Exemple #1
0
        private void rtbDisplayProccess()
        {
            MessageQData argument = new MessageQData();
            StringBuilder builder = new StringBuilder();
            new StringBuilder();
            Queue queue = new Queue();
            Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
            lock (this.comm.DisplayDataLock)
            {
                while (this.comm.DisplayQueue.Count > 0)
                {
                    queue.Enqueue(this.comm.DisplayQueue.Dequeue());
                }
            }
            Thread.CurrentThread.Priority = ThreadPriority.Normal;
            while (queue.Count > 0)
            {
                if (this._displayDataBG.CancellationPending)
                {
                    return;
                }
                try
                {
                    argument = (MessageQData) queue.Dequeue();
                }
                catch
                {
                    argument = null;
                }
                if (((argument == null) || (argument.MessageText == null)) || !(argument.MessageText != string.Empty))
                {
                    continue;
                }
                CommonClass.MessageType messageType = argument.MessageType;
                string csvString = string.Empty;
                bool flag = false;
                if ((argument.MessageSource == CommonClass.MessageSource.RX_INPUT) || (argument.MessageSource == CommonClass.MessageSource.USER_TEXT))
                {
                    csvString = argument.MessageText;
                    flag = true;
                }
                else if (argument.MessageSource == CommonClass.MessageSource.RX_OUTPUT)
                {
                    flag = false;
                    if (argument.MessageId == 0xe1)
                    {
                        if (argument.MessageSubId == 6)
                        {
                            if (this.comm.MessageProtocol != "OSP")
                            {
                                BackgroundWorker worker = new BackgroundWorker();
                                worker.DoWork += new DoWorkEventHandler(this.updateTTFFWindow);
                                worker.WorkerReportsProgress = true;
                                worker.WorkerSupportsCancellation = true;
                                worker.RunWorkerAsync(argument);
                            }
                            else if (!this.comm.AutoReplyCtrl.AutoReplyParams.AutoReply)
                            {
                                BackgroundWorker worker2 = new BackgroundWorker();
                                worker2.DoWork += new DoWorkEventHandler(this.updateTTFFWindow);
                                worker2.WorkerReportsProgress = true;
                                worker2.WorkerSupportsCancellation = true;
                                worker2.RunWorkerAsync(argument);
                            }
                        }
                        else if (argument.MessageSubId == 7)
                        {
                            BackgroundWorker worker3 = new BackgroundWorker();
                            worker3.DoWork += new DoWorkEventHandler(this.updateTTFFWindow);
                            worker3.WorkerReportsProgress = true;
                            worker3.WorkerSupportsCancellation = true;
                            worker3.RunWorkerAsync(argument);
                        }
                    }
                    else if ((argument.MessageId == 6) && (argument.MessageChanId == 0xbb))
                    {
                        BackgroundWorker worker4 = new BackgroundWorker();
                        worker4.DoWork += new DoWorkEventHandler(this.updateTTFFWindow);
                        worker4.WorkerReportsProgress = true;
                        worker4.WorkerSupportsCancellation = true;
                        worker4.RunWorkerAsync(argument);
                    }
                    switch (this.comm.RxTransType)
                    {
                        case CommunicationManager.TransmissionType.SSB:
                            this.comm.dataGui.AGC_Gain = 0;
                            csvString = argument.MessageText;
                            goto Label_0331;

                        case CommunicationManager.TransmissionType.GP2:
                            csvString = CommonUtilsClass.LogToGP2(argument.MessageText, argument.MessageTime);
                            this.comm.dataGui.AGC_Gain = 0;
                            goto Label_0331;

                        case CommunicationManager.TransmissionType.GPS:
                            csvString = this.comm.LogToCSV(argument.MessageText);
                            if ((this.comm.MessageProtocol == "OSP") && (argument.MessageId == 0x45))
                            {
                                if (argument.MessageSubId != 1)
                                {
                                    break;
                                }
                                csvString = csvString + this.comm.RxCtrl.FormatPositionResponse(csvString);
                            }
                            goto Label_0331;

                        default:
                            csvString = argument.MessageText;
                            goto Label_0331;
                    }
                    if (argument.MessageSubId == 2)
                    {
                        csvString = csvString + this.comm.RxCtrl.FormatMeasurementResponse(csvString);
                    }
                }
            Label_0331:
                if ((csvString == null) && !(csvString != string.Empty))
                {
                    continue;
                }
                builder.Append(csvString);
                if (((argument.MessageId == 0xe1) || (argument.MessageId == 0xff)) || ((argument.MessageId == 0x40) || (argument.MessageId == 0x44)))
                {
                    flag = true;
                    string pattern = @"gain (?<gain>\d+)";
                    Regex regex = new Regex(pattern, RegexOptions.Compiled);
                    if (regex.IsMatch(csvString))
                    {
                        try
                        {
                            this.comm.dataGui.AGC_Gain = Convert.ToInt32(regex.Match(csvString).Result("${gain}"));
                        }
                        catch
                        {
                        }
                    }
                    lock (this.comm.LockErrorLog)
                    {
                        foreach (string str3 in this.comm.ErrorStringList)
                        {
                            if (csvString.Contains(str3))
                            {
                                this.comm.Log.ErrorWriteLine(csvString);
                            }
                        }
                        goto Label_0449;
                    }
                }
                if (this.comm.ViewAll)
                {
                    flag = true;
                }
            Label_0449:
                if (argument.MessageId == 7)
                {
                    csvString = csvString + this.comm.RxCtrl.FormatMsgSeven(csvString);
                }
                this.comm.Log.WriteLine(csvString);
            }
        }
