Example #1
0
        private bool DiscoverDevice(ISerialPortManager serialPortManager)
        {
            ISerialPort serialPort;
            string      response;// just used for testPort receive

            foreach (var portName in serialPortManager.GetNotAllocatedPortNames())
            {
                serialPort = serialPortManager.GetSerialPort(portName);
                ConfigurePortForDiscovery(serialPort);
                Thread.Sleep(MESSAGE_DELAY);

                try
                {
                    serialPort.WriteLine("*IDN?");
                    response = serialPort.ReadLine().ToUpper();
                    serialPort.Close();

                    if (response.Contains("KEITHLEY") && response.Contains("2400"))
                    {
                        SerialPort = serialPort;
                        return(true);
                    }
                }
                catch
                {
                    // Ignore Port error. throw new PortCommunicationException(ex.Message, ex);
                }
            }
            return(false);
        }
Example #2
0
 public override void InitializeDevice(ISerialPortManager serialPortManager)
 {
     _serialPortManager = serialPortManager ?? throw new ArgumentNullException(nameof(serialPortManager));
     if (DiscoverDevice(_serialPortManager))
     {
         ConfigurePort(SerialPort);
     }
     else
     {
         throw new DeviceNotFoundException("No Wayne Kerr 4300 Device available");
     }
 }
Example #3
0
        public override void InitializeDevice(ISerialPortManager serialPortManager)
        {
            if (serialPortManager == null)
            {
                throw new ArgumentNullException(nameof(serialPortManager));
            }
            _serialPortManager = serialPortManager;

            if (DiscoverDevice(_serialPortManager))
            {
                ConfigurePort(SerialPort);
            }
            else
            {
                throw new DeviceNotFoundException("No Keithley 2400 Device available");
            }
        }
        public Worker(ILogger <Worker> logger,
                      IMessenger messenger,
                      ISerialPortManager serialport)
        {
            _logger = logger;

            _messenger = messenger;

            _serialPort = serialport;

            _serialPort.Start();

            if (SystemdHelpers.IsSystemdService())
            {
                _logger.LogInformation("Running as linux daemon");
            }
            else
            {
                _logger.LogInformation("Not running as Linux daemon");
            }
        }
Example #5
0
 public abstract void InitializeDevice(ISerialPortManager serialPortManager);
Example #6
0
 public SerialPortManagerSelector(ISerialPortManager realSerialPortManager, ISerialPortManager serialPortEmulatorManager)
 {
     _realSerialPortManager     = realSerialPortManager;
     _serialPortEmulatorManager = serialPortEmulatorManager;
 }
Example #7
0
 public void InitializeDevice(ISerialPortManager serialPortManager)
 {
     _wayneKerr4300SerialDevice.InitializeDevice(serialPortManager);
 }
Example #8
0
 public void InitializeDevice(ISerialPortManager serialPortManager)
 {
     ((ISerialDevice)_keithley2400SerialDevice).InitializeDevice(serialPortManager);
 }