05-20-2021 05:44 PM
Okay so my Main VI is a flat sequence code connecting to a bunch of motors using .NET references and then playing around with them.
The error handler I am trying to make should basically jump to the last flat sequence window (as shown) and close all my motor references and just finish the VI because the error encountered is of the motors not connecting and therefore will have to be manually restarted.
Now Why don't I use the red Abort button is simply because whenever I do this it overwhelms my CPU and Labview crashes and I have to restart everything, thus the safest way to exit would be to follow the last sequence structure code. Now I tried to make a SubVI similar to my last sequence structure code with global variables (really stupid idea). So any w2ay I can achieve this? Change my sequence structure etc,. I'm running out of ideas now.
I am also attaching my Main file but you may not be able to read the .NET references as that is from a separate 30 MB file. But should give an idea about data flow.
Solved! Go to Solution.
05-20-2021 06:04 PM
Rewrite your code and remove the flat sequence structure. There is no way to jump over frames unless you start putting a case statement in everyone which would be HORRIBLE code. I would recommend you look into using a state machine. there are tons of examples out there.
As for the red abort button, you should NEVER use that to stop your VI, with the exception of the development environment and your code going completely off the rails. As you have observed, this is not a safe way to exit your program. It is like stopping your car by slamming into a wall. It will stop the car but the outcome is certainly not desired.
05-20-2021 06:56 PM
Okay I looked into State Machines and I think I can very easily convert my VI to one as it is already a sequential flat sequence, would basically have to just put each falt sequence block in a different case structure surrounded by a While loop. My only question now is that my error function is a SubVI How do I exit this SubVI and Jump to lets say my last Case Structure or "Stop case" from within the SubVI??
I apologize in advance if its a really stupid Question lol.
05-20-2021 10:17 PM - edited 05-20-2021 10:17 PM
I think that if you right-click on the edge of your sequence structure, it gives you the option to convert it to a state machine! YYMV, though, but I've seen it work quite well.
05-21-2021 07:09 AM
@billko wrote:
I think that if you right-click on the edge of your sequence structure, it gives you the option to convert it to a state machine! YYMV, though, but I've seen it work quite well.
You must have a special plugin to do that. The only built in options the Flat Sequence Structure lets you convert to is a Stacked Sequence Structure or a Timed Sequence Structure. But a Stacked Sequence Structure can be replaced with a Case Structure, which gives you a basis for a State Machine.
05-22-2021 08:06 AM
@bajajvishal11 wrote:
... My only question now is that my error function is a SubVI How do I exit this SubVI and Jump to lets say my last Case Structure or "Stop case" from within the SubVI??
Your subVI should output the next state/case to run. Wire that into a shift register on the right side of the While Loop, and connect that string/enum from the corresponding shift register on the left side of the While Loop into the case selector of the case structure.
05-22-2021 05:58 PM
@crossrulz wrote:
@billko wrote:
I think that if you right-click on the edge of your sequence structure, it gives you the option to convert it to a state machine! YYMV, though, but I've seen it work quite well.
You must have a special plugin to do that. The only built in options the Flat Sequence Structure lets you convert to is a Stacked Sequence Structure or a Timed Sequence Structure. But a Stacked Sequence Structure can be replaced with a Case Structure, which gives you a basis for a State Machine.
No, I just have a bad memory. Your recollection is the correct one.