public IEnumerator <ITask> EnableDriveHandler(drive.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
            Update update = new Update(_state);

            SendNotification <Update>(_subMgrPort, update);

            enableDrive.ResponsePort.Post(DefaultUpdateResponseType.Instance);
            yield break;
        }
Esempio n. 2
0
 public virtual IEnumerator <ITask> EnableDriveHandler(drive.EnableDrive update)
 {
     _state.IsEnabled = update.Body.Enable;
     _state.TimeStamp = DateTime.Now;
     update.ResponsePort.Post(new DefaultUpdateResponseType());
     SendNotification <drive.Update>(_subMgrPort, _state);
     yield break;
 }
Esempio n. 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;
        }
        public IEnumerator <ITask> EnableHandler(diffdrive.EnableDrive enable)
        {
            if (_entity == null)
            {
                throw new InvalidOperationException("Simulation entity not registered with service");
            }

            _state.IsEnabled  = enable.Body.Enable;
            _entity.IsEnabled = _state.IsEnabled;

            UpdateStateFromSimulation();
            enable.ResponsePort.Post(DefaultUpdateResponseType.Instance);

            // send update for entire state
            _subMgrPort.Post(new submgr.Submit(_state, DsspActions.UpdateRequest));
            yield break;
        }
        public virtual IEnumerator<ITask> GenericAllStopHandler(pxdrive.AllStop allStop)
        {
            DriveDistance drive = new DriveDistance(new SetDriveRequest());
            drive.Body.LeftPower = 0.0;
            drive.Body.RightPower = 0.0;
            drive.Body.LeftStopAtRotationDegrees = 0;
            drive.Body.RightStopAtRotationDegrees = 0;
            drive.Body.StopState = MotorStopState.Brake;
            drive.ResponsePort = allStop.ResponsePort;
            drive.Body.DriveRequestOperation = pxdrive.DriveRequestOperation.AllStop;
            _internalDrivePowerPort.Post(drive);

            // disable drive
            _genericState.IsEnabled = false;
            pxdrive.EnableDrive disableDrive = new pxdrive.EnableDrive();
            disableDrive.Body.Enable = _genericState.IsEnabled;
            _genericState.TimeStamp = DateTime.Now;
            _state.TimeStamp = _genericState.TimeStamp;
            SendNotification<pxdrive.EnableDrive>(_genericSubMgrPort, disableDrive);

            _drivePort.Post(disableDrive);
            yield break;
        }