예제 #1
0
        private byte[] Decode(byte[] data, ref B3Element element)
        {
            if (data.Length == 0 || !Enum.IsDefined(typeof(DecodeType), data[0]))
            {
                IsChecked = false; return(new byte[0]);
            }

            int length = GetLength(data[0]);

            if (length == 0 || data.Length < length)
            {
                IsChecked = false; return(new byte[0]);
            }

            switch ((DecodeType)data[0])
            {
            case DecodeType.CenterCode:
                element.CenterCode = ElementDecodeFunctions.CenterCode(data);
                break;

            case DecodeType.ClientCode:
                element.ClientCode = ElementDecodeFunctions.ClientCode(data);
                break;

            case DecodeType.IPPort:
                element.IPPort = ElementDecodeFunctions.IPPort(data);
                break;

            case DecodeType.Interval:
                element.Interval = ElementDecodeFunctions.Interval(data);
                break;
            }

            return(BytesUtil.SubBytes(data, length));
        }
예제 #2
0
        //解析召测/自报数据采集时间,E0E0开头,若不是,则解析有误
        public DateTime DataTime(byte[] data)
        {
            if (data.Length < 2 || !(data[0].Equals(0xE0) && data[1].Equals(0xE0)))
            {
                IsChecked = false; return(DateTime.MinValue);
            }

            return(ElementDecodeFunctions.DataTime(data));
        }
예제 #3
0
        private byte[] Decode(byte[] data, ref Element element)
        {
            if (data.Length == 0 || !Enum.IsDefined(typeof(DecodeType), data[0]))
            {
                return(new byte[0]);
            }

            int length = GetLength(data[0]);

            if (length == 0 || data.Length < length)
            {
                return(new byte[0]);
            }

            switch ((DecodeType)data[0])
            {
            case DecodeType.Code:
                element.Code = ElementDecodeFunctions.Code(data);
                break;

            case DecodeType.Humidity:
                element.Humidity = ElementDecodeFunctions.Humiture(data);
                break;

            case DecodeType.Temperature:
                element.Temperature = ElementDecodeFunctions.Humiture(data);
                break;

            case DecodeType.State:
                element.State = ElementDecodeFunctions.State(data);
                break;

            case DecodeType.HumidityLimit:
                element.HumidityLimit = ElementDecodeFunctions.Humiture(data);
                break;

            case DecodeType.TemperatureLimit:
                element.TemperatureLimit = ElementDecodeFunctions.Humiture(data);
                break;
            }

            return(BytesUtil.SubBytes(data, length));
        }