jisotalo / ads-client

Unofficial Node.js ADS library for connecting to Beckhoff TwinCAT automation systems using ADS protocol.
https://jisotalo.fi/ads-client/
MIT License
80 stars 17 forks source link

On-change subscription is re-triggered when restarting application #96

Closed dotKokott closed 2 years ago

dotKokott commented 2 years ago

I noticed that a on change subscription callback will be called again when the application is restarted (ergo the subscription re-initialized) although a previous run of the application has consumed the subscription already.

Following steps:

  1. Subscribe to changes of "variableA" that is initially false.
  2. variableA changes to true
  3. Callback subscribing to variableA triggers
  4. Call disconnect and close application
  5. Restart application, re-initialize subscriptions
  6. Callback subscribing to variableA triggers again

Is this desired behaviour? Is there a suggested way to work around this as I usually just want to consume an onchange once per change.

Thank you!

jisotalo commented 2 years ago

Hi @dotKokott!

Sorry for late reply. If I remember right this is a standard feature of PLC subscription.

However I will check it out.

jisotalo commented 2 years ago

I checked this using latest ads-client and also C# library by Beckhoff. Both have the same behaviour.

When subscribing to a variable (creating device notification), the target PLC system always sends the latest value.