コード例 #1
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("操作楼道灯失败!");
            }
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            adam = new ADAM4150(new ComSettingModel {
                DigitalQuantityCom = "COM2"
            });
        }
コード例 #3
0
 private void InitDevices()
 {
     string[] port = SerialPort.GetPortNames();
     if (port.Length <= 0)
     {
         return;
     }
     adamDevices = new ADAM4150(port[0]);
     adamDevices.Open();
 }
コード例 #4
0
 /// <summary>
 /// 初始化设备
 /// </summary>
 private void InitDevices()
 {
     //string[] port = SerialPort.GetPortNames();
     //if (port.Length <= 0)
     //{
     //    return;
     //}
     adamDevices = new ADAM4150("COM4");
     adamDevices.Open();
 }
コード例 #5
0
        public MainWindow()
        {
            InitializeComponent();

            adam = new ADAM4150(new ComSettingModel {
                DigitalQuantityCom = "COM3"
            });

            timer.Elapsed += Timer_Elapsed;
            timer.Interval = 1000;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            adam = new ADAM4150(new ComSettingModel()
            {
                DigitalQuantityCom = cmbADAM.SelectedItem.ToString()
            });

            timer.Elapsed  += Timer_Elapsed;
            timer.AutoReset = true;
            timer.Interval  = 100;
        }
コード例 #7
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            adam = new ADAM4150(new ComSettingModel()
            {
                DigitalQuantityCom = "COM5"
            });

            thread.Start();

            if (!Directory.Exists(@"Image\"))
            {
                Directory.CreateDirectory(@"Image\");
            }
        }
コード例 #8
0
        public MainWindow()
        {
            InitializeComponent();
            comZ           = new ZigBeeLibrary.ComSettingModel();
            comZ.ZigbeeCom = "COM6";
            zigBee         = new ZigBee(comZ);
            zigBee.DataReceivedCallback += ZigBee_DataReceivedCallback;

            comA = new DigitalLibrary.ComSettingModel();
            comA.DigitalQuantityCom = "COM4";
            adam = new ADAM4150(comA);

            seach = new Thread(new ThreadStart(se));
            seach.Start();
        }
コード例 #9
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            zigBee = new ZigBee(new ZigBeeLibrary.ComSettingModel()
            {
                ZigbeeCom = "COM4"
            });
            adam = new ADAM4150(new DigitalLibrary.ComSettingModel()
            {
                DigitalQuantityCom = "COM5"
            });

            timer.Elapsed  += Timer_Elapsed;
            timer.AutoReset = true;
            timer.Interval  = 1000;
            timer.Start();
        }
コード例 #10
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";
            }
        }
コード例 #11
0
 private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
 {
     var timer = new Timer(_sender =>
     {
         var equipment = new ADAM4150(new ComSettingModel());
         if (equipment.CheckSerialPort(equipment.ADAM4017Provider).Status == RunStatus.Success)
         {
             equipment.SetData();
             Application.Current.Dispatcher.Invoke(() =>
             {
                 Fire.Background         = equipment.fireValue ? Brushes.Tomato : Brushes.CornflowerBlue;
                 Smoke.Background        = equipment.smokeValue ? Brushes.Tomato : Brushes.CornflowerBlue;
                 BodyInfrared.Background = equipment.bodyInfraredValue
                         ? Brushes.Tomato
                         : Brushes.CornflowerBlue;
             });
         }
     }, null, 100, 1000);
 }
コード例 #12
0
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            var exHelper = new ExhibitionHelper(exhibitionLight, catchThief, policemen, haveThief, this, imgDoor.Name, imgDoor.Name);

            LazyTimer timer = new LazyTimer(_sender =>
            {
                LazyTimer t = (LazyTimer)_sender[0];
                var statevalue = new ADAM4150(new ComSettingModel());
                if (statevalue.CheckSerialPort(statevalue.ADAM4017Provider).Status ==
                    RunStatus.Failure) return;

                Application.Current.Dispatcher.Invoke(() =>
                {
                    exHelper.OpenAlarm(statevalue.infraredValue);
                });
                t.Reset();
            }, 100, 5000);

            }
