SiemensS7NetWriteAsync 方法 (String, Boolean) |
[警告] 向PLC中写入bool数组,比如你写入M100,那么data[0]对应M100.0,写入的长度应该小于1600位
[Warn] Write the bool array to the PLC, for example, if you write M100, then data[0] corresponds to M100.0,
The length of the write should be less than 1600 bits
命名空间:
HslCommunication.Profinet.Siemens
程序集:
HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法 public override Task<OperateResult> WriteAsync(
string address,
bool[] values
)
Public Overrides Function WriteAsync (
address As String,
values As Boolean()
) As Task(Of OperateResult)
public:
virtual Task<OperateResult^>^ WriteAsync(
String^ address,
array<bool>^ values
) override
abstract WriteAsync :
address : string *
values : bool[] -> Task<OperateResult>
override WriteAsync :
address : string *
values : bool[] -> Task<OperateResult>
参数
- address
- 类型:SystemString
起始地址,格式为I100,M100,Q100,DB20.100 -> Starting address, formatted as I100,mM100,Q100,DB20.100 - values
- 类型:SystemBoolean
要写入的bool数组,长度为8的倍数 -> The bool array to write, a multiple of 8 in length
返回值
类型:
TaskOperateResult是否写入成功的结果对象 -> Whether to write a successful result object
实现
IReadWriteNetWriteAsync(String, Boolean)备注 警告: |
---|
批量写入bool数组存在一定的风险,举例写入M100.5的值 [true,false,true,true,false,true],会读取M100-M101的byte[],然后修改中间的位,再写入回去,
如果读取之后写入之前,PLC修改了其他位,则会影响其他的位的数据,请谨慎使用。
There is a certain risk in batch writing bool arrays. For example, writing the value of M100.5 [true,false,true,true,false,true],
will read the byte[] of M100-M101, then modify the middle bit, and then Write back.
If the PLC modifies other bits after reading and before writing, it will affect the data of other bits. Please use it with caution.
|
参见