Ejemplo n.º 1
0
    public static List <DS_protocol.p_IdToFrames> DSerializeData(byte[] buffers)
    {
        var ms = new MemoryStream(buffers);
        var br = new BinaryReader(ms);

        List <DS_protocol.p_IdToFrames> idtofreames = new List <DS_protocol.p_IdToFrames>();

        int nAreaCount = br.ReadChar();

        for (int nLoop = 0; nLoop < nAreaCount; nLoop++)
        {
            DS_protocol.p_IdToFrames TIdToFrame = new DS_protocol.p_IdToFrames();


            TIdToFrame.areaid = br.ReadChar();
            int nSyncFrameCount = br.ReadInt16();

            int nStartIndex = 0;
            for (int i = 0; i < nSyncFrameCount; i++)
            {
                DS_protocol.p_SyncFrame TFrame = new DS_protocol.p_SyncFrame();
                //TFrame.frame_count = br.ReadInt16();

                if (i == 0)
                {
                    nStartIndex = br.ReadInt16();
                }
                int nFrameMsgCount = br.ReadChar();
                TFrame.frame_count = nStartIndex++;
                SyncFrame cur = new SyncFrame(TFrame.frame_count, TIdToFrame.areaid);

                for (int msgLoop = 0; msgLoop < nFrameMsgCount; msgLoop++)
                {
                    var tt = DSerializeData(ms, br);
                    if (tt != null)
                    {
                        cur.msg_list.Add(tt);
                    }
                }

                Serialization.Buffer_SyncFrame_msg_list(cur.msg_list, TFrame.msg_list);
                TIdToFrame.frames.Add(TFrame);
            }

            idtofreames.Add(TIdToFrame);
        }

        br.Close();
        ms.Close();

        return(idtofreames);
    }
Ejemplo n.º 2
0
    public static bool Commpare(List <DS_protocol.p_IdToFrames> T1, List <DS_protocol.p_IdToFrames> T2)
    {
        if (T1.Count != T2.Count)
        {
            return(false);
        }

        for (int nLoop = 0; nLoop < T1.Count; ++nLoop)
        {
            DS_protocol.p_IdToFrames T1area_to_Frames = T1[nLoop];
            DS_protocol.p_IdToFrames T2area_to_Frames = T2[nLoop];

            if (T1area_to_Frames.areaid != T2area_to_Frames.areaid)
            {
                return(false);
            }

            for (int nLoop2 = 0; nLoop2 < T1area_to_Frames.frames.Count; ++nLoop2)
            {
                DS_protocol.p_SyncFrame T1p_syncFrame = T1area_to_Frames.frames[nLoop2];
                DS_protocol.p_SyncFrame T2p_syncFrame = T2area_to_Frames.frames[nLoop2];

                if (T1p_syncFrame.frame_count != T2p_syncFrame.frame_count)
                {
                    return(false);
                }

                if (T1p_syncFrame.msg_list.Count != T2p_syncFrame.msg_list.Count)
                {
                    return(false);
                }

                for (int nLoop3 = 0; nLoop3 < T1p_syncFrame.msg_list.Count; ++nLoop3)
                {
                    DS_protocol.p_CustomSyncMsg T1Msg = T1p_syncFrame.msg_list[nLoop3];
                    DS_protocol.p_CustomSyncMsg T2Msg = T2p_syncFrame.msg_list[nLoop3];

                    if (!Commpare(T1Msg, T2Msg))
                    {
                        return(false);
                    }
                }
            }
        }


        return(true);
    }