Files
IOT/DeviceCommand/Base/IS7Device.cs
2026-06-09 15:54:50 +08:00

22 lines
965 B
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using S7.Net;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceCommand.Base
{
public interface IS7Device : IBaseInterface, IDisposable
{
// 暴露出 S7.Net 原生的 Plc 对象,方便外部进行复杂扩展
Plc PlcContext { get; }
// 核心读写接口(支持直接传物理地址,如 "DB1.DBD0" 或 "M0.0"
Task WriteAsync(string address, object value, CancellationToken ct = default);
Task<object> ReadAsync(string address, CancellationToken ct = default);
Task<T> ReadAsync<T>(string address, CancellationToken ct = default);
// 批量读取/写入原始字节(常用于大块数据交互)
Task<byte[]> ReadBytesAsync(DataType dataType, int db, int startByteAdr, int count, CancellationToken ct = default);
Task WriteBytesAsync(DataType dataType, int db, int startByteAdr, byte[] value, CancellationToken ct = default);
}
}