Exemple #1
0
        private bool ParseBssData(byte[] myReadBuffer, out BSSResultData result)
        {
            int length = BitConverter.ToInt32(myReadBuffer, 4);

            byte[] resultBytes = new byte[length - 8];
            Buffer.BlockCopy(myReadBuffer, 8, resultBytes, 0, length - 8);
            BSSResultData resultData = new BSSResultData();

            if (resultData.Parse(resultBytes))
            {
                result = resultData;
                return(true);
            }
            else
            {
                result = null;
                return(false);
            }
        }
Exemple #2
0
 private bool ParseBssData(byte[] myReadBuffer,out BSSResultData result)
 {
     int length = BitConverter.ToInt32(myReadBuffer, 4);
     byte[] resultBytes = new byte[length-8];
     Buffer.BlockCopy(myReadBuffer, 8, resultBytes, 0, length - 8);
     BSSResultData resultData = new BSSResultData();
     if (resultData.Parse(resultBytes))
     {
         result = resultData;
         return true;
     }
     else
     {
         result = null;
         return false;
     }
 }
Exemple #3
0
        private void ParseNetworkPacket(byte[] ReadBuffer, int PacketLength)
        {
            byte[] myReadBuffer = new byte[PacketLength + 8];
            Buffer.BlockCopy(ReadBuffer, 0, myReadBuffer, 0, PacketLength + 8);
            switch (BitConverter.ToUInt16(myReadBuffer, 0))
            {
            case (int)ComID.Ans:
                if (ACPacketHandle != null)
                {
                    ACPacketHandle.Set();
                }
                Ans = BitConverter.ToInt32(myReadBuffer, 8);
                if (Command.Ans.ContainsKey(Ans))
                {
                    MainForm.mf.CmdWindow.DisplayAns(Command.Ans[Ans].ToString());
                }
                else
                {
                    MainForm.mf.CmdWindow.DisplayAns("返回未知ID错误码");
                }
                break;

            case (int)ComID.HighParaAns:
                if (ACPacketHandle != null)
                {
                    ACPacketHandle.Set();
                }
                string str = ParsePara(myReadBuffer);
                byte[] b   = new byte[56];
                Buffer.BlockCopy(myReadBuffer, 8, b, 0, 56);
                MainForm.mf.para.Highpara.Parse(b);
                MainForm.mf.CmdWindow.DisplayAns(str);
                break;

            case (int)ComID.LowParaAns:
                if (ACPacketHandle != null)
                {
                    ACPacketHandle.Set();
                }
                str = ParsePara(myReadBuffer);
                b   = new byte[56];
                Buffer.BlockCopy(myReadBuffer, 8, b, 0, 56);
                MainForm.mf.para.Lowpara.Parse(b);
                MainForm.mf.CmdWindow.DisplayAns(str);
                break;

            case (int)ComID.BSSdata:
                if (!hasRecv)
                {
                    BssFile.SetPath(new DirectoryInfo(MyExecPath));

                    XtfFile.SetPath(new DirectoryInfo(MyExecPath));
                    hasRecv = true;
                }
                BssFile.Write(myReadBuffer);
                BSSResultData resultData = new BSSResultData();

                if (ParseBssData(myReadBuffer, out resultData))
                {
                    BSSObject        data     = null;
                    List <BSSObject> datalist = new List <BSSObject>();
                    str = "";
                    while (resultData.Data.ALLData.Count > 0)
                    {
                        data = resultData.Data.ALLData.Dequeue();
                        str += "收到侧扫数据,长度=" + data.DataBytes.ToString() + "字节,类型:" + Enum.GetName(typeof(ObjectID), data.ID) + "\n";
                        MainForm.mf.DisplayRTBSS(data);
                        datalist.Add(data);
                    }
                    //save to xtf file
                    if (Configuration.bSaveXTF)
                    {
                        SaveXTF(datalist, resultData.Parameter);
                    }
                    datalist.Clear();
                    var highrange = resultData.Parameter.Range;   //
                    var Lowrange  = resultData.Parameter.Range;   //
                    MainForm.mf.DisplayRTRange(highrange.ToString(), Lowrange.ToString());
                    MainForm.mf.CmdWindow.DisplayAns(str);
                }
                break;

            case (int)ComID.SensorData:
                BssSensorData sensorData = new BssSensorData();
                if (ParseSensorData(myReadBuffer, out sensorData))
                {
                    str = "收到传感器数据,长度=" + myReadBuffer.Length + "字节";
                    MainForm.mf.CmdWindow.DisplayAns(str);
                    //MainForm.mf.DisplayRTBSS(resultData);
                }
                break;

            default:
                break;
            }
        }
