From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic read global variable (cluster)

Solved!
Go to solution

Hi!

 

I would lika to read every control (label and value) in my global variable which contains a cluster. The problem is that I am trying to do this on a cDAQ and as far as I undestand and has seen th property node do not worl that good on real time target. The code I have tested so far is the following: 

mainTestClusterRead.png

This is the main/fornpanel on my cDAQ. The subVI in the main code contains the following:

SubVITestClusterRead.png

The phenonomen that I hav seen is that it works fine maybe the first and second time when I run the cod bu for the third time the labels are empty. I have read something that the propertynode dose not work properly for real time target but it there a way to come to the same solution by not using the propertynode or could you use the propertynode different?

 

Best Regards

Anton

 

0 Kudos
Message 1 of 6
(4,011 Views)

Hi Anton,

 

question: why do you need to read the cluster element's labels in each iteration?

The cluster will never change (it should be typedefined anyway!)…

 

question: why do you need to read the values by property node when you have the cluster wired into the subVI?

 

(And why do you have that race condition in your MainVI?)

 

Which target does that VI run on? What hardware do you use?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(3,999 Views)

I want to do this because in the end I want to write it to a TDMS file (where the cahennel is the label and the value is the value in the cluster) which my intetion is to do in the foor loop. This is because there are a lot of controls in the cluster meaning the code become very large when using unbundle by name and save each element to the TDMS-file.

 

It is a typedef but in the project it might happen that we add or remove parts in the cluster. This means that if I cannot dynamically read what the cluster actually contains I need to change is everywhere which opens for misstakes.

However there might be other wasy to just save a cluster directyl into a TDMS file?

 

The hardware is a cDAQ-9132.

0 Kudos
Message 3 of 6
(3,990 Views)

Hi Anton,

 

I wouldn't use a cluster then…

 

- You could use arrays, one array for "labels", one for data vlues.

- You could use a CVT (current value table) implementation, it will also give you arrays of labels and values…

- You could use waveforms, they allow attributes (like names) and TDMS routines handle those attributes (AFAIK)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(3,982 Views)

This definately sounds like a place for Current Value Table (CVT).  It uses a lookup, by string, to get your value.  So if you know your names, you can quickly get your values.

 

Alternatively, you could create an array of strings to iterate over with a FOR loop and use a case structure to get the individual value and save it to the TDMS file.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(3,956 Views)
Solution
Accepted by topic author AntonBolander

 

I solved it by using an libray (Cluster Toolkit by Autotestware) to ge cluster into arrays of variant and depending on the type I converted the variant accordingly adn saved it.  I guess CVT would be able to do it but since I already uses the cluster and they are "already there" it was more convinient for me to use this solution. 

 

 

0 Kudos
Message 6 of 6
(3,902 Views)