Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        static public byte[] Parse(TemperatureLine line)
        {
            ArgumentChecker.CheckNotNull(line);
            byte[] bs = new byte[_size * 2];
            for (int i = 0; i < _size; i++)
            {
                byte[] linePointDatas = TemperatureLinePoint.Parse(line[i]);
                int    idx            = i * 2;

                bs[idx]     = linePointDatas[0];
                bs[idx + 1] = linePointDatas[1];
            }
            return(bs);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="datas"></param>
        /// <param name="beginPos"></param>
        /// <returns></returns>
        static public TemperatureLine Parse(byte[] datas, int beginPos)
        {
            ArgumentChecker.CheckNotNull(datas);
            if (datas.Length < (_size * 2) + beginPos)
            {
                throw new ArgumentException("datas.length");
            }

            TemperatureLine tl = new TemperatureLine();

            for (int i = 0; i < _size; i++)
            {
                int    idx             = i * 2 + beginPos;
                byte[] pointDatas      = new byte[] { datas[idx], datas[idx + 1] };
                TemperatureLinePoint p = TemperatureLinePoint.Parse(pointDatas);
                tl[i] = p;
            }

            return(tl);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public override CommResultState ProcessReceived(byte[] data)
        {
            CommResultState r = GRCommandMaker.CheckReceivedData(Station.Address,
                                                                 GRDef.DEVICE_TYPE, GRDef.FC_READ_SETTINGS, data);

            if (r == CommResultState.Correct)
            {
                byte[] innerDatas = GRCommandMaker.GetReceivedInnerData(data);

                byte mc = innerDatas[0];
                if (mc == GRDef.MC_TEMPERATURE_LINE)
                {
                    _tl = TemperatureLine.Parse(innerDatas, 1);
                    this._timetempline = TimeTempLine.Parse(innerDatas, 1 + 16);
                }
                else
                {
                    return(CommResultState.DataError);
                }
            }
            return(r);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="st"></param>
 public GRWriteOTGT2Line(GRStation st, TemperatureLine tl)
 {
     Station = st;
     _tl     = tl;
 }
Example #5
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public byte[] GetBytes()
 {
     return(TemperatureLine.Parse(this));
 }