private static int CompareTimes(RangeDeviceEventArgs x, RangeDeviceEventArgs y) { if (x == null) { if (y == null) { // If x is null and y is null, they're // equal. return(0); } else { // If x is null and y is not null, y // is greater. return(-1); } } else { // If x is not null... // if (y == null) // ...and y is null, x is greater. { return(1); } else { // ...and y is not null, compare the // lengths of the two strings. // //int retval = x.Timestamp.CompareTo(y.Timestamp); return(x.Timestamp.CompareTo(y.Timestamp)); //if (retval != 0) //{ // // If the strings are not of equal length, // // the longer string is greater. // // // return retval; //} //else //{ // // If the strings are of equal length, // // sort them with ordinary string comparison. // // // return x.Timestamp.CompareTo(y.Timestamp); //} } } }
private void AsyncThread_DoWork(object sender) { ReplayTimer Time = new ReplayTimer(); float statusPrevTime = 0; float rangePrevTime = 0; RangeDeviceEventArgs rPrev = null; StatusEventArgs sPrev = null; Time.Reset(); Time.Start(); StatusDataReceived?.Invoke(new object(), StartingStatusEventArgs); foreach (RangeDeviceEventArgs e in StartingRangeDeviceCurrentReadings) { RangeDeviceCurrentDataReceived?.Invoke(new object(), e); } while (IsRunning) { if (IsPaused) { Time.Stop(); Thread.Sleep(UpdateRate); continue; } Time.Start(); Time.Tick(); foreach (RangeDeviceEventArgs r in ReplayLaserEntries) { if (r.Timestamp >= Time.TotalTime) { if (r.Timestamp == rangePrevTime) { break; } rangePrevTime = r.Timestamp; if (rPrev == null) { rPrev = r; } RangeDeviceCurrentDataReceived?.Invoke(new object(), rPrev); rPrev = r; break; } } foreach (StatusEventArgs r in ReplayStatusEntries) { if (r.Timestamp >= Time.TotalTime) { if (r.Timestamp == statusPrevTime) { break; } statusPrevTime = r.Timestamp; if (sPrev == null) { sPrev = r; } StatusDataReceived?.Invoke(new object(), sPrev); sPrev = r; break; } } Thread.Sleep(UpdateRate); //Robot.Write("onelinestatus"); //foreach (string l in Devices) //{ // Robot.Write("rangeDeviceGetCurrent " + l); //} //foreach (string l in Devices) //{ // Robot.Write("rangeDeviceGetCumulative " + l); //} } }