04-24-2024 07:13 AM - edited 04-24-2024 07:15 AM
I play around with a hardware abstraction layer. Right now I am stuck with my abstract init VI.
It seems I can't override my abstract init VI in child classes with inputs that are also children of the original init VI.
Since I can't have two dynamic inputs,
any suggestions for having a generic top level Init that accepts the device and a configuration object are welcome.
Error: This VI doesn't match other VIs in the method, Connector Pane Terminal(s) are different.
04-24-2024 07:37 AM
A few alternatives:
1. Use generic parameters : either the path of an INI file, or a variant (the child method will know how to cast it back to a cluster), or a string (XML or JSON)...
2. Make property node accessors for your class, initialize the parameters you need, and then call init() with no parameters
Reference: dealing with input types on dynamic dispatch - Object-Oriented Programming
04-24-2024 07:46 AM - edited 04-24-2024 07:46 AM
You ticked me in the right direction. Since the Specific FGEN knows which Configure object it can handle, I can cast the IConfigure to the correct IConfigureViaSessionHandle type inside it's Init VI. I will follow that path and will check where it brings me.
04-24-2024 07:48 AM
What I do is pass in a JSON string for the object to be created. The first thing in that JSON object is the class name. I can use that and some string manipulation to dynamically load the desired class. I can later set the class type on the wire to a parent or a child.
I initially used an INI file for my configuration, but I eventually concluded that I needed a hierarchical format to properly define my devices and instruments. I allowed for XML, then got hooked on JSON. I recently removed the XML support because I thought JSON was so much better.
04-24-2024 08:29 AM
I like the approach of JSON configuration files. They seem reasonable for having changing configurations within the same device type.