LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FILLING ARRAY WITH ZERO DATA.

I have an ideal array of n strings of 9 bytes (B) in hexadecimal with the following pattern:

     B1 B2 B3 B4 B5 B6 B7 B8 B9

A1 00 4C 44 A4 5B 49 10 BA                     -> String 1

A1 01 4C 44 A4 5B 49 10 BA                     ->String 2

A1 02 DC 26 A4 5B 49 10 BA                     .

A1 03 7C 24 A4 5B 49 10 BA                     .

09 00 4C 44 A4 5B 49 10 BA                     .

09 01 4C 44 A4 5B 49 10 BA                     .

09 02 DC 26 A4 5B 49 10 BA                     .

09 03 7C 24 A4 5B 49 10 BA                     .

AA 00 4C 44 A4 5B 49 10 BA                     .

AA 01 4C 44 A4 5B 49 10 BA                     .

AA 02 DC 26 A4 5B 49 10 BA                    .

AA 03 7C 24 A4 5B 49 10 BA                     ->String n

 

Where the first byte corresponds to the number of a specific message, in this example I got 3 different messages indicated with the indexes, A1, 09, and AA. These indexes do not follow any sequence. However, every message is made up of 4 different strings that are indicated by sub-indexes, 00, 01, 02, and 03 (located in the second byte of every string).

 

-> message A1

 

A1 00 4C 44 A4 5B 49 10 BA                     ->           (4C 44 A4 5B 49 10 BA) part 00 of message A1          

A1 01 AC 4A A4 5B 49 10 BA                    ->           (AC 4A A4 5B 49 10 BA) part 01 of message A1          

A1 02 DC 26 A4 5B 49 10 BA                     ->           (DC 26 A4 5B 49 10 BA) part 02 of message A1          

A1 03 7C 24 A4 5B 49 10 BA                     ->           (7C 24 A4 5B 49 10 BA) part 03 of message A1

 

-> message 09

09 00 4C 44 A4 5B 49 10 BA                     ->           .

09 01 4C 44 A4 5B 49 10 BA                     ->           .            

09 02 DC 26 A4 5B 49 10 BA                     ->           .

09 03 7C 24 A4 5B 49 10 BA                     ->           .

 

-> message AA

AA 00 4C 44 A4 5B 49 10 BA                     ->           .

AA 01 4C 44 A4 5B 49 10 BA                     ->           .

AA 02 DC 26 A4 5B 49 10 BA                    ->           .            

AA 03 7C 24 A4 5B 49 10 BA                     ->           .

 

Unfortunately, I never get an ideal array of strings. Sometimes I get something like this:

 

A1 00 4C 44 A4 5B 49 10 BA

A1 02 DC 26 A4 5B 49 10 BA

09 01 4C 44 A4 5B 49 10 BA

09 02 DC 26 A4 5B 49 10 BA

09 03 7C 24 A4 5B 49 10 BA

AA 00 4C 44 A4 5B 49 10 BA

AA 03 7C 24 A4 5B 49 10 BA

 

Which means that I missed some data, for example:

 

From message A1 I missed part 01 and part 03 of the message.

From message 09 I missed part 00 of the message.

From message AA I missed part 01 and part 02 of the message.

 

A1 00 4C 44 A4 5B 49 10 BA                     -> (4C 44 A4 5B 49 10 BA) part 00 of message A1      

                                                                        ->                                          part 01 of message A1???

A1 02 DC 26 A4 5B 49 10 BA                    -> (DC 26 A4 5B 49 10 BA) part 02 of message A1      

->                                           part 03 of message A1???

What I would like to do is to add the string that corresponds to missing part of the message, and filled the part of this message with zeros.

 

For example, retaking the previous missing data:

A1 00 4C 44 A4 5B 49 10 BA          -> (4C 44 A4 5B 49 10 BA) part 00 of message A1      

A1 01 00 00 00 00 00 00 00           ->                                           part  01 of message A1 filled with ceros

A1 02 DC 26 A4 5B 49 10 BA         -> (DC 26 A4 5B 49 10 BA) part 02 of message A1      

A1 03 00 00 00 00 00 00 00           ->                                           part 03 of message A1 filled with ceros

 

As a result, I have all the allocations of my message A1 although some were filled with zeros because I missed that information.

 

Find attached a picture from the array.

0 Kudos
Message 1 of 5
(2,291 Views)

That was a bit hard to follow but if I under stand correctly, you want to pad your 2D array with dummy data. Ignoring the obvious question about WHY the data is missing... (IE fix the source instead of bandaid-ing the problem)

Looks like you will need parse the array, row by row looking at the second column and when you are missing data, create the dummy data.

 

What have you tried? If you could attach your code (not a picture) I am sure some one can help get you going in the right direction.

---------------------------------------------
Certified LabVIEW Developer (CLD)
0 Kudos
Message 2 of 5
(2,257 Views)

See the attached "Fill Array Example." There may be some edge cases I missed but I believe this correctly creates an output array based on your description. This solutions makes a few assumptions: the input array is already sorted by message ID, and that each message has exactly four parts numbered 00-03. If either of these assumptions is not valid then you may need to make some modifications.

Download All
0 Kudos
Message 3 of 5
(2,231 Views)

Thank you, I appreciate your help. Also, I noticed two things. First, when I run the program that the data that correponds to the message 09 of the part 02 is missing in the array out. Second, the last message (28) missed the last two parts (02 and 03).

 

I´m attaching the image which explains the issue.

Best regards

 

0 Kudos
Message 4 of 5
(2,201 Views)

I would detect when a new message has started and just pre-populate the array for that message.  This way you know you will have all of the items from the start.  Then you just replace the lines as you get the sub-indecies.


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 5
(2,162 Views)