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

@@ -74,7 +74,6 @@ int json_block_create_data(char monid_char[], char* mms_str , double v, int flic
//3. json<6F><6E><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//lnk2024-8-16<31><36><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>
int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag); //CZY 2023-08-17 <20><><EFBFBD><EFBFBD>
//int json_block_create_end(int MonitorId,int devkind);//CZY 2023-08-17 <20><><EFBFBD><EFBFBD>
//zw 2024-01-31 <20><><EFBFBD><EFBFBD>ģʽ<C4A3>Ż<EFBFBD>
void add_mvl_type_ctrl(char doname[], int ctrl);
@@ -88,15 +87,6 @@ typedef struct LD_info_t LD_info_t;
int urcbRealDataHasReceived(int dev_index, LD_info_t* LD_info, long long Time); //lnk20241223
#endif
//void set_log_LineID(int id);
//void set_rpt_LineID(int id);
//void set_log_TimeID(apr_time_t time);
//void set_rpt_TimeID(apr_time_t time);
//void set_log_QualityFlag(int QualityFlag);
//void set_rpt_QualityFlag(int QualityFlag);
int is_rpt_Time_exact_hour() ;
apr_status_t app_get_private_config(const char *myfilename);
@@ -165,7 +155,6 @@ int testbase64();
//////////////////////////////WW 20230822<32><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>WebSocket<65>߳<EFBFBD>
void try_start_sql_thread(); //<2F><><EFBFBD><EFBFBD>Sqlִ<6C><D6B4><EFBFBD>߳<EFBFBD>
void try_start_socket_thread(); //<2F><><EFBFBD><EFBFBD>Web Socket<65>߳<EFBFBD>
void try_start_ontimer_thread();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>߳<EFBFBD>s
/////////////////////////////WW end
@@ -202,24 +191,11 @@ int parse_device_web_test_front_read();
int parse_device_web_test_front_write();
int parse_device_cfg_web();
//int parse_line_cfg_web();
int parse_model_cfg_web();
void SOEFileWeb(char* localpath,char* cloudpath,char* wavepath);
void OTL_Select_recall_web(char* time, char* id);
int OTL_Select_DecideRecall_web(char* time, char* id);
bool CheckPG_To_Recall_web(long long start, long long end, char* Monitorid);
//////////////////////////////////////////////////////////////////////////////////////
/*int parse_database_delete(const std::vector<std::string>& codes);
int parse_commerror_write(const std::vector<std::string>& codes);
int parse_commstatus_write(const std::vector<std::string>& codes);
int parse_match_write(const std::vector<std::string>& codes);
int parse_dataintegrity_write(const std::vector<std::string>& codes);
int parse_rationality_write(const std::vector<std::string>& codes);*/
#ifdef __cplusplus
}
#endif

View File

