IModbusSlaveNetwork.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. namespace NModbus
  5. {
  6. /// <summary>
  7. /// A network of slave devices on a single transport.
  8. /// </summary>
  9. public interface IModbusSlaveNetwork : IDisposable
  10. {
  11. /// <summary>
  12. /// Listen for incoming requests.
  13. /// </summary>
  14. /// <returns></returns>
  15. Task ListenAsync(CancellationToken cancellationToken = new CancellationToken());
  16. /// <summary>
  17. /// Add a slave to the network.
  18. /// </summary>
  19. /// <param name="slave"></param>
  20. void AddSlave(IModbusSlave slave);
  21. /// <summary>
  22. /// Get a slave from the network.
  23. /// </summary>
  24. /// <param name="unitId">The slave address</param>
  25. /// <returns>The specified slave, or null if one can't be found.</returns>
  26. IModbusSlave GetSlave(byte unitId);
  27. /// <summary>
  28. /// Removes a slave from the network.
  29. /// </summary>
  30. /// <param name="unitId"></param>
  31. void RemoveSlave(byte unitId);
  32. }
  33. }