Пример #1
0
        public void Receive(DataPackage pkgData)
        {
            //收到上报参数
            ReportedParameterItem reportParameterItem = new ReportedParameterItem();

            byte[] dataBuffer = pkgData.PureData;

            using (MemoryStream ms = new MemoryStream(dataBuffer))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    reportParameterItem.StateInterval = br.ReadInt16();
                    reportParameterItem.ThuEnable = br.ReadByte();
                    reportParameterItem.TempInterval = br.ReadByte();
                    reportParameterItem.HumiInterval = br.ReadByte();
                    reportParameterItem.GPIOEnable = br.ReadByte();
                    //br.ReadBytes(6);
                }
            }

            if (OnDataChanged != null)
            {
                DataHandlerEventArgs eventArgs = new DataHandlerEventArgs();
                eventArgs.CMD_ID = pkgData.CtrlHead.CMD_ID;
                eventArgs.Value = reportParameterItem;
                OnDataChanged(this, eventArgs);
            }
        }
Пример #2
0
 public void Set(ReportedParameterItem value)
 {
     Set(false, value.StateInterval, value.ThuEnable, value.TempInterval, value.HumiInterval, value.GPIOEnable);
 }
Пример #3
0
        ReportedParameterItem GetReportParam()
        {
            //设置上报数据
            ReportedParameterItem value = new ReportedParameterItem();
            try
            {
                value.StateInterval = short.Parse(txtReportInterval.Text);
                value.TempInterval = byte.Parse(txtTempInterval.Text);
                value.HumiInterval = byte.Parse(txtHumiInterval.Text);

                value.ThuEnable = (byte)(chkReportThuInterval.Checked ? 1 : 0);
                value.GPIOEnable = (byte)(chkReportGPIOEnable.Checked ? 1 : 0);

            }
            catch
            {
                value = null;
            }

            return value;
        }
Пример #4
0
        void ShowReportParam(ReportedParameterItem value)
        {
            //显示上报数据
            if (value == null) return;
            this.Invoke((EventHandler)delegate
            {
                txtReportInterval.Text = value.StateInterval.ToString();
                txtTempInterval.Text = value.TempInterval.ToString();
                txtHumiInterval.Text = value.HumiInterval.ToString();

                chkReportThuInterval.Checked = (value.ThuEnable == 0 ? false : true);
                chkReportGPIOEnable.Checked = (value.GPIOEnable == 0 ? false : true);
            });
        }
Пример #5
0
 /// <summary>
 /// 设置上报参数
 /// </summary>
 /// <param name="value"></param>
 public void SetReportParam(ReportedParameterItem value)
 {
     runMode = RunMode.Monitor;
     var handler = monitorHandlerMan.dataHandlerDict[HCCommand.REPORTED_PARAMETER] as ReportedParameterHandler;
     if (handler != null)
     {
         handler.Set(value);
     }
 }