improved init function

This commit is contained in:
Robin Müller 2020-07-09 16:46:57 +02:00
parent 5a351474d2
commit a5d3d9ea80

View File

@ -122,8 +122,12 @@ ReturnValue_t DeviceHandlerBase::initialize() {
communicationInterface = objectManager->get<DeviceCommunicationIF>( communicationInterface = objectManager->get<DeviceCommunicationIF>(
deviceCommunicationId); deviceCommunicationId);
if (communicationInterface == NULL) { if (communicationInterface == nullptr) {
return RETURN_FAILED; sif::error << "DeviceHandlerBase::initialize: Communication interface "
"invalid." << std::endl;
sif::error << "Make sure it is set up properly and implements"
" DeviceCommunicationIF" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
} }
result = communicationInterface->initializeInterface(comCookie); result = communicationInterface->initializeInterface(comCookie);
@ -132,8 +136,10 @@ ReturnValue_t DeviceHandlerBase::initialize() {
} }
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE); IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
if (IPCStore == NULL) { if (IPCStore == nullptr) {
return RETURN_FAILED; sif::error << "DeviceHandlerBase::initialize: IPC store not set up in "
"factory." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
} }
if(rawDataReceiverId != objects::NO_OBJECT) { if(rawDataReceiverId != objects::NO_OBJECT) {
@ -152,8 +158,12 @@ ReturnValue_t DeviceHandlerBase::initialize() {
if(powerSwitcherId != objects::NO_OBJECT) { if(powerSwitcherId != objects::NO_OBJECT) {
powerSwitcher = objectManager->get<PowerSwitchIF>(powerSwitcherId); powerSwitcher = objectManager->get<PowerSwitchIF>(powerSwitcherId);
if (powerSwitcher == NULL) { if (powerSwitcher == nullptr) {
return RETURN_FAILED; sif::error << "DeviceHandlerBase::initialize: Power switcher "
<< "object ID set but no valid object found." << std::endl;
sif::error << "Make sure the raw receiver object is set up properly"
<< " and implements PowerSwitchIF" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
} }
} }
@ -189,14 +199,14 @@ ReturnValue_t DeviceHandlerBase::initialize() {
return result; return result;
} }
if(hkDestination == objects::NO_OBJECT) { // if(hkDestination == objects::NO_OBJECT) {
hkDestination = defaultHkDestination; // hkDestination = defaultHkDestination;
} // }
//
result = hkManager.initialize(commandQueue, hkDestination); // result = hkManager.initialize(commandQueue, hkDestination);
if (result != HasReturnvaluesIF::RETURN_OK) { // if (result != HasReturnvaluesIF::RETURN_OK) {
return result; // return result;
} // }
fillCommandAndReplyMap(); fillCommandAndReplyMap();