Kubo Posted February 21, 2009 Report Share Posted February 21, 2009 How do I clear the event list... I have a state machine that will initiate a sequence or command based off the selections that was picked by the user. The steps are done in order and the programs works great except for a few small issues... I have event structures waiting on events in certain parts of the state machine. There are 3 events that I want to be designated as the triggers for the structures but there are 8 stages. So some events are going to be shared... The reason why is because the unit I will be programming will rebooted multible times... so upon reboot it will need to look for that event again. I can run the program and run each stage individually, this works fine. But when I run the program and select all the stages the states with the shared events will not wait for the event to happen again because it happened in a privious stage. But once I stop then start the program it resets it event log (so it seems). So my question is, how do I clear the events each time it gets to a new stage in my state machine? OR/AND Is the another way I should do this? Thank you Quote Link to comment
Mark Yedinak Posted February 21, 2009 Report Share Posted February 21, 2009 QUOTE (Kubo @ Feb 20 2009, 03:20 PM) How do I clear the event list...I have a state machine that will initiate a sequence or command based off the selections that was picked by the user. The steps are done in order and the programs works great except for a few small issues... I have event structures waiting on events in certain parts of the state machine. There are 3 events that I want to be designated as the triggers for the structures but there are 8 stages. So some events are going to be shared... The reason why is because the unit I will be programming will rebooted multible times... so upon reboot it will need to look for that event again. I can run the program and run each stage individually, this works fine. But when I run the program and select all the stages the states with the shared events will not wait for the event to happen again because it happened in a privious stage. But once I stop then start the program it resets it event log (so it seems). So my question is, how do I clear the events each time it gets to a new stage in my state machine? OR/AND Is the another way I should do this? Thank you From what you describe your event structures and state machine states are intertwined. Generally this is not a very good way to design your system. You are better off using a producer/consumer model and use a single event structure that is always processing your events in one loop. A parallel loop would contain your state machine. When your events are triggered you would queue actions to your state machine for processing. If you need to you can also disable your front panel controls to avoid multiple events being triggered. This depends on how you want to handle your user interface. Try searching for an example of a producer/consumer design pattern. I believe one ships with LabVIEW. This should help with your application. BTW, the picture you posted is fairly useless since the code is not visible and you are asking for help with your code architecture, not your front panel design. Quote Link to comment
Kubo Posted February 21, 2009 Author Report Share Posted February 21, 2009 Thank you. I put a picture of my front panel to better discribe what my program's functionality was supposed to be... I personally work better with drawing stuff out then actually discribing it. However others may obviously disagree. Quote Link to comment
Michael Aivaliotis Posted February 21, 2009 Report Share Posted February 21, 2009 QUOTE (Kubo @ Feb 20 2009, 02:12 PM) Thank you.I put a picture of my front panel to better discribe what my program's functionality was supposed to be... I personally work better with drawing stuff out then actually discribing it. However others may obviously disagree. I agree, that's why you should post an image of your block diagram, not your front panel. There are two parts to a VI. A block diagram and a front panel. We can't see the block diagram. Quote Link to comment
Kubo Posted February 24, 2009 Author Report Share Posted February 24, 2009 I know that there is probably a more professional way to do this, I am learning... Please dont criticize too much. Some steps in the state machine have another smaller state machine in them. I did this to have the option to go different places when certain events happen or timeouts occur. Each time it gets to a step in the outer state machine, like where it says "OE_Main", it will turn on a device which will boot the same way each time... provided that option was selected. While booting, those events will occur but it may not be at that step yet... so when it does get to that step it will just go ahead with that event since it saw it previously instead of waiting for it to happen again. Is there a way to clear the event log when it gets to that step? Thanks everyone! Quote Link to comment
Mark Yedinak Posted February 24, 2009 Report Share Posted February 24, 2009 QUOTE (Kubo @ Feb 23 2009, 08:57 AM) I know that there is probably a more professional way to do this, I am learning... Please dont criticize too much.Some steps in the state machine have another smaller state machine in them. I did this to have the option to go different places when certain events happen or timeouts occur. Each time it gets to a step in the outer state machine, like where it says "OE_Main", it will turn on a device which will boot the same way each time... provided that option was selected. While booting, those events will occur but it may not be at that step yet... so when it does get to that step it will just go ahead with that event since it saw it previously instead of waiting for it to happen again. Is there a way to clear the event log when it gets to that step? Thanks everyone! Again, I will reiterate that you should look at the producer/consumer model for your design. Move all event processing into its own loop and run it parallel to the state machine. The state machine can keep track of what state you are in and what processing should or should not occur. The event handler will simply catches the events and posts a message to the state machine queue. You could use dynamic events which would allow you to specify when you want to listen for specific events. Your state machine can keep track of where it is in its processing and throw away events it no longer cares about. I don't believe there is a way to flush the events from that are queued for the event structure. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.