LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Config File & Variant Attributes

This is my first time working with configuration files and variant/attributes so I want to make sure I haven't created a monster. 

 

I have a large VI that controls multiple motors. Each motor has the same settings (voltage/current/etc...) which will never change. However, there is the chance that new motors will be added beyond the ones I'm aware of. I want the user to be able to edit a standard config file, add a new motor to the list of motors, and then define the settings for that motor. Provided they don't do anything silly, the larger program will deal with those new settings appropriately. 

 

The two challenges are: 

 

1) Allowing the config file/data structure to respond to an infinite # of additions (I.E. I can't build a new case structure each time a motor is added). 

2) This data is needed everywhere, so I'd like a single stream of data that I can pull out the identifier (Motor1, Motor2, etc...) and also the generic values of the settings. 

 

I created the attached with the help of http://www.walkingthewires.com/2015/05/13/quick-look-up/. In my very basic example this is working well. I think this does everything I need. Anytime I need the name of the config being reference I can pull it off the attribute, and since the settings are always the same I can un-bundle a given motor and send the data where it's needed. 

 

Did I do anything weird that I'm not going to discover later or am I using the variants as intended? 

 

0 Kudos
Message 1 of 2
(1,926 Views)

This is exactly the scenario when you need to use classes.  Use a generic motor class that has the basic functionality that all motors are going to have, then create a descendant class from that for each new motor added to the system.  Then, all you need to do is have an ini file that tells the system what motor is present and selects that class.  The code for that class will run without needing to create new cases throughout your code every time you add a new motor type.

0 Kudos
Message 2 of 2
(1,901 Views)