Beispiel #1
0
        public virtual IEnumerator <ITask> HttpGetSonarSensorHandler(dssphttp.HttpGet httpGet)
        {
            sonararray.Get get = new sonararray.Get();
            this.altPort.Post(get);
            yield return(get.ResponsePort.Choice());

            sonararray.SonarSensorArrayState sonararrayState = get.ResponsePort;
            httpGet.ResponsePort.Post(new dssphttp.HttpResponseType(sonararrayState));
            yield break;
        }
Beispiel #2
0
        public IEnumerator <ITask> GetSonarArrayHandler(sonararray.Get get)
        {
            var state = new sonararray.SonarSensorArrayState();

            state.Sensors = new List <sonarsensor.SonarState>(this.sensorPorts.Length);

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

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

            ICollection <sonar.SonarState> 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] = new sonarsensor.SonarState()
                {
                    HardwareIdentifier   = sensorState.HardwareIdentifier,
                    AngularRange         = sensorState.AngularRange,
                    AngularResolution    = sensorState.AngularResolution,
                    DistanceMeasurement  = sensorState.DistanceMeasurement,
                    DistanceMeasurements = sensorState.DistanceMeasurements,
                    MaxDistance          = sensorState.MaxDistance,
                    Pose = new PhysicalModel.Proxy.Pose
                    {
                        Orientation = new PhysicalModel.Proxy.Quaternion(
                            sensorState.Pose.Orientation.X,
                            sensorState.Pose.Orientation.Y,
                            sensorState.Pose.Orientation.Z,
                            sensorState.Pose.Orientation.W),
                        Position = new PhysicalModel.Proxy.Vector3(
                            sensorState.Pose.Position.X,
                            sensorState.Pose.Position.Y,
                            sensorState.Pose.Position.Z),
                    },
                    TimeStamp = sensorState.TimeStamp,
                };
            }

            var stateClone = state.Clone() as sonararray.SonarSensorArrayState;

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