2025-01-16 16:17:01 +08:00
/**
* @ file : $ RCSfile : mms_process . c , v $
* @ brief : $ PROFIBUS <EFBFBD> <EFBFBD> SSRTDB <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*
* @ version : $ Revision : 1.28 $
* @ date : $ Date : 2022 / 11 / 28 07 : 13 : 13 $
* @ author : $ Author : lizhongming $
* @ state : $ State : Exp $
*
* @ latest : $ Id : mms_process . c , v 1.28 2022 / 11 / 28 07 : 13 : 13 lizhongming Exp $
*/
# include <string.h>
# include "rdb_client.h"
//#include "../misc/utf8_to_gb.h"
//#include "../misc/gb_to_utf8.h"
# include <stdlib.h>
# include "db_interface.h"
# include "node.h"
# include "ied.h"
# include "../json/mms_json_inter.h"
void clear_rpt_counter_by_trigger ( trigger_t * trigger ) ;
//lnk20241031
extern void SOEFileWeb ( char * localpath , char * cloudpath , char * wavepath ) ;
//lnk 2024-11-4 <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> ת<EFBFBD> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
char * convertMsToDateTimeString ( int msTime ) ;
//lnk20250115
extern pthread_mutex_t mtx ;
extern apr_pool_t * g_cfg_pool ;
extern apr_pool_t * g_init_pool ;
extern int g_DevFlag ;
//lnk20250115end
# ifdef DEBUG_SISCO
SD_CONST static ST_CHAR * SD_CONST thisFileName = __FILE__ ;
# endif
# ifdef _OS_UNIX_
# include <sys/vfs.h>
# endif
extern uint32_t g_dead_lock_counter ;
extern uint32_t g_thread_blocked_times ;
extern uint16_t g_client_id ;
extern RPT_TYPEIDS g_rpt_typeids ;
//extern rdb_t *g_rdb ;
extern node_t * g_node ;
extern char g_my_conf_fname [ 256 ] ;
extern apr_pool_t * g_init_pool ;
extern apr_pool_t * g_run_pool ;
extern pt61850app_t * g_pt61850app ;
//extern char *g_sysfile_filedir;
extern char g_onlyIP [ 255 ] ; //ֱ<> <D6B1> ij<EFBFBD> <C4B3> IP<49> <50> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//extern int g_sysfile_appid; //add by rzx
//extern apr_time_t g_file_valid_time;
extern uint32_t g_min_free_size ;
/////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
extern uint32_t g_node_id ;
extern int three_secs_enabled ;
extern int auto_register_report_enabled ;
extern int FRONT_MP_NUM ;
///////////////////////////////////////////////////////////////////////////////
extern int FILE_FLAG ;
extern int recall_len ;
extern int recall_sta ;
extern int recall_daily ;
extern char * UDS_UPLOAD_URL ;
///////////////////////////////////////////////////////////////////
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 \t inited " , chnl_usr - > ip_str , ied - > channel [ chnl_no ] . port ) ;
add_comm_log ( comm_str ) ;
}
}
}
return APR_SUCCESS ;
}
void CloseIECReports ( chnl_usr_t * chnl_usr )
{
ied_t * ied ;
ied_usr_t * ied_usr ;
LD_info_t * LD_info ;
rptinfo_t * rptinfo = NULL ;
int cpuno , rpt_no ;
ST_RET ret ;
ied = chnl_usr - > chnl - > ied ;
ied_usr = GET_IEDEXT_ADDR ( ied ) ;
for ( cpuno = 0 ; cpuno < ied - > cpucount ; cpuno + + ) {
LD_info = & ( ied_usr - > LD_info [ cpuno ] ) ;
for ( rpt_no = 0 ; rpt_no < LD_info - > rptcount ; rpt_no + + ) {
char rpt_inst_name [ 65 ] ;
rptinfo = LD_info - > rptinfo [ rpt_no ] ;
if ( ! rptinfo - > rpt_registered )
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 ;
rptinfo - > m_rcb_info = NULL ;
}
}
}
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 ] ;
memset ( comm_str , 0 , 256 ) ;
apr_snprintf ( comm_str , sizeof ( comm_str ) , " %16s:%d \t \t disconnected !!! " , chnl_usr - > ip_str , chnl_usr - > chnl - > port ) ;
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 ) ;
if ( chnl_usr - > net_info ) {
ALL_RCB_INFO * all_rcb_info ;
RCB_INFO * rcb_info ;
ST_RET ret ;
if ( chnl_usr - > net_info - > user_info )
{
all_rcb_info = ( ALL_RCB_INFO * ) chnl_usr - > net_info - > user_info ;
while ( ( rcb_info = ( RCB_INFO * ) list_get_first ( & all_rcb_info - > rcb_info_list ) ) ! = NULL )
rcb_info_destroy ( rcb_info ) ;
chk_free ( all_rcb_info ) ;
chnl_usr - > net_info - > user_info = NULL ;
}
chnl_usr - > net_info - > rem_vmd = NULL ;
echo_warn ( " ---------start disconnectFromServer! \n " ) ;
ret = mms_disconnectFromServer ( chnl_usr - > net_info , & chnl_usr - > m_reqCtrl ) ;
echo_warn ( " ---------end disconnectFromServer! \n " ) ;
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 ;
chnl_usr - > m_ClosedMsTime = sGetMsTime ( ) ;
chnl_usr - > chnl - > status = STATUS_BREAKOFF ;
}
else {
chnl_usr - > m_state = CHANNEL_DISCONNECTING ;
chnl_usr - > m_StartDisconnectingTime = sGetMsTime ( ) ;
}
} else {
chnl_usr - > m_state = CHANNEL_DISCONNECTED ;
chnl_usr - > m_ClosedMsTime = sGetMsTime ( ) ;
//cout<<"m_ClosedMsTime "<<m_ClosedMsTime<<endl;
chnl_usr - > chnl - > status = STATUS_BREAKOFF ;
}
}
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;
printf ( " Do nothing,m_state == CHANNEL_CONNECTING ,NetInfo = %x " , NetInfo ) ;
} else if ( chnl_usr - > m_state = = CHANNEL_CONNECTED )
{
closeChannel ( chnl_usr ) ;
} else if ( chnl_usr - > m_state = = CHANNEL_DISCONNECTING )
{ //do nothing;
printf ( " Do nothing,m_state == CHANNEL_DISCONNECTING ,NetInfo = %x " , NetInfo ) ;
} else if ( chnl_usr - > m_state = = CHANNEL_DISCONNECTED )
{ //do nothing;
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);
}
void IECReport_tryGI ( chnl_usr_t * chnl_usr , rptinfo_t * rptinfo )
{
char varName [ 64 ] = " " ;
ST_BOOLEAN GI = TRUE ; /* call GI */
if ( ( sGetMsTime ( ) - rptinfo - > m_LastGITime ) < g_pt61850app - > giTime * 1000 )
return ;
rptinfo - > m_LastGITime = sGetMsTime ( ) ;
get_rpt_inst_name ( rptinfo , varName ) ;
strcat ( varName , " $GI " ) ;
mms_named_var_write ( chnl_usr - > net_info , varName , DOM_SPEC , rptinfo - > LD_info - > LD_name ,
g_rpt_typeids . mmsbool , ( ST_CHAR * ) & GI , g_pt61850app - > mmsOpTimeout ) ;
}
//<2F> <> <EFBFBD> Ӵ<EFBFBD> <D3B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̬<EFBFBD> <CCAC> <EFBFBD> ܵȣ <DCB5> <C8A3> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> <C7B7> <EFBFBD> Ҫע<D2AA> ᡢȡ<E1A1A2> <C8A1> ע<EFBFBD> <D7A2> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> κδ<CEBA> <CEB4> <EFBFBD>
int judge_rpt_next_should_do ( rptinfo_t * rptinfo )
{
int should_register_state = 1 ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ĭ<EFBFBD> <C4AC> ע<EFBFBD> <D7A2>
int is_real_report = ( rptinfo - > report_PQ_type & REPORT_TYPE_REAL ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> а <EFBFBD> <D0B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
int is_soe_report = ( rptinfo - > report_PQ_type & REPORT_TYPE_SOE ) ;
if ( three_secs_enabled ) {
should_register_state = 0 ; //3<> 빦<EFBFBD> <EBB9A6> ģ<EFBFBD> 飬Ĭ<E9A3AC> ϲ <EFBFBD> ע<EFBFBD> <D7A2>
if ( is_real_report ) { //ӳ<> <D3B3> <EFBFBD> а <EFBFBD> <D0B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƿ<EFBFBD> <C6BF> Ҵ<EFBFBD> <D2B4> <EFBFBD>
should_register_state = rptinfo - > LD_info - > real_data ;
}
if ( is_soe_report ) {
should_register_state = rptinfo - > LD_info - > soe_data ;
}
}
if ( should_register_state = = rptinfo - > rpt_registered ) //<2F> Ѿ<EFBFBD> <D1BE> <EFBFBD> <EFBFBD> <EFBFBD> /û<> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> û<EFBFBD> б 䶯
return SHOULD_DO_NOTHING ;
else if ( should_register_state ) //<2F> б 䶯<D0B1> <E4B6AF> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD>
return SHOULD_REGISTER ;
else
return SHOULD_UNREGISTER ; //<2F> б 䶯<D0B1> <E4B6AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
}
void ChannelCheckIECReports ( chnl_usr_t * chnl_usr )
{
ied_t * ied ;
ied_usr_t * ied_usr ;
LD_info_t * LD_info ;
rptinfo_t * rptinfo = NULL ;
channel_t * channel = NULL ;
int cpuno , rpt_no ;
char rpt_inst_name [ 65 ] ;
ST_RET ret ;
ied = chnl_usr - > chnl - > ied ;
ied_usr = GET_IEDEXT_ADDR ( ied ) ;
channel = chnl_usr - > chnl ;
//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 ] ;
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>
RCB_INFO * rcb_info ;
printf ( " start mms_register_iec_rpt................................ \n " ) ;
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 ( " \n Register 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 ;
}
printf ( " end mms_register_iec_rpt................................ \n " ) ;
}
}
else { //rpt_registered ==TRUE
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 " ,
APR_EGENERAL , LD_info - > ied - > id , LD_info - > cpuno , LD_info - > LD_name , rpt_inst_name , chnl_usr - > ip_str , chnl_usr - > chnl_id ) ;
}
else {
rptinfo - > rpt_registered = FALSE ;
echo_msg7 ( " \n UnRegister iec_rpt succeed, IED_ID=%d ,CPU=%d ,domain: %s ,rpt_inst_name: %s ,ip: %s:%d,chnl_id: %d \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 ) ;
}
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
}
}
}
void ChannelCheckWaveFiles ( chnl_usr_t * chnl_usr )
{
ied_t * ied ;
ied_usr_t * ied_usr ;
LD_info_t * LD_info ;
int cpuno ;
ied = chnl_usr - > chnl - > ied ;
ied_usr = GET_IEDEXT_ADDR ( ied ) ;
for ( cpuno = 0 ; cpuno < ied - > cpucount ; cpuno + + ) {
LD_info = & ( ied_usr - > LD_info [ cpuno ] ) ;
if ( LD_info - > line_id < = 0 ) {
continue ;
}
call_cn_wavelist ( LD_info ) ; //try to call wave file
}
}
void ChannelCheckIECLogs ( chnl_usr_t * chnl_usr )
{
ST_RET ret ;
ied_t * ied ;
ied_usr_t * ied_usr ;
LD_info_t * LD_info ;
loginfo_t * loginfo = NULL ;
int cpuno ;
double now ;
static double last_check_recall_config_time = 0.0 ;
ied = chnl_usr - > chnl - > ied ;
ied_usr = GET_IEDEXT_ADDR ( ied ) ;
for ( cpuno = 0 ; cpuno < ied - > cpucount ; cpuno + + ) {
LD_info = & ( ied_usr - > LD_info [ cpuno ] ) ;
if ( LD_info - > logcount < = 0 )
continue ;
loginfo = LD_info - > loginfo [ 0 ] ;
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 ;
for ( i = 0 ; i < LD_info - > autorecallcount ; i + + ) {
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 ) {
echo_warn6 ( " \n mms_jread Failed! 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 ) ;
failed_count + + ;
}
del_mvl_type_ctrl ( ) ;
loginfo - > need_steady = 0 ;
loginfo - > need_voltage = 0 ;
loginfo - > start_time = loginfo - > end_time ;
g_dead_lock_counter = 0 ;
g_thread_blocked_times = 0 ; //<2F> <> ֹ<EFBFBD> <D6B9> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ½<EFBFBD> <C2BD> <EFBFBD> <EFBFBD> ˳<EFBFBD>
now = sGetMsTime ( ) ;
last_check_recall_config_time = now ;
printf ( " end ==============%.2f================ \n " , last_check_recall_config_time ) ;
printf ( " end mms_jread................................ \n " ) ;
}
if ( failed_count = = 0 ) { //<2F> ɹ<EFBFBD>
Delete_recall_Xml ( LD_info - > mp_id ) ;
}
}
/*apr_time_from_sec(&loginfo->start_time, 1694275200);
apr_time_from_sec ( & loginfo - > end_time , 1694361600 ) ; */
}
}
void process_3s_config ( trigger_3s_xml_t * trigger_3s_xml )
{
int i , j ;
trigger_t * trigger ;
trigger_t * trigger_work ;
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 ;
printf ( " start process_3s_config \n " ) ;
need_write_file = FALSE ;
trigger = trigger_3s_xml - > new_triggers ; //3s<33> <73> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> е <EFBFBD> newtrigger<65> <72> <EFBFBD> 飬<EFBFBD> <E9A3AC> <EFBFBD> <EFBFBD> û<EFBFBD> <C3BB> newtrigger<65> <72> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 0
trigger_num = trigger_3s_xml - > new_trigger_num ;
for ( i = 0 ; i < trigger_num ; i + + ) {
new_in_work_found = FALSE ;
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 )
trigger_work - > soe_data = trigger [ i ] . soe_data ; //<2F> <> <EFBFBD> <EFBFBD> soe<6F> <65> ־
trigger_work - > limit = trigger [ i ] . limit ;
clear_rpt_counter_by_trigger ( trigger_work ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
new_in_work_found = TRUE ;
}
}
if ( ! new_in_work_found ) { //newtriggerΪ0<CEAA> <30> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȫ<EFBFBD> µĴ<C2B5> <C4B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڹ<EFBFBD> <DAB9> <EFBFBD> <EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD>
clear_rpt_counter_by_trigger ( & trigger [ i ] ) ;
if ( trigger [ i ] . real_data < 0 )
trigger [ i ] . real_data = 0 ;
if ( trigger [ i ] . soe_data < 0 )
trigger [ i ] . soe_data = 0 ;
trigger_3s_xml - > work_triggers [ trigger_3s_xml - > work_trigger_num + + ] = trigger [ i ] ;
}
need_write_file = TRUE ; //<2F> <> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD>
}
trigger = trigger_3s_xml - > delete_triggers ; //<2F> <> <EFBFBD> <EFBFBD> û<EFBFBD> <C3BB> deletetrigger<65> <72> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 0
trigger_num = trigger_3s_xml - > delete_trigger_num ;
for ( i = 0 ; i < trigger_num ; i + + ) {
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 ) {
clear_rpt_counter_by_trigger ( trigger_work ) ;
trigger_work - > dev_idx = INVALID_DEV_IDX ;
}
}
need_write_file = TRUE ;
}
trigger = trigger_3s_xml - > modify_triggers ; //<2F> <> <EFBFBD> <EFBFBD> û<EFBFBD> <C3BB> modifytrigger<65> <72> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 0
trigger_num = trigger_3s_xml - > modify_trigger_num ;
for ( i = 0 ; i < trigger_num ; i + + ) {
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 ] ;
clear_rpt_counter_by_trigger ( trigger_work ) ;
}
}
need_write_file = TRUE ;
}
clear_all_LD_real_soe_report_shoud_register ( ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ҫע<D2AA> <D7A2> <EFBFBD> ı <EFBFBD> <C4B1> 棬<EFBFBD> <E6A3AC> <EFBFBD> <EFBFBD> ʵʱ<CAB5> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʹ LD_info->real_data = 0;LD_info->soe_data = 0;<3B> Ͳ<EFBFBD> <CDB2> ᴥ<EFBFBD> <E1B4A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
trigger = trigger_3s_xml - > work_triggers ; //<2F> ļ<EFBFBD> <C4BC> <EFBFBD> work<72> <6B>
trigger_num = trigger_3s_xml - > work_trigger_num ;
for ( i = 0 ; i < trigger_num ; i + + ) { //<2F> <> <EFBFBD> <EFBFBD> work<72> <6B> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD>
int real_report_count = 0 ; //ʵʱ<CAB5> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( trigger [ i ] . dev_idx = = INVALID_DEV_IDX ) { //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ն˺<D5B6>
printf ( " dev_idx incaild \n " ) ;
continue ;
}
ied = find_ied_from_dev_idx ( trigger [ i ] . dev_idx ) ; //ͨ<> <CDA8> <EFBFBD> ļ<EFBFBD> <C4BC> е <EFBFBD> dev<65> <76> <EFBFBD> ҵ<EFBFBD> <D2B5> <EFBFBD> <EFBFBD> õ<EFBFBD> <C3B5> 豸<EFBFBD> <E8B1B8> <EFBFBD> Ҳ<EFBFBD> <D2B2> <EFBFBD> ˵<EFBFBD> <CBB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̵<EFBFBD> ʵ<EFBFBD> <CAB5> <EFBFBD> Ƿ<EFBFBD> <C7B7> б <EFBFBD> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ҫʵ<D2AA> ־͵<D6BE> ÿ<EFBFBD> <C3BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ¼<C4BF> <C2BC>
if ( ! ied ) {
printf ( " can't find ied by dev_idx \n " ) ;
continue ;
}
LD_info = find_LD_info_from_line_id ( ied , trigger [ i ] . line_id ) ; //<2F> <> <EFBFBD> ļ<EFBFBD> <C4BC> е ļ<D0B5> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ҵ<EFBFBD> <D2B5> <EFBFBD> <EFBFBD> õļ<C3B5> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ! LD_info ) {
printf ( " can't find line by line_idx \n " ) ;
continue ;
}
real_report_count = get_real_report_count ( LD_info ) ; //<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʵʱ<CAB5> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> LD_info->rptinfo[rpt_no]->count
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
printf ( " terminal:%s - mp:%s real_report_count %d \n " , ( ( ied_usr_t * ) ( ied - > usr_ext ) ) - > terminal_id , LD_info - > mp_id , real_report_count ) ;
trigger [ i ] . count = real_report_count ; //<2F> <> ¼<EFBFBD> <C2BC> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʵʱ<CAB5> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( trigger [ i ] . real_data & & trigger [ i ] . limit & & ( real_report_count > trigger [ i ] . limit ) ) { //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʵʱ<CAB5> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڵ<EFBFBD> ǰ<EFBFBD> ļ<EFBFBD> <C4BC> е <EFBFBD> <D0B5> <EFBFBD> <EFBFBD> ƣ<EFBFBD> <C6A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 㲻<EFBFBD> ٴ<EFBFBD> <D9B4> <EFBFBD>
trigger [ i ] . real_data = 0 ;
trigger [ i ] . limit = 0 ;
trigger [ i ] . count = 0 ;
need_write_file = TRUE ;
}
LD_info - > real_data = trigger [ i ] . real_data ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> е <EFBFBD> <D0B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ã<EFBFBD> Ȼ<EFBFBD> <C8BB> <EFBFBD> ڱ<EFBFBD> <DAB1> 津<EFBFBD> <E6B4A5> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> ʵʱ<CAB5> <CAB1> <EFBFBD> <EFBFBD>
LD_info - > soe_data = trigger [ i ] . soe_data ;
LD_info - > limit = trigger [ i ] . limit ;
LD_info - > count = trigger [ i ] . count ;
if ( LD_info - > limit > 0 ) //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> ¼
need_write_file = TRUE ;
if ( trigger [ i ] . real_data = = 0 & & trigger [ i ] . soe_data = = 0 ) //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼
need_write_file = TRUE ;
}
if ( need_write_file )
create_3s_xml ( trigger_3s_xml ) ; //д<> <D0B4> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> work<72> <6B>
}
void del_process_recall_config ( recall_xml_t * recall_xml )
{
int i , j ;
recall_t * recall ;
recall_t * recall_work ;
int recall_num ;
ied_t * ied ;
LD_info_t * LD_info ;
loginfo_t * loginfo = NULL ;
int need_write_file ;
need_write_file = FALSE ;
recall = recall_xml - > new_recalls ;
recall_num = recall_xml - > new_recall_num ;
for ( i = 0 ; i < recall_num ; i + + ) {
recall_xml - > work_recalls [ recall_xml - > work_recall_num + + ] = recall [ i ] ;
need_write_file = TRUE ;
}
recall = recall_xml - > work_recalls ;
recall_num = recall_xml - > work_recall_num ;
for ( i = 0 ; i < recall_num ; i + + ) {
LD_info = find_LD_info_only_from_line_id ( recall [ i ] . line_id ) ;
if ( ! LD_info )
continue ;
if ( LD_info - > logcount < = 0 )
continue ;
loginfo = LD_info - > loginfo [ 0 ] ;
loginfo - > need_steady = recall [ i ] . need_steady ;
loginfo - > need_voltage = recall [ i ] . need_voltage ;
loginfo - > start_time = recall [ i ] . start_time ;
loginfo - > end_time = recall [ i ] . end_time ;
}
//remove_recall_xml();
}
void check_3s_config ( )
{
double now ;
static double last_check_3s_config_time = 0.0 ; //<2F> <> ʼ <EFBFBD> <CABC> ʱ<EFBFBD> <CAB1>
trigger_3s_xml_t trigger_3s_xml ; //3s<33> <73> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD>
if ( ! three_secs_enabled ) //cfg_3s_data<74> <61> <EFBFBD> ̲ŻῪ<C5BB> <E1BFAA>
return ;
now = sGetMsTime ( ) ; //<2F> <> ǰʱ<C7B0> <CAB1>
if ( fabs ( now - last_check_3s_config_time ) < 3 * 1000 ) //wait 3secs //<2F> <> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ִ<EFBFBD> <D6B4> ʱ<EFBFBD> 鿴<EFBFBD> <E9BFB4> ǰʱ<C7B0> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> ϴ<EFBFBD> ִ<EFBFBD> <D6B4> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С <EFBFBD> <D0A1> 3<EFBFBD> 벻ִ<EBB2BB> У <EFBFBD> <D0A3> <EFBFBD> <EFBFBD> ڵ<EFBFBD> <DAB5> <EFBFBD> 3<EFBFBD> <33> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ִ<EFBFBD> <D6B4>
return ;
printf ( " begin 3s config... \n " ) ;
last_check_3s_config_time = now ; //<2F> <> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
while ( APR_SUCCESS = = parse_3s_xml ( & trigger_3s_xml ) ) { //<2F> <> <EFBFBD> <EFBFBD> 3<EFBFBD> <33> <EFBFBD> ļ<EFBFBD>
//<2F> <> <EFBFBD> <EFBFBD> ʵʱ<CAB5> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> lnk20250114
pthread_mutex_lock ( & mtx ) ;
process_3s_config ( & trigger_3s_xml ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pthread_mutex_unlock ( & mtx ) ;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//lnk20250114<31> <34> <EFBFBD> <EFBFBD> ʵʱ<CAB5> <CAB1> <EFBFBD> ݷ<EFBFBD> <DDB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> Ϣ
void process_ledger_update ( trigger_update_xml_t * ledger_update_xml )
{
int i , j ;
terminal * update ;
terminal * update_work ;
int update_num ;
ied_t * ied ;
LD_info_t * LD_info ;
int need_write_file ;
int new_in_work_found ;
ied_usr_t * ied_usr ;
chnl_usr_t * chnl_usr ;
printf ( " !!!start update ledger!!! \n " ) ;
need_write_file = FALSE ; //д<> <D0B4> ̨<EFBFBD> ˸ <EFBFBD> <CBB8> ¼<EFBFBD> ¼<EFBFBD> ļ<EFBFBD>
update = ledger_update_xml - > new_updates ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̨<EFBFBD> ˲<EFBFBD> <CBB2> <EFBFBD>
update_num = ledger_update_xml - > new_update_num ;
printf ( " add ledger num:%d \n " , update_num ) ;
for ( i = 0 ; i < update_num ; i + + ) { //<2F> 鿴<EFBFBD> <E9BFB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̨<EFBFBD> <CCA8>
new_in_work_found = FALSE ;
2025-01-16 19:16:26 +08:00
if ( update [ i ] . terminal_id ! = NULL ) {
printf ( " ledger of %s \n " , update [ i ] . terminal_id ) ;
ied = find_ied_from_terminal_id ( update [ i ] . terminal_id ) ; //ͨ<> <CDA8> <EFBFBD> ļ<EFBFBD> <C4BC> е <EFBFBD> <D0B5> ն˺<D5B6> <CBBA> ҵ<EFBFBD> <D2B5> <EFBFBD> <EFBFBD> õ<EFBFBD> <C3B5> 豸
if ( ied ) {
printf ( " find ied by terminal_id, terminal already exsist \n " ) ;
new_in_work_found = TRUE ; //<2F> <> ǰ<EFBFBD> <C7B0> <EFBFBD> е <EFBFBD> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> <EFBFBD> ҵ<EFBFBD> <D2B5> <EFBFBD> <EFBFBD> <EFBFBD> ̨<EFBFBD> ˣ<EFBFBD> <CBA3> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD>
// <20> <> <EFBFBD> <EFBFBD> ǰ<EFBFBD> ն˴ <D5B6> new_updates <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƶ<EFBFBD> modify_updates <20> <> <EFBFBD> <EFBFBD>
if ( ledger_update_xml - > modify_update_num < MAX_UPDATEA_NUM ) {
// <20> <> <EFBFBD> ӵ<EFBFBD> modify_updates <20> <> <EFBFBD> <EFBFBD>
ledger_update_xml - > modify_updates [ ledger_update_xml - > modify_update_num ] = update [ i ] ;
ledger_update_xml - > modify_update_num + + ; // <20> <> <EFBFBD> <EFBFBD> modify <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD>
// ɾ<> <C9BE> <EFBFBD> <EFBFBD> <EFBFBD> նˣ<D5B6> <CBA3> <EFBFBD> new_updates <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƴ<EFBFBD> <C6B3> <EFBFBD>
for ( j = i ; j < ledger_update_xml - > new_update_num - 1 ; j + + ) {
ledger_update_xml - > new_updates [ j ] = ledger_update_xml - > new_updates [ j + 1 ] ; // <20> <> ǰ<EFBFBD> ƶ<EFBFBD> Ԫ<EFBFBD> <D4AA>
}
ledger_update_xml - > new_update_num - - ; // <20> <> <EFBFBD> <EFBFBD> new_update_num<75> <6D> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> Ԫ<EFBFBD> <D4AA>
continue ;
} else {
fprintf ( stderr , " Exceeded MAX_UPDATEA_NUM limit for modify_updates! \n " ) ;
}
}
}
2025-01-16 16:17:01 +08:00
if ( ! new_in_work_found ) { //<2F> <> <EFBFBD> <EFBFBD> ȫ<EFBFBD> µ<EFBFBD> ̨<EFBFBD> ˣ<EFBFBD> <CBA3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڹ<EFBFBD> <DAB9> <EFBFBD> <EFBFBD> <EFBFBD> ̨<EFBFBD> <CCA8>
//<2F> <> <EFBFBD> <EFBFBD> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> <EFBFBD> Ӻͳ<D3BA> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//1-<2D> <> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> <C2B5> ڴ<EFBFBD> <DAB4> ռ <EFBFBD> //////////////////////////////
//<2F> µ<EFBFBD> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (n_clients) <20> <> ԭ<EFBFBD> е <EFBFBD> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (ԭ<> <D4AD> <EFBFBD> <EFBFBD> Ϊ g_node->n_clients)
int new_client_count = g_node - > n_clients + 1 ; // <20> <> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> µ<EFBFBD> ̨<EFBFBD> <CCA8>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> <C2B5> ڴ<EFBFBD> <DAB4> ռ 䣺ԭ<E4A3BA> <D4AD> <EFBFBD> <EFBFBD> clients ָ<> <D6B8> һ <EFBFBD> <D2BB> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> 飬<EFBFBD> <E9A3AC> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> µ<EFBFBD> <C2B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD>
ied_t * * new_clients = ( ied_t * * ) apr_pcalloc ( g_cfg_pool , new_client_count * sizeof ( ied_t * ) ) ;
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> <DDB5> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
int k ;
for ( k = 0 ; k < g_node - > n_clients ; k + + ) {
new_clients [ k ] = g_node - > clients [ k ] ;
}
// Ϊ<> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
new_clients [ g_node - > n_clients ] = ( ied_t * ) apr_pcalloc ( g_cfg_pool , sizeof ( ied_t ) ) ;
// <20> <> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
g_node - > clients = new_clients ; // <20> <> clients ָ<> <D6B8> <EFBFBD> µ<EFBFBD> <C2B5> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
g_node - > n_clients = new_client_count ; // <20> <> <EFBFBD> <EFBFBD> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//1-<2D> <> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> <C2B5> ڴ<EFBFBD> <DAB4> ռ <EFBFBD> //////////////////////////////
//2-<2D> <> <EFBFBD> <EFBFBD> <EFBFBD> ն<EFBFBD> ̨<EFBFBD> <CCA8> ///////////////////////////////////
ied = g_node - > clients [ new_client_count - 1 ] ; //<2F> ն<EFBFBD> ̨<EFBFBD> <CCA8> ָ<EFBFBD> 붨<EFBFBD> <EBB6A8> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ λ
ied_usr = ( ied_usr_t * ) apr_pcalloc ( g_init_pool , sizeof ( ied_usr_t ) ) ;
ied - > usr_ext = ied_usr ;
if ( ied_usr = = NULL )
return APR_ENOMEM ;
ied_usr - > last_call_wavelist_time = sGetMsTime ( ) + g_pt61850app - > giTime * 1000 ;
ied_usr - > LD_info = ( LD_info_t * ) apr_pcalloc ( g_init_pool , MAX_CPUNO * sizeof ( LD_info_t ) ) ;
if ( ied_usr - > LD_info = = NULL )
return APR_ENOMEM ;
ied_usr - > dev_flag = g_DevFlag ;
ied - > chncount = 1 ;
ied - > channel = ( channel_t * ) apr_pcalloc ( g_cfg_pool , sizeof ( channel_t ) * ied - > chncount ) ;
ied - > channel [ 0 ] . ied = ied ;
ied - > channel [ 0 ] . status = STATUS_BREAKOFF ;
ied - > cpucount = 0 ;
//2-<2D> <> <EFBFBD> <EFBFBD> <EFBFBD> ն<EFBFBD> ̨<EFBFBD> <CCA8> ///////////////////////////////////
//3-д<> <D0B4> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> //////////////////////////////
int ret = update_one_terminal_ledger ( update , i , ied , g_node - > n_clients ) ;
//3-д<> <D0B4> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ///////////////////////////////////
//4-<2D> <> <EFBFBD> <EFBFBD> ӳ<EFBFBD> <D3B3> <EFBFBD> ļ<EFBFBD> //////////////////////////////
//4-<2D> <> <EFBFBD> <EFBFBD> ӳ<EFBFBD> <D3B3> <EFBFBD> ļ<EFBFBD> ///////////////////////////////////
//5-<2D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʼ <EFBFBD> <CABC> //////////////////////////////
//5-<2D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʼ <EFBFBD> <CABC> ///////////////////////////////////
//6-init_rem_dib_table//////////////////////////////
//6-init_rem_dib_table///////////////////////////////////
}
need_write_file = TRUE ; //<2F> <> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̨<EFBFBD> <CCA8> д<EFBFBD> <D0B4> ̨<EFBFBD> ˸ <EFBFBD> <CBB8> ¼<EFBFBD> ¼<EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD>
}
//////////////////////////////////////////////////////////////////////////////
/*trigger = trigger_3s_xml->delete_triggers; //<2F> <> <EFBFBD> <EFBFBD> û<EFBFBD> <C3BB> delete<74> <65> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 0
trigger_num = trigger_3s_xml - > delete_trigger_num ;
for ( i = 0 ; i < trigger_num ; i + + ) {
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 ) {
clear_rpt_counter_by_trigger ( trigger_work ) ;
trigger_work - > dev_idx = INVALID_DEV_IDX ;
}
}
need_write_file = TRUE ;
}
//////////////////////////////////////////////////////////////////////////////
trigger = trigger_3s_xml - > modify_triggers ; //<2F> <> <EFBFBD> <EFBFBD> û<EFBFBD> <C3BB> modify<66> <79> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 0
trigger_num = trigger_3s_xml - > modify_trigger_num ;
for ( i = 0 ; i < trigger_num ; i + + ) {
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 ] ;
clear_rpt_counter_by_trigger ( trigger_work ) ;
}
}
need_write_file = TRUE ;
}
///////////////////////////////////////////////////////////////////////////////
trigger = trigger_3s_xml - > work_triggers ; //<2F> ļ<EFBFBD> <C4BC> <EFBFBD> work<72> <6B>
trigger_num = trigger_3s_xml - > work_trigger_num ;
if ( need_write_file )
create_3s_xml ( trigger_3s_xml ) ; //д<> <D0B4> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> work<72> <6B> */
}
//̨<> ˸ <EFBFBD> <CBB8> µ<EFBFBD> <C2B5> Դ<EFBFBD> ӡ<EFBFBD> <D3A1> <EFBFBD> <EFBFBD>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> Ϊ<EFBFBD> <CEAA>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> Ϊ<EFBFBD> <CEAA>
int is_empty ( const char * str ) {
return ( str = = NULL | | str [ 0 ] = = ' \0 ' ) ;
}
// <20> <> ӡ monitor <20> ṹ<EFBFBD> <E1B9B9> <EFBFBD> <EFBFBD> Ϣ
void print_monitor ( const monitor * mon ) {
printf ( " Monitor ID: %s \n " , is_empty ( mon - > monitor_id ) ? " N/A " : mon - > monitor_id ) ;
printf ( " Terminal Code: %s \n " , is_empty ( mon - > terminal_code ) ? " N/A " : mon - > terminal_code ) ;
printf ( " Monitor Name: %s \n " , is_empty ( mon - > monitor_name ) ? " N/A " : mon - > monitor_name ) ;
printf ( " Logical Device Sequence: %s \n " , is_empty ( mon - > logical_device_seq ) ? " N/A " : mon - > logical_device_seq ) ;
printf ( " Voltage Level: %s \n " , is_empty ( mon - > voltage_level ) ? " N/A " : mon - > voltage_level ) ;
printf ( " Terminal Connect: %s \n " , is_empty ( mon - > terminal_connect ) ? " N/A " : mon - > terminal_connect ) ;
printf ( " Timestamp: %s \n " , is_empty ( mon - > timestamp ) ? " N/A " : mon - > timestamp ) ;
printf ( " Status: %s \n " , is_empty ( mon - > status ) ? " N/A " : mon - > status ) ;
}
// <20> <> ӡ terminal <20> ṹ<EFBFBD> <E1B9B9> <EFBFBD> <EFBFBD> Ϣ
void print_terminal ( const terminal * tmnl ) {
printf ( " Terminal ID: %s \n " , is_empty ( tmnl - > terminal_id ) ? " N/A " : tmnl - > terminal_id ) ;
printf ( " Terminal Code: %s \n " , is_empty ( tmnl - > terminal_code ) ? " N/A " : tmnl - > terminal_code ) ;
printf ( " Organization Name: %s \n " , is_empty ( tmnl - > org_name ) ? " N/A " : tmnl - > org_name ) ;
printf ( " Maintenance Name: %s \n " , is_empty ( tmnl - > maint_name ) ? " N/A " : tmnl - > maint_name ) ;
printf ( " Station Name: %s \n " , is_empty ( tmnl - > station_name ) ? " N/A " : tmnl - > station_name ) ;
printf ( " Factory Name: %s \n " , is_empty ( tmnl - > tmnl_factory ) ? " N/A " : tmnl - > tmnl_factory ) ;
printf ( " Terminal Status: %s \n " , is_empty ( tmnl - > tmnl_status ) ? " N/A " : tmnl - > tmnl_status ) ;
printf ( " Device Type: %s \n " , is_empty ( tmnl - > dev_type ) ? " N/A " : tmnl - > dev_type ) ;
printf ( " Device Key: %s \n " , is_empty ( tmnl - > dev_key ) ? " N/A " : tmnl - > dev_key ) ;
printf ( " Device Series: %s \n " , is_empty ( tmnl - > dev_series ) ? " N/A " : tmnl - > dev_series ) ;
printf ( " Address: %s \n " , is_empty ( tmnl - > addr_str ) ? " N/A " : tmnl - > addr_str ) ;
printf ( " Port: %s \n " , is_empty ( tmnl - > port ) ? " N/A " : tmnl - > port ) ;
printf ( " Timestamp: %s \n " , is_empty ( tmnl - > timestamp ) ? " N/A " : tmnl - > timestamp ) ;
// <20> <> ӡ<EFBFBD> <D3A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֶ<EFBFBD> Ϊ<EFBFBD> գ <EFBFBD> <D5A3> <EFBFBD> <EFBFBD> <EFBFBD> ӡ N/A
int i ;
for ( i = 0 ; i < 10 & & ! is_empty ( tmnl - > line [ i ] . monitor_id ) ; + + i ) {
printf ( " Monitor %d: \n " , i + 1 ) ;
print_monitor ( & tmnl - > line [ i ] ) ;
}
}
// <20> <> ӡ trigger_update_xml_t <20> ṹ<EFBFBD> <E1B9B9> <EFBFBD> <EFBFBD> Ϣ
void print_trigger_update_xml ( const trigger_update_xml_t * trigger_update ) {
printf ( " Work Updates Count: %d \n " , trigger_update - > work_update_num ) ;
printf ( " New Updates Count: %d \n " , trigger_update - > new_update_num ) ;
printf ( " Delete Updates Count: %d \n " , trigger_update - > delete_update_num ) ;
printf ( " Modify Updates Count: %d \n " , trigger_update - > modify_update_num ) ;
printf ( " \n Work Updates: \n " ) ;
int i ;
for ( i = 0 ; i < trigger_update - > work_update_num ; + + i ) {
printf ( " Work Update %d: \n " , i + 1 ) ;
print_terminal ( & trigger_update - > work_updates [ i ] ) ;
}
printf ( " \n New Updates: \n " ) ;
for ( i = 0 ; i < trigger_update - > new_update_num ; + + i ) {
printf ( " New Update %d: \n " , i + 1 ) ;
print_terminal ( & trigger_update - > new_updates [ i ] ) ;
}
printf ( " \n Delete Updates: \n " ) ;
for ( i = 0 ; i < trigger_update - > delete_update_num ; + + i ) {
printf ( " Delete Update %d: \n " , i + 1 ) ;
print_terminal ( & trigger_update - > delete_updates [ i ] ) ;
}
printf ( " \n Modify Updates: \n " ) ;
for ( i = 0 ; i < trigger_update - > modify_update_num ; + + i ) {
printf ( " Modify Update %d: \n " , i + 1 ) ;
print_terminal ( & trigger_update - > modify_updates [ i ] ) ;
}
}
void check_ledger_update ( ) //lnk20250113
{
double now ;
static double last_check_3s_config_time = 0.0 ; //<2F> <> ʼ <EFBFBD> <CABC> ʱ<EFBFBD> <CAB1>
now = sGetMsTime ( ) ; //<2F> <> ǰʱ<C7B0> <CAB1>
if ( fabs ( now - last_check_3s_config_time ) < 3 * 1000 ) //wait 3secs //<2F> <> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ִ<EFBFBD> <D6B4> ʱ<EFBFBD> 鿴<EFBFBD> <E9BFB4> ǰʱ<C7B0> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> ϴ<EFBFBD> ִ<EFBFBD> <D6B4> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С <EFBFBD> <D0A1> 3<EFBFBD> 벻ִ<EBB2BB> У <EFBFBD> <D0A3> <EFBFBD> <EFBFBD> ڵ<EFBFBD> <DAB5> <EFBFBD> 3<EFBFBD> <33> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ִ<EFBFBD> <D6B4>
return ;
trigger_update_xml_t trigger_ledger_update_xml ; //̨<> ˸ <EFBFBD> <CBB8> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> ṹ
2025-01-16 19:16:26 +08:00
printf ( " check ledger update... \n " ) ;
last_check_3s_config_time = now ; //<2F> <> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
2025-01-16 16:17:01 +08:00
//<2F> ж<EFBFBD> <D0B6> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD> ִ<EFBFBD> <D6B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> նˣ<D5B6> <CBA3> <EFBFBD> ȡ<EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> ɾ<EFBFBD> <C9BE> <EFBFBD> ļ<EFBFBD>
while ( APR_SUCCESS = = parse_ledger_update_xml ( & trigger_ledger_update_xml ) ) { //<2F> <> <EFBFBD> <EFBFBD> ̨<EFBFBD> ˸ <EFBFBD> <CBB8> <EFBFBD> <EFBFBD> ļ<EFBFBD> ,<2C> <> <EFBFBD> <EFBFBD> <EFBFBD> п<EFBFBD> <D0BF> Ը<EFBFBD> <D4B8> »<EFBFBD> <C2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̨<EFBFBD> ˵<EFBFBD>
print_trigger_update_xml ( & trigger_ledger_update_xml ) ;
//<2F> <> <EFBFBD> <EFBFBD> ̨<EFBFBD> ˸ <EFBFBD> <CBB8> ¼<EFBFBD> ̨<EFBFBD> <CCA8> <EFBFBD> <EFBFBD> lnk20250114
pthread_mutex_lock ( & mtx ) ;
process_ledger_update ( & trigger_ledger_update_xml ) ; //̨<> ˸ <EFBFBD> <CBB8> <EFBFBD>
pthread_mutex_unlock ( & mtx ) ;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# ifdef _OS_UNIX_
uint32_t get_freedisk_MB ( uint32_t * totalSizeMB )
{
struct statfs diskInfo ;
unsigned long long totalBlocks = 0 ;
unsigned long long totalSize = 0 ;
size_t mbTotalsize = 0 ;
size_t freeDisk = 0 ;
size_t mbFreeDisk = 0 ;
statfs ( " /home/pq " , & diskInfo ) ;
totalBlocks = diskInfo . f_bsize ;
totalSize = totalBlocks * diskInfo . f_blocks ;
mbTotalsize = totalSize > > 20 ;
freeDisk = diskInfo . f_bfree * totalBlocks ;
mbFreeDisk = freeDisk > > 20 ;
printf ( " /home/pq total=%dMB, free=%dMB \n " , mbTotalsize , mbFreeDisk ) ;
if ( totalSizeMB )
* totalSizeMB = mbTotalsize ;
return mbFreeDisk ;
}
# else
uint32_t get_freedisk_MB ( uint32_t * totalSizeMB ) {
if ( totalSizeMB )
* totalSizeMB = 1000 ;
return 5 ;
}
# endif
void check_disk_quota ( )
{
double now ;
static double last_check_time = - 10000000.0 ;
uint32_t freeSizeMB , totalSizeMB ;
if ( g_node_id ! = STAT_DATA_BASE_NODE_ID )
return ;
now = sGetMsTime ( ) ;
if ( fabs ( now - last_check_time ) < 15 * 1000 ) //wait 15 secs
return ;
last_check_time = now ;
freeSizeMB = get_freedisk_MB ( & totalSizeMB ) ;
//printf("Current user disk free size: %dMB ,total size: %dMB \n",freeSizeMB,totalSizeMB);
if ( freeSizeMB < g_min_free_size )
echo_warn2 ( " Current user disk free size: %dMB < %dMB, please check! \n " , freeSizeMB , g_min_free_size ) ;
if ( ( freeSizeMB / ( totalSizeMB / 100 + 1 ) ) < 10 )
echo_warn2 ( " Current user disk free size percent < 10%%, free size: %dMB ,total size: %dMB ,please check! \n " ,
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>
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 ) ) {
DeletcRecallXml ( ) ;
CreateRecallXml ( ) ;
}
}
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();
}
}
void Check_Recall_Config ( char * id ) //<2F> <> <EFBFBD> 鲹<EFBFBD> <E9B2B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> Recall.xml
{
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 ) ) {
recall_xml_t recall_xml ;
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> <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>
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 ) )
ChannelCheckIECLogs ( chnl_usr ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD>
if ( ( sGetMsTime ( ) - chnl_usr - > m_LastPosRespTime ) > 15 * 1000 ) //wait 15 secs
{
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 ) ) ;
//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);
// }
//}
}
if ( chnl_usr - > m_state = = CHANNEL_CONNECTING ) //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
MVL_REQ_PEND * reqCtrl = chnl_usr - > m_reqCtrl ;
if ( reqCtrl - > done = = SD_TRUE )
{
if ( reqCtrl - > result = = SD_SUCCESS )
{
ALL_RCB_INFO * all_rcb_info ;
// cout<<endl<<endl<<pChannel->GetIP()<<" CHANNEL_CONNECTED netInfo "<<chnl_usr->net_info<<endl;
echo_warn4 ( " \n CHANNEL_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 ) ;
chnl_usr - > m_reqCtrl = NULL ;
chnl_usr - > m_state = CHANNEL_CONNECTED ;
chnl_usr - > net_info - > user_ext = chnl_usr ;
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 " ) ;
}
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 ) ;
apr_snprintf ( comm_str , sizeof ( comm_str ) , " %16s:%d \t \t connected " , chnl_usr - > ip_str , chnl_usr - > chnl - > port ) ;
add_comm_log ( comm_str ) ;
FRONT_MP_NUM + + ;
}
//lnk202411-1<> <31> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ӳɹ<D3B3> <C9B9> ļ<EFBFBD> ¼
ied_usr_t * ied_usr = ( ied_usr_t * ) chnl_usr - > chnl - > ied - > usr_ext ;
connectlog_pgsql ( ied_usr - > terminal_code , convertMsToDateTimeString ( ( int ) sGetMsTime ( ) ) , 1 ) ; //1<> ɹ<EFBFBD>
}
else
{ // solaris 9 <20> <> 224<32> <34>
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>
connectlog_pgsql ( ied_usr - > terminal_code , convertMsToDateTimeString ( ( int ) sGetMsTime ( ) ) , 0 ) ; //0ʧ<30> <CAA7>
}
printf ( " reqCtrl->result == FAIL, Since StartConnecting %i <20> <> ,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 ;
chnl_usr - > net_info - > rem_vmd = NULL ;
chnl_usr - > m_state = CHANNEL_DISCONNECTED ;
chnl_usr - > m_ClosedMsTime = sGetMsTime ( ) ;
}
}
else
{ //
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_code , convertMsToDateTimeString ( ( int ) 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 " ) ;
mvl_free_req_ctrl ( chnl_usr - > m_reqCtrl ) ;
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 )
{
if ( ( sGetMsTime ( ) - chnl_usr - > m_ClosedMsTime ) > NEXT_CONNECT_TIME ) //wait 10 secs
{
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 ) { //2023-09-26 czy <20> <> <EFBFBD> <EFBFBD> line count<0 <20> <> <EFBFBD> <EFBFBD> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD>
ret = mms_connectToServer ( ied_usr - > dev_key , ied_usr - > dev_series , serverARName , & ( chnl_usr - > net_info ) , & ( chnl_usr - > m_reqCtrl ) ) ;
if ( ret = = SD_SUCCESS )
{
//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> <C9B9> <EFBFBD> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ӵļ<D3B5> ¼
//connectlog_pgsql(ied_usr->terminal_code,convertMsToDateTimeString((int)sGetMsTime()),1);//1<> ɹ<EFBFBD>
}
else
{
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>
connectlog_pgsql ( ied_usr - > terminal_code , convertMsToDateTimeString ( ( int ) sGetMsTime ( ) ) , 0 ) ; //0ʧ<30> <CAA7>
}
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> ???
{
MVL_REQ_PEND * reqCtrl = chnl_usr - > m_reqCtrl ;
if ( reqCtrl - > done = = SD_TRUE )
{
//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 ;
chnl_usr - > m_ClosedMsTime = sGetMsTime ( ) ;
}
else
{ //
// 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 ;
chnl_usr - > net_info = NULL ;
chnl_usr - > m_state = CHANNEL_DISCONNECTED ;
chnl_usr - > m_ClosedMsTime = sGetMsTime ( ) ;
}
}
} //if(pChannel->m_state == CHANNEL_DISCONNECTING)
//////////////////
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////*********<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 ;
ST_CHAR * domName = LD_info - > LD_name ;
int Need_Destroy_Typeid = FALSE ;
assert ( chnl_usr & & LD_info ) ;
if ( type_id = = - 1 ) {
Need_Destroy_Typeid = TRUE ;
type_id = mms_var_type_id_create ( chnl_usr - > net_info , DOM_SPEC , domName , VarName , timeOut ) ;
if ( type_id = = - 1 ) ret = SD_FAILURE ; else ret = SD_SUCCESS ;
if ( ret = = SD_FAILURE ) return SD_FAILURE ;
}
ret = mms_named_var_read ( chnl_usr - > net_info , VarName , DOM_SPEC , domName , type_id , dataDest , timeOut ) ;
if ( Need_Destroy_Typeid )
if ( type_id ! = - 1 ) mvl_type_id_destroy ( type_id ) ;
return ret ;
}
static ST_RET Write_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 ;
ST_CHAR * domName = LD_info - > LD_name ;
int Need_Destroy_Typeid = FALSE ;
assert ( chnl_usr & & LD_info ) ;
if ( type_id = = - 1 ) {
Need_Destroy_Typeid = TRUE ;
type_id = mms_var_type_id_create ( chnl_usr - > net_info , DOM_SPEC , domName , VarName , timeOut ) ;
if ( type_id = = - 1 ) ret = SD_FAILURE ; else ret = SD_SUCCESS ;
if ( ret = = SD_FAILURE ) return SD_FAILURE ;
}
ret = mms_named_var_write ( chnl_usr - > net_info , VarName , DOM_SPEC , domName , type_id , dataDest , timeOut ) ;
if ( Need_Destroy_Typeid )
if ( type_id ! = - 1 ) mvl_type_id_destroy ( type_id ) ;
return ret ;
}
/*
< EnumType id = " ctlModelsEnum " >
< EnumVal ord = " 0 " > status - only < / EnumVal >
< EnumVal ord = " 1 " > direct - with - normal - security < / EnumVal >
< EnumVal ord = " 2 " > sbo - with - normal - security < / EnumVal >
< EnumVal ord = " 3 " > direct - with - enhanced - security < / EnumVal >
< EnumVal ord = " 4 " > sbo - with - enhanced - security < / EnumVal >
< / EnumType >
*/
# define TICKS_PER_MIN 60LL*1000LL*1000LL
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 ) ) ;
strcat ( only_filename_str , rem_filename ) ;
only_filename = only_filename_str ;
the_full_file = only_filename_str ;
while ( * the_full_file ! = 0 ) {
if ( * the_full_file = = ' / ' )
only_filename = the_full_file + 1 ;
the_full_file + + ;
}
memset ( rem_file_fullname , 0 , sizeof ( rem_file_fullname ) ) ;
if ( strstr ( rem_filename , " / " ) ! = NULL ) {
strcat ( rem_file_fullname , rem_filename ) ;
}
else {
strcat ( rem_file_fullname , g_pt61850app - > accPath ) ;
strcat ( rem_file_fullname , rem_filename ) ;
}
memset ( loc_file_fullname , 0 , sizeof ( loc_file_fullname ) ) ;
apr_snprintf ( loc_file_fullname , sizeof ( loc_file_fullname ) , " ../comtrade/%s " , only_filename ) ;
apr_snprintf ( only_filename_ret , 256 , " %s " , only_filename ) ;
printf ( " \n >>>>>>>>>****** Get wave file : %s from %s \n " , loc_file_fullname , rem_file_fullname ) ;
ret = mms_getFile ( chnl_usr - > net_info , loc_file_fullname , rem_file_fullname , g_pt61850app - > mmsOpTimeout ) ;
if ( ret = = SD_SUCCESS ) {
}
else {
echo_warn3 ( " >>>>>**** Error!!! %s mms_getFile wave file : %s from %s \n " , chnl_usr - > ip_str , loc_file_fullname , rem_file_fullname ) ;
}
return ret ;
}
apr_status_t prepare_call_cn_wavelist ( LD_info_t * LD_info , int FltNum )
{
int i ;
for ( i = 0 ; i < 256 ; i + + ) {
if ( LD_info - > FltNum [ i ] < = 0 ) {
LD_info - > FltNum [ i ] = FltNum ;
break ;
}
}
return APR_SUCCESS ;
}
apr_status_t call_cn_wavelist ( LD_info_t * LD_info )
{
int ret ;
int chnl_no ;
chnl_usr_t * chnl_usr = NULL ;
char * * filenames ;
int filenum ;
int i ;
char file_match_str [ 65 ] ;
char * ldstr ;
ied_t * ied = LD_info - > ied ;
ied_usr_t * ied_usr = GET_IEDEXT_ADDR ( ied ) ;
int have_new_files = FALSE ;
for ( i = 0 ; i < 256 ; i + + ) {
if ( LD_info - > FltNum [ i ] < = 0 )
continue ;
//LD<4C> <44> <EFBFBD> ƹ淶<C6B9> <E6B7B6> <EFBFBD> ֽڣ<D6BD> PQMn, <20> <> <EFBFBD> <EFBFBD> PQLDn ,<2C> <> 5<EFBFBD> <35> <EFBFBD> ֽڣ<D6BD> <20> <> Ҳֻȡ4<C8A1> <34> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5>
ldstr = LD_info - > LD_name + strlen ( LD_info - > LD_name ) - 4 ;
apr_snprintf ( file_match_str , sizeof ( file_match_str ) , " %s_%06d " , ldstr , LD_info - > FltNum [ i ] ) ;
printf ( " >>>>>>>> IED [%d]: %s is calling cn wavefile, !!!!!!!! file_match_str=%s \n " , ied - > id , ied - > name , file_match_str ) ;
ret = SD_FAILURE ;
filenum = 0 ;
assert ( ied - > chncount ) ;
for ( chnl_no = 0 ; chnl_no < ied - > chncount ; chnl_no + + ) {
chnl_usr = ( chnl_usr_t * ) ied - > channel [ chnl_no ] . connect ;
if ( chnl_usr - > m_state ! = CHANNEL_CONNECTED )
continue ;
ret = mms_mvla_fdir ( chnl_usr - > net_info , g_pt61850app - > accPath , 3 * g_pt61850app - > mmsOpTimeout , & filenames , & filenum , g_pt61850app - > tmp_pool ) ;
if ( ret = = SD_SUCCESS )
break ;
}
if ( ret = = SD_SUCCESS ) {
int cfg_idx , dat_idx ;
char file_base_name [ 128 ] ;
char file_yyyymm [ 128 ] ;
char cfg_only_filename_ret [ 256 ] ;
char dat_only_filename_ret [ 256 ] ;
int ret2 , ret3 ;
//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 ;
//<2F> <> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> dat/cfg_only_filename_ret<65> У <EFBFBD> <D0A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <D7BA> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> Ҫ<EFBFBD> ϴ<EFBFBD> <CFB4> <EFBFBD> <EFBFBD> <EFBFBD>
ret2 = pt61850_write_cn_file ( chnl_usr , ied , filenames [ cfg_idx ] , cfg_only_filename_ret ) ;
ret3 = pt61850_write_cn_file ( chnl_usr , ied , filenames [ dat_idx ] , dat_only_filename_ret ) ;
have_new_files = TRUE ;
/////////////////////////////////////////////////////////////////////////////////////////////<2F> ϴ<EFBFBD> <CFB4> ļ<EFBFBD>
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 ) {
//to find the paired qvvr by the time of trig_tm
qvvr = find_qvvr_by_trig_tm ( LD_info , trig_tm ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> Ĵ<EFBFBD> <C4B4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> Ҽ<EFBFBD> <D2BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> ƥ<EFBFBD> <C6A5> <EFBFBD> ϵ<EFBFBD> <CFB5> <EFBFBD> ̬<EFBFBD> ¼<EFBFBD>
if ( qvvr ) {
char * uuid_cfg = ( char * ) malloc ( 65 * sizeof ( char ) ) ; //<2F> ϴ<EFBFBD> <CFB4> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7>
char * uuid_dat = ( char * ) malloc ( 65 * sizeof ( char ) ) ;
char * filename_cfg = ( char * ) malloc ( 100 * sizeof ( char ) ) ; //<2F> ϴ<EFBFBD> <CFB4> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD>
char * filename_dat = ( char * ) malloc ( 100 * sizeof ( char ) ) ;
//lnk202411-5 <20> <> ¼web<65> <62> <EFBFBD> ص<EFBFBD> ·<EFBFBD> <C2B7> +<2B> ļ<EFBFBD> <C4BC> <EFBFBD>
char * wavepath_cfg = ( char * ) malloc ( 168 * sizeof ( char ) ) ;
char * wavepath_dat = ( char * ) malloc ( 168 * sizeof ( char ) ) ;
/*<2A> ϴ<EFBFBD> .cfg<66> <67> .dat<61> <74> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> */
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 ) ) ;
apr_snprintf ( loc_file_fullname_cfg , sizeof ( loc_file_fullname_cfg ) , " /home/pq/FeProject/comtrade/%s " , cfg_only_filename_ret ) ;
char oss_file_fullname_cfg [ 256 ] ; //Զ<> <D4B6> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD>
memset ( oss_file_fullname_cfg , 0 , sizeof ( oss_file_fullname_cfg ) ) ;
apr_snprintf ( oss_file_fullname_cfg , sizeof ( oss_file_fullname_cfg ) , " comtrade/wave/%s/%s " , LD_info - > mp_id , cfg_only_filename_ret ) ;
if ( FILE_FLAG = = 1 ) {
PutOSS ( oss_file_fullname_cfg , loc_file_fullname_cfg ) ; //ʹ <> <CAB9> buffer<65> <72> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD>
}
else if ( FILE_FLAG = = 2 ) {
OBSFile ( loc_file_fullname_cfg , oss_file_fullname_cfg , " putObject " ) ; //<2F> <> <EFBFBD> ﲢû<EFB2A2> <C3BB> <EFBFBD> ϴ<EFBFBD> <CFB4> ļ<EFBFBD> <C4BC> <EFBFBD>
}
else if ( FILE_FLAG = = 3 ) {
WebAPI_Uds_Upload ( UDS_UPLOAD_URL , loc_file_fullname_cfg , uuid_cfg , filename_cfg ) ; //ͨ<> <CDA8> form-data<74> ϴ<EFBFBD> <CFB4> ļ<EFBFBD>
}
//LNK20241031ʹ <31> <CAB9> JSON<4F> <4E> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> ϴ<EFBFBD> -<2D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Զ<EFBFBD> <D4B6> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӳ<EFBFBD> <D3B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> л<EFBFBD> ȡ
else if ( FILE_FLAG = = 4 ) {
SOEFileWeb ( loc_file_fullname_cfg , oss_file_fullname_cfg , wavepath_cfg ) ;
}
else
{
}
printf ( " \n >>>>>>!! %s %s...... \n " , oss_file_fullname_cfg , loc_file_fullname_cfg ) ;
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 ) ) ;
apr_snprintf ( loc_file_fullname_dat , sizeof ( loc_file_fullname_dat ) , " /home/pq/FeProject/comtrade/%s " , dat_only_filename_ret ) ;
char oss_file_fullname_dat [ 256 ] ;
memset ( oss_file_fullname_dat , 0 , sizeof ( oss_file_fullname_dat ) ) ;
apr_snprintf ( oss_file_fullname_dat , sizeof ( oss_file_fullname_dat ) , " comtrade/wave/%s/%s " , LD_info - > mp_id , dat_only_filename_ret ) ;
if ( FILE_FLAG = = 1 ) {
PutOSS ( oss_file_fullname_dat , loc_file_fullname_dat ) ; //ʹ <> <CAB9> buffer<65> <72> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD>
}
else if ( FILE_FLAG = = 2 ) {
OBSFile ( loc_file_fullname_dat , oss_file_fullname_dat , " putObject " ) ; //<2F> <> <EFBFBD> ﲢû<EFB2A2> <C3BB> <EFBFBD> ϴ<EFBFBD> <CFB4> ļ<EFBFBD> <C4BC> <EFBFBD>
}
else if ( FILE_FLAG = = 3 ) {
WebAPI_Uds_Upload ( UDS_UPLOAD_URL , loc_file_fullname_dat , uuid_dat , filename_dat ) ; //ͨ<> <CDA8> form-data<74> ϴ<EFBFBD> <CFB4> ļ<EFBFBD>
}
//LNK20241031ʹ <31> <CAB9> JSON<4F> <4E> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> ϴ<EFBFBD> -<2D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Զ<EFBFBD> <D4B6> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӳ<EFBFBD> <D3B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> л<EFBFBD> ȡ
else if ( FILE_FLAG = = 4 ) {
SOEFileWeb ( loc_file_fullname_dat , oss_file_fullname_dat , wavepath_dat ) ;
}
printf ( " \n >>>>>>!! %s %s...... \n " , oss_file_fullname_dat , loc_file_fullname_dat ) ;
/*<2A> ϴ<EFBFBD> .cfg<66> <67> .dat<61> <74> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> */
/*<2A> ϴ<EFBFBD> <CFB4> <EFBFBD> Ϣ*/
//to send json of this qvvr and rdre
end_tm = ( long long ) ( qvvr - > QVVR_PerTime * 1000 ) + trig_tm ; //<2F> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> dz<EFBFBD> <C7B3> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> Ӵ<EFBFBD> <D3B4> <EFBFBD> ʱ<EFBFBD> <CAB1>
if ( FILE_FLAG = = 3 ) {
size_t cfg_len = strlen ( uuid_cfg ) + strlen ( filename_cfg ) + 3 ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 3<EFBFBD> <33> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> "-"<22> ͽ<EFBFBD> <CDBD> <EFBFBD> <EFBFBD> <EFBFBD> '\0'
char * cfg_result = ( char * ) malloc ( cfg_len * sizeof ( char ) ) ; // <20> <> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> 㹻<EFBFBD> <E3B9BB> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
size_t dat_len = strlen ( uuid_dat ) + strlen ( filename_dat ) + 3 ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 3<EFBFBD> <33> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> "-"<22> ͽ<EFBFBD> <CDBD> <EFBFBD> <EFBFBD> <EFBFBD> '\0'
char * dat_result = ( char * ) malloc ( dat_len * sizeof ( char ) ) ; // <20> <> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> 㹻<EFBFBD> <E3B9BB> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
if ( cfg_result ! = NULL & & dat_result ! = NULL ) {
snprintf ( cfg_result , cfg_len , " %s-%s " , uuid_cfg , filename_cfg ) ; // ƴ<> <C6B4> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> 껺<EFBFBD> <EABBBA> <EFBFBD> <EFBFBD>
snprintf ( dat_result , dat_len , " %s-%s " , uuid_dat , filename_dat ) ; // ƴ<> <C6B4> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> 껺<EFBFBD> <EABBBA> <EFBFBD> <EFBFBD>
ret3 = transfer_json_qvvr_data ( g_node_id , LD_info - > line_id , qvvr - > QVVR_Amg , qvvr - > QVVR_PerTime , start_tm , end_tm , qvvr - > QVVR_type , cfg_result , dat_result , LD_info - > mp_id , qvvr - > QVVR_Rptname , ied_usr - > dev_type ) ;
}
free ( cfg_result ) ; // ʹ <> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> Ϻ <EFBFBD> <CFBA> ͷŶ<CDB7> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
free ( dat_result ) ; // ʹ <> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> Ϻ <EFBFBD> <CFBA> ͷŶ<CDB7> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
}
else if ( FILE_FLAG = = 4 ) //lnk20241031<33> <31> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̬web<65> <62> Ϣ
{
//<2F> ڴ<EFBFBD> <DAB4> <EFBFBD> <EFBFBD> 䲿<EFBFBD> ֲ<EFBFBD> <D6B2> <EFBFBD>
size_t cfg_len = strlen ( wavepath_cfg ) ;
char * cfg_result = ( char * ) malloc ( cfg_len * sizeof ( char ) ) ; // <20> <> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> 㹻<EFBFBD> <E3B9BB> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
size_t dat_len = strlen ( wavepath_dat ) ;
char * dat_result = ( char * ) malloc ( dat_len * sizeof ( char ) ) ; // <20> <> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> 㹻<EFBFBD> <E3B9BB> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
if ( cfg_result ! = NULL & & dat_result ! = NULL ) {
snprintf ( cfg_result , cfg_len , wavepath_cfg ) ; // ƴ<> <C6B4> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> 껺<EFBFBD> <EABBBA> <EFBFBD> <EFBFBD>
snprintf ( dat_result , dat_len , wavepath_dat ) ; // ƴ<> <C6B4> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> 껺<EFBFBD> <EABBBA> <EFBFBD> <EFBFBD>
ret3 = 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>
qvvr - > QVVR_Amg , qvvr - > QVVR_PerTime , start_tm , end_tm , qvvr - > QVVR_type , //<2F> <> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> 䡢<EFBFBD> <E4A1A2> ʼ ʱ<CABC> 䡢<EFBFBD> <E4A1A2> <EFBFBD> <EFBFBD> ʱ<EFBFBD> 䡢<EFBFBD> <E4A1A2> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD>
cfg_result , dat_result , //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> ·<EFBFBD> <C2B7>
LD_info - > mp_id , qvvr - > QVVR_Rptname , ied_usr - > dev_type ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ţ<EFBFBD> <C5A3> ļ<EFBFBD> <C4BC> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̬<EFBFBD> ¼<EFBFBD> ƥ<EFBFBD> <C6A5> <EFBFBD> ϵ<EFBFBD> <CFB5> <EFBFBD> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ն<EFBFBD> <D5B6> <EFBFBD> <EFBFBD> <EFBFBD>
}
free ( cfg_result ) ; // ʹ <> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> Ϻ <EFBFBD> <CFBA> ͷŶ<CDB7> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
free ( dat_result ) ; // ʹ <> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> Ϻ <EFBFBD> <CFBA> ͷŶ<CDB7> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
}
else if ( FILE_FLAG = = 1 | | FILE_FLAG = = 2 )
{
size_t cfg_len = strlen ( oss_file_fullname_cfg ) + strlen ( cfg_only_filename_ret ) + 3 ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 3<EFBFBD> <33> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> "-"<22> ͽ<EFBFBD> <CDBD> <EFBFBD> <EFBFBD> <EFBFBD> '\0'
char * cfg_result = ( char * ) malloc ( cfg_len * sizeof ( char ) ) ; // <20> <> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> 㹻<EFBFBD> <E3B9BB> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
size_t dat_len = strlen ( oss_file_fullname_dat ) + strlen ( dat_only_filename_ret ) + 3 ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 3<EFBFBD> <33> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> "-"<22> ͽ<EFBFBD> <CDBD> <EFBFBD> <EFBFBD> <EFBFBD> '\0'
char * dat_result = ( char * ) malloc ( dat_len * sizeof ( char ) ) ; // <20> <> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> 㹻<EFBFBD> <E3B9BB> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
if ( cfg_result ! = NULL & & dat_result ! = NULL ) {
snprintf ( cfg_result , cfg_len , " %s-%s " , oss_file_fullname_cfg , cfg_only_filename_ret ) ; // ƴ<> <C6B4> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> 껺<EFBFBD> <EABBBA> <EFBFBD> <EFBFBD>
snprintf ( dat_result , dat_len , " %s-%s " , oss_file_fullname_dat , dat_only_filename_ret ) ; // ƴ<> <C6B4> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> 껺<EFBFBD> <EABBBA> <EFBFBD> <EFBFBD>
ret3 = transfer_json_qvvr_data ( g_node_id , LD_info - > line_id , qvvr - > QVVR_Amg , qvvr - > QVVR_PerTime , start_tm , end_tm , qvvr - > QVVR_type , cfg_result , dat_result , LD_info - > mp_id , qvvr - > QVVR_Rptname , ied_usr - > dev_type ) ;
}
free ( cfg_result ) ; // ʹ <> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> Ϻ <EFBFBD> <CFBA> ͷŶ<CDB7> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
free ( dat_result ) ; // ʹ <> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> Ϻ <EFBFBD> <CFBA> ͷŶ<CDB7> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> <DAB4> ռ <EFBFBD>
}
/*<2A> ϴ<EFBFBD> <CFB4> <EFBFBD> Ϣ*/
qvvr - > used_status = QVVR_DATA_NOT_USED ;
free ( uuid_cfg ) ;
free ( uuid_dat ) ;
free ( filename_cfg ) ;
free ( filename_dat ) ;
//lnk 202411-5
free ( wavepath_cfg ) ;
free ( wavepath_dat ) ;
}
}
}
}
else {
if ( ied & & chnl_usr )
echo_warn2 ( " mms_mvla_fdir Failed: IED [%d] %s \n " , ied - > id , chnl_usr - > ip_str ) ;
return APR_EAGAIN ;
}
LD_info - > FltNum [ i ] = - 1 ;
}
if ( have_new_files )
clear_old_comtrade_files ( ) ;
return APR_SUCCESS ;
}
//lnk 2024-11-4 <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> ת<EFBFBD> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
char * convertMsToDateTimeString ( int msTime ) {
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ת<EFBFBD> <D7AA> Ϊ<EFBFBD> <CEAA> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD>
time_t seconds = msTime / 1000 ;
// <20> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
struct tm * timeInfo = localtime ( & seconds ) ;
// <20> <> ̬<EFBFBD> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 洢ת<E6B4A2> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD>
static char buffer [ 20 ] ;
strftime ( buffer , sizeof ( buffer ) , " %y-%m-%d %H:%M:%S " , timeInfo ) ;
return buffer ;
}