/// <summary> /// Stops the device monitor. /// </summary> public static void Stop() { var serialPortNotifier = _serialPortNotifier; if (serialPortNotifier != null) { _serialPortNotifier = null; serialPortNotifier.Stop(); } }
/// <summary> /// Starts the device monitor. This includes observing power state changes in the system. /// </summary> /// <param name="getDevices">The delegate to use to get the list of Locutus devices.</param> public static void Start(Func <IEnumerable <Device> > getDevices) { // TODO: Refactor the file system watcher approach to be in INTV.Shared ... coordinate // with changes to Mac. This is totally generic and should not be hidden here in the // LTO Flash! component. The FileSystemMonitor could likely also be reworked to be shared // between Mac and Linux, though the Mac's IOKit implementation is holding up nicely. DebugOutput("!!!!!DeviceMonitor.Start()"); GetDevices = getDevices; if (_serialPortNotifier == null) { _serialPortNotifier = new FileSystemSerialPortNotifier(); _serialPortNotifier.Start(); SingleInstanceApplication.Instance.Exit += HandleApplicationExit; } }
private static ISerialPortNotifier CreatePortNotifier() { ISerialPortNotifier portNotifier = null; var portNotifierKind = DeviceManagementInterfaceKindHelpers.GetKind(); switch (portNotifierKind) { case DeviceManagementInterfaceKind.IOKit: portNotifier = new IOKitNotificationPort(); break; case DeviceManagementInterfaceKind.Dev: portNotifier = new FileSystemNotifcationPort(); break; } return(portNotifier); }