bjustice Posted February 1, 2019 Report Share Posted February 1, 2019 I made a fun piece of code, and thought that I'd share. Maybe it'll spark some good discussion. Here it is: Push-Notifier.zip I wanted to accomplish 2 things with this code: 1) I wanted to be able to create a notifier that I can register as a user event. Basically, I want a user event to be generated whenever a new notification is sent. 2) When I register for a user event, I want to be able to also force the event structure to generate a user event using the most recent notification. (Helpful for initialization of data in the event structure) Demo VI looks like this: Anyways, thought this might be fun to share 1 Quote Link to comment
bjustice Posted February 1, 2019 Author Report Share Posted February 1, 2019 Oh, and it's saved in 2018 and makes heavy use of VIMs. So, apologies to those using older versions of LabVIEW Quote Link to comment
drjdpowell Posted February 2, 2019 Report Share Posted February 2, 2019 (edited) 11 hours ago, bjustice said: When I register for a user event, I want to be able to also force the event structure to generate a user event using the most recent notification. (Helpful for initialization of data in the event structure) This is very useful behavior, as it simplifies initialization code quite a lot, and eliminates almost all worries about "who starts first" among communicating modules. I have a similar feature in Messenger Library; I call it a "State Notification" as distinct from an "Event Notification", as the type of data where one needs the most recent value is state data. Edited February 2, 2019 by drjdpowell Quote Link to comment
shoneill Posted February 5, 2019 Report Share Posted February 5, 2019 I had a look at the code, but I guess it's lost on me a little. So the idea is that the code allows for stateful sending of events, that one can recall immediately the last value sent via Event (stored in a Notifier)? Quote Link to comment
bjustice Posted February 5, 2019 Author Report Share Posted February 5, 2019 drjdpowell touched upon the primary (and initial) purpose for the code. I had an issue where I wanted to use user events, but the rule of "who starts first" came into play. This eliminated that worry. I could spin up a sub-process, register it for the user event, and force the user event case (only in that subprocess) to initialize with the most recent data. And, it's clean! Notice how I'm able to share the "mycluster" user event case structure with both the initialization UE and the normal UE. No tacky need for another case structure event that only handles first call initialization, or some other similar thing. Quote Link to comment
shoneill Posted February 7, 2019 Report Share Posted February 7, 2019 To make sure no Events are lost I usually just register the user event at the moment of creation and pass out the event registration refnum for the event. Then, any events sent before the Event loop is running are not lost, they are stored within the event registration refnum queue. A different idea is the ability to get the last sent value. I typically involve the event loop in this as it "owns" the values and other processes may actually update the values (such as internal consistency checks) so that the last "sent" value is not actually up-to-date. But I canunderstand the idea behind being able to efficiently get this value back. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.