示例#1
0
        static public GRAlarmData Parse(byte[] datas, int fromAddress)
        {
            ArgumentChecker.CheckNotNull(datas);
            Debug.Assert(datas.Length == 2, "datas length != 2");
            //if ( datas.Length != 2 )
            byte b1 = datas[0];
            byte b2 = datas[1];

            GRAlarmData ad = new GRAlarmData();

            ad._oneGiveTemp_lo  = IsAlarm(b1, 0);
            ad._twoGiveTemp_hi  = IsAlarm(b1, 1);
            ad._oneGivePress_lo = IsAlarm(b1, 2);
            ad._twoGivePress_hi = IsAlarm(b1, 3);
            ad._twoBackPress_hi = IsAlarm(b1, 4);
            ad._twoBackPress_lo = IsAlarm(b1, 5);
            ad._watLevel_lo     = IsAlarm(b1, 6);
            ad._watLevel_hi     = IsAlarm(b1, 7);

            ad._cycPump1     = IsAlarm(b2, 0);
            ad._cycPump2     = IsAlarm(b2, 1);
            ad._cycPump3     = IsAlarm(b2, 2);
            ad._recruitPump1 = IsAlarm(b2, 3);
            ad._recruitPump2 = IsAlarm(b2, 4);
            ad._powerOff     = IsAlarm(b2, 5);
            ad._fromAddress  = fromAddress;
            return(ad);
        }
示例#2
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);
        }
示例#3
0
        //
        static public CommResultState ProcessAutoReport(byte[] datas, out GRAlarmData alarmData)
        {
            //if ( datas == null )
            //    return CommResultState.NullData;
            //if ( datas.Length != 11 )
            //    return CommResultState.LengthError;
            CommResultState result = GRCommandMaker.CheckReceivedData(0xA0, 0x20, datas);

            if (result != CommResultState.Correct)
            {
                alarmData = null;
            }
            else
            {
                int addr = datas[GRDef.ADDRESS_POS];
                alarmData = Parse(GRCommandMaker.GetReceivedInnerData(datas), addr);
            }
            return(result);
        }
示例#4
0
        //private void CollRealData()
        //{
        //    GRRealDataCommand realCmd = new GRRealDataCommand(_defGrStation);
        //    Task realTask = new Task(realCmd, new ImmediateTaskStrategy() );
        //    _grTaskSch.Tasks.Add( realTask );
        //}
        //private void SetTemp()
        //{
        //    GRSetOutSideTempCommand c = new GRSetOutSideTempCommand( _defGrStation, 21.9F );
        //    Task t = new Task( c, new ImmediateTaskStrategy() );
        //    _grTaskSch.Tasks.Add( t );
        //}
        //private void SetOutSideMode()
        //{
        //    GRSetOutSideTempModeCommand c = new GRSetOutSideTempModeCommand( _defGrStation, OutSideTempWorkMode.SetByComputer );
        //    Task t = new Task( c, new ImmediateTaskStrategy() );
        //    _grTaskSch.Tasks.Add( t );
        //}
        private void CommPortProxy_ReceiveAutoReport(object sender, EventArgs e)
        {
            //try
            //{
            CommPortProxy cpp = (CommPortProxy)sender;

            byte[] bs = cpp.AutoReportData;
            string s  = CT.BytesToString(bs) + Environment.NewLine + bs.Length;

            //MsgBox.Show (s );o
            AddLog(s);
            GRAlarmData ad;

            if (GRAlarmData.ProcessAutoReport(bs, out ad) == CommResultState.Correct)
            {
                frmPropertiesGrid f = new frmPropertiesGrid();
                f.ShowMe(ad, "");
            }
            //}
            //catch(Exception ex)
            //{
            //    MsgBox.Show( ex.ToString() );
            //}
        }