Metadata-Version: 2.4
Name: estool-sdk
Version: 0.0.1
Summary: ESTool SDK
Home-page: https://github.com/monsdio/es-tool
Author: hezhe
Author-email: hezhe <he3107zhe@qq.com>
License: MIT
Project-URL: Homepage, https://github.com/monsdio/es-tool
Project-URL: Bug Reports, https://github.com/monsdio/es-tool/issues
Keywords: estool,sdk
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: websockets~=15.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: black; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: requires-python

# ESTOOL-SDK 工具使用说明文档

## 概述

用于与设备进行通信并执行各种操作。演示了如何使用SDK连接到服务器，并调用各类API接口控制硬件设备。

## 初始化和连接
pip install estool-sdk
```python
from estool.EsApiSdk import EsApiSdk
# 创建SDK实例
sdk = EsApiSdk(ip="127.0.0.1")

# 连接到服务器
is_connect = sdk.connect()
```

- 使用 [EsApiSdk]() 类创建一个SDK实例，指定目标IP地址
- 调用 [connect()]() 方法建立与服务器的连接
- 如果连接失败，则输出错误信息并退出程序

## 主要功能模块

### 串口管理

- [get_serialport()]() - 获取可用串口列表
- [connect_serialport(serialport, dwBaudRate)]() - 连接指定串口
- [disconnect_serialport()](.py#L267-L271) - 断开当前串口连接

### 系统控制

- [emergency()](.py#L140-L144) - 发送紧急中断指令
- [do_start()](.py#L146-L150) - 启动系统运行
- [do_stop()](.py#L152-L156) - 停止系统运行

### 通道管理

- [get_channels()]() - 获取通道列表信息
- [enable_channel(channel_no)]() - 开启指定编号的通道
- [disable_channel(channel_no)]() - 关闭指定编号的通道

### 分组管理

- [save_group(group_no, group_name, channels)]() - 创建新的通道分组
- [delete_group(group_no)]() - 删除指定分组
- [get_group_list()]() - 获取所有分组信息

### 参数设置

- [set_all_channel_param(frequency, pulseWidth, currentAmplitude, pulsesPerGroup, gap)]() - 设置所有通道参数
- [set_group_channel_param(group_no, frequency, pulseWidth, currentAmplitude, pulsesPerGroup, gap)]() - 设置指定分组的通道参数
- [set_channel_param(channel_no, frequency, pulseWidth, currentAmplitude, pulsesPerGroup, gap)]() - 设置单个通道参数

### 电流设置

- [set_all_channel_current(currentAmplitude)]() - 设置所有通道电流
- [set_group_channel_current(group_no, currentAmplitude)]() - 设置指定分组的通道电流
- [set_channel_current(channel_no, currentAmplitude)]() - 设置单个通道电流

### 数据获取

- [get_system_staus()]() - 获取系统状态信息
- [get_real_current()]() - 获取实时电流数据
- [get_alert_info()]() - 获取报警信息
- [get_real_channel_param()]() - 获取实时通道参数
- [send_command(command)]() - 发送自定义命令（透传）

## 事件监听机制

通过添加通知处理器来接收来自设备的实时消息：

```python
def notification_handler(message_type: str, data: Dict):
    print(f"Received notification - Type: {message_type}, Data: {data}")


# 注册不同类型的通知监听器
sdk.add_notification_handler(EsMsgType.SYSTEM_STATUS, notification_handler)
```

支持的消息类型包括：

- [EsMsgType.SYSTEM_STATUS](.py#L20-L20) - 系统状态更新
- [EsMsgType.ALERT_LISTENER](.py#L21-L21) - 报警信息
- [EsMsgType.REAL_CURRENT](.py#L22-L22) - 实时电流数据
- [EsMsgType.CHANNEL_PARAMS](.py#L23-L23) - 通道参数变化

## 注意事项

1. 在执行任何操作前必须先成功建立连接
2. 所有操作返回结果应检查是否成功执行
3. 可以根据实际需求取消注释相应的测试代码段进行调试
4. 测试完成后会自动断开连接
5. 日志级别已配置为INFO，可根据需要调整详细程度

> 提示：可以通过修改IP地址和其他参数适配不同的硬件环境。
