修改监控部分功能

This commit is contained in:
2026-05-09 17:49:46 +08:00
parent 06a5f9707d
commit 52ece8211b
14 changed files with 456 additions and 383 deletions

View File

@@ -11,7 +11,7 @@ using System.Threading.Tasks;
namespace SamplePre.Communication.Communication
{
public class ModbusTcpCommunicator : ICommunication, IDisposable
public class ModbusTcpCommunicator : CommunicationBase, IDisposable
{
IModbusMaster _modbusMaster = null;
TcpClient _tcpClient = null;
@@ -19,31 +19,7 @@ namespace SamplePre.Communication.Communication
private readonly int _port;
/// <summary>
/// 是否连接
/// </summary>
private bool _isConnected = false;
/// <summary>
/// 是否连接
/// </summary>
public bool IsConnected
{
get => _isConnected;
set
{
if (_isConnected != value)
{
_isConnected = value;
ConnectionStatusChanged?.Invoke(value);
}
}
}
/// <summary>
/// 连接状态变化事件
/// </summary>
public event Action<bool> ConnectionStatusChanged;
/// <summary>
/// 构造函数
@@ -150,7 +126,7 @@ namespace SamplePre.Communication.Communication
/// <param name="start"></param>
/// <param name="bytes"></param>
/// <returns></returns>
public bool WriteArraysBtye<T>(int Dbno, int start, T[] data)
public override bool WriteArraysBtye<T>(int Dbno, int start, T[] data)
{
@@ -184,7 +160,7 @@ namespace SamplePre.Communication.Communication
/// 读取数组
/// </summary>
/// <returns></returns>
public ushort[] ReadArraysShort(int Dbno, int start, int lenth)
public override ushort[] ReadArraysShort(int Dbno, int start, int lenth)
{
//try
@@ -221,7 +197,7 @@ namespace SamplePre.Communication.Communication
}
public bool WriteSingleData(string address, object value)
public override bool WriteSingleData(string address, object value)
{
throw new NotImplementedException();
}