LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Refine my code

Need you guys to give me some suggestion on how to improve my code.  See attached code and explaination below.

 

1. Read Regs Banks: output a 2d array that contain my data (read through modbus)

2. for loop: process the 2d array one row at a time.  Each row of data contains different subset of data and the size for the subsets vary.  In this particular case, you have one subset with 1 parameter, and 3 subsets with 2 parameters for each row.  The subset will be combined and convert into another datatype. 

3. Multi Conv: take the data (array of U16) and convert it to an array of variant that could contain values of different data type.

4. Then, I need to index the variant array and change each variant back to it corresponding data type.  (need improvement)

5. At the end, the data are fed into a cluster and than a indicator.

 

I think I need some serious improvement on No. 4, but I want to ask your opinion first, since I want to hear some fresh idea.

 

Feel free to tear this apart. 

 

Yik 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 3
(2,342 Views)

Quick thing for #4.

 

You are taking the variant array and indexing off the same element (#0) 4 times and converting that.  I'm going to guess that you don't want the same element 4 times but 4 different elements.  Not that you can resize the index array function by dragging the bottom border downwards.  If you don't wire in any indicies, you'll get elements 0  through 3.  If you need some other index, than just wire in the appropriate constants.

Message 2 of 3
(2,336 Views)

Why didn't I think of that?  I keep doing multiple index array for a while now Smiley Sad  Thx!  What about the varient to data part?

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 3 of 3
(2,331 Views)