LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Most efficient way (best practices) for checking each subVI executed without error

I have to write a program for production testing that uses functions from dll.

Functions from dll return 0 if no error accurs in their execution, like this:

Untitled.png

 

In my program I have to call a lot of functions and for each call of every function I have to check if function returned 0. And if function does NOT return 0, the next function from the program must NOT be executed and the

program should jump to "cleanup" VI (close handles etc.)

My Idea was to implemet "zero checking" by using case structure like this:

Untitle3d.png

Each function is connected to case selector terminal (?) and I check if function returned 0. If function does NOT return 0, the other case for "cleanup the program" is executed.

 

The problem is that there are a lot of function and there are a lot of nested Case Structures. That leeds to very ugly and hard to read program.

My Question is:

What would be more elegant, efficient way of implement "zero (error) checking" in each of subVI?

 

 

 

0 Kudos
Message 1 of 6
(2,740 Views)

Hi Skoda,

 

add error IO to your subVIs. Set an error output when your DLL call does not return "zero"…

 

Then use the standard error wires!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,731 Views)

I second the use of error clusters.  With the error clusters, you can also store what the error was and which VI caused it.  In fact, you should look at using the Error Ring.

 

Then you just have a case structure around all of the code in each subVI with the error in wired to the case selector.  The green case (no error) will contain the normal code and the red case (error) can just pass the current error on and any default data.  This would eliminate the "pyramid" of case structures you are starting to do since you can then just chain each of your subVIs together and let their individual error handling do the rest.


GCentral
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
Message 3 of 6
(2,706 Views)

Look into the state machine architecture. Here is a very basic version of what you need to do.

Tim
GHSP
Message 4 of 6
(2,692 Views)

As everyone said add the error cluster to your vi's and use a State Machine architecture with each function call being its own "state" in the machine.

 

Then do something like this:

ErrCapture.PNG

Now if any state exits with an error your program will override the next state and goto the error state

Using the error cluster instead of just a boolean allows you to setup custom error messages in each function's sub-vi so you will know exactly what function failed.

========================
=== Engineer Ambiguously ===
========================
Message 5 of 6
(2,683 Views)

Just to avoid any confusion I thought I would explain further. As you can see in the post above I also have a boolean going to the OR on the error detection. This comes from my Stop button and rather than having both an Error state and a Stop state that do exactly the same thing, (close files safe shutdown) pressing the Stop button also sends it to the Error state but I only run through the Error Handler and pop-up an error message if there is an error.

 

ErrStateCapture.PNG

========================
=== Engineer Ambiguously ===
========================
Message 6 of 6
(2,674 Views)