LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

local variable without frontpanel object

If these indicators are only being used as flags to control multiple loops, then yes, there are better ways to do this. Your example would benefit from using a semaphore to block certain code from executing. Only the code that has acquired the semaphore can run. Take a look at the help and examples for semaphores to get a better idea if you've never used them before.
 
There are other synchronization methods that might be even better for your application, look at some examples for all of them.
 
Also, I know what you posted was only an example, but I can't see why you even need 3 loops for what you're doing. You might be better served by having one loop to handle events and another which does all the control. Have them communicate with a queue that passes the commands. This way when a command is queued, nothing else can really happen until it is done. This will keep more than one part of your code from trying to access an instrument at the same time.
0 Kudos
Message 11 of 13
(780 Views)
Geoff,

Generally it is better to have just one event structure with multiple event cases. Then have parallel loops which perform the tasks assigned by the events. The booleans should be inside one of the loops, probably the event handler loop so they get read more than just at the beginning of the program.

The sequence structures, interlocking loops, and local variables make it likely that your program will either experience race conditions or lock up in strange ways. State machines are much more robust and versatile.

Lynn
0 Kudos
Message 12 of 13
(777 Views)
Hmmm. You don't have a single control and the timeout is not wired (infinite). How do you even operate it????
 
Somehow I have the feeling that there is a much simpler solution. 🙂
0 Kudos
Message 13 of 13
(775 Views)