Exemple #1
0
        private void ProcessRegisterGroup(IModbusClient client, Register register)
        {
            var dumpRepository = _unitOfWork.DumpsRepository;

            switch (register.Type)
            {
            case RegisterType.Coil:
                dumpRepository.AddRegisterResult(register, client.ReadCoils(register.Offset, register.Count));
                break;

            case RegisterType.DiscreteInput:
                dumpRepository.AddRegisterResult(register, client.ReadInputRegisters(register.Offset, register.Count));
                break;

            case RegisterType.HoldingRegister:
                dumpRepository.AddRegisterResult(register, client.ReadHoldingRegisters(register.Offset, register.Count));
                break;

            case RegisterType.Input:
                dumpRepository.AddRegisterResult(register, client.ReadInputs(register.Offset, register.Count));
                break;
            }

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