Ejemplo n.º 1
0
        public void SetDetectionMode(DetectionMode detectionMode, DeviceDescriptor deviceDescriptor, Action <ProviderDescriptor, DeviceDescriptor, BindingReport, short> callback = null)
        {
            lock (_lockObj)
            {
                var deviceExists = _activeDevices.TryGetValue(deviceDescriptor, out var deviceHandler);
                if (detectionMode == DetectionMode.Subscription)
                {
                    // Subscription Mode
                    if (!deviceExists)
                    {
                        return;
                    }
                    deviceHandler.SetDetectionMode(DetectionMode.Subscription);
                }
                else
                {
                    // Bind Mode
                    if (!deviceExists)
                    {
                        deviceHandler = new DiDeviceHandler(deviceDescriptor, DeviceEmptyHandler, BindModeHandler, _deviceLibrary);
                        deviceHandler.Init();
                        _activeDevices.TryAdd(deviceDescriptor, deviceHandler);
                    }

                    _bindModeCallback = callback;
                    deviceHandler.SetDetectionMode(DetectionMode.Bind);
                }
            }
        }
Ejemplo n.º 2
0
 public bool SubscribeInput(InputSubscriptionRequest subReq)
 {
     lock (_lockObj)
     {
         if (!_activeDevices.TryGetValue(subReq.DeviceDescriptor, out var deviceHandler))
         {
             deviceHandler = new DiDeviceHandler(subReq.DeviceDescriptor, DeviceEmptyHandler, BindModeHandler, _deviceLibrary);
             deviceHandler.Init();
             _activeDevices.TryAdd(subReq.DeviceDescriptor, deviceHandler);
         }
         deviceHandler.SubscribeInput(subReq);
         return(true);
     }
 }