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.
174 lines
4.3 KiB
C++
174 lines
4.3 KiB
C++
/***********************************************
|
|
此文件功能为业务处理模块功能,实现这些通用接口,可以把本模块以插件的形式配置到平台中
|
|
|
|
*********************************************/
|
|
#include "dev.h"
|
|
#include "motor.h"
|
|
#include "manage.h"
|
|
#include "script.h"
|
|
#include "corework.h"
|
|
|
|
bool g_bInit = false;
|
|
|
|
#pragma comment(lib, "var.lib")
|
|
#pragma comment(lib, "skt.lib")
|
|
#pragma comment(lib, "ops.lib")
|
|
#pragma comment(lib, "log.lib")
|
|
#pragma comment(lib, "user.lib")
|
|
#pragma comment(lib, "config.lib")
|
|
#pragma comment(lib, "sysapi.lib")
|
|
#pragma comment(lib, "script.lib")
|
|
#pragma comment(lib, "control.lib")
|
|
|
|
int WINAPI Funwlog(pstack p, pjres r, char* err, int btest)
|
|
{
|
|
int ret = 0;
|
|
int ecode = 0;
|
|
char keyword[MAX_BUF_LEN] = { 0 };
|
|
char errmsg[MAX_BUF_LEN] = { 0 };
|
|
|
|
ret = script_calculate3(&p, r, err);
|
|
if (ret || !p)
|
|
{//参数错误或不够
|
|
if (err) strcpy(err, "wlog(keyword,err,errmsg,msg) 入参错误.");
|
|
return ERR_FORMAT_MSG;
|
|
}
|
|
comm_strncpy(keyword, r->gets(), MAX_BUF_LEN);
|
|
|
|
ret = script_calculate3(&p, r, err);
|
|
if (ret || !p)
|
|
{//参数错误或不够
|
|
if (err) strcpy(err, "wlog(keyword,err,errmsg,msg) 入参错误.");
|
|
return ERR_FORMAT_MSG;
|
|
}
|
|
|
|
if (EMSTR_INT != r->type())
|
|
{//必须为整数
|
|
if (err) strcpy(err, "wlog(keyword,err,errmsg,msg) 入参err必须为整数");
|
|
return ERR_FORMAT_MSG;
|
|
}
|
|
ecode = r->geti();
|
|
|
|
ret = script_calculate3(&p, r, err);
|
|
if (ret || !p)
|
|
{//参数错误或不够
|
|
if (err) strcpy(err, "wlog(keyword,err,errmsg,msg) 入参错误.");
|
|
return ERR_FORMAT_MSG;
|
|
}
|
|
comm_strncpy(errmsg, r->gets(), MAX_BUF_LEN);
|
|
|
|
ret = script_calculate3(&p, r, err);
|
|
if (ret || p)
|
|
{//参数错误
|
|
if (err) strcpy(err, "wlog(keyword,err,errmsg,msg) 入参错误.");
|
|
return ERR_FORMAT_MSG;
|
|
}
|
|
|
|
RETURN_CHK_NOPRT(!btest, 0); //is test
|
|
|
|
return wlog(keyword, ecode, errmsg, r->gets());
|
|
}
|
|
|
|
int WINAPI FunwVlog(pstack p, pjres r, char* err, int btest)
|
|
{
|
|
int ret = 0;
|
|
char node[MAX_BUF_LEN] = { 0 };
|
|
|
|
ret = script_calculate3(&p, r, err);
|
|
if (ret || !p)
|
|
{//参数错误或不够
|
|
if (err) strcpy(err, "vlog(node,msg) 入参错误.");
|
|
return ERR_FORMAT_MSG;
|
|
}
|
|
comm_strncpy(node, r->gets(), MAX_BUF_LEN);
|
|
|
|
ret = script_calculate3(&p, r, err);
|
|
if (ret || p)
|
|
{//参数错误
|
|
if (err) strcpy(err, "vlog(node,msg) 入参错误.");
|
|
return ERR_FORMAT_MSG;
|
|
}
|
|
|
|
RETURN_CHK_NOPRT(!btest, 0); //is test
|
|
|
|
return vlog(node, r->gets());
|
|
}
|
|
|
|
static const char* g_errDesc[] = {
|
|
"该位置无产品.",
|
|
"该位置已经有产品存在.",
|
|
};
|
|
|
|
/***********************************************
|
|
*Function: 获取插件信息描述
|
|
*Intput: pDev 插件信息结构体
|
|
*Output: pDev 插件信息缓冲区
|
|
*Return: 参考EM_ERR_CODE
|
|
*********************************************/
|
|
EXPORT_C int WINAPI get_dev_info(TDevInfo* pDev)
|
|
{
|
|
RETURN_CHK_NOPRT(pDev, ERR_INPUT_PARAM);
|
|
|
|
memset(pDev, 0, sizeof(TDevInfo));
|
|
strcpy(pDev->id, "corework");
|
|
strcpy(pDev->desc, "业务处理模块");
|
|
return 0;
|
|
}
|
|
|
|
EXPORT_C void WINAPI init()
|
|
{
|
|
ZERO_CHK(!g_bInit);
|
|
|
|
g_bInit = true;
|
|
script_reg_fun("wlog", Funwlog);
|
|
script_reg_fun("vlog", FunwVlog);
|
|
for (int i = 0; i < sizeof(g_errDesc) / sizeof(char*); i++)
|
|
{
|
|
set_err_desc(i + ERR_NO_PRODUCT, g_errDesc[i]);
|
|
}
|
|
ins;
|
|
}
|
|
|
|
EXPORT_C void WINAPI deinit()
|
|
{
|
|
ZERO_CHK(g_bInit);
|
|
g_bInit = false;
|
|
CManage::ReleaseInstance();
|
|
}
|
|
|
|
EXPORT_C int WINAPI get_command_desc(char* pszcmddesc)
|
|
{
|
|
RETURN_CHK_NOPRT(g_bInit, ERR_NO_INIT);
|
|
return ins->GetCommandDesc(pszcmddesc);
|
|
}
|
|
|
|
EXPORT_C int WINAPI init_devs(ushort index, const char* ctx)
|
|
{//直接成功
|
|
if (0 == index) ins->Init();
|
|
return 0;
|
|
}
|
|
|
|
EXPORT_C int WINAPI uninit_dev(ushort index)
|
|
{//直接成功
|
|
if (0 == index) ins->Deinit();
|
|
return 0;
|
|
}
|
|
|
|
EXPORT_C int WINAPI get_status(ushort index)
|
|
{
|
|
return g_bInit ? EDev_IDLE : EDev_NOINIT;
|
|
}
|
|
|
|
EXPORT_C int WINAPI send_custom_msg(ushort index, const char* msg, char* res/* = 0*/)
|
|
{
|
|
RETURN_CHK_NOPRT(g_bInit, ERR_NO_INIT);
|
|
return ins->SendCustomCmd(msg, res);
|
|
}
|
|
|
|
EXPORT_C int WINAPI recv_custom_msg(ushort index, const char* msg, char* res, int timeout/* = 0*/)
|
|
{
|
|
//RETURN_CHK(0 == index, ERR_INPUT_PARAM);
|
|
RETURN_CHK_NOPRT(g_bInit, ERR_NO_INIT);
|
|
return ins->RecvCustomCmd(msg, res, timeout);
|
|
}
|