Jump to content

Recommended Posts


Just wanna have you advice...

I used to use state machine :  

While Loop

    Event UI struct

          In the timeout (10ms) case the conditionnal structure 


For me advantage:

 At each step i can catch UI Event to take account user ineraction with the sequence


 If the sequence needs to chain two step quickly i will wait the timeout (10ms)  between the step...


Waiting your comments...



Link to comment



There are many possible points for comment here, but I recommend that eventually you adopt a design that separates the user interface and its behavior from the application business logic.  That is the high-level architectural answer.


My suggestion above does not completely eliminate execution competition of the sort you describe, however.  An event timeout is a bit troublesome in that the timeout occurs only if the specified timeout time has elapsed since the occurrence of any event the structure handles.  (If there are enough events, the timeout may never occur.)  I prefer not to use event structure timeouts for essential control loops, therefore. One approach I use is to have a parallel timed loop generate user events that my primary event-structure-in-while-loop handles.  This is an improvement since "interrupt" events generate at regular intervals, and the event structure handles them as soon as possible. There can still be some jitter, however, from the arrival of competing events, unless one examines and sorts the event queue (which may be possible in LabVIEW 2013, but I haven't attempted this yet). 

Link to comment

Thanks Paul,

If i understand, the right thing to do is a loop with event-struct which enqueue state modification  in a queue and a parallel loop for state machine.

The parallel loop check at each loop if a new state changement is in the queue before conditionnal struct if no data in the queue state machine execute next state . But if state machine change UI Display it must me done in the state machine loop or in the loop-event struct with user-event to transmit data ?

Link to comment



Well, a couple things:

1) The application need only use the events API.  It will not need the queue API (although events arrive in an event queue).

2) I do not suggest sending state modifications to the controller.  I use a Model-View-Controller (MVC) architecture.  The View (or another entity) sends data (which may be commands) to the Controller, which handles these data events, telling the Model what to do according to the situation; this may include instructions to change state.  The model publishes its state to the view.  A full MVC implementation from scratch may be a little much for now, although I think it is a great solution if you can invest the time.  Otherwise you can use some of the hints.  One of the hints (a huge hint, actually) is to use an interrupt event as one of the events to send to the controller.


I actually use the State Pattern to implement a true state machine within MVC.  If you want ro read more on the State Pattern you can look at https://decibel.ni.com/content/docs/DOC-23603.  It might be a bit much to digest right now, but maybe some of the principles will be helpful.


Good luck!



Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.