Exemple #2
0
        private void rtbDisplayProccess()
        {
            MessageQData argument = new MessageQData();
            StringBuilder builder = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();
            bool flag = true;
            string messageText = string.Empty;
            while (this.comm.DisplayQueue.Count > 0)
            {
                argument = (MessageQData) this.comm.DisplayQueue.Dequeue();
                if (((argument != null) && (argument.MessageText != null)) && (argument.MessageText != string.Empty))
                {
                    CommonClass.MessageType messageType = argument.MessageType;
                    if (messageText == argument.MessageText)
                    {
                        messageText = argument.MessageText;
                        continue;
                    }
                    messageText = argument.MessageText;
                    if (argument.MessageId == 0xe1)
                    {
                        if (argument.MessageSubId == 6)
                        {
                            if (this.comm.MessageProtocol != "OSP")
                            {
                                BackgroundWorker worker = new BackgroundWorker();
                                worker.DoWork += new DoWorkEventHandler(this.parseTTFFMessage);
                                worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.updateTTFFWindow);
                                worker.WorkerReportsProgress = true;
                                worker.WorkerSupportsCancellation = true;
                                worker.RunWorkerAsync(argument);
                            }
                            else if (!this.comm.AutoReplyCtrl.AutoReplyParams.AutoReply)
                            {
                                BackgroundWorker worker2 = new BackgroundWorker();
                                worker2.DoWork += new DoWorkEventHandler(this.parseTTFFMessage);
                                worker2.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.updateTTFFWindow);
                                worker2.WorkerReportsProgress = true;
                                worker2.WorkerSupportsCancellation = true;
                                worker2.RunWorkerAsync(argument);
                            }
                        }
                        else if (argument.MessageSubId == 7)
                        {
                            BackgroundWorker worker3 = new BackgroundWorker();
                            worker3.DoWork += new DoWorkEventHandler(this.parseTTFFMessage);
                            worker3.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.updateTTFFWindow);
                            worker3.WorkerReportsProgress = true;
                            worker3.WorkerSupportsCancellation = true;
                            worker3.RunWorkerAsync(argument);
                        }
                    }
                    else if (argument.MessageId == 6)
                    {
                        if (argument.MessageChanId == 0xbb)
                        {
                            BackgroundWorker worker4 = new BackgroundWorker();
                            worker4.DoWork += new DoWorkEventHandler(this.parseTTFFMessage);
                            worker4.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.updateTTFFWindow);
                            worker4.WorkerReportsProgress = true;
                            worker4.WorkerSupportsCancellation = true;
                            worker4.RunWorkerAsync(argument);
                        }
                    }
                    else if (argument.MessageId == 0x45)
                    {
                        this.comm.AutoReplyCtrl.AutoReplyParams.AutoReply = true;
                    }
                    string str2 = string.Empty;
                    switch (this.comm.RxTransType)
                    {
                        case CommunicationManager.TransmissionType.SSB:
                            this.comm.dataGui.AGC_Gain = 0;
                            str2 = argument.MessageText;
                            break;

                        case CommunicationManager.TransmissionType.GP2:
                            str2 = CommonUtilsClass.LogToGP2(argument.MessageText, argument.MessageTime);
                            this.comm.dataGui.AGC_Gain = 0;
                            break;

                        case CommunicationManager.TransmissionType.GPS:
                            str2 = this.comm.LogToCSV(argument.MessageText);
                            break;

                        default:
                            str2 = argument.MessageText;
                            flag = false;
                            break;
                    }
                    if ((str2 != null) || (str2 != string.Empty))
                    {
                        builder.Append(str2);
                        if (!flag)
                        {
                            continue;
                        }
                        builder.Append("\r\n");
                        if (((argument.MessageId != 0xe1) && (argument.MessageId != 0xff)) && ((argument.MessageId != 0x40) && (argument.MessageId != 0x44)))
                        {
                            continue;
                        }
                        builder2.Append(str2);
                        if (!str2.EndsWith("\n"))
                        {
                            builder2.Append("\r\n");
                        }
                        string pattern = @"gain (?<gain>\d+)";
                        Regex regex = new Regex(pattern, RegexOptions.Compiled);
                        if (regex.IsMatch(str2))
                        {
                            try
                            {
                                this.comm.dataGui.AGC_Gain = Convert.ToInt32(regex.Match(str2).Result("${gain}"));
                            }
                            catch
                            {
                            }
                        }
                        lock (this.comm.LockErrorLog)
                        {
                            foreach (string str4 in this.comm.ErrorStringList)
                            {
                                if (str2.Contains(str4))
                                {
                                    this.comm.Log.ErrorWriteLine(str2);
                                }
                            }
                            continue;
                        }
                    }
                }
            }
            string msg = builder.ToString();
            if (msg != string.Empty)
            {
                if (!this.comm.ViewAll)
                {
                    bool flag1 = builder2.ToString() != string.Empty;
                }
                this.comm.Log.Write(msg);
            }
        }
 public void WriteData_TTB(string msg)
 {
     if ((msg != null) && this.TTBPort.IsOpen)
     {
         byte[] inBuf = HelperFunctions.HexToByte(msg.Replace(" ", ""));
         try
         {
             this.TTBPort.Write(inBuf, 0, inBuf.Length);
             string str = string.Format(clsGlobal.MyCulture, "{0:D2}/{1:D2}/{2:D4} {3:D2}:{4:D2}:{5:D2}.{6:D3} ", new object[] { DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond });
             string str2 = string.Format(clsGlobal.MyCulture, "{0} ({1})\t{2}", new object[] { str, 1, msg });
             MessageQData data = new MessageQData();
             data.MessageSource = CommonClass.MessageSource.RX_INPUT;
             data.MessageChanId = -1;
             data.MessageId = -1;
             data.MessageSubId = -1;
             data.MessageType = CommonClass.MessageType.Outgoing;
             data.MessageText = str2;
             data.MessageTime = str;
             lock (this.DisplayDataLock)
             {
                 if (this.DisplayQueue.Count > MAX_MSG_BUFFER)
                 {
                     this.DisplayQueue.Dequeue();
                 }
                 this.DisplayQueue.Enqueue(data);
             }
         }
         catch (FormatException exception)
         {
             this.ErrorPrint(exception.Message);
         }
     }
 }
        private void guiDisplayProccess()
        {
            MessageQData data = new MessageQData();
            StringBuilder builder = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();
            while (this.DisplayQueue.Count > 0)
            {
                data = (MessageQData) this.DisplayQueue.Dequeue();
                if ((data.MessageText != null) && (data.MessageText != string.Empty))
                {
                    string messageText = string.Empty;
                    switch (this.RxTransType)
                    {
                        case TransmissionType.SSB:
                            messageText = data.MessageText;
                            break;

                        case TransmissionType.GP2:
                            messageText = CommonUtilsClass.LogToGP2(data.MessageText, data.MessageTime);
                            break;

                        case TransmissionType.GPS:
                            messageText = this.LogToCSV(data.MessageText);
                            break;

                        default:
                            messageText = data.MessageText;
                            break;
                    }
                    if ((messageText != null) || (messageText != string.Empty))
                    {
                        builder.Append(messageText);
                        builder.Append("\r\n");
                        if (this.ViewAll || (((data.MessageId != 0xe1) && (data.MessageId != 0xff)) && ((data.MessageId != 0x40) && (data.MessageId != 0x44))))
                        {
                            continue;
                        }
                        builder2.Append(messageText);
                        builder2.Append("\r\n");
                    }
                }
            }
            string str2 = builder.ToString();
            if (str2 != string.Empty)
            {
                if (!this.ViewAll)
                {
                    string str = builder2.ToString();
                    if (str != string.Empty)
                    {
                        this.msgQDisplay(str);
                    }
                }
                else
                {
                    this.msgQDisplay(str2);
                }
                this._log.Write(str2);
            }
        }
 public void WriteApp(string msg)
 {
     DateTime now = DateTime.Now;
     string str = string.Format(clsGlobal.MyCulture, "{0:D2}/{1:D2}/{2:D4} {3:D2}:{4:D2}:{5:D2}.{6:D3}", new object[] { now.Month, now.Day, now.Year, now.Hour, now.Minute, now.Second, now.Millisecond });
     string str2 = string.Format(clsGlobal.MyCulture, "{0}\t({1})\t{2}", new object[] { str, 0xff, msg });
     MessageQData data = new MessageQData();
     data.MessageSource = CommonClass.MessageSource.USER_TEXT;
     data.MessageChanId = -1;
     data.MessageId = -1;
     data.MessageSubId = -1;
     data.MessageType = CommonClass.MessageType.Outgoing;
     data.MessageText = str2;
     data.MessageTime = str;
     lock (this.DisplayDataLock)
     {
         if (this.DisplayQueue.Count > MAX_MSG_BUFFER)
         {
             this.DisplayQueue.Dequeue();
         }
         this.DisplayQueue.Enqueue(data);
     }
 }
 public void WriteData(string msg)
 {
     if (msg != null)
     {
         lock (this._lockwrite)
         {
             this.ToSendMsgQueue.Enqueue(msg);
         }
         if ((this.OK_TO_SEND || (this.SendFlag == 2)) && (this.ToSendMsgQueue.Count > 0))
         {
             while (this.ToSendMsgQueue.Count > 0)
             {
                 string str = null;
                 lock (this._lockwrite)
                 {
                     str = (string) this.ToSendMsgQueue.Dequeue();
                 }
                 switch (str)
                 {
                     case null:
                     case "":
                     {
                         continue;
                     }
                 }
                 byte[] buffer = this.InputMessageToByteArray(str);
                 bool flag = false;
                 if (this._InputDeviceMode == CommonClass.InputDeviceModes.RS232)
                 {
                     flag = this.RS232WriteData(buffer);
                 }
                 else if (this._InputDeviceMode == CommonClass.InputDeviceModes.TCP_Client)
                 {
                     flag = this.CMC.HostAppClient.WriteData(buffer);
                 }
                 else if (this._InputDeviceMode == CommonClass.InputDeviceModes.TCP_Server)
                 {
                     flag = this.CMC.HostAppServer.WriteData(buffer);
                 }
                 else if (this._InputDeviceMode == CommonClass.InputDeviceModes.I2C)
                 {
                     flag = this.CMC.HostAppI2CSlave.WriteData(buffer);
                 }
                 else
                 {
                     flag = true;
                 }
                 if (this.Log.IsBin)
                 {
                     this.Log.Write(buffer);
                 }
                 if (!flag)
                 {
                     this.ErrorPrint(string.Format("Error sending:\n{0}", str));
                 }
                 string str2 = string.Format(clsGlobal.MyCulture, "{0:D2}/{1:D2}/{2:D4} {3:D2}:{4:D2}:{5:D2}.{6:D3}", new object[] { DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond });
                 string str3 = str;
                 if (this._txTransType != TransmissionType.Text)
                 {
                     str3 = CommonUtilsClass.ByteToHex(buffer);
                 }
                 MessageQData data = new MessageQData();
                 data.MessageSource = CommonClass.MessageSource.RX_INPUT;
                 data.MessageChanId = -1;
                 data.MessageId = -1;
                 data.MessageSubId = -1;
                 data.MessageType = CommonClass.MessageType.Outgoing;
                 data.MessageText = string.Format(clsGlobal.MyCulture, "{0}\t({1})\t{2}", new object[] { str2, 1, str3 });
                 data.MessageTime = str2;
                 lock (this.DisplayDataLock)
                 {
                     if (this.DisplayQueue.Count > MAX_MSG_BUFFER)
                     {
                         this.DisplayQueue.Dequeue();
                     }
                     this.DisplayQueue.Enqueue(data);
                     continue;
                 }
             }
         }
     }
 }
        public bool File_DataReceived(CommonClass.MessageType type, string inputString, bool match, string matchString, string timeStamp)
        {
            bool flag = false;
            try
            {
                if (matchString == string.Empty)
                {
                    match = false;
                    matchString = @"(\w+)";
                }
                Regex regex = new Regex(matchString, RegexOptions.Compiled);
                if (!this._isFirstCalled)
                {
                    this.SetupRxCtrl();
                    this._isFirstCalled = true;
                }
                if (type == CommonClass.MessageType.Incoming)
                {
                    if (this.RxTransType == TransmissionType.Text)
                    {
                        MessageQData data = new MessageQData();
                        data.MessageId = 0;
                        data.MessageType = CommonClass.MessageType.Incoming;
                        string str = string.Empty;
                        int num = -1;
                        int num2 = -1;
                        int num3 = -1;
                        bool flag2 = false;
                        bool flag3 = false;
                        bool flag4 = false;
                        bool flag5 = false;
                        string timeStampInString = HelperFunctions.GetTimeStampInString();
                        if (this._rxType == ReceiverType.NMEA)
                        {
                            try
                            {
                                object obj2;
                                str = inputString.Trim(new char[] { '\n', '\r' });
                                if (!str.StartsWith("$"))
                                {
                                    goto Label_024E;
                                }
                                string str8 = str.Substring(0, 6);
                                if (str8 != null)
                                {
                                    if (!(str8 == "$GPGGA"))
                                    {
                                        if (((str8 == "$GPGSV") || (str8 == "$GPRMC")) || (str8 == "$GPGSA"))
                                        {
                                            goto Label_010D;
                                        }
                                    }
                                    else
                                    {
                                        num = 0x29;
                                        flag2 = true;
                                    }
                                }
                                goto Label_0110;
                            Label_010D:
                                flag2 = true;
                            Label_0110:
                                Monitor.Enter(obj2 = this.ListenersCtrl.ListenerLock);
                                try
                                {
                                    foreach (string str4 in this.ListenersCtrl.ListenerList.Keys)
                                    {
                                        ListenerContent content = (ListenerContent) this.ListenersCtrl.ListenerList[str4];
                                        if ((content.Source == 0) && content.State)
                                        {
                                            if (content.Chan > 0)
                                            {
                                                if (content.Chan == num2)
                                                {
                                                    flag3 = true;
                                                }
                                            }
                                            else
                                            {
                                                flag3 = true;
                                            }
                                            if (content.MsgId > 0)
                                            {
                                                if (content.MsgId == num)
                                                {
                                                    flag4 = true;
                                                }
                                            }
                                            else
                                            {
                                                flag4 = true;
                                            }
                                            if (content.SubId > 0)
                                            {
                                                if (content.SubId == num3)
                                                {
                                                    flag5 = true;
                                                }
                                            }
                                            else
                                            {
                                                flag5 = true;
                                            }
                                            if ((flag3 && flag4) && flag5)
                                            {
                                                content.MessageText = str;
                                                content.MessageTime = timeStampInString;
                                            }
                                            flag3 = flag4 = flag5 = false;
                                        }
                                    }
                                }
                                finally
                                {
                                    Monitor.Exit(obj2);
                                }
                                if (flag2)
                                {
                                    this.getSignalForGUI_NMEA(str);
                                }
                                data.MessageText = str;
                                this.DebugPrint(CommonClass.MessageType.Incoming, str);
                                this._log.WriteLine(str);
                                return flag;
                            Label_024E:
                                this.DebugPrint(CommonClass.MessageType.Incoming, str);
                                this._log.WriteLine(str);
                            }
                            catch (Exception exception)
                            {
                                this.ErrorPrint(exception.Message);
                            }
                            return flag;
                        }
                        str = inputString;
                        this.DebugPrint(CommonClass.MessageType.Incoming, str);
                        this._log.WriteLine(str);
                        return flag;
                    }
                    if (this.RxTransType == TransmissionType.Hex)
                    {
                        if (match)
                        {
                            flag = regex.IsMatch(inputString);
                            if (flag)
                            {
                                type = CommonClass.MessageType.Error;
                            }
                        }
                        this.DebugPrint(type, inputString);
                        this._log.WriteLine(inputString);
                        return flag;
                    }
                    byte[] buffer = HelperFunctions.HexToByte(inputString);
                    string str5 = string.Empty;
                    string[] separator = new string[] { "\r\n" };
                    string input = string.Empty;
                    foreach (byte num4 in buffer)
                    {
                        this._inDataBytes.Add(num4);
                    }
                    str5 = this.ByteToMsgQueue(new byte[0]);
                    if (str5.Length != 0)
                    {
                        foreach (string str7 in str5.Split(separator, StringSplitOptions.None))
                        {
                            if (str7.Length == 0)
                            {
                                continue;
                            }
                            switch (this.RxTransType)
                            {
                                case TransmissionType.SSB:
                                    input = str7;
                                    break;

                                case TransmissionType.GP2:
                                    input = CommonUtilsClass.LogToGP2(str7, timeStamp);
                                    break;

                                case TransmissionType.GPS:
                                    input = this.LogToCSV(str7);
                                    break;

                                default:
                                    input = str7;
                                    break;
                            }
                            if (match)
                            {
                                flag = regex.IsMatch(input);
                                if (flag)
                                {
                                    type = CommonClass.MessageType.Matching;
                                }
                            }
                            if (this._isCheckEpoch && this._isEpochMessage)
                            {
                                flag = true;
                                this._isCheckEpoch = false;
                            }
                            this.DebugPrint(type, input);
                        }
                    }
                    return flag;
                }
                if (match)
                {
                    flag = regex.IsMatch(inputString);
                    if (flag)
                    {
                        type = CommonClass.MessageType.Matching;
                    }
                }
                if (this._isCheckEpoch && this._isEpochMessage)
                {
                    flag = true;
                    this._isCheckEpoch = false;
                }
                this.DebugPrint(type, inputString);
                this._log.WriteLine(inputString);
            }
            catch (Exception exception2)
            {
                this.ErrorPrint(exception2.ToString());
            }
            return flag;
        }
 public int comPortDataReceivedHandler()
 {
     if (!this.AutoDetectProtocolAndBaudDone)
     {
         return 0;
     }
     try
     {
         Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
         switch (this.RxTransType)
         {
             case TransmissionType.Text:
             {
                 int num = this.comPort.BytesToRead;
                 if (num > 0)
                 {
                     byte[] buffer = this.comPort.Read();
                     lock (this._dataReadLock)
                     {
                         for (int i = 0; i < num; i++)
                         {
                             this._inDataBytes.Add(buffer[i]);
                         }
                     }
                 }
                 Thread.CurrentThread.Priority = ThreadPriority.Normal;
                 return num;
             }
             case TransmissionType.Hex:
             {
                 MessageQData data = new MessageQData();
                 data.MessageId = 0;
                 data.MessageType = CommonClass.MessageType.Incoming;
                 int num1 = this.comPort.BytesToRead;
                 byte[] input = this.comPort.Read();
                 if (input.Length > 0)
                 {
                     data.MessageText = HelperFunctions.ByteToHex(input);
                 }
                 lock (this.DisplayDataLock)
                 {
                     this.DisplayQueue.Enqueue(data);
                 }
                 Thread.CurrentThread.Priority = ThreadPriority.Normal;
                 return input.Length;
             }
         }
         int bytesToRead = this.comPort.BytesToRead;
         if (bytesToRead > 0)
         {
             byte[] buffer3 = this.comPort.Read();
             bytesToRead = buffer3.Length;
             lock (this._dataReadLock)
             {
                 for (int j = 0; j < bytesToRead; j++)
                 {
                     this._inDataBytes.Add(buffer3[j]);
                 }
             }
         }
         Thread.CurrentThread.Priority = ThreadPriority.Normal;
         return bytesToRead;
     }
     catch (Exception exception)
     {
         if (!this._closing)
         {
             this.ErrorPrint(exception.Message);
         }
         Thread.CurrentThread.Priority = ThreadPriority.Normal;
         if (exception.Message.Contains("close"))
         {
             return -1;
         }
         return 0;
     }
 }
 public string ByteToNMEAText()
 {
     List<byte> list = new List<byte>();
     Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
     lock (this._dataReadLock)
     {
         foreach (byte num in this._inDataBytes)
         {
             list.Add(num);
         }
         this._inDataBytes.Clear();
     }
     Thread.CurrentThread.Priority = ThreadPriority.Normal;
     int count = list.Count;
     byte[] msgB = list.ToArray();
     if (this.Log.IsBin)
     {
         this.Log.Write(msgB);
     }
     list.Clear();
     for (int i = 0; i < count; i++)
     {
         if (this._idx_CSVBuff >= MAX_BYTES_BUFFER)
         {
             this._idx_CSVBuff = 0;
             this._headerDetected = false;
             if ((this._InputDeviceMode != CommonClass.InputDeviceModes.I2C) || (this.CMC.HostAppI2CSlave.I2CTalkMode != CommMgrClass.I2CSlave.I2CCommMode.COMM_MODE_I2C_SLAVE))
             {
                 string msg = "Error index = " + this._idx_CSVBuff.ToString();
                 this.WriteApp(msg);
                 this.WriteApp(this.ByteArrToHexString(this._CSVBuff));
             }
             continue;
         }
         char ch = Convert.ToChar(msgB[i]);
         if (ch == '$')
         {
             this._headerDetected = true;
             this._idx_CSVBuff = 0;
             this._CSVBuff[this._idx_CSVBuff++] = msgB[i];
             continue;
         }
         if (ch != '\n')
         {
             goto Label_0461;
         }
         if (this.Flag_didFacRst_atSSB)
         {
             this.Flag_didFacRst_atSSB = false;
             this.Flag_gotNMEAMsg_afterFacRst = true;
         }
         StringBuilder builder = new StringBuilder();
         for (int j = 0; j < this._idx_CSVBuff; j++)
         {
             builder.Append(Convert.ToChar(this._CSVBuff[j]));
         }
         MessageQData data = new MessageQData();
         string str2 = builder.ToString();
         int num5 = -1;
         int num6 = -1;
         int num7 = -1;
         bool flag = false;
         bool flag2 = false;
         bool flag3 = false;
         bool flag4 = false;
         string timeStampInString = HelperFunctions.GetTimeStampInString();
         data.MessageSource = CommonClass.MessageSource.RX_OUTPUT;
         data.MessageChanId = 0;
         data.MessageId = 0;
         data.MessageSubId = 0;
         data.MessageType = CommonClass.MessageType.Incoming;
         data.MessageText = str2;
         data.MessageTime = timeStampInString;
         lock (this.DisplayDataLock)
         {
             if (this.DisplayQueue.Count > MAX_MSG_BUFFER)
             {
                 this.DisplayQueue.Dequeue();
             }
             this.DisplayQueue.Enqueue(data);
         }
         if (this._rxType == ReceiverType.NMEA)
         {
             try
             {
                 object obj4;
                 str2 = str2.Trim(new char[] { '\n', '\r' });
                 if (!str2.StartsWith("$"))
                 {
                     goto Label_0432;
                 }
                 string str6 = str2.Substring(0, 6);
                 if (str6 != null)
                 {
                     if (!(str6 == "$GPGGA"))
                     {
                         if (((str6 == "$GPGSV") || (str6 == "$GPRMC")) || (str6 == "$GPGSA"))
                         {
                             goto Label_02E9;
                         }
                     }
                     else
                     {
                         num5 = 0x29;
                         flag = true;
                     }
                 }
                 goto Label_02EC;
             Label_02E9:
                 flag = true;
             Label_02EC:
                 Monitor.Enter(obj4 = this.ListenersCtrl.ListenerLock);
                 try
                 {
                     foreach (string str5 in this.ListenersCtrl.ListenerList.Keys)
                     {
                         ListenerContent content = (ListenerContent) this.ListenersCtrl.ListenerList[str5];
                         if ((content.Source == 0) && content.State)
                         {
                             if (content.Chan > 0)
                             {
                                 if (content.Chan == num6)
                                 {
                                     flag2 = true;
                                 }
                             }
                             else
                             {
                                 flag2 = true;
                             }
                             if (content.MsgId > 0)
                             {
                                 if (content.MsgId == num5)
                                 {
                                     flag3 = true;
                                 }
                             }
                             else
                             {
                                 flag3 = true;
                             }
                             if (content.SubId > 0)
                             {
                                 if (content.SubId == num7)
                                 {
                                     flag4 = true;
                                 }
                             }
                             else
                             {
                                 flag4 = true;
                             }
                             if ((flag2 && flag3) && flag4)
                             {
                                 content.MessageText = str2;
                                 content.MessageTime = timeStampInString;
                             }
                             flag2 = flag3 = flag4 = false;
                         }
                     }
                 }
                 finally
                 {
                     Monitor.Exit(obj4);
                 }
                 if (flag)
                 {
                     this.getSignalForGUI_NMEA(str2);
                 }
                 data.MessageText = str2;
                 goto Label_0432;
             }
             catch (Exception exception)
             {
                 this.ErrorPrint(exception.Message);
                 goto Label_0432;
             }
         }
         this.ErrorPrint(str2);
     Label_0432:
         this._idx_CSVBuff = 0;
         if (this._commErrorCnt <= 0)
         {
             continue;
         }
         lock (this._lockCommErrorCnt)
         {
             this._commErrorCnt = 0;
             continue;
         }
     Label_0461:
         this._CSVBuff[this._idx_CSVBuff++] = msgB[i];
     }
     return string.Empty;
 }
        public string ByteToMsgQueue(byte[] comByte1)
        {
            int index = 4;
            int num2 = -1;
            int num3 = 5;
            bool flag = false;
            bool flag2 = false;
            bool flag3 = false;
            if (((this._rxType == ReceiverType.SLC) || (this._rxType == ReceiverType.TTB)) && (this.RxCtrl.MessageProtocol == "SSB"))
            {
                num3 = 6;
                index = 5;
                num2 = 4;
            }
            else
            {
                num3 = 5;
                index = 4;
                num2 = 0;
            }
            if (this._inDataBytes.Count > 0)
            {
                List<byte> list = new List<byte>();
                Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
                lock (this._dataReadLock)
                {
                    foreach (byte num4 in this._inDataBytes)
                    {
                        list.Add(num4);
                    }
                    this._inDataBytes.Clear();
                }
                Thread.CurrentThread.Priority = ThreadPriority.Normal;
                StringBuilder builder = new StringBuilder();
                int count = list.Count;
                byte[] msgB = list.ToArray();
                if (this.Log.IsBin)
                {
                    this.Log.Write(msgB);
                }
                list.Clear();
                for (int i = 0; i < count; i++)
                {
                    string str;
                    if (this._idx_CSVBuff >= MAX_BYTES_BUFFER)
                    {
                        this._idx_CSVBuff = 0;
                        this._headerDetected = false;
                        if ((this._InputDeviceMode != CommonClass.InputDeviceModes.I2C) || (this.CMC.HostAppI2CSlave.I2CTalkMode != CommMgrClass.I2CSlave.I2CCommMode.COMM_MODE_I2C_SLAVE))
                        {
                            string str2 = "Error index = " + this._idx_CSVBuff.ToString();
                            this.WriteApp(str2);
                            this.WriteApp(this.ByteArrToHexString(this._CSVBuff));
                        }
                        continue;
                    }
                    byte num7 = msgB[i];
                    this._b2 = num7;
                    if (((this._b1 == 160) && (this._b2 == 0xa2)) && !this._headerDetected)
                    {
                        this._headerDetected = true;
                        this._idx_CSVBuff = 0;
                        this._CSVBuff[this._idx_CSVBuff++] = this._b1;
                        this._CSVBuff[this._idx_CSVBuff++] = this._b2;
                        this._b1 = this._b2;
                        continue;
                    }
                    if ((this._b1 != 0xb0) || (this._b2 != 0xb3))
                    {
                        goto Label_10CA;
                    }
                    this._CSVBuff[this._idx_CSVBuff++] = this._b2;
                    if ((this._CSVBuff[0] != 160) || (this._CSVBuff[1] != 0xa2))
                    {
                        goto Label_10AF;
                    }
                    string timeStampInString = HelperFunctions.GetTimeStampInString();
                    int num8 = (this._CSVBuff[2] * 0x100) + this._CSVBuff[3];
                    int num9 = this._idx_CSVBuff - 8;
                    if ((this.SendFlag == 1) && (this.ToSendMsgQueue.Count > 0))
                    {
                        bool flag4 = this.OK_TO_SEND;
                        this.OK_TO_SEND = true;
                        this.WriteData();
                        this.OK_TO_SEND = flag4;
                    }
                    byte[] destinationArray = new byte[this._idx_CSVBuff];
                    Array.Copy(this._CSVBuff, destinationArray, this._idx_CSVBuff);
                    if (num8 > MAX_MSG_LENGTH)
                    {
                        str = this.ByteArrToHexString(destinationArray);
                        string str4 = string.Format("\r\n ### INVALID MESSAGE LENGTH: Len={0} (0x{1:X}): " + str + " ### \r\n", num8, num8);
                        this.WriteApp(str4);
                        this._headerDetected = false;
                        this._idx_CSVBuff = 0;
                        continue;
                    }
                    if (num8 != num9)
                    {
                        goto Label_1048;
                    }
                    int num10 = destinationArray[num2];
                    int num11 = destinationArray[index];
                    int num12 = destinationArray[num3];
                    str = this.ByteArrToHexString(destinationArray);
                    MessageQData data = new MessageQData();
                    data.MessageSource = CommonClass.MessageSource.RX_OUTPUT;
                    data.MessageChanId = num10;
                    data.MessageId = num11;
                    data.MessageSubId = num12;
                    data.MessageType = CommonClass.MessageType.Incoming;
                    data.MessageText = str;
                    data.MessageTime = timeStampInString;
                    lock (this.DisplayDataLock)
                    {
                        if (this.DisplayQueue.Count > MAX_MSG_BUFFER)
                        {
                            this.DisplayQueue.Dequeue();
                        }
                        this.DisplayQueue.Enqueue(data);
                    }
                    switch (num11)
                    {
                        case 0x2e:
                        case 0x3f:
                            if (this.ResponseViewRTBDisplay.DisplayWindow != null)
                            {
                                CommonUtilsClass responseViewRTBDisplay = this.ResponseViewRTBDisplay;
                                responseViewRTBDisplay.LineCount++;
                                this.ResponseViewRTBDisplay.DisplayData(CommonClass.MessageType.Normal, this.m_Protocols.ConvertRawToFields(destinationArray));
                            }
                            break;

                        case 0x30:
                            if (clsGlobal.IsMarketingUser())
                            {
                                break;
                            }
                            if (num12 != 1)
                            {
                                goto Label_0A13;
                            }
                            clsGlobal.IsDROn = true;
                            if (clsGlobal.IsDRVerDetected)
                            {
                                goto Label_09CC;
                            }
                            if (destinationArray.Length <= 0x19)
                            {
                                goto Label_09BC;
                            }
                            clsGlobal.DRVersion = "2.0";
                            goto Label_09C6;

                        case 0x29:
                            this.getSatellitesDataMsg41(destinationArray);
                            break;

                        case 30:
                            this.getSatellitesDataMsg30(destinationArray);
                            break;

                        case 2:
                            if (num10 == 1)
                            {
                                goto Label_04F4;
                            }
                            this.getSatellitesDataMsg2(destinationArray);
                            break;

                        case 4:
                            this.getSatellitesDataMsg4(destinationArray);
                            break;

                        case 6:
                            if (((num2 == 0) || (num10 == 0xee)) || (num10 == 0xcc))
                            {
                                this.RxCtrl.ResetCtrl.ResetRxSwVersion = this.m_Protocols.ConvertRawToFields(destinationArray);
                                this.Log.FirmwareSWVersion = this.RxCtrl.ResetCtrl.ResetRxSwVersion;
                                this._myWindowTitle = this.comPort.PortName + " " + this.RxCtrl.ResetCtrl.ResetRxSwVersion;
                                this.UpdateWindowTitleBar(this._myWindowTitle);
                                if (this.ResponseViewRTBDisplay.DisplayWindow != null)
                                {
                                    CommonUtilsClass class1 = this.ResponseViewRTBDisplay;
                                    class1.LineCount++;
                                    this.ResponseViewRTBDisplay.DisplayData(CommonClass.MessageType.Normal, this.RxCtrl.ResetCtrl.ResetRxSwVersion);
                                }
                            }
                            else if (num10 == 0xbb)
                            {
                                this.RxCtrl.GetTTFFValues(data.MessageTime, data.MessageText, this.AutoReplyCtrl.TTBTimeAidingParams.Type);
                                this.RxCtrl.GetTTFF();
                            }
                            break;

                        case 7:
                            this.getClkInfoMsg7(destinationArray);
                            break;

                        case 0x10:
                            if ((num10 == 2) && this.AutoReplyCtrl.AutoReplyParams.AutoReplyHWCfg)
                            {
                                if (this.RxCtrl.ResetCtrl.ResetType.Contains("FACTORY"))
                                {
                                    goto Label_0719;
                                }
                                this.hwConfigResponseHandler();
                            }
                            break;

                        case 0x11:
                            if ((num10 == 2) && this.AutoReplyCtrl.AutoReplyParams.AutoReplyTimeTrans)
                            {
                                this.timeAidingHandler();
                            }
                            break;

                        case 0x12:
                            if (num10 != 2)
                            {
                                goto Label_0B6E;
                            }
                            if (this.AutoReplyCtrl.AutoReplyParams.AutoReplyFreqTrans)
                            {
                                this.freqAidingHandler(HelperFunctions.ByteToHex(destinationArray));
                            }
                            break;

                        case 0x13:
                            if (num10 != 2)
                            {
                                goto Label_07E3;
                            }
                            if (this.AutoReplyCtrl.AutoReplyParams.AutoReplyApproxPos)
                            {
                                this.approxPosAidingHandler();
                            }
                            break;

                        case 0x45:
                            if (num12 != 1)
                            {
                                goto Label_0BDA;
                            }
                            this.RxCtrl.GetPosition(HelperFunctions.GetTimeStampInString(), HelperFunctions.ByteToHex(destinationArray));
                            break;

                        case 0x47:
                            if (this.AutoReplyCtrl.AutoReplyParams.AutoReplyHWCfg)
                            {
                                if (this.RxCtrl.ResetCtrl.ResetType.Contains("FACTORY"))
                                {
                                    goto Label_06B5;
                                }
                                this.hwConfigResponseHandler();
                            }
                            break;

                        case 0x48:
                            switch (destinationArray[num3])
                            {
                                case 1:
                                    goto Label_0D16;

                                case 2:
                                    goto Label_0D23;

                                case 3:
                                    goto Label_0D30;

                                case 4:
                                    goto Label_0D3D;
                            }
                            break;

                        case 0x49:
                            switch (num12)
                            {
                                case 1:
                                    goto Label_0757;

                                case 2:
                                    goto Label_0777;

                                case 3:
                                    goto Label_0797;
                            }
                            break;

                        case 0x4b:
                            if ((num12 == 1) && (destinationArray[num3 + 1] == 210))
                            {
                                this.posReqAckHandler();
                            }
                            break;

                        case 0xac:
                            if (!clsGlobal.IsMarketingUser())
                            {
                                if (num12 == 9)
                                {
                                    this.StringDRInputCarBusData = this.RxCtrl.FormatInputCarBusDataString(this.m_Protocols.ConvertRawToFields(destinationArray));
                                }
                                if (this.DisplayPanelDRSensors != null)
                                {
                                    this.DisplayPanelDRSensors.Invalidate();
                                }
                            }
                            break;

                        case 0xb2:
                            switch (destinationArray[num3])
                            {
                                case 4:
                                    if (destinationArray[index + 2] == 0)
                                    {
                                        if (this.ResponseViewRTBDisplay.DisplayWindow != null)
                                        {
                                            CommonUtilsClass class3 = this.ResponseViewRTBDisplay;
                                            class3.LineCount++;
                                            this.ResponseViewRTBDisplay.DisplayData(CommonClass.MessageType.Normal, HelperFunctions.ByteToHex(destinationArray));
                                        }
                                    }
                                    else if (destinationArray[index + 2] == 2)
                                    {
                                        if (this.ResponseViewRTBDisplay.DisplayWindow != null)
                                        {
                                            CommonUtilsClass class4 = this.ResponseViewRTBDisplay;
                                            class4.LineCount++;
                                            this.ResponseViewRTBDisplay.DisplayData(CommonClass.MessageType.Normal, HelperFunctions.ByteToHex(destinationArray));
                                        }
                                        FileStream output = File.Create(@"C:\MultiPeek.bin");
                                        BinaryWriter writer = new BinaryWriter(output);
                                        for (int j = index + 9; j < (destinationArray.Length - 4); j++)
                                        {
                                            writer.Write(destinationArray[j]);
                                        }
                                        writer.Close();
                                        output.Close();
                                    }
                                    break;

                                case 10:
                                    this.PollICTrackerSettings(destinationArray);
                                    break;
                            }
                            break;

                        case 0xe1:
                            if (num12 != 6)
                            {
                                goto Label_0DEC;
                            }
                            if (this.MessageProtocol != "OSP")
                            {
                                this.RxCtrl.GetTTFFValues(data.MessageTime, data.MessageText, this.AutoReplyCtrl.TTBTimeAidingParams.Type);
                                this.RxCtrl.GetTTFF();
                            }
                            else if (!this.AutoReplyCtrl.AutoReplyParams.AutoReply)
                            {
                                this.RxCtrl.GetTTFFValues(data.MessageTime, data.MessageText, this.AutoReplyCtrl.TTBTimeAidingParams.Type);
                                this.RxCtrl.GetTTFF();
                            }
                            break;
                    }
                    goto Label_0E62;
                Label_04F4:
                    if (this.AutoReplyCtrl.PositionRequestCtrl.LocMethod == 0)
                    {
                        this.RxCtrl.GetMeasurement(HelperFunctions.GetTimeStampInString(), HelperFunctions.ByteToHex(destinationArray));
                    }
                    else
                    {
                        this.RxCtrl.GetPosition(HelperFunctions.GetTimeStampInString(), HelperFunctions.ByteToHex(destinationArray));
                    }
                    goto Label_0E62;
                Label_06B5:
                    if (this.RxCtrl.ResetCtrl.IsAidingPerformedOnFactory)
                    {
                        this.hwConfigResponseHandler();
                    }
                    goto Label_0E62;
                Label_0719:
                    if (this.RxCtrl.ResetCtrl.IsAidingPerformedOnFactory)
                    {
                        this.hwConfigResponseHandler();
                    }
                    goto Label_0E62;
                Label_0757:
                    if (this.AutoReplyCtrl.AutoReplyParams.AutoReplyApproxPos)
                    {
                        this.approxPosAidingHandler();
                    }
                    goto Label_0E62;
                Label_0777:
                    if (this.AutoReplyCtrl.AutoReplyParams.AutoReplyTimeTrans)
                    {
                        this.timeAidingHandler();
                    }
                    goto Label_0E62;
                Label_0797:
                    if (this.AutoReplyCtrl.AutoReplyParams.AutoReplyFreqTrans)
                    {
                        this.freqAidingHandler(HelperFunctions.ByteToHex(destinationArray));
                    }
                    goto Label_0E62;
                Label_07E3:
                    this.getNavigationParams(destinationArray);
                    int aBMMode = this.NavigationParamrters.ABMMode;
                    int num14 = this.NavigationParamrters.FiveHzNavMode << 2;
                    int num15 = this.NavigationParamrters.SBASRangingMode << 3;
                    if (this.ABPModePendingSet)
                    {
                        if (this.ABPModeToSet)
                        {
                            this.RxCtrl.SetPosCalcMode((1 + num14) + num15);
                            this.ABPModePendingSet = false;
                        }
                        else
                        {
                            this.RxCtrl.SetPosCalcMode(num14 + num15);
                            this.ABPModePendingSet = false;
                        }
                        this.RxCtrl.PollNavigationParameters();
                    }
                    if (this.FiveHzNavModePendingSet)
                    {
                        if (this.FiveHzNavModeToSet)
                        {
                            this.RxCtrl.SetPosCalcMode((aBMMode + 4) + num15);
                            this.FiveHzNavModePendingSet = false;
                        }
                        else
                        {
                            this.RxCtrl.SetPosCalcMode(aBMMode + num15);
                            this.FiveHzNavModePendingSet = false;
                        }
                        this.RxCtrl.PollNavigationParameters();
                    }
                    if (this.SBASRangingPendingSet)
                    {
                        if (this.SBASRangingToSet)
                        {
                            this.RxCtrl.SetPosCalcMode((aBMMode + num14) + 8);
                            this.SBASRangingPendingSet = false;
                        }
                        else
                        {
                            this.RxCtrl.SetPosCalcMode(aBMMode + num14);
                            this.SBASRangingPendingSet = false;
                        }
                        this.RxCtrl.PollNavigationParameters();
                    }
                    if (this.ResponseViewRTBDisplay.DisplayWindow != null)
                    {
                        CommonUtilsClass class2 = this.ResponseViewRTBDisplay;
                        class2.LineCount++;
                        this.ResponseViewRTBDisplay.DisplayData(CommonClass.MessageType.Normal, this.m_Protocols.ConvertRawToFields(destinationArray));
                        this.StringRxNavParams = this.RxCtrl.FormatNavParameters(this.m_Protocols.ConvertRawToFields(destinationArray));
                        this.ResponseViewRTBDisplay.DisplayData(CommonClass.MessageType.Normal, this.StringRxNavParams);
                        if (this.RxCurrentTransmissionType == TransmissionType.GPS)
                        {
                            this._log.WriteLine(this.StringRxNavParams);
                        }
                    }
                    goto Label_0E62;
                Label_09BC:
                    clsGlobal.DRVersion = "1.0";
                Label_09C6:
                    clsGlobal.IsDRVerDetected = true;
                Label_09CC:
                    if (clsGlobal.DRVersion == "2.0")
                    {
                        destinationArray[5] = (byte) (destinationArray[5] + 200);
                    }
                    string csvString = this.m_Protocols.ConvertRawToFields(destinationArray);
                    this.StringDRNavStatus = this.RxCtrl.FormatDRStatusString(csvString);
                    goto Label_0AAE;
                Label_0A13:
                    if (num12 == 2)
                    {
                        if (!clsGlobal.IsDRVerDetected)
                        {
                            if (destinationArray.Length > 40)
                            {
                                clsGlobal.DRVersion = "2.0";
                            }
                            else
                            {
                                clsGlobal.DRVersion = "1.0";
                            }
                            clsGlobal.IsDRVerDetected = true;
                        }
                        if (clsGlobal.DRVersion == "2.0")
                        {
                            destinationArray[5] = (byte) (destinationArray[5] + 200);
                        }
                        string str6 = this.m_Protocols.ConvertRawToFields(destinationArray);
                        this.StringDRNavState = this.RxCtrl.FormatDRStateString(str6);
                    }
                    else if (num12 == 3)
                    {
                        string str7 = this.m_Protocols.ConvertRawToFields(destinationArray);
                        this.StringDRNavSubsystemData = this.RxCtrl.FormatNavSubSysString(str7);
                    }
                Label_0AAE:
                    if (this.DisplayPanelDRStatusStates != null)
                    {
                        this.DisplayPanelDRStatusStates.Invalidate();
                    }
                    goto Label_0E62;
                Label_0B6E:
                    if (destinationArray[index + 1] == 1)
                    {
                        this.OK_TO_SEND = true;
                        this.WriteData();
                    }
                    else
                    {
                        this.OK_TO_SEND = false;
                    }
                    goto Label_0E62;
                Label_0BDA:
                    if (num12 == 2)
                    {
                        this.RxCtrl.GetMeasurement(HelperFunctions.GetTimeStampInString(), HelperFunctions.ByteToHex(destinationArray));
                    }
                    goto Label_0E62;
                Label_0D16:
                    this.getSensorReadingsMsg72(destinationArray);
                    goto Label_0E62;
                Label_0D23:
                    this.getFactoryParamsMsg72(destinationArray);
                    goto Label_0E62;
                Label_0D30:
                    this.getRxStateMsg72(destinationArray);
                    goto Label_0E62;
                Label_0D3D:
                    this.getHeadingDataMsg72(destinationArray);
                    goto Label_0E62;
                Label_0DEC:
                    if (num12 == 7)
                    {
                        this.RxCtrl.GetTTFFValues(data.MessageTime, data.MessageText, this.AutoReplyCtrl.TTBTimeAidingParams.Type);
                        this.RxCtrl.GetTTFF();
                    }
                Label_0E62:
                    try
                    {
                        if (this.ListenersCtrl != null)
                        {
                            lock (this.ListenersCtrl.ListenerLock)
                            {
                                foreach (string str8 in this.ListenersCtrl.ListenerList.Keys)
                                {
                                    ListenerContent content = (ListenerContent) this.ListenersCtrl.ListenerList[str8];
                                    if ((content.Source == 0) && content.State)
                                    {
                                        if (content.Chan > 0)
                                        {
                                            if (content.Chan == this._CSVBuff[num2])
                                            {
                                                flag3 = true;
                                            }
                                        }
                                        else
                                        {
                                            flag3 = true;
                                        }
                                        if (content.MsgId > 0)
                                        {
                                            if (content.MsgId == this._CSVBuff[index])
                                            {
                                                flag = true;
                                            }
                                        }
                                        else
                                        {
                                            flag = true;
                                        }
                                        if (content.SubId > 0)
                                        {
                                            if (content.SubId == this._CSVBuff[index + 1])
                                            {
                                                flag2 = true;
                                            }
                                        }
                                        else
                                        {
                                            flag2 = true;
                                        }
                                        if ((flag3 && flag) && flag2)
                                        {
                                            MessageQData data2 = new MessageQData();
                                            data2.MessageTime = timeStampInString;
                                            data2.MessageText = str;
                                            data2.MessageCommMgr = this.PortName;
                                            if (content.QueueData.Count > 0x2710)
                                            {
                                                content.QueueData.Dequeue();
                                            }
                                            else
                                            {
                                                content.QueueData.Enqueue(data2);
                                            }
                                        }
                                        flag3 = flag = flag2 = false;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        if (!this._closing)
                        {
                            string errorStr = "CommunicationManager: ByteToMsgQueue() ListenersCtrl Processing - " + exception.Message.ToString();
                            this.ErrorPrint(errorStr);
                        }
                    }
                    if (this._commErrorCnt > 0)
                    {
                        lock (this._lockCommErrorCnt)
                        {
                            this._commErrorCnt = 0;
                        }
                    }
                    builder.Append(str + "\r\n");
                    goto Label_10AF;
                Label_1048:
                    if (num9 < num8)
                    {
                        continue;
                    }
                    string msg = string.Format("\r\n ### INVALID MESSAGE LENGTH: expected={0} (0x{1:X}), actual={2} (0x{3:X}): " + this.ByteArrToHexString(destinationArray) + " ### \r\n", new object[] { num8, num8, num9, num9 });
                    this.WriteApp(msg);
                Label_10AF:
                    this._CSVBuff.Initialize();
                    this._idx_CSVBuff = 0;
                    this._headerDetected = false;
                    continue;
                Label_10CA:
                    this._CSVBuff[this._idx_CSVBuff] = num7;
                    this._idx_CSVBuff++;
                    this._b1 = this._b2;
                }
                if (builder.Length > 0)
                {
                    return builder.ToString().ToUpper();
                }
            }
            return string.Empty;
        }
Exemple #11
0
        private void rtbDisplayProccess()
        {
            MessageQData argument = new MessageQData();
            Queue queue = new Queue();
            int num = 0;
            System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.AboveNormal;
            lock (this.comm.DisplayDataLock)
            {
                while (this.comm.DisplayQueue.Count > 0)
                {
                    queue.Enqueue(this.comm.DisplayQueue.Dequeue());
                }
            }
            System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Normal;
            while (queue.Count > 0)
            {
                if (this._displayDataBG.CancellationPending)
                {
                    return;
                }
                try
                {
                    argument = (MessageQData) queue.Dequeue();
                }
                catch
                {
                    argument = null;
                }
                if (((argument == null) || (argument.MessageText == null)) || !(argument.MessageText != string.Empty))
                {
                    continue;
                }
                CommonClass.MessageType messageType = argument.MessageType;
                string csvString = string.Empty;
                bool flag = false;
                if ((argument.MessageSource == CommonClass.MessageSource.RX_INPUT) || (argument.MessageSource == CommonClass.MessageSource.USER_TEXT))
                {
                    csvString = argument.MessageText;
                    num++;
                    flag = true;
                }
                else if (argument.MessageSource == CommonClass.MessageSource.RX_OUTPUT)
                {
                    flag = false;
                    if (argument.MessageId == 0xe1)
                    {
                        if (argument.MessageSubId == 6)
                        {
                            if (this.comm.MessageProtocol != "OSP")
                            {
                                BackgroundWorker worker = new BackgroundWorker();
                                worker.DoWork += new DoWorkEventHandler(this.updateTTFFWindow);
                                worker.WorkerReportsProgress = true;
                                worker.WorkerSupportsCancellation = true;
                                worker.RunWorkerAsync(argument);
                            }
                            else if (!this.comm.AutoReplyCtrl.AutoReplyParams.AutoReply)
                            {
                                BackgroundWorker worker2 = new BackgroundWorker();
                                worker2.DoWork += new DoWorkEventHandler(this.updateTTFFWindow);
                                worker2.WorkerReportsProgress = true;
                                worker2.WorkerSupportsCancellation = true;
                                worker2.RunWorkerAsync(argument);
                            }
                        }
                        else if (argument.MessageSubId == 7)
                        {
                            BackgroundWorker worker3 = new BackgroundWorker();
                            worker3.DoWork += new DoWorkEventHandler(this.updateTTFFWindow);
                            worker3.WorkerReportsProgress = true;
                            worker3.WorkerSupportsCancellation = true;
                            worker3.RunWorkerAsync(argument);
                        }
                    }
                    else if ((argument.MessageId == 6) && (argument.MessageChanId == 0xbb))
                    {
                        BackgroundWorker worker4 = new BackgroundWorker();
                        worker4.DoWork += new DoWorkEventHandler(this.updateTTFFWindow);
                        worker4.WorkerReportsProgress = true;
                        worker4.WorkerSupportsCancellation = true;
                        worker4.RunWorkerAsync(argument);
                    }
                    switch (this.comm.RxTransType)
                    {
                        case CommunicationManager.TransmissionType.SSB:
                            this.comm.dataGui.AGC_Gain = 0;
                            csvString = argument.MessageText;
                            goto Label_03AB;

                        case CommunicationManager.TransmissionType.GP2:
                            csvString = CommonUtilsClass.LogToGP2(argument.MessageText, argument.MessageTime);
                            this.comm.dataGui.AGC_Gain = 0;
                            goto Label_03AB;

                        case CommunicationManager.TransmissionType.GPS:
                            csvString = this.comm.LogToCSV(argument.MessageText);
                            if (this.comm.MessageProtocol == "OSP")
                            {
                                if (argument.MessageId != 0x45)
                                {
                                    goto Label_02EB;
                                }
                                if (argument.MessageSubId != 1)
                                {
                                    break;
                                }
                                csvString = csvString + this.comm.RxCtrl.FormatPositionResponse(csvString);
                            }
                            goto Label_03AB;

                        default:
                            csvString = argument.MessageText;
                            flag = true;
                            goto Label_03AB;
                    }
                    if (argument.MessageSubId == 2)
                    {
                        csvString = csvString + this.comm.RxCtrl.FormatMeasurementResponse(csvString);
                    }
                }
                goto Label_03AB;
            Label_02EB:
                if (argument.MessageId == 0x13)
                {
                    if (argument.MessageChanId != 2)
                    {
                        csvString = csvString + this.comm.StringRxNavParams;
                    }
                }
                else if (argument.MessageId == 0x4d)
                {
                    Hashtable myHash = this.comm.m_Protocols.ConvertRawToHash(HelperFunctions.HexToByte(argument.MessageText), "OSP");
                    csvString = csvString + this.comm.RxCtrl.PrintFormatedMPMStatus(myHash);
                }
            Label_03AB:
                if ((csvString == null) && !(csvString != string.Empty))
                {
                    continue;
                }
                if (((argument.MessageId == 0xe1) || (argument.MessageId == 0xff)) || (argument.MessageId == 0x44))
                {
                    flag = true;
                    num++;
                    if ((((argument.MessageId == 0xff) && (this.comm.RxCtrl.ResetCtrl != null)) && (!this.comm.RxCtrl.ResetCtrl.IsFirstTTFS && csvString.Contains("BEP:SetTime(FSf)"))) && ((this.TTFSView != null) && this.TTFSViewLocation.IsOpen))
                    {
                        string str2 = @"(?<time>\d+)\s*BEP:SetTime\(FSf\)\s*Y\w\s*T:(?<tow>\d+.\d+)\s*(?<week>\d+)";
                        Regex regex = new Regex(str2, RegexOptions.Compiled);
                        if (regex.IsMatch(csvString))
                        {
                            try
                            {
                                this.TTFSView.TTFSDataElement.TTFS = Convert.ToDouble(regex.Match(csvString).Result("${time}")) / 1000.0;
                                this.TTFSView.TTFSDataElement.TOW = Convert.ToDouble(regex.Match(csvString).Result("${tow}"));
                                this.TTFSView.TTFSDataElement.Week = Convert.ToInt32(regex.Match(csvString).Result("${week}"));
                                this.TTFSView.TTFSDataElement.isValid = true;
                                this.comm.RxCtrl.ResetCtrl.IsFirstTTFS = true;
                                this.TTFSView.TTFSDataElement.TTFSDataView.Invalidate();
                                csvString = csvString + string.Format("\r\n TTFS = {0:F2},{1:F6}", this.TTFSView.TTFSDataElement.TTFS, this.TTFSView.TTFSDataElement.TOW);
                            }
                            catch
                            {
                            }
                        }
                    }
                    string pattern = @"gain (?<gain>\d+)";
                    Regex regex2 = new Regex(pattern, RegexOptions.Compiled);
                    if (regex2.IsMatch(csvString))
                    {
                        try
                        {
                            this.comm.dataGui.AGC_Gain = Convert.ToInt32(regex2.Match(csvString).Result("${gain}"));
                        }
                        catch
                        {
                        }
                    }
                    lock (this.comm.LockErrorLog)
                    {
                        foreach (string str4 in this.comm.ErrorStringList)
                        {
                            if (csvString.Contains(str4))
                            {
                                this.comm.Log.ErrorWriteLine(csvString);
                            }
                        }
                        goto Label_063C;
                    }
                }
                if (this.comm.ViewAll)
                {
                    flag = true;
                }
            Label_063C:
                if (((this.comm.DebugViewRTBDisplay != null) && !this.comm.DebugViewRTBDisplay.viewPause) && flag)
                {
                    CommonUtilsClass debugViewRTBDisplay = this.comm.DebugViewRTBDisplay;
                    debugViewRTBDisplay.LineCount += num;
                    if (((this.comm.DebugRegExpressionHandler != null) && this.comm.DebugViewIsMatchEnable) && this.comm.DebugRegExpressionHandler.IsMatch(csvString))
                    {
                        argument.MessageType = CommonClass.MessageType.Matching;
                    }
                    this.comm.DebugViewRTBDisplay.DisplayData(argument.MessageType, csvString);
                }
                if (this.comm.Log.IsFileOpen())
                {
                    string msg = string.Empty;
                    if (((this.comm.RxTransType == this.comm.LogFormat) || (argument.MessageSource == CommonClass.MessageSource.RX_INPUT)) || (argument.MessageSource == CommonClass.MessageSource.USER_TEXT))
                    {
                        msg = csvString;
                    }
                    else
                    {
                        switch (this.comm.LogFormat)
                        {
                            case CommunicationManager.TransmissionType.GP2:
                                msg = CommonUtilsClass.LogToGP2(argument.MessageText, argument.MessageTime);
                                break;

                            case CommunicationManager.TransmissionType.GPS:
                                msg = this.comm.LogToCSV(argument.MessageText);
                                break;
                        }
                    }
                    if (msg != string.Empty)
                    {
                        if (!this.comm.IsUserSpecifiedMsgLog)
                        {
                            this.comm.Log.WriteLine(msg);
                            continue;
                        }
                        for (int i = 0; i < this.comm.UserSpecifiedMsgList.Count; i++)
                        {
                            if (this.comm.UserSpecifiedSubStringList[i] == "N")
                            {
                                if (msg.StartsWith(this.comm.UserSpecifiedMsgList[i]))
                                {
                                    this.comm.Log.WriteLine(msg);
                                }
                            }
                            else if (msg.Contains(this.comm.UserSpecifiedMsgList[i]))
                            {
                                this.comm.Log.WriteLine(msg);
                            }
                        }
                    }
                }
            }
        }