コード例 #1
0
ファイル: MotionWatch.cs プロジェクト: lynch829/Autodrive
        public void AddMotion(double currentValue, double nextValue, double speedPerSec)
        {
            var diff = Math.Abs(currentValue - nextValue);
            var sec  = diff / speedPerSec + 1.5; //small buffer for small motions

            if (!double.IsNaN(sec))
            {
                motionsToExecute.Add(sec);
                MotionCompleteEvent.Reset();
            }
        }
コード例 #2
0
ファイル: MotionWatch.cs プロジェクト: lynch829/Autodrive
 public void StartMotionClock()
 {
     if (motionsToExecute.Any())
     {
         MotionCompleteEvent.Reset();
         IsSystemInMotion = true;
         var maxTime = motionsToExecute.Max();
         Console.WriteLine($"Waiting {maxTime * 1000} ms for motion to complete...");
         timer = new Timer(SignalMotionComplete, null, (int)(maxTime * 1000), Timeout.Infinite);
     }
     else
     {
         MotionCompleteEvent.Set();
         IsSystemInMotion = false;
     }
 }