health table init now mandatory, better
diagnostic output for uninit health table or invalid health helper owner
This commit is contained in:
parent
47b3a428c6
commit
aaafed7b28
@ -164,12 +164,8 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = healthHelper.initialize();
|
result = healthHelper.initialize();
|
||||||
if (result == RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
healthHelperActive = true;
|
return result;
|
||||||
}
|
|
||||||
else {
|
|
||||||
sif::warning << "DeviceHandlerBase::initialize: Health Helper "
|
|
||||||
"initialization failure." << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = modeHelper.initialize();
|
result = modeHelper.initialize();
|
||||||
@ -246,11 +242,9 @@ void DeviceHandlerBase::readCommandQueue() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(healthHelperActive) {
|
result = healthHelper.handleHealthCommand(&command);
|
||||||
result = healthHelper.handleHealthCommand(&command);
|
if (result == RETURN_OK) {
|
||||||
if (result == RETURN_OK) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = modeHelper.handleModeCommand(&command);
|
result = modeHelper.handleModeCommand(&command);
|
||||||
@ -1028,9 +1022,7 @@ void DeviceHandlerBase::getMode(Mode_t* mode, Submode_t* submode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::setToExternalControl() {
|
void DeviceHandlerBase::setToExternalControl() {
|
||||||
if(healthHelperActive) {
|
healthHelper.setHealth(EXTERNAL_CONTROL);
|
||||||
healthHelper.setHealth(EXTERNAL_CONTROL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::announceMode(bool recursive) {
|
void DeviceHandlerBase::announceMode(bool recursive) {
|
||||||
@ -1050,25 +1042,12 @@ void DeviceHandlerBase::missedReply(DeviceCommandId_t id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HasHealthIF::HealthState DeviceHandlerBase::getHealth() {
|
HasHealthIF::HealthState DeviceHandlerBase::getHealth() {
|
||||||
if(healthHelperActive) {
|
return healthHelper.getHealth();
|
||||||
return healthHelper.getHealth();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sif::warning << "DeviceHandlerBase::getHealth: Health helper not active"
|
|
||||||
<< std::endl;
|
|
||||||
return HasHealthIF::HEALTHY;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::setHealth(HealthState health) {
|
ReturnValue_t DeviceHandlerBase::setHealth(HealthState health) {
|
||||||
if(healthHelperActive) {
|
healthHelper.setHealth(health);
|
||||||
healthHelper.setHealth(health);
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
|
||||||
else {
|
|
||||||
sif::warning << "DeviceHandlerBase::getHealth: Health helper not active"
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::checkSwitchState() {
|
void DeviceHandlerBase::checkSwitchState() {
|
||||||
|
@ -609,7 +609,6 @@ protected:
|
|||||||
|
|
||||||
/** Health helper for HasHealthIF */
|
/** Health helper for HasHealthIF */
|
||||||
HealthHelper healthHelper;
|
HealthHelper healthHelper;
|
||||||
bool healthHelperActive = false;
|
|
||||||
/** Mode helper for HasModesIF */
|
/** Mode helper for HasModesIF */
|
||||||
ModeHelper modeHelper;
|
ModeHelper modeHelper;
|
||||||
/** Parameter helper for ReceivesParameterMessagesIF */
|
/** Parameter helper for ReceivesParameterMessagesIF */
|
||||||
|
@ -39,10 +39,19 @@ void HealthHelper::setParentQeueue(MessageQueueId_t parentQueue) {
|
|||||||
ReturnValue_t HealthHelper::initialize() {
|
ReturnValue_t HealthHelper::initialize() {
|
||||||
healthTable = objectManager->get<HealthTableIF>(objects::HEALTH_TABLE);
|
healthTable = objectManager->get<HealthTableIF>(objects::HEALTH_TABLE);
|
||||||
eventSender = objectManager->get<EventReportingProxyIF>(objectId);
|
eventSender = objectManager->get<EventReportingProxyIF>(objectId);
|
||||||
// TODO: Better returnvalues
|
|
||||||
if ((healthTable == NULL) || eventSender == NULL) {
|
if (healthTable == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
sif::error << "HealthHelper::initialize: Health table object needs"
|
||||||
|
"to be created in factory." << std::endl;
|
||||||
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(eventSender == nullptr) {
|
||||||
|
sif::error << "HealthHelper::initialize: Owner has to implement "
|
||||||
|
"ReportingProxyIF." << std::endl;
|
||||||
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t result = healthTable->registerObject(objectId,
|
ReturnValue_t result = healthTable->registerObject(objectId,
|
||||||
HasHealthIF::HEALTHY);
|
HasHealthIF::HEALTHY);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
Loading…
Reference in New Issue
Block a user