ciplink 0.3.0__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ciplink-0.3.0 → ciplink-0.3.2}/Cargo.lock +4 -4
- {ciplink-0.3.0 → ciplink-0.3.2}/Cargo.toml +1 -1
- {ciplink-0.3.0 → ciplink-0.3.2}/PKG-INFO +26 -1
- {ciplink-0.3.0 → ciplink-0.3.2}/README.md +25 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/cip.rs +9 -3
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/logix/mod.rs +1 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/logix/rw.rs +30 -0
- ciplink-0.3.2/crates/ciplink/src/logix/trend.rs +787 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/src/lib.rs +114 -0
- ciplink-0.3.2/crates/ciplink-py/tests/test_trend.py +127 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/__init__.py +1 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/_version.py +1 -1
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/logix_driver.py +16 -0
- ciplink-0.3.2/python/ciplink/trend.py +105 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/LICENSE +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/Cargo.toml +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/README.md +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/epath.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/error.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/identity.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/lib.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/logix/auth.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/logix/bundle.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/logix/bundle_data.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/logix/descriptions.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/logix/driver.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/logix/metadata.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/logix/tag_cache.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/logix/types.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/packets.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/reader.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/slc/driver.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/slc/mod.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/slc/pccc.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/status.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/tables.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/transport.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/types.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink/src/value.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/.gitignore +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/Cargo.toml +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/bench/cpu_bench.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/bench/tags_bench.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/build.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/src/defs.rs +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/tests/conftest.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/tests/dump_driver.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/tests/test_binding.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/tests/test_definitions.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/tests/test_parity.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/tests/test_sim_checks.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/crates/ciplink-py/tests/test_tagserver.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/pyproject.toml +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/_logix_bundle_codec.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/_logix_metadata_bundle.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/cip/__init__.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/cip/data_types.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/cip/object_library.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/cip/pccc.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/cip/services.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/cip/status_info.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/cip_driver.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/const.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/custom_types.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/exceptions.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/logger.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/logix_auth.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/logix_metadata.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/map.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/packets/__init__.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/packets/base.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/packets/cip.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/packets/ethernetip.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/packets/logix.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/packets/util.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/py.typed +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/slc_driver.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/socket_.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/tag.py +0 -0
- {ciplink-0.3.0 → ciplink-0.3.2}/python/ciplink/util.py +0 -0
|
@@ -70,7 +70,7 @@ dependencies = [
|
|
|
70
70
|
|
|
71
71
|
[[package]]
|
|
72
72
|
name = "ciplink"
|
|
73
|
-
version = "0.3.
|
|
73
|
+
version = "0.3.2"
|
|
74
74
|
dependencies = [
|
|
75
75
|
"chacha20poly1305",
|
|
76
76
|
"getrandom 0.3.4",
|
|
@@ -85,7 +85,7 @@ dependencies = [
|
|
|
85
85
|
|
|
86
86
|
[[package]]
|
|
87
87
|
name = "ciplink-ffi"
|
|
88
|
-
version = "0.3.
|
|
88
|
+
version = "0.3.2"
|
|
89
89
|
dependencies = [
|
|
90
90
|
"ciplink",
|
|
91
91
|
"ciplink-sim",
|
|
@@ -95,7 +95,7 @@ dependencies = [
|
|
|
95
95
|
|
|
96
96
|
[[package]]
|
|
97
97
|
name = "ciplink-py"
|
|
98
|
-
version = "0.3.
|
|
98
|
+
version = "0.3.2"
|
|
99
99
|
dependencies = [
|
|
100
100
|
"ciplink",
|
|
101
101
|
"indexmap",
|
|
@@ -106,7 +106,7 @@ dependencies = [
|
|
|
106
106
|
|
|
107
107
|
[[package]]
|
|
108
108
|
name = "ciplink-sim"
|
|
109
|
-
version = "0.3.
|
|
109
|
+
version = "0.3.2"
|
|
110
110
|
dependencies = [
|
|
111
111
|
"ciplink",
|
|
112
112
|
"indexmap",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ciplink
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Classifier: Development Status :: 4 - Beta
|
|
5
5
|
Classifier: Intended Audience :: Developers
|
|
6
6
|
Classifier: Intended Audience :: Manufacturing
|
|
@@ -63,6 +63,7 @@ flowchart LR
|
|
|
63
63
|
| **Tag discovery** | the tag list and UDT definitions are uploaded on connect, or loaded on first use with `lazy_tags`; a binary tag cache makes restarts near-instant |
|
|
64
64
|
| **Online-edit safe** | tags are addressed by instance ID and checked against the controller's tag-table version on every read and write, so an online edit never silently returns the wrong tag |
|
|
65
65
|
| **Extras** | tag descriptions, PLC clock, device discovery, module identity, and a simulated controller for testing |
|
|
66
|
+
| **Trends** | the controller samples tags at a fixed period (down to 1 ms) and the driver uploads them in batches, like a Studio 5000 trend |
|
|
66
67
|
|
|
67
68
|
## Install
|
|
68
69
|
|
|
@@ -139,6 +140,30 @@ plc.write_tag("Counter", 0);
|
|
|
139
140
|
```
|
|
140
141
|
</details>
|
|
141
142
|
|
|
143
|
+
## Trends
|
|
144
|
+
|
|
145
|
+
For data faster than polling gives, a trend has the controller sample tags every `period_ms` into its own trend
|
|
146
|
+
buffer (the trend object Studio 5000 uses), on a connection of its own. Each sample carries the controller's
|
|
147
|
+
timestamp. A pen can be any atomic tag, member or array element of up to 32 bits (BOOL, SINT, INT, DINT, USINT,
|
|
148
|
+
UINT, UDINT, REAL) or a bit (`Tag.3`). 64-bit types (LINT, LREAL) can't be trended. The controller deletes the trend
|
|
149
|
+
when it's closed or when its connection drops. Every binding has trends: `plc.trend(...)` in Python, Rust and C++,
|
|
150
|
+
`plc.Trend(...)` in C#, `ciplink_trend_start` in C.
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
import time
|
|
154
|
+
from ciplink import LogixDriver
|
|
155
|
+
|
|
156
|
+
with LogixDriver("192.0.2.10") as plc:
|
|
157
|
+
with plc.trend("Motor.Speed", "Tank.Level", "Valve.Open", period_ms=1) as trend:
|
|
158
|
+
while trend.running:
|
|
159
|
+
time.sleep(0.1)
|
|
160
|
+
for sample in trend.read(): # TrendSample(timestamp_us, elapsed_us, values)
|
|
161
|
+
print(sample.timestamp, sample.values)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
`capacity` (default 4096) bounds the samples waiting for `read()`; the oldest are dropped when it is full and
|
|
165
|
+
counted in `dropped_samples`. `duration` (seconds) stops the trend by itself.
|
|
166
|
+
|
|
142
167
|
## Test without a PLC
|
|
143
168
|
|
|
144
169
|
`ciplink-sim` is a simulated Logix or SLC controller that speaks real EtherNet/IP. Load it with tags and UDTs from
|
|
@@ -40,6 +40,7 @@ flowchart LR
|
|
|
40
40
|
| **Tag discovery** | the tag list and UDT definitions are uploaded on connect, or loaded on first use with `lazy_tags`; a binary tag cache makes restarts near-instant |
|
|
41
41
|
| **Online-edit safe** | tags are addressed by instance ID and checked against the controller's tag-table version on every read and write, so an online edit never silently returns the wrong tag |
|
|
42
42
|
| **Extras** | tag descriptions, PLC clock, device discovery, module identity, and a simulated controller for testing |
|
|
43
|
+
| **Trends** | the controller samples tags at a fixed period (down to 1 ms) and the driver uploads them in batches, like a Studio 5000 trend |
|
|
43
44
|
|
|
44
45
|
## Install
|
|
45
46
|
|
|
@@ -116,6 +117,30 @@ plc.write_tag("Counter", 0);
|
|
|
116
117
|
```
|
|
117
118
|
</details>
|
|
118
119
|
|
|
120
|
+
## Trends
|
|
121
|
+
|
|
122
|
+
For data faster than polling gives, a trend has the controller sample tags every `period_ms` into its own trend
|
|
123
|
+
buffer (the trend object Studio 5000 uses), on a connection of its own. Each sample carries the controller's
|
|
124
|
+
timestamp. A pen can be any atomic tag, member or array element of up to 32 bits (BOOL, SINT, INT, DINT, USINT,
|
|
125
|
+
UINT, UDINT, REAL) or a bit (`Tag.3`). 64-bit types (LINT, LREAL) can't be trended. The controller deletes the trend
|
|
126
|
+
when it's closed or when its connection drops. Every binding has trends: `plc.trend(...)` in Python, Rust and C++,
|
|
127
|
+
`plc.Trend(...)` in C#, `ciplink_trend_start` in C.
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
import time
|
|
131
|
+
from ciplink import LogixDriver
|
|
132
|
+
|
|
133
|
+
with LogixDriver("192.0.2.10") as plc:
|
|
134
|
+
with plc.trend("Motor.Speed", "Tank.Level", "Valve.Open", period_ms=1) as trend:
|
|
135
|
+
while trend.running:
|
|
136
|
+
time.sleep(0.1)
|
|
137
|
+
for sample in trend.read(): # TrendSample(timestamp_us, elapsed_us, values)
|
|
138
|
+
print(sample.timestamp, sample.values)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`capacity` (default 4096) bounds the samples waiting for `read()`; the oldest are dropped when it is full and
|
|
142
|
+
counted in `dropped_samples`. `duration` (seconds) stops the trend by itself.
|
|
143
|
+
|
|
119
144
|
## Test without a PLC
|
|
120
145
|
|
|
121
146
|
`ciplink-sim` is a simulated Logix or SLC controller that speaks real EtherNet/IP. Load it with tags and UDTs from
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
//! connection, holding its lock across multi-step operations.
|
|
6
6
|
|
|
7
7
|
use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs, UdpSocket};
|
|
8
|
-
use std::sync::{Mutex, MutexGuard};
|
|
8
|
+
use std::sync::{Arc, Mutex, MutexGuard};
|
|
9
9
|
use std::time::{Duration, Instant};
|
|
10
10
|
|
|
11
11
|
use crate::epath::{LogicalValue, Segment, encode_epath, parse_cip_route, parse_connection_path};
|
|
@@ -149,7 +149,7 @@ impl GenericReply {
|
|
|
149
149
|
/// Matches the Python `CIPDriver`: the same requests in the same order, the same sequence counter, the same
|
|
150
150
|
/// packing and fallback decisions. A transport failure in the middle of a request drops the connection.
|
|
151
151
|
pub struct CipConnection {
|
|
152
|
-
connector: Connector
|
|
152
|
+
connector: Arc<Connector>,
|
|
153
153
|
transport: Option<Box<dyn Transport>>,
|
|
154
154
|
path: String,
|
|
155
155
|
host: String,
|
|
@@ -204,7 +204,7 @@ impl CipConnection {
|
|
|
204
204
|
check_socket_timeout(options.socket_timeout)?;
|
|
205
205
|
check_connection_size(options.connection_size)?;
|
|
206
206
|
Ok(CipConnection {
|
|
207
|
-
connector,
|
|
207
|
+
connector: Arc::new(connector),
|
|
208
208
|
transport: None,
|
|
209
209
|
path: path.to_owned(),
|
|
210
210
|
host,
|
|
@@ -223,6 +223,12 @@ impl CipConnection {
|
|
|
223
223
|
})
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
/// A connector opening transports like this connection's (for another connection to the same device).
|
|
227
|
+
pub(crate) fn share_connector(&self) -> Connector {
|
|
228
|
+
let connector = Arc::clone(&self.connector);
|
|
229
|
+
Box::new(move |host, port, timeout| connector(host, port, timeout))
|
|
230
|
+
}
|
|
231
|
+
|
|
226
232
|
/// The path the connection was created with.
|
|
227
233
|
pub fn path(&self) -> &str {
|
|
228
234
|
&self.path
|
|
@@ -28,6 +28,14 @@ use crate::types::Elementary;
|
|
|
28
28
|
use crate::value::py_str_repr;
|
|
29
29
|
use crate::{Error, ErrorKind, Result, TagError, Value};
|
|
30
30
|
|
|
31
|
+
/// What a trend pen samples: the tag its path names (the word of a BOOL array element, the integer of a bit),
|
|
32
|
+
/// that tag's type, and the bit of a BOOL.
|
|
33
|
+
pub(crate) struct PenTarget {
|
|
34
|
+
pub plc_tag: String,
|
|
35
|
+
pub data_type: TypeRef,
|
|
36
|
+
pub bit: Option<u32>,
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
/// Most elements one Read/Write Tag service carries (its element count is a UINT).
|
|
32
40
|
const MAX_SERVICE_ELEMENTS: usize = 65535;
|
|
33
41
|
/// Reply bytes of a write in a multi-service packet: sequence and reply header.
|
|
@@ -1267,6 +1275,28 @@ impl Logix {
|
|
|
1267
1275
|
.collect()
|
|
1268
1276
|
}
|
|
1269
1277
|
|
|
1278
|
+
/// What a trend pen of `tag` samples, parsed like a read of it.
|
|
1279
|
+
pub(crate) fn pen_target(&mut self, tag: &str) -> Result<PenTarget> {
|
|
1280
|
+
self.conn.ensure_forward_open("trend")?;
|
|
1281
|
+
let p = self.parse_tag_request(tag, Rw::Read, 0)?;
|
|
1282
|
+
if p.elements != 1 || p.bool_elements.is_some() {
|
|
1283
|
+
return Err(Error::request(format!(
|
|
1284
|
+
"Cannot trend {tag}: a pen is one value, not an element count"
|
|
1285
|
+
)));
|
|
1286
|
+
}
|
|
1287
|
+
let bit = match (&p.info, p.bit) {
|
|
1288
|
+
// a bit of an integer, or a BOOL array element's bit in its word
|
|
1289
|
+
(_, Some(b)) => u32::try_from(b).ok(),
|
|
1290
|
+
(Info::Member(m), None) => m.bit.map(u32::from),
|
|
1291
|
+
(Info::Tag(t), None) => t.bit_position.map(u32::from),
|
|
1292
|
+
};
|
|
1293
|
+
Ok(PenTarget {
|
|
1294
|
+
data_type: p.info.view().data_type().clone(),
|
|
1295
|
+
plc_tag: p.plc_tag,
|
|
1296
|
+
bit,
|
|
1297
|
+
})
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1270
1300
|
/// `read`: two attempts, the second after the tag definitions were loaded again because the tag table
|
|
1271
1301
|
/// changed during the first.
|
|
1272
1302
|
pub(crate) fn read_tags(&mut self, tags: &[&str]) -> Result<Vec<TagResult>> {
|