LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading an writing to indicators in a cluster

Hi,

I've got a system where I have about 20 indicators groups in a cluster. I've a button set up wired to an event structure. What I want to be able to do is read a value from the cluster using "unbundle by name", add one to the value, then put it back in the cluster using "bundle by name", and have that value displayed in the correct indicator in the cluster. This seems almost impossible to do, but seems almost exactly the kind of thing it should be possible to do.

 

I don't want the user to be able to alter any of the values in the cluster, except programmatically, via buttons that trigger events.

 

I've got this code to work without a indicator in a cluster. How should I be attempting to do this?

 

Thanks

0 Kudos
Message 1 of 12
(1,793 Views)

Without seeing your code we can only hope we understand your request.  My solution (guess) is:

 

  1. Put the cluster of data in a state variable (wire).
  2. In an event structure event that responds to the button click:
    1. unbundle the value
    2. increment it
    3. re-bundle it
    4. send the state machine to a UI updating state (or, if you're an animal, just write it to a local variable)
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 12
(1,764 Views)

Your descriptions is pretty confusing without actually seeing your code skeleton. First you say you have "indicators", then you talk about "without indicator". So what is it? What is an "indicator group"? What is the structure of the cluster?

 

Typically you would keep the cluster in a shift register and display it using an indicator (NOTE: An indicator cannot be modified by the user at runtime, fulfilling one of your requirements.)

Instead of unbundle-modify-bundle I would recommend the "in place element structure", of course. It is designed for this purpose.

0 Kudos
Message 3 of 12
(1,748 Views)

Below is a quick clumsy example. On way, as suggested earlier is to unbundle rebundle, and is shown is example. The other way is turn the cluster into an array then increment and then turn array back into cluster. (That is shown in the -1 case in the attached example. To use it make it the default case, set current default to 0, and delete other cases.)

 

This examples relies on the labels of the controls have an identifier for the cluster. If you don't want that as your label, then use a caption and keep the identifier label. Example in 2015

 

snip.png

0 Kudos
Message 4 of 12
(1,744 Views)

Here's what I had in mind:

 

altenbach_0-1657308980032.png

 

 

Also note that if all elements are of the same datatype, maybe an array instead of a cluster would be sufficient. More scalable and simpler!

 

0 Kudos
Message 5 of 12
(1,740 Views)

Thank you everyone, nearly got this solved now!

0 Kudos
Message 6 of 12
(1,681 Views)

Hi,

I've two size 11 arrays (one string, one float) in a cluster, and I'm trying to add 1 to the zero position of the double array, based on an event block in a while loop. I try to initialise the arrays using a constant cluster. The problem is when I use "Replace array subset" the values don't update, and when I use insert into array, I get a shifting pattern for instance;

0,0,0,0,0,0,0,0,0,0,0  then

1,0,0,0,0,0,0,0,0,0,0  then

2,1,0,0,0,0,0,0,0,0,0

 

I'm just iterating this as a proof on concept, I've included the code I'm working on,

Thanks

 

 

0 Kudos
Message 7 of 12
(1,675 Views)

You can change the value of an element in a cluster (control or indicator) with a property node (either a static one or by reference):

wiebeCARYA_0-1657628100062.png

 

Careful though, this could lead to a big confusing mess...

0 Kudos
Message 8 of 12
(1,666 Views)

Hi Glass,

 


@Glass3 wrote:

I've two size 11 arrays (one string, one float) in a cluster, and I'm trying to add 1 to the zero position of the double array,


There are two arrays in your cluster, but they are empty!

You cannot replace non-exisiting elements in an array!!!

 

See this:

(There are two InPlaceElement (IPE) structures in the event case…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 12
(1,665 Views)

@Glass3 wrote:

I'm just iterating this as a proof on concept, I've included the code I'm working on,

Thanks


  • There are many flaws.
  • If you replace an element in an empty array, nothing will happen. You need to have an array with at least one element in the cluster. Your two arrays need to have 11 elements according to the requirements!
  • altenbach_0-1657806065306.png

     

  • Your cluster should be wired across the timeout case if that ever triggers (currently, tit never does, because the timeout is not wired).
  • You need an event for the stop button.
  • Mind your representations (size should be blue, there is a primitive for +1.etc. The entire array should be blue if it is always integers)
  • I stringly recommend to show the label if the cluster elements in the constants. Self-documenting!
  • Don't use LEDs as controls and call them "buttons". Using mouse-down on an indicator is convoluted. Use value change on a control!
0 Kudos
Message 10 of 12
(1,634 Views)