LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to add elements into table in ascending order

Solved!
Go to solution

Hello , i am using serial data parsing using state machine. Each of my incoming packet is of 13 bytes and then i need to display different group of bytes into different fields of table indicator. Right now, i am only sending 1004 packets to my labview application. After identifying the start of frame of 2 bytes from each of my packet , i need to display the next 4 bytes from each packet into the timestamp field of table indicator. The problem which i am facing is that, i am getting the most recent packet value at the top of my timestamp field. i need a way to display my data in ascending order, showing first packet at the top. If i use "Sort 2D array" function to tackle this issue , then i am missing out on some packets and i am not getting proper packet count. please help me , i need a way to display my first packet at the top and want my table to grow in ascending order.Moreover , i am posting the sceenshots of my block diagram and front panel. If u look closely in my block diagram screenshot , then u can see that i am somehow appending my table control 3 using "Insert into array" function , without doing this, i am only getting my first row filled at the end of the data transfer and not the whole table filled.

Download All
0 Kudos
Message 1 of 6
(3,731 Views)

to paraphrase an old saying ... a VI says more than a thousand pictures

to let people help you, create a vi that shows your problem as an example,

and attach it to you post.

 

but looking at your pic, you have a shift register for your table data, then you use "insert into array" on this data, and add your new line, and then again your current data in "Table Control 3" local variable,

that looks wrong to me.

 

from the picture i don't know how you get a descending order,

for me adding stuff using "insert into array" without any arguments on 'row' and 'col' just adds the new 1d-array at the end, which means ascending order.

 

regards


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 2 of 6
(3,713 Views)

I am not sure if a "cluster sort" will help but I will mention it just the same.

 

If you sort a 1-d array of clusters using a sort- 1d aray LV will sort the clusters based on the first element in the cluster. If there are "ties" between element it will use the second inem in the cluster to break the tie.

 

So if you;

 

Cluster_Sort.png

 

For loop iterate through rows and convert the rows into a a cluster (array to cluster) and build the array on the output.

Sort 1-d array

Another For loop to take the sorted array of cluster and convert back to an array and build a 2d array at the output tunnel.

 

You do not have to figure out where to insert the data, just add the new to the end, sort it, convert back to arrays and update the table.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 6
(3,670 Views)

I somehow managed to display data in ascending order but that method was causing me lose a big amount of packets.So , i discarded that method. Can u please tell me a way how can i display data in my state machine by using all the rows of table control and displaying each packet information on a separate row. At the moment, my table control is overwriting each packet information on a single row, rather than using all the rows. In the screenshot given below, i have tested my program with a packet count of 5000 packets. Please suggest me an optimized way of writing data on my table control by writing each new packet information on a new row.

Download All
0 Kudos
Message 4 of 6
(3,650 Views)
Solution
Accepted by topic author shaunmarsh123

It is difficult to debug a screenshot because it isn't showing all the cases and doesn't even show the entire block diagram.

 

One thing I do see is that you have some tunnels on the case structures that are marked for Use Default if Unwired and that you have some cases that don't have those tunnels wired.  My guess is that when a certain case runs, the data coming from the shift register is lost and you are starting over with an empty string array.

Message 5 of 6
(3,633 Views)

You guessed it right, i was making the mistake of not wiring up all the cases to the shift registers. Thanks alot !!

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