点击或拖拽改变大小

SiemensS7NetWriteAsync 方法 (String, Boolean)

写入PLC的一个位,例如"M100.6","I100.7","Q100.0","DB20.100.0",如果只写了"M100"默认为"M100.0"
Write a bit of PLC, for example "M100.6", "I100.7", "Q100.0", "DB20.100.0", if only write "M100" defaults to "M100.0"

命名空间:  HslCommunication.Profinet.Siemens
程序集:  HslCommunication (在 HslCommunication.dll 中) 版本:11.0.6.0 (11.0.6.0)
语法
public override Task<OperateResult> WriteAsync(
	string address,
	bool value
)

参数

address
类型:SystemString
起始地址,格式为"M100.6", "I100.7", "Q100.0", "DB20.100.0" -> Start address, format "M100.6", "I100.7", "Q100.0", "DB20.100.0"
value
类型:SystemBoolean
写入的数据,True或是False -> Writes the data, either True or False

返回值

类型:TaskOperateResult
是否写入成功的结果对象 -> Whether to write a successful result object

实现

IReadWriteNetWriteAsync(String, Boolean)
示例
假设写入M100.0的位是否通断
WriteBool示例
SiemensS7Net siemens = new SiemensS7Net( SiemensPLCS.S1200, " 192.168.1.110" );

// 以下是简单的写入,没有仔细校验的方式
siemens.Write( "M100.0", true );

// 如果需要判断是否读取成功
OperateResult write1 = siemens.Write( "M100.0", true );
if (write1.IsSuccess)
{
    // success
}
else
{
    // failed
}
参见