LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event-Loop and parallel while-loop or better two event-loops?

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

0 Kudos
Message 1 of 26
(3,653 Views)

 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.

-----

The best solution is the one you find it by yourself
Message 2 of 26
(3,648 Views)

Hey,

 

If you use two event loops they will "compete" with each other for events what leads to an unpredictable behavior of your program.

Message 3 of 26
(3,640 Views)

But they would have different events, nothing to compete.

But it is no problem for me to use this "global-variable"-solution.

 

0 Kudos
Message 4 of 26
(3,634 Views)

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"

 

 

Message 5 of 26
(3,607 Views)

Ah, thanks for explanation. Sounds really as it could happen.

I totally forgot about default case.

0 Kudos
Message 6 of 26
(3,600 Views)

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

Message 7 of 26
(3,597 Views)

@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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 26
(3,585 Views)

@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.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 9 of 26
(3,580 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 10 of 26
(3,576 Views)