Beispiel #1
0
        /// <summary>
        /// 小盒子
        /// </summary>
        /// <param name="data"></param>
        /// <param name="offset"></param>
        /// <param name="flag"></param>
        public ChannelParam(byte[] data, int offset, bool flag)
        {
            UInt16 crc = CRC16.ComputeCRC16(data, offset + 1, 124 - 2);


            UInt16 crcCal = BitConverter.ToUInt16(data, offset + 1 + 124 - 2);


            if (crc != crcCal)
            {
                return;
            }

            this.ChannnelNum = data[0 + offset];
            this.State       = (byte)(data[2 + offset] >> 7);
            this.SampleRate  = data[1 + offset] + ((data[2 + offset] & 0x1f) << 8);

            this.ChannelType = data[3 + offset];
            //时间
            int year  = data[4 + offset] + 2000;
            int month = data[5 + offset];
            int day   = data[6 + offset];

            this.Time = new DateTime(year, month, day);

            //名字
            int num = data[7 + offset];

            if (num > 0)
            {
                num = num > 8 ? 8 : num;

                this.Person = ASCIIEncoding.UTF8.GetString(data, 8 + offset, num);
            }
            else
            {
                this.Person = "";
            }


            for (int i = 0; i < 21; i++)
            {
                CalcItem calItm = new CalcItem(data, 16 + i * 5 + offset);
                if (calItm.IsValid)
                {
                    calList.Add(calItm);
                }
            }
        }
Beispiel #2
0
 public void ReplaceCalcItem(int m, CalcItem itm)
 {
     calList[m] = itm;
 }
Beispiel #3
0
 public void AddCalcItem(CalcItem itm)
 {
     calList.Add(itm);
 }
Beispiel #4
0
        /// <summary>
        /// 综合电压采集模块
        /// </summary>
        /// <param name="data"></param>
        /// <param name="offset"></param>
        public ChannelParam(byte[] data,int offset)
        {
            InitialMydictionary();
               UInt16 crc= CRC16.ComputeCRC16(data, offset+1, 128 - 2);

               UInt16 crcCal = BitConverter.ToUInt16(data, offset + 1 + 128 - 2);

               if (crc != crcCal) return;

            this.ChannnelNum = data[0 + offset];
            this.State = (byte)(data[2 + offset] >> 7);
            this.SampleRate = data[1 + offset] + ((data[2 + offset] & 0x1f) << 8);

            this.ChannelType = data[3 + offset];
            //时间
            int year = data[4 + offset] + 2000;
            int month = data[5 + offset];
            int day = data[6 + offset];
            this.Time = new DateTime(year, month, day);

            //名字
            int num = data[7 + offset];

            if (num > 0)
            {
                num = num > 7 ? 7 : num;

                this.Person = ASCIIEncoding.UTF8.GetString(data, 8 + offset, num);
            }
            else {

                this.Person = "";
            }

            for (int i = 0; i < 52; i++)
            {

                if (i < 13)
                {
                    if (i == 0)
                    {
                        CalcItem calItm2 = new CalcItem(data, 15 + offset, 0, 0, true);
                        if (calItm2.IsValid)
                        {
                            calList.Add(calItm2);
                        }
                    }
                    else
                    {
                        CalcItem calItm = new CalcItem(data, 15 + (i - 1) * 2 + offset + 4, i, 0);
                        if (calItm.IsValid)
                        {
                            calList.Add(calItm);
                        }
                    }
                }
                else if (i < 26)
                {
                    if (i == 13)
                    {
                        CalcItem calItm2 = new CalcItem(data, 15 + 12 * 2 + 4 + offset, 0, 1, true);
                        if (calItm2.IsValid)
                        {
                            calList.Add(calItm2);
                        }
                    }
                    else
                    {
                        CalcItem calItm = new CalcItem(data, 15 + (i - 2) * 2 + offset + 8, i - 13, 1);
                        if (calItm.IsValid)
                        {
                            calList.Add(calItm);
                        }
                    }
                }
                else if (i < 39)
                {
                    if (i == 26)
                    {
                        CalcItem calItm2 = new CalcItem(data, 15 + 24 * 2 + offset + 8, 0, 2,true);
                        if (calItm2.IsValid)
                        {
                            calList.Add(calItm2);
                        }
                    }
                    else
                    {
                        CalcItem calItm = new CalcItem(data, 15 + (i - 3) * 2 + offset + 12, i - 26, 2);
                        if (calItm.IsValid)
                        {
                            calList.Add(calItm);
                        }
                    }
                }
                else if (i < 52)
                {
                    if (i == 39)
                    {
                        CalcItem calItm2 = new CalcItem(data, 15 + 36 * 2 + offset + 12, 0, 3,true);
                        if (calItm2.IsValid)
                        {
                            calList.Add(calItm2);
                        }
                    }
                    else
                    {
                        CalcItem calItm = new CalcItem(data, 15 + (i - 4) * 2 + offset + 16, i -39, 3);
                        if (calItm.IsValid)
                        {
                            calList.Add(calItm);
                        }
                    }
                }

            }
        }
