LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically append 2D array to Multicolumn ListBox

Solved!
Go to solution

Hello,

I'm trying to display the most recent data as well as the device outputting the data on a MCLB. Also, the MCLB serves as a menu to access additional device information.  The data is updated in 2D array data sets. Each data set has a group number and each group can comprise any number of rows. The data is updated in groups at specific setpoints. These groups of devices are measured at each setpoint and the group measurements are repeated for new setpoints. The problem that I'm having is I'm dynamically appending the 2D array data sets to the end of another 2D array and when overwriting old data sets when group measurements are repeated for a new setpoint. I've attached screenshots of the UI, and the calling code.  I also tried to use an action engine to control the data update and display but I can't get it to work. Also attached.  I will appreciate any help and suggestion. Thanks in advance!

 

Current data display

Single data set.png

 

Desired Display

Multiple data set.png

Block Diagram

Main VI.png

Action Engine

parse data vi.png

0 Kudos
Message 1 of 14
(172 Views)

@SolPS wrote:

The problem that I'm having is I'm dynamically appending the 2D array data sets to the end of another 2D array and when overwriting old data sets when group measurements are repeated for a new setpoint.


Appending and overwriting is obviously not the same, but you describe it as "problem". So what do you actually want?

Instead of replace array subset, you should probably use built array in concatenate mode.

 

Sorry, I cannot currently look at your VI, only 2020 here.

0 Kudos
Message 2 of 14
(149 Views)

If I understand well, you want to replace data when new are available, not append them.

Does the number of lines for each group (=batch?) can change at runtime or is fixed?

If it's fixed - as I guess - you need to allocate on initialization (Write = False) a number of blank lines corresponding to the total number of data you will ever get, then replace data at different offsets depending on the group number. These offsets should be precalculated.

On the other hand, if you don't know in advance the number of lines for each group, things get more complicated.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 14
(126 Views)

Hello Pincpanter,

Yes, that is correct. I want to replace existing data when new ones are available.

The number of lines/rows in each batch changes at run time and I try to ascertain the number of rows in each batch and then replace the data at the corresponding offset. That is what I tried to do with the action engine but I couldn't get it to work. 

 

0 Kudos
Message 4 of 14
(111 Views)

Hello Altenbach,

Sorry, I don't think using append was the correct way to describe the problem. I want to replace existing data with new ones when available.

Build array function will not work because I will not be able to replace/overwrite old data. Basically, I need to replace existing 2D array data at specific offsets within the defined 2D array. Here is the other case of the block diagram.

parse data vi init.png 

0 Kudos
Message 5 of 14
(109 Views)
Solution
Accepted by SolPS

@SolPS  ha scritto:

Hello Pincpanter,

Yes, that is correct. I want to replace existing data when new ones are available.

The number of lines/rows in each batch changes at run time and I try to ascertain the number of rows in each batch and then replace the data at the corresponding offset. That is what I tried to do with the action engine but I couldn't get it to work. 

 


If the number of lines/rows changes at run time, Replace Array Subset is not the right function. You need to keep in memory the offset and length for each batch number (into the same or another shift register), then use Delete From Array to remove the old data and Insert Into Array to add the new ones.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 6 of 14
(99 Views)

@SolPS wrote:

Hello Altenbach,

Sorry, I don't think using append was the correct way to describe the problem. I want to replace existing data with new ones when available.

Build array function will not work because I will not be able to replace/overwrite old data. Basically, I need to replace existing 2D array data at specific offsets within the defined 2D array. Here is the other case of the block diagram.

 


Your earlier image showed a "longer" desired display. Where does the "specific offset" value come from? Where do you "define" the 2D array?

 

You need to initialize the 2D string array with the maximum expected size, then replace rows based on e.g. the value in column 2 or whatever.

 

You can get both dimension of the input array directly.

 

If you would "save for previous" before attaching, more could inspect your VI.

0 Kudos
Message 7 of 14
(83 Views)

Hello Pincpanter,

I followed your suggestion and modified my action engine as shown below. It works now as intended. Thank you!  

parse data vi solution.png

0 Kudos
Message 8 of 14
(73 Views)

Hello Altenbach,

Thanks for your reply. I was able to get my application to work by following Pincpanter's suggestion above. Again thanks for the input.

0 Kudos
Message 9 of 14
(72 Views)

@SolPS wrote:

Hello Pincpanter,

I followed your suggestion and modified my action engine as shown below. It works now as intended. Thank you!  

 


This still looks overly complicated. I am sure Inspector Clouseau had something simpler in mind. 😮

 

If you would attach your code (saved for previous, 2020 or below) I am sure I could dramatically simplify this hairball of code 😄

0 Kudos
Message 10 of 14
(59 Views)