LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

subvi dll error handling

Hi everyone

 

I have a basic/principal question regarding subvi's and associated error handling.

 

Say I have an DLL which contains a function that takes input a and b, outputs c and d and that I want to wrap this function call (plus additional logic) into a SubVI. I can imagine this done in two ways with error handling:

subvi1_noerror.pngsubvi2_noerror.png

subvi1_error.pngsubvi2_error.png

 

Which one is the most "correct" (or pretty or smart) way to do it?

 

Best regards

Wuhtzu

0 Kudos
Message 1 of 5
(3,247 Views)

It is best to put all front-panel controls and indicators on the top level of a subVI (the only exception to this is the main VI).

 

(EDIT: that means put the controls and indicators outside the case structure, as in subvi 2)

 

That said, if your subVIs contain only the DLL call, then there is no need for the case structure.  The Call Library Function Node will not execute if there is an error on the error in terminal.

Message 2 of 5
(3,238 Views)

First off, I agree with nathand that you do not need the case structure (the Call Library Function Node handles it).

 

Second, if you are wrapping DLL functions, take a look at the import DLL tool.  (Tools->Import->Shared Library in the menus).  It will create wrappers for your DLL functions -- then you just have to test them and make some tweaks

 

For example, if you have a parameter which is a pointer, the tool will make you an input and an output (since it can't tell which it is meant to be, and might be both).  Often you really just want it as an input or just as an output, so you have to change that (and make sure, if an output, that you have someplace to put it; in some cases you will need to make a constant of that type and pass it into the Call Library Function node, and then pass it out.

 

I have had a lot of success using this tool, and it saves a lot of repetetive grunt work.

 

B.

 

 

 

 

0 Kudos
Message 3 of 5
(3,223 Views)

Hi Wuhtzu

 

I would recommend a combination of the first and the second solution.

 

This means:

1) I would like to have the controls inside the no-error case, because the program should only read the value if there is no error. If you have the controls outside and attached to the terminals of the while loop LabVIEW will still have to read the value of the controls even though they are not used in the particular case. (Try this with the highlighting in the block diagram).

 

2) I would though place the indicators on the outside because they should be updated with either a proper value or an error message. Meaning they have to be updated for both cases.

 

Best regards,

Anders Rohde

Application Engineer

National Instruments, DK

0 Kudos
Message 4 of 5
(3,213 Views)

@A.Rohde wrote:

1) I would like to have the controls inside the no-error case, because the program should only read the value if there is no error. If you have the controls outside and attached to the terminals of the while loop LabVIEW will still have to read the value of the controls even though they are not used in the particular case. (Try this with the highlighting in the block diagram).


This is not good advice.  Reading controls at the top-level should be efficient whether or not the values are used, but there can be a cost to putting controls inside the case structure as explained in the "clear as mud" thread to which I linked in my first reply.

0 Kudos
Message 5 of 5
(3,204 Views)