Пример #1
0
 public virtual IEnumerator <ITask> AlternateGetHandler(analog.Get get)
 {
     _alternateState = new analog.AnalogSensorState();
     _alternateState.RawMeasurement = _state.SoundReading;
     _alternateState.TimeStamp      = _state.TimeStamp;
     get.ResponsePort.Post(_alternateState);
     yield break;
 }
        public IEnumerator <ITask> GetHandler(analogarray.Get get)
        {
            var state = new analogarray.AnalogSensorArrayState();

            state.Sensors = new List <analogsensor.AnalogSensorState>(this.sensorPorts.Length);

            // compose state on the fly by issuing N parallel GET requests to partners
            var getSensorState = new analogsensor.Get();

            foreach (var port in this.sensorPorts)
            {
                state.Sensors.Add(null);
                port.Post(getSensorState);
            }

            ICollection <analogsensor.AnalogSensorState> sensorStates = null;
            ICollection <Fault> faults = null;

            yield return(getSensorState.ResponsePort.MultipleItemReceive(
                             this.sensorPorts.Length,
                             (s, f) =>
            {
                sensorStates = s;
                faults = f;
            }));

            if (faults != null && faults.Count > 0)
            {
                get.ResponsePort.Post(Fault.FromCodeSubcode(FaultCodes.Receiver, DsspFaultCodes.OperationFailed));
                yield break;
            }

            foreach (var sensorState in sensorStates)
            {
                state.Sensors[sensorState.HardwareIdentifier] = sensorState;
            }

            var stateClone = state.Clone() as analogarray.AnalogSensorArrayState;

            get.ResponsePort.Post(stateClone);
            yield break;
        }
 public virtual IEnumerator <ITask> GetHandler(pxanalogsensor.Get get)
 {
     // the state is updated automatically
     get.ResponsePort.Post(_state);
     yield break;
 }
Пример #4
0
 public IEnumerator <ITask> GetHandler(analog.Get get)
 {
     get.ResponsePort.Post(_state);
     yield break;
 }
 public virtual IEnumerator <ITask> AnalogGetHandler(pxanalogsensor.Get get)
 {
     get.ResponsePort.Post(SyncGenericState());
     yield break;
 }
Пример #6
0
 public virtual IEnumerator <ITask> GetHandler(pxanalogsensor.Get get)
 {
     UpdateState();
     get.ResponsePort.Post(_state);
     yield break;
 }
        public IEnumerator <ITask> GetHandler(infraredarray.Get get)
        {
            var state = new infraredarray.InfraredSensorArrayState();

            state.Sensors = new List <infraredsensor.InfraredState>(this.sensorPorts.Length);

            // compose state on the fly by issuing N parallel GET requests to partners
            var getSensorState = new analogsensor.Get();

            foreach (var port in this.sensorPorts)
            {
                state.Sensors.Add(null);
                port.Post(getSensorState);
            }

            ICollection <analogsensor.AnalogSensorState> sensorStates = null;
            ICollection <Fault> faults = null;

            yield return(getSensorState.ResponsePort.MultipleItemReceive(
                             this.sensorPorts.Length,
                             (s, f) =>
            {
                sensorStates = s;
                faults = f;
            }));

            if (faults != null && faults.Count > 0)
            {
                get.ResponsePort.Post(Fault.FromCodeSubcode(FaultCodes.Receiver, DsspFaultCodes.OperationFailed));
                yield break;
            }

            foreach (var sensorState in sensorStates)
            {
                PhysicalModel.Proxy.Pose sensorPose;
                switch (sensorState.HardwareIdentifier)
                {
                case 0:
                    sensorPose = this.LeftIRPose;
                    break;

                case 1:
                    sensorPose = this.MiddleIRPose;
                    break;

                case 2:
                    sensorPose = this.RightIRPose;
                    break;

                default:
                    sensorPose = new PhysicalModel.Proxy.Pose();
                    break;
                }

                state.Sensors[sensorState.HardwareIdentifier] = new infraredsensor.InfraredState()
                {
                    DistanceMeasurement    = sensorState.RawMeasurement,
                    HardwareIdentifier     = sensorState.HardwareIdentifier,
                    ManufacturerIdentifier = SimSensorManufacturer,
                    MaxDistance            = int.MaxValue,
                    MinDistance            = 0,
                    Pose      = sensorPose,
                    TimeStamp = sensorState.TimeStamp
                };
            }

            var stateClone = state.Clone() as infraredarray.InfraredSensorArrayState;

            get.ResponsePort.Post(stateClone);
            yield break;
        }