public virtual IEnumerator<ITask> FindGpsConfigHandler(FindGpsConfig query) { _state.Connected = _gpsConnection.FindGps(); if (_state.Connected) { _state.MicrosoftGpsConfig = _gpsConnection.MicrosoftGpsConfig; SaveState(_state); } query.ResponsePort.Post(_state.MicrosoftGpsConfig); yield break; }
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"] == "MicrosoftGpsConfig" ) { if (parameters["buttonOk"] == "Search") { FindGpsConfig findConfig = new FindGpsConfig(); _mainPort.Post(findConfig); Activate( Arbiter.Choice( Arbiter.Receive<MicrosoftGpsConfig>(false, findConfig.ResponsePort, delegate(MicrosoftGpsConfig response) { HttpPostSuccess(httpPost); }), Arbiter.Receive<Fault>(false, findConfig.ResponsePort, delegate(Fault f) { HttpPostFailure(httpPost, f); }) ) ); } else if (parameters["buttonOk"] == "Connect and Update") { MicrosoftGpsConfig config = (MicrosoftGpsConfig)_state.MicrosoftGpsConfig.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) && GpsConnection.ValidBaudRate(baud)) { config.BaudRate = baud; } config.CaptureHistory = ((parameters["CaptureHistory"] ?? "off") == "on"); config.CaptureNmea = ((parameters["CaptureNmea"] ?? "off") == "on"); config.RetrackNmea = ((parameters["RetrackNmea"] ?? "off") == "on"); Console.WriteLine(string.Format("Switches: CaptureHistory={0} CaptureNmea={1} RetrackNmea={2}", config.CaptureHistory, config.CaptureNmea, config.RetrackNmea)); 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 { HttpPostFailure(httpPost, null); } }, delegate(Exception Failure) { LogError(Failure.Message); }) ); yield break; }