diff --git a/bsp_q7s/callbacks/pcduSwitchCb.cpp b/bsp_q7s/callbacks/pcduSwitchCb.cpp index ec5f4dc5..f9b6c761 100644 --- a/bsp_q7s/callbacks/pcduSwitchCb.cpp +++ b/bsp_q7s/callbacks/pcduSwitchCb.cpp @@ -10,8 +10,8 @@ void pcdu::switchCallback(GOMSPACE::Pdu pdu, uint8_t channel, bool state, void* return; } if (pdu == GOMSPACE::Pdu::PDU1) { - PDU1::SwitchChannels typedChannel = static_cast(channel); - if (typedChannel == PDU1::SwitchChannels::ACS_A_SIDE) { + PDU1::Channels typedChannel = static_cast(channel); + if (typedChannel == PDU1::Channels::ACS_A_SIDE) { if (state) { gpioComIF->pullHigh(gpioIds::GNSS_0_NRESET); } else { @@ -20,8 +20,8 @@ void pcdu::switchCallback(GOMSPACE::Pdu pdu, uint8_t channel, bool state, void* } } else if (pdu == GOMSPACE::Pdu::PDU2) { - PDU2::SwitchChannels typedChannel = static_cast(channel); - if (typedChannel == PDU2::SwitchChannels::ACS_B_SIDE) { + PDU2::Channels typedChannel = static_cast(channel); + if (typedChannel == PDU2::Channels::ACS_B_SIDE) { if (state) { gpioComIF->pullHigh(gpioIds::GNSS_1_NRESET); } else { diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index d72beb8d..c155e705 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -192,7 +192,7 @@ void ObjectFactory::produce(void* args) { starTrackerCookie->setNoFixedSizeReply(); StrHelper* strHelper = new StrHelper(objects::STR_HELPER); new StarTrackerHandler(objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie, strHelper, - pcduSwitches::PDU1_CH2_STAR_TRACKER_5V); + pcdu::PDU1_CH2_STAR_TRACKER_5V); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ @@ -601,7 +601,7 @@ void ObjectFactory::createHeaterComponents() { heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio); new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, - objects::PCDU_HANDLER, pcduSwitches::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V); + objects::PCDU_HANDLER, pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V); } void ObjectFactory::createSolarArrayDeploymentComponents() { @@ -621,7 +621,7 @@ void ObjectFactory::createSolarArrayDeploymentComponents() { // TODO: Find out burn time. For now set to 1000 ms. new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF, solarArrayDeplCookie, objects::PCDU_HANDLER, - pcduSwitches::Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V, + pcdu::Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V, gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000); } @@ -632,7 +632,7 @@ void ObjectFactory::createSyrlinksComponents() { syrlinksUartCookie->setParityEven(); new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie, - pcduSwitches::PDU1_CH1_SYRLINKS_12V); + pcdu::PDU1_CH1_SYRLINKS_12V); } void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF) { @@ -668,7 +668,7 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF) { supervisorCookie->setNoFixedSizeReply(); new PlocSupervisorHandler(objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, supervisorCookie, Gpio(gpioIds::ENABLE_SUPV_UART, gpioComIF), - pcduSwitches::PDU1_CH6_PLOC_12V); + pcdu::PDU1_CH6_PLOC_12V); #endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */ static_cast(consumer); } @@ -925,8 +925,8 @@ void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* // Create device handler components auto plPcduHandler = new PayloadPcduHandler( objects::PLPCDU_HANDLER, objects::SPI_COM_IF, spiCookie, gpioComIF, SdCardManager::instance(), - pwrSwitcher, pcduSwitches::Switches::PDU2_CH1_PL_PCDU_BATT_0_14V8, - pcduSwitches::Switches::PDU2_CH6_PL_PCDU_BATT_1_14V8, false); + pwrSwitcher, pcdu::Switches::PDU2_CH1_PL_PCDU_BATT_0_14V8, + pcdu::Switches::PDU2_CH6_PL_PCDU_BATT_1_14V8, false); spiCookie->setCallbackMode(PayloadPcduHandler::extConvAsTwoCallback, plPcduHandler); // plPcduHandler->enablePeriodicPrintout(true, 5); // static_cast(plPcduHandler); diff --git a/common/config/devices/powerSwitcherList.h b/common/config/devices/powerSwitcherList.h index 1981bb9c..d032428b 100644 --- a/common/config/devices/powerSwitcherList.h +++ b/common/config/devices/powerSwitcherList.h @@ -1,72 +1,6 @@ #ifndef FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ #define FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ -#include "OBSWConfig.h" - -#include - -#include -#include - -namespace pcduSwitches { - -/* Switches are uint8_t datatype and go from 0 to 255 */ -enum Switches: power::Switch_t { - PDU1_CH0_TCS_BOARD_3V3, - PDU1_CH1_SYRLINKS_12V, - PDU1_CH2_STAR_TRACKER_5V, - PDU1_CH3_MGT_5V, - PDU1_CH4_SUS_NOMINAL_3V3, - PDU1_CH5_SOLAR_CELL_EXP_5V, - PDU1_CH6_PLOC_12V, - PDU1_CH7_ACS_A_SIDE_3V3, - PDU1_CH8_UNOCCUPIED, - - PDU2_CH0_Q7S, - PDU2_CH1_PL_PCDU_BATT_0_14V8, - PDU2_CH2_RW_5V, - PDU2_CH3_TCS_BOARD_HEATER_IN_8V, - PDU2_CH4_SUS_REDUNDANT_3V3, - PDU2_CH5_DEPLOYMENT_MECHANISM_8V, - PDU2_CH6_PL_PCDU_BATT_1_14V8, - PDU2_CH7_ACS_BOARD_SIDE_B_3V3, - PDU2_CH8_PAYLOAD_CAMERA, - NUMBER_OF_SWITCHES -}; - -static const uint8_t ON = 1; -static const uint8_t OFF = 0; - -// Output states after reboot of the PDUs - -const std::array INIT_SWITCH_STATES = { - // PDU 1 -// Because the TE0720 is not connected to the PCDU, this switch is always on -#ifdef TE0720_1CFA - ON, -#else - OFF, -#endif - OFF, - OFF, - OFF, - OFF, - OFF, - OFF, - OFF, - OFF, - - // PDU 2 - ON, - OFF, - OFF, - OFF, - OFF, - OFF, - OFF, - OFF, - OFF -}; -} +#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" #endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/fsfw b/fsfw index a11d7455..94ed5822 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit a11d7455dfaf2e736f73f6c4dda1f8c06b9f1234 +Subproject commit 94ed5822971575e9715c39c86ab4466c81718441 diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 267b5f4d..7811fdbe 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -280,7 +280,7 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, TcsBoardHelper helper(rtdIds); TcsBoardAssembly* tcsBoardAss = new TcsBoardAssembly(objects::TCS_BOARD_ASS, objects::NO_OBJECT, pwrSwitcher, - pcduSwitches::Switches::PDU1_CH0_TCS_BOARD_3V3, helper); + pcdu::Switches::PDU1_CH0_TCS_BOARD_3V3, helper); static_cast(tcsBoardAss); #endif // OBSW_ADD_RTD_DEVICES == 1 } diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index 26c09901..fd11a8a2 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -1,6 +1,7 @@ #include "GomspaceDeviceHandler.h" #include +#include #include "devicedefinitions/GomSpacePackets.h" #include "devicedefinitions/powerDefinitions.h" @@ -356,6 +357,46 @@ ReturnValue_t GomspaceDeviceHandler::setParamCallback(SetParamMessageUnpacker& u return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t GomspaceDeviceHandler::initializePduPool( + localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager, + std::array initOutEnb) { + localDataPoolMap.emplace(P60System::pool::PDU_CURRENTS, new PoolEntry(9)); + localDataPoolMap.emplace(P60System::pool::PDU_VOLTAGES, new PoolEntry(9)); + + localDataPoolMap.emplace(P60System::pool::PDU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_CONV_EN_3, new PoolEntry({0})); + + localDataPoolMap.emplace(P60System::pool::PDU_OUT_ENABLE, + new PoolEntry(initOutEnb.data(), initOutEnb.size())); + + localDataPoolMap.emplace(P60System::pool::PDU_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_BATT_MODE, new PoolEntry({0})); + + localDataPoolMap.emplace(P60System::pool::PDU_LATCHUPS, new PoolEntry(9)); + + localDataPoolMap.emplace(P60System::pool::PDU_DEVICES, new PoolEntry(8)); + localDataPoolMap.emplace(P60System::pool::PDU_STATUSES, new PoolEntry(8)); + + localDataPoolMap.emplace(P60System::pool::PDU_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::pool::PDU_WDT_CSP_LEFT2, new PoolEntry({0})); + return RETURN_OK; +} + ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() { WatchdogResetCommand watchdogResetCommand; size_t cspPacketLen = 0; @@ -405,3 +446,112 @@ ReturnValue_t GomspaceDeviceHandler::printStatus(DeviceCommandId_t cmd) { sif::info << "No printHkTable implementation given.." << std::endl; return HasReturnvaluesIF::RETURN_OK; } + +ReturnValue_t GomspaceDeviceHandler::parsePduHkTable(PDU::PduCoreHk& coreHk, PDU::PduAuxHk& auxHk, + const uint8_t* packet) { + uint16_t dataOffset = 0; + PoolReadGuard pg0(&coreHk); + PoolReadGuard pg1(&auxHk); + if (pg0.getReadResult() != HasReturnvaluesIF::RETURN_OK or + pg1.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 datasets failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + /* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. */ + dataOffset += 12; + for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) { + coreHk.currents[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; + dataOffset += 4; + } + for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) { + coreHk.voltages[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; + dataOffset += 4; + } + + auxHk.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + auxHk.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + coreHk.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + + auxHk.converterEnable1 = *(packet + dataOffset); + dataOffset += 3; + auxHk.converterEnable2 = *(packet + dataOffset); + dataOffset += 3; + auxHk.converterEnable3 = *(packet + dataOffset); + dataOffset += 3; + + for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) { + coreHk.outputEnables[idx] = packet[dataOffset]; + dataOffset += 3; + } + + auxHk.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + coreHk.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + auxHk.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + auxHk.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); + dataOffset += 4; + coreHk.battMode = *(packet + dataOffset); + /* +10 because here begins the second gomspace csp packet */ + dataOffset += 3 + 10; + + for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) { + auxHk.latchups[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + } + + for (uint8_t idx = 0; idx < PDU::DEVICES_NUM; idx++) { + auxHk.deviceTypes[idx] = *(packet + dataOffset); + dataOffset += 3; + } + for (uint8_t idx = 0; idx < PDU::DEVICES_NUM; idx++) { + auxHk.devicesStatus[idx] = *(packet + dataOffset); + dataOffset += 3; + } + + auxHk.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + auxHk.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + auxHk.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + auxHk.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + auxHk.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + auxHk.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + auxHk.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + auxHk.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + auxHk.csp1WatchdogPingsLeft = *(packet + dataOffset); + dataOffset += 3; + auxHk.csp2WatchdogPingsLeft = *(packet + dataOffset); + + coreHk.setChanged(true); + if (not coreHk.isValid()) { + coreHk.setValidity(true, true); + } + if (not auxHk.isValid()) { + auxHk.setValidity(true, true); + } + return RETURN_OK; +} diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index fedc91d9..7c1555bc 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -110,6 +110,12 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { virtual ReturnValue_t childCommandHook(DeviceCommandId_t cmd, const uint8_t *commandData, size_t commandDataLen); + ReturnValue_t parsePduHkTable(PDU::PduCoreHk &coreHk, PDU::PduAuxHk &auxHk, + const uint8_t *packet); + ReturnValue_t initializePduPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager, + std::array initOutEnb); + private: SetParamMessageUnpacker setParamCacher; /** diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index d37673fc..83275e37 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -111,7 +111,7 @@ void P60DockHandler::parseHkTableReply(const uint8_t *packet) { dataOffset += 6; coreHk.bootCount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - if(firstHk) { + if (firstHk) { triggerEvent(P60_BOOT_COUNT, coreHk.bootCount.value); } dataOffset += 6; @@ -216,11 +216,11 @@ void P60DockHandler::parseHkTableReply(const uint8_t *packet) { ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { using namespace P60System; - localDataPoolMap.emplace(pool::CURRENTS, &hkCurrents); + localDataPoolMap.emplace(pool::P60_CURRENTS, &hkCurrents); - localDataPoolMap.emplace(pool::VOLTAGES, &hkVoltages); + localDataPoolMap.emplace(pool::P60_VOLTAGES, &hkVoltages); - localDataPoolMap.emplace(pool::OUTPUT_ENABLE, &outputEnables); + localDataPoolMap.emplace(pool::P60_OUTPUT_ENABLE, &outputEnables); localDataPoolMap.emplace(pool::P60DOCK_TEMPERATURE_1, new PoolEntry({0})); localDataPoolMap.emplace(pool::P60DOCK_TEMPERATURE_2, new PoolEntry({0})); diff --git a/mission/devices/PCDUHandler.cpp b/mission/devices/PCDUHandler.cpp index c819b223..218293e2 100644 --- a/mission/devices/PCDUHandler.cpp +++ b/mission/devices/PCDUHandler.cpp @@ -11,8 +11,9 @@ PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) : SystemObject(setObjectId), poolManager(this, nullptr), - pdu2HkTableDataset(this), - pdu1HkTableDataset(this), + pdu1CoreHk(this), + pdu2CoreHk(this), + switcherSet(this), cmdQueueSize(cmdQueueSize) { auto mqArgs = MqArgs(setObjectId, static_cast(this)); commandQueue = QueueFactory::instance()->createMessageQueue( @@ -51,8 +52,8 @@ ReturnValue_t PCDUHandler::initialize() { return RETURN_FAILED; } result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - static_cast(P60System::SetIds::PDU_2), this->getObjectId(), commandQueue->getId(), - true); + static_cast(P60System::SetIds::PDU_2_CORE), this->getObjectId(), + commandQueue->getId(), true); if (result != RETURN_OK) { sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " << "PDU2Handler" << std::endl; @@ -67,8 +68,8 @@ ReturnValue_t PCDUHandler::initialize() { return RETURN_FAILED; } result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - static_cast(P60System::SetIds::PDU_1), this->getObjectId(), commandQueue->getId(), - true); + static_cast(P60System::SetIds::PDU_1_CORE), this->getObjectId(), + commandQueue->getId(), true); if (result != RETURN_OK) { sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " << "PDU1Handler" << std::endl; @@ -79,9 +80,13 @@ ReturnValue_t PCDUHandler::initialize() { } void PCDUHandler::initializeSwitchStates() { - using namespace pcduSwitches; - for (uint8_t idx = 0; idx < Switches::NUMBER_OF_SWITCHES; idx++) { - switchStates[idx] = INIT_SWITCH_STATES[idx]; + using namespace pcdu; + for (uint8_t idx = 0; idx < NUMBER_OF_SWITCHES; idx++) { + if (idx < PDU::CHANNELS_LEN) { + switchStates[idx] = INIT_SWITCHES_PDU1[idx]; + } else { + switchStates[idx] = INIT_SWITCHES_PDU2[idx]; + } } } @@ -103,11 +108,12 @@ void PCDUHandler::readCommandQueue() { MessageQueueId_t PCDUHandler::getCommandQueue() const { return commandQueue->getId(); } void PCDUHandler::handleChangedDataset(sid_t sid, store_address_t storeId, bool* clearMessage) { - if (sid == sid_t(objects::PDU2_HANDLER, static_cast(P60System::SetIds::PDU_2))) { - updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset); + if (sid == sid_t(objects::PDU2_HANDLER, static_cast(P60System::SetIds::PDU_2_CORE))) { + updateHkTableDataset(storeId, &pdu2CoreHk, &timeStampPdu2HkDataset); updatePdu2SwitchStates(); - } else if (sid == sid_t(objects::PDU1_HANDLER, static_cast(P60System::SetIds::PDU_1))) { - updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset); + } else if (sid == + sid_t(objects::PDU1_HANDLER, static_cast(P60System::SetIds::PDU_1_CORE))) { + updateHkTableDataset(storeId, &pdu1CoreHk, &timeStampPdu1HkDataset); updatePdu1SwitchStates(); } else { sif::error << "PCDUHandler::handleChangedDataset: Invalid sid" << std::endl; @@ -143,29 +149,33 @@ void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSet } void PCDUHandler::updatePdu2SwitchStates() { - using namespace pcduSwitches; + using namespace pcdu; + using namespace PDU2; GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU2; - PoolReadGuard rg(&pdu2HkTableDataset); - if (rg.getReadResult() == RETURN_OK) { + PoolReadGuard rg0(&switcherSet); + PoolReadGuard rg1(&pdu2CoreHk); + if (rg0.getReadResult() == RETURN_OK and rg1.getReadResult() == RETURN_OK) { + for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) { + switcherSet.pdu2Switches[idx] = pdu2CoreHk.outputEnables[idx]; + } MutexGuard mg(pwrMutex); - checkAndUpdateSwitch(pdu, Switches::PDU2_CH0_Q7S, pdu2HkTableDataset.outEnabledQ7S.value); + checkAndUpdateSwitch(pdu, Switches::PDU2_CH0_Q7S, pdu2CoreHk.outputEnables[Channels::Q7S]); checkAndUpdateSwitch(pdu, Switches::PDU2_CH1_PL_PCDU_BATT_0_14V8, - pdu2HkTableDataset.outEnabledPlPCDUCh1.value); - checkAndUpdateSwitch(pdu, Switches::PDU2_CH2_RW_5V, - pdu2HkTableDataset.outEnabledReactionWheels.value); + pdu2CoreHk.outputEnables[Channels::PAYLOAD_PCDU_CH1]); + checkAndUpdateSwitch(pdu, Switches::PDU2_CH2_RW_5V, pdu2CoreHk.outputEnables[Channels::RW]); checkAndUpdateSwitch(pdu, Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V, - pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value); + pdu2CoreHk.outputEnables[Channels::TCS_HEATER_IN]); checkAndUpdateSwitch(pdu, Switches::PDU2_CH4_SUS_REDUNDANT_3V3, - pdu2HkTableDataset.outEnabledSUSRedundant.value); + pdu2CoreHk.outputEnables[Channels::SUS_REDUNDANT]); checkAndUpdateSwitch(pdu, Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V, - pdu2HkTableDataset.outEnabledDeplMechanism.value); + pdu2CoreHk.outputEnables[Channels::DEPY_MECHANISM]); checkAndUpdateSwitch(pdu, Switches::PDU2_CH6_PL_PCDU_BATT_1_14V8, - pdu2HkTableDataset.outEnabledPlPCDUCh6.value); + pdu2CoreHk.outputEnables[Channels::PAYLOAD_PCDU_CH6]); checkAndUpdateSwitch(pdu, Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3, - pdu2HkTableDataset.outEnabledAcsBoardSideB.value); + pdu2CoreHk.outputEnables[Channels::ACS_B_SIDE]); checkAndUpdateSwitch(pdu, Switches::PDU2_CH8_PAYLOAD_CAMERA, - pdu2HkTableDataset.outEnabledPayloadCamera.value); + pdu2CoreHk.outputEnables[Channels::PAYLOAD_CAMERA]); if (firstSwitchInfoPdu2) { firstSwitchInfoPdu2 = false; } @@ -176,27 +186,33 @@ void PCDUHandler::updatePdu2SwitchStates() { } void PCDUHandler::updatePdu1SwitchStates() { - using namespace pcduSwitches; - PoolReadGuard rg(&pdu1HkTableDataset); + using namespace pcdu; + using namespace PDU1; + PoolReadGuard rg0(&switcherSet); + PoolReadGuard rg1(&pdu1CoreHk); GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU1; - if (rg.getReadResult() == RETURN_OK) { + if (rg0.getReadResult() == RETURN_OK and rg1.getReadResult() == RETURN_OK) { + for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) { + switcherSet.pdu1Switches[idx] = pdu1CoreHk.outputEnables[idx]; + } MutexGuard mg(pwrMutex); checkAndUpdateSwitch(pdu, Switches::PDU1_CH0_TCS_BOARD_3V3, - pdu1HkTableDataset.outEnabledTCSBoard3V3.value); + pdu1CoreHk.outputEnables[Channels::TCS_BOARD_3V3]); checkAndUpdateSwitch(pdu, Switches::PDU1_CH1_SYRLINKS_12V, - pdu1HkTableDataset.outEnabledSyrlinks.value); + pdu1CoreHk.outputEnables[Channels::SYRLINKS]); checkAndUpdateSwitch(pdu, Switches::PDU1_CH2_STAR_TRACKER_5V, - pdu1HkTableDataset.outEnabledStarTracker.value); - checkAndUpdateSwitch(pdu, Switches::PDU1_CH3_MGT_5V, pdu1HkTableDataset.outEnabledMGT.value); + pdu1CoreHk.outputEnables[Channels::STR]); + checkAndUpdateSwitch(pdu, Switches::PDU1_CH3_MGT_5V, pdu1CoreHk.outputEnables[Channels::MGT]); checkAndUpdateSwitch(pdu, Switches::PDU1_CH4_SUS_NOMINAL_3V3, - pdu1HkTableDataset.outEnabledSUSNominal.value); + pdu1CoreHk.outputEnables[Channels::SUS_NOMINAL]); checkAndUpdateSwitch(pdu, Switches::PDU1_CH5_SOLAR_CELL_EXP_5V, - pdu1HkTableDataset.outEnabledSolarCellExp.value); - checkAndUpdateSwitch(pdu, Switches::PDU1_CH6_PLOC_12V, pdu1HkTableDataset.outEnabledPLOC.value); + pdu1CoreHk.outputEnables[Channels::SOL_CELL_EXPERIMENT]); + checkAndUpdateSwitch(pdu, Switches::PDU1_CH6_PLOC_12V, + pdu1CoreHk.outputEnables[Channels::PLOC]); checkAndUpdateSwitch(pdu, Switches::PDU1_CH7_ACS_A_SIDE_3V3, - pdu1HkTableDataset.outEnabledAcsBoardSideA.value); + pdu1CoreHk.outputEnables[Channels::ACS_A_SIDE]); checkAndUpdateSwitch(pdu, Switches::PDU1_CH8_UNOCCUPIED, - pdu1HkTableDataset.outEnabledChannel8.value); + pdu1CoreHk.outputEnables[Channels::UNUSED]); if (firstSwitchInfoPdu1) { firstSwitchInfoPdu1 = false; } @@ -208,7 +224,7 @@ void PCDUHandler::updatePdu1SwitchStates() { LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { return &poolManager; } ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) { - using namespace pcduSwitches; + using namespace pcdu; ReturnValue_t result; uint16_t memoryAddress = 0; size_t parameterValueSize = sizeof(uint8_t); @@ -216,94 +232,94 @@ ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onO GomspaceDeviceHandler* pdu = nullptr; switch (switchNr) { - case pcduSwitches::PDU1_CH0_TCS_BOARD_3V3: { + case pcdu::PDU1_CH0_TCS_BOARD_3V3: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3; pdu = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcduSwitches::PDU1_CH1_SYRLINKS_12V: { + case pcdu::PDU1_CH1_SYRLINKS_12V: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_SYRLINKS; pdu = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcduSwitches::PDU1_CH2_STAR_TRACKER_5V: { + case pcdu::PDU1_CH2_STAR_TRACKER_5V: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_STAR_TRACKER; pdu = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcduSwitches::PDU1_CH3_MGT_5V: { + case pcdu::PDU1_CH3_MGT_5V: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_MGT; pdu = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcduSwitches::PDU1_CH4_SUS_NOMINAL_3V3: { + case pcdu::PDU1_CH4_SUS_NOMINAL_3V3: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL; pdu = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcduSwitches::PDU1_CH5_SOLAR_CELL_EXP_5V: { + case pcdu::PDU1_CH5_SOLAR_CELL_EXP_5V: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP; pdu = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcduSwitches::PDU1_CH6_PLOC_12V: { + case pcdu::PDU1_CH6_PLOC_12V: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_PLOC; pdu = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcduSwitches::PDU1_CH7_ACS_A_SIDE_3V3: { + case pcdu::PDU1_CH7_ACS_A_SIDE_3V3: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A; pdu = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } - case pcduSwitches::PDU1_CH8_UNOCCUPIED: { + case pcdu::PDU1_CH8_UNOCCUPIED: { memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_CHANNEL8; pdu = ObjectManager::instance()->get(objects::PDU1_HANDLER); break; } // This is a dangerous command. Reject/Igore it for now - case pcduSwitches::PDU2_CH0_Q7S: { + case pcdu::PDU2_CH0_Q7S: { return RETURN_FAILED; // memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_Q7S; // pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); // break; } - case pcduSwitches::PDU2_CH1_PL_PCDU_BATT_0_14V8: { + case pcdu::PDU2_CH1_PL_PCDU_BATT_0_14V8: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH1; pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcduSwitches::PDU2_CH2_RW_5V: { + case pcdu::PDU2_CH2_RW_5V: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_RW; pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcduSwitches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V: { + case pcdu::PDU2_CH3_TCS_BOARD_HEATER_IN_8V: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN; pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcduSwitches::PDU2_CH4_SUS_REDUNDANT_3V3: { + case pcdu::PDU2_CH4_SUS_REDUNDANT_3V3: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_SUS_REDUNDANT; pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcduSwitches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V: { + case pcdu::PDU2_CH5_DEPLOYMENT_MECHANISM_8V: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM; pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcduSwitches::PDU2_CH6_PL_PCDU_BATT_1_14V8: { + case pcdu::PDU2_CH6_PL_PCDU_BATT_1_14V8: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6; pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcduSwitches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3: { + case pcdu::PDU2_CH7_ACS_BOARD_SIDE_B_3V3: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_B; pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; } - case pcduSwitches::PDU2_CH8_PAYLOAD_CAMERA: { + case pcdu::PDU2_CH8_PAYLOAD_CAMERA: { memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA; pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); break; @@ -355,7 +371,7 @@ ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onO ReturnValue_t PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) { return RETURN_OK; } ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { - if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) { + if (switchNr >= pcdu::NUMBER_OF_SWITCHES) { sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; return RETURN_FAILED; } @@ -377,212 +393,10 @@ object_id_t PCDUHandler::getObjectId() const { return SystemObject::getObjectId( ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { - using namespace pcduSwitches; - using namespace P60System; - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_Q7S, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_RW, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_RW, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_VCC, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VBAT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CONV_EN_1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CONV_EN_2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CONV_EN_3, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_OUT_EN_Q7S, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU2_CH0_Q7S]})); - localDataPoolMap.emplace( - pool::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU2_CH1_PL_PCDU_BATT_0_14V8]})); - localDataPoolMap.emplace(pool::PDU2_OUT_EN_RW, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU2_CH2_RW_5V]})); -#ifdef TE0720_1CFA - localDataPoolMap.emplace(pool::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({1})); -#else - localDataPoolMap.emplace( - pool::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V]})); -#endif - localDataPoolMap.emplace( - pool::PDU2_OUT_EN_SUS_REDUNDANT, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU2_CH4_SUS_REDUNDANT_3V3]})); - localDataPoolMap.emplace( - pool::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V]})); - localDataPoolMap.emplace( - pool::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU2_CH6_PL_PCDU_BATT_1_14V8]})); - localDataPoolMap.emplace( - pool::PDU2_OUT_EN_ACS_BOARD_SIDE_B, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3]})); - localDataPoolMap.emplace( - pool::PDU2_OUT_EN_PAYLOAD_CAMERA, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU2_CH8_PAYLOAD_CAMERA]})); - - localDataPoolMap.emplace(pool::PDU2_BOOTCAUSE, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_BOOTCNT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_UPTIME, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_RESETCAUSE, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_BATT_MODE, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_LATCHUP_Q7S, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_RW, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_DEVICE_0, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_4, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_5, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_6, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_7, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_DEVICE_0_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_1_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_2_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_3_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_4_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_5_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_6_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_7_STATUS, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_WDT_CNT_GND, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CNT_I2C, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CNT_CAN, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CNT_CSP1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CNT_CSP2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_GND_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_I2C_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CAN_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CSP_LEFT1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CSP_LEFT2, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_CURRENT_OUT_MGT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_CURRENT_OUT_PLOC, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry({0})); - - localDataPoolMap.emplace( - pool::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU1_CH0_TCS_BOARD_3V3]})); - localDataPoolMap.emplace( - pool::PDU1_VOLTAGE_OUT_SYRLINKS, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU1_CH1_SYRLINKS_12V]})); - localDataPoolMap.emplace( - pool::PDU1_VOLTAGE_OUT_STAR_TRACKER, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU1_CH2_STAR_TRACKER_5V]})); - localDataPoolMap.emplace(pool::PDU1_VOLTAGE_OUT_MGT, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU1_CH3_MGT_5V]})); - localDataPoolMap.emplace( - pool::PDU1_VOLTAGE_OUT_SUS_NOMINAL, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU1_CH4_SUS_NOMINAL_3V3]})); - localDataPoolMap.emplace( - pool::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU1_CH5_SOLAR_CELL_EXP_5V]})); - localDataPoolMap.emplace( - pool::PDU1_VOLTAGE_OUT_PLOC, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU1_CH6_PLOC_12V]})); - localDataPoolMap.emplace( - pool::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU1_CH7_ACS_A_SIDE_3V3]})); - localDataPoolMap.emplace( - pool::PDU1_VOLTAGE_OUT_CHANNEL8, - new PoolEntry({INIT_SWITCH_STATES[Switches::PDU1_CH8_UNOCCUPIED]})); - - localDataPoolMap.emplace(pool::PDU1_VCC, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_VBAT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_CONV_EN_1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_CONV_EN_2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_CONV_EN_3, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_OUT_EN_SYRLINKS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_OUT_EN_MGT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_OUT_EN_PLOC, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_OUT_EN_CHANNEL8, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU1_BOOTCAUSE, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_BOOTCNT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_UPTIME, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_RESETCAUSE, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_BATT_MODE, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_LATCHUP_SYRLINKS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_LATCHUP_MGT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_LATCHUP_PLOC, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_LATCHUP_CHANNEL8, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU1_DEVICE_0, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_4, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_5, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_6, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_7, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU1_DEVICE_0_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_1_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_2_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_3_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_4_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_5_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_6_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_DEVICE_7_STATUS, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU1_WDT_CNT_GND, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_WDT_CNT_I2C, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_WDT_CNT_CAN, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_WDT_CNT_CSP1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_WDT_CNT_CSP2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_WDT_GND_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_WDT_I2C_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_WDT_CAN_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_WDT_CSP_LEFT1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU1_WDT_CSP_LEFT2, new PoolEntry({0})); - + using namespace pcdu; + localDataPoolMap.emplace(PoolIds::PDU1_SWITCHES, &pdu1Switches); + localDataPoolMap.emplace(PoolIds::PDU1_SWITCHES, &pdu2Switches); + poolManager.subscribeForPeriodicPacket(switcherSet.getSid(), false, 5.0, true); return HasReturnvaluesIF::RETURN_OK; } @@ -602,17 +416,17 @@ uint32_t PCDUHandler::getPeriodicOperationFrequency() const { return pstInterval void PCDUHandler::setTaskIF(PeriodicTaskIF* task) { executingTask = task; } LocalPoolDataSetBase* PCDUHandler::getDataSetHandle(sid_t sid) { - if (sid == pdu2HkTableDataset.getSid()) { - return &pdu2HkTableDataset; + if (sid == switcherSet.getSid()) { + return &switcherSet; } else { sif::error << "PCDUHandler::getDataSetHandle: Invalid sid" << std::endl; return nullptr; } } -void PCDUHandler::checkAndUpdateSwitch(GOMSPACE::Pdu pdu, pcduSwitches::Switches switchIdx, +void PCDUHandler::checkAndUpdateSwitch(GOMSPACE::Pdu pdu, pcdu::Switches switchIdx, uint8_t setValue) { - using namespace pcduSwitches; + using namespace pcdu; if (switchStates[switchIdx] != setValue) { #if OBSW_INITIALIZE_SWITCHES == 1 // This code initializes the switches to the default init switch states on every reboot. diff --git a/mission/devices/PCDUHandler.h b/mission/devices/PCDUHandler.h index c44052bb..8f589751 100644 --- a/mission/devices/PCDUHandler.h +++ b/mission/devices/PCDUHandler.h @@ -2,6 +2,7 @@ #define MISSION_DEVICES_PCDUHANDLER_H_ #include +#include #include #include #include @@ -56,21 +57,29 @@ class PCDUHandler : public PowerSwitchIF, /** Housekeeping manager. Handles updates of local pool variables. */ LocalDataPoolManager poolManager; + /** Hk table dataset of PDU1 */ + PDU1::Pdu1CoreHk pdu1CoreHk; /** * The dataset holding the hk table of PDU2. This dataset is a copy of the PDU2 HK dataset * of the PDU2Handler. Each time the PDU2Handler updates his HK dataset, a copy is sent * to this object via a HousekeepingMessage. */ - PDU2::PDU2HkTableDataset pdu2HkTableDataset; + PDU2::Pdu2CoreHk pdu2CoreHk; + + pcdu::SwitcherStates switcherSet; + + PoolEntry pdu1Switches = + PoolEntry(pcdu::INIT_SWITCHES_PDU1.data(), pcdu::INIT_SWITCHES_PDU1.size()); + PoolEntry pdu2Switches = + PoolEntry(pcdu::INIT_SWITCHES_PDU2.data(), pcdu::INIT_SWITCHES_PDU2.size()); + /** The timeStamp of the current pdu2HkTableDataset */ CCSDSTime::CDS_short timeStampPdu2HkDataset; - /** Hk table dataset of PDU1 */ - PDU1::PDU1HkTableDataset pdu1HkTableDataset; /** The timeStamp of the current pdu1HkTableDataset */ CCSDSTime::CDS_short timeStampPdu1HkDataset; - uint8_t switchStates[pcduSwitches::NUMBER_OF_SWITCHES]; + uint8_t switchStates[pcdu::NUMBER_OF_SWITCHES]; /** * Pointer to the IPCStore. * This caches the pointer received from the objectManager in the constructor. @@ -119,7 +128,7 @@ class PCDUHandler : public PowerSwitchIF, */ void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, CCSDSTime::CDS_short* datasetTimeStamp); - void checkAndUpdateSwitch(GOMSPACE::Pdu pdu, pcduSwitches::Switches switchIdx, uint8_t setValue); + void checkAndUpdateSwitch(GOMSPACE::Pdu pdu, pcdu::Switches switchIdx, uint8_t setValue); }; #endif /* MISSION_DEVICES_PCDUHANDLER_H_ */ diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index be26d984..0f7bbfe1 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -3,12 +3,13 @@ #include #include -#include "OBSWConfig.h" +#include "devices/powerSwitcherList.h" PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE), - pdu1HkTableDataset(this) {} + coreHk(this), + auxHk(this) {} PDU1Handler::~PDU1Handler() {} @@ -19,52 +20,7 @@ ReturnValue_t PDU1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { parseHkTableReply(packet); - handleDeviceTM(&pdu1HkTableDataset, id, true); - -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU1 == 1 - pdu1HkTableDataset.read(); - sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 << std::endl; - sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl; - sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker - << std::endl; - sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl; - sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal << std::endl; - sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp - << std::endl; - sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl; - sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA - << std::endl; - sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA - << std::endl; - - sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3 << std::endl; - sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl; - sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker - << std::endl; - sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl; - sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal << std::endl; - sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp - << std::endl; - sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl; - sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA - << std::endl; - sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8 << std::endl; - printOutputSwitchStates(); - sif::info << "PDU1 battery mode: " << static_cast(pdu1HkTableDataset.battMode.value) - << std::endl; - sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl; - float vbat = pdu1HkTableDataset.vbat.value * 0.001; - sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl; - float temperatureC = pdu1HkTableDataset.temperature.value * 0.1; - sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl; - sif::info << "PDU1 csp1 watchdog pings before reboot: " - << static_cast(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) - << std::endl; - sif::info << "PDU1 csp2 watchdog pings before reboot: " - << static_cast(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) - << std::endl; - pdu1HkTableDataset.commit(); -#endif + handleDeviceTM(&coreHk, id, true); } void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { @@ -123,315 +79,22 @@ ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker, } void PDU1Handler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - PoolReadGuard pg(&pdu1HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if (readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return; - } - /* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. */ - dataOffset += 12; - pdu1HkTableDataset.currentOutTCSBoard3V3 = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutStarTracker = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSUSNominal = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSolarCellExp = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutACSBoardSideA = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - - pdu1HkTableDataset.voltageOutTCSBoard3V3 = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutStarTracker = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSUSNominal = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSolarCellExp = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutACSBoardSideA = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - - pdu1HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - - pdu1HkTableDataset.converterEnable1 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.converterEnable2 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.converterEnable3 = *(packet + dataOffset); - dataOffset += 3; - - pdu1HkTableDataset.outEnabledTCSBoard3V3 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSyrlinks = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledStarTracker = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledMGT = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSUSNominal = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSolarCellExp = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledPLOC = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledAcsBoardSideA = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledChannel8 = *(packet + dataOffset); - dataOffset += 3; - - pdu1HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); - dataOffset += 4; - pdu1HkTableDataset.battMode = *(packet + dataOffset); - /* +10 because here begins the second gomspace csp packet */ - dataOffset += 3 + 10; - - pdu1HkTableDataset.latchupsTcsBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsMgt = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSusNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSolarCellExp = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsPloc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsAcsBoardSideA = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - - pdu1HkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; - - pdu1HkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; - - pdu1HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.groundWatchdogSecondsLeft = - *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.i2cWatchdogSecondsLeft = - *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.canWatchdogSecondsLeft = - *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); - - pdu1HkTableDataset.setChanged(true); - if (not pdu1HkTableDataset.isValid()) { - pdu1HkTableDataset.setValidity(true, true); - } + GomspaceDeviceHandler::parsePduHkTable(coreHk, auxHk, packet); } ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(P60System::pool::PDU1_CURRENT_OUT_TCS_BOARD_3V3, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_CURRENT_OUT_STAR_TRACKER, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_CURRENT_OUT_MGT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_CURRENT_OUT_SUS_NOMINAL, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_CURRENT_OUT_PLOC, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry({0})); - - localDataPoolMap.emplace(P60System::pool::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_VOLTAGE_OUT_STAR_TRACKER, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_VOLTAGE_OUT_MGT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_VOLTAGE_OUT_SUS_NOMINAL, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry({0})); - - localDataPoolMap.emplace(P60System::pool::PDU1_VCC, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_VBAT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_CONV_EN_1, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_CONV_EN_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_CONV_EN_3, new PoolEntry({0})); - - localDataPoolMap.emplace(P60System::pool::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_OUT_EN_SYRLINKS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_OUT_EN_MGT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_OUT_EN_SOLAR_CELL_EXP, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_OUT_EN_PLOC, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_OUT_EN_ACS_BOARD_SIDE_A, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_OUT_EN_CHANNEL8, new PoolEntry({0})); - - localDataPoolMap.emplace(P60System::pool::PDU1_BOOTCAUSE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_BOOTCNT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_UPTIME, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_RESETCAUSE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_BATT_MODE, new PoolEntry({0})); - - localDataPoolMap.emplace(P60System::pool::PDU1_LATCHUP_TCS_BOARD_3V3, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_LATCHUP_SYRLINKS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_LATCHUP_STAR_TRACKER, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_LATCHUP_MGT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_LATCHUP_SOLAR_CELL_EXP, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_LATCHUP_PLOC, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_LATCHUP_ACS_BOARD_SIDE_A, - new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_LATCHUP_CHANNEL8, new PoolEntry({0})); - - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_0, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_1, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_4, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_6, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_7, new PoolEntry({0})); - - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_0_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_1_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_2_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_3_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_4_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_5_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_6_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_DEVICE_7_STATUS, new PoolEntry({0})); - - localDataPoolMap.emplace(P60System::pool::PDU1_WDT_CNT_GND, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_WDT_CNT_I2C, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_WDT_CNT_CAN, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_WDT_CNT_CSP1, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_WDT_CNT_CSP2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_WDT_GND_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_WDT_I2C_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_WDT_CAN_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_WDT_CSP_LEFT1, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::pool::PDU1_WDT_CSP_LEFT2, new PoolEntry({0})); - poolManager.subscribeForPeriodicPacket(pdu1HkTableDataset.getSid(), false, 0.4, true); + initializePduPool(localDataPoolMap, poolManager, pcdu::INIT_SWITCHES_PDU1); + poolManager.subscribeForPeriodicPacket(coreHk.getSid(), false, 10.0, false); + poolManager.subscribeForPeriodicPacket(auxHk.getSid(), false, 30.0, false); return HasReturnvaluesIF::RETURN_OK; } LocalPoolDataSetBase *PDU1Handler::getDataSetHandle(sid_t sid) { - if (sid == pdu1HkTableDataset.getSid()) { - return &pdu1HkTableDataset; + if (sid == coreHk.getSid()) { + return &coreHk; + } else if (sid == auxHk.getSid()) { + return &auxHk; } return nullptr; } @@ -440,7 +103,7 @@ ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = RETURN_OK; switch (cmd) { case (GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&pdu1HkTableDataset); + PoolReadGuard pg(&coreHk); result = pg.getReadResult(); if (result != HasReturnvaluesIF::RETURN_OK) { break; @@ -449,7 +112,7 @@ ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { break; } case (GOMSPACE::PRINT_LATCHUPS): { - PoolReadGuard pg(&pdu1HkTableDataset); + PoolReadGuard pg(&auxHk); result = pg.getReadResult(); if (result != HasReturnvaluesIF::RETURN_OK) { break; @@ -468,72 +131,46 @@ ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { } void PDU1Handler::printHkTableSwitchVI() { + using namespace PDU1; sif::info << "PDU1 Info: " << std::endl; - sif::info << "Boot Cause: " << pdu1HkTableDataset.bootcause << " | Boot Count: " << std::setw(4) - << std::right << pdu1HkTableDataset.bootcount << std::endl; - sif::info << "Reset Cause: " << pdu1HkTableDataset.resetcause - << " | Battery Mode: " << static_cast(pdu1HkTableDataset.battMode.value) - << std::endl; + sif::info << "Boot Cause: " << auxHk.bootcause << " | Boot Count: " << std::setw(4) << std::right + << coreHk.bootcount << std::endl; + sif::info << "Reset Cause: " << auxHk.resetcause + << " | Battery Mode: " << static_cast(coreHk.battMode.value) << std::endl; sif::info << "SwitchState, Currents [mA], Voltages [mV]:" << std::endl; - sif::info << std::setw(30) << std::left << "TCS Board" << std::dec << "| " - << unsigned(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << ", " << std::setw(4) - << std::right << pdu1HkTableDataset.currentOutTCSBoard3V3.value << ", " << std::setw(4) - << pdu1HkTableDataset.voltageOutTCSBoard3V3.value << std::endl; - sif::info << std::setw(30) << std::left << "Syrlinks" << std::dec << "| " - << unsigned(pdu1HkTableDataset.outEnabledSyrlinks.value) << ", " << std::setw(4) - << std::right << pdu1HkTableDataset.currentOutSyrlinks.value << ", " << std::setw(4) - << pdu1HkTableDataset.voltageOutSyrlinks.value << std::endl; - sif::info << std::setw(30) << std::left << "Star Tracker" << std::dec << "| " - << static_cast(pdu1HkTableDataset.outEnabledStarTracker.value) << ", " - << std::setw(4) << std::right << pdu1HkTableDataset.currentOutStarTracker.value << ", " - << std::setw(4) << pdu1HkTableDataset.voltageOutStarTracker.value << std::endl; - sif::info << std::setw(30) << std::left << "MGT" << std::dec << "| " - << static_cast(pdu1HkTableDataset.outEnabledMGT.value) << ", " - << std::setw(4) << std::right << pdu1HkTableDataset.currentOutMGT.value << ", " - << std::setw(4) << pdu1HkTableDataset.voltageOutMGT.value << std::endl; - sif::info << std::setw(30) << std::left << "SuS nominal" << std::dec << "| " - << static_cast(pdu1HkTableDataset.outEnabledSUSNominal.value) << ", " - << std::setw(4) << std::right << pdu1HkTableDataset.currentOutSUSNominal.value << ", " - << std::setw(4) << pdu1HkTableDataset.voltageOutSUSNominal.value << std::endl; - sif::info << std::setw(30) << std::left << "Solar Cell Experiment" << std::dec << "| " - << static_cast(pdu1HkTableDataset.outEnabledSolarCellExp.value) << ", " - << std::setw(4) << std::right << pdu1HkTableDataset.currentOutSolarCellExp.value << ", " - << std::setw(4) << pdu1HkTableDataset.voltageOutSolarCellExp.value << std::endl; - sif::info << std::setw(30) << std::left << "PLOC" << std::dec << "| " - << static_cast(pdu1HkTableDataset.outEnabledPLOC.value) << ", " - << std::setw(4) << std::right << pdu1HkTableDataset.currentOutPLOC.value << ", " - << std::setw(4) << pdu1HkTableDataset.voltageOutPLOC.value << std::endl; - sif::info << std::setw(30) << std::left << "ACS Side A" << std::dec << "| " - << static_cast(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << ", " - << std::setw(4) << std::right << pdu1HkTableDataset.currentOutACSBoardSideA.value - << ", " << std::setw(4) << pdu1HkTableDataset.voltageOutACSBoardSideA.value - << std::endl; - sif::info << std::setw(30) << std::left << "Channel 8" << std::dec << "| " - << static_cast(pdu1HkTableDataset.outEnabledChannel8.value) << ", " - << std::setw(4) << std::right << pdu1HkTableDataset.currentOutChannel8.value << ", " - << std::setw(4) << pdu1HkTableDataset.voltageOutChannel8.value << std::right - << std::endl; + auto printerHelper = [&](std::string channelStr, Channels idx) { + sif::info << std::setw(30) << std::left << channelStr << std::dec << "| " + << unsigned(coreHk.outputEnables[idx]) << ", " << std::setw(4) << std::right + << coreHk.currents[idx] << ", " << std::setw(4) << coreHk.voltages[idx] << std::endl; + }; + + printerHelper("TCS Board", Channels::TCS_BOARD_3V3); + printerHelper("Syrlinks", Channels::SYRLINKS); + printerHelper("Star Tracker", Channels::STR); + printerHelper("MGT", Channels::MGT); + printerHelper("SUS Nominal", Channels::SUS_NOMINAL); + printerHelper("SCEX", Channels::SOL_CELL_EXPERIMENT); + printerHelper("PLOC", Channels::PLOC); + printerHelper("ACS Board A Side", Channels::ACS_A_SIDE); + printerHelper("Channel 8", Channels::UNUSED); + printerHelper("Syrlinks", Channels::SYRLINKS); } void PDU1Handler::printHkTableLatchups() { + using namespace PDU1; sif::info << "PDU1 Latchup Information" << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "TCS Board" << std::dec << "| " - << std::setw(4) << std::right << pdu1HkTableDataset.latchupsTcsBoard3V3 << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Syrlinks" << std::dec << "| " - << std::setw(4) << std::right << pdu1HkTableDataset.latchupsSyrlinks << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Star Tracker" << std::dec << "| " - << std::setw(4) << std::right << pdu1HkTableDataset.latchupsStarTracker << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "MGT" << std::dec << "| " - << std::setw(4) << std::right << pdu1HkTableDataset.latchupsMgt << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "SuS Nominal" << std::dec << "| " - << std::setw(4) << std::right << pdu1HkTableDataset.latchupsSusNominal << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Solar Cell Experiment" << std::dec - << "| " << std::setw(4) << std::right << pdu1HkTableDataset.latchupsSolarCellExp - << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "PLOC" << std::dec << "| " - << std::setw(4) << std::right << pdu1HkTableDataset.latchupsPloc << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "ACS A Side" << std::dec << "| " - << std::setw(4) << std::right << pdu1HkTableDataset.latchupsAcsBoardSideA << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Channel 8" << std::dec << "| " - << std::setw(4) << std::right << pdu1HkTableDataset.latchupsChannel8 << std::endl; + auto printerHelper = [&](std::string channelStr, Channels idx) { + sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "TCS Board" << std::dec << "| " + << std::setw(4) << std::right << auxHk.latchups[idx] << std::endl; + }; + printerHelper("TCS Board", Channels::TCS_BOARD_3V3); + printerHelper("Syrlinks", Channels::SYRLINKS); + printerHelper("Star Tracker", Channels::STR); + printerHelper("MGT", Channels::MGT); + printerHelper("SUS Nominal", Channels::SUS_NOMINAL); + printerHelper("SCEX", Channels::SOL_CELL_EXPERIMENT); + printerHelper("PLOC", Channels::PLOC); + printerHelper("ACS Board A Side", Channels::ACS_A_SIDE); + printerHelper("Channel 8", Channels::UNUSED); + printerHelper("Syrlinks", Channels::SYRLINKS); } diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 67afc922..845f57ec 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -43,7 +43,8 @@ class PDU1Handler : public GomspaceDeviceHandler { static constexpr uint8_t MAX_CHANNEL_STR_WIDTH = 24; /** Dataset for the housekeeping table of the PDU1 */ - PDU1::PDU1HkTableDataset pdu1HkTableDataset; + PDU1::Pdu1CoreHk coreHk; + PDU1::Pdu1AuxHk auxHk; GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr; void* hookArgs = nullptr; diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 69a8f3fd..38cdb9e5 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -3,12 +3,13 @@ #include #include -#include "OBSWConfig.h" +#include "devices/powerSwitcherList.h" PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE), - pdu2HkTableDataset(this) {} + coreHk(this), + auxHk(this) {} PDU2Handler::~PDU2Handler() {} @@ -23,29 +24,7 @@ void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac * Hk table will be sent to the commander if hk table request was not triggered by the * PDU2Handler itself. */ - handleDeviceTM(&pdu2HkTableDataset, id, true); - -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU2 == 1 - pdu2HkTableDataset.read(); - sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV" - << std::endl; - sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl; - float vbat = pdu2HkTableDataset.vbat.value * 0.1; - sif::info << "PDU2 VBAT: " << vbat << std::endl; - float temperatureC = pdu2HkTableDataset.temperature.value * 0.1; - sif::info << "PDU2 Temperature: " << temperatureC << " °C" << std::endl; - printOutputSwitchStates(); - sif::info << "PDU2 uptime: " << pdu2HkTableDataset.uptime << " seconds" << std::endl; - sif::info << "PDU2 battery mode: " << unsigned(pdu2HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU2 ground watchdog reboots: " << pdu2HkTableDataset.gndWdtReboots << std::endl; - sif::info << "PDU2 ground watchdog timer seconds left: " - << pdu2HkTableDataset.groundWatchdogSecondsLeft << " seconds" << std::endl; - sif::info << "PDU2 csp1 watchdog pings before reboot: " - << unsigned(pdu2HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU2 csp2 watchdog pings before reboot: " - << unsigned(pdu2HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - pdu2HkTableDataset.commit(); -#endif + handleDeviceTM(&coreHk, id, true); } void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { @@ -54,315 +33,23 @@ void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, vo } LocalPoolDataSetBase *PDU2Handler::getDataSetHandle(sid_t sid) { - if (sid == pdu2HkTableDataset.getSid()) { - return &pdu2HkTableDataset; + if (sid == coreHk.getSid()) { + return &coreHk; + } else if (sid == auxHk.getSid()) { + return &auxHk; } return nullptr; } void PDU2Handler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - pdu2HkTableDataset.read(); - /** - * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. - */ - dataOffset += 12; - pdu2HkTableDataset.currentOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadPCDUCh1 = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutReactionWheels = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutTCSBoardHeaterIn = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutSUSRedundant = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutDeplMechanism = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadPCDUCh6 = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutACSBoardSideB = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadCamera = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - - pdu2HkTableDataset.voltageOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadPCDUCh1 = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutReactionWheels = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutTCSBoardHeaterIn = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutSUSRedundant = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutDeplMechanism = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadPCDUCh6 = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutACSBoardSideB = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadCamera = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - - pdu2HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - - pdu2HkTableDataset.converterEnable1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.converterEnable2 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.converterEnable3 = *(packet + dataOffset); - dataOffset += 3; - - pdu2HkTableDataset.outEnabledQ7S = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPlPCDUCh1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledReactionWheels = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledTCSBoardHeaterIn = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledSUSRedundant = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledDeplMechanism = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPlPCDUCh6 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledAcsBoardSideB = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPayloadCamera = *(packet + dataOffset); - dataOffset += 3; - - pdu2HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); - dataOffset += 4; - pdu2HkTableDataset.battMode = *(packet + dataOffset); - /* +10 because here begins the second gomspace csp packet */ - dataOffset += 3 + 10; - - pdu2HkTableDataset.latchupsQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadPcduCh1 = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsRw = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsTcsBoardHeaterIn = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsSusRedundant = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsDeplMenchanism = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadPcduCh6 = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsAcsBoardSideB = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadCamera = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - - pdu2HkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; - - pdu2HkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; - - pdu2HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.groundWatchdogSecondsLeft = - *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.i2cWatchdogSecondsLeft = - *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.canWatchdogSecondsLeft = - *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); - - pdu2HkTableDataset.commit(); - pdu2HkTableDataset.setChanged(true); + GomspaceDeviceHandler::parsePduHkTable(coreHk, auxHk, packet); } ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - using namespace P60System; - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_Q7S, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_RW, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_RW, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_VCC, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_VBAT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CONV_EN_1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CONV_EN_2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_CONV_EN_3, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_OUT_EN_Q7S, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_OUT_EN_RW, new PoolEntry({0})); -#ifdef TE0720_1CFA - localDataPoolMap.emplace(pool::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({1})); -#else - localDataPoolMap.emplace(pool::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({0})); -#endif - localDataPoolMap.emplace(pool::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_BOOTCAUSE, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_BOOTCNT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_UPTIME, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_RESETCAUSE, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_BATT_MODE, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_LATCHUP_Q7S, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_RW, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_DEVICE_0, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_4, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_5, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_6, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_7, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_DEVICE_0_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_1_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_2_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_3_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_4_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_5_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_6_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_DEVICE_7_STATUS, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::PDU2_WDT_CNT_GND, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CNT_I2C, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CNT_CAN, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CNT_CSP1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CNT_CSP2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_GND_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_I2C_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CAN_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CSP_LEFT1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::PDU2_WDT_CSP_LEFT2, new PoolEntry({0})); -#if OBSW_ENABLE_PERIODIC_HK == 1 - poolManager.subscribeForPeriodicPacket(pdu2HkTableDataset.getSid(), false, 0.4, true); -#endif + initializePduPool(localDataPoolMap, poolManager, pcdu::INIT_SWITCHES_PDU1); + poolManager.subscribeForPeriodicPacket(coreHk.getSid(), false, 10.0, false); + poolManager.subscribeForPeriodicPacket(auxHk.getSid(), false, 30.0, false); return HasReturnvaluesIF::RETURN_OK; } @@ -370,7 +57,7 @@ ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = RETURN_OK; switch (cmd) { case (GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&pdu2HkTableDataset); + PoolReadGuard pg(&coreHk); result = pg.getReadResult(); if (result != HasReturnvaluesIF::RETURN_OK) { break; @@ -379,7 +66,7 @@ ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { break; } case (GOMSPACE::PRINT_LATCHUPS): { - PoolReadGuard pg(&pdu2HkTableDataset); + PoolReadGuard pg(&auxHk); result = pg.getReadResult(); if (result != HasReturnvaluesIF::RETURN_OK) { break; @@ -398,77 +85,45 @@ ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { } void PDU2Handler::printHkTableSwitchVI() { + using namespace PDU2; sif::info << "PDU2 Info:" << std::endl; - sif::info << "Boot Cause: " << pdu2HkTableDataset.bootcause << " | Boot Count: " << std::setw(4) - << std::right << pdu2HkTableDataset.bootcount << std::endl; - sif::info << "Reset Cause: " << pdu2HkTableDataset.resetcause - << " | Battery Mode: " << static_cast(pdu2HkTableDataset.battMode.value) - << std::endl; + sif::info << "Boot Cause: " << auxHk.bootcause << " | Boot Count: " << std::setw(4) << std::right + << coreHk.bootcount << std::endl; + sif::info << "Reset Cause: " << auxHk.resetcause + << " | Battery Mode: " << static_cast(coreHk.battMode.value) << std::endl; sif::info << "SwitchState, Currents [mA], Voltages [mV]: " << std::endl; - sif::info << std::setw(30) << std::left << "Q7S" << std::dec << "| " - << unsigned(pdu2HkTableDataset.outEnabledQ7S.value) << ", " << std::setw(4) - << std::right << pdu2HkTableDataset.currentOutQ7S.value << ", " << std::setw(4) - << pdu2HkTableDataset.voltageOutQ7S.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload PCDU Channel 1" << std::dec << "| " - << unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh1.value) << ", " << std::setw(4) - << std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh1.value << ", " - << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh1.value << std::endl; - sif::info << std::setw(30) << std::left << "Reaction Wheels" << std::dec << "| " - << unsigned(pdu2HkTableDataset.outEnabledReactionWheels.value) << ", " << std::setw(4) - << std::right << pdu2HkTableDataset.currentOutReactionWheels.value << ", " - << std::setw(4) << pdu2HkTableDataset.voltageOutReactionWheels.value << std::endl; - sif::info << std::setw(30) << std::left << "TCS Board Heater Input" << std::dec << "| " - << unsigned(pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value) << ", " << std::setw(4) - << std::right << pdu2HkTableDataset.currentOutTCSBoardHeaterIn.value << ", " - << std::setw(4) << pdu2HkTableDataset.voltageOutTCSBoardHeaterIn.value << std::endl; - sif::info << std::setw(30) << std::left << "SuS Redundant" << std::dec << "| " - << unsigned(pdu2HkTableDataset.outEnabledSUSRedundant.value) << ", " << std::setw(4) - << std::right << pdu2HkTableDataset.currentOutSUSRedundant.value << ", " << std::setw(4) - << pdu2HkTableDataset.voltageOutSUSRedundant.value << std::endl; - sif::info << std::setw(30) << std::left << "Deployment mechanism" << std::dec << "| " - << unsigned(pdu2HkTableDataset.outEnabledDeplMechanism.value) << ", " << std::setw(4) - << std::right << pdu2HkTableDataset.currentOutDeplMechanism.value << ", " - << std::setw(4) << pdu2HkTableDataset.voltageOutDeplMechanism.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload PCDU Channel 6" << std::dec << "| " - << unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh6.value) << ", " << std::setw(4) - << std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh6.value << ", " - << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh6.value << std::endl; - sif::info << std::setw(30) << std::left << "ACS Board Side B" << std::dec << "| " - << unsigned(pdu2HkTableDataset.outEnabledAcsBoardSideB.value) << ", " << std::setw(4) - << std::right << pdu2HkTableDataset.currentOutACSBoardSideB.value << ", " - << std::setw(4) << pdu2HkTableDataset.voltageOutACSBoardSideB.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload Camera" << std::dec << "| " - << unsigned(pdu2HkTableDataset.outEnabledPayloadCamera.value) << ", " << std::setw(4) - << std::right << pdu2HkTableDataset.currentOutPayloadCamera.value << ", " - << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right - << std::endl; + auto printerHelper = [&](std::string channelStr, Channels idx) { + sif::info << std::setw(30) << std::left << channelStr << std::dec << "| " + << unsigned(coreHk.outputEnables[idx]) << ", " << std::setw(4) << std::right + << coreHk.currents[idx] << ", " << std::setw(4) << coreHk.voltages[idx] << std::endl; + }; + printerHelper("Q7S", Channels::Q7S); + printerHelper("PL PCDU CH1", Channels::PAYLOAD_PCDU_CH1); + printerHelper("Reaction Wheels", Channels::RW); + printerHelper("TCS Board Heater Input", Channels::TCS_HEATER_IN); + printerHelper("SUS Redundant", Channels::SUS_REDUNDANT); + printerHelper("Deployment Mechanism", Channels::DEPY_MECHANISM); + printerHelper("PL PCDU CH6", Channels::PAYLOAD_PCDU_CH6); + printerHelper("ACS Board B Side", Channels::ACS_B_SIDE); + printerHelper("Payload Camera", Channels::PAYLOAD_CAMERA); } void PDU2Handler::printHkTableLatchups() { + using namespace PDU2; sif::info << "PDU2 Latchup Information" << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Q7S" << std::dec << "| " - << std::setw(4) << std::right << pdu2HkTableDataset.latchupsQ7S << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Payload PCDU Channel 1" << std::dec - << "| " << std::setw(4) << std::right << pdu2HkTableDataset.latchupsPayloadPcduCh1 - << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Reaction Wheels" << std::dec - << "| " << std::setw(4) << std::right << pdu2HkTableDataset.latchupsRw << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "TCS Board Heater Input" << std::dec - << "| " << std::setw(4) << std::right << pdu2HkTableDataset.latchupsTcsBoardHeaterIn - << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "SuS Nominal" << std::dec << "| " - << std::setw(4) << std::right << pdu2HkTableDataset.latchupsSusRedundant << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Deployment mechanism" << std::dec - << "| " << std::setw(4) << std::right << pdu2HkTableDataset.latchupsDeplMenchanism - << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Payload PCDU Channel 6" << std::dec - << "| " << std::setw(4) << std::right << pdu2HkTableDataset.latchupsPayloadPcduCh6 - << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "ACS Board Side B" << std::dec - << "| " << std::setw(4) << std::right << pdu2HkTableDataset.latchupsAcsBoardSideB - << std::endl; - sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Payload Camera" << std::dec << "| " - << std::setw(4) << std::right << pdu2HkTableDataset.latchupsPayloadCamera << std::endl; + auto printerHelper = [&](std::string channelStr, Channels idx) { + sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "TCS Board" << std::dec << "| " + << std::setw(4) << std::right << auxHk.latchups[idx] << std::endl; + }; + printerHelper("Q7S", Channels::Q7S); + printerHelper("PL PCDU CH1", Channels::PAYLOAD_PCDU_CH1); + printerHelper("Reaction Wheels", Channels::RW); + printerHelper("TCS Board Heater Input", Channels::TCS_HEATER_IN); + printerHelper("SUS Redundant", Channels::SUS_REDUNDANT); + printerHelper("Deployment Mechanism", Channels::DEPY_MECHANISM); + printerHelper("PL PCDU CH6", Channels::PAYLOAD_PCDU_CH6); + printerHelper("ACS Board B Side", Channels::ACS_B_SIDE); + printerHelper("Payload Camera", Channels::PAYLOAD_CAMERA); } ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker, diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index ab113dda..2680c80e 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -42,7 +42,8 @@ class PDU2Handler : public GomspaceDeviceHandler { static constexpr uint8_t MAX_CHANNEL_STR_WIDTH = 24; /** Dataset for the housekeeping table of the PDU2 */ - PDU2::PDU2HkTableDataset pdu2HkTableDataset; + PDU2::Pdu2CoreHk coreHk; + PDU2::Pdu2AuxHk auxHk; GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr; void* hookArgs = nullptr; diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index 9bb016b7..2b24ba07 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -7,7 +7,7 @@ SolarArrayDeploymentHandler::SolarArrayDeploymentHandler( object_id_t setObjectId_, object_id_t gpioDriverId_, CookieIF* gpioCookie_, - object_id_t mainLineSwitcherObjectId_, pcduSwitches::Switches mainLineSwitch_, gpioId_t deplSA1, + object_id_t mainLineSwitcherObjectId_, pcdu::Switches mainLineSwitch_, gpioId_t deplSA1, gpioId_t deplSA2, uint32_t burnTimeMs) : SystemObject(setObjectId_), gpioDriverId(gpioDriverId_), diff --git a/mission/devices/SolarArrayDeploymentHandler.h b/mission/devices/SolarArrayDeploymentHandler.h index e5d91d3d..d66a0509 100644 --- a/mission/devices/SolarArrayDeploymentHandler.h +++ b/mission/devices/SolarArrayDeploymentHandler.h @@ -43,8 +43,8 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, */ SolarArrayDeploymentHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF* gpioCookie, object_id_t mainLineSwitcherObjectId, - pcduSwitches::Switches mainLineSwitch, gpioId_t deplSA1, - gpioId_t deplSA2, uint32_t burnTimeMs); + pcdu::Switches mainLineSwitch, gpioId_t deplSA1, gpioId_t deplSA2, + uint32_t burnTimeMs); virtual ~SolarArrayDeploymentHandler(); diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 8b19c909..e0d73d22 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -4,9 +4,12 @@ #include #include #include +#include #include +#include "devices/powerSwitcherList.h" + namespace GOMSPACE { enum class Pdu { PDU1, PDU2 }; @@ -45,14 +48,22 @@ namespace P60System { enum class BatteryModes : uint8_t { CRITICAL = 1, SAFE = 2, NORMAL = 3, FULL = 4 }; -enum class SetIds : uint32_t { PDU_1 = 1, PDU_2 = 2, P60_CORE = 3, P60_AUX = 4, ACU = 5 }; +enum class SetIds : uint32_t { + PDU_1_CORE = 1, + PDU_1_AUX = 2, + PDU_2_CORE = 3, + PDU_2_AUX = 4, + P60_CORE = 5, + P60_AUX = 6, + ACU = 7 +}; namespace pool { enum Ids : lp_id_t { - CURRENTS, - VOLTAGES, - OUTPUT_ENABLE, + P60_CURRENTS, + P60_VOLTAGES, + P60_OUTPUT_ENABLE, P60DOCK_TEMPERATURE_1, P60DOCK_TEMPERATURE_2, P60DOCK_BOOT_CAUSE, @@ -90,154 +101,34 @@ enum Ids : lp_id_t { P60DOCK_ANT6_DEPL, P60DOCK_AR6_DEPL, - PDU1_CURRENT_OUT_TCS_BOARD_3V3, - PDU1_CURRENT_OUT_SYRLINKS, - PDU1_CURRENT_OUT_STAR_TRACKER, - PDU1_CURRENT_OUT_MGT, - PDU1_CURRENT_OUT_SUS_NOMINAL, - PDU1_CURRENT_OUT_SOLAR_CELL_EXP, - PDU1_CURRENT_OUT_PLOC, - PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, - PDU1_CURRENT_OUT_CHANNEL8, - PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, - PDU1_VOLTAGE_OUT_SYRLINKS, - PDU1_VOLTAGE_OUT_STAR_TRACKER, - PDU1_VOLTAGE_OUT_MGT, - PDU1_VOLTAGE_OUT_SUS_NOMINAL, - PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, - PDU1_VOLTAGE_OUT_PLOC, - PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, - PDU1_VOLTAGE_OUT_CHANNEL8, - PDU1_VCC, - PDU1_VBAT, - PDU1_TEMPERATURE, - PDU1_CONV_EN_1, - PDU1_CONV_EN_2, - PDU1_CONV_EN_3, - PDU1_OUT_EN_TCS_BOARD_3V3, - PDU1_OUT_EN_SYRLINKS, - PDU1_OUT_EN_STAR_TRACKER, - PDU1_OUT_EN_MGT, - PDU1_OUT_EN_SUS_NOMINAL, - PDU1_OUT_EN_SOLAR_CELL_EXP, - PDU1_OUT_EN_PLOC, - PDU1_OUT_EN_ACS_BOARD_SIDE_A, - PDU1_OUT_EN_CHANNEL8, - PDU1_BOOTCAUSE, - PDU1_BOOTCNT, - PDU1_UPTIME, - PDU1_RESETCAUSE, - PDU1_BATT_MODE, - PDU1_LATCHUP_TCS_BOARD_3V3, - PDU1_LATCHUP_SYRLINKS, - PDU1_LATCHUP_STAR_TRACKER, - PDU1_LATCHUP_MGT, - PDU1_LATCHUP_SUS_NOMINAL, - PDU1_LATCHUP_SOLAR_CELL_EXP, - PDU1_LATCHUP_PLOC, - PDU1_LATCHUP_ACS_BOARD_SIDE_A, - PDU1_LATCHUP_CHANNEL8, - PDU1_DEVICE_0, - PDU1_DEVICE_1, - PDU1_DEVICE_2, - PDU1_DEVICE_3, - PDU1_DEVICE_4, - PDU1_DEVICE_5, - PDU1_DEVICE_6, - PDU1_DEVICE_7, - PDU1_DEVICE_0_STATUS, - PDU1_DEVICE_1_STATUS, - PDU1_DEVICE_2_STATUS, - PDU1_DEVICE_3_STATUS, - PDU1_DEVICE_4_STATUS, - PDU1_DEVICE_5_STATUS, - PDU1_DEVICE_6_STATUS, - PDU1_DEVICE_7_STATUS, - PDU1_WDT_CNT_GND, - PDU1_WDT_CNT_I2C, - PDU1_WDT_CNT_CAN, - PDU1_WDT_CNT_CSP1, - PDU1_WDT_CNT_CSP2, - PDU1_WDT_GND_LEFT, - PDU1_WDT_I2C_LEFT, - PDU1_WDT_CAN_LEFT, - PDU1_WDT_CSP_LEFT1, - PDU1_WDT_CSP_LEFT2, - - /** PDU2 Ids */ - PDU2_CURRENT_OUT_Q7S, - PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, - PDU2_CURRENT_OUT_RW, - PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, - PDU2_CURRENT_OUT_SUS_REDUNDANT, - PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, - PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, - PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, - PDU2_CURRENT_OUT_PAYLOAD_CAMERA, - PDU2_VOLTAGE_OUT_Q7S, - PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, - PDU2_VOLTAGE_OUT_RW, - PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, - PDU2_VOLTAGE_OUT_SUS_REDUNDANT, - PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, - PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, - PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, - PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, - PDU2_VCC, - PDU2_VBAT, - PDU2_TEMPERATURE, - PDU2_CONV_EN_1, - PDU2_CONV_EN_2, - PDU2_CONV_EN_3, - PDU2_OUT_EN_Q7S, - PDU2_OUT_EN_PAYLOAD_PCDU_CH1, - PDU2_OUT_EN_RW, - PDU2_OUT_EN_TCS_BOARD_HEATER_IN, - PDU2_OUT_EN_SUS_REDUNDANT, - PDU2_OUT_EN_DEPLOYMENT_MECHANISM, - PDU2_OUT_EN_PAYLOAD_PCDU_CH6, - PDU2_OUT_EN_ACS_BOARD_SIDE_B, - PDU2_OUT_EN_PAYLOAD_CAMERA, - PDU2_BOOTCAUSE, - PDU2_BOOTCNT, - PDU2_UPTIME, - PDU2_RESETCAUSE, - PDU2_BATT_MODE, - PDU2_LATCHUP_Q7S, - PDU2_LATCHUP_PAYLOAD_PCDU_CH1, - PDU2_LATCHUP_RW, - PDU2_LATCHUP_TCS_BOARD_HEATER_IN, - PDU2_LATCHUP_SUS_REDUNDANT, - PDU2_LATCHUP_DEPLOYMENT_MECHANISM, - PDU2_LATCHUP_PAYLOAD_PCDU_CH6, - PDU2_LATCHUP_ACS_BOARD_SIDE_B, - PDU2_LATCHUP_PAYLOAD_CAMERA, - PDU2_DEVICE_0, - PDU2_DEVICE_1, - PDU2_DEVICE_2, - PDU2_DEVICE_3, - PDU2_DEVICE_4, - PDU2_DEVICE_5, - PDU2_DEVICE_6, - PDU2_DEVICE_7, - PDU2_DEVICE_0_STATUS, - PDU2_DEVICE_1_STATUS, - PDU2_DEVICE_2_STATUS, - PDU2_DEVICE_3_STATUS, - PDU2_DEVICE_4_STATUS, - PDU2_DEVICE_5_STATUS, - PDU2_DEVICE_6_STATUS, - PDU2_DEVICE_7_STATUS, - PDU2_WDT_CNT_GND, - PDU2_WDT_CNT_I2C, - PDU2_WDT_CNT_CAN, - PDU2_WDT_CNT_CSP1, - PDU2_WDT_CNT_CSP2, - PDU2_WDT_GND_LEFT, - PDU2_WDT_I2C_LEFT, - PDU2_WDT_CAN_LEFT, - PDU2_WDT_CSP_LEFT1, - PDU2_WDT_CSP_LEFT2, + // IDs for both PDUs + PDU_CURRENTS, + PDU_VOLTAGES, + PDU_VCC, + PDU_VBAT, + PDU_TEMPERATURE, + PDU_CONV_EN_1, + PDU_CONV_EN_2, + PDU_CONV_EN_3, + PDU_OUT_ENABLE, + PDU_BOOTCAUSE, + PDU_BOOTCNT, + PDU_UPTIME, + PDU_RESETCAUSE, + PDU_BATT_MODE, + PDU_LATCHUPS, + PDU_DEVICES, + PDU_STATUSES, + PDU_WDT_CNT_GND, + PDU_WDT_CNT_I2C, + PDU_WDT_CNT_CAN, + PDU_WDT_CNT_CSP1, + PDU_WDT_CNT_CSP2, + PDU_WDT_GND_LEFT, + PDU_WDT_I2C_LEFT, + PDU_WDT_CAN_LEFT, + PDU_WDT_CSP_LEFT1, + PDU_WDT_CSP_LEFT2, /** ACU Ids */ ACU_CURRENT_IN_CHANNEL0, @@ -302,7 +193,7 @@ enum Ids : lp_id_t { ACU_DEVICE_6_STATUS, ACU_DEVICE_7_STATUS, ACU_WDT_CNT_GND, - ACU_WDT_GND_LEFT + ACU_WDT_GND_LEFT, }; } } // namespace P60System @@ -373,18 +264,18 @@ class CoreHkSet : public StaticLocalDataSet<16> { /** Measured output currents */ lp_vec_t currents = - lp_vec_t(sid.objectId, P60System::pool::CURRENTS, + lp_vec_t(sid.objectId, P60System::pool::P60_CURRENTS, this); /** Measured output voltages */ lp_vec_t voltages = - lp_vec_t(sid.objectId, P60System::pool::VOLTAGES, + lp_vec_t(sid.objectId, P60System::pool::P60_VOLTAGES, this); /** Output enable states */ lp_vec_t outputEnables = - lp_vec_t(sid.objectId, P60System::pool::OUTPUT_ENABLE, - this); + lp_vec_t(sid.objectId, + P60System::pool::P60_OUTPUT_ENABLE, this); lp_var_t bootCount = lp_var_t(sid.objectId, P60System::pool::P60DOCK_BOOT_CNT, this); lp_var_t battMode = @@ -495,11 +386,114 @@ static const uint16_t MAX_HKTABLE_ADDRESS = 141; /** The size of the csp reply containing the housekeeping table data */ static const uint16_t HK_TABLE_REPLY_SIZE = 303; static const uint8_t HK_TABLE_ENTRIES = 73; + +static constexpr uint8_t CHANNELS_LEN = 9; +static constexpr uint8_t DEVICES_NUM = 8; + +class PduCoreHk : public StaticLocalDataSet<9> { + public: + PduCoreHk(HasLocalDataPoolIF* owner, uint32_t setId) : StaticLocalDataSet(owner, setId) {} + + PduCoreHk(object_id_t objectId, uint32_t setId) : StaticLocalDataSet(sid_t(objectId, setId)) {} + + /** Measured output currents */ + lp_vec_t currents = + lp_vec_t(sid.objectId, P60System::pool::PDU_CURRENTS, this); + /** Measured output currents */ + lp_vec_t voltages = + lp_vec_t(sid.objectId, P60System::pool::PDU_VOLTAGES, this); + /** Output switch states */ + lp_vec_t outputEnables = + lp_vec_t(sid.objectId, P60System::pool::PDU_VOLTAGES, this); + /** Number of reboots */ + lp_var_t bootcount = + lp_var_t(sid.objectId, P60System::pool::PDU_BOOTCNT, this); + /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ + lp_var_t battMode = + lp_var_t(sid.objectId, P60System::pool::PDU_BATT_MODE, this); + lp_var_t temperature = + lp_var_t(sid.objectId, P60System::pool::PDU_TEMPERATURE, this); +}; + +/** + * @brief This class defines a dataset for the hk table of a PDU + */ +class PduAuxHk : public StaticLocalDataSet<36> { + public: + PduAuxHk(HasLocalDataPoolIF* owner, uint32_t setId) : StaticLocalDataSet(owner, setId) {} + + PduAuxHk(object_id_t objectId, uint32_t setId) : StaticLocalDataSet(sid_t(objectId, setId)) {} + + /** Measured VCC */ + lp_var_t vcc = lp_var_t(sid.objectId, P60System::pool::PDU_VCC, this); + /** Measured VBAT */ + lp_var_t vbat = lp_var_t(sid.objectId, P60System::pool::PDU_VBAT, this); + + /** Output converter enable status */ + lp_var_t converterEnable1 = + lp_var_t(sid.objectId, P60System::pool::PDU_CONV_EN_1, this); + lp_var_t converterEnable2 = + lp_var_t(sid.objectId, P60System::pool::PDU_CONV_EN_2, this); + lp_var_t converterEnable3 = + lp_var_t(sid.objectId, P60System::pool::PDU_CONV_EN_3, this); + + lp_var_t bootcause = + lp_var_t(sid.objectId, P60System::pool::PDU_BOOTCAUSE, this); + + /** Uptime in seconds */ + lp_var_t uptime = lp_var_t(sid.objectId, P60System::pool::PDU_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::pool::PDU_RESETCAUSE, this); + + /** Number of detected latchups on each output channel */ + lp_vec_t latchups = + lp_vec_t(sid.objectId, P60System::pool::PDU_LATCHUPS, this); + + /** + * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is + * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. + */ + lp_vec_t deviceTypes = + lp_vec_t(sid.objectId, P60System::pool::PDU_DEVICES, this); + /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ + lp_vec_t devicesStatus = + lp_vec_t(sid.objectId, P60System::pool::PDU_STATUSES, this); + + /** Number of reboots triggered by the ground watchdog */ + lp_var_t gndWdtReboots = + lp_var_t(sid.objectId, P60System::pool::PDU_WDT_CNT_GND, this); + /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ + lp_var_t i2cWdtReboots = + lp_var_t(sid.objectId, P60System::pool::PDU_WDT_CNT_I2C, this); + /** Number of reboots triggered through the CAN watchdog */ + lp_var_t canWdtReboots = + lp_var_t(sid.objectId, P60System::pool::PDU_WDT_CNT_CAN, this); + /** Number of reboots triggered through the CSP watchdog */ + lp_var_t csp1WdtReboots = + lp_var_t(sid.objectId, P60System::pool::PDU_WDT_CNT_CSP1, this); + lp_var_t csp2WdtReboots = + lp_var_t(sid.objectId, P60System::pool::PDU_WDT_CNT_CSP2, this); + /** Ground watchdog remaining seconds before rebooting */ + lp_var_t groundWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::pool::PDU_WDT_GND_LEFT, this); + /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ + lp_var_t i2cWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::pool::PDU_WDT_I2C_LEFT, this); + /** CAN watchdog remaining seconds before rebooting. */ + lp_var_t canWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::pool::PDU_WDT_CAN_LEFT, this); + /** CSP watchdogs remaining pings before rebooting. */ + lp_var_t csp2WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::pool::PDU_WDT_CSP_LEFT1, this); + lp_var_t csp1WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::pool::PDU_WDT_CSP_LEFT2, this); +}; + } // namespace PDU namespace PDU1 { -enum SwitchChannels : uint8_t { +enum Channels : uint8_t { TCS_BOARD_3V3 = 0, SYRLINKS = 1, STR = 2, @@ -508,7 +502,8 @@ enum SwitchChannels : uint8_t { SOL_CELL_EXPERIMENT = 5, PLOC = 6, ACS_A_SIDE = 7, - UNUSED = 8 + UNUSED = 8, + LEN = 9 }; /** @@ -525,185 +520,29 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_PLOC = 0x4E; static const uint16_t CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A = 0x4F; static const uint16_t CONFIG_ADDRESS_OUT_EN_CHANNEL8 = 0x50; -/** - * @brief This class defines a dataset for the hk table of the PDU1. - */ -class PDU1HkTableDataset : public StaticLocalDataSet { +class Pdu1CoreHk : public ::PDU::PduCoreHk { public: - PDU1HkTableDataset(HasLocalDataPoolIF* owner) - : StaticLocalDataSet(owner, static_cast(::P60System::SetIds::PDU_1)) {} + Pdu1CoreHk(HasLocalDataPoolIF* owner) + : PduCoreHk(owner, static_cast(::P60System::SetIds::PDU_1_CORE)) {} - PDU1HkTableDataset(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, static_cast(::P60System::SetIds::PDU_1))) {} - - /** Measured output currents */ - lp_var_t currentOutTCSBoard3V3 = - lp_var_t(sid.objectId, P60System::pool::PDU1_CURRENT_OUT_TCS_BOARD_3V3, this); - lp_var_t currentOutSyrlinks = - lp_var_t(sid.objectId, P60System::pool::PDU1_CURRENT_OUT_SYRLINKS, this); - lp_var_t currentOutStarTracker = - lp_var_t(sid.objectId, P60System::pool::PDU1_CURRENT_OUT_STAR_TRACKER, this); - lp_var_t currentOutMGT = - lp_var_t(sid.objectId, P60System::pool::PDU1_CURRENT_OUT_MGT, this); - lp_var_t currentOutSUSNominal = - lp_var_t(sid.objectId, P60System::pool::PDU1_CURRENT_OUT_SUS_NOMINAL, this); - lp_var_t currentOutSolarCellExp = - lp_var_t(sid.objectId, P60System::pool::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, this); - lp_var_t currentOutPLOC = - lp_var_t(sid.objectId, P60System::pool::PDU1_CURRENT_OUT_PLOC, this); - lp_var_t currentOutACSBoardSideA = - lp_var_t(sid.objectId, P60System::pool::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, this); - lp_var_t currentOutChannel8 = - lp_var_t(sid.objectId, P60System::pool::PDU1_CURRENT_OUT_CHANNEL8, this); - /** Measured voltage of output channels */ - lp_var_t voltageOutTCSBoard3V3 = - lp_var_t(sid.objectId, P60System::pool::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, this); - lp_var_t voltageOutSyrlinks = - lp_var_t(sid.objectId, P60System::pool::PDU1_VOLTAGE_OUT_SYRLINKS, this); - lp_var_t voltageOutStarTracker = - lp_var_t(sid.objectId, P60System::pool::PDU1_VOLTAGE_OUT_STAR_TRACKER, this); - lp_var_t voltageOutMGT = - lp_var_t(sid.objectId, P60System::pool::PDU1_VOLTAGE_OUT_MGT, this); - lp_var_t voltageOutSUSNominal = - lp_var_t(sid.objectId, P60System::pool::PDU1_VOLTAGE_OUT_SUS_NOMINAL, this); - lp_var_t voltageOutSolarCellExp = - lp_var_t(sid.objectId, P60System::pool::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, this); - lp_var_t voltageOutPLOC = - lp_var_t(sid.objectId, P60System::pool::PDU1_VOLTAGE_OUT_PLOC, this); - lp_var_t voltageOutACSBoardSideA = - lp_var_t(sid.objectId, P60System::pool::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, this); - lp_var_t voltageOutChannel8 = - lp_var_t(sid.objectId, P60System::pool::PDU1_VOLTAGE_OUT_CHANNEL8, this); - /** Measured VCC */ - lp_var_t vcc = lp_var_t(sid.objectId, P60System::pool::PDU1_VCC, this); - /** Measured VBAT */ - lp_var_t vbat = lp_var_t(sid.objectId, P60System::pool::PDU1_VBAT, this); - lp_var_t temperature = - lp_var_t(sid.objectId, P60System::pool::PDU1_TEMPERATURE, this); - /** Output converter enable status */ - lp_var_t converterEnable1 = - lp_var_t(sid.objectId, P60System::pool::PDU1_CONV_EN_1, this); - lp_var_t converterEnable2 = - lp_var_t(sid.objectId, P60System::pool::PDU1_CONV_EN_2, this); - lp_var_t converterEnable3 = - lp_var_t(sid.objectId, P60System::pool::PDU1_CONV_EN_3, this); - - /** Output channels enable status */ - lp_var_t outEnabledTCSBoard3V3 = - lp_var_t(sid.objectId, P60System::pool::PDU1_OUT_EN_TCS_BOARD_3V3, this); - lp_var_t outEnabledSyrlinks = - lp_var_t(sid.objectId, P60System::pool::PDU1_OUT_EN_SYRLINKS, this); - lp_var_t outEnabledStarTracker = - lp_var_t(sid.objectId, P60System::pool::PDU1_OUT_EN_STAR_TRACKER, this); - lp_var_t outEnabledMGT = - lp_var_t(sid.objectId, P60System::pool::PDU1_OUT_EN_MGT, this); - lp_var_t outEnabledSUSNominal = - lp_var_t(sid.objectId, P60System::pool::PDU1_OUT_EN_SUS_NOMINAL, this); - lp_var_t outEnabledSolarCellExp = - lp_var_t(sid.objectId, P60System::pool::PDU1_OUT_EN_SOLAR_CELL_EXP, this); - lp_var_t outEnabledPLOC = - lp_var_t(sid.objectId, P60System::pool::PDU1_OUT_EN_PLOC, this); - lp_var_t outEnabledAcsBoardSideA = - lp_var_t(sid.objectId, P60System::pool::PDU1_OUT_EN_ACS_BOARD_SIDE_A, this); - lp_var_t outEnabledChannel8 = - lp_var_t(sid.objectId, P60System::pool::PDU1_OUT_EN_CHANNEL8, this); - lp_var_t bootcause = - lp_var_t(sid.objectId, P60System::pool::PDU1_BOOTCAUSE, this); - /** Number of reboots */ - lp_var_t bootcount = - lp_var_t(sid.objectId, P60System::pool::PDU1_BOOTCNT, this); - /** Uptime in seconds */ - lp_var_t uptime = lp_var_t(sid.objectId, P60System::pool::PDU1_UPTIME, this); - lp_var_t resetcause = - lp_var_t(sid.objectId, P60System::pool::PDU1_RESETCAUSE, this); - /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ - lp_var_t battMode = - lp_var_t(sid.objectId, P60System::pool::PDU1_BATT_MODE, this); - - /** Number of detected latchups on each output channel */ - lp_var_t latchupsTcsBoard3V3 = - lp_var_t(sid.objectId, P60System::pool::PDU1_LATCHUP_TCS_BOARD_3V3, this); - lp_var_t latchupsSyrlinks = - lp_var_t(sid.objectId, P60System::pool::PDU1_LATCHUP_SYRLINKS, this); - lp_var_t latchupsStarTracker = - lp_var_t(sid.objectId, P60System::pool::PDU1_LATCHUP_STAR_TRACKER, this); - lp_var_t latchupsMgt = - lp_var_t(sid.objectId, P60System::pool::PDU1_LATCHUP_MGT, this); - lp_var_t latchupsSusNominal = - lp_var_t(sid.objectId, P60System::pool::PDU1_LATCHUP_SUS_NOMINAL, this); - lp_var_t latchupsSolarCellExp = - lp_var_t(sid.objectId, P60System::pool::PDU1_LATCHUP_SOLAR_CELL_EXP, this); - lp_var_t latchupsPloc = - lp_var_t(sid.objectId, P60System::pool::PDU1_LATCHUP_PLOC, this); - lp_var_t latchupsAcsBoardSideA = - lp_var_t(sid.objectId, P60System::pool::PDU1_LATCHUP_ACS_BOARD_SIDE_A, this); - lp_var_t latchupsChannel8 = - lp_var_t(sid.objectId, P60System::pool::PDU1_LATCHUP_CHANNEL8, this); - - /** - * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is - * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. - */ - lp_var_t device0 = lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_7, this); - /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ - lp_var_t device0Status = - lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_0_STATUS, this); - lp_var_t device1Status = - lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_1_STATUS, this); - lp_var_t device2Status = - lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_2_STATUS, this); - lp_var_t device3Status = - lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_3_STATUS, this); - lp_var_t device4Status = - lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_4_STATUS, this); - lp_var_t device5Status = - lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_5_STATUS, this); - lp_var_t device6Status = - lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_6_STATUS, this); - lp_var_t device7Status = - lp_var_t(sid.objectId, P60System::pool::PDU1_DEVICE_7_STATUS, this); - - /** Number of reboots triggered by the ground watchdog */ - lp_var_t gndWdtReboots = - lp_var_t(sid.objectId, P60System::pool::PDU1_WDT_CNT_GND, this); - /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ - lp_var_t i2cWdtReboots = - lp_var_t(sid.objectId, P60System::pool::PDU1_WDT_CNT_I2C, this); - /** Number of reboots triggered through the CAN watchdog */ - lp_var_t canWdtReboots = - lp_var_t(sid.objectId, P60System::pool::PDU1_WDT_CNT_CAN, this); - /** Number of reboots triggered through the CSP watchdog */ - lp_var_t csp1WdtReboots = - lp_var_t(sid.objectId, P60System::pool::PDU1_WDT_CNT_CSP1, this); - lp_var_t csp2WdtReboots = - lp_var_t(sid.objectId, P60System::pool::PDU1_WDT_CNT_CSP2, this); - /** Ground watchdog remaining seconds before rebooting */ - lp_var_t groundWatchdogSecondsLeft = - lp_var_t(sid.objectId, P60System::pool::PDU1_WDT_GND_LEFT, this); - /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ - lp_var_t i2cWatchdogSecondsLeft = - lp_var_t(sid.objectId, P60System::pool::PDU1_WDT_I2C_LEFT, this); - /** CAN watchdog remaining seconds before rebooting. */ - lp_var_t canWatchdogSecondsLeft = - lp_var_t(sid.objectId, P60System::pool::PDU1_WDT_CAN_LEFT, this); - /** CSP watchdogs remaining pings before rebooting. */ - lp_var_t csp2WatchdogPingsLeft = - lp_var_t(sid.objectId, P60System::pool::PDU1_WDT_CSP_LEFT1, this); - lp_var_t csp1WatchdogPingsLeft = - lp_var_t(sid.objectId, P60System::pool::PDU1_WDT_CSP_LEFT2, this); + Pdu1CoreHk(object_id_t objectId) + : PduCoreHk(objectId, static_cast(::P60System::SetIds::PDU_1_CORE)) {} }; + +class Pdu1AuxHk : public ::PDU::PduAuxHk { + public: + Pdu1AuxHk(HasLocalDataPoolIF* owner) + : PduAuxHk(owner, static_cast(::P60System::SetIds::PDU_1_AUX)) {} + + Pdu1AuxHk(object_id_t objectId) + : PduAuxHk(objectId, static_cast(::P60System::SetIds::PDU_1_AUX)) {} +}; + } // namespace PDU1 namespace PDU2 { -enum SwitchChannels : uint8_t { +enum Channels : uint8_t { Q7S = 0, PAYLOAD_PCDU_CH1 = 1, RW = 2, @@ -712,7 +551,8 @@ enum SwitchChannels : uint8_t { DEPY_MECHANISM = 5, PAYLOAD_PCDU_CH6 = 6, ACS_B_SIDE = 7, - PAYLOAD_CAMERA = 8 + PAYLOAD_CAMERA = 8, + LEN = 9 }; /** @@ -729,180 +569,24 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6 = 0x4E; static const uint16_t CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_B = 0x4F; static const uint16_t CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA = 0x50; -/** - * @brief This class defines a dataset for the hk table of the PDU2. - */ -class PDU2HkTableDataset : public StaticLocalDataSet { +class Pdu2CoreHk : public ::PDU::PduCoreHk { public: - PDU2HkTableDataset(HasLocalDataPoolIF* owner) - : StaticLocalDataSet(owner, static_cast(::P60System::SetIds::PDU_2)) {} + Pdu2CoreHk(HasLocalDataPoolIF* owner) + : PduCoreHk(owner, static_cast(::P60System::SetIds::PDU_2_CORE)) {} - PDU2HkTableDataset(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, static_cast(::P60System::SetIds::PDU_2))) {} - - /** Measured output currents */ - lp_var_t currentOutQ7S = - lp_var_t(sid.objectId, P60System::pool::PDU2_CURRENT_OUT_Q7S, this); - lp_var_t currentOutPayloadPCDUCh1 = - lp_var_t(sid.objectId, P60System::pool::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, this); - lp_var_t currentOutReactionWheels = - lp_var_t(sid.objectId, P60System::pool::PDU2_CURRENT_OUT_RW, this); - lp_var_t currentOutTCSBoardHeaterIn = - lp_var_t(sid.objectId, P60System::pool::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, this); - lp_var_t currentOutSUSRedundant = - lp_var_t(sid.objectId, P60System::pool::PDU2_CURRENT_OUT_SUS_REDUNDANT, this); - lp_var_t currentOutDeplMechanism = - lp_var_t(sid.objectId, P60System::pool::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, this); - lp_var_t currentOutPayloadPCDUCh6 = - lp_var_t(sid.objectId, P60System::pool::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, this); - lp_var_t currentOutACSBoardSideB = - lp_var_t(sid.objectId, P60System::pool::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, this); - lp_var_t currentOutPayloadCamera = - lp_var_t(sid.objectId, P60System::pool::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, this); - /** Measured voltage of output channels */ - lp_var_t voltageOutQ7S = - lp_var_t(sid.objectId, P60System::pool::PDU2_VOLTAGE_OUT_Q7S, this); - lp_var_t voltageOutPayloadPCDUCh1 = - lp_var_t(sid.objectId, P60System::pool::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, this); - lp_var_t voltageOutReactionWheels = - lp_var_t(sid.objectId, P60System::pool::PDU2_VOLTAGE_OUT_RW, this); - lp_var_t voltageOutTCSBoardHeaterIn = - lp_var_t(sid.objectId, P60System::pool::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, this); - lp_var_t voltageOutSUSRedundant = - lp_var_t(sid.objectId, P60System::pool::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, this); - lp_var_t voltageOutDeplMechanism = - lp_var_t(sid.objectId, P60System::pool::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, this); - lp_var_t voltageOutPayloadPCDUCh6 = - lp_var_t(sid.objectId, P60System::pool::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, this); - lp_var_t voltageOutACSBoardSideB = - lp_var_t(sid.objectId, P60System::pool::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, this); - lp_var_t voltageOutPayloadCamera = - lp_var_t(sid.objectId, P60System::pool::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, this); - /** Measured VCC */ - lp_var_t vcc = lp_var_t(sid.objectId, P60System::pool::PDU2_VCC, this); - /** Measured VBAT */ - lp_var_t vbat = lp_var_t(sid.objectId, P60System::pool::PDU2_VBAT, this); - lp_var_t temperature = - lp_var_t(sid.objectId, P60System::pool::PDU2_TEMPERATURE, this); - /** Output converter enable status */ - lp_var_t converterEnable1 = - lp_var_t(sid.objectId, P60System::pool::PDU2_CONV_EN_1, this); - lp_var_t converterEnable2 = - lp_var_t(sid.objectId, P60System::pool::PDU2_CONV_EN_2, this); - lp_var_t converterEnable3 = - lp_var_t(sid.objectId, P60System::pool::PDU2_CONV_EN_3, this); - /** Output channels enable status */ - lp_var_t outEnabledQ7S = - lp_var_t(sid.objectId, P60System::pool::PDU2_OUT_EN_Q7S, this); - lp_var_t outEnabledPlPCDUCh1 = - lp_var_t(sid.objectId, P60System::pool::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, this); - lp_var_t outEnabledReactionWheels = - lp_var_t(sid.objectId, P60System::pool::PDU2_OUT_EN_RW, this); - lp_var_t outEnabledTCSBoardHeaterIn = - lp_var_t(sid.objectId, P60System::pool::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, this); - lp_var_t outEnabledSUSRedundant = - lp_var_t(sid.objectId, P60System::pool::PDU2_OUT_EN_SUS_REDUNDANT, this); - lp_var_t outEnabledDeplMechanism = - lp_var_t(sid.objectId, P60System::pool::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, this); - lp_var_t outEnabledPlPCDUCh6 = - lp_var_t(sid.objectId, P60System::pool::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, this); - lp_var_t outEnabledAcsBoardSideB = - lp_var_t(sid.objectId, P60System::pool::PDU2_OUT_EN_ACS_BOARD_SIDE_B, this); - lp_var_t outEnabledPayloadCamera = - lp_var_t(sid.objectId, P60System::pool::PDU2_OUT_EN_PAYLOAD_CAMERA, this); - - lp_var_t bootcause = - lp_var_t(sid.objectId, P60System::pool::PDU2_BOOTCAUSE, this); - /** Number of reboots */ - lp_var_t bootcount = - lp_var_t(sid.objectId, P60System::pool::PDU2_BOOTCNT, this); - /** Uptime in seconds */ - lp_var_t uptime = lp_var_t(sid.objectId, P60System::pool::PDU2_UPTIME, this); - lp_var_t resetcause = - lp_var_t(sid.objectId, P60System::pool::PDU2_RESETCAUSE, this); - /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ - lp_var_t battMode = - lp_var_t(sid.objectId, P60System::pool::PDU2_BATT_MODE, this); - - /** Number of detected latchups on each output channel */ - lp_var_t latchupsQ7S = - lp_var_t(sid.objectId, P60System::pool::PDU2_LATCHUP_Q7S, this); - lp_var_t latchupsPayloadPcduCh1 = - lp_var_t(sid.objectId, P60System::pool::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, this); - lp_var_t latchupsRw = - lp_var_t(sid.objectId, P60System::pool::PDU2_LATCHUP_RW, this); - lp_var_t latchupsTcsBoardHeaterIn = - lp_var_t(sid.objectId, P60System::pool::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, this); - lp_var_t latchupsSusRedundant = - lp_var_t(sid.objectId, P60System::pool::PDU2_LATCHUP_SUS_REDUNDANT, this); - lp_var_t latchupsDeplMenchanism = - lp_var_t(sid.objectId, P60System::pool::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, this); - lp_var_t latchupsPayloadPcduCh6 = - lp_var_t(sid.objectId, P60System::pool::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, this); - lp_var_t latchupsAcsBoardSideB = - lp_var_t(sid.objectId, P60System::pool::PDU2_LATCHUP_ACS_BOARD_SIDE_B, this); - lp_var_t latchupsPayloadCamera = - lp_var_t(sid.objectId, P60System::pool::PDU2_LATCHUP_PAYLOAD_CAMERA, this); - - /** - * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is - * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. - */ - lp_var_t device0 = lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_7, this); - /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ - lp_var_t device0Status = - lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_0_STATUS, this); - lp_var_t device1Status = - lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_1_STATUS, this); - lp_var_t device2Status = - lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_2_STATUS, this); - lp_var_t device3Status = - lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_3_STATUS, this); - lp_var_t device4Status = - lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_4_STATUS, this); - lp_var_t device5Status = - lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_5_STATUS, this); - lp_var_t device6Status = - lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_6_STATUS, this); - lp_var_t device7Status = - lp_var_t(sid.objectId, P60System::pool::PDU2_DEVICE_7_STATUS, this); - - /** Number of reboots triggered by the ground watchdog */ - lp_var_t gndWdtReboots = - lp_var_t(sid.objectId, P60System::pool::PDU2_WDT_CNT_GND, this); - /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ - lp_var_t i2cWdtReboots = - lp_var_t(sid.objectId, P60System::pool::PDU2_WDT_CNT_I2C, this); - /** Number of reboots triggered through the CAN watchdog */ - lp_var_t canWdtReboots = - lp_var_t(sid.objectId, P60System::pool::PDU2_WDT_CNT_CAN, this); - /** Number of reboots triggered through the CSP watchdog */ - lp_var_t csp1WdtReboots = - lp_var_t(sid.objectId, P60System::pool::PDU2_WDT_CNT_CSP1, this); - lp_var_t csp2WdtReboots = - lp_var_t(sid.objectId, P60System::pool::PDU2_WDT_CNT_CSP2, this); - /** Ground watchdog remaining seconds before rebooting */ - lp_var_t groundWatchdogSecondsLeft = - lp_var_t(sid.objectId, P60System::pool::PDU2_WDT_GND_LEFT, this); - /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ - lp_var_t i2cWatchdogSecondsLeft = - lp_var_t(sid.objectId, P60System::pool::PDU2_WDT_I2C_LEFT, this); - /** CAN watchdog remaining seconds before rebooting. */ - lp_var_t canWatchdogSecondsLeft = - lp_var_t(sid.objectId, P60System::pool::PDU2_WDT_CAN_LEFT, this); - /** CSP watchdog remaining pings before rebooting. */ - lp_var_t csp1WatchdogPingsLeft = - lp_var_t(sid.objectId, P60System::pool::PDU2_WDT_CSP_LEFT1, this); - lp_var_t csp2WatchdogPingsLeft = - lp_var_t(sid.objectId, P60System::pool::PDU2_WDT_CSP_LEFT2, this); + Pdu2CoreHk(object_id_t objectId) + : PduCoreHk(objectId, static_cast(::P60System::SetIds::PDU_2_CORE)) {} }; + +class Pdu2AuxHk : public ::PDU::PduAuxHk { + public: + Pdu2AuxHk(HasLocalDataPoolIF* owner) + : PduAuxHk(owner, static_cast(::P60System::SetIds::PDU_2_AUX)) {} + + Pdu2AuxHk(object_id_t objectId) + : PduAuxHk(objectId, static_cast(::P60System::SetIds::PDU_2_AUX)) {} +}; + } // namespace PDU2 namespace ACU { @@ -1054,4 +738,65 @@ class HkTableDataset : public StaticLocalDataSet { }; } // namespace ACU +namespace pcdu { + +enum PoolIds : uint32_t { PDU1_SWITCHES, PDU2_SWITCHES }; + +/* Switches are uint8_t datatype and go from 0 to 255 */ +enum Switches : power::Switch_t { + PDU1_CH0_TCS_BOARD_3V3, + PDU1_CH1_SYRLINKS_12V, + PDU1_CH2_STAR_TRACKER_5V, + PDU1_CH3_MGT_5V, + PDU1_CH4_SUS_NOMINAL_3V3, + PDU1_CH5_SOLAR_CELL_EXP_5V, + PDU1_CH6_PLOC_12V, + PDU1_CH7_ACS_A_SIDE_3V3, + PDU1_CH8_UNOCCUPIED, + + PDU2_CH0_Q7S, + PDU2_CH1_PL_PCDU_BATT_0_14V8, + PDU2_CH2_RW_5V, + PDU2_CH3_TCS_BOARD_HEATER_IN_8V, + PDU2_CH4_SUS_REDUNDANT_3V3, + PDU2_CH5_DEPLOYMENT_MECHANISM_8V, + PDU2_CH6_PL_PCDU_BATT_1_14V8, + PDU2_CH7_ACS_BOARD_SIDE_B_3V3, + PDU2_CH8_PAYLOAD_CAMERA +}; + +static constexpr uint8_t NUMBER_OF_SWITCHES = 18; + +static const uint8_t ON = 1; +static const uint8_t OFF = 0; + +// Output states after reboot of the PDUs + +const std::array INIT_SWITCHES_PDU1 = { +// Because the TE0720 is not connected to the PCDU, this switch is always on +#ifdef TE0720_1CFA + ON, +#else + OFF, +#endif + OFF, OFF, OFF, OFF, OFF, OFF, OFF, OFF, +}; +const std::array INIT_SWITCHES_PDU2 = {ON, OFF, OFF, OFF, OFF, + OFF, OFF, OFF, OFF}; + +static constexpr uint32_t SWITCHER_SET_ID = 0; + +class SwitcherStates : public StaticLocalDataSet { + public: + SwitcherStates(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SWITCHER_SET_ID) {} + + SwitcherStates(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SWITCHER_SET_ID)) {} + + lp_vec_t pdu1Switches = + lp_vec_t(sid.objectId, PDU1_SWITCHES, this); + lp_vec_t pdu2Switches = + lp_vec_t(sid.objectId, PDU2_SWITCHES, this); +}; + +} // namespace pcdu #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ */ diff --git a/mission/system/AcsBoardAssembly.cpp b/mission/system/AcsBoardAssembly.cpp index 0d65d20e..5e9076b2 100644 --- a/mission/system/AcsBoardAssembly.cpp +++ b/mission/system/AcsBoardAssembly.cpp @@ -4,6 +4,8 @@ #include #include +#include "OBSWConfig.h" + AcsBoardAssembly::AcsBoardAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* switcher, AcsBoardHelper helper, GpioIF* gpioIF) : DualLaneAssemblyBase(objectId, parentId, switcher, SWITCH_A, SWITCH_B, diff --git a/mission/system/AcsBoardAssembly.h b/mission/system/AcsBoardAssembly.h index 0ed65227..412cb273 100644 --- a/mission/system/AcsBoardAssembly.h +++ b/mission/system/AcsBoardAssembly.h @@ -105,10 +105,8 @@ class AcsBoardAssembly : public DualLaneAssemblyBase { void selectGpsInDualMode(duallane::Submodes side); private: - static constexpr pcduSwitches::Switches SWITCH_A = - pcduSwitches::Switches::PDU1_CH7_ACS_A_SIDE_3V3; - static constexpr pcduSwitches::Switches SWITCH_B = - pcduSwitches::Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3; + static constexpr pcdu::Switches SWITCH_A = pcdu::Switches::PDU1_CH7_ACS_A_SIDE_3V3; + static constexpr pcdu::Switches SWITCH_B = pcdu::Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3; bool tryingOtherSide = false; bool dualModeErrorSwitch = true; diff --git a/mission/system/DualLaneAssemblyBase.cpp b/mission/system/DualLaneAssemblyBase.cpp index fbd69d8f..020ce1ff 100644 --- a/mission/system/DualLaneAssemblyBase.cpp +++ b/mission/system/DualLaneAssemblyBase.cpp @@ -2,10 +2,11 @@ #include +#include "OBSWConfig.h" + DualLaneAssemblyBase::DualLaneAssemblyBase(object_id_t objectId, object_id_t parentId, - PowerSwitchIF* pwrSwitcher, - pcduSwitches::Switches switch1, - pcduSwitches::Switches switch2, Event pwrTimeoutEvent, + PowerSwitchIF* pwrSwitcher, pcdu::Switches switch1, + pcdu::Switches switch2, Event pwrTimeoutEvent, Event sideSwitchNotAllowedEvent, Event transitionOtherSideFailedEvent) : AssemblyBase(objectId, parentId, 20), diff --git a/mission/system/DualLaneAssemblyBase.h b/mission/system/DualLaneAssemblyBase.h index 3017afc0..4233d860 100644 --- a/mission/system/DualLaneAssemblyBase.h +++ b/mission/system/DualLaneAssemblyBase.h @@ -19,9 +19,8 @@ class DualLaneAssemblyBase : public AssemblyBase, public ConfirmsFailuresIF { static constexpr UniqueEventId_t SIDE_SWITCH_TRANSITION_NOT_ALLOWED_ID = 3; DualLaneAssemblyBase(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher, - pcduSwitches::Switches switch1, pcduSwitches::Switches switch2, - Event pwrSwitchTimeoutEvent, Event sideSwitchNotAllowedEvent, - Event transitionOtherSideFailedEvent); + pcdu::Switches switch1, pcdu::Switches switch2, Event pwrSwitchTimeoutEvent, + Event sideSwitchNotAllowedEvent, Event transitionOtherSideFailedEvent); protected: // This helper object complete encapsulates power switching diff --git a/mission/system/SusAssembly.h b/mission/system/SusAssembly.h index 58394709..b9216072 100644 --- a/mission/system/SusAssembly.h +++ b/mission/system/SusAssembly.h @@ -43,10 +43,8 @@ class SusAssembly : public DualLaneAssemblyBase { private: enum class States { IDLE, SWITCHING_POWER, MODE_COMMANDING } state = States::IDLE; - static constexpr pcduSwitches::Switches SWITCH_NOM = - pcduSwitches::Switches::PDU1_CH4_SUS_NOMINAL_3V3; - static constexpr pcduSwitches::Switches SWITCH_RED = - pcduSwitches::Switches::PDU2_CH4_SUS_REDUNDANT_3V3; + static constexpr pcdu::Switches SWITCH_NOM = pcdu::Switches::PDU1_CH4_SUS_NOMINAL_3V3; + static constexpr pcdu::Switches SWITCH_RED = pcdu::Switches::PDU2_CH4_SUS_REDUNDANT_3V3; FixedArrayList modeTable; SusAssHelper helper;