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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structure inside case structure? error or LabVIEW limitation?

Solved!
Go to solution

Hi 

 

I am trying to achieve an event structure inside a case structure. The event is triggerd by a mouse event (mouse down, move and up).

This vi is trying to simulate a device behavior with some sensor, so the mouse triggered event structure, will not be there in the real working environment, so I can't remove the case structure.

 

But As I noticed that if i try to click the 2D drawing area (which my mouse events are triggered with) before I enable the boolean condition, I can no longer access any of the front panel component (button, led, etc), 

they seems to be frozen. But if the case is set to true before trying to click the 2D drawing area, everything seems to work well.

 

Is this somekind of LabVIEW bug or it is a limitation?

 

This are my vis.

 

Thanks

 

Event Inside Case

-Just a student-
0 Kudos
Message 1 of 12
(7,815 Views)

Search the forums for "Lock Front Panel".

 

Also read Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2012 Help .

 

Basically, don't bury event structures inside other structures such as a case structure.

0 Kudos
Message 2 of 12
(7,811 Views)

Is there any solution other than using event structure to detects mouse events? in a state machine form perhaps?

-Just a student-
0 Kudos
Message 3 of 12
(7,806 Views)

Get rid of the outer while loop.  It is an infinite while loop.  How do you end your VI?  You are forced to abort it.

 

Why is the event structure in the case structure?  What does the on/off button do?  What is in the other case?  Get rid of the case structure.  Use the on/off boolean where needed inside the event structure to decide whether to do something or nothing.

0 Kudos
Message 4 of 12
(7,800 Views)

Like what I have mentioned before, I am trying to simulate a device behavior, in this case a sensor array with a mouse event (mouse down, mouse move and so on). 

The outer while loop is always there since I am building a non-abort-able standalone application, and so I always use it, and there will be something there later on.

The on-off case structure is to simulate the behavior of the device (ON-OFF), in the real condition this case structure will serve as initialization of the device, later on the device will run inside the inner while loop, where a false condition of the ON-OFF boolean button will stop the loop condition and also will simulate the OFF condition of the device. 

Basically i could not remove all the structure other than the case structure, for the mouse event.

-Just a student-
0 Kudos
Message 5 of 12
(7,792 Views)
Solution
Accepted by topic author Nandha

Hello Nandha,

 

Use an Standard Architecture.

 

I have modified the code. I hope its fine now.

 

Please find the modified code attached.

 

LV 2012.

 

Regards,

Bijay

 

 

Message 6 of 12
(7,758 Views)

Thanks for your modification. So as I understood, if you want to use event based structure inside a case structure, there should not be a condition where the event structure is not running, thus the state machine will always put it to condition where the event struct. is active. Anything else is best to be avoided then.

-Just a student-
0 Kudos
Message 7 of 12
(7,716 Views)

I am also having trouble with this. I have read the caveats that event structures should not be inside case structures. But the basic state machine design is made up of a case structure with a case for each state. If I want to use an event structure in one of my states, how do I get around this?

 

I also have my stop control in a stop case as part of the state machine. Do I still have to make a stop event in the event structure that is in a state/case that wouldn't normally stop my program?

 

I think my problem is that every event in my event case is triggered by a user clicking a control on the front panel. If this isn't happening then my state machine can never transition. How can I make the event structure active with a kind of dummy event so that it doesn't hang?

0 Kudos
Message 8 of 12
(7,337 Views)

Use a producer/consumer event based architecture. It focuses and solves on limitations created by the approach of using event structure in specific cases of a state machine.

It is more complicated than a classic state machine, but still considered to be one of the basic frameworks of VIs.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 9 of 12
(7,313 Views)

@KarlosAmigos wrote:

I am also having trouble with this. I have read the caveats that event structures should not be inside case structures. But the basic state machine design is made up of a case structure with a case for each state. If I want to use an event structure in one of my states, how do I get around this?

 

I also have my stop control in a stop case as part of the state machine. Do I still have to make a stop event in the event structure that is in a state/case that wouldn't normally stop my program?

 

I think my problem is that every event in my event case is triggered by a user clicking a control on the front panel. If this isn't happening then my state machine can never transition. How can I make the event structure active with a kind of dummy event so that it doesn't hang?


The problem with having an event in your state machine is that you are using one loop for it, which can cause (imagine this) your front panel and events to freeze while other parts of your code are being executed.

 

The solution to this is to use a producer / consumer archictecture. Google search of this phrase returns a lot of results. You may also want to browse through this:

http://www.ieee.li/pdf/viewgraphs/labview_design_patterns.pdf

Message 10 of 12
(7,310 Views)