You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.8 KiB
C

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*********************************************************************
*文件说明: 所有插件公用头文件
*作者: logos
*日期: 2017/02/07
*修改日志: 2017/02/07 CW4945 创建
***注意事项***
1. 无论哪种类型,都必须支持公共接口
init
uninit
get_status
send_custom_msg
recv_custom_msg
2. 加载插件时会检测接口,若接口检测不通过,则插件加载会失败
3. 所有接口都必须是非阻塞实现,除非包含延时参数
4. 索引从上层调用init/initctx时会自动动态累加第一个对象为0以此类推.
***********************************************************************/
#pragma once
#ifndef _INCLUDE_DEV_API_H
#define _INCLUDE_DEV_API_H
#include "dtype.h"
/***********************************************
*Function: 初始化模块 -- 可以不支持
*Intput: NULL
*Output: NULL
*Return: NULL
*********************************************/
EXPORT_C void WINAPI init();
/***********************************************
*Function: 反初始化模块 -- 可以不支持
*Intput: NULL
*Output: NULL
*Return: NULL
*********************************************/
EXPORT_C void WINAPI deinit();
/*********************************************
*Function: 获取插件支持的自定义指令描述 -- 若没有,可以不支持此接口
*Intput: pszcmddesc 指令描述列表缓冲区
*Output: pszcmddesc 指令描述列表缓冲区
*Return: 返回字符串长度返回0表示没有自定义指令
*PS: 可以传入NULL获取字符串长度申请内存后重新获取内容
*********************************************/
EXPORT_C int WINAPI get_command_desc(char* pszcmddesc);
/***********************************************
*Function: 创建/初始化一个对象
*Intput: index 对象索引,动态累加,从0开始
param 初始化参数 最多支持PARAM_CNT个参数
*Output: NULL
*Return: 成功返回0失败返回错误码<0
*********************************************/
EXPORT_C int WINAPI init_dev(ushort index, TParam* param);
/***********************************************
*Function: 创建/初始化一个对象 -- 参数使用字符串
*Intput: index 对象索引,动态累加,从0开始
ctx 初始化参数 多个参数以;分割<256字节,最多支持PARAM_CNT个参数
*Output: NULL
*Return: 成功返回0失败返回错误码<0
*********************************************/
EXPORT_C int WINAPI init_devs(ushort index, const char* ctx);
/***********************************************
*Function: 反初始化/释放一个对象
*Intput: index 对象索引
*Output: NULL
*Return: 成功返回0失败返回错误码<0
*********************************************/
EXPORT_C int WINAPI uninit_dev(ushort index);
/***********************************************
*Function: 获取指定对象当前状态
*Intput: index 对象索引
*Output: NULL
*Return: EDevStatus or EMoveStatus
*********************************************/
EXPORT_C int WINAPI get_status(ushort index);
/*********************************************
*Function: 向指定对象发送消息(万能接口)
*Intput: index 对象索引
msg 要发送的消息
res 返回消息,可以不传
*Output: res 返回消息,可以不传
*Return: 成功返回0,失败返回错误码<0
*********************************************/
EXPORT_C int WINAPI send_custom_msg(ushort index, const char* msg, char* res/* = 0*/);
/*********************************************
*Function: 接收指定对象消息(万能接口)
*Intput: index 对象索引
msg 过滤字段及参数,可以为空字符串
res 返回消息
timeout 超时机制 单位ms
*Output: res 返回消息
*Return: 成功返回0,失败返回错误码<0
*PS: 超时返回ERR_TIMEOUT
*PS: 若有过滤机制,未接收到的消息由底层插件自行处理,或缓存下来
*********************************************/
EXPORT_C int WINAPI recv_custom_msg(ushort index, const char* msg, char* res, int timeout);
#endif //防止重复包含头文件