private void BeginArmMovement(int timeForMovement, Model_Arm.ArmPosition newPosn) { // Should only get here with a positive time and the _ArmTimer not running // Double check the arm and grip are not already moving if ((timeForMovement >= 0) && (Model_Arm.ArmStatus.HALT == ArmStatus) && (Model_Arm.GripStatus.HALT == GripStatus) && (false == _ArmTimer.Enabled)) { // Set the Arm status to moving as we simulate the arm movement ArmStatus = Model_Arm.ArmStatus.MOVING; // Set the current arm position to unknown as we simulate that we cannot know where it is ArmPosition = Model_Arm.ArmPosition.UNKNOWN; // Do not change grip position FutureGripPosition = GripPosition; // Future arm position set FutureArmPosition = newPosn; _ArmTimer.Interval = timeForMovement; _ArmTimer.Enabled = true; _ArmTimer.Start(); } }
/// <summary> /// Fires when the grip movement has simulated and the appropriate time has elapsed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _Griptimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { _GripTimer.Stop(); _GripTimer.Enabled = false; // Arm and Grip have finished movement ArmPosition = FutureArmPosition; ArmStatus = Model_Arm.ArmStatus.HALT; GripPosition = FutureGripPosition; GripStatus = Model_Arm.GripStatus.HALT; // Clear future positions FutureArmPosition = Model_Arm.ArmPosition.UNKNOWN; FutureGripPosition = Model_Arm.GripPosition.UNKNOWN; // Notify top level state machine of success if (Model_Arm.GripPosition.CLOSED == GripPosition) { RaiseGripEventOnTopLevel(OnGripUpdateEvent, new object[] { this, true, VialIndex, GripPosition, Rack, string.Format("\nAt {0}: Grabbed Vial ID{1} from {2} rack", e.SignalTime, VialIndex, Rack) }); } if (Model_Arm.GripPosition.OPEN == GripPosition) { RaiseGripEventOnTopLevel(OnGripUpdateEvent, new object[] { this, true, VialIndex, GripPosition, Rack, string.Format("\nAt {0}: Released Vial ID{1} to {2} rack", e.SignalTime, VialIndex, Rack) }); } }
/// <summary> /// Fires when the arm movement has simulated and the appropriate time has elapsed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _Armtimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { _ArmTimer.Stop(); _ArmTimer.Enabled = false; // Arm and Grip have finished movement ArmPosition = FutureArmPosition; ArmStatus = Model_Arm.ArmStatus.HALT; GripPosition = FutureGripPosition; GripStatus = Model_Arm.GripStatus.HALT; // Clear future positions FutureArmPosition = Model_Arm.ArmPosition.UNKNOWN; FutureGripPosition = Model_Arm.GripPosition.UNKNOWN; // Notify top level state machine of success RaiseArmEventOnTopLevel(OnArmUpdateEvent, new object[] { this, true, string.Format("\nAt {0}: Arm is at {1}", e.SignalTime, ArmPosition) }); }
private void BeginGripMovement(int timeForGripAction, int index, Model_Rack.RackPurpose rack, Model_Arm.GripPosition newPosn, Model_Arm.GripStatus newStatus) { // Should only get here with a positive time and the _ArmTimer not running // Double check the arm and grip are not already moving if ((timeForGripAction >= 0) && (Model_Arm.ArmStatus.HALT == ArmStatus) && (Model_Arm.GripStatus.HALT == GripStatus) && (false == _GripTimer.Enabled)) { // Set the grip status and next state GripPosition = Model_Arm.GripPosition.UNKNOWN; GripStatus = newStatus; FutureGripPosition = newPosn; VialIndex = index; Rack = rack; // Do not overwrite arm position FutureArmPosition = ArmPosition; _GripTimer.Interval = timeForGripAction; _GripTimer.Enabled = true; _GripTimer.Start(); } }
/// <summary> /// Received then the grip has completed a movement /// </summary> /// <param name="sender"></param> /// <param name="proceed"></param> /// <param name="message"></param> private void Arm_OnGripUpdateEventReceived(ViewModel_Arm sender, bool proceed, int index, Model_Arm.GripPosition grip, Model_Rack.RackPurpose rack, string message) { if (proceed) { if (SimulationState.STAGE1_PICK_UP_INPUT_VIAL == _CurrentState) { // Belt and braces if (Model_Rack.RackPurpose.INPUT == rack) { // Just picked up from input so set current input ID _InputRack.SetCurrentID(index); _RefreshInput = false; } } if (SimulationState.STAGE6_PICK_UP_OUTPUT_VIAL == _CurrentState) { // Belt and braces if (Model_Rack.RackPurpose.OUTPUT == rack) { // Just picked up from output so set current output ID _OutputRack.SetCurrentID(index); } } if (SimulationState.STAGE10_PLACE_VIAL_AT_OUTPUT == _CurrentState) { // Belt and braces if (Model_Rack.RackPurpose.OUTPUT == rack) { _OutputRack.SetCurrentID(index + 1); } } DoProceed(); } RaiseEventOnTopLevel(OnSimulationUpdateEvent, new object[] { this, message }); }