ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Properly close multi loop application

Can someone show me an example on how to properly close an multi-WHILE LOOP application?




0 Kudos
Message 1 of 6
(3,775 Views)

There are many possibilities. (local variables on one singe stop button for example). I prefer event structures.

see e.g.: http://forums.ni.com/ni/board/message?board.id=170&message.id=136388#M136388

 

0 Kudos
Message 2 of 6
(3,773 Views)

Don't want to hijack the thread....   but isn't it bad style to have multiple event structures like that?   Or is that only a problem for dynamically registered event?  

I'm thinking about this thread: http://forums.ni.com/ni/board/message?board.id=170&message.id=237840&view=by_date_ascending&page=4

 

Personally, I generally use local variable/property nodes, or have a (command) queue in the loop, with either a special stop command for the loop,  or the loop simply terminates when the queue is unavailable.   (Like the producer/consumer design patterns that you can select when creating a new vi.)

Message Edited by Anthony de Vries on 10-18-2007 05:27 PM

0 Kudos
Message 3 of 6
(3,740 Views)
 

I don't really use dynamic events, so I cannot comment on that specific thread, but for plain events I never had any issues with multiple event structures tied to the same FP event.

In my opinion, the following are OK:

  • Multiple event structures serving the same FP event (e.g. "stop:value changed" in this case). Each in it's own while loop.

Not OK are the following (again in my opinion):

  • Multiple events in the same loop (unless all are "transparent" with 0ms timeout). Still, this is not something I would do.
  • event structures within event structures
  • event structures inside case structures
  • event structures inside certain sequences (if any of the frames contains delays).
  • events containing long delays.
  • events NOT in a while loop (except for dialog style VIs that don't have any while loops)
  • events containing interactive while loops (short "math" while loops are of course ok, e.g. as used in a newton iteration)
  • ...

In summary: any event topology that prevents the event from being serviced by the code dataflow within a short time is NOT OK.

This is my own list. Have a look at the NI documentation for other more details. I cannot find any objection against firing multiple event structures in parallel. 🙂

0 Kudos
Message 4 of 6
(3,727 Views)


@Anthony de Vries wrote:
Personally, I generally use local variable/property nodes, ...

My solution has the advantage that the loop rate can be extremely long and the stop still occurs immediately. Imagine you have a logging loop that takes a snapshot every hour, using the event timeout. Pressing the stop breaks the timeout and finishes the loop immediately and you can even trigger a final snapshot if desired.

Sure you can use other methods to do the same, but it will probably be more complicated.

0 Kudos
Message 5 of 6
(3,725 Views)
I absolutely agree, your solution of using multiple event structures is very neat.   I think I will start to use them as well, for exactly the reasons you mention.    Just wanted to make sure I'm not going to run into troubles...
0 Kudos
Message 6 of 6
(3,719 Views)