VWED_server/docs/sc/OPC UA相关.md

94 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

```markdown
## OPC-UA
#### OPC 读取数值
* 方法说明
读取 OPC server 中的某个地址位的值。
```python
def read_opc_value(address: str | int) -> any:
```
* 输入参数
* `address`str 类型,读取的地址位。
* 输出参数
* 读到的值。
* 异常
读取失败会抛出 `RuntimeError` 异常 "read_opc_value error"。
* 方法说明
```python
def read_opc_value(namespace_index: int, address: str | int) -> any:
```
* 输入参数
* `namespace_index`int 类型,命名空间索引
* `address`str 类型,读取的地址位。地址类型 g=550e8400-e29b-41d4-a716-446655440000: g= 表示地址类型是 UUIDi=1008: i= 表示地址类型是 numberb=EAk=: b= 表示地址类型是 Opaques=1009: s= 表示地址类型是字符串
* 输出参数
* 读到的值。
* 异常
读取失败会抛出 `RuntimeError` 异常 "read_opc_value error"。
#### OPC 订阅方式读取数值
* 方法说明
通过订阅的方式,读取 OPC server 中的某个地址位的值。
```python
def read_opc_value_by_subscription(namespace_index: int, address: str) -> any:
```
* 输入参数
* `namespace_index`int 类型,命名空间索引。
* `address`str 类型,读取的地址位。地址类型 g=550e8400-e29b-41d4-a716-446655440000: g= 表示地址类型是 UUIDi=1008: i= 表示地址类型是 numberb=EAk=: b= 表示地址类型是 Opaques=1009: s= 表示地址类型是字符串
* 输出参数
* 读到的值。
* 异常
读取失败会抛出 `RuntimeError` 异常 "read_opc_value error"。
#### OPC 写入数值
* 方法说明
向 OPC server 中的某个地址位写入值。
```python
def write_opc_value(address: str | int, value: any) -> bool:
```
* 输入参数
* `address`str 类型,表示写入的地址。
* `value`any 类型,写入的值。
* 输出参数
成功返回 `True`,失败返回 `False`
* 异常
本方法不抛出异常。
* 方法说明
向 OPC server 中的某个地址位写入值。
```python
def write_opc_value(namespace_index: int, address: str | int, value: any) -> bool:
```
* 输入参数
* `namespace_index`int 类型,命名空间索引
* `address`str 类型,表示写入的地址。地址类型 g=550e8400-e29b-41d4-a716-446655440000: g= 表示地址类型是 UUIDi=1008: i= 表示地址类型是 numberb=EAk=: b= 表示地址类型是 Opaques=1009: s= 表示地址类型是字符串
* `value`any 类型,写入的值。
* 输出参数
成功返回 `True`,失败返回 `False`
* 异常
本方法不抛出异常。
```