05-12-2022 11:16 AM
Hello guys . i am working with this state machine for a HMI to communicate with a specific instrument .
1/ i want that if i press the "stop measurment button" at any time in any state of my prgramm, this button stops the instrument instantaneously without having to wait that all the sequences are done ( beacuse once all the sequences are done, the instrument stops automatically) . Can i set a priority in labview states ???
( i didn't post all the program due to its confidentiality so i just wrote a descriptin in every state)
2/ i want to calculate the execution time of every state
pleaaase help me !!!
05-12-2022 11:34 AM - edited 05-12-2022 11:36 AM
Put the case structure with sequences inside the timeout event and add an event for the stop button. All other state can be handled with event cases.
Keep the timeout in a shift register and manipulate the timeout from -1 to finite if sequences should execute.
05-12-2022 11:41 AM
can u do this in the vi that i attached bellow cuz i didnt understand you and thank you so much
05-12-2022 11:42 AM
You need a queued message handler rather than a simple state machine.
With a QMH the event loop is always running and a pripority command can be added to the state queue with Enqueue at opposite end.
A brief mod is attached (incomplete)
05-13-2022 10:35 AM
i tried ur method but the problem that occured is that i want that once i clic on start measurment button it executes seq1 then seq2 then seq3 then seq4 and then the state machine returns to the state wait for event . In the code attached in the vi bellow once i clic on start measurement it go to the state sequence 1 and returns to the state wait for event whereas i want to execute seq1 until seq4 and return to the wait for event state . Please can u have a look at the vi that i did ?
05-13-2022 10:55 AM
@JASMIN185 wrote:
can u do this in the vi that i attached bellow cuz i didnt understand you and thank you so much
You did not attach your typedef. Also make sure to save for previous. Your latest attachment is in LabVIEW 2021, which many cannot open.
05-13-2022 11:16 AM
here's the VI
05-13-2022 11:20 AM
Do you have the typedef of the original VI?
05-14-2022 07:38 AM - edited 05-14-2022 07:43 AM
No, the vi came stripped of dependencies. Hence the really nasty split from the SSM to QSM<events> I assume the OP could
GO TO GRAMMAS HOUSE as a better explanation of priority messaging but I failed to add that link
A simple enqueue in a loop should give a nice sequence of "non-priority" steps. The message handler would not need a wait for events case (the dequeue element automagically does that!)
05-14-2022 08:45 AM
I still think all we need is one simple loop as I suggested.
Of course the term "immediately" is a bit soft when external instruments are involved, because the might need a clean shutdown procedure.