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); }
private async Task StartDeviceImport() { using (var sync = await deviceRootDeviceManagerLock.EnterAsync(ShutdownCancellationToken)) { deviceRootDeviceManager?.Dispose(); deviceRootDeviceManager = new DeviceRootDeviceManager(HS, pluginConfig.DBLoginInformation, pluginConfig.ImportDevicesData, ShutdownCancellationToken); } }
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); }
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); }
private void StartDeviceImport() { lock (deviceRootDeviceManagerLock) { if (deviceRootDeviceManager != null) { deviceRootDeviceManager.Cancel(); deviceRootDeviceManager.Dispose(); } deviceRootDeviceManager = new DeviceRootDeviceManager(HS, pluginConfig.DBLoginInformation, pluginConfig.ImportDevicesData, ShutdownCancellationToken); } }