Пример #1
0
        /// <summary>
        /// 直流
        /// </summary>
        /// <returns></returns>

        public byte[] ToArray2()
        {
            //byte[] data = new byte[4];
            List <byte> data = new List <byte>();

            //int freq = Array.IndexOf(FrequencyArray, this.Freq);
            //byte freqval = (byte)freq;
            //byte freqtmp = (byte)(freqval << 4);
            //byte gearval = this.Gear;
            //byte xx = (byte)(freqtmp + gearval);

            //data[0] = (byte)((freqval << 4) + gearval);
            //data[0] = freqval;
            Int16 tmp = HalfFloat.ToInt16(this.CoeffK);

            data.Add((byte)(tmp & 0xff));
            data.Add((byte)((tmp >> 8) & 0xff));
            //if(freqval == 0)
            //{
            tmp = HalfFloat.ToInt16(this.CoeffB);
            data.Add((byte)(tmp & 0xff));
            data.Add((byte)((tmp >> 8) & 0xff));
            //}
            return(data.ToArray());
        }
Пример #2
0
        /// <summary>
        /// 交流
        /// </summary>
        /// <returns></returns>
        ///
        public byte[] ToArray()
        {
            List <byte> data = new List <byte>();

            Int16 tmp = HalfFloat.ToInt16(this.CoeffK);

            data.Add((byte)(tmp & 0xff));
            data.Add((byte)((tmp >> 8) & 0xff));
            //tmp = HalfFloat.ToInt16(this.CoeffB);
            //data.Add((byte)(tmp & 0xff));
            //data.Add((byte)((tmp >> 8) & 0xff));
            ////}
            return(data.ToArray());
        }
Пример #3
0
        /// <summary>
        /// 小盒子
        /// </summary>
        /// <returns></returns>
        public byte[] ToArray3()
        {
            byte[] data = new byte[5];

            int  freq    = Array.IndexOf(FrequencyArray, this.Freq);
            byte freqval = (byte)freq;
            //byte freqtmp = (byte)(freqval << 4);
            byte gearval = this.Gear;

            //byte xx = (byte)(freqtmp + gearval);

            data[0] = (byte)((freqval << 4) + gearval);
            Int16 tmp = HalfFloat.ToInt16(this.CoeffK);

            data[1] = (byte)(tmp & 0xff);
            data[2] = (byte)((tmp >> 8) & 0xff);

            tmp     = HalfFloat.ToInt16(this.CoeffB);
            data[3] = (byte)(tmp & 0xff);
            data[4] = (byte)((tmp >> 8) & 0xff);

            return(data);
        }