05-08-2013 10:43 PM - edited 05-08-2013 10:46 PM
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
Solved! Go to Solution.
05-08-2013 10:48 PM
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.
05-08-2013 10:59 PM
Is there any solution other than using event structure to detects mouse events? in a state machine form perhaps?
05-08-2013 11:04 PM
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.
05-08-2013 11:24 PM
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.
05-09-2013 04:12 AM
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
05-09-2013 10:21 PM
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.
03-20-2014 06:27 AM
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?
03-20-2014 07:01 AM - edited 03-20-2014 07:02 AM
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
03-20-2014 07:03 AM
@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