/// <summary> /// Remove All Devices From the Factory, if needed it Close the Devices. /// </summary> public void RemoveAllDevices() { if (_deviceHandlerFactory != null) { _deviceHandlerFactory.StopAllDeviceThreads(); _deviceHandlerFactory = null; } if (Devices == null) { return; } try { foreach (var deviceEntry in Devices) { bool isClosed = CloseDeviceFromFactory(deviceEntry.Key); if (isClosed) { RemoveDevice(deviceEntry.Key); } } } catch (InvalidOperationException) { // kann ignoriert werden da alle Devices schon weg sind! } // Devices.Clear(); Devices = null; }
/// <summary> /// Runs the I/O Read/Write for the Device with the given devices Number /// </summary> /// <param name="deviceNumber">Number of the Device to Run</param> /// <param name="mode">Device Mode we will use at Run</param> public void RunDevice(int deviceNumber, IModes mode) { var device = GetDeviceNumber(deviceNumber); device.Modes = mode; if (_deviceHandlerFactory == null) { _deviceHandlerFactory = new DeviceHandlerFactory(); } var deviceHandler = _deviceHandlerFactory.AddNewDeviceThread(device); if (deviceHandler == null) { return; } deviceHandler.RunTimeUpdate += DeviceHandler_RunTimeUpdate; }