Hi,
I have two questions.
Question 1) I am trying to write a vi which is a state machine, which also listens for events.
The program runs through a sequence, listens for events, while reading in data from the serial port in a default state.
What would the best structure be for this?
I have used an event structure which adds items to a queue, with a seperate state structure, which reads items from the queue.
However, my program takes about 2 minutes to respond to events. I have created a cut down program, showing the structure I am using.
Question 2) My test vi, for question 1 is showing problems, where enumerated type constants are changing within the program.
The enumerated constant is a strict type defined control.
This can be seen by running the attatched program "Qn on state with events.vi" with execution highlighting turned on. The program then goes into states that it shouldn't.
Is this a problem with my program? or an incorrect LabVIEW behaviour?
My application works fine, however, the cut down program, showing the structure, doesn't work correctly.
Details on Question 1)
----------------------
The sequence of the VI I'm designing is:
1)Disable front panel buttons which generate events
2)Initialise the serial instrument
3)Program the serial instrument
4)Enable buttons on the front panel which generate events
5)(a)Go into a default state, which is reading data from the serial instrument.
5)(b) at the same time, listen for events from front panel controls, which write commands to the serial instrument.
5)(c) once the event has been carried out, go back into the default state of reading from the serial instrument
6) If the stop button has been pressed, stop the program
The way I have done this, is using queue's and events.
This is the sequence I have followed.
1) Initialise the event structure to have a timeout of -1, never time out
2)Disable front panel buttons which generate events
3)Initialise the serial instrument
4)Program the serial instrument
5)(a)Enable buttons on the front panel which generate events
5)(b)Change the timeout of the event structure to 500ms,Generate a user event at the same time, to update the timeout setting on the event structure.
(This allows the timeout case of the event structure, to read from the serial port on a regular basis)
This allows timeout to be the default case of the event structure.
5)(c) at the same time, listen for events from front panel controls, which write commands to the serial instrument.
5)(d) once the event has been carried out, go back into the default state of reading from the serial instrument
6) If the stop button has been pressed, stop the program
Any advice on this would be greatly appreciated.
Thanks,
Anthony