/// <summary>
 /// Sends a command to the CHR UM6 Sensor.
 /// </summary>
 /// <param name="body"></param>
 /// <param name="responsePort"></param>
 public SendChrUm6OrientationSensorCommand(ChrUm6OrientationSensorCommand body, Microsoft.Ccr.Core.PortSet <Microsoft.Dss.ServiceModel.Dssp.DefaultUpdateResponseType, W3C.Soap.Fault> responsePort)
     :
     base(body, responsePort)
 {
 }
Esempio n. 2
0
        public IEnumerator <ITask> HttpPostHandler(HttpPost httpPost)
        {
            // Use helper to read form data
            ReadFormData readForm = new ReadFormData(httpPost);

            _httpUtilities.Post(readForm);

            // Wait for result
            Activate(Arbiter.Choice(readForm.ResultPort,
                                    delegate(NameValueCollection parameters)
            {
                if (!string.IsNullOrEmpty(parameters["Action"]) &&
                    parameters["Action"] == "ChrUm6OrientationSensorConfig"
                    )
                {
                    if (parameters["buttonOk"] == "Search")
                    {
                        FindChrConfig findConfig = new FindChrConfig();
                        _mainPort.Post(findConfig);
                        Activate(
                            Arbiter.Choice(
                                Arbiter.Receive <ChrUm6OrientationSensorConfig>(false, findConfig.ResponsePort,
                                                                                delegate(ChrUm6OrientationSensorConfig response)
                        {
                            HttpPostSuccess(httpPost);
                        }),
                                Arbiter.Receive <Fault>(false, findConfig.ResponsePort,
                                                        delegate(Fault f)
                        {
                            HttpPostFailure(httpPost, f);
                        })
                                )
                            );
                    }
                    else if (parameters["buttonOk"] == "Connect")
                    {
                        ChrUm6OrientationSensorConfig config = (ChrUm6OrientationSensorConfig)_state.ChrUm6OrientationSensorConfig.Clone();
                        int port;
                        if (int.TryParse(parameters["CommPort"], out port) && port >= 0)
                        {
                            config.CommPort = port;
                            config.PortName = "COM" + port.ToString();
                        }

                        int baud;
                        if (int.TryParse(parameters["BaudRate"], out baud) && ChrConnection.ValidBaudRate(baud))
                        {
                            config.BaudRate = baud;
                        }

                        Configure configure = new Configure(config);
                        _mainPort.Post(configure);
                        Activate(
                            Arbiter.Choice(
                                Arbiter.Receive <DefaultUpdateResponseType>(false, configure.ResponsePort,
                                                                            delegate(DefaultUpdateResponseType response)
                        {
                            HttpPostSuccess(httpPost);
                        }),
                                Arbiter.Receive <Fault>(false, configure.ResponsePort,
                                                        delegate(Fault f)
                        {
                            HttpPostFailure(httpPost, f);
                        })
                                )
                            );
                    }
                    else if (parameters["buttonOk"] == "Refresh Data")
                    {
                        HttpPostSuccess(httpPost);
                    }
                    else if (parameters["buttonOk"] == "Set Accelerometer Reference Vector")
                    {
                        ChrUm6OrientationSensorCommand cmd = new ChrUm6OrientationSensorCommand()
                        {
                            Command = "SetAccelRefVector"
                        };
                        SendChrUm6OrientationSensorCommand sCmd = new SendChrUm6OrientationSensorCommand(cmd);

                        _mainPort.Post(sCmd);
                        Activate(
                            Arbiter.Choice(
                                Arbiter.Receive <DefaultUpdateResponseType>(false, sCmd.ResponsePort,
                                                                            delegate(DefaultUpdateResponseType response)
                        {
                            HttpPostSuccess(httpPost);
                        }),
                                Arbiter.Receive <Fault>(false, sCmd.ResponsePort,
                                                        delegate(Fault f)
                        {
                            HttpPostFailure(httpPost, f);
                        })
                                )
                            );
                    }
                    else if (parameters["buttonOk"] == "Set Magnetometer Reference Vector")
                    {
                        ChrUm6OrientationSensorCommand cmd = new ChrUm6OrientationSensorCommand()
                        {
                            Command = "SetMagnRefVector"
                        };
                        SendChrUm6OrientationSensorCommand sCmd = new SendChrUm6OrientationSensorCommand(cmd);

                        _mainPort.Post(sCmd);
                        Activate(
                            Arbiter.Choice(
                                Arbiter.Receive <DefaultUpdateResponseType>(false, sCmd.ResponsePort,
                                                                            delegate(DefaultUpdateResponseType response)
                        {
                            HttpPostSuccess(httpPost);
                        }),
                                Arbiter.Receive <Fault>(false, sCmd.ResponsePort,
                                                        delegate(Fault f)
                        {
                            HttpPostFailure(httpPost, f);
                        })
                                )
                            );
                    }
                    else if (parameters["buttonOk"] == "Zero Rate Gyros")
                    {
                        ChrUm6OrientationSensorCommand cmd = new ChrUm6OrientationSensorCommand()
                        {
                            Command = "ZeroRateGyros"
                        };
                        SendChrUm6OrientationSensorCommand sCmd = new SendChrUm6OrientationSensorCommand(cmd);

                        _mainPort.Post(sCmd);
                        Activate(
                            Arbiter.Choice(
                                Arbiter.Receive <DefaultUpdateResponseType>(false, sCmd.ResponsePort,
                                                                            delegate(DefaultUpdateResponseType response)
                        {
                            HttpPostSuccess(httpPost);
                        }),
                                Arbiter.Receive <Fault>(false, sCmd.ResponsePort,
                                                        delegate(Fault f)
                        {
                            HttpPostFailure(httpPost, f);
                        })
                                )
                            );
                    }
                }
                else
                {
                    HttpPostFailure(httpPost, null);
                }
            },
                                    delegate(Exception Failure)
            {
                LogError(Failure.Message);
            })
                     );
            yield break;
        }
 /// <summary>
 /// Sends a command to the CHR UM6 Sensor.
 /// </summary>
 /// <param name="body"></param>
 public SendChrUm6OrientationSensorCommand(ChrUm6OrientationSensorCommand body)
     :
     base(body)
 {
 }