Beispiel #1
0
 private void OnEventReceived(DeviceRelaisEvent @event)
 {
     if (EventReceived != null)
     {
         EventReceived.Invoke(this, @event);
     }
 }
Beispiel #2
0
        public async Task PullInputsAsync(System.Threading.CancellationToken cancellationToken)
        {
            if (m_DeviceIOPortClient == null)
            {
                return;
            }
            OnvifDevice.Capabilities capabilities = await this.m_onVifDevice.GetDeviceCapabilitiesAsync();

            if (capabilities.Device.IO.InputConnectors == 0)
            {
                return;
            }


            try
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    OnVifServices.OnvifDeviceIO10.GetDigitalInputsResponse inputresponse = await m_DeviceIOPortClient.GetDigitalInputsAsync();

                    foreach (var digital in inputresponse.DigitalInputs)
                    {
                        bool idlestate = digital.IdleStateSpecified;
                        if (digital.IdleState == OnvifDeviceIO10.DigitalIdleState.closed)
                        {
                        }
                        if (digital.IdleState == OnvifDeviceIO10.DigitalIdleState.open)
                        {
                        }

                        {
                            var @event = new DeviceRelaisEvent();
                            OnEventReceived(@event);
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                m_ErrorMessage = ex.Message;
            }
        }
Beispiel #3
0
        public async Task PullRelaisOutputsAsync(System.Threading.CancellationToken cancellationToken)
        {
            if (m_DeviceIOPortClient == null)
            {
                return;
            }
            OnvifDevice.Capabilities capabilities = await this.m_onVifDevice.GetDeviceCapabilitiesAsync();

            try
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    OnVifServices.OnvifDeviceIO10.GetDigitalInputsResponse inputresponse = await m_DeviceIOPortClient.GetDigitalInputsAsync();



                    OnVifServices.OnvifDeviceIO10.GetRelayOutputsResponse1 relayresponse = await m_DeviceIOPortClient.GetRelayOutputsAsync();

                    foreach (var digital in inputresponse.DigitalInputs)
                    {
                        if (digital.IdleState == OnvifDeviceIO10.DigitalIdleState.closed)
                        {
                        }
                        if (digital.IdleState == OnvifDeviceIO10.DigitalIdleState.open)
                        {
                        }

                        {
                            var @event = new DeviceRelaisEvent();
                            OnEventReceived(@event);
                        }
                    }


                    foreach (var relay in relayresponse.RelayOutputs)
                    {
                        //    RelayLogicalState logigalstate = RelayLogicalState.active;

                        //          if (relay.. == OnvifMedia10.R.closed)

                        OnVifServices.OnvifDeviceIO10.GetRelayOutputOptionsResponse relayoptions = await m_DeviceIOPortClient.GetRelayOutputOptionsAsync(relay.token);

                        if (relay.Properties.IdleState == OnvifDeviceIO10.RelayIdleState.open)
                        {
                            OnVifServices.OnvifDeviceIO10.SetRelayOutputStateResponse resp = await m_DeviceIOPortClient.SetRelayOutputStateAsync(relay.token, OnvifDeviceIO10.RelayLogicalState.inactive);


                            var @event = new DeviceRelaisEvent();
                            OnEventReceived(@event);
                        }
                        if (relay.Properties.IdleState == OnvifDeviceIO10.RelayIdleState.closed)
                        {
                            OnVifServices.OnvifDeviceIO10.SetRelayOutputStateResponse resp1 = await m_DeviceIOPortClient.SetRelayOutputStateAsync(relay.token, OnvifDeviceIO10.RelayLogicalState.active);

                            var @event = new DeviceRelaisEvent();
                            OnEventReceived(@event);
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                m_ErrorMessage = ex.Message;
            }
        }