SystemLink Forum

cancel
Showing results for 
Search instead for 
Did you mean: 

Tagging 150+ variables

I have been using the tag history for some time and I would like to expand it now to include many more variables.

As of now, the code only uses 12 tags and the code already looks cluttered (Pictures below).

 

Doing the same for 150+ variables will make this code impossible to maintain.

 

Before I start doing this for every single variable I must ask:

Are there better ways of writing this code? As of now, each variable has its own tag creation and tag cluster. (followed the labview example "write multiple tags" and expanded on it).

 

 

 

 

 

Download All
0 Kudos
Message 1 of 4
(2,571 Views)

Hi, 

 

To help me understand the problem better, I have a few questions.

  1. What is the overall physical application?
  2. Do you need to use the tag to communicate through different VIs?
  3. Would you mind sharing the code?

Any additional information would be great.

 

Joelle 

0 Kudos
Message 2 of 4
(2,549 Views)

You could bundle all of the tag references into an array and work on the array tag references instead. You can use the tag property node to get the name of the tag and use that with a case structure to program a case for each tag but then, you have a case structure with hundreds of tags which isn't ideal either. 

 

I could also see a solution using either clusters or OOP where you store what were previously your global variables as a name-value pairs in an array. Then, you would add a keyword to each tag for the name of the name-value pair it's value is stored in. Then, in a loop that you would use for writing, you would get the name of the name-value pair from the tag using a tag property node, you would search through the array for the name-value pair for this tag, get its value, wire it to the generate tag cluster, and use a shift register to keep the tag cluster between each loop iteration. Then when your tag cluster is complete, you would use the Multi Write VI to push all the values to their tags. Alternatively, you could use a number as a property to indicate the index in the array that the value is stored at to prevent you from having to iterate through the array to find the appropriate name-value pair.

 

If you're writing to hundreds of tags, and each of the tags' value comes from a different place, then when it comes down to it, you're going to have to write that code somewhere.

-----------------------------------------------
Brandon Grey
Certified LabVIEW Architect

0 Kudos
Message 3 of 4
(2,546 Views)

In my simple cRIO data logging example that uses tags, I just used a class to clean things up and iterate over things in a loop when needed.

 

https://github.com/joshuaprewitt/skyline-crio-logger

Screen Shot 2018-07-25 at 1.32.47 PM.png

 

Screen Shot 2018-07-25 at 1.33.31 PM.png

 

 

 

 

 

Message 4 of 4
(2,544 Views)