コード例 #13
0
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            var timer = new Timer(_sender =>
                {
                var equipment = new ADAM4150(new ComSettingModel());
                    if (equipment.CheckSerialPort(equipment.ADAM4017Provider).Status == RunStatus.Success)
                    {
                        equipment.SetData();
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            Fire.Background = equipment.fireValue ? Brushes.Tomato : Brushes.CornflowerBlue;
                            Smoke.Background = equipment.smokeValue ? Brushes.Tomato : Brushes.CornflowerBlue;
                            BodyInfrared.Background = equipment.bodyInfraredValue
                                ? Brushes.Tomato
                                : Brushes.CornflowerBlue;

                        });
                    }
                },null, 100, 1000);
        }
コード例 #14
0
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            var exHelper = new ExhibitionHelper(exhibitionLight, catchThief, policemen, haveThief, this, imgDoor.Name, imgDoor.Name);

            LazyTimer timer = new LazyTimer(_sender =>
            {
                LazyTimer t    = (LazyTimer)_sender[0];
                var statevalue = new ADAM4150(new ComSettingModel());
                if (statevalue.CheckSerialPort(statevalue.ADAM4017Provider).Status ==
                    RunStatus.Failure)
                {
                    return;
                }

                Application.Current.Dispatcher.Invoke(() =>
                {
                    exHelper.OpenAlarm(statevalue.infraredValue);
                });
                t.Reset();
            }, 100, 5000);
        }
コード例 #15
0
        private void No1_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
        var equipment = new ADAM4150(new ComSettingModel());
            var state = equipment.CheckSerialPort(equipment.ADAM4017Provider);
            if (state.Status == RunStatus.Success)
            {
                if (Global.ADAM4150Provider.OnOff( no1state ? ADAM4150FuncID.OffSocket1 : ADAM4150FuncID.OnSocket1 ))
                {
                    no1.Text = no1state ? "OFF" : "ON";
                    no1.Background = no1state ? Brushes.LightCoral : Brushes.CornflowerBlue;
                    no1state = !no1state;
                }
                else
                {
                    MessageBox.Show("The Operation is erron");
                }
            }
            else
            {
                MessageBox.Show(state.ResultMessage);
            }

        }
コード例 #16
0
        private void No1_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var equipment = new ADAM4150(new ComSettingModel());
            var state     = equipment.CheckSerialPort(equipment.ADAM4017Provider);

            if (state.Status == RunStatus.Success)
            {
                if (Global.ADAM4150Provider.OnOff(no1state ? ADAM4150FuncID.OffSocket1 : ADAM4150FuncID.OnSocket1))
                {
                    no1.Text       = no1state ? "OFF" : "ON";
                    no1.Background = no1state ? Brushes.LightCoral : Brushes.CornflowerBlue;
                    no1state       = !no1state;
                }
                else
                {
                    MessageBox.Show("The Operation is erron");
                }
            }
            else
            {
                MessageBox.Show(state.ResultMessage);
            }
        }
コード例 #17
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("开启路灯失败。");
            }
        }
コード例 #18
0
        private void Dst_Tick(object sender, EventArgs e)
        {
            ZigBeeLibrary.ComSettingModel zig = new ZigBeeLibrary.ComSettingModel();
            zig.ZigbeeCom = "com3";

            DigitalLibrary.ComSettingModel adam = new DigitalLibrary.ComSettingModel();
            adam.DigitalQuantityCom = "com2";

            ZigBee zigb = new ZigBee(zig);

            zigb.GetSet();

            ADAM4150 ada = new ADAM4150(adam);

            ada.SetData();

            textBox.Text  = zigb.temperatureValue;
            textBox1.Text = zigb.humidityValue;
            textBox5.Text = zigb.lightValue;
            textBox2.Text = ada.DI2.ToString();
            textBox3.Text = ada.DI1.ToString();
            textBox4.Text = ada.DI0.ToString();
            textBox6.Text = ada.DI4.ToString();
        }