Пример #1
0
 private void se()
 {
     while (isRun)
     {
         Thread.Sleep(1000);
         if (isA)
         {
             adam.SetData();
             if (of1 != ofn1)
             {
                 adam.OnOff(of1 ? ADAM4150FuncID.OnDO2 : ADAM4150FuncID.OffDO2);
                 ofn1 = of1;
             }
             if (of2 != ofn2)
             {
                 adam.OnOff(of2 ? ADAM4150FuncID.OnDO1 : ADAM4150FuncID.OffDO1);
                 ofn2 = of2;
             }
         }
         if (isZ)
         {
             zigBee.GetSet();
         }
     }
 }
Пример #2
0
        /// <summary>
        /// 开关楼道灯
        /// </summary>
        /// <param name="onOff">true为开false为关</param>
        /// <param name="infrared">用于控制是否需要红外线感应才开启</param>
        private void OnOffCorridorLamp(bool OnOff, bool infrared)
        {
            //使用Global.ADAM4150Provider.CheckSerialPort来判断相应串口是否打开
            ICS.Common.ResultEntity result = Global.ADAM4150Provider.CheckSerialPort(Global.ADAM4150Provider.ADAM4017Provider);
            //若执行状态(retData.Status)为失败(Result.Failure),则表示串口未打开,设置错误信息用于返回
            if (result.Status == RunStatus.Failure)
            {
                MessageBox.Show(result.ResultMessage);
                return;
            }

            //将ADAM4150数字量控制类赋值给新变量,方便下面的使用
            ADAM4150 adam = Global.ADAM4150Provider;

            //判断是打开还是关闭楼道灯,byte[]数组存放开关灯命令,adam.OnOff(data);执行命令返回执行结果
            if (OnOff == false)
            {
                //byte[]数组存放关闭楼道灯命令
                byte[] data = new byte[] { 0x01, 0x05, 0x00, 0x11, 0x00, 0x00, 0x9D, 0xCF };
                OnOff = adam.OnOff(data);
                btnCorridorLamp.Content = "开关楼道灯";
            }
            else
            {
                //byte[]数组存放开启楼道灯命令
                byte[] data = new byte[] { 0x01, 0x05, 0x00, 0x11, 0xFF, 0x00, 0xDC, 0x3F };
                OnOff = adam.OnOff(data);
                btnCorridorLamp.Content = "关闭楼道灯";
            }

            if (OnOff == false)
            {
                MessageBox.Show("操作楼道灯失败!");
            }
        }
Пример #3
0
        private void MonitorZigBee()
        {
            zigBee.GetSet();

            this.Dispatcher.Invoke(new Action(() =>
            {
                lblTemp.Content = zigBee.lightValue;
                lblHum.Content  = zigBee.temperatureValue;
                lblLig.Content  = zigBee.lightValue;
            }));

            double lightNum, limitNum;

            if (double.TryParse(zigBee.lightValue, out lightNum) && double.TryParse(txbLig.Text, out limitNum))
            {
                if (lightNum < limitNum)
                {
                    adam.OnOff(ADAM4150FuncID.OffDO2);
                }
                else
                {
                    adam.OnOff(ADAM4150FuncID.OnDO2);
                }
            }
        }
Пример #4
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            DigitalLibrary.ComSettingModel csm = new DigitalLibrary.ComSettingModel();
            csm.DigitalQuantityCom = "com2";
            ADAM4150 adam = new ADAM4150(csm);

            if (button1.Tag.ToString() == "1")
            {
                adam.OnOff(ADAM4150FuncID.OffDO0);
                button1.Tag = "0";
            }
            else
            {
                adam.OnOff(ADAM4150FuncID.OnDO0);
                button1.Tag = "1";
            }
        }
Пример #5
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            adam.SetData();

            if (isHum == adam.DI0)
            {
                return;
            }

            isHum = adam.DI0;

            if (!isHum)
            {
                adam.OnOff(ADAM4150FuncID.OnDO0);
            }
            else
            {
                adam.OnOff(ADAM4150FuncID.OffDO0);
            }
        }
Пример #6
0
        /// <summary>
        /// 开关路灯
        /// </summary>
        /// <param name="onOff">true为开false为关</param>
        private void OnOffStreetLamp(bool OnOff)

        {
            //使用Global.ADAM4150Provider.CheckSerialPort来判断相应串口是否打开
            ICS.Common.ResultEntity result = Global.ADAM4150Provider.CheckSerialPort(Global.ADAM4150Provider.ADAM4017Provider);
            //若执行状态(ret.Status)为失败(Result.Failure),则表示串口未打开,设置错误信息用于返回
            if (result.Status == RunStatus.Failure)
            {
                MessageBox.Show(result.ResultMessage);
                return;
            }

            //将ADAM4150数字量控制类赋值给新变量,方便下面的使用
            ADAM4150 adam = Global.ADAM4150Provider;

            //判断是打开还是关闭路灯,adam.OnOff(data);执行命令返回执行结果
            if (OnOff == false)
            {
                //byte[]数组存放关闭路灯命令
                byte[] data = new byte[] { 0x01, 0x05, 0x00, 0x12, 0x00, 0x00, 0x6D, 0xCF };
                OnOff = adam.OnOff(data);
                btnStreetLamp.Content = "开关路灯";
            }
            else
            {
                //byte[]数组存放开启路灯命令
                byte[] data = new byte[] { 0x01, 0x05, 0x00, 0x12, 0xFF, 0x00, 0x2C, 0x3F };
                OnOff = adam.OnOff(data);
                btnStreetLamp.Content = "关闭路灯";
            }

            //判断执行结果是否成功
            if (OnOff == false)
            {
                MessageBox.Show("开启路灯失败。");
            }
        }
Пример #7
0
 private void btnDO0_Click(object sender, RoutedEventArgs e)
 {
     if ((string)btnDO0.Content == "打开")
     {
         if (adam.OnOff(ADAM4150FuncID.OnDO0))
         {
             btnDO0.Content = "关闭";
         }
     }
     else
     {
         if (adam.OnOff(ADAM4150FuncID.OffDO0))
         {
             btnDO0.Content = "打开";
         }
     }
 }
 /// <summary>
 /// 控制风扇
 /// </summary>
 /// <param name="v"></param>
 public void ControlFan(bool state)
 {
     if (state)
     {
         if (_adam.OnOff(ADAM4150FuncID.OnDO1))
         {
             _info.IsFanOpen = state;
         }
     }
     else
     {
         if (_adam.OnOff(ADAM4150FuncID.OffDO1))
         {
             _info.IsFanOpen = state;
         }
     }
 }