点击或拖拽改变大小

OmronFinsNetWriteAsync 方法 (String, Boolean)

向PLC中位软元件写入bool数组,返回是否写入成功,比如你写入D100,values[0]对应D100.0,地址格式为"D100.0","C100.0","W100.0","H100.0","A100.0"
Write the bool array to the PLC's median device and return whether the write was successful. For example, if you write D100, values [0] corresponds to D100.0 and the address format is "D100.0", "C100.0", "W100. 0 "," H100.0 "," A100.0 "

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

参数

address
类型:SystemString
要写入的数据地址
values
类型:SystemBoolean
要写入的实际数据,可以指定任意的长度

返回值

类型:TaskOperateResult
返回写入结果

实现

IReadWriteNetWriteAsync(String, Boolean)
示例
WriteBool示例
OmronFinsNet omronFinsNet = new OmronFinsNet( "192.168.1.110", 9600 );

// 以下是简单的写入,没有仔细校验的方式
omronFinsNet.Write( "D100.1", true );
omronFinsNet.Write( "D100.1", new bool[] { true, false, true, false } );

// 如果需要判断是否读取成功
OperateResult write1 = omronFinsNet.Write( "D100.1", true );
if (write1.IsSuccess)
{
    // success
}
else
{
    // failed
}


OperateResult write2 = omronFinsNet.Write( "D100.1", new bool[] { true, false, true, false } );
if (write2.IsSuccess)
{
    // success
}
else
{
    // failed
}
参见