キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

event structure state machine

Hello,

 

I have created a state machine and one of those states includes an Event structure for User events to be handled. This event structure is polled after each data acquisition. It seems like my program gets stalled because after the 'Start' button is pressed, the program gets data and then the event structure waits for an event to happen before it gets new data again. Is there a way to bypass the event structure if no events need to be handled?

 

Thank you.

 

Richard

0 件の賞賛
メッセージ1/18
5,491件の閲覧回数

Give it a zero-millisecond timeout.

 

Example_VI_BD.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 件の賞賛
メッセージ2/18
5,489件の閲覧回数

You need to be careful about just putting a 0ms timeout on your event structure.  Sometimes you need to sit there and wait forever, like when waiting for the Start button.  So you really need to use a shift register to control what the timeout should be.  Set it to -1 when you want to wait forever and 0 when you just need to do a quick check for events before continuing on with data collection.

 

A better way would like be to separate your event handling and yoru data acquisition into two loops, using queues or notifiers to communicate between the loops.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
メッセージ3/18
5,471件の閲覧回数
The main advantage of this state machine is, you can dynamically change the states...
If you feel that the even structure need not to be handle, simple switch/bypass that case.
So that the next case will execute.
This witching can be done through a shift register and a Boolean...
0 件の賞賛
メッセージ4/18
5,446件の閲覧回数

@leumaseoj wrote:
The main advantage of this state machine is, you can dynamically change the states...
If you feel that the even structure need not to be handle, simple switch/bypass that case.
So that the next case will execute.
This witching can be done through a shift register and a Boolean...

And then how do you expect to handle UI events?  The event structure needs to be handled otherwise you could be stuck with no way to quit.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 件の賞賛
メッセージ5/18
5,434件の閲覧回数
It depends up on the user decision... In case while initializing, if the event is not needed, in the initialization state itself user can make the boolean false (shift register boolean). If you think after the precheck/data acquisition is done, UI needs user event, you can enable the Boolean (shift register boolean) in that data acquisition/precheck state itself.
Because state machine is very good at sequential execution. If you want to terminate a code suddenly, you can raise a error, this can enter into error case and do the nessesory action either close or error handling.
0 件の賞賛
メッセージ6/18
5,428件の閲覧回数

The JKI State Machine handles this well.  The "Idle", "" case in the state machine contains the Event structure so a long operation "macro" can poll the Idle case and when the system is simply waiting for a UI event, the "" (empty string) state will.

 

This method works well for many of us using the JKI SM.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 件の賞賛
メッセージ7/18
5,412件の閲覧回数

,

 

This is the way I'm going to do it. I made the Timeout event select between 0 or -1 wether an event needs to be handled or not. Then, inside all the other events, I just set a Timeout constant to 0 so that at the next loop, the Timeout event is handled again and selects between 0 or -1.

 

The only question I have is how to notify the Timeout event that an event just happened and needs to be handled and to set the Timeout terminal to -1 instead of 0?

 

Thank you,

 

Richard

0 件の賞賛
メッセージ8/18
5,354件の閲覧回数

Your timeout needs to be in a shift register.  Then each case can set the timeout to whatever you need it to be.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 件の賞賛
メッセージ9/18
5,343件の閲覧回数
Yes, that's what I did, but its the Timeout event that decides if its goig to be a 0 or -1 that the Timeout terminal takes. My question is, how does the timeout event gets notified of any event that need to be handled?
0 件の賞賛
メッセージ10/18
5,332件の閲覧回数