PBL 1-15 审核修改
This commit is contained in:
@@ -80,6 +80,71 @@ namespace DOAN.Infrastructure.PLC
|
||||
return M100_7;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读多个连续的二进制数据 转为字节数组
|
||||
/// </summary>
|
||||
/// <param name="addr"></param>
|
||||
/// <param name="length"></param>
|
||||
/// <returns></returns>
|
||||
//public byte[,] ReadAllValue(string addr = "VB100", ushort length = 11)
|
||||
//{
|
||||
// byte[,] data = new byte[length, 8];
|
||||
// //需要自行解析,length为地址个数
|
||||
// siemensTcpNet.ReadByte(addr);
|
||||
// OperateResult<byte[]> result = siemensTcpNet.Read(addr, length);
|
||||
// if (result.IsSuccess)
|
||||
// {
|
||||
|
||||
// if (result.Content.Length > 0)
|
||||
// {
|
||||
|
||||
// for (int i = 0; i < result.Content.Length; i++)
|
||||
// {
|
||||
|
||||
// int row = i / 8;
|
||||
// int col = i % 8;
|
||||
// data[row, col] = result.Content[i];
|
||||
|
||||
// }
|
||||
// return data;
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine($"PLC IO 取值失败,地址为{addr},地址个数为{length}");
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 读多个连续的二进制数据 转为字节数组
|
||||
/// </summary>
|
||||
/// <param name="addr"></param>
|
||||
/// <param name="length"></param>
|
||||
/// <returns></returns>
|
||||
public byte[] ReadAllValue(string addr = "VB100", ushort length = 12)
|
||||
{
|
||||
|
||||
//需要自行解析,length为地址个数
|
||||
siemensTcpNet.ReadByte(addr);
|
||||
OperateResult<byte[]> result = siemensTcpNet.Read(addr, length);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
|
||||
return result.Content;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"PLC IO 取值失败,地址为{addr},地址个数为{length}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ConnectClose()
|
||||
|
||||
Reference in New Issue
Block a user