|
|
|
|
/***********************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>鹦<EFBFBD>ܣ<EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щͨ<EFBFBD>ýӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѱ<EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ƽ̨<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
*********************************************/
|
|
|
|
|
#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)
|
|
|
|
|
{//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (err) strcpy(err, "wlog(keyword,err,errmsg,msg) <20><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>.");
|
|
|
|
|
return ERR_FORMAT_MSG;
|
|
|
|
|
}
|
|
|
|
|
comm_strncpy(keyword, r->gets(), MAX_BUF_LEN);
|
|
|
|
|
|
|
|
|
|
ret = script_calculate3(&p, r, err);
|
|
|
|
|
if (ret || !p)
|
|
|
|
|
{//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (err) strcpy(err, "wlog(keyword,err,errmsg,msg) <20><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>.");
|
|
|
|
|
return ERR_FORMAT_MSG;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (EMSTR_INT != r->type())
|
|
|
|
|
{//<2F><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
|
|
|
|
if (err) strcpy(err, "wlog(keyword,err,errmsg,msg) <20><><EFBFBD><EFBFBD>err<72><72><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>");
|
|
|
|
|
return ERR_FORMAT_MSG;
|
|
|
|
|
}
|
|
|
|
|
ecode = r->geti();
|
|
|
|
|
|
|
|
|
|
ret = script_calculate3(&p, r, err);
|
|
|
|
|
if (ret || !p)
|
|
|
|
|
{//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (err) strcpy(err, "wlog(keyword,err,errmsg,msg) <20><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>.");
|
|
|
|
|
return ERR_FORMAT_MSG;
|
|
|
|
|
}
|
|
|
|
|
comm_strncpy(errmsg, r->gets(), MAX_BUF_LEN);
|
|
|
|
|
|
|
|
|
|
ret = script_calculate3(&p, r, err);
|
|
|
|
|
if (ret || p)
|
|
|
|
|
{//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (err) strcpy(err, "wlog(keyword,err,errmsg,msg) <20><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>.");
|
|
|
|
|
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)
|
|
|
|
|
{//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (err) strcpy(err, "vlog(node,msg) <20><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>.");
|
|
|
|
|
return ERR_FORMAT_MSG;
|
|
|
|
|
}
|
|
|
|
|
comm_strncpy(node, r->gets(), MAX_BUF_LEN);
|
|
|
|
|
|
|
|
|
|
ret = script_calculate3(&p, r, err);
|
|
|
|
|
if (ret || p)
|
|
|
|
|
{//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (err) strcpy(err, "vlog(node,msg) <20><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>.");
|
|
|
|
|
return ERR_FORMAT_MSG;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RETURN_CHK_NOPRT(!btest, 0); //is test
|
|
|
|
|
|
|
|
|
|
return vlog(node, r->gets());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char* g_errDesc[] = {
|
|
|
|
|
"<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ.",
|
|
|
|
|
"<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD>в<EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>.",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/***********************************************
|
|
|
|
|
*Function: <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*Intput: pDev <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ṹ<EFBFBD><EFBFBD>
|
|
|
|
|
*Output: pDev <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*Return: <EFBFBD>ο<EFBFBD>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, "ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>");
|
|
|
|
|
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)
|
|
|
|
|
{//ֱ<>ӳɹ<D3B3>
|
|
|
|
|
if (0 == index) ins->Init();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_C int WINAPI uninit_dev(ushort index)
|
|
|
|
|
{//ֱ<>ӳɹ<D3B3>
|
|
|
|
|
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);
|
|
|
|
|
}
|