Exemple #1
0
 private void SortMessage(Msg.MessageObject msgObject)
 {
     try
     {
         if (msgObject == null)
         {
             return;
         }
         string key = msgObject.ToKey();
         if (dictionary.ContainsKey(key))
         {
             dictionary[key].msgMethod = msgObject;
             dictionary[key].ResetEvent.Set();
         }
     }
     catch { }
 }
Exemple #2
0
 private void SortMessage(Msg.MessageObject msgObject)
 {
     try
     {
         if (msgObject == null)
         {
             return;
         }
         byte head = (byte)(msgObject.CmdType & 0xF0);
         if (head == 0xC0)
         {
             if (msgObject.CmdType == 0xC3)
             {
                 Msg.MsgObject_GetLockStatus getLockStatus = new Msg.MsgObject_GetLockStatus
                 {
                     FrameMsg = msgObject.FrameMsg, Data = msgObject.Data
                 };
                 getLockStatus.CmdUnpacked();
                 if (dSwitchLock != null)
                 {
                     dSwitchLock(getLockStatus);
                 }
                 return;
             }
             byte key = msgObject.ToKey();
             if (dictionary.ContainsKey(key))
             {
                 dictionary[key].msgMethod = msgObject;
                 dictionary[key].ResetEvent.Set();
             }
         }
         else if (head == 0xF0)
         {
             Msg.MsgObject_ErrorMsg error = new Msg.MsgObject_ErrorMsg
             {
                 CmdType = msgObject.CmdType
             };
             error.CmdUnpacked();
             if (dErrorMsg != null)
             {
                 dErrorMsg(error);
             }
         }
     }
     catch { }
 }
Exemple #3
0
 public void SendSyncMsg(Msg.MessageObject msgObject, int tiemOut)
 {
     if (msgObject != null)
     {
         if (dictionary == null)
         {
             dictionary = new Dictionary <string, ManualReset>();
         }
         string key = msgObject.ToKey();
         if (!dictionary.ContainsKey(key))
         {
             ManualReset manualReset = new ManualReset(false)
             {
                 msgMethod = null
             };
             dictionary.Add(key, manualReset);
         }
         else
         {
             dictionary[key].msgMethod = null;
             dictionary[key].ResetEvent.Reset();
         }
         WaitHandle[] waitHandles = new WaitHandle[] { dictionary[key].ResetEvent };
         BaseConnect.SendMsg(msgObject);
         int num = WaitHandle.WaitAny(waitHandles, tiemOut, false);
         try
         {
             if ((num == 0) && (dictionary[key].msgMethod != null))
             {
                 msgObject.UshortLen = dictionary[key].msgMethod.UshortLen;
                 msgObject.SetData   = dictionary[key].msgMethod.SetData;
                 msgObject.Child     = dictionary[key].msgMethod.Child;
                 msgObject.CmdUnpacked();
             }
         }
         catch { }
     }
 }