WIP: PL PCDU #142
@ -1199,7 +1199,7 @@ void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF*
|
||||
spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
// Create device handler components
|
||||
auto plPcduHandler = new PayloadPcduHandler(objects::PLPCDU_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie, gpioComIF, false);
|
||||
spiCookie, gpioComIF, SdCardManager::instance(), false);
|
||||
spiCookie->setCallbackMode(PayloadPcduHandler::extConvAsTwoCallback, plPcduHandler);
|
||||
static_cast<void>(plPcduHandler);
|
||||
#if OBSW_TEST_PL_PCDU == 1
|
||||
|
@ -9,7 +9,8 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "definitions.h"
|
||||
#include "mission/memory/definitions.h"
|
||||
#include "mission/memory/SdCardMountedIF.h"
|
||||
#include "events/subsystemIdRanges.h"
|
||||
#include "fsfw/events/Event.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
@ -22,7 +23,7 @@ class MutexIF;
|
||||
* @brief Manages handling of SD cards like switching them on or off or getting the current
|
||||
* state
|
||||
*/
|
||||
class SdCardManager {
|
||||
class SdCardManager: public SdCardMountedIF {
|
||||
friend class SdCardAccess;
|
||||
|
||||
public:
|
||||
@ -168,7 +169,7 @@ class SdCardManager {
|
||||
* @param prefSdCardPtr
|
||||
* @return
|
||||
*/
|
||||
std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE);
|
||||
std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE) override;
|
||||
|
||||
OpStatus checkCurrentOp(Operations& currentOp);
|
||||
|
||||
@ -183,11 +184,11 @@ class SdCardManager {
|
||||
/**
|
||||
* @brief Checks if an SD card is mounted
|
||||
*
|
||||
* @param sdCard The SD crad to check
|
||||
* @param sdCard The SD card to check
|
||||
*
|
||||
* @return true if mounted, otherwise false
|
||||
*/
|
||||
bool isSdCardMounted(sd::SdCard sdCard);
|
||||
bool isSdCardMounted(sd::SdCard sdCard) override;
|
||||
|
||||
private:
|
||||
CommandExecutor cmdExecutor;
|
||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
||||
Subproject commit 4747e54c5d71e930125803f875532ee1f79f5054
|
||||
Subproject commit 123f2ff360e71228e1c0c786d80a4c93d7144a2e
|
@ -13,11 +13,13 @@
|
||||
#include "devices/gpioIds.h"
|
||||
|
||||
PayloadPcduHandler::PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie,
|
||||
GpioIF* gpioIF, bool periodicPrintout)
|
||||
GpioIF* gpioIF, SdCardMountedIF* sdcMan,
|
||||
bool periodicPrintout)
|
||||
: DeviceHandlerBase(objectId, comIF, cookie),
|
||||
adcSet(this),
|
||||
periodicPrintout(periodicPrintout),
|
||||
gpioIF(gpioIF) {}
|
||||
gpioIF(gpioIF),
|
||||
sdcMan(sdcMan) {}
|
||||
|
||||
void PayloadPcduHandler::doStartUp() {
|
||||
if ((state != States::PCDU_OFF) and (state != States::ON_TRANS_SSR)) {
|
||||
@ -254,6 +256,18 @@ void PayloadPcduHandler::checkAdcValues() {
|
||||
adcSet.processed[U_X8_DIV_6] = static_cast<float>(adcSet.channels[9]) * SCALE_VOLTAGE;
|
||||
adcSet.processed[I_DRO] = static_cast<float>(adcSet.channels[10]) * SCALE_CURRENT_DRO * 1000.0;
|
||||
adcSet.processed[U_DRO_DIV_6] = static_cast<float>(adcSet.channels[11]) * SCALE_VOLTAGE;
|
||||
if(adcSet.processed[U_BAT_DIV_6] < -6.0 or adcSet.processed[U_BAT_DIV_6] > -3.3) {
|
||||
bool tooLarge = false;
|
||||
if(adcSet.processed[U_BAT_DIV_6] > -3.3) {
|
||||
tooLarge = true;
|
||||
}
|
||||
uint32_t rawVoltage = 0;
|
||||
size_t serSize = 0;
|
||||
SerializeAdapter::serialize(&adcSet.processed[U_BAT_DIV_6],
|
||||
reinterpret_cast<uint8_t*>(&rawVoltage), &serSize, 4, SerializeIF::Endianness::NETWORK);
|
||||
triggerEvent(NEG_V_OUT_OF_BOUNDS, tooLarge, rawVoltage);
|
||||
transitionBackToOff();
|
||||
}
|
||||
}
|
||||
|
||||
void PayloadPcduHandler::stateMachineToNormal() {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw_hal/common/gpio/GpioIF.h"
|
||||
#include "mission/devices/devicedefinitions/payloadPcduDefinitions.h"
|
||||
#include "mission/memory/SdCardMountedIF.h"
|
||||
|
||||
#ifdef FSFW_OSAL_LINUX
|
||||
class SpiComIF;
|
||||
@ -34,9 +35,31 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PL_PCDU_HANDLER;
|
||||
static constexpr Event TRANSITION_BACK_TO_OFF =
|
||||
event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||
static constexpr Event NEG_V_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 1, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||
static constexpr Event U_DRO_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 2, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||
static constexpr Event I_DRO_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 3, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||
static constexpr Event U_X8_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 4, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||
static constexpr Event I_X8_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 5, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||
static constexpr Event U_TX_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 6, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||
static constexpr Event I_TX_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 7, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||
static constexpr Event U_MPA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 8, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||
static constexpr Event I_MPA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 9, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||
static constexpr Event U_HPA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 10, severity::MEDIUM);
|
||||
//! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value
|
||||
static constexpr Event I_HPA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 11, severity::MEDIUM);
|
||||
|
||||
PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF,
|
||||
bool periodicPrintout);
|
||||
SdCardMountedIF* sdcMan, bool periodicPrintout);
|
||||
|
||||
void setToGoToNormalModeImmediately(bool enable);
|
||||
void enablePeriodicPrintout(bool enable, uint8_t divider);
|
||||
@ -91,6 +114,7 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
||||
Countdown countdown = Countdown(5000);
|
||||
Countdown adcCountdown = Countdown(50);
|
||||
GpioIF* gpioIF;
|
||||
SdCardMountedIF* sdcMan;
|
||||
|
||||
PoolEntry<uint16_t> channelValues = PoolEntry<uint16_t>({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
PoolEntry<float> processedValues =
|
||||
@ -113,7 +137,6 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
||||
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
|
||||
void handleExtConvRead(const uint8_t* bufStart);
|
||||
void handlePrintout();
|
||||
void checkAdcValues();
|
||||
|
@ -1,12 +1,17 @@
|
||||
#ifndef LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_
|
||||
#define LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "mission/devices/max1227.h"
|
||||
#include "mission/memory/NVMParameterBase.h"
|
||||
|
||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
|
||||
#include "mission/devices/max1227.h"
|
||||
|
||||
namespace plpcdu {
|
||||
|
||||
@ -77,8 +82,39 @@ static constexpr float SCALE_CURRENT_TX = MAX122X_SCALE / (GAIN_INA169 * R_SHUNT
|
||||
static constexpr float SCALE_CURRENT_X8 = MAX122X_SCALE / (GAIN_INA169 * R_SHUNT_X8);
|
||||
static constexpr float SCALE_CURRENT_DRO = MAX122X_SCALE / (GAIN_INA169 * R_SHUNT_DRO);
|
||||
|
||||
// TODO: Make these configurable parameters using a JSON file
|
||||
// Upper bound of currents in milliamperes [mA]
|
||||
static constexpr float NEG_V_LOWER_BOUND = -6.0;
|
||||
static constexpr float NEG_V_UPPER_BOUND = -3.3;
|
||||
|
||||
static constexpr float DRO_U_LOWER_BOUND = 5.0;
|
||||
static constexpr float DRO_U_UPPER_BOUND = 7.0;
|
||||
static constexpr float DRO_I_UPPER_BOUND = 40.0;
|
||||
|
||||
static constexpr float X8_U_LOWER_BOUND = 2.6;
|
||||
static constexpr float X8_U_UPPER_BOUND = 4.0;
|
||||
static constexpr float X8_I_UPPER_BOUND = 100.0;
|
||||
|
||||
static constexpr float TX_U_LOWER_BOUND = 2.6;
|
||||
static constexpr float TX_U_UPPER_BOUND = 4.0;
|
||||
static constexpr float TX_I_UPPER_BOUND = 250.0;
|
||||
|
||||
static constexpr float MPA_U_LOWER_BOUND = 2.6;
|
||||
static constexpr float MPA_U_UPPER_BOUND = 4.0;
|
||||
static constexpr float MPA_I_UPPER_BOUND = 650.0;
|
||||
|
||||
static constexpr float HPA_U_LOWER_BOUND = 9.6;
|
||||
static constexpr float HPA_U_UPPER_BOUND = 11.0;
|
||||
static constexpr float HPA_I_UPPER_BOUND = 3000.0;
|
||||
|
||||
static constexpr float SSR_TO_DRO_WAIT_TIME = 5.0;
|
||||
static constexpr float DRO_TO_X8_WAIT_TIME = 905.0;
|
||||
static constexpr float X8_TO_TX_WAIT_TIME = 5.0;
|
||||
static constexpr float TX_TO_MPA_WAIT_TIME = 5.0;
|
||||
static constexpr float MPA_TO_HPA_WAIT_TIME = 5.0;
|
||||
|
||||
/**
|
||||
* The current of the processed values is calculated and stored as a milli ampere value.
|
||||
* The current of the processed values is calculated and stored as a milliamperes [mA].
|
||||
* The voltages are stored as Volt values.
|
||||
*/
|
||||
class PlPcduAdcSet : public StaticLocalDataSet<DATASET_ENTRIES> {
|
||||
@ -92,6 +128,42 @@ class PlPcduAdcSet : public StaticLocalDataSet<DATASET_ENTRIES> {
|
||||
lp_var_t<float> tempC = lp_var_t<float>(sid.objectId, TEMP, this);
|
||||
};
|
||||
|
||||
class PlPcduParameter : public SystemObject, public NVMParameterBase {
|
||||
public:
|
||||
static constexpr char SSR_TO_DRO_WAIT_TIME_K[] = "ssrToDroWait";
|
||||
static constexpr char DRO_TO_X8_WAIT_TIME_K[] = "droToX8Wait";
|
||||
static constexpr char X8_TO_TX_WAIT_TIME_K[] = "X8ToTxWait";
|
||||
static constexpr char TX_TO_MPA_WAIT_TIME_K[] = "txToMpaWait";
|
||||
static constexpr char MPA_TO_HPA_WAIT_TIME_K[] = "mpaToHpaWait";
|
||||
|
||||
PlPcduParameter(object_id_t objectId)
|
||||
: SystemObject(objectId), NVMParameterBase(""), mountPrefix("") {
|
||||
// Initialize with default values
|
||||
insertValue(SSR_TO_DRO_WAIT_TIME_K, SSR_TO_DRO_WAIT_TIME);
|
||||
insertValue(DRO_TO_X8_WAIT_TIME_K, DRO_TO_X8_WAIT_TIME);
|
||||
insertValue(X8_TO_TX_WAIT_TIME_K, X8_TO_TX_WAIT_TIME);
|
||||
insertValue(TX_TO_MPA_WAIT_TIME_K, TX_TO_MPA_WAIT_TIME);
|
||||
insertValue(MPA_TO_HPA_WAIT_TIME_K, MPA_TO_HPA_WAIT_TIME);
|
||||
}
|
||||
|
||||
ReturnValue_t initialize(std::string mountPrefix) {
|
||||
setFullName(mountPrefix + "/conf/plpcdu.json");
|
||||
ReturnValue_t result = readJsonFile();
|
||||
if(result == HasReturnvaluesIF::RETURN_OK) {
|
||||
// File does not exist. Create it. Keys and appropriate init values were
|
||||
// specified in constructor
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::info << "Creating PL PCDU JSON file at " << getFullName() << std::endl;
|
||||
#endif
|
||||
writeJsonFile();
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string mountPrefix;
|
||||
};
|
||||
|
||||
} // namespace plpcdu
|
||||
|
||||
#endif /* LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_ */
|
||||
|
20
mission/memory/SdCardMountedIF.h
Normal file
20
mission/memory/SdCardMountedIF.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef MISSION_MEMORY_SDCARDMOUNTERIF_H_
|
||||
#define MISSION_MEMORY_SDCARDMOUNTERIF_H_
|
||||
|
||||
#include "definitions.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class SdCardMountedIF {
|
||||
public:
|
||||
virtual~SdCardMountedIF() {};
|
||||
virtual std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE) = 0;
|
||||
virtual bool isSdCardMounted(sd::SdCard sdCard) = 0;
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* MISSION_MEMORY_SDCARDMOUNTERIF_H_ */
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
||||
Subproject commit a671e86400152d8480c1efde29d69848ca6b6066
|
||||
Subproject commit 7e24589184bb7bbd427c66ed55b3c29bbeba927f
|
Loading…
Reference in New Issue
Block a user