Jump to content

Event strutures, wait on event before proceeding


Recommended Posts

I am sure this is easy stuff, but its a friday and I am burned out.

Okay I got down the sequence structures and how to initiate each step one at a time. But how would I be able to preform a step and make it pause there until a certain value is received... I opened up the examples for the event structures and tried reading the how to's... I got burned out. Maybe someone could help me out by pointing me in the right direction.

This is based off my first question on here.... How to recieve a value when a pre-determined group of text is recieved in serial connection.

I am going to be using a sequence in my state machine, when it is at that state it will start that sequence. That works fine, but I want it to pause at a frame till I get a true value from that string... when it gets that value, then proceed. Is there an easy way to do this? Will I have to dynamically register that event? (Thats the part I dont understand fully)

Link to comment

QUOTE (Kubo @ Feb 13 2009, 03:12 PM)

I am sure this is easy stuff, but its a friday and I am burned out.

Okay I got down the sequence structures and how to initiate each step one at a time. But how would I be able to preform a step and make it pause there until a certain value is received... I opened up the examples for the event structures and tried reading the how to's... I got burned out. Maybe someone could help me out by pointing me in the right direction.

This is based off my first question on here.... How to recieve a value when a pre-determined group of text is recieved in serial connection.

I am going to be using a sequence in my state machine, when it is at that state it will start that sequence. That works fine, but I want it to pause at a frame till I get a true value from that string... when it gets that value, then proceed. Is there an easy way to do this? Will I have to dynamically register that event? (Thats the part I dont understand fully)

Actually this functionality is part of your state machine. I am not sure how you implemented yours but I prefer to use queues for my state events. The state machine runs parallel to the while loop containing the event structure. The event structure handles my user interface events and can start or stop the state machine. The state machine itself contains the logic regarding the sequence of your processing as well as handling when certain things should occur or waiting for a specific data input. For instance, once started your state machine could initialize your hardware, then send some data followed by a wait for a response from the hardware. Once the response is read it would then go to the next step in the process. I suggest you include an error state and a general delay state in your state machine. That wait you could set a timeout value for your response and process the error in an appropriate manner. At the moment I don't have an example of a simple queued state machine. I am sure others might be able to provide one. If not I could probably put something together if you needed it.

Link to comment

QUOTE (Kubo @ Feb 13 2009, 04:12 PM)

I am sure this is easy stuff, but its a friday and I am burned out.

Okay I got down the sequence structures and how to initiate each step one at a time. But how would I be able to preform a step and make it pause there until a certain value is received... I opened up the examples for the event structures and tried reading the how to's... I got burned out. Maybe someone could help me out by pointing me in the right direction.

This is based off my first question on here.... How to recieve a value when a pre-determined group of text is recieved in serial connection.

I am going to be using a sequence in my state machine, when it is at that state it will start that sequence. That works fine, but I want it to pause at a frame till I get a true value from that string... when it gets that value, then proceed. Is there an easy way to do this? Will I have to dynamically register that event? (Thats the part I dont understand fully)

You should probably lose the sequence structures. The way it sounds you are using them (I can't be sure - sharing your code is always helpful to get the best advise) they are merely a waste of space and make the code harder for humans to read, the VI will be sequenced by data flow and the wires between the nodes. Using sequence structures is often a sign that you do not yet understand data flow, and are trying to make the VI operate like a non-data flow, text language based program.

I find them useful only for initializing things like the state of controls and indicators at start up, and on rare occasions where I need to place a time delay between two other operations, however, since I wrapped a wait for ms multiple in a subVI with an error pass through I now sequence the delay by wiring the error cluster wire. This is neater, takes up less real estate on the block diagram and is recognized to be a better coding technique. Serial comm is one of the odd uses of delaying between steps thereby subverting the data flow to allow time for the serial comm to complete.

Link to comment

QUOTE (mross @ Feb 14 2009, 03:15 AM)

You should probably lose the sequence structures. The way it sounds you are using them (I can't be sure - sharing your code is always helpful to get the best advise) they are merely a waste of space and make the code harder for humans to read, the VI will be sequenced by data flow and the wires between the nodes. Using sequence structures is often a sign that you do not yet understand data flow, and are trying to make the VI operate like a non-data flow, text language based program.

I find them useful only for initializing things like the state of controls and indicators at start up, and on rare occasions where I need to place a time delay between two other operations, however, since I wrapped a wait for ms multiple in a subVI with an error pass through I now sequence the delay by wiring the error cluster wire. This is neater, takes up less real estate on the block diagram and is recognized to be a better coding technique. Serial comm is one of the odd uses of delaying between steps thereby subverting the data flow to allow time for the serial comm to complete.

Here is my state machine and code so far. Its probably has some bad techniques and wrong ways to do it... however cleaning it up will be something I will do later on. I just want to make this functional and try to understand a little bit at at time.

Thanks guys

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.

Guest
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.