LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cast Class Control Inputs of a VI Reference

Basically I want to register different VIs into a list. All VIs shall have the same Inputs: Module input, Module Output, Message input (also a class) and error handling.

Any VI may have different types of the Module and the Message even though all Modules have the same parent class and all Messages have the same parent class. While registering their intputs should be somehow downcasted the the parent classes.

When executing any one of the references I want to pass an object of the parent class in some generic function (search through all references and call the right one). The called VI should have its special child class as input so I don't need to manually place one or two case-Nodes in every VI.

 

Till now I have not found LabVIEW beeing able to do this, but of cource c++ is able to do some.

Attached you will find the c++ example and also a try within LabVIEW (LV14 SPI1).

 

Download All
0 Kudos
Message 1 of 3
(3,249 Views)

I'm pretty sure LabVIEW can't do exactly what you want to do.  

 

LabVIEW's standard OO methodology uses Dynamic Dispatch VIs, which have one and only one class input that determines which version of the VI it runs based on the child class farthest down the inheritance tree that has an override for that VI name.

 

There are two other methods to have VIs that are more flexible.  One is to use polymorphic VIs (which cannot be used directly with Dynamic Dispatch VIs, though you can create static wrapper VIs for them and then use them) but these are done by matching the wire type with the terminal type and don't check the class that runs inside the wires, so it's not practical for run-time OO.  The other is to call VIs by reference, which would require them to all have the same connection pane but you could make your own logical list of which combination of 2 descendant classes combine to call which VI by reference.  Both of those methods aren't automatic and would require you to do extra work each time you wanted to create a new descendant.

 

Think about it this way, if LabVIEW could do what you want:  You have 3 module classes that descend from each other, A1 (parent), A2 (child), and A3 (grandchild).  You have 3 message classes that descend from each other too, B1 (parent), B2 (child), and B3 (grandchild).  You create a top-level A1B1 VI, and then create overrides for A2B3 and A3B2.  You then call the top-level VI with run-time classes of A3B3.  Which override does it call?  Unless you guarantee that you've created functions for all 9 AxBx combinations, there's no easy way to define the behavior there.  So LabVIEW disallows it.

 

I think at this point it would be more practical to stop, back up, and tell us exactly what it is you're trying to do in your program, and maybe we can recommend which sort of solution to actually use.  To be honest it kind of looks like you're trying to replicate the Actor Framework, which has a generic Actor class and a generic Message class.

 

0 Kudos
Message 2 of 3
(3,202 Views)

Basically its rigth. My question goes near to the actor framework. I do have a framework with the same focus. Rigth now any messages executed it found by its name in a case structure. If I use the class name (from the message) I need to write the exact name of the class into the case structure. If the name changes the function will break. Therefore I like to register the wanted behavior (a SubVI of the target module) with the message class (from which I get the name). Anytime the message is processed the system should find the correct SubVI by the messages name and execute it.

I know that the actor framework has an other way. There the message defines what is done, not the target actor itself. So its hard to make generic message execution (e.g. send all messages via TCP to another process). Also its hard to define a dervied actor which changes (override) the behavior of message xy.

Additionally I don't like to implement all the cast operators a hundred times.

0 Kudos
Message 3 of 3
(3,113 Views)