From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-01-2010 10:16 AM
I was talking to a CLA who gave me the following suggestion:
1) : Don’t have any data intensive operations in the event loop, use a read controls and write controls state (or read FP data/write FP data) in the consumer to get FP/user data into your main shifter and always call these two states. E.g. user hits a button that fires an event which enqueues the read FP controls state and the FP control data gets updated into the main shifter. The consumer loop, as it is churning through the states, periodically calls write FP data, to update indicator values to the user.
However, right now I can't get ahold of him so I figured i'd see what you all had to say.
I have a queued state machine (producer-consumer). My question is, I have my controls inside the event structure in the producer loop. I change a value of a control, which fires an event and queues up read fp data state in the consumer loop. How then, do I read this new value in the consumer loop like he suggests? Is my best bet in this case a functional global that holds a cluster of all controls? Bundle up the new value in the "set" case of the functional global (do this in the producer loop whe an event is fired), Then get the functional global data in the "read fp data state" in the consumer loop and feed it to a shift register to be read by all cases?
Thoughts?
03-01-2010 10:27 AM
03-01-2010 10:41 AM
for(imstuck) wrote:I was talking to a CLA who gave me the following suggestion:
1) : Don’t have any data intensive operations in the event loop, use a read controls and write controls state (or read FP data/write FP data) in the consumer to get FP/user data into your main shifter and always call these two states. E.g. user hits a button that fires an event which enqueues the read FP controls state and the FP control data gets updated into the main shifter. The consumer loop, as it is churning through the states, periodically calls write FP data, to update indicator values to the user.
However, right now I can't get ahold of him so I figured i'd see what you all had to say.
I have a queued state machine (producer-consumer). My question is, I have my controls inside the event structure in the producer loop. I change a value of a control, which fires an event and queues up read fp data state in the consumer loop. How then, do I read this new value in the consumer loop like he suggests? Is my best bet in this case a functional global that holds a cluster of all controls? Bundle up the new value in the "set" case of the functional global (do this in the producer loop whe an event is fired), Then get the functional global data in the "read fp data state" in the consumer loop and feed it to a shift register to be read by all cases?
Thoughts?
That sounds good to me.
One note...
Think about "where is the master copy of my data?". If using a FG, the master copy should be in the FG. Be careful with taking a copy out of teh FG and acting on it since once out of the FG, you could create a race condition.
Ben
03-01-2010 10:46 AM
Ben wrote:
One note...
Think about "where is the master copy of my data?". If using a FG, the master copy should be in the FG. Be careful with taking a copy out of teh FG and acting on it since once out of the FG, you could create a race condition.
Ben
I was just doing this Thanks!
03-01-2010 11:19 AM
03-01-2010 11:41 AM - edited 03-01-2010 11:43 AM
As an example of the approach Mark mentioned, you can look here. Feel free to ignore the limericks.
I will often have my controls outside of their event case, and put them in my UI update loop (assuming that the UI requires regular updating of some of the front panel objects...since I do a lot of DAQ, this is often the case). If the event structure needs to use the control value to perform an operation (as is usually the case), you can use the "NewVal" event data node to obtain the current value of the control. Of course, as you already know, you have to set your Booleans appropriately. My "stop" button is the one control that I ALWAYS have inside the event structure.