i have a measurement-instrument that creates measurements for a specified time. During this time i have to fetch the measurements from the internal memory to prevent an overflow. Currently i have this:
public int FetchDatalog(int Time_s, double Period, out int Count, ref double[] Results)
{
Count = 0;
try
{
DateTime timeout = DateTime.UtcNow.AddSeconds(Time_s);
double[] values;
while (DateTime.UtcNow < timeout)
{
values = //here is the command to tell the instrument to return 10 results
Count = values.Count();
Thread.Sleep(500);
//HERE IS SOMETHING MISSING <-----
}
}
return 0;
}
So i have a function that reads in a loop always 10 results from a instruments until a specified time is over. During the loops the read data must be merged.
At the arrow-marked position i need now something that merges the 10 values together and finally returns all merged values back in results.
How can i do this with unknown length?
(As extra problem is: The 10 results can be "up to 10" results. Sometimes less then 10, so i could change here also if needed to only read 1 value, but this would make it slowlier.
Thanks for all help
Added comment here so its readable - Sayse
I mean merge:
loop1: values[]=1,2,3,4,5,6,7,8,9,0;
loop2: values[]=11,22,33,44,55,66,77,88,99,11
loop3: values[]=111,222,333,444,555,666,777,888,999,111
This three values should finally return in parameter result as
result[]=1,2,3,4,5,6,7,8,9,0,11,22,33,44,55,66,
77,88,99,11,111,222,333,444,555,666,777,888,999,111
So they should be put together to a bigger array.
List<double>of the results? All this messing around withrefandoutparameters is a bit odd (as are your parameter names).Thread.Sleepis doing anything usefulList<double>and at your arrow position, dotheList.AddRange(values);. Then you have all the results together once the loop ends.