Пример #1
0
 private void DealNMonHeadMessage(NotifyMessage notMessage)
 {
     try
     {
         if (notMessage.ListData == null || notMessage.ListData.Count < 2)
         {
             AppendMessage(string.Format("NotifyMessage param count invalid."));
             return;
         }
         string strMonID = notMessage.ListData[0];
         string strHead  = notMessage.ListData[1];
         if (mNMonItem == null)
         {
             return;
         }
         if (mNMonItem.MonID != strMonID)
         {
             return;
         }
         MonitorObject monObj = mNMonItem.MonObject;
         if (monObj == null)
         {
             return;
         }
         byte[]       data = Converter.Hex2Byte(strHead);
         SNM_RESPONSE head = (SNM_RESPONSE)Converter.Bytes2Struct(data, typeof(SNM_RESPONSE));
         if (mNMonCore != null)
         {
             mNMonCore.StopMon();
             mNMonCore = null;
         }
         mNMonCore = new NMonCore(monObj);
         mNMonCore.IsConnectServer = false;
         mNMonCore.IsDecodeData    = false;
         mNMonCore.Debug          += (s, msg) => AppendMessage(string.Format("NMonCore:{0}", msg));
         mNMonCore.ReceiveHead(head);
     }
     catch (Exception ex)
     {
         AppendMessage(ex.Message);
     }
 }
Пример #2
0
 private void DealNMonHeadMessage(NotifyMessage notMessage)
 {
     try
     {
         if (notMessage.ListData == null || notMessage.ListData.Count < 2)
         {
             CurrentApp.WriteLog("NMonHeadMessage", string.Format("ListData count invalid"));
             return;
         }
         string strMonID = notMessage.ListData[0];
         string strHead  = notMessage.ListData[1];
         if (strMonID == mMonitorObject.MonID)
         {
             MonitorObject monObj = mMonitorObject;
             byte[]        data   = Converter.Hex2Byte(strHead);
             SNM_RESPONSE  head   = (SNM_RESPONSE)Converter.Bytes2Struct(data, typeof(SNM_RESPONSE));
             if (mNMonCore != null)
             {
                 mNMonCore.StopMon();
                 mNMonCore = null;
             }
             mMonitorItem.VoiceFormat   = head.format;
             mMonitorItem.TimeDeviation = mTimeDeviation;
             mMonitorItem.UpdateState();
             mNMonCore = new NMonCore(monObj);
             mNMonCore.IsConnectServer = false;
             mNMonCore.IsDecodeData    = false;
             mNMonCore.Debug          += (s, msg) =>
             {
                 CurrentApp.WriteLog("NMonCore", msg);
             };
             mNMonCore.ReceiveHead(head);
         }
     }
     catch (Exception ex)
     {
         CurrentApp.WriteLog("NMonHeadMessage", string.Format("Fail.\t{0}", ex.Message));
     }
 }