private void OnTopicMessageCommand(ReceivedCommand arguments) { var topic = arguments.ReadStringArg(); var message = arguments.ReadStringArg(); MqttClient.Publish($"{m_TopicPrefix}/{topic}", Encoding.GetBytes(message)); }
// ------------------ C A L L B A C K S --------------------- private void OnSsrChange(ReceivedCommand receivedCommand) { int.TryParse(receivedCommand.ReadStringArg(), out int ssrIndex); int.TryParse(receivedCommand.ReadStringArg(), out int ssrValue); SsrResultEventHandler?.Invoke(this, new SsrResult { Index = ssrIndex, IsEngaged = ssrValue == 1 }); }
private void OnHeaterChange(ReceivedCommand receivedCommand) { int.TryParse(receivedCommand.ReadStringArg(), out int heaterIndex); int.TryParse(receivedCommand.ReadStringArg(), out int heaterValue); HeaterResultEventHandler?.Invoke(this, new HeaterResult { Index = heaterIndex, IsEngaged = heaterIndex == 1 }); }
private void OnTempChange(ReceivedCommand receivedCommand) { int.TryParse(receivedCommand.ReadStringArg(), out int probeIndex); decimal.TryParse(receivedCommand.ReadStringArg(), out decimal temp); TemperatureResultEventHandler?.Invoke(this, new TemperatureResult { Index = probeIndex, Value = temp }); }
private async void OnTempChange(ReceivedCommand receivedCommand) { int.TryParse(receivedCommand.ReadStringArg(), out int probeIndex); decimal.TryParse(receivedCommand.ReadStringArg(), out decimal temp); await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { _eventAggregator.GetEvent <TemperatureResultEvent>().Publish(new TemperatureResult { Index = probeIndex, Value = temp }); }); }
private async void OnHeaterChange(ReceivedCommand receivedCommand) { int.TryParse(receivedCommand.ReadStringArg(), out int heaterIndex); int.TryParse(receivedCommand.ReadStringArg(), out int heaterValue); await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { _eventAggregator.GetEvent <HeaterResultEvent>().Publish(new HeaterResult { Index = heaterIndex, IsEngaged = heaterIndex == 1 }); }); }
private void Messenger_DebugCommand(ReceivedCommand args) { String debug = args.ReadStringArg(); Logger.Log(debug); OnLog(debug); }
private void OnReceiveCheckResponse(ReceivedCommand receivedCommand) { var response = receivedCommand.ReadStringArg().Trim(); if (response == "OK") { _arduinoFound = true; } }
// Callback function that prints a message from the arduino void OnPrintMessage(ReceivedCommand arguments) { var unique_id = arguments.ReadUInt16Arg(); var box = arguments.ReadUInt16Arg(); var message = arguments.ReadStringArg(); Console.WriteLine("Controller {0}, Box:{1}, PrintMessage:{2}", unique_id, box, message); Ready = true; }
private void OnPjonBufferCt(ReceivedCommand arguments) { var output = arguments.ReadStringArg(); if (string.IsNullOrWhiteSpace(output)) { return; } _controllerForm.SetPjonBufferCt(output); }
// Callback function that prints that the Arduino has acknowledged protected virtual void OnVersion(ReceivedCommand arguments) { vi = new VersionInfo(); vi.name = arguments.ReadStringArg(); vi.major = arguments.ReadInt32Arg(); vi.minor = arguments.ReadInt32Arg(); //var logger = NLog.LogManager.GetCurrentClassLogger(); //logger.Info(vi.ToString()); }
private void OnMeasurement(ReceivedCommand command) { string value = command.ReadStringArg(); if (value != String.Empty) { if (value[0] == '-') { value = value.Substring(1); if (value.Length > 3) { value = "-" + value.Replace(value.Substring(value.Length - 3, 3), String.Empty) + "." + value.Substring(value.Length - 3, 3); } else if (value.Length == 3) { value = "-0." + value; } else if (value.Length == 2) { value = "-0.0" + value; } else if (value.Length == 1) { value = "-0.00" + value; } } else { if (value.Length > 3) { value = value.Replace(value.Substring(value.Length - 3, 3), String.Empty) + "." + value.Substring(value.Length - 3, 3); } else if (value == "0") { value = "0.000"; } else if (value.Length == 3) { value = "0." + value; } else if (value.Length == 2) { value = "0.0" + value; } else if (value.Length == 1) { value = "0.00" + value; } } } if (MeasurementChanged != null) { MeasurementChanged(value); } }
// Callback function that prints that the Arduino has acknowledged void OnAcknowledge(ReceivedCommand arguments) { var output = arguments.ReadStringArg(); if (string.IsNullOrWhiteSpace(output)) { return; } // _controllerForm.SetCamMsgText(output); const string s = @" ACK "; Console.WriteLine(s); _controllerForm.SetMsgText(s + output); }
/// <summary> /// Handles the event for the model changed sent by the Fixture Manager via Serial Communication Port /// </summary> /// <param name="command"></param> private void OnModelChanged(ReceivedCommand command) { int tempFixture; tempFixture = int.Parse(command.ReadStringArg()); if (tempFixture != fixture || fixture == NO_FIXTURE) { fixture = tempFixture; if (FixtureChanged != null) { FixtureChanged(fixture); } } SendSelectionCommand(); }
private void StatusReceived(ReceivedCommand receivedcommand) { Log.Info(receivedcommand.ReadStringArg()); }
// Callback function that prints that the Arduino has experienced an error static void OnError(ReceivedCommand arguments) { Console.WriteLine($"Error: {arguments.ReadStringArg()}"); }
// Callback function that prints that the Arduino has acknowledged static void OnAcknowledge(ReceivedCommand arguments) { Console.WriteLine($"ACK: {arguments.ReadStringArg()}"); }
// Callback function that prints that the Arduino has acknowledged void OnAcknowledge(ReceivedCommand arguments) { Console.WriteLine("ACK: " + arguments.ReadStringArg()); _arduinoReady = true; }
// Callback function that prints that the Arduino has experienced an error void OnError(ReceivedCommand arguments) { Console.WriteLine("ERR: " + arguments.ReadStringArg()); }
// Callback function that prints the Arduino status to the console void OnStatus(ReceivedCommand arguments) { Console.Write("Arduino status: "); Console.WriteLine(arguments.ReadStringArg()); }
/* * private string _lastLapOutput = ""; * private DateTime _lastLapTime = DateTime.Now; * //public string LogPath = @"C:\nginx-rtmp\www"; * //public string LogPath = @"C:\Users\pantonvi\AppData\Roaming\Microsoft\Windows\Network Shortcuts\Downloads"; * //public string LogPath = @"C:\obs-dev"; * public string LapFileName = @"\laps.html"; * public string LapLogFileName = @"\laps_{0}.log"; * * // Callback function that prints the Arduino status to the console * private void OnLapStatus(ReceivedCommand arguments) * { * var output = arguments.ReadStringArg(); * if (_lastLapOutput == output) return; * * //string[] dirs = Directory.GetDirectories(LogPath); * * var lapTime = DateTime.Now; * var dayLogName = lapTime.ToString("yyyyMMdd"); * var settingLap = (( lapTime-_lastLapTime).Seconds<5?" *":""); * var text1 = string.Format("{0}{1}", output, Environment.NewLine); * var text2 = string.Format("{0}{1}{2}", output, settingLap, Environment.NewLine); * var line = string.Format("{1} {0}", text2, lapTime.ToString("s")); * * _controllerForm.SetLapsText(text2); * * var logPath = _controllerForm.txtLogPath.Text; * * File.WriteAllText(logPath + LapFileName , text1); * * //log laps * File.AppendAllText(logPath + string.Format(LapLogFileName, dayLogName), line); * * _lastLapOutput = output; * _lastLapTime = lapTime; * } */ //private string _lastBtnOutput = ""; //private DateTime _lastBtnTime = DateTime.Now; private void OnBtnStatus(ReceivedCommand arguments) { var output = arguments.ReadStringArg(); //var btnTime = DateTime.Now; //if (_lastBtnOutput == output // && btnTime.Subtract(_lastBtnTime).Seconds < 1) return; int v; if (!int.TryParse(output, out v)) { return; } var in01 = int.Parse(_controllerForm.btn01In.Text); var in02 = int.Parse(_controllerForm.btn02In.Text); var in03 = int.Parse(_controllerForm.btn03In.Text); var out01 = int.Parse(_controllerForm.btn01Out.Text); var out02 = int.Parse(_controllerForm.btn02Out.Text); var out03 = int.Parse(_controllerForm.btn03Out.Text); //_controllerForm.SetLapsText(text2); if ((v & in01) == in01 && (v & out01) == out01) { _controllerForm.btnCam01center.PerformClick(); } else if ((v & in01) == in01) { _controllerForm.btnCam01in.PerformClick(); } else if ((v & out01) == out01) { _controllerForm.btnCam01out.PerformClick(); } if ((v & in02) == in02 && (v & out02) == out02) { _controllerForm.btnCam02center.PerformClick(); } else if ((v & in02) == in02) { _controllerForm.btnCam02in.PerformClick(); } else if ((v & out02) == out02) { _controllerForm.btnCam02out.PerformClick(); } if ((v & in03) == in03 && (v & out03) == out03) { _controllerForm.btnCam03center.PerformClick(); } else if ((v & in03) == in03) { _controllerForm.btnCam03in.PerformClick(); } else if ((v & out03) == out03) { _controllerForm.btnCam03out.PerformClick(); } //_lastBtnOutput = output; //_lastBtnTime = btnTime; }
// Callback function that prints the Arduino status to the console private void OnLapStatus(ReceivedCommand arguments) { var output = arguments.ReadStringArg(); _controllerForm.SetLapStatusWriteFiles(output); }