Пример #1
0
        public LISParser(ILisConnection aConnection)
        {
            Connection = aConnection;
            //slf4net.LoggerFactory.GetLogger(typeof(MyClass));

            fLog = LoggerFactory.GetLogger(typeof(LISParser));
        }
Пример #2
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;
            }
        }