No project description provided
Project description
NCOS-Module
NCOS子设备基类。
通过继承该类快速构建NCOS下的子设备模块,并与NCOS进行数据交换
类
ModuleBase
| RUN
运行模块, 并开始管理主事件循环
def run(self)
返回
None
| BIND_NCOS_BROKER
绑定NCOS的主题网关
def bind_ncos_broker(self, host:str, port:int)
参数
参数 | 类型 | 说明 |
---|---|---|
host | str | 网关主机地址 |
port | int | 网关端口 |
返回
None
| ADD_TOPIC
添加模块订阅
def add_topic(self, topic:str, accessor)
参数
参数 | 类型 | 说明 |
---|---|---|
topic | str | 订阅的主题 |
accessor | func | 接收到订阅消息时的处理函数 |
返回
None
| SET_WILL
设置模块遗愿,当模块与NCOS网关断开时向NCOS发送指定内容
def set_will(self, content:str)
参数
参数 | 类型 | 说明 |
---|---|---|
content | str | 向NCOS发送的指定内容 |
返回
None
| HANDLE_CONNECT
当与MCU或其他设备建立好连接后执行本函数
@abstractmethod
def handle_connect(self)
参数
None
返回
None
| HANDLE_DISCONNECT
当与MCU或其他设备断开连接后执行本函数
@abstractmethod
def handle_disconnect(self)
参数
None
返回
None
| HANDLE_STARTUP
当模块run函数被调用时执行本函数
@abstractmethod
def handle_startup(self)
参数
None
返回
None
| HANDLE_EXIT
当模块run函数退出时执行本函数
@abstractmethod
def handle_exit(self)
参数
None
返回
None
| HANDLE_POST_INSTALL
主动向NCOS安装本模块时执行本函数
@abstractmethod
def handle_post_install(self)
参数
None
返回
None
| HANDLE_BROKER_CONNECTED
与NCOS主题网关建立连接时执行本函数
@abstractmethod
def handle_broker_connected(self, client, userdata, flags, rc)
参数
参数 | 类型 | 说明 |
---|---|---|
client | object | the client instance for this callback |
userdata | object | 用户自定义数据 |
flags | dict | response flags sent by the broker |
rc | int | the connection result |
返回
None
| HANDLE_NCOS_READY
当收到NCOS广播已准备好时执行本函数
@abstractmethod
def handle_NCOS_ready(self, data)
参数
参数 | 类型 | 说明 |
---|---|---|
data | dict | 参见NCOS_Ready |
返回
None
| HANDLE_DATA_PULL
当NCOS发起拉取数据指令执行本函数
@abstractmethod
def handle_data_pull(self, data)
参数
参数 | 类型 | 说明 |
---|---|---|
data | dict |
返回
None
| HANDLE_CONFIG
当NCOS向模块下发配置指令时执行本函数
@abstractmethod
def handle_config(self, data)
参数
参数 | 类型 | 说明 |
---|---|---|
data | dict |
返回
None
| HANDLE_ACTION
当NCOS向模块下发操作指令时执行本函数
@abstractmethod
def handle_action(self, data)
参数
参数 | 类型 | 说明 |
---|---|---|
data | dict |
返回
None
| HANDLE_INSTALLED
当收到NCOS对模块安装请求的响应时执行本函数
@abstractmethod
def handle_installed(self, result:bool, reason:str)
参数
参数 | 类型 | 说明 |
---|---|---|
result | bool | 安装结果的标识, true = 安装成功 |
reason | str | 安装失败的原因 |
返回
None
| HANDLE_UNINSTALLED
当模块主动卸载时执行本函数
@abstractmethod
def handle_uninstalled(self, reason:str)
参数
参数 | 类型 | 说明 |
---|---|---|
reason | str | 卸载原因 |
返回
None
| HANDLE_ERROR
当模块发生异常时的处理函数
@abstractmethod
def handle_error(self, error)
参数
参数 | 类型 | 说明 |
---|---|---|
error | str | 异常信息 |
返回
None
数据结构
NCOS_Ready
{
"slots": []
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyncos-module-0.0.15.tar.gz
(8.4 kB
view hashes)
Built Distribution
Close
Hashes for pyncos_module-0.0.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c436d87a868e5f88758dd7bdf31ff092d2f66c912708792a7fbcc6517c46c1fe |
|
MD5 | bb801a1c6f62395d7242050c63c33596 |
|
BLAKE2b-256 | 8dbf06a5cfaec8b974edc9cd615074e88d759102f50b1703cef63accfbbbcfad |