06-09-2010 03:51 AM
Hello,
I want to know what the best practice is for Error Handling in an While Loop - Event Structure combination.
In the above picture there is a start-event (not visible) that sets the timeout to >0, for starting executing the code in the timeout-event.
The problem I have is when an error occurs. This error will never be reset and forever flow through the while-loop.
Can you guys help me in the right direction, please?
06-09-2010 05:22 AM
1) You can put a state machine around the event structure to ask to go to a certain error state whenever an errror occurs
or
You can dynamically create an event that will handle all the errors and performs the required options.
Guru
06-09-2010 05:50 AM
06-09-2010 06:34 AM
Well you have many possibilities to do it. I suggest this one see attached VI. With this solution you can logg the error in a text file if you want.
06-09-2010 12:16 PM
Here is a simple and easy way, but it is not very elegant. It simply stops the loop and you have to look at the error out. It does no clean up. Ideally, a state machine is better. Look for the status after each state or event. If an error occurs, make the clean up state the next state. In clean up, turn off power, reset whatever, close references, and send a true constant to the loop stop sign.
This example is just for simplicity in case you don't need clean up.