10-18-2016 06:55 AM
Hi all,
is there a possibility to create a "Property Node" but select the property name dynamically?
As a starting point consider I have a string array of property names (e.g. "property1, property2, property3", which could have been read from a file) and would want to set values for all of those on a specifc object.
Background is the question on how to programatically set voltage ranges for different channels on a CompactRIO module.
Regards,
Patrick
10-18-2016 07:19 AM
Hope your requirement is quite possible, you can take reference of all controls and cmpare the name with the file based on the match you can set values to those contols
10-18-2016 08:20 AM
I don't think so. There are multiple properties and they have different datatypes. There would be no way to wire data to the property since it is unknown which property it is at compile time.
I'd assume that you probably only have a limited number of properties you'd be trying to set the value for. I'd make a case structure that has one of each of those properties in it. Then the property name you read from the file would drive the case structure, and the string value you read from the file could be converted to the property datatype and written to that specific property within the case structure.
10-18-2016 08:36 AM
Thanks for you answers. If I understood the first one correctly they go into the same direction...
@RavensFan wrote:
I'd assume that you probably only have a limited number of properties you'd be trying to set the value for.
Well "limited" meaning 32 channels on one analog input module to start with (let alone other modules I might want to connect)...
It's obviously not impossible to create a case structure with 32 different cases, but it looks awfully wrong to me... I really hope there is a more elegant solution to this!
10-18-2016 09:28 AM
It is very possible to create 32 cases in a case structure. It would take some time to do it manually (I'd guess about an hour, maybe less.) Remember you can create and wire up one case. Then copy as often as you need just modifying the property chosen and the selector value for that case. If you needed a whole log of cases, you could use VI scripting, but I don't think you need that here.
10-18-2016 09:34 AM - edited 10-18-2016 09:36 AM
What are you trying to accomplish? (You described the "how" but if you describe the "what" we might be able to come up with something better.)
e.g., "I want to set the disabled property for a bunch of controls depending on what product number I am testing."
edit:
nvm You already did describe what you needed. Perhaps I should just take some time off from posting since I've been doing this a lot lately. 😕
10-18-2016 09:37 AM - edited 10-18-2016 09:38 AM
Check out the link in the very first post where the "what" is described in detail... (OK, you found it)
To break it down I want to give the user the possibility to specify pairs of "channel number" and "voltage range" in a simple text file and set them accordingly for the input module.
10-18-2016 09:44 AM
I just made this 3 case structure in less than 2 minutes. I bet it would take about 15 minutes to do all 32 cases.
10-19-2016 08:04 AM
You can use these methods to access the properties of any G Object:
Use the attached VI to find index values (property ID codes).
10-20-2016 08:41 AM - edited 10-20-2016 08:42 AM
Hi Paul,
for the time being I resorted to the inelegant case structure workaround, but this finally seems to be what I had in mind initially, thank you!
However I tried to reproduce what you had in your screenshot, but an "Invoke Node" for class "Generic" (did I identify that correctly from you screenshot?) does not have any selectable methods. Therfore I can neither find the "Set Property" nor "Get Property" methods...