Beispiel #1
0
        private async Task InitializeAstmAsync()
        {
            switch (Settings.ConnectionMode)
            {
            case ConnectionMode.Ethernet:
                var isPortValid = ushort.TryParse(Settings.Port.ToString(), out var uShortPort);
                if (!isPortValid)
                {
                    logger.Error($"Invalid port defined: {Settings.Port}. Max value allowed for port is 65535"); return;
                }

                lowLevelConnection = new Lis01A02TCPConnection(Settings.IpAddress, uShortPort);
                lisConnection      = new Lis01A2Connection(lowLevelConnection);

                await ConnectAsync();

                break;

            case ConnectionMode.Serial:
                lowLevelConnection = new Lis01A02RS232Connection(Settings.SerialPort);
                lisConnection      = new Lis01A2Connection(lowLevelConnection);
                await ConnectAsync();

                break;

            default:
                break;
            }
        }
 public Lis01A2Connection(ILis01A2Connection connection, int timeOut)
 {
     Connection = connection;
     _receiveTimeOutTimer.Interval = timeOut * 1000;
     _receiveTimeOutTimer.Enabled  = false;
     _receiveTimeOutTimer.Elapsed += ReceiveTimeOutTimer_Elapsed;
     _logger = LoggerFactory.GetLogger(typeof(Lis01A2Connection));
 }
 public Lis01A2Connection(ILis01A2Connection connection) : this(connection, 30)
 {
 }