seems to work, improve dummy PCDU handler
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
parent
ff6ad60eed
commit
23a4b08709
@ -2,8 +2,12 @@
|
||||
|
||||
#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) {}
|
||||
: DeviceHandlerBase(objectId, comif, comCookie), dummySwitcher(objectId, 18, 18, false) {
|
||||
switcherLock = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
PcduHandlerDummy::~PcduHandlerDummy() {}
|
||||
|
||||
@ -44,6 +48,17 @@ ReturnValue_t PcduHandlerDummy::initializeLocalDataPool(localpool::DataPool &loc
|
||||
}
|
||||
|
||||
ReturnValue_t PcduHandlerDummy::sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) {
|
||||
if (onOff == SWITCH_ON) {
|
||||
triggerEvent(power::SWITCH_CMD_SENT, true, switchNr);
|
||||
} else {
|
||||
triggerEvent(power::SWITCH_CMD_SENT, false, switchNr);
|
||||
}
|
||||
{
|
||||
MutexGuard mg(switcherLock);
|
||||
// To simulate a real PCDU, remember the switch change to trigger a SWITCH_HAS_CHANGED event
|
||||
// at a later stage.
|
||||
switchChangeArray[switchNr] = true;
|
||||
}
|
||||
return dummySwitcher.sendSwitchCommand(switchNr, onOff);
|
||||
}
|
||||
|
||||
@ -60,3 +75,22 @@ ReturnValue_t PcduHandlerDummy::getFuseState(uint8_t fuseNr) const {
|
||||
}
|
||||
|
||||
uint32_t PcduHandlerDummy::getSwitchDelayMs(void) const { return dummySwitcher.getSwitchDelayMs(); }
|
||||
|
||||
void PcduHandlerDummy::performOperationHook() {
|
||||
SwitcherBoolArray switcherChangeCopy{};
|
||||
{
|
||||
MutexGuard mg(switcherLock);
|
||||
std::memcpy(switcherChangeCopy.data(), switchChangeArray.data(), switchChangeArray.size());
|
||||
}
|
||||
for (uint8_t idx = 0; idx < switcherChangeCopy.size(); idx++) {
|
||||
if (switcherChangeCopy[idx]) {
|
||||
if (dummySwitcher.getSwitchState(idx) == PowerSwitchIF::SWITCH_ON) {
|
||||
triggerEvent(power::SWITCH_HAS_CHANGED, true, idx);
|
||||
} else {
|
||||
triggerEvent(power::SWITCH_HAS_CHANGED, false, idx);
|
||||
}
|
||||
MutexGuard mg(switcherLock);
|
||||
switchChangeArray[idx] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,12 @@ class PcduHandlerDummy : public DeviceHandlerBase, public PowerSwitchIF {
|
||||
virtual ~PcduHandlerDummy();
|
||||
|
||||
protected:
|
||||
MutexIF *switcherLock;
|
||||
DummyPowerSwitcher dummySwitcher;
|
||||
using SwitcherBoolArray = std::array<bool, 18>;
|
||||
|
||||
SwitcherBoolArray switchChangeArray{};
|
||||
void performOperationHook() override;
|
||||
void doStartUp() override;
|
||||
void doShutDown() override;
|
||||
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
|
||||
|
Loading…
Reference in New Issue
Block a user