Exemple #1
0
 private void SignalMotionComplete(object state)
 {
     MotionCompleteEvent.Set();
     timer.Dispose();
     IsSystemInMotion = false;
     motionsToExecute.Clear();
 }
Exemple #2
0
        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();
            }
        }
Exemple #3
0
 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;
     }
 }