Beispiel #1
0
        private void ProcessDevice(IModbusClient client, Device device)
        {
            client.SetSlave(device);
            client.Connect(); // exception: device connection

            device.Registers.ToList().ForEach(register =>
            {
                try
                {
                    ProcessRegisterGroup(client, register); // exception: connection gone away(?), exception: wrong registers data
                }
                catch (Exception e)
                {
                    _unitOfWork.DumpsRepository.AddEmptyRegisterResult(register);

                    _logger.LogError("{date} - Register group {num} error: {exception}", DateTimeOffset.Now, register.Id, e.Message);
                }

                //_logger.LogInformation("{date} - Device {num} processed", DateTimeOffset.Now, device.Id);
            });

            client.Disconnect();
        }