move acs event handling to system
This commit is contained in:
parent
6538005a30
commit
1154c0e887
@ -26,6 +26,7 @@ will consitute of a breaking change warranting a new major release:
|
||||
|
||||
## Changed
|
||||
|
||||
- Move ACS event handling to system component.
|
||||
- Persistent TM stores will now create new files on each reboot.
|
||||
- Fast ACS subsystem commanding: Command SUS board consecutively with other devices now
|
||||
- Star Tracker: Use ground confguration for EM and flight config for FM by default.
|
||||
|
@ -8,90 +8,7 @@
|
||||
|
||||
AcsSubsystem::AcsSubsystem(object_id_t setObjectId, uint32_t maxNumberOfSequences,
|
||||
uint32_t maxNumberOfTables)
|
||||
: Subsystem(setObjectId, maxNumberOfSequences, maxNumberOfTables) {
|
||||
auto mqArgs = MqArgs(getObjectId(), static_cast<void*>(this));
|
||||
eventQueue =
|
||||
QueueFactory::instance()->createMessageQueue(10, EventMessage::EVENT_MESSAGE_SIZE, &mqArgs);
|
||||
}
|
||||
|
||||
ReturnValue_t AcsSubsystem::initialize() {
|
||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
if (manager == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "AcsSubsystem::initialize: Invalid event manager" << std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
ReturnValue_t result = manager->registerListener(eventQueue->getId());
|
||||
if (result != returnvalue::OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "AcsSubsystem::registerListener: Failed to register as "
|
||||
"listener"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
;
|
||||
}
|
||||
result =
|
||||
manager->subscribeToEvent(eventQueue->getId(), event::getEventId(acs::SAFE_RATE_VIOLATION));
|
||||
if (result != returnvalue::OK) {
|
||||
sif::error << "AcsSubsystem: Subscribing for acs::SAFE_RATE_VIOLATION failed" << std::endl;
|
||||
}
|
||||
result =
|
||||
manager->subscribeToEvent(eventQueue->getId(), event::getEventId(acs::SAFE_RATE_RECOVERY));
|
||||
if (result != returnvalue::OK) {
|
||||
sif::error << "AcsSubsystem: Subscribing for acs::SAFE_RATE_RECOVERY failed" << std::endl;
|
||||
}
|
||||
result =
|
||||
manager->subscribeToEvent(eventQueue->getId(), event::getEventId(acs::MULTIPLE_RW_INVALID));
|
||||
if (result != returnvalue::OK) {
|
||||
sif::error << "AcsSubsystem: Subscribing for acs::MULTIPLE_RW_INVALID failed" << std::endl;
|
||||
}
|
||||
result = manager->subscribeToEvent(eventQueue->getId(),
|
||||
event::getEventId(acs::MEKF_INVALID_MODE_VIOLATION));
|
||||
if (result != returnvalue::OK) {
|
||||
sif::error << "AcsSubsystem: Subscribing for acs::MULTIPLE_RW_INVALID failed" << std::endl;
|
||||
}
|
||||
return Subsystem::initialize();
|
||||
}
|
||||
|
||||
void AcsSubsystem::performChildOperation() {
|
||||
handleEventMessages();
|
||||
return Subsystem::performChildOperation();
|
||||
}
|
||||
|
||||
void AcsSubsystem::handleEventMessages() {
|
||||
EventMessage event;
|
||||
for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK;
|
||||
result = eventQueue->receiveMessage(&event)) {
|
||||
ReturnValue_t status;
|
||||
switch (event.getMessageId()) {
|
||||
case EventMessage::EVENT_MESSAGE:
|
||||
if (event.getEvent() == acs::SAFE_RATE_VIOLATION) {
|
||||
CommandMessage msg;
|
||||
ModeMessage::setCmdModeMessage(msg, acs::AcsMode::DETUMBLE, 0);
|
||||
status = commandQueue->sendMessage(commandQueue->getId(), &msg);
|
||||
if (result != returnvalue::OK) {
|
||||
sif::error << "AcsSubsystem: sending DETUMBLE mode cmd to self has failed" << std::endl;
|
||||
}
|
||||
}
|
||||
if (event.getEvent() == acs::SAFE_RATE_RECOVERY) {
|
||||
CommandMessage msg;
|
||||
ModeMessage::setCmdModeMessage(msg, acs::AcsMode::SAFE, 0);
|
||||
status = commandQueue->sendMessage(commandQueue->getId(), &msg);
|
||||
if (status != returnvalue::OK) {
|
||||
sif::error << "AcsSubsystem: sending SAFE mode cmd to self has failed" << std::endl;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sif::debug << "AcsSubsystem::performChildOperation: Did not subscribe "
|
||||
"to this event message"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
: Subsystem(setObjectId, maxNumberOfSequences, maxNumberOfTables) {}
|
||||
|
||||
void AcsSubsystem::announceMode(bool recursive) {
|
||||
const char* modeStr = acs::getModeStr(static_cast<acs::AcsMode>(mode));
|
||||
|
@ -8,13 +8,7 @@ class AcsSubsystem : public Subsystem {
|
||||
AcsSubsystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables);
|
||||
|
||||
private:
|
||||
ReturnValue_t initialize() override;
|
||||
void performChildOperation() override;
|
||||
void announceMode(bool recursive) override;
|
||||
|
||||
void handleEventMessages();
|
||||
|
||||
MessageQueueIF* eventQueue = nullptr;
|
||||
};
|
||||
|
||||
#endif /* MISSION_SYSTEM_ACSSUBSYSTEM_H_ */
|
||||
|
@ -1,10 +1,16 @@
|
||||
#include "EiveSystem.h"
|
||||
|
||||
#include <fsfw/events/EventManager.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <mission/acsDefs.h>
|
||||
|
||||
EiveSystem::EiveSystem(object_id_t setObjectId, uint32_t maxNumberOfSequences,
|
||||
uint32_t maxNumberOfTables)
|
||||
: Subsystem(setObjectId, maxNumberOfSequences, maxNumberOfTables) {}
|
||||
: Subsystem(setObjectId, maxNumberOfSequences, maxNumberOfTables) {
|
||||
auto mqArgs = MqArgs(getObjectId(), static_cast<void*>(this));
|
||||
eventQueue =
|
||||
QueueFactory::instance()->createMessageQueue(10, EventMessage::EVENT_MESSAGE_SIZE, &mqArgs);
|
||||
}
|
||||
|
||||
void EiveSystem::announceMode(bool recursive) {
|
||||
const char* modeStr = "UNKNOWN";
|
||||
@ -41,3 +47,72 @@ void EiveSystem::announceMode(bool recursive) {
|
||||
sif::info << "EIVE system is now in " << modeStr << " mode" << std::endl;
|
||||
return Subsystem::announceMode(recursive);
|
||||
}
|
||||
|
||||
void EiveSystem::performChildOperation() {
|
||||
handleEventMessages();
|
||||
return Subsystem::performChildOperation();
|
||||
}
|
||||
|
||||
ReturnValue_t EiveSystem::initialize() {
|
||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
if (manager == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "AcsSubsystem::initialize: Invalid event manager" << std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
ReturnValue_t result = manager->registerListener(eventQueue->getId());
|
||||
if (result != returnvalue::OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "AcsSubsystem::registerListener: Failed to register as "
|
||||
"listener"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
;
|
||||
}
|
||||
result =
|
||||
manager->subscribeToEvent(eventQueue->getId(), event::getEventId(acs::MULTIPLE_RW_INVALID));
|
||||
if (result != returnvalue::OK) {
|
||||
sif::error << "AcsSubsystem: Subscribing for acs::MULTIPLE_RW_INVALID failed" << std::endl;
|
||||
}
|
||||
result = manager->subscribeToEvent(eventQueue->getId(),
|
||||
event::getEventId(acs::MEKF_INVALID_MODE_VIOLATION));
|
||||
if (result != returnvalue::OK) {
|
||||
sif::error << "AcsSubsystem: Subscribing for acs::MULTIPLE_RW_INVALID failed" << std::endl;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void EiveSystem::handleEventMessages() {
|
||||
EventMessage event;
|
||||
for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK;
|
||||
result = eventQueue->receiveMessage(&event)) {
|
||||
ReturnValue_t status;
|
||||
switch (event.getMessageId()) {
|
||||
case EventMessage::EVENT_MESSAGE:
|
||||
if (event.getEvent() == acs::SAFE_RATE_VIOLATION) {
|
||||
CommandMessage msg;
|
||||
ModeMessage::setCmdModeMessage(msg, acs::AcsMode::DETUMBLE, 0);
|
||||
status = commandQueue->sendMessage(commandQueue->getId(), &msg);
|
||||
if (result != returnvalue::OK) {
|
||||
sif::error << "AcsSubsystem: sending DETUMBLE mode cmd to self has failed" << std::endl;
|
||||
}
|
||||
}
|
||||
if (event.getEvent() == acs::SAFE_RATE_RECOVERY) {
|
||||
CommandMessage msg;
|
||||
ModeMessage::setCmdModeMessage(msg, acs::AcsMode::SAFE, 0);
|
||||
status = commandQueue->sendMessage(commandQueue->getId(), &msg);
|
||||
if (status != returnvalue::OK) {
|
||||
sif::error << "AcsSubsystem: sending SAFE mode cmd to self has failed" << std::endl;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sif::debug << "AcsSubsystem::performChildOperation: Did not subscribe "
|
||||
"to this event message"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,12 @@ class EiveSystem : public Subsystem {
|
||||
EiveSystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables);
|
||||
|
||||
private:
|
||||
ReturnValue_t initialize() override;
|
||||
void performChildOperation() override;
|
||||
void announceMode(bool recursive) override;
|
||||
void handleEventMessages();
|
||||
|
||||
MessageQueueIF* eventQueue = nullptr;
|
||||
};
|
||||
|
||||
#endif /* MISSION_SYSTEM_EIVESYSTEM_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user