// the counting loop private void countingLoop() { QueryPerformanceCounter(out startTime); flag_OutOfLoop = false; // entering the loop while (Enabled) { QueryPerformanceCounter(out currentTime); // obtaining current time double diff = (currentTime - startTime) / (1.0 * ClockFrequency); if (diff >= Interval) { // creating a new (overflow) event var handler = TimerOverflow; PrecisionTimerEventArgs args = new PrecisionTimerEventArgs(diff); if (handler != null) { handler(this, args); } QueryPerformanceCounter(out startTime); // resetting the startTime in order to capture the next overflow } } flag_OutOfLoop = true; // just left the loop. Clear to kill the thread }
public void IMUSamplingEvent(Object s, PrecisionTimerEventArgs e) { if (IMUcomms != null) { if (IMUcomms.Flag_CommsActive) { Matrix <float> imudata = new Matrix <float>(1, 6); imudata.Data[0, 0] = IMUcomms.Last_Acc1; imudata.Data[0, 1] = IMUcomms.Last_Acc2; imudata.Data[0, 2] = IMUcomms.Last_Acc3; imudata.Data[0, 3] = IMUcomms.Last_Angvel1; imudata.Data[0, 4] = IMUcomms.Last_Angvel2; imudata.Data[0, 5] = IMUcomms.Last_Angvel3; if (!Flag_GravityFound_Y) // check for gravity along the Y axis { Flag_GravityFound_Y = (Math.Abs(imudata.Data[0, 0] - 1.0) < 0.001); } if (Flag_GravityFound_Y) // record the data { IMUDataInstance newIMUData = new IMUDataInstance(FrameIndex, IMUcomms.Last_Acc1, IMUcomms.Last_Acc2, IMUcomms.Last_Acc3, IMUcomms.Last_Angvel1, IMUcomms.Last_Angvel2, IMUcomms.Last_Angvel3); IMUCapturedata.Add(newIMUData); } } } }
// the counting loop private void countingLoop() { QueryPerformanceCounter(out startTime); flag_OutOfLoop = false; // entering the loop while (Enabled) { QueryPerformanceCounter(out currentTime); // obtaining current time double diff = (currentTime - startTime) / (1.0 * ClockFrequency); if (diff >= Interval) { // creating a new (overflow) event var handler = TimerOverflow; PrecisionTimerEventArgs args = new PrecisionTimerEventArgs(diff); if (handler != null) { handler(this, args); } QueryPerformanceCounter(out startTime); // resetting the startTime in order to capture the next overflow } } flag_OutOfLoop = true; // just left the loop. Clear to kill the thread }
public void IMUSamplingEvent(Object s, PrecisionTimerEventArgs e) { if (IMUcomms != null) if (IMUcomms.Flag_CommsActive) { Matrix<float> imudata = new Matrix<float>(1, 6); imudata.Data[0, 0] = IMUcomms.Last_Acc1; imudata.Data[0, 1] = IMUcomms.Last_Acc2; imudata.Data[0, 2] = IMUcomms.Last_Acc3; imudata.Data[0, 3] = IMUcomms.Last_Angvel1; imudata.Data[0, 4] = IMUcomms.Last_Angvel2; imudata.Data[0, 5] = IMUcomms.Last_Angvel3; if (!Flag_GravityFound_Y) // check for gravity along the Y axis Flag_GravityFound_Y = (Math.Abs(imudata.Data[0, 0] - 1.0) < 0.001); if (Flag_GravityFound_Y) // record the data { IMUDataInstance newIMUData = new IMUDataInstance(FrameIndex, IMUcomms.Last_Acc1, IMUcomms.Last_Acc2, IMUcomms.Last_Acc3, IMUcomms.Last_Angvel1, IMUcomms.Last_Angvel2, IMUcomms.Last_Angvel3); IMUCapturedata.Add(newIMUData); } } }