/// <summary> /// HAS TO BE CALLED WITH _L_instrutionCompletition /// </summary> private void onInstructionCompleted() { var now = DateTime.Now; _lastInstructionStartTime = now; _uEstimation = _vEstimation = _xEstimation = _yEstimation = 0; if (_incompleteInstructionQueue.Count == 0) { //TODO probably garbage from buffer return; } var instruction = _incompleteInstructionQueue.Dequeue(); _completedState.Completed(instruction); --_incompleteInstructions; }
private void runCncSimulator() { IsConnected = true; fireOnConnectionStatusChange(); _plannedState.Completed(new HomingInstruction()); _completedState.Completed(new HomingInstruction()); var simulationDelay = 100; while (true) { Thread.Sleep(simulationDelay); if (_incompleteInstructionQueue.Count > 0) { InstructionCNC instruction; lock (_L_instructionCompletition) { _lastInstructionStartTime = DateTime.Now; instruction = _incompleteInstructionQueue.Peek(); } var tickCount = instruction.CalculateTotalTime(); var time = 1000 * tickCount / Constants.TimerFrequency; if (SIMULATE_REAL_DELAY) { Thread.Sleep((int)Math.Max(0, (long)time - (long)simulationDelay)); } else { Thread.Sleep(200); } lock (_L_instructionCompletition) { onInstructionCompleted(); if (_incompleteInstructionQueue.Count == 0 && OnInstructionQueueIsComplete != null) { OnInstructionQueueIsComplete(); } } } } }
private bool checkBoundaries(InstructionCNC instruction, ref StateInfo state) { state.Completed(instruction); return(state.CheckBoundaries()); }