VWED_server/docs/sc/Melsec相关.md

122 lines
2.7 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.

# Melsec (Python 版本)
#### Melsec 读取 boolean
* 方法说明
Melsec 读取 boolean。
```python
def read_melsec_boolean(ip: str, port: int, address: str) -> bool | None
```
* 输入参数
* ip: str 类型,从机 IP
* port: int 类型,从机端口
* address: str 类型,读取的地址位
* 输出参数
* None: 读取失败
* bool: 读取成功的返回值
* 异常
本方法不抛出异常,异常捕获后只作日志记录。
#### Melsec 读取 number
* 方法说明
Melsec 读取 number。
```python
def read_melsec_number(ip: str, port: int, address: str) -> float | None
```
* 输入参数
* ip: str 类型,从机 IP
* port: int 类型,从机端口
* address: str 类型,读取的地址位
* 输出参数
* None: 读取失败
* float: 读取成功的返回值
* 异常
本方法不抛出异常,异常捕获后只作日志记录。
#### Melsec 读取 string
* 方法说明
Melsec 读取 string。
```python
def read_melsec_string(ip: str, port: int, address: str, length: int) -> str | None
```
* 输入参数
* ip: str 类型,从机 IP
* port: int 类型,从机端口
* address: str 类型,读取的地址位
* length: int 类型,读取的长度
* 输出参数
* None: 读取失败
* str: 读取成功的返回值
* 异常
本方法不抛出异常,异常捕获后只作日志记录。
#### Melsec 写入 boolean
* 方法说明
Melsec 写入 boolean。
```python
def write_melsec_boolean(ip: str, port: int, address: str, value: bool) -> bool
```
* 输入参数
* ip: str 类型,从机 IP
* port: int 类型,从机端口
* address: str 类型,写入的地址位
* value: bool 类型,写入的值
* 输出参数
* 成功返回 True失败返回 False
* 异常
本方法不抛出异常,异常捕获后只作日志记录。
#### Melsec 写入 number
* 方法说明
Melsec 写入 number。
```python
def write_melsec_number(ip: str, port: int, address: str, value: float) -> bool
```
* 输入参数
* ip: str 类型,从机 IP
* port: int 类型,从机端口
* address: str 类型,写入的地址位
* value: float 类型,写入的值
* 输出参数
* 成功返回 True失败返回 False
* 异常
本方法不抛出异常,异常捕获后只作日志记录。
#### Melsec 写入 string
* 方法说明
Melsec 写入 string。
```python
def write_melsec_string(ip: str, port: int, address: str, value: str) -> bool
```
* 输入参数
* ip: str 类型,从机 IP
* port: int 类型,从机端口
* address: str 类型,写入的地址位
* value: str 类型,写入的值
* 输出参数
* 成功返回 True失败返回 False
* 异常
本方法不抛出异常,异常捕获后只作日志记录。