@ -429,72 +429,48 @@ void servaModBusManager::m_fThreadProc( void ){
break ;
} ;
case MBUS_FUNC_SIG_STROBE_LIGHT : { // Set TCC AUX signal
// ?? and create Scheduled mitigation of the signal ??
DBC_UINT64_LIST * tIDS = m_pDBC - > listPlatformModBusRTU ( ( * idx ) - > platform_id ) ;
if ( tIDS ) {
for ( DBC_UINT64_LIST : : iterator idd = tIDS - > begin ( ) ; idd ! = tIDS - > end ( ) ; idd + + ) {
MODBUS_RTU_INFO * tRTU = m_pDBC - > getModBusRTU ( * idd ) ;
if ( tRTU ) {
//AUX ?? Or HEALTH
uint8_t CBV = tRTU - > crossbar [ MBUS_CROSSBAR_HEALTH ] ;
// check if TCC Module
if ( tRTU - > func = = 3 & & CBV ) {
CBV - - ;
uint8_t bON = ( 1 < < CBV ) ;
uint8_t bOFF = ~ ( 1 < < CBV ) ;
//Remove Scheduled Signal change
m_mProtector . lock ( ) ;
for ( V_MODBUS_ACION_ITEMS : : iterator idz = m_vActioItems . begin ( ) ; idz ! = m_vActioItems . end ( ) ; ) {
if ( ( * idz ) - > module_id = = tRTU - > id ) {
//check if shceduled signal is current
if ( ( ( ( * idz ) - > value & bON ) = = bON ) | | ( ( ( * idz ) - > mask & bOFF ) = = bOFF ) ) {
free ( ( * idx ) ) ;
m_vActioItems . erase ( idz ) ;
//AUX crossbar record used as additional functionality
uint8_t CBV = tRTU - > crossbar [ MBUS_CROSSBAR_AUX ] ;
// check if TCC Module
if ( tRTU - > func = = 3 & & CBV ) {
// check if was not snoozed by operator
int c_status = m_pDBC - > getScadaPostStatus ( ( * idx ) - > platform_id , SCADA_POST_TYPE_HELTH_STROBE , ( * idx ) - > func ) ;
if ( c_status < 1 ) { // Not Snoozed by Operator
CBV - - ;
uint8_t bON = ( 1 < < CBV ) ;
uint8_t bOFF = ~ ( 1 < < CBV ) ;
//Remove Scheduled Signal change
m_mProtector . lock ( ) ;
for ( V_MODBUS_ACION_ITEMS : : iterator idz = m_vActioItems . begin ( ) ; idz ! = m_vActioItems . end ( ) ; ) {
if ( ( * idz ) - > module_id = = tRTU - > id ) {
//check if shceduled signal is current
if ( ( ( ( * idz ) - > value & bON ) = = bON ) | | ( ( ( * idz ) - > mask & bOFF ) = = bOFF ) ) {
free ( ( * idx ) ) ;
m_vActioItems . erase ( idz ) ;
} else idz + + ;
//break;
} else idz + + ;
//break;
} else idz + + ;
} ;
m_mProtector . unlock ( ) ;
//Skeep Signal if Allready Set
if ( ( tRTU - > c_OutBits & bON ) = = 0 ) {
tRTU - > c_OutBits | = bON ;
int rv = modbus_set_rtu ( tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tRTU - > c_OutBits ) ;
if ( rv < 0 ) {
tRTU - > c_OutBits & = bOFF ;
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_OFFLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
} else {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_ONLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
//Create Action Item Do disable Signal
/*
MODBUS_ACION_ITEM * tAI = ( MODBUS_ACION_ITEM * ) malloc ( sizeof ( MODBUS_ACION_ITEM ) ) ;
if ( tAI ) {
memset ( tAI , 0 , sizeof ( MODBUS_ACION_ITEM ) ) ;
//?? How long
tAI - > scheduled_on = getMilliseconds ( ) + ( m_sManagerData . automaticAlarmRisingTO * 1000 ) ;
tAI - > module_id = tRTU - > id ;
tAI - > mask = ( 1 < < CBV ) ;
m_mProtector . lock ( ) ;
m_vActioItems . push_back ( tAI ) ;
m_mProtector . unlock ( ) ;
} ;
*/
} ;
} else {
// Only Create New Action Item to Mitigate
// That will propogate delay because old Mitigation item was deleted
/*
MODBUS_ACION_ITEM * tAI = ( MODBUS_ACION_ITEM * ) malloc ( sizeof ( MODBUS_ACION_ITEM ) ) ;
if ( tAI ) {
memset ( tAI , 0 , sizeof ( MODBUS_ACION_ITEM ) ) ;
//?? How long
tAI - > scheduled_on = getMilliseconds ( ) + ( m_sManagerData . automaticAlarmRisingTO * 1000 ) ;
tAI - > module_id = tRTU - > id ;
tAI - > mask = ( 1 < < CBV ) ;
m_mProtector . lock ( ) ;
m_vActioItems . push_back ( tAI ) ;
m_mProtector . unlock ( ) ;
m_mProtector . unlock ( ) ;
//Skeep Signal if Allready Set
if ( ( tRTU - > c_OutBits & bON ) = = 0 ) {
tRTU - > c_OutBits | = bON ;
int rv = modbus_set_rtu ( tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tRTU - > c_OutBits ) ;
if ( rv < 0 ) {
tRTU - > c_OutBits & = bOFF ;
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_OFFLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
} else {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_ONLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
m_pDBC - > addScadaPost ( ( * idx ) - > platform_id , SCADA_POST_TYPE_HELTH_STROBE , ( * idx ) - > func ) ;
} ;
} else {
m_pDBC - > addScadaPost ( ( * idx ) - > platform_id , SCADA_POST_TYPE_HELTH_STROBE , ( * idx ) - > func ) ;
} ;
*/
} ;
} ;
free ( tRTU ) ;
@ -699,52 +675,54 @@ bool servaModBusManager::dispatchEvent( EVENT_CONTAINER *Evt ){
} ;
break ;
} ;
case EVT_SRV_SESSION_ENDED : {
LOG ( " EVT Session Ended " ) ;
SCADA_TRACK_INFO * tData = m_pDBC - > getTrackSCADA ( Evt - > m_nSourceNodeID ) ;
if ( tData ) {
//MODBUS_RTU_INFO *tRTU = m_pDBC->getModBusRTU_Platform( tData->platform_id );
DBC_UINT64_LIST * tIDS = m_pDBC - > listPlatformModBusRTU ( tData - > platform_id ) ;
if ( tIDS ) {
for ( DBC_UINT64_LIST : : iterator idx = tIDS - > begin ( ) ; idx ! = tIDS - > end ( ) ; idx + + ) {
MODBUS_RTU_INFO * tRTU = m_pDBC - > getModBusRTU ( * idx ) ;
if ( tRTU ) {
uint8_t CBV = tRTU - > crossbar [ ( ( tData - > side = = ' U ' ) ? MBUS_CROSSBAR_UPPER_TRACK : MBUS_CROSSBAR_BOTTOM_TRACK ) ] ;
if ( CBV ) {
CBV - - ;
uint8_t bON = ( 1 < < CBV ) ;
uint8_t bOFF = ~ ( 1 < < CBV ) ;
//Remove Scheduled Signal change
m_mProtector . lock ( ) ;
for ( V_MODBUS_ACION_ITEMS : : iterator idd = m_vActioItems . begin ( ) ; idd ! = m_vActioItems . end ( ) ; ) {
if ( ( * idd ) - > module_id = = tRTU - > id ) {
//check if shceduled signal is current
if ( ( ( ( * idd ) - > value & bON ) = = bON ) | | ( ( ( * idd ) - > mask & bOFF ) = = bOFF ) ) {
free ( ( * idd ) ) ;
m_vActioItems . erase ( idd ) ;
case EVT_SRV_SESSION_ENDED : { // Ignore Session End since The SCADA signal must be disabled only by operator
if ( m_sManagerData . supressSignalBySessionEnd ) {
LOG ( " EVT Session Ended " ) ;
SCADA_TRACK_INFO * tData = m_pDBC - > getTrackSCADA ( Evt - > m_nSourceNodeID ) ;
if ( tData ) {
//MODBUS_RTU_INFO *tRTU = m_pDBC->getModBusRTU_Platform( tData->platform_id );
DBC_UINT64_LIST * tIDS = m_pDBC - > listPlatformModBusRTU ( tData - > platform_id ) ;
if ( tIDS ) {
for ( DBC_UINT64_LIST : : iterator idx = tIDS - > begin ( ) ; idx ! = tIDS - > end ( ) ; idx + + ) {
MODBUS_RTU_INFO * tRTU = m_pDBC - > getModBusRTU ( * idx ) ;
if ( tRTU ) {
uint8_t CBV = tRTU - > crossbar [ ( ( tData - > side = = ' U ' ) ? MBUS_CROSSBAR_UPPER_TRACK : MBUS_CROSSBAR_BOTTOM_TRACK ) ] ;
if ( CBV ) {
CBV - - ;
uint8_t bON = ( 1 < < CBV ) ;
uint8_t bOFF = ~ ( 1 < < CBV ) ;
//Remove Scheduled Signal change
m_mProtector . lock ( ) ;
for ( V_MODBUS_ACION_ITEMS : : iterator idd = m_vActioItems . begin ( ) ; idd ! = m_vActioItems . end ( ) ; ) {
if ( ( * idd ) - > module_id = = tRTU - > id ) {
//check if shceduled signal is current
if ( ( ( ( * idd ) - > value & bON ) = = bON ) | | ( ( ( * idd ) - > mask & bOFF ) = = bOFF ) ) {
free ( ( * idd ) ) ;
m_vActioItems . erase ( idd ) ;
} else idd + + ;
//break;
} else idd + + ;
//break;
} else idd + + ;
} ;
m_mProtector . unlock ( ) ;
} ;
m_mProtector . unlock ( ) ;
//Mitigate Signal if sent
if ( ( tRTU - > c_OutBits & bON ) = = bON ) {
tRTU - > c_OutBits & = bOFF ;
int rv = modbus_set_rtu ( tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tRTU - > c_OutBits ) ;
if ( rv < 0 ) {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_OFFLINE , 0 , 0 ) ;
} else {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_ONLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
//Mitigate Signal if sent
if ( ( tRTU - > c_OutBits & bON ) = = bON ) {
tRTU - > c_OutBits & = bOFF ;
int rv = modbus_set_rtu ( tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tRTU - > c_OutBits ) ;
if ( rv < 0 ) {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_OFFLINE , 0 , 0 ) ;
} else {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_ONLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
} ;
} ;
} ;
} ; // checking crossbar
free ( tRTU ) ;
} ; // checking crossbar
free ( tRTU ) ;
} ;
} ;
delete ( tIDS ) ;
} ;
delete ( tIDS ) ;
free ( tData ) ;
} ;
free ( tData ) ;
} ;
break ;
} ;
@ -858,78 +836,190 @@ bool servaModBusManager::dispatchEvent( EVENT_CONTAINER *Evt ){
} ;
return false ; // No need Propogate this Evt
} ;
case CMD_KRN_SCADA_SNOOZE_POST_MESSAGE : {
MODBUS_PB_DATA * tData = ( MODBUS_PB_DATA * ) Evt - > m_pEvtData ;
if ( tData ) {
MODBUS_PM_DATA * sData = m_pDBC - > getScadaPostData ( tData - > id ) ;
if ( sData ) {
bool mitigate = false ;
if ( sData - > type = = 6 ) {
mitigate = true ;
} else {
if ( sData - > type > = m_sManagerData . helthSignalLevel ) mitigate = true ;
} ;
if ( mitigate ) {
DBC_UINT64_LIST * tIDS = m_pDBC - > listPlatformModBusRTU ( sData - > platform_id ) ;
if ( tIDS ) {
for ( DBC_UINT64_LIST : : iterator idx = tIDS - > begin ( ) ; idx ! = tIDS - > end ( ) ; idx + + ) {
MODBUS_RTU_INFO * tRTU = m_pDBC - > getModBusRTU ( * idx ) ;
if ( tRTU ) {
uint8_t CBV = tRTU - > crossbar [ ( ( sData - > type = = 6 ) ? MBUS_CROSSBAR_AUX : MBUS_CROSSBAR_HEALTH ) ] ;
//check only TCC modules
if ( tRTU - > func = = 3 & & CBV ) {
CBV - - ;
uint8_t bON = ( 1 < < CBV ) ;
uint8_t bOFF = ~ ( 1 < < CBV ) ;
# ifdef DEBUG_EXTRA
char tB [ 200 ] ;
sprintf ( tB , " %s:%d 0x%02x 0x%02x " , tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tData - > c_OutBits ) ;
LOG ( tB ) ;
# endif
//Mitigate Signal if sent
if ( ( tRTU - > c_OutBits & bON ) = = bON ) {
tRTU - > c_OutBits & = bOFF ;
int rv = modbus_set_rtu ( tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tRTU - > c_OutBits ) ;
if ( rv < 0 ) {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_OFFLINE , 0 , 0 ) ;
} else {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_ONLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
} ;
} ;
} ; // Crossbar Check
free ( tRTU ) ;
} ;
} ;
} ;
} ;
m_pDBC - > updateScadaPostStatus ( tData - > id , 1 ) ;
} ;
} ;
return false ; // No need Propogate this Evt
} ;
case EVT_SRV_MODBUS_D_POSTBOX : {
MODBUS_PB_DATA * tData = ( MODBUS_PB_DATA * ) Evt - > m_pEvtData ;
if ( tData ) {
MODBUS_PM_DATA * sData = m_pDBC - > getScadaPostData ( tData - > id ) ;
if ( sData ) {
bool mitigate = false ;
if ( sData - > type = = 6 ) {
mitigate = true ;
} else {
if ( sData - > type > = m_sManagerData . helthSignalLevel ) mitigate = true ;
} ;
if ( mitigate ) {
DBC_UINT64_LIST * tIDS = m_pDBC - > listPlatformModBusRTU ( sData - > platform_id ) ;
if ( tIDS ) {
for ( DBC_UINT64_LIST : : iterator idx = tIDS - > begin ( ) ; idx ! = tIDS - > end ( ) ; idx + + ) {
MODBUS_RTU_INFO * tRTU = m_pDBC - > getModBusRTU ( * idx ) ;
if ( tRTU ) {
uint8_t CBV = tRTU - > crossbar [ ( ( sData - > type = = 6 ) ? MBUS_CROSSBAR_AUX : MBUS_CROSSBAR_HEALTH ) ] ;
//check only TCC modules
if ( tRTU - > func = = 3 & & CBV ) {
CBV - - ;
uint8_t bON = ( 1 < < CBV ) ;
uint8_t bOFF = ~ ( 1 < < CBV ) ;
# ifdef DEBUG_EXTRA
char tB [ 200 ] ;
sprintf ( tB , " %s:%d 0x%02x 0x%02x " , tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tData - > c_OutBits ) ;
LOG ( tB ) ;
# endif
//Mitigate Signal if sent
if ( ( tRTU - > c_OutBits & bON ) = = bON ) {
tRTU - > c_OutBits & = bOFF ;
int rv = modbus_set_rtu ( tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tRTU - > c_OutBits ) ;
if ( rv < 0 ) {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_OFFLINE , 0 , 0 ) ;
} else {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_ONLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
} ;
} ;
} ; // Crossbar Check
free ( tRTU ) ;
} ;
} ;
} ;
} ;
m_pDBC - > deleteScadaPost ( tData - > id ) ;
} ;
} ;
return false ; // No need Propogate this Evt
} ;
case EVT_SRV_MODULE_HEALTH : {
if ( Evt - > m_pEvtData = = NULL ) return false ;
if ( m_sManagerData . helthSignalLevel ) {
MODULE_HEALTH_STATUS * tData = ( MODULE_HEALTH_STATUS * ) Evt - > m_pEvtData ;
if ( tData - > status > = m_sManagerData . helthSignalLevel ) {
//MODBUS_RTU_INFO *tRTU = m_pDBC->getModBusRTU_Platform( tData->platform_id );
DBC_UINT64_LIST * tIDS = m_pDBC - > listPlatformModBusRTU ( tData - > platform_id ) ;
if ( tIDS ) {
for ( DBC_UINT64_LIST : : iterator idx = tIDS - > begin ( ) ; idx ! = tIDS - > end ( ) ; idx + + ) {
MODBUS_RTU_INFO * tRTU = m_pDBC - > getModBusRTU ( * idx ) ;
if ( tRTU ) {
uint8_t CBV = tRTU - > crossbar [ MBUS_CROSSBAR_HEALTH ] ;
//Check Only TCC modules
if ( tRTU - > func = = 3 & & CBV ) {
CBV - - ;
uint8_t bON = ( 1 < < CBV ) ;
uint8_t bOFF = ~ ( 1 < < CBV ) ;
# ifdef DEBUG_EXTRA
char tB [ 200 ] ;
sprintf ( tB , " %s:%d 0x%02x 0x%02x " , tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tData - > c_OutBits ) ;
LOG ( tB ) ;
# endif
//Set Signal if was Cleared
if ( ( tRTU - > c_OutBits & bON ) = = 0 ) {
tRTU - > c_OutBits | = bON ;
int rv = modbus_set_rtu ( tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tRTU - > c_OutBits ) ;
if ( rv < 0 ) {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_OFFLINE , 0 , 0 ) ;
} else {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_ONLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
//checking if Snoozed
int c_status = m_pDBC - > getScadaPostStatus ( tData - > platform_id , ( SERVER_SCADA_POST_TYPE ) tData - > status , tData - > module_id ) ;
if ( c_status < 1 ) {
if ( c_status < 0 & & tData - > status ) { // No Record in MBox
// Add status regardless of
m_pDBC - > addScadaPost ( tData - > platform_id , ( SERVER_SCADA_POST_TYPE ) tData - > status , tData - > module_id ) ;
c_status = 0 ; // Set Enabled Signal Status
} ;
// 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
m_pDBC - > deleteScadaPostsAbowe ( tData - > platform_id , ( SERVER_SCADA_POST_TYPE ) tData - > status ) ;
if ( tData - > status > = m_sManagerData . helthSignalLevel & & c_status = = 0 ) {
//MODBUS_RTU_INFO *tRTU = m_pDBC->getModBusRTU_Platform( tData->platform_id );
DBC_UINT64_LIST * tIDS = m_pDBC - > listPlatformModBusRTU ( tData - > platform_id ) ;
if ( tIDS ) {
for ( DBC_UINT64_LIST : : iterator idx = tIDS - > begin ( ) ; idx ! = tIDS - > end ( ) ; idx + + ) {
MODBUS_RTU_INFO * tRTU = m_pDBC - > getModBusRTU ( * idx ) ;
if ( tRTU ) {
uint8_t CBV = tRTU - > crossbar [ MBUS_CROSSBAR_HEALTH ] ;
//Check Only TCC modules
if ( tRTU - > func = = 3 & & CBV ) {
CBV - - ;
uint8_t bON = ( 1 < < CBV ) ;
uint8_t bOFF = ~ ( 1 < < CBV ) ;
# ifdef DEBUG_EXTRA
char tB [ 200 ] ;
sprintf ( tB , " %s:%d 0x%02x 0x%02x " , tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tData - > c_OutBits ) ;
LOG ( tB ) ;
# endif
//Set Signal if was Cleared
if ( ( tRTU - > c_OutBits & bON ) = = 0 ) {
tRTU - > c_OutBits | = bON ;
int rv = modbus_set_rtu ( tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tRTU - > c_OutBits ) ;
if ( rv < 0 ) {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_OFFLINE , 0 , 0 ) ;
} else {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_ONLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
} ;
} ;
} ;
} ; // Crossbar check
free ( tRTU ) ;
} ; // Crossbar check
free ( tRTU ) ;
} ;
} ;
delete ( tIDS ) ;
} ;
delete ( tIDS ) ;
} ;
} else { //Below Level
//MODBUS_RTU_INFO *tRTU = m_pDBC->getModBusRTU_Platform( tData->platform_id );
DBC_UINT64_LIST * tIDS = m_pDBC - > listPlatformModBusRTU ( tData - > platform_id ) ;
if ( tIDS ) {
for ( DBC_UINT64_LIST : : iterator idx = tIDS - > begin ( ) ; idx ! = tIDS - > end ( ) ; idx + + ) {
MODBUS_RTU_INFO * tRTU = m_pDBC - > getModBusRTU ( * idx ) ;
if ( tRTU ) {
uint8_t CBV = tRTU - > crossbar [ MBUS_CROSSBAR_HEALTH ] ;
//check only TCC modules
if ( tRTU - > func = = 3 & & CBV ) {
CBV - - ;
uint8_t bON = ( 1 < < CBV ) ;
uint8_t bOFF = ~ ( 1 < < CBV ) ;
# ifdef DEBUG_EXTRA
char tB [ 200 ] ;
sprintf ( tB , " %s:%d 0x%02x 0x%02x " , tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tData - > c_OutBits ) ;
LOG ( tB ) ;
# endif
//Mitigate Signal if sent
if ( ( tRTU - > c_OutBits & bON ) = = bON ) {
tRTU - > c_OutBits & = bOFF ;
int rv = modbus_set_rtu ( tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tRTU - > c_OutBits ) ;
if ( rv < 0 ) {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_OFFLINE , 0 , 0 ) ;
} else {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_ONLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
} else { //Below Level
//MODBUS_RTU_INFO *tRTU = m_pDBC->getModBusRTU_Platform( tData->platform_id );
DBC_UINT64_LIST * tIDS = m_pDBC - > listPlatformModBusRTU ( tData - > platform_id ) ;
if ( tIDS ) {
for ( DBC_UINT64_LIST : : iterator idx = tIDS - > begin ( ) ; idx ! = tIDS - > end ( ) ; idx + + ) {
MODBUS_RTU_INFO * tRTU = m_pDBC - > getModBusRTU ( * idx ) ;
if ( tRTU ) {
uint8_t CBV = tRTU - > crossbar [ MBUS_CROSSBAR_HEALTH ] ;
//check only TCC modules
if ( tRTU - > func = = 3 & & CBV ) {
CBV - - ;
uint8_t bON = ( 1 < < CBV ) ;
uint8_t bOFF = ~ ( 1 < < CBV ) ;
# ifdef DEBUG_EXTRA
char tB [ 200 ] ;
sprintf ( tB , " %s:%d 0x%02x 0x%02x " , tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tData - > c_OutBits ) ;
LOG ( tB ) ;
# endif
//Mitigate Signal if sent
if ( ( tRTU - > c_OutBits & bON ) = = bON ) {
tRTU - > c_OutBits & = bOFF ;
int rv = modbus_set_rtu ( tRTU - > ip , tRTU - > port , tRTU - > output_base_addr , tRTU - > c_OutBits ) ;
if ( rv < 0 ) {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_OFFLINE , 0 , 0 ) ;
} else {
m_pDBC - > updateModBusRTU ( tRTU - > id , MBUS_STATUS_ONLINE , tRTU - > c_InBits , tRTU - > c_OutBits ) ;
} ;
} ;
} ;
} ; // Crossbar Check
free ( tRTU ) ;
} ; // Crossbar Check
free ( tRTU ) ;
} ;
} ;
} ;
} ;
} ;
}
} ;
break ;
} ;