Пример #1
0
 public static bool IfTrueWithBAA(byte[] RxBuffer, int Length)
 {
     if (CheckTools.DAT_GetD16FromArray(RxBuffer, 28, 0) != Length)
     {
         return(false);
     }
     return(true);
 }
Пример #2
0
        public static bool ExpendWithBAA(byte[] RxBuffer, int Length)
        {
            if (!IfTrueWithBAA(RxBuffer, Length))
            {
                return(false);
            }
            DensityPacket TempPacket = new DensityPacket();
            int           PacketLength;
            int           TimeSpace;
            int           DataType;
            int           BigBagSize;
            int           i = 4;
            int           TimeOffset;

            ClearDensityPacket(ref TempPacket);
            TempPacket.StationNumber = CheckTools.DAT_GetD32FromArray(RxBuffer, i, 0).ToString(); i += 4;
            TempPacket.StationOrder  = CheckTools.DAT_GetD32FromArray(RxBuffer, i, 0).ToString(); i += 4;
            TempPacket.Note          = Tools.DAT_GetString(RxBuffer, i, 16).Trim(); i += 16;
            PacketLength             = CheckTools.DAT_GetD16FromArray(RxBuffer, i, 0); i += 2;
            TimeSpace  = RxBuffer[i]; i += 1;
            DataType   = RxBuffer[i]; i += 1;
            TimeOffset = i;
            TempPacket.RecordDataTime = Tools.DAT_GetTime(RxBuffer, i).ToString(); i += 6;
            int N            = 60 / TimeSpace;
            int SmallBagSize = N * 4 + 6;

            BigBagSize = (PacketLength - 36) / (SmallBagSize);
            if (BigBagSize != 2)
            {
                return(false);//总共只有水位和雨量两项
            }
            for (int n = 0; n < N; n++)
            {
                TempPacket.RecordDataTime   = Tools.DAT_GetSpaceTime(RxBuffer, TimeOffset, TimeSpace, n).ToString();
                TempPacket.RecordWaterLevel = Tools.DAT_GetNum(RxBuffer, i + n * 4, 0, DataType);
                TempPacket.RecordRainFall   = Tools.DAT_GetNum(RxBuffer, i + SmallBagSize + n * 4, 0, DataType);
                lock (Configs.DensityPacketQueue)
                {
                    Configs.DensityPacketQueue.Enqueue(TempPacket);
                }
            }
            if (SmallBagSize > 0)
            {
                return(true);
            }
            return(false);
        }