2021-01-23 17:22:40 +01:00
|
|
|
#ifndef MISSION_DEVICES_PCDUHANDLER_H_
|
|
|
|
#define MISSION_DEVICES_PCDUHANDLER_H_
|
|
|
|
|
2021-02-27 19:46:13 +01:00
|
|
|
#include <devices/powerSwitcherList.h>
|
2022-04-07 19:48:09 +02:00
|
|
|
#include <fsfw/datapool/PoolEntry.h>
|
2021-01-28 14:55:21 +01:00
|
|
|
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
|
|
|
#include <fsfw/objectmanager/SystemObject.h>
|
2022-01-17 15:58:27 +01:00
|
|
|
#include <fsfw/power/PowerSwitchIF.h>
|
2021-01-28 14:55:21 +01:00
|
|
|
#include <fsfw/tasks/ExecutableObjectIF.h>
|
2022-01-17 15:58:27 +01:00
|
|
|
#include <fsfw/timemanager/CCSDSTime.h>
|
|
|
|
#include <mission/devices/GomspaceDeviceHandler.h>
|
2022-03-16 20:13:21 +01:00
|
|
|
|
|
|
|
#include "devicedefinitions/GomspaceDefinitions.h"
|
|
|
|
#include "devicedefinitions/powerDefinitions.h"
|
2021-01-28 14:55:21 +01:00
|
|
|
|
2021-01-23 17:22:40 +01:00
|
|
|
/**
|
2021-01-28 14:55:21 +01:00
|
|
|
* @brief The PCDUHandler provides a compact interface to handle all devices related to the
|
2022-03-16 20:13:21 +01:00
|
|
|
* control of power.
|
|
|
|
* @details
|
|
|
|
* This is necessary because the FSFW manages all power related functionalities via one
|
|
|
|
* power object. This includes for example switching on and off of devices.
|
2021-01-23 17:22:40 +01:00
|
|
|
*/
|
2022-01-17 15:58:27 +01:00
|
|
|
class PCDUHandler : public PowerSwitchIF,
|
|
|
|
public HasLocalDataPoolIF,
|
|
|
|
public SystemObject,
|
|
|
|
public ExecutableObjectIF {
|
|
|
|
public:
|
|
|
|
PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20);
|
|
|
|
virtual ~PCDUHandler();
|
|
|
|
|
|
|
|
virtual ReturnValue_t initialize() override;
|
|
|
|
virtual ReturnValue_t performOperation(uint8_t counter) override;
|
2022-08-15 17:25:16 +02:00
|
|
|
virtual void handleChangedDataset(sid_t sid, store_address_t storeId = store_address_t::invalid(),
|
2022-03-16 20:13:21 +01:00
|
|
|
bool* clearMessage = nullptr) override;
|
2022-01-17 15:58:27 +01:00
|
|
|
|
2022-03-30 12:22:49 +02:00
|
|
|
virtual ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override;
|
|
|
|
virtual ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override;
|
2022-01-17 15:58:27 +01:00
|
|
|
virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override;
|
|
|
|
virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override;
|
|
|
|
virtual uint32_t getSwitchDelayMs(void) const override;
|
|
|
|
virtual object_id_t getObjectId() const override;
|
|
|
|
virtual LocalDataPoolManager* getHkManagerHandle() override;
|
|
|
|
|
|
|
|
virtual MessageQueueId_t getCommandQueue() const override;
|
|
|
|
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
|
|
|
LocalDataPoolManager& poolManager) override;
|
|
|
|
virtual uint32_t getPeriodicOperationFrequency() const override;
|
|
|
|
virtual ReturnValue_t initializeAfterTaskCreation() override;
|
|
|
|
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
|
|
|
virtual void setTaskIF(PeriodicTaskIF* task_);
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint32_t pstIntervalMs = 0;
|
2022-03-16 20:13:21 +01:00
|
|
|
MutexIF* pwrMutex = nullptr;
|
2022-01-17 15:58:27 +01:00
|
|
|
|
|
|
|
/** Housekeeping manager. Handles updates of local pool variables. */
|
|
|
|
LocalDataPoolManager poolManager;
|
|
|
|
|
2022-04-07 19:48:09 +02:00
|
|
|
/** Hk table dataset of PDU1 */
|
|
|
|
PDU1::Pdu1CoreHk pdu1CoreHk;
|
2022-01-17 15:58:27 +01:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2022-04-07 19:48:09 +02:00
|
|
|
PDU2::Pdu2CoreHk pdu2CoreHk;
|
|
|
|
|
|
|
|
pcdu::SwitcherStates switcherSet;
|
|
|
|
|
|
|
|
PoolEntry<uint8_t> pdu1Switches =
|
|
|
|
PoolEntry<uint8_t>(pcdu::INIT_SWITCHES_PDU1.data(), pcdu::INIT_SWITCHES_PDU1.size());
|
|
|
|
PoolEntry<uint8_t> pdu2Switches =
|
|
|
|
PoolEntry<uint8_t>(pcdu::INIT_SWITCHES_PDU2.data(), pcdu::INIT_SWITCHES_PDU2.size());
|
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
/** The timeStamp of the current pdu2HkTableDataset */
|
|
|
|
CCSDSTime::CDS_short timeStampPdu2HkDataset;
|
|
|
|
|
|
|
|
/** The timeStamp of the current pdu1HkTableDataset */
|
|
|
|
CCSDSTime::CDS_short timeStampPdu1HkDataset;
|
|
|
|
|
2022-04-07 19:48:09 +02:00
|
|
|
uint8_t switchStates[pcdu::NUMBER_OF_SWITCHES];
|
2022-01-17 15:58:27 +01:00
|
|
|
/**
|
|
|
|
* Pointer to the IPCStore.
|
|
|
|
* This caches the pointer received from the objectManager in the constructor.
|
|
|
|
*/
|
|
|
|
StorageManagerIF* IPCStore = nullptr;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Message queue to communicate with other objetcs. Used for example to receive
|
|
|
|
* local pool messages from ACU, PDU1 and PDU2.
|
|
|
|
*/
|
|
|
|
MessageQueueIF* commandQueue = nullptr;
|
|
|
|
|
|
|
|
size_t cmdQueueSize;
|
2022-03-16 20:13:21 +01:00
|
|
|
bool firstSwitchInfoPdu1 = true;
|
|
|
|
bool firstSwitchInfoPdu2 = true;
|
2022-01-17 15:58:27 +01:00
|
|
|
|
|
|
|
PeriodicTaskIF* executingTask = nullptr;
|
|
|
|
|
|
|
|
void readCommandQueue();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function sets all switchStates to the initial switch configuration of the
|
|
|
|
* two PDUs after reboot.
|
|
|
|
*/
|
|
|
|
void initializeSwitchStates();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Updates all switchStates related to the PDU2.
|
|
|
|
* Function is called each time a new hk dataset has been received from the PDU2Handler.
|
|
|
|
*/
|
|
|
|
void updatePdu2SwitchStates();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Updates all switchStates related to the PDU1. Called each time the PDU1Handler
|
|
|
|
* sends a new hk dataset.
|
|
|
|
*/
|
|
|
|
void updatePdu1SwitchStates();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief In case of an update snapshot message this function handles the update of the
|
|
|
|
* local dataset.
|
|
|
|
* @param storeId Storage id of updated dataset.
|
|
|
|
* @param dataset Pointer to the local dataset.
|
|
|
|
* @param datasetTimeStamp Pointer to a variable which will hold the timestamp of the updated
|
|
|
|
* dataset.
|
|
|
|
*/
|
|
|
|
void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset,
|
|
|
|
CCSDSTime::CDS_short* datasetTimeStamp);
|
2022-04-07 19:48:09 +02:00
|
|
|
void checkAndUpdateSwitch(GOMSPACE::Pdu pdu, pcdu::Switches switchIdx, uint8_t setValue);
|
2021-01-23 17:22:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MISSION_DEVICES_PCDUHANDLER_H_ */
|