health helper optional, diagnostic output improved

This commit is contained in:
Robin Müller 2020-06-06 12:59:43 +02:00
parent d35524ecbc
commit 5289497ab5
5 changed files with 39 additions and 14 deletions

View File

@ -139,10 +139,12 @@ ReturnValue_t DeviceHandlerBase::initialize() {
}
result = healthHelper.initialize();
if (result != RETURN_OK) {
sif::error << "DeviceHandlerBase::initialize: Health Helper "
"initialization failure" << std::endl;
return result;
if (result == RETURN_OK) {
healthHelperActive = true;
}
else {
sif::warning << "DeviceHandlerBase::initialize: Health Helper "
"initialization failure." << std::endl;
}
result = modeHelper.initialize();
@ -215,9 +217,11 @@ void DeviceHandlerBase::readCommandQueue() {
return;
}
result = healthHelper.handleHealthCommand(&message);
if (result == RETURN_OK) {
return;
if(healthHelperActive) {
result = healthHelper.handleHealthCommand(&message);
if (result == RETURN_OK) {
return;
}
}
result = modeHelper.handleModeCommand(&message);
@ -996,7 +1000,9 @@ void DeviceHandlerBase::getMode(Mode_t* mode, Submode_t* submode) {
}
void DeviceHandlerBase::setToExternalControl() {
healthHelper.setHealth(EXTERNAL_CONTROL);
if(healthHelperActive) {
healthHelper.setHealth(EXTERNAL_CONTROL);
}
}
void DeviceHandlerBase::announceMode(bool recursive) {
@ -1016,11 +1022,24 @@ void DeviceHandlerBase::missedReply(DeviceCommandId_t id) {
}
HasHealthIF::HealthState DeviceHandlerBase::getHealth() {
return healthHelper.getHealth();
if(healthHelperActive) {
return healthHelper.getHealth();
}
else {
sif::warning << "DeviceHandlerBase::getHealth: Health helper not active"
<< std::endl;
return HasHealthIF::HEALTHY;
}
}
ReturnValue_t DeviceHandlerBase::setHealth(HealthState health) {
healthHelper.setHealth(health);
if(healthHelperActive) {
healthHelper.setHealth(health);
}
else {
sif::warning << "DeviceHandlerBase::getHealth: Health helper not active"
<< std::endl;
}
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -601,6 +601,7 @@ protected:
/** Health helper for HasHealthIF */
HealthHelper healthHelper;
bool healthHelperActive = false;
/** Mode helper for HasModesIF */
ModeHelper modeHelper;
/** Parameter helper for ReceivesParameterMessagesIF */

View File

@ -163,6 +163,8 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() {
ReturnValue_t DeviceHandlerFailureIsolation::initialize() {
ReturnValue_t result = FailureIsolationBase::initialize();
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "DeviceHandlerFailureIsolation::initialize: Could not"
" initialize FailureIsolationBase." << std::endl;
return result;
}
ConfirmsFailuresIF* power = objectManager->get<ConfirmsFailuresIF>(

View File

@ -19,7 +19,9 @@ FailureIsolationBase::~FailureIsolationBase() {
ReturnValue_t FailureIsolationBase::initialize() {
EventManagerIF* manager = objectManager->get<EventManagerIF>(
objects::EVENT_MANAGER);
if (manager == NULL) {
if (manager == nullptr) {
sif::error << "FailureIsolationBase::initialize: Event Manager has not"
" been initialized!" << std::endl;
return RETURN_FAILED;
}
ReturnValue_t result = manager->registerListener(eventQueue->getId());

View File

@ -69,9 +69,10 @@ void ObjectManager::initialize() {
return_value = it.second->initialize();
if ( return_value != RETURN_OK ) {
object_id_t var = it.first;
sif::error << "Object 0x" << std::hex << std::setw(8) <<
std::setfill('0')<< var << " failed to initialize " <<
"with code 0x" << return_value << std::dec << std::endl;
sif::error << "ObjectManager::initialize: Object 0x" << std::hex <<
std::setw(8) << std::setfill('0')<< var << " failed to "
"initialize with code 0x" << return_value << std::dec <<
std::endl;
error_count++;
}
}