08-17-2015 11:32 AM
Hello, I'm looking for ideas on the best way to setup an array of clusters with different data contained within the cluster.
Not sure I'm asking the question correctly - I have searched through the forums enough to see that what I am trying to do is not possible - hence looking for ideas on how to achieve the functionality.
Best shown by example:
So this shows the cluster containing 2 strings, an ENUM, and a boolean for each unit.
There might be 50 Units, there might be only 1 unit - unknown at runtime - so I'd like to get this into an array that can be resized as needed.
Trouble is - each unit has different "Commands" - so I am programmatically setting the "Strings" value with the correct commands for that unit.
Well that can not be done inside an array.
So what to do?
Again, just looking for best ideas to achieve this functionality.
Thanks,
Dave P.
08-17-2015 11:37 AM - edited 08-17-2015 11:42 AM
The only thing that you're trying to do and having trouble is have different command lists within this array based on the unit, right? Help us understand how you're trying to do this, because this seems like a weird use-case. How is the Unit selected? Is the whole array going to be forced to match a specific Unit's commands, or are you trying to have elements of the array match different unit commands?
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
08-17-2015 11:43 AM - edited 08-17-2015 11:57 AM
@James.M wrote:
The only thing that you're trying to do and having trouble is have different command lists within this array based on the unit, right? Help us understand how you're trying to do this, because this seems like a weird use-case. How is the Unit selected? Is the whole array going to be forced to match a specific Unit's commands, or are you trying to have elements of the array match different unit commands?
Ok, let me explain a bit further..
Each unit is data from a class object and is dependant upon which hardware is connected to the PC. The "Commands" will vary for each unit depending on what gets plugged in.
I plan to poulate an array with the needed info from the class object; Unit Name, Unit Serial #, Command listing for that unit (Enum Strings), and a boolean indicating wether or not to send that command.
Then I can use the array as a control and in an event case of "Array Value Change", loop through the array unitl I see a Boolean TRUE for sending the command and pass the index to the control loop for the units class objects.
The hard part is getting the strings value for the enum to contain different items for each cluster in the array. From what I ahve read - it can not be done this way. So I'm trying to figure out how can I get the same functionality.
08-17-2015 11:50 AM - edited 08-17-2015 12:05 PM
Yeah, that can't be done since elements of arrays must share the same datatype.
But maybe you don't need it to work this way. If this were possible, how would the array elements know which unit command enum to use? I could see a potential problem down the line for you if you're spitting out this array of commands, but you don't know which command list each element is referring to.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
08-17-2015 11:55 AM
Instead of an Enum for the Command, I would just use another string. Problem solved.
08-17-2015 12:03 PM
@crossrulz wrote:
Instead of an Enum for the Command, I would just use another string. Problem solved.
This is only satisfactory if he doesn't care about the UX and trusts the user to type everything in exactly right. In that case, he might as well just put an U8 numeric in place of his enum and make the user select the right command number.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
08-17-2015 12:16 PM
@James.M wrote:
@crossrulz wrote:
Instead of an Enum for the Command, I would just use another string. Problem solved.
This is only satisfactory if he doesn't care about the UX and trusts the user to type everything in exactly right. In that case, he might as well just put an U8 numeric in place of his enum and make the user select the right command number.
That's correct, It needs to be a list of commands that are available on that particular unit - the user can only select from those commands.
I can't be the only one who has had this issue before - but it's a hard one to define so I may be missing it in the forum search.
I just don't see any posts where someone came up with the equivalent functionality and I seem to be having coders block on coming up with a useable solution.
08-17-2015 12:18 PM - edited 08-17-2015 12:32 PM
I think the only way for you to do this and keep the output consistent is to use a Combobox instead of an enum and allow undefined inputs. The undefined inputs are required, so that when you have entered in a command from a different command-list, it is allowed even once the Strings list has changed. You can still utilize the dropdown functionality using some clever event structure code to edit the StringsAndValues[]. Try this out:
The default strings and values for the combo box are "Item". When it is running, depending on the boolean control, the dropdown will show different options. The end result is an array of commands from different dropdowns.
You do have to be careful with this because somehow you need to tell your code down the line which command list you are using. If you have the same command name for two different "units", then your code may get confused.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
08-17-2015 12:44 PM
As others have said, when in an array the only thing that can vary between elements is the value, but not the properties of the elements.
But as I posted before there is work arounds like this example that allows you to populare the drop down with new items making it appear as if each drop down has a unique list.
http://forums.ni.com/t5/LabVIEW/Edit-a-array-of-Cluster-element-property/m-p/2987577#M856978
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-17-2015 12:55 PM
Aaaaand of course Hooovahh made the same thing already, better and a year ago.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'