private void PrimarySerial_NewMessageReceived(object sender, Message message) { try { MessageLog += message.ToString() + "\r\n"; } catch { } }
public void InterpretMessage(string raw) { Message msg = new Message(raw); System.Diagnostics.Debug.WriteLine(msg.ToString()); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { OnNewMessageReceivedEvent(this, msg); })); }
private void OnNewMessageReceivedEvent(object sender, Message message) { if (NewMessageReceived != null) NewMessageReceived(sender, message); }
public void SendMessage(Message msg) { _MessageQueue.Add(msg); }
private void StartRandomValuesGenerator() { DispatcherTimer dt = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(500) }; dt.Tick += delegate { if (IsRandomizerEnabled) { Message temp = new Message(ParticipantID.Reactor_1, ParticipantID.MCP, MessageType.Data, string.Format("{0}\t{1}\t{2}", DimensionSymbol.Temperature, 36 + 2 * rnd.NextDouble(), Unit.Celsius)); PrimarySerial.InterpretMessage(temp.Raw); Message biom = new Message(ParticipantID.Reactor_1, ParticipantID.MCP, MessageType.Data, string.Format("{0}\t{1}\t{2}", DimensionSymbol.Biomass, 345 + 13 * rnd.NextDouble(), Unit.Analog)); PrimarySerial.InterpretMessage(biom.Raw); Message ox = new Message(CurrentOffgasScope, ParticipantID.MCP, MessageType.Data, string.Format("{0}\t{1}\t{2}", DimensionSymbol.O2_Saturation, 345 + 13 * rnd.NextDouble(), Unit.Analog)); PrimarySerial.InterpretMessage(ox.Raw); Message cd = new Message(CurrentOffgasScope, ParticipantID.MCP, MessageType.Data, string.Format("{0}\t{1}\t{2}", DimensionSymbol.CO2_Saturation, 120 + 23 * rnd.NextDouble(), Unit.Analog)); PrimarySerial.InterpretMessage(cd.Raw); Message ch = new Message(CurrentOffgasScope, ParticipantID.MCP, MessageType.Data, string.Format("{0}\t{1}\t{2}", DimensionSymbol.CHx_Saturation, 600 + 12 * rnd.NextDouble(), Unit.Analog)); PrimarySerial.InterpretMessage(ch.Raw); } }; dt.Start(); }
private void PrimarySerial_NewMessageReceived(object sender, Message message) { Experiment receivingExperiment; Cultivation receiver = ExperimentLibrary.FindRunningCultivation(message.Sender, out receivingExperiment); if (receiver == null) return; receiver.ReceiveMessage(message); }
public async void ReceiveMessage(Message msg) { switch (msg.MessageType) { case MessageType.Data: ProcessData(msg.Contents); break; case MessageType.Command: break; case MessageType.DataFormat: break; case MessageType.CommandFormat: break; default: break; } IsReceiving = true; await Task.Delay(100); IsReceiving = false; }
private void SendMessage() { try { Message msg = new Message(From, To, Type, Contents.Split(new string[] { "\\t" }, StringSplitOptions.None)); PrimarySerial.SendMessage(msg); MessageLog += msg.ToString() + "\r\n"; } catch { } }