diff --git a/lib/App/common/serverMySQL_dataBinder.cpp b/lib/App/common/serverMySQL_dataBinder.cpp index 58284c9a..743d46a8 100644 --- a/lib/App/common/serverMySQL_dataBinder.cpp +++ b/lib/App/common/serverMySQL_dataBinder.cpp @@ -228,7 +228,7 @@ bool servaMySQLDBC::deleteScadaPostsAbowe( uint64_t platform_id, SERVER_SCADA_PO if (m_bIsConnected){ char tQBuf[MAX_PATH_LEN]; // type < 6 - to delete only Health statuses - not the TCC one - sprintf(tQBuf, "DELETE FROM `metro_platforms_mboxes` WHERE `platform_id`=%" PRIu64 " AND `type`>=%d AND `type`<6", platform_id, mtyp ); + sprintf(tQBuf, "DELETE FROM `metro_platforms_mboxes` WHERE `platform_id`=%" PRIu64 " AND `type`>%d AND `type`<6", platform_id, mtyp ); #ifdef DEBUG_ALL LOG(tQBuf); #endif diff --git a/lib/App/serva/servaLifeMonitoring.cpp b/lib/App/serva/servaLifeMonitoring.cpp index f7e70a42..5cfd2cb2 100644 --- a/lib/App/serva/servaLifeMonitoring.cpp +++ b/lib/App/serva/servaLifeMonitoring.cpp @@ -39,7 +39,7 @@ servaLifeMonitoring::servaLifeMonitoring():basicValidatable(),basicThread(){ tHZ->platform_id = *idx; uint8_t cid = 0; tHZ->lvl = 255; // To clean prev State - tHZ->validation_ts = getMilliseconds();//Set Next Validation Cycle + tHZ->validated = false; for ( DBC_UINT64_LIST::iterator jdx = tML->begin(); jdx != tML->end(); jdx++ ) { tHZ->module_id[cid] = *jdx; tHZ->module_monitored[cid] = true; @@ -90,6 +90,7 @@ bool servaLifeMonitoring::validateZone( HEALTH_MONITORING_ZONE *ptr ){ ptr->lvl = min_lvl; ptr->lvl_id = min_id; }; + ptr->validated = false; }; return retVal; }; @@ -110,7 +111,7 @@ uint8_t servaLifeMonitoring::validateModule( uint64_t module_id ){ } else { switch ( ms ) { case ARGUS_CLOUD_STATUS_E_GENERIC: break; - case ARGUS_CLOUD_STATUS_E_CAM_GENERIC: + case ARGUS_CLOUD_STATUS_E_CAM_GENERIC: case ARGUS_CLOUD_STATUS_E_CAM_NC: case ARGUS_CLOUD_STATUS_E_CAM_NPTZ: case ARGUS_CLOUD_STATUS_E_CAM_NIM: retVal = ARGUS_LIFE_STATUS_LVL_1; break; @@ -148,7 +149,9 @@ bool servaLifeMonitoring::validate(){ m_mMonitoringZonesProtector.lock(); for ( V_HEALTH_MONITORING_ZONES::iterator idx = m_vMonitoringZones.begin(); idx != m_vMonitoringZones.end(); idx++ ) { if (!validateZone(*idx)) { +#ifdef DEBUG LOG("Zone Health is Changed"); +#endif MODULE_HEALTH_STATUS *tData = (MODULE_HEALTH_STATUS*) malloc(sizeof(MODULE_HEALTH_STATUS)); if ( tData ) { tData->status = (*idx)->lvl; @@ -179,6 +182,7 @@ bool servaLifeMonitoring::validate(){ void servaLifeMonitoring::m_fThreadProc( void ){ m_bThreadStatus = TH_WORKING; uint32_t ots = time(NULL); + pthread_setname_np( pthread_self(), "LifeMonitoring" ); while( m_bThreadStatus < TH_ENDED ) { uint32_t cts = time(NULL); if ( ( cts - m_nStartupTS ) > LM_SKEEP_MONITORING_SECONDS ){ @@ -193,8 +197,10 @@ void servaLifeMonitoring::m_fThreadProc( void ){ }; m_mMonitoringZonesProtector.unlock(); if ( tCWZ ) { - for ( uint8_t i = 0; i < 4; i++ ) { - if (tCWZ->module_monitored[i]) tCWZ->module_status[i] = validateModule( tCWZ->module_id[i] ); + if ( !tCWZ->validated ) { + for (uint8_t i = 0; i < 4; i++) { + if (tCWZ->module_monitored[i]) tCWZ->module_status[i] = validateModule( tCWZ->module_id[i] ); + }; }; m_mMonitoringZonesProtector.lock(); m_vMonitoringZones.push_back( tCWZ ); diff --git a/lib/App/serva/servaLifeMonitoring.h b/lib/App/serva/servaLifeMonitoring.h index d239b85a..a41f5682 100644 --- a/lib/App/serva/servaLifeMonitoring.h +++ b/lib/App/serva/servaLifeMonitoring.h @@ -15,7 +15,7 @@ typedef struct S_HEALTH_MONITORING_ZONE{ uint64_t platform_id; uint8_t lvl; uint64_t lvl_id; - uint64_t validation_ts; + bool validated; }HEALTH_MONITORING_ZONE; typedef std::vector V_HEALTH_MONITORING_ZONES; diff --git a/lib/App/serva/servaMediaEncoder.cpp b/lib/App/serva/servaMediaEncoder.cpp index d8344026..fd88947a 100644 --- a/lib/App/serva/servaMediaEncoder.cpp +++ b/lib/App/serva/servaMediaEncoder.cpp @@ -420,6 +420,7 @@ void servaMediaEncoder::m_fThreadProc( void ){ sprintf( tB, "Converting %s to %s", m_sDecoderVS.m_pFileName, m_sEncoderVS.m_pFileName ); LOG( tB ); #endif + pthread_setname_np( pthread_self(), "MediaEncoder" ); cv::VideoCapture cap( m_sDecoderVS.m_pFileName ); if( cap.isOpened() ) { cv::Mat mat; diff --git a/lib/App/serva/servaModBusManager.cpp b/lib/App/serva/servaModBusManager.cpp index f0a3dd60..fb033ca4 100644 --- a/lib/App/serva/servaModBusManager.cpp +++ b/lib/App/serva/servaModBusManager.cpp @@ -736,7 +736,7 @@ bool servaModBusManager::dispatchEvent( EVENT_CONTAINER *Evt ){ DBC_UINT64_LIST *tIDS = m_pDBC->listPlatformModBusRTU( sData->platform_id ); if ( tIDS ) { for ( DBC_UINT64_LIST::iterator idx=tIDS->begin(); idx != tIDS->end(); idx++ ) { - mitigateCoil( *idx, ((sData->type == SCADA_POST_TYPE_HELTH_STROBE)?MBUS_CROSSBAR_AUX:MBUS_CROSSBAR_HEALTH) ); + mitigateCoil( *idx, ((sData->type == SCADA_POST_TYPE_HELTH_STROBE)?MBUS_CROSSBAR_AUX:MBUS_CROSSBAR_HEALTH), (SERVER_SCADA_POST_TYPE) sData->type ); }; delete( tIDS ); }; @@ -758,7 +758,7 @@ bool servaModBusManager::dispatchEvent( EVENT_CONTAINER *Evt ){ DBC_UINT64_LIST *tIDS = m_pDBC->listPlatformModBusRTU( sData->platform_id ); if ( tIDS ) { for ( DBC_UINT64_LIST::iterator idx=tIDS->begin(); idx != tIDS->end(); idx++ ) { - mitigateCoil( *idx, ((sData->type == SCADA_POST_TYPE_HELTH_STROBE)?MBUS_CROSSBAR_AUX:MBUS_CROSSBAR_HEALTH) ); + mitigateCoil( *idx, ((sData->type == SCADA_POST_TYPE_HELTH_STROBE)?MBUS_CROSSBAR_AUX:MBUS_CROSSBAR_HEALTH), (SERVER_SCADA_POST_TYPE) sData->type ); }; delete( tIDS ); }; @@ -820,6 +820,9 @@ void servaModBusManager::activateCoil( uint64_t rtu_id, uint8_t function_id, uin // clear all abowe Health statuses as not relevant // do we need a module ID ?? since the zone is whole platform // If tData->status == 0 then the Health status will be cleared + char tB[128]; + sprintf( tB, "Clearing All Abowe Health level %d on Activate", pt ); + LOG( tB ); m_pDBC->deleteScadaPostsAbowe( tRTU->platform_id, pt ); }; @@ -863,8 +866,11 @@ void servaModBusManager::mitigateCoil( uint64_t rtu_id, uint8_t function_id, SER // clear all abowe Health statuses as not relevant // do we need a module ID ?? since the zone is whole platform // If tData->status == 0 then the Health status will be cleared + char tB[128]; + sprintf( tB, "Clearing All Abowe Health level %d on Mitigate", pt ); + LOG( tB ); if ( pt ) { - m_pDBC->deleteScadaPostsAbowe(tRTU->platform_id, (SERVER_SCADA_POST_TYPE)( pt - 1 ) ); + m_pDBC->deleteScadaPostsAbowe(tRTU->platform_id, (SERVER_SCADA_POST_TYPE) pt); // pt-1 - to remove above and current } else { m_pDBC->deleteScadaPostsAbowe(tRTU->platform_id, SCADA_POST_TYPE_NA ); }; diff --git a/lib/App/serva/servaRemoteClientHandler.cpp b/lib/App/serva/servaRemoteClientHandler.cpp index 646c480b..637f114d 100644 --- a/lib/App/serva/servaRemoteClientHandler.cpp +++ b/lib/App/serva/servaRemoteClientHandler.cpp @@ -463,6 +463,7 @@ void servaRPCHadnler::m_fThreadProc( void ){ #ifdef DEBUG LOG("Connector Thread Started"); #endif + pthread_setname_np( pthread_self(), "RPC Handler" ); while ( m_bThreadStatus < TH_ENDED ) { // seconds Counter (for internal purposes) cTimeTSeconds = time( NULL );