DHB ctor simplified

This commit is contained in:
Robin Müller 2020-07-09 16:31:33 +02:00
parent 32ef807341
commit 5a351474d2
6 changed files with 24 additions and 10 deletions

View File

@ -67,6 +67,7 @@ public:
*/
ReturnValue_t initialize(MessageQueueIF* queueToUse,
object_id_t hkDestination);
/**
* This function is used to set the default HK packet destination.
* This destination will usually only be set once.

View File

@ -19,11 +19,11 @@
object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
object_id_t DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT;
object_id_t DeviceHandlerBase::defaultFdirParentId = objects::NO_OBJECT;
object_id_t DeviceHandlerBase::defaultHkDestination = objects::NO_OBJECT;
DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId,
object_id_t deviceCommunication, CookieIF * comCookie,
FailureIsolationBase* fdirInstance,
size_t cmdQueueSize) :
FailureIsolationBase* fdirInstance, size_t cmdQueueSize) :
SystemObject(setObjectId), mode(MODE_OFF), submode(SUBMODE_NONE),
wiretappingMode(OFF), storedRawData(StorageManagerIF::INVALID_ADDRESS),
deviceCommunicationId(deviceCommunication), comCookie(comCookie),
@ -31,8 +31,8 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId,
actionHelper(this, nullptr), hkManager(this, nullptr),
childTransitionFailure(RETURN_OK), fdirInstance(fdirInstance),
hkSwitcher(this), defaultFDIRUsed(fdirInstance == nullptr),
switchOffWasReported(false), hkDestination(hkDestination),
childTransitionDelay(5000), transitionSourceMode(_MODE_POWER_DOWN),
switchOffWasReported(false), childTransitionDelay(5000),
transitionSourceMode(_MODE_POWER_DOWN),
transitionSourceSubMode(SUBMODE_NONE) {
commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize,
MessageQueueMessage::MAX_MESSAGE_SIZE);
@ -189,6 +189,10 @@ ReturnValue_t DeviceHandlerBase::initialize() {
return result;
}
if(hkDestination == objects::NO_OBJECT) {
hkDestination = defaultHkDestination;
}
result = hkManager.initialize(commandQueue, hkDestination);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;

View File

@ -1048,6 +1048,7 @@ private:
PowerSwitchIF *powerSwitcher = nullptr;
/** Cached for initialize() */
static object_id_t defaultHkDestination;
object_id_t hkDestination = objects::NO_OBJECT;
/**

View File

@ -29,7 +29,7 @@ ReturnValue_t FailureIsolationBase::initialize() {
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (ownerId != 0) {
if (faultTreeParent != objects::NO_OBJECT) {
result = manager->subscribeToAllEventsFrom(eventQueue->getId(), ownerId);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
@ -41,10 +41,15 @@ ReturnValue_t FailureIsolationBase::initialize() {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
}
if (faultTreeParent != 0) {
if (faultTreeParent != objects::NO_OBJECT) {
ConfirmsFailuresIF* parentIF = objectManager->get<ConfirmsFailuresIF>(
faultTreeParent);
if (parentIF == NULL) {
if (parentIF == nullptr) {
sif::error << "FailureIsolationBase::intialize: Parent object"
<< "invalid." << std::endl;
sif::error << "Make sure it implements ConfirmsFailuresIF."
<< std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
return RETURN_FAILED;
}
eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue());

View File

@ -17,8 +17,11 @@ public:
static const Event FDIR_CHANGED_STATE = MAKE_EVENT(1, SEVERITY::INFO); //!< FDIR has an internal state, which changed from par2 (oldState) to par1 (newState).
static const Event FDIR_STARTS_RECOVERY = MAKE_EVENT(2, SEVERITY::MEDIUM); //!< FDIR tries to restart device. Par1: event that caused recovery.
static const Event FDIR_TURNS_OFF_DEVICE = MAKE_EVENT(3, SEVERITY::MEDIUM); //!< FDIR turns off device. Par1: event that caused recovery.
FailureIsolationBase(object_id_t owner, object_id_t parent = 0,
FailureIsolationBase(object_id_t owner,
object_id_t parent = objects::NO_OBJECT,
uint8_t messageDepth = 10, uint8_t parameterDomainBase = 0xF0);
virtual ~FailureIsolationBase();
virtual ReturnValue_t initialize();
@ -26,7 +29,7 @@ public:
* This is called by the DHB in performOperation()
*/
void checkForFailures();
MessageQueueId_t getEventReceptionQueue();
MessageQueueId_t getEventReceptionQueue() override;
virtual void triggerEvent(Event event, uint32_t parameter1 = 0,
uint32_t parameter2 = 0);
protected:

View File

@ -50,7 +50,7 @@ ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) {
if (not returnPair.second) {
//TODO Return Code
sif::error << "PUSDistributor::registerService: Service ID already"
"exists in map." << std::endl;
" exists in map." << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;