public void CaptureWorkerStartFeed() { capture.Start(); Assert.IsTrue(capture.Started); Assert.IsTrue(capture.Capturing); }
/// <summary> /// 初始化设备 /// </summary> /// <param name="instance">设备</param> /// <param name="device">设备配置</param> /// <returns>是否成功</returns> private bool InitializeDevice(IDevice instance, Configuration.Device device) { try { var category = Enum.Parse(typeof(DeviceCategory), device.category); switch (category) { case DeviceCategory.Camera: { // 启动服务线程并设置参数 if (!instance.Write(WriteMode.URI, device.uri)) { Tracker.LogE($"Write parameters fail: {device.model}"); return(false); } if (!instance.Write(WriteMode.CameraParameters, device.cameraParameters)) { Tracker.LogE($"Write parameters fail: {device.model}"); return(false); } // 启动获取数据工作线程 dynamic worker = new CaptureWorker(); if (ARESULT.AFAILED(worker.Initialize(new Dictionary <string, object>() { { "cell", this }, { "device", instance } }))) { Tracker.LogE($"CaptureVideoWorker initialize fail: {device.model}"); return(false); } if (ARESULT.AFAILED(worker.Start())) { Tracker.LogE($"CaptureVideoWorker start fail: {device.model}"); return(false); } workers.Add(worker); Tracker.LogE($"CaptureVideoWorker start succeed: {device.model}"); break; } case DeviceCategory.IrCamera: { // 启动服务线程并设置参数 if (!instance.Write(WriteMode.URI, device.uri)) { Tracker.LogE($"Write parameters fail: {device.model}"); return(false); } if (!instance.Write(WriteMode.IrCameraParameters, device.irCameraParameters)) { Tracker.LogE($"Write parameters fail: {device.model}"); return(false); } if (!instance.Write(WriteMode.CameraParameters, device.cameraParameters)) { Tracker.LogE($"Write parameters fail: {device.model}"); return(false); } // 启动获取数据工作线程 dynamic worker = new CaptureWorker(); if (ARESULT.AFAILED(worker.Initialize(new Dictionary <string, object>() { { "cell", this }, { "device", instance } }))) { Tracker.LogE($"CaptureVideoWorker initialize fail: {device.model}"); return(false); } if (ARESULT.AFAILED(worker.Start())) { Tracker.LogE($"CaptureVideoWorker start fail: {device.model}"); return(false); } workers.Add(worker); Tracker.LogE($"CaptureVideoWorker start succeed: {device.model}"); // 启动处理告警工作线程 worker = new ProcessAlarmWorker(); if (ARESULT.AFAILED(worker.Initialize(new Dictionary <string, object>() { { "cell", this }, { "device", instance } }))) { Tracker.LogE($"ProcessAlarmWorker initialize fail: {device.model}"); return(false); } if (ARESULT.AFAILED(worker.Start())) { Tracker.LogE($"ProcessAlarmWorker start fail: {device.model}"); return(false); } workers.Add(worker); Tracker.LogE($"ProcessAlarmWorker start succeed: {device.model}"); break; } default: return(false); } return(true); } catch (Exception e) { Tracker.LogE($"Initialize device fail: {device.model}", e); return(false); } }