what i need to do is to repeat each line but with increasing the sequence column by one.
The out put of the csv file is as follows:
PROJECT;SEQUENCE;STEP;XPOS;YPOS;ZPOS;WRIST;WRISTROT;SPEED;PAUSE
1084;1;1;-12;-18;0;71;-51;30;400
1084;2;1;13;-18;0;71;-51;30;400
1084;3;1;0;0;0;71;-51;30;0
1084;4;1;0;0;0;71;-51;30;0
1084;5;1;18,33;5,46;20;71;-51;30;400
1084;6;1;18,33;5,46;20;71;-51;30;2000
1084;7;1;18,33;5,46;20;71;-51;30;400
1084;8;1;36,57;6,27;20;71;-51;30;400
1084;9;1;36,57;6,27;20;71;-51;30;400
1084;10;1;36,57;6,27;20;71;-51;30;400
1084;11;1;36,57;6,27;20;71;-51;30;0
1084;12;1;-12;-18;0;71;-51;30;400
The code is as follows:
Note that XX.Count = 9, I want to repeat each line after the original line starting from buffer[2]. So the First two lines (buffer[0],buffer[1]) and the last line buffer[buffer.Length-1]should not be repeated.. I just want to repeat each line but with increasing the sequence.
so the output of the sequence will be 1,2,3,4,5,6,7,8.... till buffer.Length-1
static void generatecsv(int MobileID)
{
string ProgramPfad = (@"C:\Robotron\MobileRobotDaten\" + MobileID + ".csv");
List
List
Menu_Tree(MobileID, out XX, out YY, out ZZ, out VV);
string[] buffer = new string[XX.Count + 3];
using (System.IO.StreamWriter file = new System.IO.StreamWriter(ProgramPfad))
{
double x_robot = -12.0;
double y_robot = -18.0;
double z_robot = 0.0;
double x_distance = 25.0;
double y_distance = 0.0;
file.WriteLine("PROJECT;SEQUENCE;STEP;XPOS;YPOS;ZPOS;WRIST;WRISTROT;SPEED;PAUSE");
buffer[0] = (MobileID + ";" + 1 + ";" + 1 + ";" + x_robot + ";" + y_robot + ";" + z_robot + ";" + 71 + ";" + -51 + ";" + 30 + ";" + 400);
buffer[1] = (MobileID + ";" + 2 + ";" + 1 + ";" + (x_robot + x_distance) + ";" + (y_robot + y_distance) + ";" + z_robot + ";" + 71 + ";" + -51 + ";" + 30 + ";" + 400);
file.WriteLine(buffer[0]);
file.WriteLine(buffer[1]);
for (int i = 2; i < buffer.Length - 1; i++)
{
if (VV[i - 2] == -1)
{
buffer[i] = (MobileID + ";" + (i + 1) + ";" + 1 + ";" + XX[i - 2] + ";" + YY[i - 2] + ";" + ZZ[i - 2] + ";" + 71 + ";" + -51 + ";" + 30 + ";" + 400);
}
else
{
buffer[i] = (MobileID + ";" + (i + 1) + ";" + 1 + ";" + XX[i - 2] + ";" + YY[i - 2] + ";" + ZZ[i - 2] + ";" + 71 + ";" + -51 + ";" + 30 + ";" + (VV[i - 2] * 1000));
}
file.WriteLine(buffer[i]);
}
buffer[buffer.Length - 1] = buffer[0] = (MobileID + ";" + (buffer.Length) + ";" + 1 + ";" + x_robot + ";" + y_robot + ";" + z_robot + ";" + 71 + ";" + -51 + ";" + 30 + ";" + 400);
file.WriteLine(buffer[buffer.Length - 1]);
}
}
VulpesPosted Oct 23, 2014, 9:18 AM
((j == seq) ? ZZ[i - 2] : 0.0)
Hesham HassaneinPosted Oct 23, 2014, 9:28 AM
Hesham HassaneinPosted Oct 23, 2014, 9:04 AM
VulpesPosted Oct 23, 2014, 8:58 AM
Hesham HassaneinPosted Oct 23, 2014, 8:07 AM
buffer[0] sequence =1
buffer[1] sequence=2
buffer[2] sequence=3
buffer[2] sequence=4
buffer[3] sequence=5
buffer[3] sequence=6
and so on till buffer[buffer.Length-1] this should not be repeated
VulpesPosted Oct 23, 2014, 7:53 AM
So, just to be clear, are you saying that you want:
buffer[2] to be repeated 1 time
buffer[3] to be repeated 2 times
buffer[4] to be repeated 3 times
and so on?
Hesham HassaneinPosted Oct 23, 2014, 6:03 AM