01-24-2019 01:42 PM
I am running LV 2016 with the DSC. The code uses shared variable value change events. When the event structure initializes, LV will fire each of the registered SV events one time with the variable's current value. I have been trying to get around this behavior with little luck. The attached code is what I have come up with so far. The curious thing is that is I run it with execution highlighting turned on, the code does what I want. However, if I turn off highlighting the initial events still fire.
Any ideas would be helpful, or if you have any thoughts on alternative means for getting to my goal that would be good too...
Mike...
01-24-2019 09:27 PM - edited 01-24-2019 09:34 PM
Try adding an explicit DataSocket Read after enabling value change events:
Edit: It seems like just adding a 500ms wait after enabling value change events also works, as alluded to by the execution highlighting. So maybe the DataSocket Read is just delaying things enough (it takes around 350ms).
01-24-2019 10:11 PM
Can you use a "Flush Event Queue Function" function on the "event registration refnum" before it gets to the Event Structure and wire a zero to the "keep most recent" input?
01-25-2019 07:29 AM
I know DSC enables the ability to set an initial value for each shared variable; do you happen to be using that property within the shared variable library that you have setup? Not sure if that is tied to your issue or not, but I'm wondering if some implicit shared variable value initialization is happening within the NI Tagger service soon after the VI is run, and causing the event structure value change events to trigger. I think the delay work-around that others have mentioned is consistent with that value initialization theory.