添加装置重启功能和控制位写入功能
This commit is contained in:
506
mms/mmsclient.c
506
mms/mmsclient.c
@@ -80,6 +80,9 @@
|
||||
|
||||
#include <ctype.h> //lnk20241119
|
||||
#include "../cfg_parse/custom_printf.h"//lnk20250225
|
||||
|
||||
#include "../log4cplus/log4.h"
|
||||
|
||||
extern uint32_t g_node_id;
|
||||
extern char subdir[128];
|
||||
unsigned int g_no_auth = 0;
|
||||
@@ -132,6 +135,8 @@ IDENT_RESP_INFO identify_response_info =
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
extern pt61850app_t *g_pt61850app;
|
||||
|
||||
extern TP0_CONN *tp0_conn_arr; /* ptr to array of "max_num_conns" structs */
|
||||
|
||||
static ST_VOID disc_ind_fun (MVL_NET_INFO *cc, ST_INT discType);
|
||||
@@ -269,12 +274,25 @@ MY_CONTROL_INFO my_control_info;
|
||||
ST_INT mms_var_type_id_create (MVL_NET_INFO *clientNetInfo, ST_INT scope,
|
||||
ST_CHAR *dom_name, ST_CHAR *var_name, int iTimeOut)
|
||||
{
|
||||
MVL_REQ_PEND *reqCtrl;
|
||||
//MVL_REQ_PEND *reqCtrl;
|
||||
//reqCtrl 必须初始化为 NULL,防止 mvla_getvar 失败后释放野指针
|
||||
MVL_REQ_PEND *reqCtrl = NULL;
|
||||
|
||||
GETVAR_REQ_INFO getvar_req;
|
||||
ST_INT type_id = -1; /* start with invalid type id */
|
||||
ST_RET ret;
|
||||
|
||||
//参数合法性检查
|
||||
if (clientNetInfo == NULL || dom_name == NULL || var_name == NULL)
|
||||
{
|
||||
printf("[GETVAR] invalid arg netInfo=%p dom=%p var=%p\n",
|
||||
clientNetInfo, dom_name, var_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//结构体清零,避免未初始化字段导致异常
|
||||
memset(&getvar_req, 0, sizeof(getvar_req));
|
||||
|
||||
/* Get the type of this "Oper" attribute & create type. */
|
||||
/* Would be more efficient to do this just once before this function.*/
|
||||
getvar_req.req_tag = GETVAR_NAME;
|
||||
@@ -283,19 +301,53 @@ ST_RET ret;
|
||||
if (scope == DOM_SPEC)
|
||||
getvar_req.name.domain_id= dom_name;
|
||||
getvar_req.name.obj_name.vmd_spec = var_name;
|
||||
|
||||
//增加调试打印,确认崩溃点
|
||||
printf("[GETVAR] start dom=%s var=%s\n", dom_name, var_name);
|
||||
|
||||
ret = mvla_getvar (clientNetInfo, &getvar_req, &reqCtrl);
|
||||
if (ret == SD_SUCCESS)
|
||||
|
||||
//打印 mvla_getvar 返回值和 reqCtrl
|
||||
printf("[GETVAR] mvla_getvar ret=0x%X reqCtrl=%p\n", ret, reqCtrl);
|
||||
|
||||
if (ret == SD_SUCCESS){
|
||||
ret = waitReqDone (reqCtrl, iTimeOut);
|
||||
if (ret != SD_SUCCESS)
|
||||
//打印 waitReqDone 返回值
|
||||
printf("[GETVAR] wait ret=0x%X\n", ret);
|
||||
}
|
||||
|
||||
if (ret != SD_SUCCESS){
|
||||
echo_warn2 ("Error getting type of variable '%s' in domain '%s'\n", var_name, dom_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Don't care about name so pass NULL. */
|
||||
type_id = mvl_type_id_create (NULL, reqCtrl->u.getvar.resp_info->type_spec.data,
|
||||
reqCtrl->u.getvar.resp_info->type_spec.len);
|
||||
//type_id = mvl_type_id_create (NULL, reqCtrl->u.getvar.resp_info->type_spec.data,
|
||||
// reqCtrl->u.getvar.resp_info->type_spec.len);
|
||||
//严格检查 resp_info/type_spec,避免空指针崩溃
|
||||
if (ret == SD_SUCCESS &&
|
||||
reqCtrl != NULL &&
|
||||
reqCtrl->u.getvar.resp_info != NULL &&
|
||||
reqCtrl->u.getvar.resp_info->type_spec.data != NULL &&
|
||||
reqCtrl->u.getvar.resp_info->type_spec.len > 0)
|
||||
{
|
||||
type_id = mvl_type_id_create(
|
||||
NULL,
|
||||
reqCtrl->u.getvar.resp_info->type_spec.data,
|
||||
reqCtrl->u.getvar.resp_info->type_spec.len);
|
||||
|
||||
printf("[GETVAR] create type_id=%d len=%d\n",
|
||||
type_id,
|
||||
reqCtrl->u.getvar.resp_info->type_spec.len);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("[GETVAR] failed dom=%s var=%s ret=0x%X\n",
|
||||
dom_name, var_name, ret);
|
||||
}
|
||||
}
|
||||
mvl_free_req_ctrl (reqCtrl); /* Done with request struct */
|
||||
//只有 reqCtrl 非空才释放
|
||||
if (reqCtrl != NULL)mvl_free_req_ctrl (reqCtrl); /* Done with request struct */
|
||||
return (type_id);
|
||||
}
|
||||
|
||||
@@ -1683,20 +1735,20 @@ static ST_VOID *my_realloc_err (ST_VOID *old, ST_UINT size)
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//#define MAX_FILE_HANDLE_NUM (256)
|
||||
//static FILE *fp_arr[MAX_FILE_HANDLE_NUM];
|
||||
//static ST_INT32 cur_handle = 0;
|
||||
//ST_INT32 set_file_pointer( FILE *fp)
|
||||
//{
|
||||
// ST_INT32 the_handle = cur_handle;
|
||||
// fp_arr[cur_handle++] = fp;
|
||||
// cur_handle %= MAX_FILE_HANDLE_NUM;
|
||||
// return the_handle;
|
||||
//}
|
||||
//FILE* get_file_pointer(ST_INT32 handle)
|
||||
//{
|
||||
// return fp_arr[handle];
|
||||
//}
|
||||
#define MAX_FILE_HANDLE_NUM (256)
|
||||
static FILE *fp_arr[MAX_FILE_HANDLE_NUM];
|
||||
static ST_INT32 cur_handle = 0;
|
||||
ST_INT32 set_file_pointer( FILE *fp)
|
||||
{
|
||||
ST_INT32 the_handle = cur_handle;
|
||||
fp_arr[cur_handle++] = fp;
|
||||
cur_handle %= MAX_FILE_HANDLE_NUM;
|
||||
return the_handle;
|
||||
}
|
||||
FILE* get_file_pointer(ST_INT32 handle)
|
||||
{
|
||||
return fp_arr[handle];
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if (MMS_FOPEN_EN & RESP_EN)
|
||||
@@ -1705,39 +1757,39 @@ static ST_VOID *my_realloc_err (ST_VOID *old, ST_UINT size)
|
||||
/************************************************************************/
|
||||
ST_VOID u_mvl_fopen_ind (MVL_IND_PEND *indCtrl)
|
||||
{
|
||||
//FILE *fp;
|
||||
//FOPEN_RESP_INFO resp_info;
|
||||
//struct stat stat_buf;
|
||||
FILE *fp;
|
||||
FOPEN_RESP_INFO resp_info;
|
||||
struct stat stat_buf;
|
||||
|
||||
//fp = fopen (indCtrl->u.fopen.filename, "rb"); /* CRITICAL: use "b" flag for binary transfer*/
|
||||
//if (fp == NULL)
|
||||
// {
|
||||
// _mplas_err_resp (indCtrl,11,6); /* File-access denied */
|
||||
// return;
|
||||
// }
|
||||
//if (fseek (fp, indCtrl->u.fopen.init_pos, SEEK_SET))
|
||||
// {
|
||||
// _mplas_err_resp (indCtrl,11,5); /* Position invalid */
|
||||
// return;
|
||||
// }
|
||||
fp = fopen (indCtrl->u.fopen.filename, "rb"); /* CRITICAL: use "b" flag for binary transfer*/
|
||||
if (fp == NULL)
|
||||
{
|
||||
_mplas_err_resp (indCtrl,11,6); /* File-access denied */
|
||||
return;
|
||||
}
|
||||
if (fseek (fp, indCtrl->u.fopen.init_pos, SEEK_SET))
|
||||
{
|
||||
_mplas_err_resp (indCtrl,11,5); /* Position invalid */
|
||||
return;
|
||||
}
|
||||
|
||||
///* WARNING: this only works if (FILE *) is a 32-bit pointer. */
|
||||
//resp_info.frsmid = set_file_pointer(fp); //(ST_INT32) fp;
|
||||
/* WARNING: this only works if (FILE *) is a 32-bit pointer. */
|
||||
resp_info.frsmid = set_file_pointer(fp); //(ST_INT32) fp;
|
||||
|
||||
//if (fstat (fileno (fp), &stat_buf))
|
||||
// { /* Can't get file size or time */
|
||||
// _mplas_err_resp (indCtrl,11,0); /* File Problem, Other */
|
||||
// return;
|
||||
// }
|
||||
//else
|
||||
// {
|
||||
// resp_info.ent.fsize = stat_buf.st_size;
|
||||
// resp_info.ent.mtimpres = SD_TRUE;
|
||||
// resp_info.ent.mtime = stat_buf.st_mtime;
|
||||
// }
|
||||
if (fstat (fileno (fp), &stat_buf))
|
||||
{ /* Can't get file size or time */
|
||||
_mplas_err_resp (indCtrl,11,0); /* File Problem, Other */
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
resp_info.ent.fsize = stat_buf.st_size;
|
||||
resp_info.ent.mtimpres = SD_TRUE;
|
||||
resp_info.ent.mtime = stat_buf.st_mtime;
|
||||
}
|
||||
|
||||
//indCtrl->u.fopen.resp_info = &resp_info;
|
||||
//mplas_fopen_resp (indCtrl);
|
||||
indCtrl->u.fopen.resp_info = &resp_info;
|
||||
mplas_fopen_resp (indCtrl);
|
||||
}
|
||||
#endif /* MMS_FOPEN_EN & RESP_EN */
|
||||
|
||||
@@ -1748,31 +1800,31 @@ ST_VOID u_mvl_fopen_ind (MVL_IND_PEND *indCtrl)
|
||||
/************************************************************************/
|
||||
ST_VOID u_mvl_fread_ind (MVL_IND_PEND *indCtrl)
|
||||
{
|
||||
//FILE *fp;
|
||||
//ST_UCHAR *tmp_buf;
|
||||
//MVLAS_FREAD_CTRL *fread_ctrl = &indCtrl->u.fread;
|
||||
//FREAD_RESP_INFO resp_info;
|
||||
FILE *fp;
|
||||
ST_UCHAR *tmp_buf;
|
||||
MVLAS_FREAD_CTRL *fread_ctrl = &indCtrl->u.fread;
|
||||
FREAD_RESP_INFO resp_info;
|
||||
|
||||
//fp = get_file_pointer(fread_ctrl->req_info->frsmid);// (FILE *) fread_ctrl->req_info->frsmid;
|
||||
///* Do NOT read more than "max_size". */
|
||||
//tmp_buf = (ST_UCHAR *) chk_malloc (fread_ctrl->max_size);
|
||||
fp = get_file_pointer(fread_ctrl->req_info->frsmid);// (FILE *) fread_ctrl->req_info->frsmid;
|
||||
/* Do NOT read more than "max_size". */
|
||||
tmp_buf = (ST_UCHAR *) chk_malloc (fread_ctrl->max_size);
|
||||
|
||||
//resp_info.fd_len = fread (tmp_buf, 1, fread_ctrl->max_size, fp);
|
||||
//if (resp_info.fd_len == 0 && ferror (fp))
|
||||
// {
|
||||
// _mplas_err_resp (indCtrl, 3, 0);
|
||||
// return;
|
||||
// }
|
||||
resp_info.fd_len = fread (tmp_buf, 1, fread_ctrl->max_size, fp);
|
||||
if (resp_info.fd_len == 0 && ferror (fp))
|
||||
{
|
||||
_mplas_err_resp (indCtrl, 3, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
//resp_info.filedata = tmp_buf;
|
||||
//if (resp_info.fd_len == fread_ctrl->max_size)
|
||||
// resp_info.more_follows = SD_TRUE;
|
||||
//else
|
||||
// resp_info.more_follows = SD_FALSE;
|
||||
resp_info.filedata = tmp_buf;
|
||||
if (resp_info.fd_len == fread_ctrl->max_size)
|
||||
resp_info.more_follows = SD_TRUE;
|
||||
else
|
||||
resp_info.more_follows = SD_FALSE;
|
||||
|
||||
//fread_ctrl->resp_info = &resp_info;
|
||||
//mplas_fread_resp (indCtrl);
|
||||
//chk_free (tmp_buf); /* Temporary buffer */
|
||||
fread_ctrl->resp_info = &resp_info;
|
||||
mplas_fread_resp (indCtrl);
|
||||
chk_free (tmp_buf); /* Temporary buffer */
|
||||
}
|
||||
#endif /* #if (MMS_FREAD_EN & RESP_EN) */
|
||||
|
||||
@@ -1782,15 +1834,15 @@ ST_VOID u_mvl_fread_ind (MVL_IND_PEND *indCtrl)
|
||||
/************************************************************************/
|
||||
ST_VOID u_mvl_fclose_ind (MVL_IND_PEND *indCtrl)
|
||||
{
|
||||
//FILE *fp;
|
||||
//MVLAS_FCLOSE_CTRL *fclose_ctrl = &indCtrl->u.fclose;
|
||||
FILE *fp;
|
||||
MVLAS_FCLOSE_CTRL *fclose_ctrl = &indCtrl->u.fclose;
|
||||
|
||||
//fp = get_file_pointer(fclose_ctrl->req_info->frsmid);//(FILE *) fclose_ctrl->req_info->frsmid;
|
||||
fp = get_file_pointer(fclose_ctrl->req_info->frsmid);//(FILE *) fclose_ctrl->req_info->frsmid;
|
||||
|
||||
//if (fclose (fp))
|
||||
// _mplas_err_resp (indCtrl, 11, 0); /* File problem, other */
|
||||
//else
|
||||
// mplas_fclose_resp (indCtrl);
|
||||
if (fclose (fp))
|
||||
_mplas_err_resp (indCtrl, 11, 0); /* File problem, other */
|
||||
else
|
||||
mplas_fclose_resp (indCtrl);
|
||||
}
|
||||
#endif /* #if (MMS_FCLOSE_EN & RESP_EN) */
|
||||
|
||||
@@ -1946,44 +1998,294 @@ MVL_REQ_PEND *reqCtrl;
|
||||
}
|
||||
|
||||
//lnk20260508添加重启装置函数
|
||||
ST_RET write_ledrs_oper(MVL_NET_INFO* netInfo,//netInfo:客户端和 MMS 服务器之间的网络连接信息
|
||||
ST_CHAR* domName, //域名 iedname+0
|
||||
ST_INT oper_type_id, //数据类型 这里是boolean
|
||||
ST_INT timeOut) //响应时长
|
||||
int BuildResetDomName(ied_usr_t *ied_usr, char *domName, size_t domNameSize)
|
||||
{
|
||||
if (ied_usr == NULL || domName == NULL || domNameSize == 0)
|
||||
return -1;
|
||||
|
||||
domName[0] = '\0';
|
||||
|
||||
XmlConfigC cfg1;
|
||||
memset(&cfg1, 0, sizeof(cfg1));
|
||||
|
||||
if (get_xml_config_by_dev_type(ied_usr->dev_type, &cfg1))
|
||||
{
|
||||
printf("========== XmlConfigC dump ==========\n");
|
||||
printf("IEDControl = '%s'\n", cfg1.IEDControl);
|
||||
printf("IEDname = '%s'\n", cfg1.IEDname);
|
||||
printf("LDevicePrefix = '%s'\n", cfg1.LDevicePrefix);
|
||||
printf("=====================================\n");
|
||||
|
||||
if (cfg1.IEDControl[0] != '\0')
|
||||
{
|
||||
snprintf(domName, domNameSize, "%s", cfg1.IEDControl);
|
||||
printf("[RESET] use cfg1.IEDControl=%s\n", domName);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ied_usr->LD_info && ied_usr->LD_info[0].LD_name)
|
||||
{
|
||||
snprintf(domName, domNameSize, "%s", ied_usr->LD_info[0].LD_name);
|
||||
|
||||
int len = strlen(domName);
|
||||
if (len > 0 && isdigit(domName[len - 1]))
|
||||
domName[len - 1] = '0';
|
||||
|
||||
printf("[RESET] use LD_name domName=%s\n", domName);
|
||||
|
||||
DIY_WARNLOG_CODE(ied_usr->terminal_id, 1, LOG_CODE_FILE_CONTROL,
|
||||
"【WARN】未取到 IEDControl 信息,使用 LD_name=%s terminal_id=%s",
|
||||
domName, ied_usr->terminal_id);
|
||||
|
||||
return -2;
|
||||
}
|
||||
|
||||
snprintf(domName, domNameSize, "%s", "PQMonitorPQM0");
|
||||
printf("[RESET] use default domName=%s\n", domName);
|
||||
DIY_ERRORLOG_CODE(ied_usr->terminal_id, 1, LOG_CODE_FILE_CONTROL,
|
||||
"【ERROR】未取到 LD 信息,使用默认 domName=%s terminal_id=%s",
|
||||
domName, ied_usr->terminal_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static ST_INT ledrs_var_type_create(MVL_NET_INFO* net_info,
|
||||
OBJECT_NAME* varObj,
|
||||
ST_INT timeOut)
|
||||
{
|
||||
MVL_REQ_PEND* reqCtrl;
|
||||
GETVAR_REQ_INFO getvar_req;
|
||||
VAR_ACC_TSPEC* type_spec;
|
||||
ST_INT type_id = -1;
|
||||
ST_RET ret;
|
||||
|
||||
memset(&getvar_req, 0, sizeof(getvar_req));
|
||||
|
||||
getvar_req.req_tag = GETVAR_NAME;
|
||||
getvar_req.name = *varObj;
|
||||
|
||||
ret = mvla_getvar(net_info, &getvar_req, &reqCtrl);
|
||||
|
||||
if (ret == SD_SUCCESS)
|
||||
ret = waitReqDone(reqCtrl, timeOut);
|
||||
|
||||
if (ret == SD_SUCCESS)
|
||||
{
|
||||
type_spec = &reqCtrl->u.getvar.resp_info->type_spec;
|
||||
|
||||
type_id = mvl_type_id_create(NULL,
|
||||
type_spec->data,
|
||||
type_spec->len);
|
||||
}
|
||||
|
||||
if (reqCtrl)
|
||||
mvl_free_req_ctrl(reqCtrl);
|
||||
|
||||
return type_id;
|
||||
}
|
||||
static ST_INT create_oper_type_id(MVL_NET_INFO *net_info,
|
||||
ST_CHAR *domName,
|
||||
const char *ctlName,
|
||||
ST_INT timeOut)
|
||||
{
|
||||
OBJECT_NAME obj;
|
||||
ST_CHAR varName[MAX_IDENT_LEN + 1];
|
||||
|
||||
LEDRs_Oper_t oper;
|
||||
memset(&oper, 0, sizeof(oper));
|
||||
if (net_info == NULL || domName == NULL || ctlName == NULL)
|
||||
return -1;
|
||||
|
||||
oper.ctlVal = SD_TRUE; //618050抓包显示为true
|
||||
|
||||
oper.origin.orCat = 3; //61850抓包显示为3
|
||||
oper.origin.orIdent[0] = '\0'; //618050抓包显示为missing
|
||||
|
||||
oper.ctlNum = 1; //618050抓包显示为1
|
||||
|
||||
u_get_current_utc_time(&oper.T);//618050抓包显示为当前时间
|
||||
|
||||
oper.Test = SD_FALSE; //618050抓包显示为false
|
||||
oper.Check[0] = 0x00; //618050抓包显示为bitstring 00
|
||||
memset(&obj, 0, sizeof(obj));
|
||||
|
||||
apr_snprintf(varName,
|
||||
sizeof(varName),
|
||||
"LLN0$CO$LEDRs$Oper"); //61850抓包显示为LLN0$CO$LEDRs$Oper
|
||||
"LLN0$%s",
|
||||
ctlName);
|
||||
|
||||
ret = mms_named_var_write(netInfo,
|
||||
varName, //itemid
|
||||
DOM_SPEC, //统一使用DOM_SPEC作为域名标识符
|
||||
domName,
|
||||
oper_type_id,
|
||||
(ST_CHAR*)&oper, //数据源 这里是封装好的LEDRs_Oper_t结构体
|
||||
timeOut);
|
||||
obj.object_tag = DOM_SPEC;
|
||||
obj.domain_id = domName;
|
||||
obj.obj_name.vmd_spec = varName;
|
||||
|
||||
printf("[CTRL_INIT] create type dom=%s var=%s\n",
|
||||
domName, varName);
|
||||
|
||||
return ledrs_var_type_create(net_info, &obj, timeOut);
|
||||
}
|
||||
void InitLedrsOperTypeForChannel(chnl_usr_t *chnl_usr)
|
||||
{
|
||||
printf("[CTRL_INIT] enter\n");
|
||||
|
||||
if (chnl_usr == NULL || chnl_usr->chnl == NULL ||
|
||||
chnl_usr->chnl->ied == NULL || chnl_usr->net_info == NULL)
|
||||
{
|
||||
printf("[CTRL_INIT] invalid chnl_usr\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ied_t *ied = chnl_usr->chnl->ied;
|
||||
ied_usr_t *ied_usr = GET_IEDEXT_ADDR(ied);
|
||||
|
||||
if (ied_usr == NULL || ied_usr->LD_info == NULL)
|
||||
{
|
||||
printf("[CTRL_INIT] invalid ied_usr or LD_info\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("[CTRL_INIT] current inited=%d ledrs=%d reboot=%d reset=%d\n",
|
||||
(int)ied_usr->oper_type_cache.inited,
|
||||
ied_usr->oper_type_cache.ledrs_oper_type_id,
|
||||
ied_usr->oper_type_cache.reboot_oper_type_id,
|
||||
ied_usr->oper_type_cache.reset_oper_type_id);
|
||||
|
||||
if (ied_usr->oper_type_cache.inited == SD_TRUE)
|
||||
{
|
||||
printf("[CTRL_INIT] already inited\n");
|
||||
return;
|
||||
}
|
||||
|
||||
char domName[256] = {0};
|
||||
|
||||
BuildResetDomName(ied_usr,
|
||||
domName,
|
||||
sizeof(domName));
|
||||
|
||||
printf("[CTRL_INIT] final dom=%s\n", domName);
|
||||
|
||||
ied_usr->oper_type_cache.ledrs_oper_type_id =
|
||||
create_oper_type_id(chnl_usr->net_info,
|
||||
domName,
|
||||
"CO$LEDRs$Oper",
|
||||
g_pt61850app->mmsOpTimeout);
|
||||
|
||||
printf("[CTRL_INIT] LEDRs type_id=%d\n",
|
||||
ied_usr->oper_type_cache.ledrs_oper_type_id);
|
||||
|
||||
ied_usr->oper_type_cache.reboot_oper_type_id =
|
||||
create_oper_type_id(chnl_usr->net_info,
|
||||
domName,
|
||||
"CO$Reboot$Oper",
|
||||
g_pt61850app->mmsOpTimeout);
|
||||
|
||||
printf("[CTRL_INIT] Reboot type_id=%d\n",
|
||||
ied_usr->oper_type_cache.reboot_oper_type_id);
|
||||
|
||||
ied_usr->oper_type_cache.reset_oper_type_id =
|
||||
create_oper_type_id(chnl_usr->net_info,
|
||||
domName,
|
||||
"ST$Mod$stVal",
|
||||
g_pt61850app->mmsOpTimeout);
|
||||
|
||||
printf("[CTRL_INIT] Reset type_id=%d\n",
|
||||
ied_usr->oper_type_cache.reset_oper_type_id);
|
||||
|
||||
/* 无论成功失败,都不再重复初始化 */
|
||||
ied_usr->oper_type_cache.inited = SD_TRUE;
|
||||
|
||||
printf("[CTRL_INIT] finish inited=%d\n",
|
||||
(int)ied_usr->oper_type_cache.inited);
|
||||
}
|
||||
|
||||
|
||||
ST_RET write_common_oper(chnl_usr_t *chnl_usr,
|
||||
ST_CHAR *domName,
|
||||
const char *ctlName,
|
||||
ST_INT oper_type_id,
|
||||
ST_INT timeOut)
|
||||
{
|
||||
if (chnl_usr == NULL ||
|
||||
chnl_usr->net_info == NULL ||
|
||||
domName == NULL ||
|
||||
ctlName == NULL ||
|
||||
oper_type_id < 0)
|
||||
{
|
||||
printf("[OPER_WRITE] invalid param\n");
|
||||
return SD_FAILURE;
|
||||
}
|
||||
|
||||
ST_CHAR varName[MAX_IDENT_LEN + 1];
|
||||
apr_snprintf(varName,
|
||||
sizeof(varName),
|
||||
"LLN0$%s",
|
||||
ctlName);
|
||||
|
||||
Control_Oper_t oper;
|
||||
memset(&oper, 0, sizeof(oper));
|
||||
|
||||
oper.ctlVal = SD_TRUE;
|
||||
oper.origin.orCat = 3;
|
||||
oper.origin.orIdent.len = 0;
|
||||
oper.ctlNum = 1;
|
||||
u_get_current_utc_time(&oper.T);
|
||||
oper.Test = SD_FALSE;
|
||||
oper.Check[0] = 0x00;
|
||||
oper.Check[1] = 0x00;
|
||||
|
||||
if ((int)sizeof(Control_Oper_t) !=
|
||||
mvl_type_ctrl[oper_type_id].data_size)
|
||||
{
|
||||
printf("[OPER_WRITE] SIZE MISMATCH ctl=%s local=%d runtime=%d\n",
|
||||
ctlName,
|
||||
(int)sizeof(Control_Oper_t),
|
||||
mvl_type_ctrl[oper_type_id].data_size);
|
||||
return SD_FAILURE;
|
||||
}
|
||||
|
||||
printf("[OPER_WRITE] dom=%s var=%s type_id=%d\n",
|
||||
domName, varName, oper_type_id);
|
||||
|
||||
return mms_named_var_write(chnl_usr->net_info,
|
||||
varName,
|
||||
DOM_SPEC,
|
||||
domName,
|
||||
oper_type_id,
|
||||
(ST_CHAR *)&oper,
|
||||
timeOut);
|
||||
}
|
||||
|
||||
ST_RET mms_conclude_disconnect(MVL_NET_INFO *net_info, ST_INT timeOut)
|
||||
{
|
||||
MVL_REQ_PEND *reqCtrl = NULL;
|
||||
ST_RET ret;
|
||||
|
||||
if (net_info == NULL)
|
||||
return SD_FAILURE;
|
||||
|
||||
printf("[RESET] before mvl_concl\n");
|
||||
|
||||
ret = mvl_concl(net_info, &reqCtrl);
|
||||
|
||||
printf("[RESET] after mvl_concl ret=0x%X reqCtrl=%p\n",
|
||||
ret, reqCtrl);
|
||||
|
||||
if (ret == SD_SUCCESS && reqCtrl != NULL)
|
||||
{
|
||||
ret = waitReqDone(reqCtrl, timeOut);
|
||||
|
||||
printf("[RESET] conclude wait ret=0x%X\n", ret);
|
||||
}
|
||||
|
||||
if (reqCtrl != NULL)
|
||||
mvl_free_req_ctrl(reqCtrl);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ST_RET write_mod_stval(chnl_usr_t *chnl_usr,
|
||||
ST_CHAR *domName,
|
||||
ST_INT timeOut)
|
||||
{
|
||||
ST_CHAR varName[MAX_IDENT_LEN + 1];
|
||||
ST_INT16 value = 88;
|
||||
|
||||
apr_snprintf(varName, sizeof(varName), "LLN0$ST$Mod$stVal");
|
||||
|
||||
return mms_named_var_write(chnl_usr->net_info,
|
||||
varName,
|
||||
DOM_SPEC,
|
||||
domName,
|
||||
14, //int
|
||||
(ST_CHAR *)&value,
|
||||
timeOut);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* init_log_cfg */
|
||||
|
||||
Reference in New Issue
Block a user