Пример #1
0
        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;
        }
Пример #2
0
 public void DriveEnableDriveHandler(drive.EnableDrive enabledrive)
 {
     this.controllerDrivePort.Post(
         new drive.EnableDrive()
     {
         Body = enabledrive.Body, ResponsePort = enabledrive.ResponsePort
     });
 }
Пример #3
0
        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;
        }
Пример #4
0
        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));
        }
Пример #5
0
        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);
        }