Ejemplo n.º 1
0
        /// <summary>
        /// 重置设备集合
        /// </summary>
        /// <param name="devices">设备集合</param>
        public void Reset(List <FlowDevice> devices)
        {
            _startTime = DateTime.Now;

            foreach (var client in _clients)
            {
                bool exist = false;
                foreach (FlowDevice device in devices)
                {
                    if (client.Key == GetDeviceKey(device))
                    {
                        exist = true;
                        break;
                    }
                }
                if (!exist)
                {
                    client.Value.FlowChannel.Stop();
                    client.Value.VideoChannel.Stop();
                    _clients.TryRemove(client.Key, out _);
                }
            }

            foreach (FlowDevice device in devices.Where(d => d.FlowDevice_FlowChannels.Count > 0 && d.FlowDevice_FlowChannels.Any(c => c.Channel.Lanes.Count > 0)))
            {
                bool exist = false;
                foreach (var client in _clients)
                {
                    if (client.Key == GetDeviceKey(device))
                    {
                        exist = true;
                        break;
                    }
                }

                if (!exist)
                {
                    WebSocketClientChannel flowWebsocket = new WebSocketClientChannel(GetDeviceUrl(device, FlowUrl));
                    flowWebsocket.WebSocketReceived += FlowReceivedHandler;
                    WebSocketClientChannel videoWebsocket = new WebSocketClientChannel(GetDeviceUrl(device, VideoUrl));
                    videoWebsocket.WebSocketReceived += VideoReceivedHandler;
                    _clients.TryAdd(GetDeviceKey(device), new Item {
                        FlowChannel = flowWebsocket, VideoChannel = videoWebsocket
                    });
                    flowWebsocket.Start();
                    videoWebsocket.Start();
                }
            }
        }
Ejemplo n.º 2
0
        public void Reset(List <DensityDevice> devices)
        {
            _startTime = DateTime.Now;

            foreach (var client in _clients)
            {
                bool exist = false;
                foreach (DensityDevice device in devices)
                {
                    if (client.Key == GetDeviceKey(device))
                    {
                        exist = true;
                        break;
                    }
                }
                if (!exist)
                {
                    client.Value.Channel.Stop();
                    _clients.TryRemove(client.Key, out _);
                }
            }

            foreach (DensityDevice device in devices.Where(d => d.DensityDevice_DensityChannels.Count > 0 && d.DensityDevice_DensityChannels.Any(c => c.Channel.Regions.Count > 0)))
            {
                bool exist = false;
                foreach (var client in _clients)
                {
                    if (client.Key == GetDeviceKey(device))
                    {
                        exist = true;
                        break;
                    }
                }

                if (!exist)
                {
                    WebSocketClientChannel websocket = new WebSocketClientChannel(GetDeviceUrl(device));
                    websocket.WebSocketReceived += ReceiveHandler;
                    _clients.TryAdd(GetDeviceKey(device), new Item
                    {
                        Channel = websocket
                    });
                    websocket.Start();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 开始适配器
        /// </summary>
        /// <param name="devices">设备集合</param>
        /// <param name="densityBranchBlock">密度数据块分支</param>
        /// <param name="eventBranchBlock">事件数据块分支</param>
        public void Start(List <DensityDevice> devices, DensityBranchBlock densityBranchBlock, EventBranchBlock eventBranchBlock)
        {
            _startTime = DateTime.Now;

            _densityBranchBlock = densityBranchBlock;
            _eventBranchBlock   = eventBranchBlock;

            foreach (DensityDevice device in devices.Where(d => d.DensityDevice_DensityChannels.Count > 0 && d.DensityDevice_DensityChannels.Any(r => r.Channel.Regions.Count > 0)))
            {
                WebSocketClientChannel websocket = new WebSocketClientChannel(GetDeviceUrl(device));
                websocket.WebSocketReceived += ReceiveHandler;
                _clients.TryAdd(GetDeviceKey(device), new Item
                {
                    Channel = websocket
                });
                websocket.Start();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 开始适配器
        /// </summary>
        /// <param name="devices">设备集合</param>
        /// <param name="flowBranchBlock">流量数据分支</param>
        /// <param name="videoBranchBlock">视频结构化数据分支</param>
        public void Start(List <FlowDevice> devices, FlowBranchBlock flowBranchBlock, VideoBranchBlock videoBranchBlock)
        {
            _startTime = DateTime.Now;

            _flowBranchBlock  = flowBranchBlock;
            _videoBranchBlock = videoBranchBlock;
            foreach (FlowDevice device in devices.Where(d => d.FlowDevice_FlowChannels.Count > 0 && d.FlowDevice_FlowChannels.Any(c => c.Channel.Lanes.Count > 0)))
            {
                WebSocketClientChannel flowWebsocket = new WebSocketClientChannel(GetDeviceUrl(device, FlowUrl));
                flowWebsocket.WebSocketReceived += FlowReceivedHandler;
                WebSocketClientChannel videoWebsocket = new WebSocketClientChannel(GetDeviceUrl(device, VideoUrl));
                videoWebsocket.WebSocketReceived += VideoReceivedHandler;
                _clients.TryAdd(GetDeviceKey(device), new Item {
                    FlowChannel = flowWebsocket, VideoChannel = videoWebsocket
                });
                flowWebsocket.Start();
                videoWebsocket.Start();
            }
        }