Example #1
0
        public static PHCCPhysicalDeviceInfo[] GetDevices(bool throwOnFail)
        {
            var devices = new List <PHCCPhysicalDeviceInfo>();
            var ports   = new Ports();

            foreach (var portName in ports.SerialPortNames)
            {
                var deviceInfo = new PHCCPhysicalDeviceInfo(portName, "PHCC device on " + portName);
                try
                {
                    if (
                        PHCCDeviceMonitor.GetInstance(deviceInfo, MinAnalogDataSourceVal,
                                                      MaxAnalogDataSourceVal)
                        .IsDeviceAttached(false))
                    {
                        devices.Add(deviceInfo);
                    }
                }
                catch (Exception ex)
                {
                    _log.Debug(ex.Message, ex);
                }
            }
            var toReturn = devices.ToArray();

            return(toReturn);
        }
Example #2
0
 public static bool IsDeviceAttached(PHCCPhysicalDeviceInfo device, bool throwOnFail)
 {
     if (device == null)
     {
         throw new ArgumentNullException(nameof(device));
     }
     return
         (PHCCDeviceMonitor.GetInstance(device, MinAnalogDataSourceVal,
                                        MaxAnalogDataSourceVal)
          .IsDeviceAttached(throwOnFail));
 }