LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional "To More Specific Class"?

At the company I work at they use abstracted class libraries for instrument control. There is the top level "instrument" library that contains properties that pertain to any type of test equipment and then they have the child level for different instrument types, in this case "optical device". These class libraries are very formalized and there is a bureaucracy to modify them so for all intents and purposes I don't have the ability to modify them.

 

In general I will use the parent "instrument" class to read configuration information from a file that includes the specific instrument's child class name and open a session to it. Then to call subvis of the child class I first use "To More Specific Class" to pass the handle. This works perfectly fine except when using it in a loop. If I attempt to loop the operation the first iteration works perfectly fine but on the second I get the error:

 

Error 1448 occurred at To More Specific Class in subvi.vi->main.vi

Possible reason(s):

LabVIEW: (Hex 0x5A8) Bad type cast. LabVIEW cannot treat the run-time value of this LabVIEW class as an instance of the given LabVIEW class.

 

I think what is happening at run time (but not sure of) is that the wire inputting into the "To More Specific Class" node is the parent class type on the first iteration but then on the second iteration becomes of the child type so when the "To More Specific Class" node is encountered again it is trying to find the child of the child.

 

I found some discussion of what happens at run time at:

 

https://forums.ni.com/t5/LabVIEW/inheritage-bug/m-p/793804?requireLogin=False

 

The recommendation there seemed to be to add accessors to the parent class which as I mentioned above I don't have any control of.

 

So my question is if there is a way to make a conditional "To More Specific Class" node where LabView will allow you to wire a parent handle to a child handle when writing the code but only attempts the typecasting at run time when it sees the parent/child but doesn't once the input side of the node is updated to the child class? 

 

As a side note I'm basing my LabView code on a TestStand sequence which uses the same parent and child subvis and it seems with TestStand they are able to pass the handles between the two classes without any typecasting.

0 Kudos
Message 1 of 3
(974 Views)

I'm having trouble understanding your exact situation.  Could you give some example code?

 

My initial thought is to just downconvert before the loop.


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
0 Kudos
Message 2 of 3
(968 Views)

Thanks for the reply. Unfortunately I'm not authorized to post my company's code but I'm going to try to distill it down to the basic elements and post that.

0 Kudos
Message 3 of 3
(942 Views)