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

Reply via email to