delete useless code

This commit is contained in:
lnk
2025-04-29 15:05:36 +08:00
parent 2a8f2c996c
commit 59079da4be
22 changed files with 1140 additions and 12715 deletions

View File

@@ -81,39 +81,6 @@ extern char* UDS_UPLOAD_URL;
///////////////////////////////////////////////////////////////////
//lnk20250122start
#if 0
apr_status_t init_rem_dib_table()
{
int pos = 0;
int iedno,chnl_no;
ied_t *ied;
struct in_addr ip;
chnl_usr_t *chnl_usr;
set_rem_dib_table_size( g_pt61850app->chnl_counts );
g_pt61850app->chnl_usr = apr_pcalloc( g_init_pool,g_pt61850app->chnl_counts*sizeof(chnl_usr_t*) );
printf( "set_rem_dib_table_size %d \n",g_pt61850app->chnl_counts );
for(iedno=0 ; iedno<g_node->n_clients; iedno++) {
ied = g_node->clients[iedno];
for(chnl_no=0 ; chnl_no<ied->chncount; chnl_no++) {
chnl_usr = ied->channel[chnl_no].connect;
g_pt61850app->chnl_usr[pos] = chnl_usr;
ip.s_addr = htonl(ied->channel[chnl_no].addr);
strcpy(chnl_usr->ip_str,inet_ntoa(ip));
printf( " add_rem_dib_table %s:%d \n",chnl_usr->ip_str ,ied->channel[chnl_no].port );
add_rem_dib_table (pos++,chnl_usr->ip_str,ied->channel[chnl_no].port );
{
char comm_str[256];
memset(comm_str,0,256);
apr_snprintf(comm_str,sizeof(comm_str),"%16s:%d\t\tinited",chnl_usr->ip_str,ied->channel[chnl_no].port);
add_comm_log(comm_str);
}
}
}
return APR_SUCCESS;
}
#endif
apr_status_t init_rem_dib_table()
{
int pos = 0;
@@ -174,19 +141,7 @@ void CloseIECReports(chnl_usr_t *chnl_usr)
continue;
if ( rptinfo->chnl_id != chnl_usr->chnl_id)
continue;
/*get_rpt_inst_name(rptinfo,rpt_inst_name);
ret = mms_unregister_iec_rpt (chnl_usr->net_info, &g_rpt_typeids,
LD_info->LD_name,rpt_inst_name,g_pt61850app->mmsOpTimeout );
if(ret == SD_FAILURE)
{
echo_warn3("unregister iec_rpt failed !!! domain: %s ,rpt_inst_name: %s ,chnl_id: %d \n",
LD_info->LD_name,rpt_inst_name,chnl_usr->chnl_id);
}
else
{
printf("unregister iec_rpt succeed, domain: %s ,rpt_inst_name: %s ,chnl_id: %d \n",
LD_info->LD_name,rpt_inst_name,chnl_usr->chnl_id);
} */
rptinfo->rpt_registered = FALSE;
//ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>10<31><30><EFBFBD><EFBFBD> <20><>ע<EFBFBD><D7A2>һ<EFBFBD>ε<EFBFBD><CEB5><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
rptinfo->m_LastRegisterFailedTime = sGetMsTime() -10*60*1000;
@@ -195,24 +150,6 @@ void CloseIECReports(chnl_usr_t *chnl_usr)
}
}
void prcess_ied_comm_2_json(ied_t *ied,int status)
{
ied_usr_t *ied_usr = NULL;
LD_info_t *LD_info = NULL;
int cpuno ;
apr_time_t tm = apr_time_now()/1000;
if (!three_secs_enabled)
return;
ied_usr = (ied_usr_t*)ied->usr_ext;
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
if (LD_info ) {
//prcess_monitor_comm_2_json(LD_info->line_id,status,tm);
}
}
}
void closeChannel(chnl_usr_t *chnl_usr)
{
char comm_str[256];
@@ -221,9 +158,6 @@ void closeChannel(chnl_usr_t *chnl_usr)
add_comm_log(comm_str);
FRONT_MP_NUM--;
echo_warn1("Close Channel IP: %s",chnl_usr->ip_str );
//prcess_ied_comm_2_json(chnl_usr->chnl->ied,STATUS_BREAKOFF);
//RDB_SetIedChnlStatus(chnl_usr->chnl->ied, STATUS_BREAKOFF, chnl_usr->chnl_id);
//write_status_to_db(0,chnl_usr->chnl->addr);
CloseIECReports(chnl_usr);
echo_warn1("-------Close Channel IP: %s success!!!!!!!!!", chnl_usr->ip_str);
@@ -247,15 +181,15 @@ void closeChannel(chnl_usr_t *chnl_usr)
if (ret != SD_SUCCESS){
echo_warn("---------disconnectFromServer success!\n");
//cout<<endl<<endl<<GetIP()<<" mms_disconnectFromServer failed ,Disconnect it roughly!"<<endl;
echo_warn2( "CHANNEL %s,NetInfo= %x mms_disconnectFromServer failed ,Disconnect it roughly! \n",chnl_usr->ip_str,chnl_usr->net_info);
//mms_release_connection(chnl_usr->net_info); ???????
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
chnl_usr->net_info->user_ext = NULL;
chnl_usr->net_info = NULL;
//cout<<"CHANNEL Close roughly, NetInfo_Channel_Map.entries()= "<<NetInfo_Channel_Map.entries()<<endl;
chnl_usr->m_reqCtrl = NULL;
chnl_usr->net_info = NULL;
chnl_usr->m_state = CHANNEL_DISCONNECTED;
@@ -270,7 +204,7 @@ void closeChannel(chnl_usr_t *chnl_usr)
}else {
chnl_usr->m_state = CHANNEL_DISCONNECTED;
chnl_usr->m_ClosedMsTime = sGetMsTime();
//cout<<"m_ClosedMsTime "<<m_ClosedMsTime<<endl;
chnl_usr->chnl->status = STATUS_BREAKOFF;
}
}
@@ -280,7 +214,7 @@ ST_VOID Callback_channel_disconnect_ind(MVL_NET_INFO * NetInfo, ST_INT discType)
chnl_usr_t *chnl_usr;
chnl_usr = (chnl_usr_t*)NetInfo->user_ext;
//cout<<"NetInfo_Channel_Map.entries()= "<<NetInfo_Channel_Map.entries()<<endl;
if ( chnl_usr ) {
if(chnl_usr->m_state == CHANNEL_CONNECTING)
{ //do nothing;
@@ -296,22 +230,15 @@ ST_VOID Callback_channel_disconnect_ind(MVL_NET_INFO * NetInfo, ST_INT discType)
printf("Do nothing,m_state == CHANNEL_DISCONNECTED ,NetInfo = %x",NetInfo);
}
//cout <<"NetInfo_Channel_Map[NetInfo] " << pCh <<endl ;
chnl_usr->net_info = NULL;
NetInfo->user_ext = NULL;
}
printf(" Callback_channel_disconnect_ind ,NetInfo = %x",NetInfo);
/* cout<<"after: NetInfo_Channel_Map.entries()= "<<NetInfo_Channel_Map.entries()<<endl;*/
//zw<7A>޸<EFBFBD> 2023 - 8 - 17 ͨѶ<CDA8>жϻص<CFBB><D8B5><EFBFBD><EFBFBD><EFBFBD> PG<50><47><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>жϴ<D0B6><CFB4><EFBFBD>
ied_usr_t* ied_usr = (ied_usr_t*)(chnl_usr->chnl[0].ied->usr_ext);
//printf("%s", ied_usr->terminal_code);
//connectlog_pgsql(ied_usr->terminal_code);
//apr_time_t tm = apr_time_now();//
//printf("time: %llu", tm);
//apr_time_exp_t pTm;
//apr_time_exp_gmt(&pTm, tm);
//printf("time: %u %u %u", pTm.tm_year, pTm.tm_mon, pTm.tm_mday);
}
@@ -369,26 +296,25 @@ void ChannelCheckIECReports(chnl_usr_t *chnl_usr)
ied_usr = GET_IEDEXT_ADDR(ied);
channel = chnl_usr->chnl;
//printf("check error %s !!!!!!!!!!!!!!cpucount:%d\n",((ied_usr_t*)chnl_usr->chnl->ied->usr_ext)->terminal_id,(int)ied->cpucount);
//printf("1 chnl_usr->ip_str = %s \n",chnl_usr->ip_str);
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++)
//for(cpuno = ied->cpucount - 1; cpuno >= 0; cpuno--)
{
LD_info = &(ied_usr->LD_info[cpuno]); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (LD_info->cpuno==0)
continue;
//printf("2 chnl_usr->ip_str = %s \n",chnl_usr->ip_str);
for(rpt_no=0 ; rpt_no<LD_info->rptcount; rpt_no++) { //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>棨ӳ<E6A3A8><D3B3><EFBFBD>ļ<EFBFBD><C4BC>ж<EFBFBD>ȡ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>
rptinfo = LD_info->rptinfo[rpt_no] ;
/*if ( strstr(rptinfo->rptID,"LLN0$RP$urcbRealData") )
continue;*/
if (judge_rpt_next_should_do(rptinfo)==SHOULD_DO_NOTHING)//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ񴥷<C7B7>
continue;
//printf("3 chnl_usr->ip_str = %s \n",chnl_usr->ip_str);
if(rptinfo->m_curRptSuffix==-1)
rptinfo->m_curRptSuffix = g_pt61850app->rptSuffix[g_client_id][0] ;
rptinfo->m_curRptSuffix = g_pt61850app->rptSuffix[g_client_id][0] ;
get_rpt_inst_name(rptinfo,rpt_inst_name);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if ( ! rptinfo->rpt_registered ) {
if ( (sGetMsTime() -rptinfo->m_LastRegisterFailedTime) > 20*1000 ) {
//ע<><D7A2>ʧ<EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD><EFBFBD><EFBFBD> 20<32><30> <20><>ע<EFBFBD><D7A2>һ<EFBFBD><D2BB>
@@ -397,84 +323,39 @@ void ChannelCheckIECReports(chnl_usr_t *chnl_usr)
if ( strstr(rptinfo->rptID,"LLN0$BR$brcbFlickerData") )
rptinfo->IntgPd = 600; //10<31><30><EFBFBD><EFBFBD>
/////////////////////////WW 2023-08-30 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
rcb_info = mms_register_iec_rpt (chnl_usr->net_info, &g_rpt_typeids,
LD_info->LD_name,rpt_inst_name,g_pt61850app->mmsOpTimeout, rptinfo->IntgPd,rptinfo->TrgOpt,
(ST_UINT8*)rptinfo->m_EntryID ,(ST_UINT8*)rptinfo->OptFlds);
//rcb_info = mms_register_iec_rpt_by_devtype(chnl_usr->net_info, &g_rpt_typeids,
// LD_info->LD_name, rpt_inst_name, g_pt61850app->mmsOpTimeout, ied_usr->dev_type, chnl_usr->ip_str, channel->port,
// rptinfo->IntgPd, rptinfo->TrgOpt,
// (ST_UINT8*)rptinfo->m_EntryID, (ST_UINT8*)rptinfo->OptFlds);
//WW end
///////////////////////////
if( !rcb_info )
{
if ( ++rptinfo->m_curRptSuffix > g_pt61850app->rptSuffix[g_client_id][1] )
rptinfo->m_curRptSuffix = g_pt61850app->rptSuffix[g_client_id][0] ;
rptinfo->m_LastRegisterFailedTime = sGetMsTime() ;
echo_err9("\nע<EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>Rregister iec_rpt failed !!! IED_ID=%d ,CPU=%d , domain: %s ,rpt_inst_name: %s ,ip: %s:%d,chnl_id: %d ,IntgPd=%d ,TrgOpt=0x%x \n",
APR_EGENERAL, LD_info->ied->id,LD_info->cpuno,LD_info->LD_name,rpt_inst_name,chnl_usr->ip_str,chnl_usr->chnl->port,
chnl_usr->chnl_id, rptinfo->IntgPd,rptinfo->TrgOpt );
//<2F><><EFBFBD>ټ<EFBFBD>¼<EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD>־lnk20241104
/*if (g_node_id == SOE_COMTRADE_BASE_NODE_ID)
{
//<2F>ݽ<EFBFBD><DDBD>¼<EFBFBD><C2BC><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
SoeRptSql(LD_info->terminal_code,1, rptinfo->rptID);
}*/
//zw<7A>޸<EFBFBD> 2023 - 8 - 18 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܼ<EFBFBD>¼
//printf("start %s \n", Rpt_errorlog_json());
//insert into "MEAS_PQ_COMM_ERROR_TR"("TERMINAL_ID","COMM_DATE","FILE_NAME") values('8afaa9a15707483a0157262f8e78077d',date'2023-08-18','FILENAME111')
//char ERROR_DES[256] = "", ERROR_PARAM[256] = "";
//char** varnames;
//int varnum,j;
////double beforeCallDomainMsTime = sGetMsTime() ;
//ST_RET ret = mms_mvla_getnam(chnl_usr->net_info, VMD_SPEC, NULL, MMS_CLASS_DOM, g_pt61850app->mmsOpTimeout,
// &varnames, &varnum, g_pt61850app->tmp_pool);
//for (j = 0; j < varnum; ++j) {
// //printf("LD %d name: %s \n", j, varnames[j]);
// strcat(ERROR_PARAM, varnames[j]);
// strcat(ERROR_PARAM, " ");
//}
//ret = mms_mvla_getnam(chnl_usr->net_info, DOM_SPEC, varnames[1], MMS_CLASS_VARLIST, 3,
// &varnames, &varnum, g_pt61850app->tmp_pool);
//for (j = 0; j < varnum; ++j) {
// //printf("LD %d name: [%s] \n", j, varnames[j]);
// strcat(ERROR_PARAM, varnames[j]);
// strcat(ERROR_PARAM, " ");
//}
//strcat(ERROR_DES, ied_usr->org_name);
//strcat(ERROR_DES, ",");
//strcat(ERROR_DES, ied_usr->station_name);
//strcat(ERROR_DES, ",");
//strcat(ERROR_DES, ied_usr->dev_type);
//strcat(ERROR_DES, ",");
//strcat(ERROR_DES, chnl_usr->ip_str);
//strcat(ERROR_DES, ",");
//strcat(ERROR_DES, rpt_inst_name);
//errorlog_json(LD_info->terminal_code, chnl_usr->ip_str, chnl_usr->chnl->port, g_node_id, "<22><><EFBFBD><EFBFBD><E6B4A5>ʧ<EFBFBD><CAA7>", ERROR_DES, ERROR_PARAM);
}
else
{
//<2F><><EFBFBD>ټ<EFBFBD>¼<EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD>־lnk20241104
/*if (g_node_id == SOE_COMTRADE_BASE_NODE_ID)
{
//<2F>ݽ<EFBFBD><DDBD>¼<EFBFBD><C2BC><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܼ<EFBFBD>¼
SoeRptSql(LD_info->terminal_code, 0, rptinfo->rptID);
}*/
double GIoffset;
rptinfo->rpt_registered = TRUE;
//rptinfo->m_LastDataTime = sGetMsTime();//WW 2023-08-29 ȥ<><C8A5>
rptinfo->m_rcb_info = rcb_info;
rptinfo->chnl_id = chnl_usr->chnl_id;
chnl_usr->m_NegRespTimes = 0;
chnl_usr->m_LastPosRespTime = sGetMsTime();
echo_msg11("\nRegister iec_rpt succeed, IED_ID=%d ,CPU=%d ,domain: %s ,rpt_inst_name: %s ,ip: %s:%d,chnl_id: %d ,IntgPd=%d ,TrgOpt=0x%x ,OptFlds=0x%x%x \n",
LD_info->ied->id,LD_info->cpuno,LD_info->LD_name,rpt_inst_name,chnl_usr->ip_str,chnl_usr->chnl->port,chnl_usr->chnl_id,
rptinfo->IntgPd,rptinfo->TrgOpt,rptinfo->OptFlds[0],rptinfo->OptFlds[1] );
// add here to GI not the same time
GIoffset = 0.5 * g_pt61850app->giTime;
rptinfo->m_LastGITime = sGetMsTime() - GIoffset*1000;
@@ -486,8 +367,10 @@ void ChannelCheckIECReports(chnl_usr_t *chnl_usr)
if ( (sGetMsTime() -rptinfo->m_LastUnRegisterFailedTime) > 20*1000 ) {
//ȡ<><C8A1>ע<EFBFBD><D7A2>ʧ<EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD><EFBFBD><EFBFBD> 20<32><30> <20><>ȡ<EFBFBD><C8A1>ע<EFBFBD><D7A2>һ<EFBFBD><D2BB>
printf("start mms_unregister_iec_rpt................................\n");
ret = mms_unregister_iec_rpt (chnl_usr->net_info, &g_rpt_typeids,
LD_info->LD_name,rpt_inst_name,g_pt61850app->mmsOpTimeout);
if( ret == SD_FAILURE ) {
rptinfo->m_LastUnRegisterFailedTime = sGetMsTime() ;
echo_err6("\nȡ<EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>UnRregister iec_rpt failed !!! IED_ID=%d ,CPU=%d , domain: %s ,rpt_inst_name: %s ,ip: %s,chnl_id: %d \n",
@@ -500,20 +383,8 @@ void ChannelCheckIECReports(chnl_usr_t *chnl_usr)
}
printf("end mms_unregister_iec_rpt................................\n");
}
//double nowMsTime = sGetMsTime() ;
//int ScanRateMs = 3*rptinfo->IntgPd*1000;
//if (rptinfo->chnl_id==chnl_usr->chnl_id) {
// //IECReport_tryGI(chnl_usr,rptinfo);
// if ( (ScanRateMs) && BSTR_BIT_GET( &(rptinfo->TrgOpt), TRGOPS_BITNUM_INTEGRITY ) ) // IntgPd<50><64>ʱ<EFBFBD><CAB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
// if ( (nowMsTime - rptinfo->m_LastDataTime) > ScanRateMs )
// {
// echo_err4("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IntgPd<50><64>ʱ<EFBFBD><CAB1>δ<EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ݣ<EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, domain: %s ,rpt_inst_name: %s ,ip: %s,chnl_id: %d \n",
// APR_EGENERAL,LD_info->LD_name,rpt_inst_name,chnl_usr->ip_str,chnl_usr->chnl_id);
// closeChannel(chnl_usr);
// return;
// }
//}
} //else { //rpt_registered ==TRUE
}
}
}
}
@@ -560,7 +431,7 @@ void ChannelCheckIECLogs(chnl_usr_t *chnl_usr)
apr_sleep(apr_time_from_sec(1) / 10);
Check_Recall_Config(LD_info->mp_id);//<2F><><EFBFBD>Ի<EFBFBD>ȡxml<6D>
//add_comm_log(LD_info->mp_id);
if (LD_info->autorecallcount != 0 && LD_info->autorecallflag != 1) {
int i;
int failed_count = 0;
@@ -568,51 +439,22 @@ void ChannelCheckIECLogs(chnl_usr_t *chnl_usr)
LD_info->autorecallflag = 1;
//loginfo->need_steady = 1; loginfo->need_voltage = 1;
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>̬lnk20241030<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ģ<DEB8>Check_Recall_Config<69><67>xml<6D>ļ<EFBFBD><C4BC><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ݺ󣬸<DDBA>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>LD_info
loginfo->need_steady = LD_info->autorecall[i]->need_steady; loginfo->need_voltage = LD_info->autorecall[i]->need_voltage;
loginfo->start_time = apr_time_from_sec(LD_info->autorecall[i]->start - 5);
loginfo->end_time = apr_time_from_sec(LD_info->autorecall[i]->end - 5);
//printf("bef mms_jread............. %11d %11d \n", LD_info->autorecall[i]->start, LD_info->autorecall[i]->end);
if (loginfo->need_steady == 0 && loginfo->need_voltage == 0)
continue;
if (loginfo->end_time <= loginfo->start_time)
continue;
/*if ( (sGetMsTime() -loginfo->last_checktime) < 180*1000 )
continue;*/
//loginfo->last_checktime = sGetMsTime();
printf("start mms_jread................................\n");
//now = sGetMsTime();
//last_check_recall_config_time = now;
//printf("start ==============%.2f================\n", last_check_recall_config_time);
echo_msg6("\n mms_jread IED_ID=%d ,CPU=%d ,domain: %s ,logName: %s ,ip: %s,chnl_id: %d \n",
LD_info->ied->id, LD_info->cpuno, LD_info->LD_name, loginfo->logName, chnl_usr->ip_str, chnl_usr->chnl_id);
//set_log_LineID(LD_info->line_id);
//set_line_info(LOG_IDX,LD_info->line_id,LD_info->SubV_Index,LD_info->Dev_Index,LD_info->Sub_Index,LD_info->GD_Index);
//long long start = LD_info->autorecall[i]->start;
//long long end = start;
//for (;end < LD_info->autorecall[i]->end;)
//{
// if (end < LD_info->autorecall[i]->end - 180)
// {
// start = end;
// end = end + 180;
// loginfo->start_time = apr_time_from_sec(start - 5);
// loginfo->end_time = apr_time_from_sec(end - 5);
// }
// else {
// start = end;
// end = LD_info->autorecall[i]->end;
// loginfo->start_time = apr_time_from_sec(start - 5);
// loginfo->end_time = apr_time_from_sec(end - 5);
// }
//}
//printf(" mms_jread..... start time: %d end time: %d\n", start, end);
ret = mms_jread(loginfo, chnl_usr->net_info, loginfo->LD_info->LD_name, loginfo->logName,
loginfo->start_time, loginfo->end_time, g_pt61850app->mmsOpTimeout, chnl_usr->ip_str);
if (ret != SD_SUCCESS) {
@@ -640,8 +482,7 @@ void ChannelCheckIECLogs(chnl_usr_t *chnl_usr)
Delete_recall_Xml(LD_info->mp_id);
}
}
/*apr_time_from_sec(&loginfo->start_time, 1694275200);
apr_time_from_sec(&loginfo->end_time, 1694361600);*/
}
}
@@ -654,8 +495,7 @@ void process_3s_config(trigger_3s_xml_t *trigger_3s_xml)
int trigger_num;
ied_t *ied;
LD_info_t *LD_info;
// int rpt_no;
// rptinfo_t *rptinfo;
int need_write_file;
int new_in_work_found;
@@ -669,7 +509,7 @@ void process_3s_config(trigger_3s_xml_t *trigger_3s_xml)
for (j=0; j<trigger_3s_xml->work_trigger_num; j++){
trigger_work = &trigger_3s_xml->work_triggers[j];
if (trigger_work->dev_idx==trigger[i].dev_idx && trigger_work->line_id==trigger[i].line_id ) {
//*trigger_work = trigger[i];
if (trigger[i].real_data>=0)
trigger_work->real_data = trigger[i].real_data;//<2F><><EFBFBD><EFBFBD>rtdata<74><61>־
if (trigger[i].soe_data>=0)
@@ -805,7 +645,6 @@ void del_process_recall_config(recall_xml_t* recall_xml)
}
//remove_recall_xml();
}
void check_3s_config()
@@ -827,7 +666,7 @@ void check_3s_config()
//<2F><><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>lnk20250114
//pthread_mutex_lock(&mtx); printf("3s hold lock !!!!!!!!!!!");
process_3s_config(&trigger_3s_xml); //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_unlock(&mtx); printf("3s free lock !!!!!!!!!!!");
//pthread_mutex_unlock(&mtx); printf("3s free lock !!!!!!!!!!!");
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1352,110 +1191,6 @@ void check_disk_quota()
freeSizeMB,totalSizeMB);
}
void check_recall_config()
{
double now;
static double last_check_recall_config_time = 0.0;
static int recall_flag = 1;// 1-<2D><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD> 2-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3-<2D><><EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
int recall_lenth = recall_len;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int recall_start = recall_sta;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int recall_dailytime = recall_daily;//ÿ<>ղ<EFBFBD><D5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
static int recall_count = 0;//<2F><><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
recall_xml_t recall_xml;
if(g_node_id != HIS_DATA_BASE_NODE_ID)
return;
now = sGetMsTime();
if ( fabs(now - last_check_recall_config_time) < 5*1000 ) //wait 5 secs
return;
last_check_recall_config_time = now;
//parse_recall_xml(&recall_xml);
//process_recall_config(&recall_xml);
//printf("==============%.2f================\n", last_check_recall_config_time);
apr_time_t previousTime = apr_time_now();//
apr_time_exp_t localTime;
apr_time_exp_gmt(&localTime, previousTime);
if (localTime.tm_hour == recall_dailytime && recall_flag == 1) {
recall_flag = 2;
recall_count = 0;
//recall_pgsql(1);//<2F><><EFBFBD><EFBFBD>ǰһ<C7B0><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
if (recall_flag == 2) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
if (recall_start > 30) {
recall_start = 30;
}
if (recall_lenth > 10) {
recall_lenth = 10;
}
if (recall_start < recall_lenth) //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>С<EFBFBD>ڲ<EFBFBD><DAB2>г<EFBFBD><D0B3><EFBFBD> <20><><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
{
recall_lenth = recall_start;
}
if (recall_count < recall_lenth)
{
recall_pgsql(recall_start - recall_count);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//char* day = getoneday(recall_start - recall_count);//<2F><>ȡǰn<C7B0><6E> yyyy-mm-dd
//printf("==============%s================\n", day);
//deletechar(day);
recall_count++;
}
else
{
recall_flag = 3;
}
}
if (localTime.tm_hour != recall_dailytime && recall_flag == 3) {
recall_flag = 1;
recall_count = 0;
}
}
void recall_pgsql(int num)
{
char* day = getoneday(num);//<2F><>ȡǰn<C7B0><6E> yyyy-mm-dd
int i = 0;
while (i < g_pt61850app->chnl_counts)
{
chnl_usr_t* chnl_usr;
ied_t* ied;
ied_usr_t* ied_usr;
LD_info_t* LD_info;
int cpuno = 0;
chnl_usr = g_pt61850app->chnl_usr[i];
ied = chnl_usr->chnl->ied;
ied_usr = GET_IEDEXT_ADDR(ied);
if (chnl_usr->m_state == CHANNEL_CONNECTED)
{
while (cpuno < ied->cpucount)
{
LD_info = &(ied_usr->LD_info[cpuno]);
if (LD_info->logcount <= 0)
continue;
printf("/home/pq mpid=%s\n", LD_info->mp_id);
//<2F><EFBFBD><E6BBBB>web<65>ӿ<EFBFBD>2024-10-21 lnk
//int ReDecide = OTL_Select_DecideRecall(day, LD_info->mp_id);
//int ReDecide = OTL_Select_DecideRecall_web(day, LD_info->mp_id);//<2F><>ʹ<EFBFBD><CAB9>lnk20241206
//if (ReDecide == 1) {//<2F><>ʹ<EFBFBD><CAB9>lnk20241206
//<2F><EFBFBD><E6BBBB>web<65>ӿ<EFBFBD>2024-10-21 lnk
//OTL_Select_recall(day, LD_info->mp_id);
//OTL_Select_recall_web(day, LD_info->mp_id);//<2F><>ʹ<EFBFBD><CAB9>lnk20241206
//}//<2F><>ʹ<EFBFBD><CAB9>lnk20241206
g_dead_lock_counter = 0;
g_thread_blocked_times = 0;
cpuno++;
}
}
i++;
}
deletechar(day);
}
void create_recall_xml()
{
//<2F><><EFBFBD>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD><EFBFBD>xml<6D>ļ<EFBFBD>
@@ -1468,8 +1203,7 @@ void create_recall_xml()
void Delete_recall_Xml(char* id) {
if (g_node_id == HIS_DATA_BASE_NODE_ID || g_node_id == NEW_HIS_DATA_BASE_NODE_ID || g_node_id == RECALL_HIS_DATA_BASE_NODE_ID || (g_node_id == RECALL_ALL_DATA_BASE_NODE_ID)) {
delete_recall_xml(id);
//process_recall_config(&recall_xml);
//remove_recall_xml();
}
}
@@ -1481,34 +1215,22 @@ void Check_Recall_Config(char *id) //
memset((char*)&recall_xml, 0, sizeof(recall_xml_t));
parse_recall_xml(&recall_xml,id); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
process_recall_config(&recall_xml); //<2F><><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>ֵ<EFBFBD><D6B5>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
//process_recall_config(&recall_xml);
//remove_recall_xml();
}
/*recall_xml_t recall_xml;
memset((char*)&recall_xml, 0, sizeof(recall_xml_t));
int ret = parse_recall_xml(&recall_xml);
if (0 == ret)
process_recall_config(&recall_xml);*/
}
void CheckAllConnectedChannel()
{
chnl_usr_t *chnl_usr;
static uint32_t chnl_sequence_no = 0;
//10-11-02 20:18 beijing, only one ied by visited every loop һ<EFBFBD>η<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD>
//һ<>η<EFBFBD><CEB7><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ն<EFBFBD>
do {
chnl_usr = g_pt61850app->chnl_usr[chnl_sequence_no];
chnl_sequence_no = (chnl_sequence_no+1) % g_pt61850app->chnl_counts;
} while ( (g_onlyIP[0]!=0) && (strcmp(g_onlyIP,chnl_usr->ip_str)!=0) );
//for (i=0; i<g_pt61850app->chnl_counts; i++) {
//chnl_usr = g_pt61850app->chnl_usr[i] ;
//printf("CheckAllConnectedChannel chnl_usr->ip_str = %s \n",chnl_usr->ip_str);
if(chnl_usr->m_state == CHANNEL_CONNECTED)
{
/*if(chnl_usr->chnl->ied->id==virtual_ied){
chnl_usr->m_state = CHANNEL_CONNECTED;
return;
}*/
ChannelCheckIECReports(chnl_usr);//<2F><><EFBFBD><EFBFBD>
if ( (g_node_id == SOE_COMTRADE_BASE_NODE_ID) || (g_node_id == HIS_DATA_BASE_NODE_ID) || (g_node_id == NEW_HIS_DATA_BASE_NODE_ID) || (g_node_id == RECALL_HIS_DATA_BASE_NODE_ID) || (g_node_id == RECALL_ALL_DATA_BASE_NODE_ID))
ChannelCheckWaveFiles(chnl_usr);//¼<><C2BC><EFBFBD>ļ<EFBFBD>
@@ -1518,93 +1240,58 @@ void CheckAllConnectedChannel()
{
char** varnames ;
int varnum;
//double beforeCallDomainMsTime = sGetMsTime() ;
ST_RET ret = mms_mvla_getnam(chnl_usr->net_info, VMD_SPEC, NULL,MMS_CLASS_DOM,g_pt61850app->mmsOpTimeout,
&varnames,&varnum,g_pt61850app->tmp_pool);
//for ( j = 0; j < varnum; ++j)
//printf("LD %d name: %s \n",j,varnames[j]);
//ret = mms_mvla_getnam(chnl_usr->net_info, DOM_SPEC, varnames[1],MMS_CLASS_VARLIST,3,
// &varnames,&varnum,g_pt61850app->tmp_pool);
////ret = mms_mvla_getnam(chnl_usr->net_info, DOM_SPEC, varnames[1], MMS_CLASS_VAR, 3,
//// &varnames, &varnum, g_pt61850app->tmp_pool);
//for ( j = 0; j < varnum; ++j)
// printf("LD %d name: [%s] \n",j,varnames[j]);
//double comdiff = sGetMsTime() - beforeCallDomainMsTime;
//cout<<"cost secs to check com "<<int(comdiff)<<endl;
//ST_RET ret = mms_mvla_status( chnl_usr->net_info, 15 );
chnl_usr->m_LastPosRespTime = sGetMsTime();
if (ret == SD_SUCCESS) {
//chnl_usr->m_LastPosRespTime = sGetMsTime();
chnl_usr->m_NegRespTimes = 0;
}else {
// cout<<" "<<pChannel->GetIP()<<" <20><> domain name ʧ<><CAA7> "<<endl;
printf("%d--------------\n", chnl_usr->m_NegRespTimes);
chnl_usr->m_NegRespTimes++;
}
}
if ( chnl_usr->m_NegRespTimes >=2 ) {
//printf("==============chnl_usr->m_NegRespTimes================\n");
closeChannel(chnl_usr);//???<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ mms_release_connection
chnl_usr->m_NegRespTimes = 0;
chnl_usr->m_LastPosRespTime = sGetMsTime();
}
}
//}
}
void CheckNextNotConnectedChannel()
{
static uint32_t chnl_total_no = 0;
chnl_usr_t *chnl_usr;
// element_t *elem_a;
// element_t *elem_b;
do {
chnl_usr = g_pt61850app->chnl_usr[chnl_total_no];
chnl_total_no = (chnl_total_no+1) % g_pt61850app->chnl_counts;
} while ( (g_onlyIP[0]!=0) && (strcmp(g_onlyIP,chnl_usr->ip_str)!=0) );
//printf("check error chnl_total_no !!!!!!!!!!!!!! %d\n",chnl_total_no);
//10-11-01 22:03 beijing
if( ( (chnl_total_no+1)==g_pt61850app->chnl_counts) || (g_onlyIP[0]!=0) ){
if(g_pt61850app->initNum<255)
g_pt61850app->initNum++;
}
if(chnl_usr->chnl->ied->chncount == 2){
//elem_a = RDB_GetElement(SUBSTATION, chnl_usr->chnl->ied->id,64264, 5);
//elem_b = RDB_GetElement(SUBSTATION, chnl_usr->chnl->ied->id,64264, 6);
//if(elem_a&&elem_b){
// if((((M_DP_NA_1_t*)elem_a->value.data)->diq.parts.DPI == 0x01)&&(((M_DP_NA_1_t*)elem_b->value.data)->diq.parts.DPI == 0x01)){
// iecs_set_ied_invalid(chnl_usr->chnl->ied);
// }
//}
}
else{
//elem_a = RDB_GetElement(SUBSTATION, chnl_usr->chnl->ied->id,64264, 5);
//if(elem_a){
// if(((M_DP_NA_1_t*)elem_a->value.data)->diq.parts.DPI == 0x01){
// iecs_set_ied_invalid(chnl_usr->chnl->ied);
// }
//}
}
//printf("check error %s !!!!!!!!!!!!!!\n",((ied_usr_t*)chnl_usr->chnl->ied->usr_ext)->terminal_id);
if(chnl_usr->m_state == CHANNEL_CONNECTING)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
//printf("check error93 !!!!!!!!!!!!!!\n");
MVL_REQ_PEND* reqCtrl= chnl_usr->m_reqCtrl ;
//printf("check error60 !!!!!!!!!!!!!!\n");
if( reqCtrl->done == SD_TRUE)
{
//printf("check error92 !!!!!!!!!!!!!!\n");
if(reqCtrl->result == SD_SUCCESS)
{
//printf("check error91 !!!!!!!!!!!!!!\n");
ALL_RCB_INFO *all_rcb_info;
// cout<<endl<<endl<<pChannel->GetIP()<<" CHANNEL_CONNECTED netInfo "<<chnl_usr->net_info<<endl;
echo_warn4("\nCHANNEL_CONNECTED %s:%d ,NetInfo= %x chnl_usr= %x \n",
chnl_usr->ip_str,chnl_usr->chnl->port,chnl_usr->net_info,chnl_usr);
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
@@ -1615,7 +1302,7 @@ void CheckNextNotConnectedChannel()
all_rcb_info = (ALL_RCB_INFO *)chk_calloc(1, sizeof (ALL_RCB_INFO));
all_rcb_info->rpt_typeids = &g_rpt_typeids;
//assert(chnl_usr->net_info->user_info == NULL);
if (chnl_usr->net_info->user_info != NULL) {
echo_warn("chnl_usr->net_info->user_info is not NULL\n");
}
@@ -1623,8 +1310,7 @@ void CheckNextNotConnectedChannel()
chnl_usr->net_info->user_info = all_rcb_info;
chnl_usr->chnl->ied->status = STATUS_NORMAL;
chnl_usr->chnl->status = STATUS_NORMAL;
//prcess_ied_comm_2_json(chnl_usr->chnl->ied,STATUS_NORMAL);
//RDB_SetIedChnlStatus(chnl_usr->chnl->ied, STATUS_NORMAL, chnl_usr->chnl_id);
{
char comm_str[256];
memset(comm_str,0,256);
@@ -1642,17 +1328,11 @@ void CheckNextNotConnectedChannel()
}
else
{// solaris 9 <20><> 224<32><34>
//printf("check error90 !!!!!!!!!!!!!!\n");
int secsSince = (int)(sGetMsTime() - chnl_usr->m_StartConnectingTime)/1000 ;
//cout<<"reqCtrl->result == FAIL, Since StartConnecting "<<secsSince<<"<22><> "<<pChannel->GetIP()<<" !!! "<<endl;
ied_usr_t* ied_usr = (ied_usr_t*)chnl_usr->chnl->ied->usr_ext;
if (g_node_id == STAT_DATA_BASE_NODE_ID || g_node_id == NEW_HIS_DATA_BASE_NODE_ID) {
//lnk202411-4
//connectlog_pgsql(ied_usr->terminal_code);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
//printf("check error89 !!!!!!!!!!!!!!\n");
//connectlog_pgsql(ied_usr->terminal_id,convertMsToDateTimeString(sGetMsTime()),0);//0ʧ<30><CAA7>
//printf("check error88 !!!!!!!!!!!!!!\n");
}
printf( "reqCtrl->result == FAIL, Since StartConnecting %i sec ,channel IP %s:%d \n",secsSince,chnl_usr->ip_str,chnl_usr->chnl->port);
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
chnl_usr->m_reqCtrl = NULL;
@@ -1662,17 +1342,12 @@ void CheckNextNotConnectedChannel()
}
}
else
{//
//printf("check error61 !!!!!!!!!!!!!!\n");
if ( (sGetMsTime() - chnl_usr->m_StartConnectingTime) > 300*1000 ) //300*1000 ) //wait 300 secs ?????
{
if ( (sGetMsTime() - chnl_usr->m_StartConnectingTime) > 300*1000 ) //300*1000 ) //wait 300 secs
{
ied_usr_t* ied_usr = (ied_usr_t*)chnl_usr->chnl->ied->usr_ext;
if (g_node_id == STAT_DATA_BASE_NODE_ID || g_node_id == NEW_HIS_DATA_BASE_NODE_ID) {
//connectlog_pgsql(ied_usr->terminal_code);//reqCtrl->doneδ<65><CEB4><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ5<CAB1><35><EFBFBD><EFBFBD>
//lnk202411-4
//connectlog_pgsql(ied_usr->terminal_id,convertMsToDateTimeString(sGetMsTime()),0);//0ʧ<30><CAA7>
}
//cout<<pChannel->GetIP()<<" reqCtrl->done == SD_false but time over 300 secs, close channel !!!"<<endl;
echo_warn2( "reqCtrl->doneδ<65><CEB4><EFBFBD><EFBFBD>,but time over 300 secs, close channel IP %s,NetInfo= %x ",chnl_usr->ip_str,chnl_usr->net_info);
if (chnl_usr->net_info->req_pend_list) {
echo_warn("reqCtrl->doneδ<65><CEB4><EFBFBD><EFBFBD>,but time over 300 secs!!!!!!!!\n");
@@ -1680,94 +1355,60 @@ void CheckNextNotConnectedChannel()
chnl_usr->m_reqCtrl = NULL;
}
mms_release_connection(chnl_usr->net_info);
//mvl_free_req_ctrl(chnl_usr->m_reqCtrl); //???
chnl_usr->net_info->rem_vmd = NULL;
chnl_usr->m_state = CHANNEL_DISCONNECTED;
chnl_usr->m_ClosedMsTime = sGetMsTime();
//if(chnl_usr->chnl->ied->id==virtual_ied){
// chnl_usr->m_state = CHANNEL_CONNECTED;
// chnl_usr->chnl->ied->status = STATUS_NORMAL;
// chnl_usr->chnl->status = STATUS_NORMAL;
// //Special_CPU_Set(chnl_usr->chnl->ied, STATUS_NORMAL);
// //RDB_SetIedChnlStatus(chnl_usr->chnl->ied, STATUS_NORMAL,0);
//}
}
}
} //if(pChannel->m_state == CHANNEL_CONNECTING)
}
else if(chnl_usr->m_state == CHANNEL_DISCONNECTED)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("check error99 !!!!!!!!!!!!!!\n");
if ( (sGetMsTime() - chnl_usr->m_ClosedMsTime) > NEXT_CONNECT_TIME ) //wait 10 secs
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("check error98 !!!!!!!!!!!!!!\n");
ST_RET ret;
ST_CHAR serverARName[32];
ied_usr_t *ied_usr = (ied_usr_t*)chnl_usr->chnl->ied->usr_ext;
apr_snprintf(serverARName,sizeof(serverARName),"%s:%d",chnl_usr->ip_str,chnl_usr->chnl->port);
if (chnl_usr->chnl->ied->cpucount != NULL && chnl_usr->chnl->ied->cpucount > 0 && ied_usr->dev_flag == ENABLE) {//2023-09-26 czy <20><><EFBFBD><EFBFBD>line count<0 <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>//lnk20250121<32><31><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ret = mms_connectToServer(ied_usr->dev_key, ied_usr->dev_series, serverARName, &(chnl_usr->net_info), &(chnl_usr->m_reqCtrl));
//printf("check error73 !!!!!!!!!!!!!!\n");
if (ret == SD_SUCCESS)
{
//printf("check error74 !!!!!!!!!!!!!!\n");
//if(chnl_usr->chnl->ied->id==virtual_ied){
// chnl_usr->m_state = CHANNEL_CONNECTED;
// chnl_usr->chnl->ied->status = STATUS_NORMAL;
// chnl_usr->chnl->status = STATUS_NORMAL;
// //Special_CPU_Set(chnl_usr->chnl->ied, STATUS_NORMAL);
// //RDB_SetIedChnlStatus(chnl_usr->chnl->ied, STATUS_NORMAL,0);
// return;
//}
//echo_warn3("!!!!!!!!!!!!!!!!!!!!!!!!! %s:%d %x \n", chnl_usr->ip_str, chnl_usr->chnl->port, chnl_usr->net_info);
echo_msg3("mms_connectToServer IP %s:%d ,NetInfo= %x \n", chnl_usr->ip_str, chnl_usr->chnl->port, chnl_usr->net_info);
chnl_usr->m_state = CHANNEL_CONNECTING;
chnl_usr->m_StartConnectingTime = sGetMsTime();
//RDB_SetIedChnlStatus(chnl_usr->chnl->ied, STATUS_NOINIT, chnl_usr->chnl_id);
//write_status_to_db(0,chnl_usr->chnl->addr);
//lnk202411-1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ӳɹ<D3B3>
//connectlog_pgsql(ied_usr->terminal_id,convertMsToDateTimeString(sGetMsTime()),1);
}
else
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("check error97 !!!!!!!!!!!!!!\n");
chnl_usr->m_ClosedMsTime = sGetMsTime();
if (g_node_id == STAT_DATA_BASE_NODE_ID || g_node_id == NEW_HIS_DATA_BASE_NODE_ID) {
//lnk202411-4
//connectlog_pgsql(ied_usr->terminal_code);//<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("check error96 !!!!!!!!!!!!!!\n");
//connectlog_pgsql(ied_usr->terminal_id,convertMsToDateTimeString(sGetMsTime()),0);//<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>״̬û<CCAC>иı<C4B1><E4B2BB>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>20250312
//printf("check error95 !!!!!!!!!!!!!!\n");
}
echo_warn3("FAILED: mms_connectToServer IP %s:%d ,NetInfo= %x \n", chnl_usr->ip_str, chnl_usr->chnl->port, chnl_usr->net_info);
}
}
}
}//if(pChannel->m_state == CHANNEL_DISCONNECTED)
else if(chnl_usr->m_state == CHANNEL_DISCONNECTING) //need check timeout?<3F><EFBFBD><E1B2BB><EFBFBD><EFBFBD>Զͣ<D4B6><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>???
}
else if(chnl_usr->m_state == CHANNEL_DISCONNECTING) //need check timeout?<3F><EFBFBD><E1B2BB><EFBFBD><EFBFBD>Զͣ<D4B6><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
//printf("check error92 !!!!!!!!!!!!!!\n");
MVL_REQ_PEND* reqCtrl= chnl_usr->m_reqCtrl ;
if( reqCtrl->done == SD_TRUE)
{
//printf("check error72 !!!!!!!!!!!!!!\n");
//cout<<endl<<endl<<pChannel->GetIP()<<" CHANNEL_DISCONNECTING done"<<endl;
echo_warn3( "CHANNEL_DISCONNECTING done %s:%d,NetInfo= %x ",chnl_usr->ip_str,chnl_usr->chnl->port,chnl_usr->net_info);
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
if(chnl_usr->net_info)
chnl_usr->net_info->user_ext = NULL;
//NetInfo_Channel_Map.remove(chnl_usr->net_info);
//cout<<"CHANNEL_DISCONNECTING done NetInfo_Channel_Map.entries()= "<<NetInfo_Channel_Map.entries()<<endl;
chnl_usr->m_reqCtrl = NULL;
chnl_usr->net_info = NULL;
chnl_usr->m_state = CHANNEL_DISCONNECTED;
@@ -1779,18 +1420,17 @@ void CheckNextNotConnectedChannel()
}
else
{//
//printf("check error70 !!!!!!!!!!!!!!\n");
// cout<<endl<<endl<<pChannel->GetIP()<<" CHANNEL_DISCONNECTING waiting ..."<<endl;
{
echo_warn2( "CHANNEL_DISCONNECTING waiting ... %s,NetInfo= %x ",chnl_usr->ip_str,chnl_usr->net_info);
if ( (sGetMsTime() - chnl_usr->m_StartDisconnectingTime) > 30*1000 ) // //wait 30 secs ?????
{
//cout<<pChannel->GetIP()<<"CHANNEL_DISCONNECTING reqCtrl->done == SD_false but time over 180 secs, close channel !!!"<<endl;
echo_warn2( "CHANNEL_DISCONNECTING reqCtrl->doneδ<65><CEB4><EFBFBD><EFBFBD>,but time over 180 secs, close channel IP %s,NetInfo= %x ",chnl_usr->ip_str,chnl_usr->net_info);
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
chnl_usr->net_info->user_ext = NULL;
//NetInfo_Channel_Map.remove(chnl_usr->net_info);
mms_release_connection(chnl_usr->net_info);
chnl_usr->net_info->rem_vmd = NULL;
chnl_usr->m_reqCtrl = NULL;
@@ -1803,16 +1443,10 @@ void CheckNextNotConnectedChannel()
connectlog_pgsql(ied_usr->terminal_id,convertMsToDateTimeString(t_now),0);
}
}
}//if(pChannel->m_state == CHANNEL_DISCONNECTING)
//////////////////
//printf("check error77 !!!!!!!!!!!!!!\n");
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////*********<2A><><EFBFBD>ؿ<EFBFBD><D8BF>Ʋ<EFBFBD><C6B2><EFBFBD>**********////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
static ST_RET Read_Named_Var(LD_info_t *LD_info,chnl_usr_t *chnl_usr,char* VarName,ST_INT type_id, ST_VOID *dataDest, ST_INT timeOut)
{
ST_RET ret= SD_FAILURE;
@@ -1866,12 +1500,10 @@ static ST_RET Write_Named_Var(LD_info_t *LD_info,chnl_usr_t *chnl_usr,char* VarN
int pt61850_write_cn_file(chnl_usr_t *chnl_usr, ied_t *ied, char *rem_filename, char *only_filename_ret)
{
int ret ;
// ticks_t ticks;
char loc_filename[128], loc_file_fullname[256], rem_file_fullname[256],only_filename_str[256];
// int result ;//= FILE_NAME_UNIQUE;
// uint8_t cpuNo =0;
char *only_filename,*the_full_file;
// ied_usr_t *ied_usr = GET_IEDEXT_ADDR(ied);
memset(loc_filename,0,sizeof(loc_filename));
memset(only_filename_str,0,sizeof(only_filename_str) );
@@ -1965,7 +1597,6 @@ apr_status_t call_cn_wavelist(LD_info_t *LD_info )
//WW 2023-11-01<30><31>¼<EFBFBD><C2BC><EFBFBD>κ<EFBFBD><CEBA><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>޸<EFBFBD>Ϊint<6E><74>fltnumƥ<6D><C6A5>
ret2 = parse_file_names_by_fltnum(LD_info->FltNum[i], ldstr, filenames, filenum, &cfg_idx, &dat_idx, file_base_name, file_yyyymm);
//ret2 = parse_file_names(file_match_str,filenames,filenum,&cfg_idx,&dat_idx,file_base_name,file_yyyymm);
//WW 2023-11-01 end
if (ret2 !=APR_SUCCESS)
return ret2;
@@ -1979,9 +1610,7 @@ apr_status_t call_cn_wavelist(LD_info_t *LD_info )
if (ret2==SD_SUCCESS && ret3==SD_SUCCESS ) { //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
QVVR_t *qvvr; //<2F><>̬<EFBFBD>¼<EFBFBD>
long long start_tm,trig_tm,end_tm;
//char ftp_filename[256];
//doCommService();
//memset(ftp_filename,0,256);
ret2 = extract_timestamp_from_cfg_file(filenames[cfg_idx],&start_tm,&trig_tm);//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC>Ŀ<EFBFBD>ʼʱ<CABC><CAB1><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>ʱ<EFBFBD><CAB1>
printf(">>>>>>>> extract_timestamp_from_cfg_file end \n");
if (ret2 ==APR_SUCCESS) {
@@ -2001,8 +1630,6 @@ apr_status_t call_cn_wavelist(LD_info_t *LD_info )
char linux_cmd[256] = {0};
printf(">>>>>>>> qvvr ok end \n");
apr_snprintf(linux_cmd,sizeof(linux_cmd),"./sftp_upload %s %s/%04d",cfg_only_filename_ret,file_yyyymm,LD_info->line_id);//û<><C3BB>ʹ<EFBFBD><CAB9>
//printf("\n>>>>>> %s ...... \n",linux_cmd);
//system(linux_cmd);
char loc_file_fullname_cfg[256];//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
memset(loc_file_fullname_cfg, 0, sizeof(loc_file_fullname_cfg));
@@ -2041,8 +1668,6 @@ apr_status_t call_cn_wavelist(LD_info_t *LD_info )
}
apr_snprintf(linux_cmd,sizeof(linux_cmd),"./sftp_upload %s %s/%04d",dat_only_filename_ret,file_yyyymm,LD_info->line_id);//<2F><>ͨ<EFBFBD><CDA8>sftp<74>ϴ<EFBFBD><CFB4>ŷ<EFBFBD>json<6F><6E>ȥ
//printf("\n>>>>>> %s ...... \n",linux_cmd);
//system(linux_cmd);
char loc_file_fullname_dat[256];
memset(loc_file_fullname_dat, 0, sizeof(loc_file_fullname_dat));