06-23-2010 12:23 AM
Hello Every one,
Can any one please help me out in sorting a 2-D array. Here is the requirement there will be some groups, and each group consists of 'x' number of elements.The user enters only elements but in a zig zag order. And the program short sort out each channel and list out to which group it is belonging (Where the 2-D array of Group name and elements is provided).
Say for example if there are three groups with some elements in each groups as follows.
Physics: retarder, force,torque,capacity
Chemistry: reaction, chemicals, sodium
Geography: land,map,soil, earth.
And if the user enters the following input's: soil, torque, chemical, force,reaction, land.
The program should return the following output:
Note : The order of the elements should match the order they are defined.
Physics, force,torque ------------ group name and group elements in the first row
Chemistry, reaction, chemical ------------ group name and group elements in the Second row
Geography,land, soil ------------ group name and group elements in the third row
Thanks for the help
- Raghu
Solved! Go to Solution.
06-23-2010 05:31 AM
06-23-2010 08:37 AM
Thanxs Jim for your support., This is something what I was trying to achieve.But Iam still running in to some issues. Can you please help me out in solving this issues.
1) User will be provided with a array input rather than a string input as shown in the attached image.
2) The elements in the output should be matched to the order defined in the 2- D array.
for example Physics group contains retarder, force, torque and capacity. But now In the output Iam reading as Physics,torque,force in the first array, where I need to display Physics force torque.
3) And the last issue iam facing is if the user only enters 2-group elements say physics and geography elements, in the output Iam reading a empty row in the second row. Where I need to move the third row to the second row, without displaying a blank row. As shown in the attached image (row_shift)
Thanxs for your support Jim.
- Raghu
06-23-2010 09:10 AM - edited 06-23-2010 09:10 AM
Why don't you make our life easier and attach your actual VI containing typical default data in the controls? This way we could easily make a few modifications instead of needing to start from scratch.
Thanks!
06-23-2010 09:12 AM - edited 06-23-2010 09:17 AM
I've got the solution coded to address your latest requirements, but I'd like to see you take a shot at some of it. Your first requirement is incredibly easy. Have you tried to fix it yourself? (I used two OpenG array VIs to make it easier.)
Edit: added images
06-23-2010 05:16 PM
Hello Jim,
Frankly to say I dont know how to code in labview, so I havent tried it doing myself. We are using a NI hardware USB 8473 for CAN communication. So we are trying to develope a much user friendly GUI for our group. Where we need to add this piece of code. If you can post the solution it would be much helpful for us.
Thanxs
-Raghu.
06-24-2010 05:01 AM - edited 06-24-2010 05:01 AM
06-24-2010 05:21 AM
06-25-2010 12:09 AM
Sure Jim, I can definitely share my project details.Here is what we are trying to achieve.
The attached vi is used to transmit the messages to Engine ECM. It takes the input's *.dbc file where the channel names are defined
The present vi is working like this. It transmit messages correctly only if the messages are defined in the ascending order(the order in which they are defined in the *.dbc file).
Say for example take 3 PGNS
1) 18ff0fef Which has the following channels in the PGN
a) Notch
b) Gear
c) Service brake
2) 14ff2ef which has the following channels in the PGN
a) Bus_voltage
b) Bus_current
c) power
3)14ff03ef which has the following channels in the PGN
a) Coolant_temp
b) oil_press
c) Imat
If I want to transmit the following channels and define them in the following order
1) Gear
2) Imat
3) Bus_voltage
4) Notch
The program is only writing correct data for Gear,Imat and some garbage values for Bus_voltage and Notch.
But if I define the channels in the ascending order as defined in the *.dbc file in the following fashion
1)Notch
2)Gear
3)Bus_voltage
4)Imat
I can transmit the right data for each channel.
So what Iam trying to do is Iam planning to sort out all the channels names what user enter's and sort the channels in the order as defined in the *.dbc file and pass it to the program.
And the other issue I am facing is if two channels belong to the same PGN like Gear and Notch I have to transmit the values in the same array.
Say for example i want to transmit the values as follows Notch =4; Gear = 3; Bus_voltage = 25; Imat = 80 the array matrix will be like this
Array_1: 4,3
Array_2: 25
Array_3: 80.
I was able to sort out all the channels listed in the *.dbc file in to single array but have no clue how to do the rest of work. Can you please help me in achieving the expected result. Iam attaching the vi and picture which describes where channel information and channel values are passed to the program.
Thank you,
- Raghu
06-25-2010 05:46 AM
My program worked for me with your data entered in both orders. The only times I have had trouble has been when I didn't match the case of one of the elements. Have you tried the file in my last post, or the one before it?
I don't understand what you're looking for at the end of your post. I'm guessing that the order of the elements in "scaled data" matches the order in "User input". Is this correct?