Hi Sebastian, great stuff! ... thanks for working on this. This is definitely a huge milestone for PLC4X as I don't know any other open-source driver supporting such a subscribe pattern. Unfortunately now I have to accept the challenge and implement something like this for Siemens ;-) ... really hope to find some information on this (And eventually which devices support it)
We should however have a look at the API and streamline it that it matches the Read API and doesn't diverge too much. One thing I did notice, is that the current way we can only subscribe a single address. I think we should extend the API to support Subscribing to multiple data blocks, just as we do in the read API. For the Siemens Write API for example I catch these multi-writes and internally map them to independent write operations. I think we should do something like this with the subscriptions. Building a SCADA system by subscribing to individual blocks and having them send from the PLC doesn't sound scalable to me. But again ... thanks a lot for your hard work on this and the ADS protocol in general. Chris Am 24.05.18, 13:48 schrieb "Sebastian Rühl" <[email protected]>: Hi together, I implemented subscription support in the plc4x api: https://github.com/apache/incubator-plc4x/blob/master/plc4j/api/src/main/java/org/apache/plc4x/java/api/connection/PlcSubscriber.java <https://github.com/apache/incubator-plc4x/blob/master/plc4j/api/src/main/java/org/apache/plc4x/java/api/connection/PlcSubscriber.java> Basically you can now „observe“ and address and the you get asynchronous notification about this address. For an example have a look on the Beckhoff ADS implementation. https://github.com/apache/incubator-plc4x/blob/master/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/ManualPlc4XAdsTest.java#L52 <https://github.com/apache/incubator-plc4x/blob/master/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/ManualPlc4XAdsTest.java#L52> As for now some details about the cycleTime and other specific attributes are hardcoded: https://github.com/apache/incubator-plc4x/blob/master/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java#L170 <https://github.com/apache/incubator-plc4x/blob/master/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java#L170> As soon as we start to implement something for S7 (and other protocols) we should get an idea what might be common for the protocols. Also I had some discussion with Christopher about the API of PlcSubscriber, whenever to reuse the PlcReadRequest/PlcReadResponse. I personally favor the explicit exposure of a Notification Type in combination with a lightweight implementation of a subscription API as seen here: https://github.com/apache/incubator-plc4x/blob/master/plc4j/api/src/main/java/org/apache/plc4x/java/api/connection/PlcSubscriber.java#L39 <https://github.com/apache/incubator-plc4x/blob/master/plc4j/api/src/main/java/org/apache/plc4x/java/api/connection/PlcSubscriber.java#L39> https://github.com/apache/incubator-plc4x/blob/master/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/PlcNotification.java <https://github.com/apache/incubator-plc4x/blob/master/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/PlcNotification.java> As always feedback is appreciated. :) Sebastian
