Showing results for 
Search instead for 
Did you mean: 

OOP Class Configuration Assistance

I am looking for some guidance on the configuration/implementation of my classes.


The specific application is I want to use classes to be able to specify the protocol and the message to be sent via a COM port to a device under test.  


Each protocol has a specific way the packet is built, so I have created child overrides for the parent "Build Packet".  Same goes for the Checksum calculation (see attached pic)


Each message has a different requirement for input parameters, and usually the same command does not have the same inputs for each protocol (meaning each child will have a number of methods not implemented in the parent class).


As part of my sequencer for the test configuration, I would like to specify which protocol and command to send.  


So my ini file has a key (string) "IRCommand" = Protocol,Command and another key "IRParameter"=Data to be built into message.  Note:  Each command has a header, count, Data field, checksum.


Attached is the picture of how I attempted this, but it did not seem to get specific enough (I could get the correct protocol, but not the actual message).


I also attached a screenshot of on the the child overrides for the Get SN command.  It calls the parent Send Command, but specifies some of the inputs and handles the response according to how I need to parse the packet.


My question is, if I specify IRCommand=ABC,SendThisCommand, how to I translate that easily into my child message implementation in the class. 





Download All
0 Kudos
Message 1 of 4

You have your implementation classes set to dynamic despatch, right? Otherwise it will call the parent method instead of the individual child methods.

LabVIEW Champion, CLA, CLED, CTD
0 Kudos
Message 2 of 4

Yes, the classes are set to Dynamic Dispatch.  The Build Packet and Checksum work as expected, the child vi dynamically dispatches the child implementation.


Do I have to create a vi for EVERY message that a child can run in the parent class?  I thought that the Child could have extra vi's/methods that the parent did not have.


For Example:  Parent has: Build Packet, Init, Checksum, Close, Send Command.


Child1 has: Build packet, Checksum, Read SN, Write SN, Get Count, Set Count.


Child2 has: Build Packet, Checksum, Set ParameterA, Write SN, Read SN


0 Kudos
Message 3 of 4

Yes, the child can have extra methods - but you won't be able to call them dynamically unless there is also a matching dynamic dispatch parent method (or it's called in one of the dynamic dispatch VIs). In this case you'd need to cast to a more specific object (the child class) and then call the child-specific method - usually you'd do that in a case structure etc. You can just make the parent implementation do nothing though.


Here's an example from one of my applications - I have two CAN interfaces and either one can be a hardware interface (Kvaser / FPGA) or a simulation interface. You can see there are interface specific VIs which are called but the output of the case structures is the generic CAN interface object.




Also, just to clarify you said the 'classes' are set to dynamic dispatch - dynamic dispatch is something you set on the individual method VIs (of the same name) in your classes. Maybe you meant to say methods or VIs but I just wanted to clarify that your method VIs for the parent/child have the same name and dynamic dispatch terminals.


Have you tried probing your objects while it's running to make sure that the correct implementation is being called at run-time?

LabVIEW Champion, CLA, CLED, CTD
0 Kudos
Message 4 of 4