修改字段
This commit is contained in:
@@ -17,9 +17,9 @@ namespace DOAN.Infrastructure.PLC
|
||||
// private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static SiemensS7Net siemensTcpNet = null;
|
||||
public static bool ConnectPLC()
|
||||
public static bool ConnectPLC()
|
||||
{
|
||||
siemensTcpNet= new SiemensS7Net(SiemensPLCS.S200Smart, "192.168.2.1")
|
||||
siemensTcpNet = new SiemensS7Net(SiemensPLCS.S200Smart, "192.168.2.1")
|
||||
{
|
||||
ConnectTimeOut = 5000
|
||||
};
|
||||
@@ -46,13 +46,26 @@ namespace DOAN.Infrastructure.PLC
|
||||
/// <param name="addr"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static bool WriteBit(string addr,bool value)
|
||||
public static bool WriteBit(string addr, bool value)
|
||||
{
|
||||
|
||||
|
||||
OperateResult write = siemensTcpNet.Write(addr, value);
|
||||
return write.IsSuccess;
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 读取bit
|
||||
/// </summary>
|
||||
/// <param name="addr"></param>
|
||||
/// <returns></returns>
|
||||
public static bool ReadBit(string addr)
|
||||
{
|
||||
|
||||
bool M100_7 = siemensTcpNet.ReadBool(addr).Content;
|
||||
return M100_7;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void ConnectClose()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user