/// <summary> /// 获取最新速度数据并发送 /// </summary> private void OnUpdateGestureResultTime(object sender, System.Timers.ElapsedEventArgs e) { EulerAngle upperOffset = EulerAngleOffset(_latestUpperArmAngleSpeed); EulerAngle foreOffset = EulerAngleOffset(_latestForeArmAngleSpeed); GestureUpdated?.Invoke(upperOffset, foreOffset); }
/// <summary> /// Updates gesture. Start timer which deactivates gesture state after certain amount of time. /// </summary> /// <param name="timer">Timer object.</param> /// <param name="type">Gesture type.</param> private void UpdateGesture(ref CancellableTimer timer, GestureType type) { if (timer?.IsRunning == true) { timer.Stop(); } GestureUpdated?.Invoke(type, true); timer = new CancellableTimer(TimeSpan.FromMilliseconds(GestureTimeout), () => { GestureUpdated?.Invoke(type, false); }); timer.Start(); }