public IEnumerator <ITask> EnableDriveHandler(EnableDrive enableDrive) { _state.IsEnabled = enableDrive.Body.Enable; _state.TimeStamp = DateTime.Now; // if we are enabling the drive, validate that the motors are configured. if (enableDrive.Body.Enable) { try { ValidateDriveConfiguration(false); } catch (InvalidOperationException) { // If validation fails, // force the state to not be enabled. _state.IsEnabled = false; // rethrow the fault throw; } } // send notification to subscription manager drive.Update update = new drive.Update(_state); SendNotification <drive.Update>(_subMgrPort, update); enableDrive.ResponsePort.Post(DefaultUpdateResponseType.Instance); yield break; }
public void DriveEnableDriveHandler(drive.EnableDrive enabledrive) { this.controllerDrivePort.Post( new drive.EnableDrive() { Body = enabledrive.Body, ResponsePort = enabledrive.ResponsePort }); }
public IEnumerator <ITask> EnableDriveHandler(drive.EnableDrive enableDrive) { _state.IsEnabled = enableDrive.Body.Enable; _state.TimeStamp = DateTime.Now; // send notification to subscription manager _subMgrPort.Post(new submgr.Submit(_state, DsspActions.UpdateRequest)); enableDrive.ResponsePort.Post(new DefaultUpdateResponseType()); yield break; }
public void DriveEnableHandler(diffdrive.EnableDrive enable) { if (this.driveEntity == null) { throw new InvalidOperationException("Simulation entity not registered with service"); } this.state.DriveState.IsEnabled = enable.Body.Enable; this.driveEntity.IsEnabled = this.state.DriveState.IsEnabled; this.UpdateStateFromSimulation(); enable.ResponsePort.Post(DefaultUpdateResponseType.Instance); // send update for entire state this.subMgrPort.Post(new submgr.Submit(this.state.DriveState, DsspActions.UpdateRequest)); }
public IEnumerator <ITask> DriveEnableDriveHandler(drive.EnableDrive enabledrive) { this.state.DriveState.TimeStamp = DateTime.Now; this.state.DriveState.IsEnabled = enabledrive.Body.Enable; // The caller's intent is to disable the drive, so we need to set motor power to zero if (!this.state.DriveState.IsEnabled) { serialcomservice.SendAndGetRequest sg = new serialcomservice.SendAndGetRequest(); sg.Timeout = this.state.DefaultResponsePause; sg.Data = new serialcomservice.Packet(board.CreatePacket <byte>(board.SetFullStopString)); var resultPort = this.serialCOMServicePort.SendAndGet(sg); yield return(resultPort.Choice()); soap.Fault f = (soap.Fault)resultPort; if (f != null) { LogError(string.Format("Failed to send command: {0}", board.SetFullStopString)); enabledrive.ResponsePort.Post(f); yield break; } if (this.HasFWError((serialcomservice.Packet)resultPort)) { f = soap.Fault.FromCodeSubcodeReason(soap.FaultCodes.Receiver, DsspFaultCodes.OperationFailed, "Error received from FW!"); enabledrive.ResponsePort.Post(f); yield break; } // Reflect into state this.state.DriveState.LeftWheel.MotorState.CurrentPower = GDDriveFullStop; this.state.DriveState.RightWheel.MotorState.CurrentPower = GDDriveFullStop; this.state.DriveState.LeftWheel.WheelSpeed = 0; this.state.DriveState.RightWheel.WheelSpeed = 0; } enabledrive.ResponsePort.Post(DefaultUpdateResponseType.Instance); }