Example #1
0
 public IEnumerator <ITask> UpdateHandler(Update update)
 {
     _state           = update.Body;
     _state.TimeStamp = DateTime.Now;
     update.ResponsePort.Post(new DefaultUpdateResponseType());
     yield break;
 }
Example #2
0
        /// <summary>
        /// Service Start
        /// </summary>
        protected override void Start()
        {
            if (_state == null)
            {
                //add default state.
                //NOTE: because this is a custom implementation of the drive service, we can hard code values
                //also, because there are no encoders, we do not need any of the wheel measurements.

                _state           = new drive.DriveDifferentialTwoWheelState();
                _state.IsEnabled = true;

                _state.LeftWheel                 = new Microsoft.Robotics.Services.Motor.WheeledMotorState();
                _state.LeftWheel.Name            = "Left Wheel";
                _state.LeftWheel.MotorState      = new Microsoft.Robotics.Services.Motor.MotorState();
                _state.LeftWheel.MotorState.Name = "Left Motor";

                _state.RightWheel                 = new Microsoft.Robotics.Services.Motor.WheeledMotorState();
                _state.RightWheel.Name            = "Right Wheel";
                _state.RightWheel.MotorState      = new Microsoft.Robotics.Services.Motor.MotorState();
                _state.RightWheel.MotorState.Name = "Right Motor";
            }

            // Listen on the main port for requests and call the appropriate handler.
            ActivateDsspOperationHandlers();

            // Publish the service to the local Node Directory
            DirectoryInsert();

            // display HTTP service Uri
            LogInfo(LogGroups.Console, "Service uri: ");
        }
Example #3
0
        private void InitState()
        {
            if (_state != null)
            {
                _state.TimeStamp = DateTime.Now;
                return;
            }

            _state                      = new DriveDifferentialTwoWheelState();
            _state.LeftWheel            = new motor.WheeledMotorState();
            _state.LeftWheel.MotorState = new motor.MotorState();
            _state.LeftWheel.MotorState.HardwareIdentifier = 1;
            _state.LeftWheel.MotorState.Name = "Left Motor";
            _state.LeftWheel.MotorState.PowerScalingFactor = 1;


            _state.RightWheel            = new motor.WheeledMotorState();
            _state.RightWheel.MotorState = new motor.MotorState();
            _state.RightWheel.MotorState.HardwareIdentifier = 2;
            _state.RightWheel.MotorState.Name = "Right Motor";
            _state.RightWheel.MotorState.PowerScalingFactor = 1;

            _state.LeftWheel.EncoderState  = new encoder.EncoderState();
            _state.RightWheel.EncoderState = new encoder.EncoderState();

            _state.IsEnabled = true;
            _state.TimeStamp = DateTime.Now;
            _state.InternalPendingDriveOperation = DriveRequestOperation.NotSpecified;

            SaveState(_state);
        }
Example #4
0
        /// <summary>
        /// Service Start
        /// </summary>
        protected override void Start()
        {
            if (_state == null)
            {
                //add default state.  
                //NOTE: because this is a custom implementation of the drive service, we can hard code values
                //also, because there are no encoders, we do not need any of the wheel measurements.

                _state = new drive.DriveDifferentialTwoWheelState();
                _state.IsEnabled = true;

                _state.LeftWheel = new motor.WheeledMotorState();
                _state.LeftWheel.Name = "Left Wheel";
                _state.LeftWheel.MotorState = new motor.MotorState();
                _state.LeftWheel.MotorState.Name = "Left Motor";

                _state.RightWheel = new motor.WheeledMotorState();
                _state.RightWheel.Name = "Right Wheel";
                _state.RightWheel.MotorState = new motor.MotorState();
                _state.RightWheel.MotorState.Name = "Right Motor";
            }

            // Listen on the main port for requests and call the appropriate handler.
            ActivateDsspOperationHandlers();

            // Publish the service to the local Node Directory
            DirectoryInsert();

            // display HTTP service Uri
            LogInfo(LogGroups.Console, "Service uri: ");
        }
Example #5
0
        public IEnumerator <ITask> DriveHttpGetHandler(Microsoft.Dss.Core.DsspHttp.HttpGet httpget)
        {
            drive.Get get = new drive.Get();

            this.controllerDrivePort.Post(get);

            yield return(get.ResponsePort.Choice());

            drive.DriveDifferentialTwoWheelState newState = (drive.DriveDifferentialTwoWheelState)get.ResponsePort;

            if (newState != null)
            {
                HttpResponseType resp = new HttpResponseType(HttpStatusCode.OK, newState);
                httpget.ResponsePort.Post(resp);
            }
            else
            {
                HttpResponseType resp = new HttpResponseType(HttpStatusCode.InternalServerError, (soap.Fault)get.ResponsePort);
                httpget.ResponsePort.Post(resp);
            }

            yield break;
        }
Example #6
0
        private void InitState()
        {
            if (_state != null)
            {
                _state.TimeStamp = DateTime.Now;
                return;
            }

            _state = new DriveDifferentialTwoWheelState();
            _state.LeftWheel = new motor.WheeledMotorState();
            _state.LeftWheel.MotorState = new motor.MotorState();
            _state.LeftWheel.MotorState.HardwareIdentifier = 1;
            _state.LeftWheel.MotorState.Name = "Left Motor";
            _state.LeftWheel.MotorState.PowerScalingFactor = 1;

            _state.RightWheel = new motor.WheeledMotorState();
            _state.RightWheel.MotorState = new motor.MotorState();
            _state.RightWheel.MotorState.HardwareIdentifier = 2;
            _state.RightWheel.MotorState.Name = "Right Motor";
            _state.RightWheel.MotorState.PowerScalingFactor = 1;

            _state.LeftWheel.EncoderState = new encoder.EncoderState();
            _state.RightWheel.EncoderState = new encoder.EncoderState();

            _state.IsEnabled = true;
            _state.TimeStamp = DateTime.Now;
            _state.InternalPendingDriveOperation = DriveRequestOperation.NotSpecified;

            SaveState(_state);
        }
Example #7
0
 public IEnumerator<ITask> UpdateHandler(Update update)
 {
     _state = update.Body;
     _state.TimeStamp = DateTime.Now;
     update.ResponsePort.Post(new DefaultUpdateResponseType());
     yield break;
 }
Example #8
0
 /// <summary>
 /// Initialization Constructor
 /// </summary>
 /// <param name="state"></param>
 public Update(DriveDifferentialTwoWheelState state)
 {
     this.Body = state;
 }