//////////////////////////////////////////////////////////////////////////////// /// @author Marcel Ionescu /// @brief Re-read variables which may change at run-time /// @retval true success /// @retval false failure /// @remarks Call it on USR2 /// @note TAKE CARE: DO NOT read same variable in Init and Reload. Init calls Reload. /// @note The group get set to "GATEWAY" inside the method /// @note TAKE CARE: put here only variables used directly /// @note Do not put here varaibles used /// - to initialise some other variables, /// - as parameters to constructors /// - as parameters for I/O subsystems (serials, USB, UDP, TCP) //////////////////////////////////////////////////////////////////////////////// bool CISAConfig::Reload( void ) { // LOGLVL_ERR = 1, /// User should ALWAYS log this log level. // LOGLVL_INF = 2, /// User may choose to ignore this loglevel, to reduce the log noise. It is recommended to log it, however. // LOGLVL_DBG = 3 /// User should NOT log this level, except for stack debugging /// @see ../ISA100/log_callback.h if (!CIniParser::FindGroup("GATEWAY")) { return false; } READ_DEFAULT_VARIABLE_INT("LOG_LEVEL_APP", m_nLogLevelApp, 3 ); if( m_nLogLevelApp < 1 ) m_nLogLevelApp = 1; if( m_nLogLevelApp > 3 ) m_nLogLevelApp = 3; READ_DEFAULT_VARIABLE_INT("LOG_LEVEL_STACK", m_nLogLevelStack, 3 ); if( m_nLogLevelStack < 1 ) m_nLogLevelStack = 1; if( m_nLogLevelStack > 3 ) m_nLogLevelStack = 3; READ_DEFAULT_VARIABLE_INT("TCP_INACTIVITY_SEC", m_nTCPInactivity, 3600); READ_DEFAULT_VARIABLE_INT("TCP_MAX_MSG_SIZE", m_nTCPMaxSize, 10*1024*1024); READ_DEFAULT_VARIABLE_INT("SYSTEM_REPORTS_CACHE_TIMEOUT", m_nSystemReportsCacheTimeout, 10 ); READ_DEFAULT_VARIABLE_INT("CLIENTSERVER_CACHE_TIMEOUT", m_nClientServerCacheTimeout, 120 ); READ_DEFAULT_VARIABLE_INT("YGSAP_DEVICE_LIST_REFRESH", m_nDeviceListRefresh, 30 ); READ_DEFAULT_VARIABLE_INT("CONTRACT_LIST_REFRESH", m_nContractListRefresh, 300 ); READ_DEFAULT_VARIABLE_YES_NO("DISPLAY_REPORTS", m_nDisplayReports, "no"); READ_DEFAULT_VARIABLE_INT("MAX_SAP_IN_DATA_LOG", m_nMaxSapInDataLog, 16); READ_DEFAULT_VARIABLE_INT("MAX_SAP_OUT_DATA_LOG", m_nMaxSapOutDataLog, 24); READ_DEFAULT_VARIABLE_INT("MAX_PUBLISH_DATA_LOG", m_nMaxPublishDataLog, 16); READ_DEFAULT_VARIABLE_INT("MAX_CS_DATA_LOG", m_nMaxCSDataLog, 12); READ_DEFAULT_VARIABLE_INT("GPDU_STATISTICS_PERIOD", m_nGPDUStatisticsPeriod, 600); /// interval used to average GS_GPDU_Path_Reliability/GS_GPDU_Latency // old method READ_DEFAULT_VARIABLE_INT("GPDU_MAX_LATENCY_PERCENT", m_nGPDUMaxLatencyPercent, 10); /// percent of publication period. Above it a publish packet is considered late and added to GS_GPDU_Latency return true; }
bool GatewayConfig::RuntimeReload() { READ_MANDATORY_VARIABLE_STRING("AppJoinKey", m_u8AppJoinKey); READ_MANDATORY_VARIABLE("GW_REQ_TIMEOUT", m_nGwReqTimeout); m_nGwReqTimeout *= sysconf(_SC_CLK_TCK); READ_DEFAULT_VARIABLE_INT("GW_REQ_RETRY_TIMEOUT", m_nGwReqRetryTimeout, 15); m_nGwReqRetryTimeout = m_nGwReqRetryTimeout * 60 * sysconf(_SC_CLK_TCK); // from minutes to clock ticks READ_DEFAULT_VARIABLE_INT("LOG_INTERNAL_STATUS_PERIOD", m_nLogInternalStatusPeriod, 0); READ_DEFAULT_VARIABLE_INT("LOG_INTERNAL_REQUEST_STATISTICS_PERIOD", m_nLogInternalRequestsStatisticsPeriod, 0); READ_MANDATORY_VARIABLE("CACHE_BURST_RESP_TIMEOUT", m_nGwBurstRespTimeout); READ_MANDATORY_VARIABLE("CACHE_READ_RESP_TIMEOUT", m_nGwRespTimeout); READ_MANDATORY_VARIABLE("GW_DRM_TIMEOUT", m_nGwDrmTimeout); m_nGwDrmTimeout *= sysconf(_SC_CLK_TCK); READ_MANDATORY_VARIABLE("GW_REQ_MAX_RETRY_NO", m_nGwReqMaxRetryNo); READ_DEFAULT_VARIABLE_INT("LOCAL_GW_RETRIES", m_nLocalGwRetries, 3); READ_DEFAULT_VARIABLE_INT("DEVICES_REFRESH_INTERVAL", m_nDevicesRefreshInterval, 5); READ_DEFAULT_VARIABLE_INT("LOG_LEVEL_STACK", m_nLogLevelStack, 4); //4-debug, 3-info READ_DEFAULT_VARIABLE_INT("LOG_LEVEL_APP", m_nLogLevelApp, 4); //4-debug, 3-info int granularity_keepalive; READ_DEFAULT_VARIABLE_INT("GRANULARITY_KEEPALIVE", granularity_keepalive, 60); m_u8GranularityKeepAlive = (uint8_t) granularity_keepalive; READ_DEFAULT_VARIABLE_INT("MAX_CMDS_PER_APDU", m_nMaxCmdsPerAPDU, 5); READ_DEFAULT_VARIABLE_YES_NO("NM_BURSTS_CACHING_ENABLED", m_bNmBurstsCachingEnabled, "YES"); READ_DEFAULT_VARIABLE_YES_NO("USE_SUBDEV_POLLING_ADDRESSES", m_bUseSubdevPollingAddresses, "YES"); READ_DEFAULT_VARIABLE_YES_NO("DONT_ACK_C119_WHEN_TIME_MINUS_1", m_bDontAckC119WhenTime_minus1, "NO"); READ_DEFAULT_VARIABLE_YES_NO("SEND_DIRECT_WIRED_DEVICE_BURST", m_bSendDirectWiredDeviceBurst, "NO"); READ_DEFAULT_VARIABLE_YES_NO("BUILD_UNIV_CMDS_CACHE", m_bBuildUnivCommandsCache, "NO"); READ_DEFAULT_VARIABLE_INT("DRM_TYPE", m_nDrmType, GatewayConfig::DRM_TYPE_CACHE_BASED); // READ_DEFAULT_VARIABLE_STRING("GATEWAY_TAG", m_szTag, "GwTag" ); READ_DEFAULT_VARIABLE_INT("DRM_ENTRY_LIFETIME", m_nDrmEntryLifetime, 1200); READ_DEFAULT_VARIABLE_YES_NO("SEND_INVALID_REQUEST_TO_DEVICE", m_bSendInvalidRequestToDevice, "NO"); EnableLog(m_nLogLevelStack);//4-debug, 3-info EnableLog_APP(m_nLogLevelApp);//4-debug, 3-info LOG_INFO_APP("GatewayConfig DONE logLevel stack=" << m_nLogLevelStack << " app=" << m_nLogLevelApp); ReadSpecificCmds(); BurstSpecificCmds(); ReadGWUniversalVariables(); return true; }
int CConfig::Init( const char * p_szModule, const char * p_szFileName ) { LOG( "CConfig::Init" ); m_nIsMasterAN = NO_RF_MEMBER; if( ! Load( p_szFileName ) || ! CIniParser::FindGroup("GLOBAL") || ( CIniParser::GetVar(NULL, "AN_ID",(unsigned char*)(&m_stAddress), sizeof(m_stAddress)) != sizeof(m_stAddress) ) || ( CIniParser::GetVar(NULL, "APP_ID",(unsigned char*)(&m_shAppId), sizeof(m_shAppId)) != sizeof(m_shAppId) ) || (m_shAppId == 0) || ((*(int*)&m_stAddress) == 0) ) { LOG( "PANIC CConfig::Init: section GLOBAL not found, or AN_ID/APP_ID are wrong"); Release(); // calling parent's Release() return 0; } //LOG("CConfig::Init: AN_ID=%s APP_ID=%s", GetHex(&m_stAddress,sizeof(m_stAddress)), GetHex(&m_shAppId,sizeof(m_shAppId))); LOG("CConfig::Init: AN_ID=%s APP_ID=%s", GetHexT(&m_stAddress), GetHexT(&m_shAppId)); m_ppModulesToWatch[0] = 0; strncpy( m_szModule, p_szModule, sizeof(m_szModule)-1 ); int nLogSize; bool bTail; int nMoveTimeout; char szStorage[PATH_MAX]; char temp[ 16 ]; int nFFree; bool bBackup1; /// create backup logs with .1 extension, SM-style /// when active, the FTP_SCRIPT is no longer executed READ_DEFAULT_VARIABLE_YES_NO ( "LOG_BACKUP_1", bBackup1, "N" ); g_stLog.SetBackup1( bBackup1 ); READ_DEFAULT_VARIABLE_INT ( "MODULES_STOP_TIMEOUT", CApp::m_nStopTimeout, 30 ); //seconds READ_DEFAULT_VARIABLE_INT ( "MAX_LOG_SIZE", nLogSize, 512 ); //kBytes g_stLog.SetMaxSize( nLogSize * 1024 ); READ_DEFAULT_VARIABLE_STRING ( "LOG_STORAGE", szStorage, ""); // g_stLog.SetStorage( szStorage); will do it only once, because it's heavy READ_DEFAULT_VARIABLE_YES_NO ( "TAIL_SAFE", bTail, "NO" ); g_stLog.SetTail( bTail); READ_DEFAULT_VARIABLE_INT ( "MOVE_TIMEOUT", nMoveTimeout, 120 ); //seconds g_stLog.SetMoveTimeout( nMoveTimeout); READ_DEFAULT_VARIABLE_INT ( "LOG_FLASH_FREE_LIMIT", nFFree, 5120 ); //kBytes g_stLog.SetFlashFreeLimit( nFFree ); if ( CIniParser::FindGroup( p_szModule ) == NULL ) return 0; if( GetVar("MAX_LOG_SIZE", &nLogSize) ){ LOG( "Override value for MAX_LOG_SIZE = %d", nLogSize); g_stLog.SetMaxSize( nLogSize * 1024 ); } if( GetVar("TAIL_SAFE", temp, sizeof( temp)) ){ bTail=( !strcasecmp( temp, "Y") || !strcasecmp( temp, "YES") || !strcasecmp( temp, "1") || !strcasecmp( temp, "TRUE")); LOG( "Override value for TAIL_SAFE = %s", bTail?"TRUE":"FALSE"); g_stLog.SetTail( bTail ); } if( GetVar("MOVE_TIMEOUT", &nMoveTimeout) ){ LOG( "Override value for MOVE_TIMEOUT = %d", nMoveTimeout); g_stLog.SetMoveTimeout( nMoveTimeout); } if( GetVar("LOG_STORAGE", szStorage, sizeof( szStorage)) ){ LOG( "Override value for LOG_STORAGE = %s", szStorage); } g_stLog.SetStorage( szStorage); //we didn't do it before ReadAndSetLogLevel(); return 1; }