Beckhoff / ADS

Beckhoff protocol to communicate with TwinCAT devices.
MIT License
493 stars 194 forks source link

Event driven read plc values #173

Closed zoltyczerwony closed 1 year ago

zoltyczerwony commented 1 year ago

Hi, i'd like to ask how to approach this problem: i have 3 vars that i would like to monitor, but i'm interested only on change of value not on value itself and as a callback i would like to read 10 other vars. Using c++ and AdsSyncAddDeviceNotificationReq i'm not able to do this - it reacts on var change but when i try to read other var i get exception. Should i be using multi threading or remove notification, read vars and add new notification?

pbruenn commented 1 year ago

Sounds like you are trying that in the context of your notification callback? Yes, you have to decouple your callback from the next AdsRequest, so what I would do is let the notification callback wakeup another thread which updates the 10 other variables.