예제 #1
0
        public void MonitorSensor()
        {
            if (ipCameraHelper == null)
            {
                this.Dispatcher.Invoke(new Action(() =>
                {
                    ipCameraHelper = new IpCameraHelper("192.168.3.200:80", "admin", "", new Action <ImageEventArgs>(ShowImage));
                }));
            }

            //adam.SetData();

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

            adamDIO = adam.DI0;

            if (!adamDIO)
            {
                ipCameraHelper.StartProcessing();
            }
            else
            {
                if (ipCameraHelper != null)
                {
                    ipCameraHelper.StopProcessing();
                }
            }

            MonitorSensor();
        }
예제 #2
0
        public void MonitorSensor()
        {
            //adam.SetData();

            if ((int)btnStart.Tag == 0)
            {
                if (ipCameraHelper == null)
                {
                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        ipCameraHelper = new IpCameraHelper(cameraIp, "admin", "", new Action <ImageEventArgs>(ShowImage));
                    }));
                }

                ipCameraHelper.StartProcessing();

                btnStart.Content = "停止监控";
                btnStart.Tag     = 1;
            }
            else
            {
                if (ipCameraHelper != null)
                {
                    ipCameraHelper.StopProcessing();
                }

                btnStart.Content = "开始监控";
                btnStart.Tag     = 0;
            }
        }
        private void MonitorLogic()
        {
            while (true)                          //线程循环监测
            {
                UpdateLogic();                    //更新逻辑值状态

                if (savedLogical == logicalValue) //逻辑值状态未改变时跳出
                {
                    return;
                }

                savedLogical = logicalValue;        //逻辑值已改变,保存逻辑值到变量

                if (savedLogical)
                {
                    ipCamera.StartProcessing();
                }
                else
                {
                    ipCamera.StopProcessing();
                }

                Thread.Sleep(1000);
            }
        }