10-28-2007 03:15 PM
10-28-2007 03:30 PM - edited 10-28-2007 03:30 PM
Message Edited by Ravens Fan on 10-28-2007 04:33 PM
10-28-2007 04:05 PM
@Ravens Fan wrote:
NEVER have multiple event structures that share the same events.
Actually, that's OK. 🙂 NOT OK is having multiple event structures in the same sequence structure.
See also: http://forums.ni.com/ni/board/message?board.id=170&message.id=278981#M278981
First for the definition of a state machine. You don't have a state machine by any conventional definition of it, but a state worm. 😉
A state machine has a single main state loop and can transition from any state to any other state depending on the needs. You can switch states, or repeat states as often as needed. Your "states" must execute in a forced linear order and then all's over. Not a state machine!!!
I think you should take about two steps back and rethink your code architecture. What UI events need to be handled? What needs to occur in parallel?
Remember: An event structure is always ready and does not depend on dataflow. If an event is set to lock the front panel until it complete (the default setting) and dataflow prevents it from executing, your entire program will deadlock.
10-28-2007 06:58 PM
@altenbach wrote:
@Ravens Fan wrote:
NEVER have multiple event structures that share the same events.
Actually, that's OK. 🙂 NOT OK is having multiple event structures in the same sequence structure.
See also: http://forums.ni.com/ni/board/message?board.id=170&message.id=278981#M278981
That's interesting. I had always thought I read more messages discouraging such a thing rather than saying it was okay. Your link lead me to another thread with this message. http://forums.ni.com/ni/board/message?board.id=170&message.id=245793#M245793. Now that thread was mainly concentrating on registered user events which would be a different, but related animal.
So if you have 2 event structures they each have their own event queue? So if you have a common event, one structure pulls it off its event queue and it does not affect the other structure's event queue? I guess the inherent problem with this particular VI was that the second event structure locked the front panel. Since the code never got to that 2nd event structure because the first loop never stopped because the change was from true to false. After reading your post and the others, I did some experimentation and turned off the Lock front panel on the 2nd structure, and that prevented the lockup of the program.
Overall, the example VI still shows problems with the architecture and I think your answer should put the original poster on the right track. I think as a rule I would probably never put the same event in multiple structures, I feel there are better ways to communicate the same event between different parts of a program, but I learned something by reading your reply and about how the event structures work in the background. Thanks.
10-28-2007 08:50 PM
10-28-2007 08:57 PM
10-29-2007 06:17 AM
10-29-2007 10:24 AM - edited 10-29-2007 10:24 AM
Message Edited by Ravens Fan on 10-29-2007 11:24 AM