31 lines
1.3 KiB
C#
31 lines
1.3 KiB
C#
using NModbus;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO.Ports;
|
|
using System.Linq;
|
|
using System.Net.Sockets;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DeviceCommand.Base
|
|
{
|
|
public interface IModbusDevice
|
|
{
|
|
public TcpClient TcpClient { get; set; }
|
|
public SerialPort SerialPort { get; set; }
|
|
public IModbusMaster Modbus { get; set; }
|
|
Task<bool> ConnectAsync(CancellationToken ct = default);
|
|
void Close();
|
|
|
|
Task WriteSingleRegisterAsync(byte slaveAddress, ushort registerAddress, ushort value, CancellationToken ct = default);
|
|
Task WriteMultipleRegistersAsync(byte slaveAddress, ushort startAddress, ushort[] values, CancellationToken ct = default);
|
|
Task<ushort[]> ReadHoldingRegistersAsync(byte slaveAddress, ushort startAddress, ushort numberOfPoints, CancellationToken ct = default);
|
|
|
|
Task WriteSingleCoilAsync(byte slaveAddress, ushort coilAddress, bool value, CancellationToken ct = default);
|
|
Task<bool[]> ReadCoilsAsync(byte slaveAddress, ushort startAddress, ushort numberOfPoints, CancellationToken ct = default);
|
|
|
|
Task<ushort[]> ReadInputRegistersAsync(byte slaveAddress, ushort startAddress, ushort numberOfPoints, CancellationToken ct = default);
|
|
}
|
|
|
|
}
|