Files
ADP/DeviceCommand/Devices/IOBoard.cs
2026-06-12 16:55:47 +08:00

49 lines
1.5 KiB
C#

using Common.Attributes;
using DeviceCommand.Base;
using NModbus;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceCommand.Device
{
[ADPCommand]
public class IOBoard : ModbusTcp
{
public IOBoard(string Ip地址, int , int , int )
{
ConfigureDevice(Ip地址, , , );
}
public async Task (byte , ushort , bool data)
{
await Modbus.WriteSingleCoilAsync(, , data);
}
public async Task (byte , ushort , bool[] datas)
{
var = await Modbus.ReadCoilsAsync(1, 0, 16);
for (int i = 0; i < datas.Length; i++)
{
if ( + i < .Length)
{
[ + i] = datas[i];
}
}
await Modbus.WriteMultipleCoilsAsync(, 0, );
}
public async Task (byte , ushort )
{
await Modbus.ReadCoilsAsync(, , 1);
}
public async Task<bool[]> (byte , ushort ,ushort )
{
return await Modbus.ReadCoilsAsync(, , );
}
}
}