LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State machine (UI) with big changes due to events - null event?

I have a complex gui, lots of controls, but not lots of compute required.   It operates in stages: startup, broad scope input, subscope input, processing.  There are several different broad scopes that define the sub-scopes.  The pattern for that is state machine. 

 

There are secondary buttons not related to the scope: reset, export current results, exit.  These need to interrupt or change the target state in the state machine. 

 

So how do I make an event handler that, if there is no event, it doesn't change the target next state, but if there is an event of interest, it can change the desired state?

 

Is there a "null event" where I can say "in the case of no events, just be a pass-through, but if there is an event of interest, you can transform"?

0 Kudos
Message 1 of 6
(2,235 Views)

Please show some code to illustrate your question. If no event happens, it should not do anything, so what are you trying to prevent?

0 Kudos
Message 2 of 6
(2,221 Views)

I can't show internal stuff in a public forum.  It would be a "career limiting" action.

 

It takes a little while to contrive realistic dummy codes to use.

 

Is the "timeout" a "nothing happened in x amount of time"?  That might work for my case.  That might qualify as a "dummy event".

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

Still not clear why you need a dummy or timeout event if nothing happens.

0 Kudos
Message 4 of 6
(2,208 Views)

Not sure what you are looking for, but, this is what I do, if I am understanding your question correctly.

 

I use the JKI State Machine which has an event structure in it. This should would if you are using multiple loops or a single loop.

 

If I need to interrupt a long sequence of states, for example, if I am firing a laser for a spectrum, I add a short timeout and go to an idle state where a command can be received to interrupt the sequence.

 

For example:

  1. Set Timeout >> 10 ms
  2. Laser: Initiate
  3. Idle (Timeout for 10 ms)
  4. Laser: Fire
  5. Data: CollectSpectrum
  6. Data: Analyze
  7. Data: Plot
  8. Set Timeout >> -1 (No Timeout)

So for a "normal" sequence the is a 10 ms wait in between the a couple of the states, you can add as many as you need. If a user hits the "Stop Laser" button, that command can be received in the idle state and change the sequence of events.

 

mcduff

Message 5 of 6
(2,196 Views)

Well, you can build an Event Structure as an "Event" State and schedule it whenever you need to.  One way to do this would be to schedule it after every "normal" State, and have a second Shift Register with "and if there's no Event pending, do this, instead".  I cobbled together a little demo (in LabVIEW 2016, which is why I included a Snippet to show the point, just in case you can't open my VI -- you should be able to "fill in the Blanks" yourself).  Note that I use a Timeout Event, with the Timeout set to 0 (so it exits immediately if there is no Event, and does whatever is specified if there is No Event Pending, i.e. the normal "Next State".  In my haste, I neglected putting in the Error Line ...

DEMO SSM with Events.png

I'm sure there are more elegant ways to do this, but this, at least, gets Events into the Simple State Machine model and allows an Event to "change the State" and potentially alter the course of the SSM.

 

Bob Schor

 

0 Kudos
Message 6 of 6
(2,193 Views)