PLC 交互

This commit is contained in:
qianhao.xu
2024-11-08 08:42:33 +08:00
parent 74c849149e
commit 47855d3f54
7 changed files with 104 additions and 48 deletions

View File

@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace DOAN.Infrastructure.PLC
{
public class PCLTool
public class PLCTool
{
@@ -40,22 +40,18 @@ namespace DOAN.Infrastructure.PLC
}
public static int Write(string addr,int num)
/// <summary>
/// 写入bit
/// </summary>
/// <param name="addr"></param>
/// <param name="value"></param>
/// <returns></returns>
public static bool WriteBit(string addr,bool value)
{
OperateResult write = siemensTcpNet.Write(addr, (byte)num);
if (write.IsSuccess)
{
Console.WriteLine("Write [v100] success");
return 1;
}
else
{
Console.WriteLine("Write [v100] failed: " + write.Message);
return 0;
}
OperateResult write = siemensTcpNet.Write(addr, value);
return write.IsSuccess;
}
public static void ConnectClose()