LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop events structure



FakStory wrote:
I tried to isolate the problem and it disapeared, ... it is probably a race condition...
The scary thing about race conditions is the fact that they can become temporarily invisible. Unless you know exactly what the original problem was, it might still be there and the race condition could easily re-appear, either randomly or as you make minor changes to the code.
 
You need to make sure that you really understand what the problem was and that the race condition is really eliminated. 😉
0 Kudos
Message 11 of 14
(853 Views)
great, thanks...

By the way, eliminate local variable does fix the problem? if yes, it would not be better to find an other way to stop my application in all my case? Like using many different Stop booleen in each page control in ex. ...
Neverthe less, I'm sure that is the event case that created the race condition...but I can't figure it out...

FAk
0 Kudos
Message 12 of 14
(833 Views)
Hello FakStory,
from my own experience I would advice to take altenbach's hint for serious, better to find out the reason for your problem. In my case I supposed to have fixed the problem but when I made an EXE from the program, some execution timings changed and my old problem waved and smiled again Smiley Mad
One way to approach that kind of problem is to use constructions like action engines (AE) or LV2- style globals, where LabView cares for mutual exclusion. And if this problem still occurs, it would be possible to build a protocol mechanism into this AE, storing the timestamp and caller of the AE.
And as an answer to your last post, if you use locals in a careful way, this can be an easy way to pass data between parts of the program. But if you use them to synchronize program parts, then you should have only one local (or terminal) where data is written and all other locals should be read. This doesn't prevent you from race conditions in every case but eliminates a lot of causes for race condition problems.
greets, Dave
Greets, Dave
0 Kudos
Message 13 of 14
(819 Views)

Hi FakStory,

The Event Structure itself only requires one Value Change event to execute regardless of any type of race conditions that may be present in your code. Events are queued and will be executed by the Event Structure as soon as your code reaches one. If you’d like to test how many times the Event Structure is executing the “stop”: Value Change event, I would recommend the following snippet of code. This will verify whether the event is executing more than once.

It sounds like you’re program is getting stuck elsewhere before you reach the event structure. I would check other parts of your code that depend on the “stop” button and occur sequentially before the snippet of code you provided.

Since you are using “Switch When Released” mechanical action, it is necessary to synchronize the rest of your code with this behavior. The Value Change event will fire on a change to True or False, but Local Variables may depend on a True case or False case to obtain the correct result elsewhere.

Another easy thing you could do is add a breakpoint on a line wired into your Event Structure. This will allow you to see if your code is getting to this point when you hit the stop button only one time. If it does not, you know your code is hanging elsewhere.

Regards,

Mike L



Message Edited by lion-o on 11-12-2007 06:04 PM
0 Kudos
Message 14 of 14
(791 Views)