10-04-2012 06:55 PM
Hi
Every one
I have created multiple producer/connsumer loops.
One producer loop is event case which wait from control value change from FP and then send queue to consumer loop (control solenoid valve)
The other separate producer loop is for NI 9213 to display Temp data, I use other consumer loop to acquire data from NI9213
I am not sure if I can use notification to stop both pair of loops.
I hope when I click Stop The whole Process Button in FP, then, True value is send to Nofication. Then NI 9213 Producer loop get this message to stop loop. Right now stop process button only control solenoid loop since this button is in event structure.
I tried notification. When I put wait on notification in NI 9213 loop, this loopkeep waiting any notification and doesnot monitor the temp data
Thanks
Solved! Go to Solution.
10-04-2012 07:58 PM
Sounds like you need to set the timeout value for Wait on Notification, since the default is to wait forever. Then you need to check if the wait timed out, and only do something (exit the loop) if timed out is false, meaning a new notification is available. You might also want to check for errors coming out of the Wait on Notification, since if one loop destroys the notifier it will cause an error in any Wait on Notification loops that use that notifier.
If this doesn't answer your question, please attach your VI to your reply.
10-04-2012 08:51 PM
OHOH...
yes . It works
Thank you so much
10-09-2012 08:48 PM
Hello
Now I have a new question. I also need to send message to other 3 consumer loops to begin save data . For example, when NI 9213 Temp is higher than 35 degree C. I can send msg to notifier in producer loop. Other consumer loops will wait notification(time out 10ms). When they received " True" which is coming from producer loop and then start to save data in a file.
Right now I put wait on notification (time out 10ms)in consumer loop, which is connected to case structure , true for saving data and false for not saving data.
In producer loop, once I send "T" to notifier, consumer loop start to save but on next loop, It will stop saving it seems to output False to case selector.
Is there other way to keep saving until I send false to notifier? I may use time out terminal ??
10-09-2012 09:48 PM
Have you considered using a queued message (often caled a queue state machine) rather than using a notifier? Also, I generally try to use explicit messages to control consumer loops rather than simply using a boolean. Explicit messages are more explicit and if you use a general message construct (a cluster with a message type (string or ENUM) and a variant) you can pass any type pf data specific to a particular message. If no data is required then the data portion will be empty. The one down side with using queues is that you will need to send the message to each queue rather than broadcast via a notifier. In your case it is inefficient to check the notifier every iteration because it only has meaning once.
Alternatively you can use a tradiitional state machine in the consumer with one of your states that will simply wait on the start notification. Once received you transition to another state and only return to the start if required.
10-09-2012 09:49 PM
One simple solution is to save the most recent notification in a shift register, and use that value when timeout is true (a Select node makes this easy).
10-10-2012 12:51 PM
Thanks.
I made like this
When I click save ,consumer loop will start save immediately
But When I click stop saving , after one loop it will stop. because the SR value is still true, so saving data loop will run one more loop then stop
Is there other methods to improve this?
Thanks
10-10-2012 01:05 PM - edited 10-10-2012 01:07 PM
@MYLONG wrote:
Thanks.
I made like this
When I click save ,consumer loop will start save immediately
But When I click stop saving , after one loop it will stop. because the SR value is still true, so saving data loop will run one more loop then stop
Is there other methods to improve this?
Thanks
you are stopping the second loop on "error" only...if you want to stop, you wire a stop local to the second loop or send a messege "stop" to a "stop" case with a true bool wired directly to your 2nd loop stop
10-10-2012 01:19 PM - edited 10-10-2012 01:44 PM
try queues as mark had suggested...
also look at Caveats and Recommendations when Using Events and LabVIEW Error Handling Best Practices , enforce data flow by using error clusters and dont forget to merge errors
10-10-2012 01:22 PM
I would go with what Mark suggested...
The advantage of the queue over Notifier is that the queue has a buffer; whereas the notifier is like a single element queue.
On the other hand, you can also wire a cluster to the notifier which would do more than simply sending a boolean or a string message, or an enum (although enums are quite useful). You can send combinations thereof.. You could use the enum to select a state and the boolean could be to pick choice(s) within that state. The message could provide additional information.
It all depends on how you design the solution. And how you want the software to behave...