コード例 #1
0
        public MPowerConnectorManager(IHSApplication HS, MPowerDevice device, CancellationToken shutdownToken)
        {
            this.HS        = HS;
            this.Device    = device;
            rootDeviceData = new DeviceRootDeviceManager(device.Name, device.Id, this.HS);

            combinedCancellationSource = CancellationTokenSource.CreateLinkedTokenSource(shutdownToken, instanceCancellationSource.Token);
            runTask     = Task.Factory.StartNew(ManageConnection, Token);
            processTask = Task.Factory.StartNew(ProcessDeviceUpdates, Token, TaskCreationOptions.LongRunning, TaskScheduler.Current);
        }
コード例 #2
0
 private async Task StartDeviceImport()
 {
     using (var sync = await deviceRootDeviceManagerLock.EnterAsync(ShutdownCancellationToken))
     {
         deviceRootDeviceManager?.Dispose();
         deviceRootDeviceManager = new DeviceRootDeviceManager(HS,
                                                               pluginConfig.DBLoginInformation,
                                                               pluginConfig.ImportDevicesData,
                                                               ShutdownCancellationToken);
     }
 }
コード例 #3
0
        public CameraManager(IHSApplication HS,
                             ICameraSettings cameraSettings,
                             CancellationToken shutdownDownToken)
        {
            this.HS           = HS;
            CameraSettings    = cameraSettings;
            cancelTokenSource = new CombinedCancelToken(shutdownDownToken);
            rootDeviceData    = new DeviceRootDeviceManager(cameraSettings, this.HS, cancelTokenSource.Token);
            camera            = cameraSettings.CreateCamera(shutdownDownToken);

            TaskHelper.StartAsyncWithErrorChecking(Invariant($"{cameraSettings.Name} Process Updates"),
                                                   ProcessUpdates, cancelTokenSource.Token);
        }
コード例 #4
0
        public AirVisualNodeConnectorManager(IHSApplication HS, AirVisualNode device, CancellationToken shutdownToken)
        {
            this.HS        = HS;
            Device         = device;
            rootDeviceData = new DeviceRootDeviceManager(device.Name, device.Id, this.HS);

            combinedCancellationSource = CancellationTokenSource.CreateLinkedTokenSource(shutdownToken);
            connector = new AirVisualNodeConnector(Device.DeviceIP,
                                                   new NetworkCredential(Device.Username, Device.Password),
                                                   combinedCancellationSource.Token);
            connector.SensorDataChanged += SensorDataChanged;

            connector.Connect();
            TaskHelper.StartAsyncWithErrorChecking("Node Updates", ProcessDeviceUpdates, Token);
        }
コード例 #5
0
        private void StartDeviceImport()
        {
            lock (deviceRootDeviceManagerLock)
            {
                if (deviceRootDeviceManager != null)
                {
                    deviceRootDeviceManager.Cancel();
                    deviceRootDeviceManager.Dispose();
                }

                deviceRootDeviceManager = new DeviceRootDeviceManager(HS,
                                                                      pluginConfig.DBLoginInformation,
                                                                      pluginConfig.ImportDevicesData,
                                                                      ShutdownCancellationToken);
            }
        }