Exemplo n.º 1
0
        /// <summary>
        /// 断帧
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        internal static void SetResultArray(byte[] result)
        {
            try
            {
                if (result.Length > 0)
                {
                    if (result[0] != 0x03)
                    {
                        return;
                    }

                    int contentLength = 0, nowIndex = 1;
                    while (result.Length > contentLength)
                    {
                        contentLength += BytesSerialize.returnByteLengthRight(result.Skip(nowIndex).Take(4).ToArray());
                        queueArray.Add(result.Skip(nowIndex - 1).Take(contentLength).ToArray());
                        nowIndex += contentLength + 1;
                    }
                }
            }
            catch (Exception msg)
            {
                Log.LogWrite(msg);
            }
        }
Exemplo n.º 2
0
        internal List <PortChartData> ChartShowNew(string pullPathFile, out List <string> listName)
        {
            List <PortChartData> theListPortChartData = new List <PortChartData>();
            int Index = 1;

            listName = new List <string>();
            int nowIndex = 0;

            try
            {
                string newPath = pullPathFile.Replace(".dat", ".cfg");
                using (StreamReader sr = new StreamReader(newPath))
                {
                    sr.ReadLine();
                    int myCount = int.Parse(Regex.Match(sr.ReadLine().Split(',')[1].Trim(), @"^[0-9]+").Value);
                    for (int i = 0; i < myCount; i++)
                    {
                        listName.Add(sr.ReadLine().Split(',')[1]);
                    }
                    using (FileStream sf = new FileStream(Path.GetFullPath(pullPathFile), FileMode.Open))
                    {
                        byte[] bytes = new byte[sf.Length];
                        sf.Read(bytes, 0, bytes.Length);
                        int count = bytes.Length / 48;
                        List <PortChartLineData> lines = new List <PortChartLineData>();
                        for (nowIndex = 0; nowIndex < count; nowIndex++)
                        {
                            List <byte>   bs = bytes.Skip(nowIndex * 48).Take(myCount * 2 + 8).ToList();
                            PortChartData thePortChartData = new PortChartData();
                            thePortChartData.V_X = BytesSerialize.returnByteLengthRightLeft(bs.Skip(4).Take(4).ToArray());  //竖坐标X
                            thePortChartData.H_Y = (ByteWithString.ByteArrayToInt(bs.Skip(8).Take(myCount * 2).ToArray())); //竖坐标Y
                            theListPortChartData.Add(thePortChartData);
                        }
                    }
                }
            }
            catch (Exception r) {
                int ss   = nowIndex;
                int dddv = Index;
                //string ss = "";
            }
            return(theListPortChartData);
        }
Exemplo n.º 3
0
 private void reportSel(byte[] data)
 {
     while (true)
     {
         if (data.Length == 0)
         {
             break;
         }
         if (data[0] != 0x03)
         {
             break;
         }
         int reportLength = BytesSerialize.returnByteLengthRight(data.Skip(1).Take(4).ToArray());
         if (reportLength > data.Length)
         {
             break;
         }
         byte[] report = data.Skip(0).Take(reportLength).ToArray();
         reports.Add(report);
         data = data.Skip(reportLength).Take(data.Length - reportLength).ToArray();
     }
 }