示例#1
1
        private void PrimarySerial_NewMessageReceived(object sender, Message message)
        {
            try
            {
                MessageLog += message.ToString() + "\r\n";
            }
            catch
            {

            }
        }
示例#2
0
 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);
     }));
 }
示例#3
0
 private void OnNewMessageReceivedEvent(object sender, Message message)
 {
     if (NewMessageReceived != null)
         NewMessageReceived(sender, message);
 }
示例#4
0
 public void SendMessage(Message msg)
 {
     _MessageQueue.Add(msg);
 }
示例#5
0
        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();
        }
示例#6
0
 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);
 }
示例#7
0
 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;
 }
示例#8
0
        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
            {

            }
        }