Exemple #4
0
        private void ParseNetworkPacket(byte[] ReadBuffer, int PacketLength)
        {
            byte[] myReadBuffer = new byte[PacketLength+8];
            Buffer.BlockCopy(ReadBuffer,0,myReadBuffer,0,PacketLength+8);
            switch (BitConverter.ToUInt16(myReadBuffer,0))
            {
                case (int)ComID.Ans:
                    if (ACPacketHandle!=null)
                        ACPacketHandle.Set();
                    Ans = BitConverter.ToInt32(myReadBuffer, 8);
                    if (Command.Ans.ContainsKey(Ans))
                        MainForm.mf.CmdWindow.DisplayAns(Command.Ans[Ans].ToString());
                    else
                    {
                        MainForm.mf.CmdWindow.DisplayAns("返回未知ID错误码");
                    }
                    break;
                case (int)ComID.HighParaAns:
                    if (ACPacketHandle != null)
                        ACPacketHandle.Set();
                    string str = ParsePara(myReadBuffer);
                    byte[] b = new byte[56];
                    Buffer.BlockCopy(myReadBuffer,8,b,0,56);
                    MainForm.mf.para.Highpara.Parse(b);
                    MainForm.mf.CmdWindow.DisplayAns(str);
                    break;
                case (int)ComID.LowParaAns:
                    if (ACPacketHandle != null)
                        ACPacketHandle.Set();
                    str = ParsePara(myReadBuffer);
                    b = new byte[56];
                    Buffer.BlockCopy(myReadBuffer,8,b,0,56);
                    MainForm.mf.para.Lowpara.Parse(b);
                    MainForm.mf.CmdWindow.DisplayAns(str);
                    break;
                case (int)ComID.BSSdata:
                    if(!hasRecv)
                        {
                            BssFile.SetPath(new DirectoryInfo(MyExecPath));
                        
                            XtfFile.SetPath(new DirectoryInfo(MyExecPath));
                            hasRecv = true;
                        }
                    BssFile.Write(myReadBuffer);
                    BSSResultData resultData = new BSSResultData();

                    if (ParseBssData(myReadBuffer, out resultData))
                    {
                        BSSObject data = null;
                        List<BSSObject> datalist = new List<BSSObject>();
                        str = "";
                        while (resultData.Data.ALLData.Count>0)
                        {
                            data = resultData.Data.ALLData.Dequeue();
                            str +=  "收到侧扫数据,长度=" + data.DataBytes.ToString()+"字节,类型:" + Enum.GetName(typeof (ObjectID), data.ID)+"\n";
                            MainForm.mf.DisplayRTBSS(data);
                            datalist.Add(data);
                        }
                        //save to xtf file 
                        if (Configuration.bSaveXTF)
                        {
                            SaveXTF(datalist, resultData.Parameter);
                        }
                        datalist.Clear();
                        var highrange = resultData.Parameter.Range ;//
                        var Lowrange = resultData.Parameter.Range;//
                        MainForm.mf.DisplayRTRange(highrange.ToString(), Lowrange.ToString());
                        MainForm.mf.CmdWindow.DisplayAns(str);
                        
                    }
                    break;
                case (int)ComID.SensorData:
                    BssSensorData sensorData = new BssSensorData();
                    if (ParseSensorData(myReadBuffer, out sensorData))
                    {
                        str = "收到传感器数据,长度=" + myReadBuffer.Length + "字节";
                        MainForm.mf.CmdWindow.DisplayAns(str);
                        //MainForm.mf.DisplayRTBSS(resultData);
                    }
                    break;
                default:
                    break;
            }
        }