コード例 #1
0
ファイル: utils_AutoReply.cs プロジェクト: kihwanoh/SiRFLive
        internal static string FieldList_to_HexString(bool isSLCRx, ArrayList fieldList, byte channelType)
        {
            string message = "";
            int    num     = 0;

            if (fieldList.Count == 0)
            {
                return(string.Empty);
            }
            StringBuilder builder = new StringBuilder();

            builder.Append(((SLCMsgStructure)fieldList[0]).defaultValue);
            for (int i = 1; i < fieldList.Count; i++)
            {
                if (string.IsNullOrEmpty(((SLCMsgStructure)fieldList[i]).defaultValue))
                {
                    builder.Append(",");
                    builder.Append("0");
                }
                else
                {
                    builder.Append(",");
                    builder.Append(((SLCMsgStructure)fieldList[i]).defaultValue);
                }
            }
            string[]      strArray = builder.ToString().Split(new char[] { ',' });
            StringBuilder builder2 = new StringBuilder();

            for (int j = 0; j < fieldList.Count; j++)
            {
                builder2.Append(MsgFactory.ConvertDecimalToHex(strArray[j], ((SLCMsgStructure)fieldList[j]).datatype, ((SLCMsgStructure)fieldList[j]).scale));
                num += ((SLCMsgStructure)fieldList[j]).bytes;
            }
            message = builder2.ToString();
            return("A0A2" + num.ToString("X").PadLeft(4, '0') + message + GetChecksum(message, isSLCRx) + "B0B3");
        }
コード例 #2
0
        private string AI3_Request_ConvertFieldsToRaw(string csvMessage, ArrayList fieldList)
        {
            int num = 0;

            char[]   separator = new char[] { ',' };
            string[] strArray  = new string[0x7d0];
            strArray = csvMessage.Split(separator);
            int.Parse(strArray[0]);
            int.Parse(strArray[1]);
            if (fieldList.Count == 0)
            {
                return(string.Empty);
            }
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < fieldList.Count; i++)
            {
                builder.Append(MsgFactory.ConvertDecimalToHex(strArray[i], ((SLCMsgStructure)fieldList[i]).datatype, ((SLCMsgStructure)fieldList[i]).scale));
            }
            string str = string.Empty;
            string msg = builder.ToString().Replace(" ", "");

            if (base.AutoReplyParams.AutoAid_Eph_fromTTB && (base.EphDataMsg != ""))
            {
                int    num3 = msg.Length;
                string str3 = msg.Substring(0, 0x26);
                string str4 = msg.Substring(0xf26, num3 - 0xf26);
                int    num4 = base.EphDataMsg.Length / 2;
                for (int k = 0; k < (0x780 - num4); k++)
                {
                    base.EphDataMsg = base.EphDataMsg + "00";
                }
                msg = str3 + base.EphDataMsg + str4;
            }
            if (base.AutoReplyParams.AutoAid_AcqData_fromTTB && (base.AcqAssistDataMsg != ""))
            {
                int    num6 = msg.Length;
                string str5 = msg.Substring(0, 0x156c);
                string str6 = msg.Substring(0x1936, num6 - 0x1936);
                int    num7 = base.AcqAssistDataMsg.Length / 2;
                for (int m = 0; m < (0x1e4 - num7); m++)
                {
                    base.AcqAssistDataMsg = base.AcqAssistDataMsg + "00";
                }
                msg = str5 + "01" + base.AcqAssistDataMsg + str6;
            }
            byte[] buffer = HelperFunctions.HexToByte(msg);
            buffer[0xcab] = 8;
            byte[] buffer2 = this.compressMsg(buffer, 0xcac);
            int    length  = buffer2.GetLength(0);
            byte   num10   = (byte)(length / 0x3f8);
            int    num11   = length % 0x3f8;

            if (0 < (length % 0x3f8))
            {
                num10 = (byte)(num10 + 1);
            }
            byte[] input = new byte[0x3fc];
            input[0] = 1;
            input[1] = 1;
            input[2] = num10;
            byte[] buffer4 = new byte[num11 + 4];
            buffer4[0] = 1;
            buffer4[1] = 1;
            buffer4[2] = num10;
            for (byte j = 0; j < num10; j = (byte)(j + 1))
            {
                if (j < (num10 - 1))
                {
                    input[3] = (byte)(j + 1);
                    for (int n = 0; n < 0x3f8; n++)
                    {
                        input[n + 4] = buffer2[(j * 0x3f8) + n];
                    }
                    num = 0x3fc;
                    string message = HelperFunctions.ByteToHex(input);
                    string str8    = "A0A2" + num.ToString("X").PadLeft(4, '0') + message + utils_AutoReply.GetChecksum(message, true) + "B0B3";
                    str = str + str8.Replace(" ", "") + "\r\n";
                }
                else
                {
                    buffer4[3] = (byte)(j + 1);
                    for (int num14 = 0; num14 < num11; num14++)
                    {
                        buffer4[num14 + 4] = buffer2[(j * 0x3f8) + num14];
                    }
                    num = num11 + 4;
                    string str9  = HelperFunctions.ByteToHex(buffer4);
                    string str10 = "A0A2" + num.ToString("X").PadLeft(4, '0') + str9 + utils_AutoReply.GetChecksum(str9, true) + "B0B3";
                    str = str + str10.Replace(" ", "") + "\r\n";
                }
            }
            return(str);
        }