添加文件删除和复位代码
This commit is contained in:
@@ -51,6 +51,8 @@ extern int64_t G_APP_START_MS;
|
|||||||
|
|
||||||
extern int RECALL_ONLY_FLAG; //lnk20260309添加一个全局变量,标志是否只运行补招程序
|
extern int RECALL_ONLY_FLAG; //lnk20260309添加一个全局变量,标志是否只运行补招程序
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern void SendFileWeb(const std::string& strUrl,
|
extern void SendFileWeb(const std::string& strUrl,
|
||||||
const char* localpath,
|
const char* localpath,
|
||||||
const char* cloudpath,
|
const char* cloudpath,
|
||||||
@@ -87,7 +89,16 @@ extern "C" {
|
|||||||
ST_CHAR *destfilename,
|
ST_CHAR *destfilename,
|
||||||
int iTimeout);
|
int iTimeout);
|
||||||
|
|
||||||
|
extern ST_RET mms_mvla_fdelete (MVL_NET_INFO *net_info,ST_CHAR *file_to_delete,int iTimeout);
|
||||||
|
|
||||||
|
extern 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); //响应时长
|
||||||
|
|
||||||
extern pt61850app_t *g_pt61850app;
|
extern pt61850app_t *g_pt61850app;
|
||||||
|
|
||||||
|
extern RPT_TYPEIDS g_rpt_typeids;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -2391,6 +2402,55 @@ static int HandleTypeTransferToDevice(chnl_usr_t* chnl_usr,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////删除
|
||||||
|
static int HandleDeleteFileInDevice(chnl_usr_t* chnl_usr,
|
||||||
|
file_dir_req_t* req,
|
||||||
|
std::string& jsonString)
|
||||||
|
{
|
||||||
|
if (chnl_usr == NULL || req == NULL || chnl_usr->net_info == NULL)
|
||||||
|
{
|
||||||
|
if (req)
|
||||||
|
jsonString = BuildSingleFileRespJson(req, NULL, "file", 1, -1);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req->path[0] == '\0')
|
||||||
|
{
|
||||||
|
DIY_ERRORLOG_CODE(req->devid, 1, LOG_CODE_FILE_CONTROL,
|
||||||
|
"【ERROR】删除装置文件失败,path为空 devid=%s",
|
||||||
|
req->devid);
|
||||||
|
|
||||||
|
jsonString = BuildSingleFileRespJson(req, NULL, "file", 1, -1);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ST_RET ret = mms_mvla_fdelete(chnl_usr->net_info,
|
||||||
|
(ST_CHAR*)req->path,
|
||||||
|
3 * g_pt61850app->mmsOpTimeout);
|
||||||
|
|
||||||
|
if (ret != SD_SUCCESS)
|
||||||
|
{
|
||||||
|
DIY_ERRORLOG_CODE(req->devid, 1, LOG_CODE_FILE_CONTROL,
|
||||||
|
"【ERROR】删除装置文件失败 devid=%s, path=%s, ret=0x%X",
|
||||||
|
req->devid, req->path, ret);
|
||||||
|
|
||||||
|
jsonString = BuildSingleFileRespJson(req, req->path, "file", 1, -1);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DIY_INFOLOG_CODE(req->devid, 1, LOG_CODE_FILE_CONTROL,
|
||||||
|
"【NORMAL】删除装置文件成功 devid=%s, path=%s",
|
||||||
|
req->devid, req->path);
|
||||||
|
|
||||||
|
jsonString = BuildSingleFileRespJson(req,
|
||||||
|
req->path,
|
||||||
|
"file",
|
||||||
|
1,
|
||||||
|
0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void HandleFileDirReqForChannel(chnl_usr_t *chnl_usr)
|
void HandleFileDirReqForChannel(chnl_usr_t *chnl_usr)
|
||||||
{
|
{
|
||||||
if (chnl_usr == NULL) {
|
if (chnl_usr == NULL) {
|
||||||
@@ -2476,6 +2536,60 @@ void HandleFileDirReqForChannel(chnl_usr_t *chnl_usr)
|
|||||||
/* Web 下载到本地,再传送到装置 /etc */
|
/* Web 下载到本地,再传送到装置 /etc */
|
||||||
handleRet = HandleTypeTransferToDevice(chnl_usr, req, jsonString);
|
handleRet = HandleTypeTransferToDevice(chnl_usr, req, jsonString);
|
||||||
}
|
}
|
||||||
|
else if (req->type == 3){
|
||||||
|
/* 删除文件 */
|
||||||
|
handleRet = HandleDeleteFileInDevice(chnl_usr, req, jsonString);
|
||||||
|
}
|
||||||
|
else if (req->type == 4){ //复位
|
||||||
|
char domName[256] = {0}; //构造ied+0的domName
|
||||||
|
|
||||||
|
// 取第一个 LD
|
||||||
|
if (ied_usr->LD_info &&
|
||||||
|
ied_usr->LD_info[0].LD_name)
|
||||||
|
{
|
||||||
|
snprintf(domName,
|
||||||
|
sizeof(domName),
|
||||||
|
"%s",
|
||||||
|
ied_usr->LD_info[0].LD_name);
|
||||||
|
|
||||||
|
// 把末尾数字改成0
|
||||||
|
int len = strlen(domName);
|
||||||
|
|
||||||
|
if (len > 0 && isdigit(domName[len - 1]))
|
||||||
|
{
|
||||||
|
domName[len - 1] = '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else //没取到则使用默认的domName "PQMonitorPQM0"
|
||||||
|
{
|
||||||
|
strcpy(domName, "PQMonitorPQM0");
|
||||||
|
std::cout << "use default domName=PQMonitorPQM0"
|
||||||
|
<< std::endl;
|
||||||
|
DIY_ERRORLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||||
|
"【ERROR】未取到 LD 信息,使用默认 domName=%s terminal_id=%s",
|
||||||
|
domName, req->devid);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "[CTRL] domName="
|
||||||
|
<< domName
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
handleRet = write_ledrs_oper(chnl_usr->net_info,
|
||||||
|
domName,
|
||||||
|
g_rpt_typeids.mmsbool, //数据类型,使用全局配置的mmsbool类型
|
||||||
|
g_pt61850app->mmsOpTimeout);
|
||||||
|
|
||||||
|
if(handleRet == 0){
|
||||||
|
jsonString = BuildSingleFileRespJson(req, NULL, "file", 1, 0);
|
||||||
|
DIY_WARNLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||||
|
"【WARN】复位操作成功 terminal_id=%s", req->devid);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
jsonString = BuildSingleFileRespJson(req, NULL, "file", 1, -1);
|
||||||
|
DIY_ERRORLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||||
|
"【ERROR】复位操作失败 terminal_id=%s ret=0x%X", req->devid, handleRet);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DIY_WARNLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
DIY_WARNLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||||
|
|||||||
@@ -1945,6 +1945,45 @@ MVL_REQ_PEND *reqCtrl;
|
|||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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) //响应时长
|
||||||
|
{
|
||||||
|
ST_RET ret;
|
||||||
|
ST_CHAR varName[MAX_IDENT_LEN + 1];
|
||||||
|
|
||||||
|
LEDRs_Oper_t oper;
|
||||||
|
memset(&oper, 0, sizeof(oper));
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
apr_snprintf(varName,
|
||||||
|
sizeof(varName),
|
||||||
|
"LLN0$CO$LEDRs$Oper"); //61850抓包显示为LLN0$CO$LEDRs$Oper
|
||||||
|
|
||||||
|
ret = mms_named_var_write(netInfo,
|
||||||
|
varName, //itemid
|
||||||
|
DOM_SPEC, //统一使用DOM_SPEC作为域名标识符
|
||||||
|
domName,
|
||||||
|
oper_type_id,
|
||||||
|
(ST_CHAR*)&oper, //数据源 这里是封装好的LEDRs_Oper_t结构体
|
||||||
|
timeOut);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* init_log_cfg */
|
/* init_log_cfg */
|
||||||
|
|||||||
@@ -534,6 +534,24 @@ QVVR_t* find_qvvr_by_trig_tm(LD_info_t* LD_info,long long trig_tm);
|
|||||||
|
|
||||||
void HandleFileDirReqForChannel(chnl_usr_t *chnl_usr);
|
void HandleFileDirReqForChannel(chnl_usr_t *chnl_usr);
|
||||||
|
|
||||||
|
//lnk20250508添加重启装置函数
|
||||||
|
//根据抓包显示oper的data结构有6个item
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ST_BOOLEAN ctlVal; //0:不重启 1:重启
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ST_INT8 orCat;
|
||||||
|
ST_CHAR orIdent[1]; // 空字符串
|
||||||
|
} origin;
|
||||||
|
|
||||||
|
ST_UINT8 ctlNum;
|
||||||
|
MMS_UTC_TIME T;
|
||||||
|
ST_BOOLEAN Test;
|
||||||
|
ST_UCHAR Check[1]; // bit-string 00
|
||||||
|
} LEDRs_Oper_t;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user