Пример #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 XiDeviceHandler(deviceDescriptor, DeviceEmptyHandler, BindModeHandler, _deviceLibrary);
                        deviceHandler.Init();
                        _activeDevices.TryAdd(deviceDescriptor, deviceHandler);
                    }

                    _bindModeCallback = callback;
                    deviceHandler.SetDetectionMode(DetectionMode.Bind);
                }
            }
        }
Пример #2
0
 public bool SubscribeInput(InputSubscriptionRequest subReq)
 {
     lock (_lockObj)
     {
         if (!_activeDevices.TryGetValue(subReq.DeviceDescriptor, out var deviceHandler))
         {
             deviceHandler = new XiDeviceHandler(subReq.DeviceDescriptor, DeviceEmptyHandler, BindModeHandler, _deviceLibrary);
             deviceHandler.Init();
             _activeDevices.TryAdd(subReq.DeviceDescriptor, deviceHandler);
         }
         deviceHandler.SubscribeInput(subReq);
         return(true);
     }
 }