private void stepCallback(object state) { Queue<armMovement> dance = (Queue<armMovement>)state; //the dance should be one move shorter now if (safe) { armMovement lastMove = dance.Dequeue(); if (inRange(lastMove.target,lastMove.ID)) { if (dance.Count > 0) { currentMovement = dance.Peek(); if (transmitMove(currentMovement.ID, currentMovement.target)) { stepTimer.Change(currentMovement.waitTime, Timeout.Infinite); } else { safe = false; if (macroEventStatusUpdate != null) { macroEventStatusUpdate(safe); } stepTimer.Change(0, Timeout.Infinite); } } else { safe = false; if (macroEventStatusUpdate != null) { macroEventStatusUpdate(safe); } stepTimer.Change(0, Timeout.Infinite); } } else { safe = false; if (macroEventStatusUpdate != null) { macroEventStatusUpdate(safe); } stepTimer.Change(0, Timeout.Infinite); } } }
public void performMacro(Queue<armMovement> dance) { stepTimer.Change(Timeout.Infinite, Timeout.Infinite); currentDance = dance; safe = true; if (macroEventStatusUpdate != null) { macroEventStatusUpdate(safe); } if (currentDance.Count > 0) { currentMovement = currentDance.Peek(); if (transmitMove(currentMovement.ID, currentMovement.target)) { stepTimer = new Timer(stepCallback, currentDance, currentMovement.waitTime, Timeout.Infinite); } else { safe = false; if (macroEventStatusUpdate != null) { macroEventStatusUpdate(safe); } stepTimer.Change(0, Timeout.Infinite); } } }