07-08-2022 10:48 AM
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
07-08-2022 12:45 PM - edited 07-08-2022 12:46 PM
Without seeing your code we can only hope we understand your request. My solution (guess) is:
07-08-2022 02:29 PM
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.
07-08-2022 02:33 PM
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
07-08-2022 02:36 PM - edited 07-08-2022 02:38 PM
Here's what I had in mind:
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!
07-12-2022 05:43 AM
Thank you everyone, nearly got this solved now!
07-12-2022 06:45 AM
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
07-12-2022 07:16 AM - edited 07-12-2022 07:47 AM
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):
Careful though, this could lead to a big confusing mess...
07-12-2022 07:17 AM - edited 07-12-2022 07:20 AM
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…)
07-14-2022 08:41 AM - edited 07-14-2022 08:44 AM
@Glass3 wrote:
I'm just iterating this as a proof on concept, I've included the code I'm working on,
Thanks