Exemple #1
0
        private IX20Device GetConnectedDevice()
        {
            var devices = X20DeviceEnumerator.GetDevices(SerilogHelper.GetLoggerFactory());

            if (devices.Count() == 0)
            {
                return(null);
            }

            try
            {
                var dev = devices.First().CreateDevice(SerilogHelper.GetLoggerFactory());

                // send 'get capabilities' command
                var capabilities = dev.GetCapabilities();
                SamplingRate = capabilities.SamplingRate;

                dev.UsePpgWaveform();
                //      dev.UseRamp();

                // send 'start' command
                dev.StartMeasurement();

                return(dev);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Warning: " + ex.Message);
            }
            return(null);
        }
        public static IX20Device GetFirstSuitableDevice(ILoggerFactory loggerFactory)
        {
            var deviceInfo = X20DeviceEnumerator.GetDevices(loggerFactory).FirstOrDefault();

            if (deviceInfo == null)
            {
                throw new Exception("Could not find a PSK-X20 device.");
            }
            loggerFactory.CreateLogger(nameof(DeviceHelper))
            .LogInformation($"Using device with serial number '{deviceInfo.SerialNumber}'");
            return(deviceInfo.CreateDevice(loggerFactory));;
        }
Exemple #3
0
        private static Func <PhysioDataPackage> GetWinUsbPhysioPipeReader(Guid guid)
        {
            var logger  = SerilogHelper.CreateLogger(nameof(Program));
            var devices = X20DeviceEnumerator.GetDevices(SerilogHelper.GetLoggerFactory());

            if (devices.Count() == 0)
            {
                Console.WriteLine("No matching WinUSB devices found, waiting to connect...");
                do
                {
                    System.Threading.Thread.Sleep(1000);
                    devices = X20DeviceEnumerator.GetDevices(SerilogHelper.GetLoggerFactory());
                }while (devices.Count() == 0);
            }
            var dev = devices.First().CreateDevice(SerilogHelper.GetLoggerFactory());

            dev.UsePpgWaveform();
            dev.StartMeasurement();

            // read pipe function for WinUSB device
            Func <PhysioDataPackage> readData = () => dev.GetPhysioData();

            return(readData);
        }