Beispiel #5
0
        /// <summary>
        /// 小盒子
        /// </summary>
        /// <param name="data"></param>
        /// <param name="offset"></param>
        /// <param name="flag"></param>
        public ChannelParam(byte[] data, int offset, bool flag)
        {
            UInt16 crc = CRC16.ComputeCRC16(data, offset + 1, 124 - 2);

            UInt16 crcCal = BitConverter.ToUInt16(data, offset + 1 + 124 - 2);

            if (crc != crcCal) return;

            this.ChannnelNum = data[0 + offset];
            this.State = (byte)(data[2 + offset] >> 7);
            this.SampleRate = data[1 + offset] + ((data[2 + offset] & 0x1f) << 8);

            this.ChannelType = data[3 + offset];
            //时间
            int year = data[4 + offset] + 2000;
            int month = data[5 + offset];
            int day = data[6 + offset];
            this.Time = new DateTime(year, month, day);

            //名字
            int num = data[7 + offset];

            if (num > 0)
            {
                num = num > 8 ? 8 : num;

                this.Person = ASCIIEncoding.UTF8.GetString(data, 8 + offset, num);
            }
            else
            {

                this.Person = "";
            }

            for (int i = 0; i < 21; i++)
            {
                CalcItem calItm = new CalcItem(data, 16 + i * 5 + offset);
                if (calItm.IsValid)
                {
                    calList.Add(calItm);
                }
            }
        }
Beispiel #6
0
 public void ReplaceCalcItem(int m, CalcItem itm)
 {
     calList[m] = itm;
 }
Beispiel #7
0
 public void AddCalcItem(CalcItem itm)
 {
     calList.Add(itm);
 }
Beispiel #8
0
        /// <summary>
        /// 综合电压采集模块
        /// </summary>
        /// <param name="data"></param>
        /// <param name="offset"></param>
        public ChannelParam(byte[] data, int offset)
        {
            InitialMydictionary();
            UInt16 crc = CRC16.ComputeCRC16(data, offset + 1, 128 - 2);


            UInt16 crcCal = BitConverter.ToUInt16(data, offset + 1 + 128 - 2);


            if (crc != crcCal)
            {
                return;
            }

            this.ChannnelNum = data[0 + offset];
            this.State       = (byte)(data[2 + offset] >> 7);
            this.SampleRate  = data[1 + offset] + ((data[2 + offset] & 0x1f) << 8);

            this.ChannelType = data[3 + offset];
            //时间
            int year  = data[4 + offset] + 2000;
            int month = data[5 + offset];
            int day   = data[6 + offset];

            this.Time = new DateTime(year, month, day);

            //名字
            int num = data[7 + offset];

            if (num > 0)
            {
                num = num > 7 ? 7 : num;

                this.Person = ASCIIEncoding.UTF8.GetString(data, 8 + offset, num);
            }
            else
            {
                this.Person = "";
            }


            for (int i = 0; i < 52; i++)
            {
                if (i < 13)
                {
                    if (i == 0)
                    {
                        CalcItem calItm2 = new CalcItem(data, 15 + offset, 0, 0, true);
                        if (calItm2.IsValid)
                        {
                            calList.Add(calItm2);
                        }
                    }
                    else
                    {
                        CalcItem calItm = new CalcItem(data, 15 + (i - 1) * 2 + offset + 4, i, 0);
                        if (calItm.IsValid)
                        {
                            calList.Add(calItm);
                        }
                    }
                }
                else if (i < 26)
                {
                    if (i == 13)
                    {
                        CalcItem calItm2 = new CalcItem(data, 15 + 12 * 2 + 4 + offset, 0, 1, true);
                        if (calItm2.IsValid)
                        {
                            calList.Add(calItm2);
                        }
                    }
                    else
                    {
                        CalcItem calItm = new CalcItem(data, 15 + (i - 2) * 2 + offset + 8, i - 13, 1);
                        if (calItm.IsValid)
                        {
                            calList.Add(calItm);
                        }
                    }
                }
                else if (i < 39)
                {
                    if (i == 26)
                    {
                        CalcItem calItm2 = new CalcItem(data, 15 + 24 * 2 + offset + 8, 0, 2, true);
                        if (calItm2.IsValid)
                        {
                            calList.Add(calItm2);
                        }
                    }
                    else
                    {
                        CalcItem calItm = new CalcItem(data, 15 + (i - 3) * 2 + offset + 12, i - 26, 2);
                        if (calItm.IsValid)
                        {
                            calList.Add(calItm);
                        }
                    }
                }
                else if (i < 52)
                {
                    if (i == 39)
                    {
                        CalcItem calItm2 = new CalcItem(data, 15 + 36 * 2 + offset + 12, 0, 3, true);
                        if (calItm2.IsValid)
                        {
                            calList.Add(calItm2);
                        }
                    }
                    else
                    {
                        CalcItem calItm = new CalcItem(data, 15 + (i - 4) * 2 + offset + 16, i - 39, 3);
                        if (calItm.IsValid)
                        {
                            calList.Add(calItm);
                        }
                    }
                }
            }
        }