hopefully last EM fix for v2.0
EIVE/eive-obsw/pipeline/pr-develop This commit looks good Details

This commit is contained in:
Robin Müller 2023-04-14 21:44:23 +02:00
parent b47bda8ed1
commit b98f91f6c1
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 62 additions and 55 deletions

View File

@ -48,6 +48,9 @@ will consitute of a breaking change warranting a new major release:
- UDP TMTC Bridge: 50 -> 120
- TCP TMTC Bridge: 50 -> 120
- Service 5: 120 -> 160, number of events handled in one cycle increased to 80
- EM: PCDU dummy is not a device handler anymore, but a custom power switcher object. This avoids
some issues where the event manager could not send an event message to the PCDU dummy because
the FDIR event queue was too small.
## Added

View File

@ -63,8 +63,7 @@ void ObjectFactory::produce(void* args) {
PowerSwitchIF* pwrSwitcher = nullptr;
#if OBSW_ADD_GOMSPACE_PCDU == 0
auto* comCookieDummy = new ComCookieDummy();
pwrSwitcher = new PcduHandlerDummy(objects::PCDU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy);
pwrSwitcher = new PcduHandlerDummy(objects::PCDU_HANDLER);
#else
createPcduComponents(gpioComIF, &pwrSwitcher, enableHkSets);
#endif

View File

@ -1,49 +1,20 @@
#include "PcduHandlerDummy.h"
#include <fsfw/ipc/QueueFactory.h>
#include <mission/power/gsDefs.h>
#include "mission/power/defs.h"
PcduHandlerDummy::PcduHandlerDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie)
: DeviceHandlerBase(objectId, comif, comCookie), dummySwitcher(objectId, 18, 18, false) {
PcduHandlerDummy::PcduHandlerDummy(object_id_t objectId)
: SystemObject(objectId), manager(this, nullptr), dummySwitcher(objectId, 18, 18, false) {
switcherLock = MutexFactory::instance()->createMutex();
queue = QueueFactory::instance()->createMessageQueue(20);
}
PcduHandlerDummy::~PcduHandlerDummy() {}
void PcduHandlerDummy::doStartUp() { setMode(MODE_NORMAL); }
void PcduHandlerDummy::doShutDown() { setMode(MODE_OFF); }
ReturnValue_t PcduHandlerDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) {
return NOTHING_TO_SEND;
}
ReturnValue_t PcduHandlerDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) {
return NOTHING_TO_SEND;
}
ReturnValue_t PcduHandlerDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData,
size_t commandDataLen) {
return returnvalue::OK;
}
ReturnValue_t PcduHandlerDummy::scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) {
return returnvalue::OK;
}
ReturnValue_t PcduHandlerDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) {
return returnvalue::OK;
}
void PcduHandlerDummy::fillCommandAndReplyMap() {}
uint32_t PcduHandlerDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
ReturnValue_t PcduHandlerDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
ReturnValue_t PcduHandlerDummy::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
return returnvalue::OK;
}
@ -76,7 +47,8 @@ ReturnValue_t PcduHandlerDummy::getFuseState(uint8_t fuseNr) const {
uint32_t PcduHandlerDummy::getSwitchDelayMs(void) const { return dummySwitcher.getSwitchDelayMs(); }
void PcduHandlerDummy::performOperationHook() {
ReturnValue_t PcduHandlerDummy::performOperation(uint8_t opCode) {
// TODO: Handle HK messages in queue.
SwitcherBoolArray switcherChangeCopy{};
{
MutexGuard mg(switcherLock);
@ -93,4 +65,18 @@ void PcduHandlerDummy::performOperationHook() {
switchChangeArray[idx] = false;
}
}
return returnvalue::OK;
}
object_id_t PcduHandlerDummy::getObjectId() const { return SystemObject::getObjectId(); }
MessageQueueId_t PcduHandlerDummy::getCommandQueue() const { return queue->getId(); }
dur_millis_t PcduHandlerDummy::getPeriodicOperationFrequency() const {
// TODO: dummy value. Retrieve from intiitalize after task creation..
return 400;
}
LocalDataPoolManager* PcduHandlerDummy::getHkManagerHandle() { return &manager; }
LocalPoolDataSetBase* PcduHandlerDummy::getDataSetHandle(sid_t sid) { return nullptr; }

View File

@ -3,7 +3,10 @@
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw/power/DummyPowerSwitcher.h>
class PcduHandlerDummy : public DeviceHandlerBase, public PowerSwitchIF {
class PcduHandlerDummy : public PowerSwitchIF,
public HasLocalDataPoolIF,
public SystemObject,
public ExecutableObjectIF {
public:
static const DeviceCommandId_t SIMPLE_COMMAND = 1;
static const DeviceCommandId_t PERIODIC_REPLY = 2;
@ -11,33 +14,49 @@ class PcduHandlerDummy : public DeviceHandlerBase, public PowerSwitchIF {
static const uint8_t SIMPLE_COMMAND_DATA = 1;
static const uint8_t PERIODIC_REPLY_DATA = 2;
PcduHandlerDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie);
PcduHandlerDummy(object_id_t objectId);
virtual ~PcduHandlerDummy();
protected:
MutexIF *switcherLock;
MessageQueueIF* queue;
LocalDataPoolManager manager;
MutexIF* switcherLock;
DummyPowerSwitcher dummySwitcher;
using SwitcherBoolArray = std::array<bool, 18>;
ReturnValue_t performOperation(uint8_t opCode) override;
SwitcherBoolArray switchChangeArray{};
void performOperationHook() override;
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId,
size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
void fillCommandAndReplyMap() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
ReturnValue_t sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) override;
ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override;
ReturnValue_t getSwitchState(power::Switch_t switchNr) const override;
ReturnValue_t getFuseState(uint8_t fuseNr) const override;
uint32_t getSwitchDelayMs(void) const override;
object_id_t getObjectId() const override;
/** Command queue for housekeeping messages. */
MessageQueueId_t getCommandQueue() const override;
dur_millis_t getPeriodicOperationFrequency() const override;
/**
* Every class implementing this interface should have a local data pool manager. This
* function will return a reference to the manager.
* @return
*/
LocalDataPoolManager* getHkManagerHandle() override;
/**
* This function is used by the pool manager to get a valid dataset
* from a SID. This function is protected to prevent users from
* using raw data set pointers which could not be thread-safe. Users
* should use the #ProvidesDataPoolSubscriptionIF.
* @param sid Corresponding structure ID
* @return
*/
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
};