Example #1
0
        /// <summary>
        /// 将 byte[] 转换成供热控制器的实时数据对象,
        /// </summary>
        /// <param name="datas">is innerDatas</param>
        /// <param name="fromAddress"></param>
        /// <returns></returns>
        static public GRRealData Parse(byte[] datas, int fromAddress)
        {
            ArgumentChecker.CheckNotNull(datas);
            Debug.Assert(datas.Length == 0x68, "Parse GRRealData"); //Decimal  104

            GRRealData rd = new GRRealData();


            rd._twoGiveBaseTemp = GetFloatValue(datas, 0 + 8);
            rd._DrangeSubSet    = GetFloatValue(datas, 4 + 8);
            rd._DrangeSet       = GetFloatValue(datas, 8 + 8);
            rd._outsideTemp     = GetFloatValue(datas, 12 + 8);
            rd._oneGiveTemp     = GetFloatValue(datas, 16 + 8);
            rd._oneBackTemp     = GetFloatValue(datas, 20 + 8);
            rd._twoGiveTemp     = GetFloatValue(datas, 24 + 8);
            rd._twoBackTemp     = GetFloatValue(datas, 28 + 8);
            rd._oneGivePress    = GetFloatValue(datas, 32 + 8);
            rd._oneBackPress    = GetFloatValue(datas, 36 + 8);
            rd._twoGivePress    = GetFloatValue(datas, 40 + 8);
            rd._twoBackPress    = GetFloatValue(datas, 44 + 8);

            rd._openDegree = GetByteValue(datas, 48 + 8);

            rd._WatBoxLevel = GetFloatValue(datas, 49 + 8);
            rd._oneInstant  = GetFloatValue(datas, 53 + 8);
            rd._twoInstant  = GetFloatValue(datas, 57 + 8);

            rd._oneAccum = GetULongValue(datas, 69 + 8);
            rd._twoAccum = GetULongValue(datas, 73 + 8);

            rd._warn1    = GetByteValue(datas, 86 + 8);
            rd._warn2    = GetByteValue(datas, 87 + 8);
            rd._state    = GetByteValue(datas, 88 + 8);
            rd._datetime = DateTime.Now;

            rd._twoPressCha = rd._twoGivePress - rd._twoBackPress;
            rd._grPumpState = GRPumpState.Parse(rd._state);
            rd._fromAddress = fromAddress;

            //int fromAddr=99;
            rd._grAlarmData = GRAlarmData.Parse(
                new byte[] { rd._warn1, rd._warn2 },
                fromAddress);

            return(rd);
        }
Example #2
0
        static public GRRealData Parse(DataRow r)
        {
            if (r == null)
            {
                return(null);
            }
            try
            {
                GRRealData rd = new GRRealData();
                rd._datetime        = Convert.ToDateTime(r["time"]);
                rd._oneGiveTemp     = Convert.ToSingle(r["oneGiveTemp"]);
                rd._oneBackTemp     = Convert.ToSingle(r["oneBackTemp"]);
                rd._twoGiveTemp     = Convert.ToSingle(r["twoGiveTemp"]);
                rd._twoBackTemp     = Convert.ToSingle(r["twoBackTemp"]);
                rd._outsideTemp     = Convert.ToSingle(r["outsideTemp"]);
                rd._twoGiveBaseTemp = Convert.ToSingle(r["twoGiveBaseTemp"]);
                rd._oneGivePress    = Convert.ToSingle(r["oneGivePress"]);
                rd._oneBackPress    = Convert.ToSingle(r["oneBackPress"]);
                rd._WatBoxLevel     = Convert.ToSingle(r["WatBoxLevel"]);
                rd._twoGivePress    = Convert.ToSingle(r["twoGivePress"]);
                rd._twoBackPress    = Convert.ToSingle(r["twoBackPress"]);
                rd._oneInstant      = Convert.ToSingle(r["oneInstant"]);
                rd._twoInstant      = Convert.ToSingle(r["twoInstant"]);
                rd._oneAccum        = (uint)Convert.ToInt32(r["oneAccum"]);
                rd._twoAccum        = (uint)Convert.ToInt32(r["twoAccum"]);
                rd._openDegree      = Convert.ToByte(r["openDegree"]);
                rd._twoPressCha     = Convert.ToSingle(r["twoPressCha"]);

                GRPumpState pumpState = GRPumpState.Parse(r);

                rd._grPumpState = pumpState;
                rd._grAlarmData = null;

                return(rd);
            }
            catch (Exception ex)
            {
                MsgBox.Show(ex.ToString());
                return(null);
            }
//            return null;
        }