06-18-2014 02:03 AM
Hello,
i have an event-structure in a a while-loop that checks two buttons. a) StartMeasurement b)StopMeasurement.
Currently when i press the Start-Button then i write to a Global-Variable the string "STARTED".
In a parallel while-loop i check if the global == STARTED and execute then the Measurement.vi.
I cannot execute the meas-vi inside tof the event-structure as it would pause the whole event-structure and if someone presses the stop-button it would be executed after meas-vi is finished.
Can this work? Or should i better replace the case-structure with a second event-structure and create a "ValueSignaling" in the upper part?
I wonder if the pc is not overloaded if there are running so much loops.
In both cases i would use a second global-variable that is set if the stop-button-was pressed to stop the running Measurement-vi.
Thx for ideas
06-18-2014 02:14 AM
Do not go for 2 event structure in any case. Please check the LabVIEW design pattern and I guess Producer/Consumer would serve what you need.
06-18-2014 02:29 AM
06-18-2014 02:37 AM
But they would have different events, nothing to compete.
But it is no problem for me to use this "global-variable"-solution.
06-18-2014 03:55 AM
I once had this behavior also with different events registered in two eventstructures.
I don't know exactly what is going on under the hood but I guess there is something like:
LabVIEW: " Here is an event someone registered ... do something "
Eventstructure 1: " I take it ... oh don't know what to do .. go to default"
Eventstructure 2: "Where is my Event"
LabVIEW: "Doh"
06-18-2014 04:27 AM
Ah, thanks for explanation. Sounds really as it could happen.
I totally forgot about default case.
06-18-2014 04:34 AM
Had to clarify this,
It wouldn't be the default case (there is non in eventstructure), it would be more like a default action for not registered events in the eventloop.
Like: not registered -> throw it away
06-18-2014 05:07 AM
@CMW.. wrote:
Hey,
If you use two event loops they will "compete" with each other for events what leads to an unpredictable behavior of your program.
That's not how it's supposed to work, a Queue will consume the queued item leaving ev. others wanting, but the point of Events is one-to-many.
/Y
06-18-2014 05:12 AM
@Yamaeda wrote:
@CMW.. wrote:
Hey,
If you use two event loops they will "compete" with each other for events what leads to an unpredictable behavior of your program.
That's not how it's supposed to work, a Queue will consume the queued item leaving ev. others wanting, but the point of Events is one-to-many.
/Y
Sorry I don't understand.
06-18-2014 05:20 AM
P@Anand wrote:
Sorry I don't understand.
As you can have many listeners to an event, it's the preferred method to send information to many listeners, as "platform shutdown"-event. Thus 1 generated event will cause many listeners to react, one (producer) to many (consumer).
A queue, on the other hand, consumes the queued item and performes them in order, but you can queue from anywhere in the program, making it perfect as Many producers to one consumer. Typically "write to file" is something you dont want to parallellize. many (producers) to one (consumer).
As a side note, Many producer and Many consumer is also best implemented as events.
/Y