@@ -26,9 +26,8 @@ extern pthread_mutex_t mtx;
extern pt61850app_t *g_pt61850app;
extern node_t *g_node;
char g_my_conf_fname[256];
//extern byte_t g_Master;
char g_onlyIP[255]; //ֱ<><D6B1>ij<EFBFBD><C4B3>IP<49><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//extern byte_t g_protect_file; //0:<3A><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD> 1:<3A>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD>
apr_pool_t *g_root_pool;
apr_pool_t *g_rdb_pool;
@@ -122,7 +121,6 @@ void init_daemon(void)
//"--subdir, set the subdir of /CloudForward/ as the working directory, \n"
int usage()
{
// fprintf(stderr,"\n\n******** IEC61850 Protocol ********\n");
fprintf(stderr,"\nUsage : pt61850netd_pqfe -d [subdir] \n");
exit(-1);
@@ -179,16 +177,9 @@ int prepare_entironment_2()
return (-1);
}
//g_fun_pool = 0;
//rv = apr_thread_mutex_create(&g_rdb_mutex, APR_THREAD_MUTEX_NESTED,g_root_pool);//<2F><><EFBFBD><EFBFBD>RDB<44><42>
//if ( rv != APR_SUCCESS) {
// return rv;
//}
/* Initialize the register table. Call these functions first! */
echo_msg1("%-60s","Initialize system register......");
//init_default_dbparser_table(); //<2F><><EFBFBD>ݸ<EFBFBD>XML<4D>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>RDB<44><42>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
//load_driver_library(); //<2F><><EFBFBD>ø<EFBFBD><C3B8>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
echo_msg("OK\n\n");
initTimezoneOffset();
@@ -211,11 +202,8 @@ void printf_cur_user()
int main(int argc, const char **argv)
{
// ipcclient_t *ipcclient = NULL;
// void *cookie = NULL;
uint32_t stimer = 1;
apr_status_t rv;
// int pid;
/* Prepare the system context */
rv=prepare_entironment_2();
@@ -225,22 +213,6 @@ int main(int argc, const char **argv)
getVersion(argc,argv);
////////////////////
//WW <20><><EFBFBD><EFBFBD>json
//TestJson(NULL);
//WW 2023-08-31 end
///////////////////
//TestSMSPost();//WW 2023-08-28<32><38><EFBFBD>Թ<EFBFBD>˾post
//TestBodyPost();
//TestToken();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դҵ<D4B4><D2B5><EFBFBD><EFBFBD>̨
////////////////////
//WW <20><><EFBFBD><EFBFBD>json
//TestOSS();
//TestOBS();
//WW 2023-09-01 end
///////////////////
/* Parse the command-line parameter */
rv=parse_param(argc, argv);
if (rv!=APR_SUCCESS){
return rv;
@@ -280,9 +252,6 @@ int main(int argc, const char **argv)
return rv;
}
//lnk20241024ȥ<34><C8A5><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
//OTLConnect();
rv = run_protocol();
if (rv!=APR_SUCCESS){
return rv;
@@ -360,10 +329,8 @@ int parse_param(int argc, const char **argv)
char *p;
char temp[128];
//int g_front_seg_index, g_front_seg_num;
/* Set default command-line parameter */
g_node_id = 0;
//g_protect_file = 0;
echo_warn2("================= compiled@ %s %s =================\n",__DATE__ , __TIME__ );
@@ -383,18 +350,7 @@ int parse_param(int argc, const char **argv)
break;
case 'R':
case 'r':
// if (opt_arg[0] >= '0' && opt_arg[0] <= '9' )
// {
// g_client_id = atoi(opt_arg);
// if (g_client_id>2||g_client_id<0)
// {
// printf("Do not support triple or above clients \n ");
// return (usage());
// }
////g_auto_client_id = FALSE;
// }
// else
// return (usage());
break;
case 's':
case 'S':
@@ -413,11 +369,6 @@ int parse_param(int argc, const char **argv)
printf("g_front_seg_num:%d",g_front_seg_num);
//echo_warn2("================= compiled@ %d %d =================\n", g_front_seg_index, g_front_seg_num);
//lnk20241206<30><36><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>¼subdir<69><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
//echo_warn1("subdir %s ", opt_arg + 6);
//strcpy(subdir, opt_arg + 6);
break;
break;
case 'a':
@@ -433,14 +384,7 @@ int parse_param(int argc, const char **argv)
break;
case 'f':
case 'F':
//if (opt_arg[strlen(opt_arg)-1] == '/'
// || opt_arg[strlen(opt_arg)-1] == '\\') {
// echo_errg( "Error: Bad or invalid file name");
// return (usage());
// }
// //g_my_conf_fname = SHR_GetPrivateFileName(opt_arg,g_root_pool);
// echo_warn1("using config file %s!\n", g_my_conf_fname);
// break;
break;
case 'P':
case 'p':
if (opt_arg[0] >= '0' && opt_arg[0] <= '9' ) {
@@ -459,7 +403,6 @@ int parse_param(int argc, const char **argv)
return 0;
}
///////////////////////////////////////////////////////////////<2F><><EFBFBD>Ӳ<EFBFBD><D3B2>Խ<EFBFBD><D4BD>̵ļ<CCB5><C4BC>غ<EFBFBD><D8BA><EFBFBD>lnk20250304
void doMonitorTaskmain(void) {
static int stimer = 0;

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));

View File

@@ -73,28 +73,22 @@ static ST_VOID log_var_jou_data (ST_INT var_type_id,VAR_ACC_DATA *var ,MMS_DECOD
ST_INT data_size; /* size of data element */
type_ctrl = mvl_type_ctrl_find (var_type_id);
//char doname[32];
//strcpy(doname, dom_name);
//type_ctrl = (MVL_TYPE_CTRL*)(sel_mvl_type_ctrl(doname));
//printf ("\naddress: %p \n", type_ctrl);
if (type_ctrl)
{
num_rt = type_ctrl->num_rt;
rt = type_ctrl->rt;
data_size = type_ctrl->data_size;
//printf ("\nTYPE: %d %d %d\n", num_rt, data_size, rt->el_size);
/* If the TDL produced is longer than max_tdl_len, this function */
/* "gracefully" fails (i.e. returns 0). */
if (ms_runtime_to_tdl (rt, num_rt, tdl_buf, sizeof(tdl_buf))>0)
;//SLOGCALWAYS1 (" TYPE: %s", tdl_buf);
;
else
echo_warn (" TYPE: unknown");
//printf("\nrt %p and rt_num: %d \n", &type_ctrl->rt,type_ctrl->num_rt);
//printf ("\nTYPE: %s \n", tdl_buf);
va_data_size = data_size;
temp_data_buf = (ST_CHAR*)malloc( va_data_size);
rc = ms_asn1_to_local (rt, num_rt, var->data, var->len, temp_data_buf);
//printf("type_ctrl->num_rt %d %x %x \n", type_ctrl->num_rt , &data, &(var->data));
my_local_to_data (temp_data_buf,rt,num_rt, data);
if (data->item_num==0) {
echo_warn("!!!!!!!!!!!!!!!!!!!data num is 0 !!!!!!!!!!!!!!!!\n");
@@ -151,8 +145,7 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
do_name = strstr(jou_entry->ef.data.list_of_var[j].var_tag, "/");
do_name++;
}
//printf("do_name =====%s=====\n", do_name);
//start = sGetMsTime();
printf("\nbrf if");
if (sel_mvl_type_ctrl_flag(do_name) == -1)
{
@@ -162,20 +155,13 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
char doname[32];
strcpy(doname, do_name);
add_mvl_type_ctrl(doname, var_type_id);
//printf("create var_type_id =====%d=====%p======\n", var_type_id, &doname);
}
printf("\nbrf var_type_id");
var_type_id = sel_mvl_type_ctrl_flag(do_name);
printf("\nafter var_type_id");
//end = sGetMsTime();
//last_check_recall_config_time = last_check_recall_config_time + end - start;
//printf("jou_entry->ef.data.num_of_var =====%d===== =====%d=====\n", jou_entry->ef.data.num_of_var, var_type_id);
/*var_type_id = mms_var_type_id_create(clientNetInfo, DOM_SPEC,
dom_name, do_name, iTimeout);*/
//printf("var_type_id =====%d=====\n", var_type_id);
if (var_type_id < 0) {
//return SD_FAILURE;
continue;
}
log_var_jou_data(var_type_id,&(jou_entry->ef.data.list_of_var[j].value_spec),&mms_dec_data, do_name);
@@ -336,10 +322,10 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
v = (double)mms_dec_data.data_item[ii].u.data_uint64;
else if (mms_dec_data.data_item[ii].type==DATA_DOUBLE_TYPE)
v = mms_dec_data.data_item[ii].u.data_double;
//printf("%s %s = %f \n",jou_entry->ef.data.list_of_var[j].var_tag, mms_dec_data.data_item[ii].comp_name,v);
apr_snprintf(mms_ref,sizeof(mms_ref),"%s$%s",do_name,mms_dec_data.data_item[ii].comp_name);
if ( (strstr(mms_ref,"]")==NULL) || (strstr(mms_ref,"0]")) )
//printf("\nlog read: %s=%f\n",mms_ref,v);
if (j==0 && ii==0) {
printf("\n ----------------------------------------------------------------log read: %s=%f--------------------------------------------------------------\n",mms_ref,v);
if ( strstr(mms_ref,"QVVR") ) {
@@ -356,31 +342,22 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
}
if ( ( (loginfo->need_steady==0) &&(log_data_type == STEADY_DATA))
|| ( (loginfo->need_voltage==0) &&(log_data_type != STEADY_DATA)) ){
//mvl_type_id_destroy(var_type_id);
return SD_SUCCESS;
}
if ( log_data_type == QVVR_DATA ) {
processQVVR_start(loginfo->LD_info);
//processQVVR_time(loginfo->LD_info,t/1000);
}
else if ( log_data_type == RDRE_DATA ) {
processRDRE_start(loginfo->LD_info);
}
else {
/*ied_t* ied;
ied = find_ied_from_dev_code(loginfo->LD_info->terminal_code);
ied_usr_t* ied_usr = (ied_usr_t*)ied->usr_ext;
json_block_create_start( loginfo->LD_info->voltage_level, loginfo->LD_info->mp_id,0, ied_usr->dev_type);*/
//json_block_create_time(loginfo->LD_info->line_id,t/1000);
}
}
//set_db_value(LOG_IDX,mms_ref,v,FALSE);
length_FCDA = strlen( mms_ref );
if ( ('$'==mms_ref[length_FCDA-2]) && ('q'==mms_ref[length_FCDA-1]) ) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
//printf("going q");
if(not_set_log_q_this && ( log_data_type == STEADY_DATA )) {
int quality = 0;
@@ -400,7 +377,6 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
printf("quality = 1 continue");
continue;
}
//set_log_QualityFlag(quality);
if (log_data_steady_type == 0) {
json_block_create_flag(loginfo->LD_info->mp_id, quality, 0);
}
@@ -415,9 +391,6 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
}
else if ( ('$'==mms_ref[length_FCDA-2]) && ('t'==mms_ref[length_FCDA-1]) ) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
//printf("going t");
if (not_set_log_t_this) {
apr_time_t t = convert_btime6_to_apr_time(&(mms_dec_data.data_item[ii].u.data_bTime6));
if ( log_data_type == QVVR_DATA ) {
@@ -445,8 +418,6 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
}
}
else {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
//printf("going v");
if ( log_data_type == QVVR_DATA ){
processQVVR_data(loginfo->LD_info,mms_ref,v);
@@ -471,7 +442,6 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
}
//mvl_type_id_destroy(var_type_id);
}
printf("\naft for");
if ( log_data_type == QVVR_DATA ) {
@@ -481,10 +451,9 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
processRDRE_end(loginfo->LD_info);
}
else {
//json_block_create_end(loginfo->LD_info->mp_id,0);
}
printf("\nend process_jou_entry");
//printf("process_jou_entry ==============%.2f================\n", last_check_recall_config_time);
return ret;
}
@@ -550,7 +519,7 @@ ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_n
int cpuno = 0;
chnl_usr = g_pt61850app->chnl_usr[i];
//printf("\n chnl_usr->m_state ===== %d\n", chnl_usr->m_state);
if (strstr(chnl_usr->ip_str, ip) != NULL)
{
printf("\nSame Ip %s : %s", chnl_usr->ip_str, ip);
@@ -614,25 +583,21 @@ ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_n
if( (last_occur_time.day!=jou_entry->occur_time.day)||(last_occur_time.ms!=jou_entry->occur_time.ms) ) {
last_occur_time=jou_entry->occur_time;
//append_db_records(LOG_IDX);
}
printf("\nbrf convert_btod_to_apr_time");
t = convert_btod_to_apr_time(&jou_entry->occur_time);
//set_log_TimeID(convert_btod_to_apr_time(&jou_entry->occur_time));
if (jou_entry->entry_form_tag == 2)
{
printf("\nbrf jou_entry->ef.data.list_of_var_pres");
if (jou_entry->ef.data.list_of_var_pres)
{
//for (j = 0; j < jou_entry->ef.data.num_of_var; j++)
//{
// printf ("\n Var # %d: var_tag = %s", j, jou_entry->ef.data.list_of_var[j].var_tag);
// printf ("\n Var # %d: value_spec.len = %d", j,jou_entry->ef.data.list_of_var[j].value_spec.len);
//}
start = sGetMsTime();
printf("\nbrf process_jou_entry");
process_jou_entry(loginfo,t,jou_entry, clientNetInfo, dom_name, iTimeout) ;
//start = sGetMsTime();
if ( jread_resp->more_follows == 0 && ((i + 1) == jread_resp->num_of_jou_entry)) {
printf("\njread_resp->more_follows == 0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
//lnk2024-8-16<31><36><EFBFBD>ӽ<EFBFBD><D3BD>߲<EFBFBD><DFB2><EFBFBD>
@@ -650,14 +615,11 @@ ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_n
end = sGetMsTime();
}
last_check_recall_config_time = last_check_recall_config_time + end - start;
//printf("jread_resp->more_follows = 0 ==============%.2f================\n", last_check_recall_config_time);
}
else {
printf ("\n annotation = %s", jou_entry->ef.annotation);
}
//apr_time_exp_t newTime;
//apr_time_exp_gmt(&newTime, t);
printf("\nstart timecheck");
apr_time_exp_t newTime;
apr_time_exp_gmt(&newTime, process_jou_entry_t);
@@ -677,10 +639,6 @@ ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_n
}
mvl_free_req_ctrl (reqCtrl); /* CRITICAL: */
} while (more_follows);
//mvl_type_id_destroy(1);
//del_mvl_type_ctrl();
//printf("do while ==============%.2f================\n", last_check_recall_config_time);
//append_db_records(LOG_IDX);
return (ret);
}

View File

@@ -25,17 +25,17 @@ extern int g_front_seg_num;
#include "../include/rocketmq/SimpleProducer.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
////////////////////////////////////////////
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR* SD_CONST thisFileName = __FILE__;
#endif
extern RPT_TYPEIDS g_rpt_typeids;
//ied_info_t *my_info;
extern apr_pool_t* g_root_pool;
uint8_t set_mx_q;
//rdb_t *g_rdb = NULL;
node_t* g_node = NULL;
extern char g_my_conf_fname[256];
apr_pool_t* g_init_pool;
@@ -51,19 +51,10 @@ uint8_t set_mx_q;
pt61850app_t* g_pt61850app;
//application_t g_sysfile_app; //ϵͳ<CFB5>ļ<EFBFBD><C4BC><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ϣ<EFBFBD>
//int g_sysfile_appid = -1;
//char *g_sysfile_filedir;
//byte_t g_Master;
//byte_t g_protect_file; //0:<3A><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD> 1:<3A>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD>
//apr_time_t g_file_valid_time; //ֻ<>ٻ<EFBFBD>ָ<EFBFBD><D6B8>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>
//byte_t g_file_name_len; //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD>󳤶ȣ<F3B3A4B6>Ĭ<EFBFBD><C4AC>Ϊ40<34><30><EFBFBD><EFBFBD>Ϊ0ʱ<30><CAB1>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><E2B3A4>
//byte_t g_file_time_from; //<2F>ļ<EFBFBD><C4BC><EFBFBD>Чʱ<D0A7><CAB1>ȡֵ<C8A1>δ<EFBFBD><CEB4><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>1ȡϵͳʱ<CDB3><CAB1>
static void* APR_THREAD_FUNC rtdb_worker(apr_thread_t* thd, void* data);
static apr_status_t pt61850app_init();
//static apr_status_t app_process_command(command_t *cmd);
///////////////////////////////////////////////////////////////////////////////
extern int three_secs_enabled;
@@ -145,7 +136,7 @@ static apr_status_t read_DEV_idx_from_db()
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
ied = g_node->clients[iedno];
ied_usr = GET_IEDEXT_ADDR(ied);
//read_DEV_Index_from_db(ied->channel[0].addr, &ied_usr->dev_idx);
for (cpuno = 0; cpuno < ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
if (LD_info->LD_name == NULL)
@@ -153,12 +144,12 @@ static apr_status_t read_DEV_idx_from_db()
len = strlen(LD_info->LD_name);
tmp = LD_info->LD_name[len - 1] - '0';
LD_info->line_id = ied_usr->dev_idx * 10 + tmp;
//ret = read_line_infos_from_db(LD_info->line_id, &LD_info->SubV_Index,&LD_info->Dev_Index,&LD_info->Sub_Index,&LD_info->GD_Index);
if (ret != TRUE)
LD_info->line_id = -1;
if (LD_info->loginfo) {
loginfo = LD_info->loginfo[0];
//read_updatetime_from_db(ied->channel[0].addr, &loginfo->start_time);
}
}
}
@@ -168,7 +159,7 @@ static apr_status_t read_DEV_idx_from_db()
apr_status_t init_rdb()
{
apr_status_t rv;
// driver_t* driver;
rv = apr_pool_create(&g_init_pool, g_root_pool);
if (rv != APR_SUCCESS) {
return rv;
@@ -186,50 +177,28 @@ apr_status_t init_rdb()
if (rv != APR_SUCCESS) {
return rv;
}
//my_info = apr_pcalloc(g_run_pool,sizeof(ied_info_t));
rv = pt61850app_init();
if (rv != APR_SUCCESS) {
return rv;
}
/*rv = parse_json_cfg();
if ( rv != APR_SUCCESS) {
echo_errg("Failed to parse json define xml file! \n");
return rv;
}*/
init_config();
GetServerIndexFromDB();
/*lnk10-10*/
//<2F><><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>web<65>ӿ<EFBFBD>
//rv = parse_device_web_test_ext();
//rv = parse_device_web_test_dev();
//rv = parse_device_web_test_front_read();
//rv = parse_device_web_test_front_write();
rv = parse_device_cfg_web();
//rv = parse_device_cfg();
//rv = parse_device_cfg_json();
//rv = parse_device_cfg_pg();
if (rv != APR_SUCCESS) {
echo_errg("Parsed device config xml file with error,try to run! \n");
return rv;
}
/*lnk10-10*/
//rv = parse_line_cfg_web(); <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>ն<EFBFBD>̨<EFBFBD><CCA8>
//rv = parse_line_cfg();
//rv = parse_line_cfg_pg();
/*lnk10-10*/
rv = parse_model_cfg_web();
if (rv != APR_SUCCESS) {
echo_errg("Parsed model with error,try to run! \n");
return rv;
}
//OTL_Select_xmlModel(); //xmlģ<6C><C4A3><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ȡ
Set_xml_nodeinfo();//<2F><><EFBFBD><EFBFBD>xmlģ<6C><C4A3>
rv = parse_rpt_log_ini();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
@@ -253,7 +222,7 @@ apr_status_t run_protocol()
{
apr_status_t rv;
apr_thread_t* rtdb_thread;
// apr_thread_t* mms_thread;
static apr_threadattr_t* worker_attr = NULL;
//lnk20250214//<2F><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD>0<EFBFBD><30>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>̨<EFBFBD>ˣ<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>ٸ<EFBFBD><D9B8><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC>Ľ<EFBFBD><C4BD>̺<EFBFBD>
@@ -366,16 +335,6 @@ apr_status_t run_protocol()
}
//lnkɾ<6B><C9BE><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>߳<EFBFBD>
#if 0
if (1 == g_iOTLFlag) {
printf("try_start_sql_thread \n");
try_start_sql_thread();
}
else
printf("sql_thread ignore \n");
#endif
printf("try_start_ontimer_thread \n");
try_start_ontimer_thread();
@@ -387,44 +346,23 @@ extern uint32_t g_thread_blocked_times;
/*--------------------------- <20><><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD>߳<EFBFBD> -----------------------------------*/
static void* APR_THREAD_FUNC rtdb_worker(apr_thread_t* thd, void* data)
{
// apr_event_t event;
// command_t cmd[1];
// int i =0;
/* Maintenance the clients request */
while (1) {
//pthread_mutex_lock(&mtx); printf("work hold lock !!!!!!!!!!!");
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("check error4 !!!!!!!!!!!!!!\n");
doCommService();//<2F><><EFBFBD><EFBFBD>61850<35><30>Ϣ
check_3s_config();//3<><33><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>̶<EFBFBD>ȡ3<C8A1><EFBFBD><EBB4A5>
//pthread_mutex_lock(&mtx); printf("check connect hold lock !!!!!!!!!!!");
CheckNextNotConnectedChannel();//<2F><><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>״̬
//pthread_mutex_unlock(&mtx); printf("check connect free lock !!!!!!!!!!!");
//pthread_mutex_lock(&mtx); printf("check prt hold lock !!!!!!!!!!!");
CheckAllConnectedChannel();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6A1A2>־<EFBFBD><D6BE><EFBFBD>١<EFBFBD><D9A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//pthread_mutex_unlock(&mtx); printf("check prt free lock !!!!!!!!!!!");
//check_recall_config();//<2F><><EFBFBD>ٽ<EFBFBD><D9BD>̶<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
create_recall_xml();//<2F><><EFBFBD>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD><EFBFBD>xml<6D>ļ<EFBFBD>
pthread_mutex_lock(&mtx); //printf("work hold lock !!!!!!!!!!!");
pthread_mutex_lock(&mtx);
check_ledger_update();//lnk20250113<31><33>ȡ̨<C8A1>˸<EFBFBD><CBB8>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˸<EFBFBD><CBB8><EFBFBD>
pthread_mutex_unlock(&mtx);
pthread_mutex_unlock(&mtx); //printf("work free lock !!!!!!!!!!!");
//Check_Recall_Config();
/*if ((g_protect_file) && (g_pt61850app->initNum>=MIN_INIT_NUM) ) {
tryCallWaveList_in_AllIeds();
}*/
//clear_old_comtrade_files();
check_disk_quota();//<2F>жϴ<D0B6><CFB4>̿ռ<CCBF>
apr_pool_clear(g_pt61850app->tmp_pool);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
@@ -436,7 +374,6 @@ static void* APR_THREAD_FUNC rtdb_worker(apr_thread_t* thd, void* data)
echo_msg("rtdb worker thread terminated...");
}
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
void Set_val_from_61850rpt(element_t* elem, double v)
@@ -453,7 +390,6 @@ int Set_q_from_61850rpt(char* q)
else
quality = 1;
return quality;
//set_rpt_QualityFlag(quality);
}
#define TIME_T_2036 (66*365* SECONDS_PER_DAY)
@@ -481,9 +417,6 @@ apr_time_t convert_btime6_to_apr_time(MMS_BTIME6* bTime6)
return ticks;
}
/*
61850
λ <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֵ
@@ -594,8 +527,3 @@ byte_t get_pulse_q_from_61850(char* q_61850)
else
return 0;
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////

View File

@@ -445,7 +445,6 @@ int SendMessageToWeb(int socketClient, int iErrorCode); //
void CheckAllConnectedChannel() ;
void check_3s_config();
void check_recall_config();
void create_recall_xml();
void check_disk_quota();

View File

@@ -549,15 +549,6 @@ void processQVVR_end(LD_info_t* LD_info)
if ( (LD_info->qvvr[i].QVVR_type==0)||(LD_info->qvvr[i].QVVR_type==LD_info->qvvr[LD_info->qvvr_idx].QVVR_type) ) {
long long end_tm = (long long)(LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime*1000) + LD_info->qvvr[i].QVVR_time;//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>dz<EFBFBD><C7B3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("~~~~~~~this qvvr node type before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_type);
//printf("~~~~~~~this qvvr node QVVR_PerTime before record is %f~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_PerTime);
//printf("~~~~~~~this qvvr node QVVR_Amg before record is %f~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_Amg);
//printf("~~~~~~~this qvvr node QVVR_time before record is %lld~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_time);
//printf("~~~~~~~this qvvr node used_status before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].used_status);
//printf("~~~~~~~this qvvr node QVVR_start before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_start);
//printf("~~~~~~~this qvvr node timestamp before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].timestamp);
printf("\n~~~~~~~now qvvr node type before record is %d~~~~~~~~~~ \n",LD_info->qvvr[LD_info->qvvr_idx].QVVR_type);
printf("~~~~~~~now qvvr node QVVR_PerTime before record is %f~~~~~~~~~~ \n",LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime);
@@ -583,12 +574,6 @@ void processQVVR_end(LD_info_t* LD_info)
printf("~~~~~~~this qvvr node timestamp before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].timestamp);
printf("~~~~~~~this qvvr node QVVR_start before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_start);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("\n~~~~~~~qvvr node %d status is pair~~~~~~~~~~ \n",i);
//printf("Before calling: &QVVR_Amg = %p, &QVVR_PerTime = %p\n",
//&LD_info->qvvr[LD_info->qvvr_idx].QVVR_Amg,
//&LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime);
//ƥ<><C6A5><EFBFBD><EFBFBD><EFBFBD>ٷ<EFBFBD>qvvr<76><72><EFBFBD><EFBFBD>ʼʱ<CABC><CAB1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A3AC><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ʱֻ<CAB1><D6BB>ʱ<EFBFBD><CAB1>û<EFBFBD><C3BB>ֵ<EFBFBD><D6B5><EFBFBD>Ǹ<EFBFBD>ʱ<EFBFBD><CAB1>
ret = transfer_json_qvvr_data(g_node_id, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ʹ<EFBFBD><CAB9>
LD_info->line_id, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>