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; } }
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(); }
private void MonitorLogic() { while (true) //线程循环监测 { UpdateLogic(); //更新逻辑值状态 if (savedLogical == logicalValue) //逻辑值状态未改变时跳出 { return; } savedLogical = logicalValue; //逻辑值已改变,保存逻辑值到变量 if (savedLogical) { ipCamera.StartProcessing(); } else { ipCamera.StopProcessing(); } Thread.Sleep(1000); } }
public MainWindow() { InitializeComponent(); ipc = new IpCameraHelper("10.96.34.171:80", "admin", "", new Action <ImageEventArgs>((a) => { bit = a.FrameReadyEventArgs.BitmapImage; })); ipc.StartProcessing(); sto.IsEnabled = false; gam.IsEnabled = true; ti = new Timer(50); ti.Elapsed += new ElapsedEventHandler(tim1); ti2 = new Timer(50); ti2.Elapsed += new ElapsedEventHandler(tim2); // ti.BeginInit(); }