eive-obsw/mission/devices/PayloadPcduHandler.h

98 lines
4.0 KiB
C
Raw Normal View History

2022-02-10 14:24:34 +01:00
#ifndef LINUX_DEVICES_PLPCDUHANDLER_H_
#define LINUX_DEVICES_PLPCDUHANDLER_H_
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
2022-02-21 17:31:56 +01:00
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
#include <fsfw/timemanager/Countdown.h>
2022-02-21 16:57:16 +01:00
2022-02-21 14:42:05 +01:00
#include "devicedefinitions/payloadPcduDefinitions.h"
2022-02-10 16:55:06 +01:00
#include "fsfw_hal/common/gpio/GpioIF.h"
2022-02-10 14:24:34 +01:00
/**
* @brief Device handler for the EIVE Payload PCDU
* @details
* Documentation:
* https://egit.irs.uni-stuttgart.de/eive/eive_dokumente/src/branch/master/400_Raumsegment/412_PayloaPCDUDocumentation/release/EIVE-D-421-001_PLPCDU_Documentation.pdf
*
* Important components:
* - SSR - Solid State Relay: Decouples voltages from battery
* - DRO - Dielectric Resonsant Oscillator: Generates modulation signal
* - X8: Frequency X8 Multiplicator
* - TX: Transmitter/Sender module. Modulates data onto carrier signal
* - MPA - Medium Power Amplifier
* - HPA - High Power Amplifier
*/
2022-02-21 17:31:56 +01:00
class PayloadPcduHandler : public DeviceHandlerBase {
2022-02-10 15:39:54 +01:00
public:
2022-02-21 17:31:56 +01:00
PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF,
bool periodicPrintout);
2022-02-10 15:39:54 +01:00
2022-02-21 16:57:16 +01:00
void setToGoToNormalModeImmediately(bool enable);
2022-02-21 17:31:56 +01:00
void enablePeriodicPrintout(bool enable, uint8_t divider);
2022-02-21 16:57:16 +01:00
2022-02-10 15:39:54 +01:00
private:
2022-02-10 16:05:36 +01:00
enum class States {
PCDU_OFF,
// Solid State Relay, enable battery voltages VBAT0 and VBAT1. This will also switch on
// the ADC
ON_TRANS_SSR,
ON_TRANS_ADC_CLOSE_ZERO,
// Enable Dielectric Resonant Oscillator and start monitoring voltages as
// soon as DRO voltage reaches 6V
ON_TRANS_DRO,
// Switch on X8 compoennt and monitor voltages for 5 seconds
ON_TRANS_X8,
// Switch on TX component and monitor voltages for 5 seconds
ON_TRANS_TX,
// Switch on MPA component and monitor voltages for 5 seconds
ON_TRANS_MPA,
// Switch on HPA component and monitor voltages for 5 seconds
ON_TRANS_HPA,
// All components of the experiment are on
PCDU_ON,
} state = States::PCDU_OFF;
2022-02-10 18:05:14 +01:00
enum class MonitoringMode { NONE, CLOSE_TO_ZERO, NEGATIVE } monMode = MonitoringMode::NONE;
2022-02-21 14:42:05 +01:00
enum class AdcStates { OFF, BOOT_DELAY, SEND_SETUP, NORMAL } adcState = AdcStates::OFF;
2022-02-21 16:57:16 +01:00
bool goToNormalMode = false;
2022-02-21 14:42:05 +01:00
plpcdu::PlPcduAdcSet adcSet;
std::array<uint8_t, plpcdu::MAX_ADC_REPLY_SIZE> cmdBuf = {};
// This variable is tied to DRO +6 V voltage. Voltages, currents are monitored and the experiment
// is shut down immediately if there is a negative voltage.
bool transitionOk = false;
bool commandExecuted = false;
2022-02-21 14:42:05 +01:00
bool adcCmdExecuted = false;
2022-02-21 17:31:56 +01:00
bool periodicPrintout = false;
PeriodicOperationDivider opDivider = PeriodicOperationDivider(5);
2022-02-21 14:42:05 +01:00
uint8_t tempReadDivisor = 1;
Countdown countdown = Countdown(5000);
2022-02-21 14:42:05 +01:00
Countdown adcCountdown = Countdown(50);
2022-02-10 16:55:06 +01:00
GpioIF* gpioIF;
2022-02-10 16:05:36 +01:00
2022-02-21 15:28:33 +01:00
PoolEntry<uint16_t> channelValues = PoolEntry<uint16_t>({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
2022-02-21 14:42:05 +01:00
PoolEntry<float> tempC = PoolEntry<float>({0.0});
2022-02-10 16:55:06 +01:00
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
2022-02-10 14:24:34 +01:00
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
size_t* foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
2022-02-21 17:31:56 +01:00
void handleExtConvRead(const uint8_t* bufStart);
void handlePrintout();
void stateMachineToNormal();
2022-02-10 14:24:34 +01:00
};
#endif /* LINUX_DEVICES_PLPCDUHANDLER_H_ */