v1.10.0 #220
@ -1205,7 +1205,7 @@ void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF*
|
||||
gpioComIF->addGpios(plPcduGpios);
|
||||
SpiCookie* spiCookie = new SpiCookie(addresses::PLPCDU_ADC, gpioIds::PLPCDU_ADC_CS,
|
||||
q7s::SPI_DEFAULT_DEV, plpcdu::MAX_ADC_REPLY_SIZE,
|
||||
spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
spi::DEFAULT_MAX_1227_MODE, spi::PL_PCDU_MAX_1227_SPEED);
|
||||
// Create device handler components
|
||||
auto plPcduHandler =
|
||||
new PayloadPcduHandler(objects::PLPCDU_HANDLER, objects::SPI_COM_IF, spiCookie, gpioComIF,
|
||||
|
@ -32,6 +32,8 @@ static const uint32_t SUS_MAX1227_SPI_FREQ = 976'000;
|
||||
static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 976'000;
|
||||
static constexpr spi::SpiModes DEFAULT_MAX_1227_MODE = spi::SpiModes::MODE_3;
|
||||
|
||||
static constexpr uint32_t PL_PCDU_MAX_1227_SPEED = 976'000;
|
||||
|
||||
static constexpr uint32_t DEFAULT_ADIS16507_SPEED = 976'000;
|
||||
static constexpr spi::SpiModes DEFAULT_ADIS16507_MODE = spi::SpiModes::MODE_3;
|
||||
|
||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
||||
Subproject commit e2eb6a46b6611dd93c4c50486ab9af5f223473e5
|
||||
Subproject commit 75c56280ad139640d2c12ac4ab78ce66c25fb495
|
@ -70,8 +70,8 @@ void PayloadPcduHandler::stateMachineToNormal() {
|
||||
if (submode == plpcdu::NORMAL_ALL_ON) {
|
||||
if (state == States::ON_TRANS_ADC_CLOSE_ZERO) {
|
||||
if (not commandExecuted) {
|
||||
float waitTime = SSR_TO_DRO_WAIT_TIME;
|
||||
params.getValue(PlPcduParameter::SSR_TO_DRO_WAIT_TIME_K, waitTime);
|
||||
float waitTime = DFT_SSR_TO_DRO_WAIT_TIME;
|
||||
params.getValue(PARAM_KEY_MAP[SSR_TO_DRO_WAIT_TIME], waitTime);
|
||||
countdown.setTimeout(std::round(waitTime * 1000));
|
||||
countdown.resetTimer();
|
||||
commandExecuted = true;
|
||||
@ -89,8 +89,8 @@ void PayloadPcduHandler::stateMachineToNormal() {
|
||||
}
|
||||
if (state == States::ON_TRANS_DRO) {
|
||||
if (not commandExecuted) {
|
||||
float waitTime = DRO_TO_X8_WAIT_TIME;
|
||||
params.getValue(PlPcduParameter::DRO_TO_X8_WAIT_TIME_K, waitTime);
|
||||
float waitTime = DFT_DRO_TO_X8_WAIT_TIME;
|
||||
params.getValue(PARAM_KEY_MAP[DRO_TO_X8_WAIT_TIME], waitTime);
|
||||
countdown.setTimeout(std::round(waitTime * 1000));
|
||||
countdown.resetTimer();
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
@ -111,8 +111,8 @@ void PayloadPcduHandler::stateMachineToNormal() {
|
||||
}
|
||||
if (state == States::ON_TRANS_X8) {
|
||||
if (not commandExecuted) {
|
||||
float waitTime = X8_TO_TX_WAIT_TIME;
|
||||
params.getValue(PlPcduParameter::X8_TO_TX_WAIT_TIME_K, waitTime);
|
||||
float waitTime = DFT_X8_TO_TX_WAIT_TIME;
|
||||
params.getValue(PARAM_KEY_MAP[X8_TO_TX_WAIT_TIME], waitTime);
|
||||
countdown.setTimeout(std::round(waitTime * 1000));
|
||||
countdown.resetTimer();
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
@ -133,8 +133,8 @@ void PayloadPcduHandler::stateMachineToNormal() {
|
||||
}
|
||||
if (state == States::ON_TRANS_TX) {
|
||||
if (not commandExecuted) {
|
||||
float waitTime = TX_TO_MPA_WAIT_TIME;
|
||||
params.getValue(PlPcduParameter::TX_TO_MPA_WAIT_TIME_K, waitTime);
|
||||
float waitTime = DFT_TX_TO_MPA_WAIT_TIME;
|
||||
params.getValue(PARAM_KEY_MAP[TX_TO_MPA_WAIT_TIME], waitTime);
|
||||
countdown.setTimeout(std::round(waitTime * 1000));
|
||||
countdown.resetTimer();
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
@ -156,8 +156,8 @@ void PayloadPcduHandler::stateMachineToNormal() {
|
||||
}
|
||||
if (state == States::ON_TRANS_MPA) {
|
||||
if (not commandExecuted) {
|
||||
float waitTime = MPA_TO_HPA_WAIT_TIME;
|
||||
params.getValue(PlPcduParameter::MPA_TO_HPA_WAIT_TIME_K, waitTime);
|
||||
float waitTime = DFT_MPA_TO_HPA_WAIT_TIME;
|
||||
params.getValue(PARAM_KEY_MAP[MPA_TO_HPA_WAIT_TIME], waitTime);
|
||||
countdown.setTimeout(std::round(waitTime * 1000));
|
||||
countdown.resetTimer();
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
@ -430,19 +430,24 @@ void PayloadPcduHandler::checkAdcValues() {
|
||||
adcTransition = state == States::ON_TRANS_DRO and adcCountdown.isBusy();
|
||||
// Now check against voltage and current limits, depending on state
|
||||
if (state >= States::ON_TRANS_DRO and not adcTransition) {
|
||||
params.getValue(PlPcduParameter::NEG_V_LOWER_BOUND_K, lowerBound);
|
||||
params.getValue(PlPcduParameter::NEG_V_UPPER_BOUND_K, upperBound);
|
||||
if (ssrToDroInjectionRequested) {
|
||||
handleFailureInjection("SSR to DRO", NEG_V_OUT_OF_BOUNDS);
|
||||
ssrToDroInjectionRequested = false;
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[NEG_V_LOWER_BOUND], lowerBound);
|
||||
params.getValue(PARAM_KEY_MAP[NEG_V_UPPER_BOUND], upperBound);
|
||||
if (not checkVoltage(adcSet.processed[U_NEG_V_FB], lowerBound, upperBound,
|
||||
NEG_V_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
params.getValue(PlPcduParameter::DRO_U_LOWER_BOUND_K, lowerBound);
|
||||
params.getValue(PlPcduParameter::DRO_U_UPPER_BOUND_K, upperBound);
|
||||
params.getValue(PARAM_KEY_MAP[DRO_U_LOWER_BOUND], lowerBound);
|
||||
params.getValue(PARAM_KEY_MAP[DRO_U_UPPER_BOUND], upperBound);
|
||||
if (not checkVoltage(adcSet.processed[U_DRO_DIV_6], lowerBound, upperBound,
|
||||
U_DRO_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
params.getValue(PlPcduParameter::DRO_I_UPPER_BOUND_K, upperBound);
|
||||
params.getValue(PARAM_KEY_MAP[DRO_I_UPPER_BOUND], upperBound);
|
||||
if (not checkCurrent(adcSet.processed[I_DRO], upperBound, I_DRO_OUT_OF_BOUNDS)) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::warning << "Detected out of bounds current for DRO: " << adcSet.processed[I_DRO]
|
||||
@ -453,52 +458,72 @@ void PayloadPcduHandler::checkAdcValues() {
|
||||
}
|
||||
adcTransition = state == States::ON_TRANS_X8 and adcCountdown.isBusy();
|
||||
if (state >= States::ON_TRANS_X8 and not adcTransition) {
|
||||
params.getValue(PlPcduParameter::X8_U_LOWER_BOUND_K, lowerBound);
|
||||
params.getValue(PlPcduParameter::X8_U_UPPER_BOUND_K, upperBound);
|
||||
if (droToX8InjectionRequested) {
|
||||
handleFailureInjection("X8 to TX", U_X8_OUT_OF_BOUNDS);
|
||||
droToX8InjectionRequested = false;
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[X8_U_LOWER_BOUND], lowerBound);
|
||||
params.getValue(PARAM_KEY_MAP[X8_U_UPPER_BOUND], upperBound);
|
||||
if (not checkVoltage(adcSet.processed[U_X8_DIV_6], lowerBound, upperBound,
|
||||
U_X8_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
params.getValue(PlPcduParameter::X8_I_UPPER_BOUND_K, upperBound);
|
||||
params.getValue(PARAM_KEY_MAP[X8_I_UPPER_BOUND], upperBound);
|
||||
if (not checkCurrent(adcSet.processed[I_X8], upperBound, I_X8_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
adcTransition = state == States::ON_TRANS_TX and adcCountdown.isBusy();
|
||||
if (state >= States::ON_TRANS_TX and not adcTransition) {
|
||||
params.getValue(PlPcduParameter::TX_U_LOWER_BOUND_K, lowerBound);
|
||||
params.getValue(PlPcduParameter::TX_U_UPPER_BOUND_K, upperBound);
|
||||
if (txToMpaInjectionRequested) {
|
||||
handleFailureInjection("TX to MPA", U_TX_OUT_OF_BOUNDS);
|
||||
txToMpaInjectionRequested = false;
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[TX_U_LOWER_BOUND], lowerBound);
|
||||
params.getValue(PARAM_KEY_MAP[TX_U_UPPER_BOUND], upperBound);
|
||||
if (not checkVoltage(adcSet.processed[U_TX_DIV_6], lowerBound, upperBound,
|
||||
U_TX_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
params.getValue(PlPcduParameter::TX_I_UPPER_BOUND_K, upperBound);
|
||||
params.getValue(PARAM_KEY_MAP[TX_I_UPPER_BOUND], upperBound);
|
||||
if (not checkCurrent(adcSet.processed[I_TX], upperBound, I_TX_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
adcTransition = state == States::ON_TRANS_MPA and adcCountdown.isBusy();
|
||||
if (state >= States::ON_TRANS_MPA and not adcTransition) {
|
||||
params.getValue(PlPcduParameter::MPA_U_LOWER_BOUND_K, lowerBound);
|
||||
params.getValue(PlPcduParameter::MPA_U_UPPER_BOUND_K, upperBound);
|
||||
if (mpaToHpaInjectionRequested) {
|
||||
handleFailureInjection("MPA to HPA", U_HPA_OUT_OF_BOUNDS);
|
||||
mpaToHpaInjectionRequested = false;
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[MPA_U_LOWER_BOUND], lowerBound);
|
||||
params.getValue(PARAM_KEY_MAP[MPA_U_UPPER_BOUND], upperBound);
|
||||
if (not checkVoltage(adcSet.processed[U_MPA_DIV_6], lowerBound, upperBound,
|
||||
U_MPA_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
params.getValue(PlPcduParameter::MPA_I_UPPER_BOUND_K, upperBound);
|
||||
params.getValue(PARAM_KEY_MAP[MPA_I_UPPER_BOUND], upperBound);
|
||||
if (not checkCurrent(adcSet.processed[I_MPA], upperBound, I_MPA_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
adcTransition = state == States::ON_TRANS_HPA and adcCountdown.isBusy();
|
||||
if (state >= States::ON_TRANS_HPA and not adcTransition) {
|
||||
params.getValue(PlPcduParameter::HPA_U_LOWER_BOUND_K, lowerBound);
|
||||
params.getValue(PlPcduParameter::HPA_U_UPPER_BOUND_K, upperBound);
|
||||
if (allOnInjectRequested) {
|
||||
handleFailureInjection("All On", U_HPA_OUT_OF_BOUNDS);
|
||||
allOnInjectRequested = false;
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[HPA_U_LOWER_BOUND], lowerBound);
|
||||
params.getValue(PARAM_KEY_MAP[HPA_U_UPPER_BOUND], upperBound);
|
||||
if (not checkVoltage(adcSet.processed[U_HPA_DIV_6], lowerBound, upperBound,
|
||||
U_HPA_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
params.getValue(PlPcduParameter::HPA_I_UPPER_BOUND_K, upperBound);
|
||||
params.getValue(PARAM_KEY_MAP[HPA_I_UPPER_BOUND], upperBound);
|
||||
if (not checkCurrent(adcSet.processed[I_HPA], upperBound, I_HPA_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
@ -560,6 +585,96 @@ ReturnValue_t PayloadPcduHandler::serializeFloat(uint32_t& param, float val) {
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
|
||||
ReturnValue_t PayloadPcduHandler::getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||
ParameterWrapper* parameterWrapper,
|
||||
const ParameterWrapper* newValues,
|
||||
uint16_t startAtIndex) {
|
||||
using namespace plpcdu;
|
||||
switch (uniqueId) {
|
||||
case (PlPcduParamIds::NEG_V_LOWER_BOUND):
|
||||
case (PlPcduParamIds::NEG_V_UPPER_BOUND):
|
||||
case (PlPcduParamIds::DRO_U_LOWER_BOUND):
|
||||
case (PlPcduParamIds::DRO_U_UPPER_BOUND):
|
||||
case (PlPcduParamIds::DRO_I_UPPER_BOUND):
|
||||
case (PlPcduParamIds::X8_U_LOWER_BOUND):
|
||||
case (PlPcduParamIds::X8_U_UPPER_BOUND):
|
||||
case (PlPcduParamIds::X8_I_UPPER_BOUND):
|
||||
case (PlPcduParamIds::TX_U_LOWER_BOUND):
|
||||
case (PlPcduParamIds::TX_U_UPPER_BOUND):
|
||||
case (PlPcduParamIds::TX_I_UPPER_BOUND):
|
||||
case (PlPcduParamIds::MPA_U_LOWER_BOUND):
|
||||
case (PlPcduParamIds::MPA_U_UPPER_BOUND):
|
||||
case (PlPcduParamIds::MPA_I_UPPER_BOUND):
|
||||
case (PlPcduParamIds::HPA_U_LOWER_BOUND):
|
||||
case (PlPcduParamIds::HPA_U_UPPER_BOUND):
|
||||
case (PlPcduParamIds::HPA_I_UPPER_BOUND):
|
||||
case (PlPcduParamIds::SSR_TO_DRO_WAIT_TIME):
|
||||
case (PlPcduParamIds::DRO_TO_X8_WAIT_TIME):
|
||||
case (PlPcduParamIds::X8_TO_TX_WAIT_TIME):
|
||||
case (PlPcduParamIds::TX_TO_MPA_WAIT_TIME):
|
||||
case (PlPcduParamIds::MPA_TO_HPA_WAIT_TIME): {
|
||||
handleDoubleParamUpdate(PARAM_KEY_MAP[static_cast<PlPcduParamIds>(uniqueId)],
|
||||
parameterWrapper, newValues);
|
||||
break;
|
||||
}
|
||||
case (PlPcduParamIds::INJECT_SSR_TO_DRO_FAILURE): {
|
||||
ssrToDroInjectionRequested = true;
|
||||
break;
|
||||
}
|
||||
case (PlPcduParamIds::INJECT_DRO_TO_X8_FAILURE): {
|
||||
droToX8InjectionRequested = true;
|
||||
break;
|
||||
}
|
||||
case (PlPcduParamIds::INJECT_X8_TO_TX_FAILURE): {
|
||||
x8ToTxInjectionRequested = true;
|
||||
break;
|
||||
}
|
||||
case (PlPcduParamIds::INJECT_TX_TO_MPA_FAILURE): {
|
||||
txToMpaInjectionRequested = true;
|
||||
break;
|
||||
}
|
||||
case (PlPcduParamIds::INJECT_MPA_TO_HPA_FAILURE): {
|
||||
mpaToHpaInjectionRequested = true;
|
||||
break;
|
||||
}
|
||||
case (PlPcduParamIds::INJECT_ALL_ON_FAILURE): {
|
||||
allOnInjectRequested = true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return DeviceHandlerBase::getParameter(domainId, uniqueId, parameterWrapper, newValues,
|
||||
startAtIndex);
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void PayloadPcduHandler::handleFailureInjection(std::string output, Event event) {
|
||||
sif::info << "PayloadPcduHandler::checkAdcValues: " << output
|
||||
<< " failure injection. "
|
||||
"Transitioning back to off"
|
||||
<< std::endl;
|
||||
triggerEvent(event, 0, 0);
|
||||
transitionOk = false;
|
||||
transitionBackToOff();
|
||||
droToX8InjectionRequested = false;
|
||||
}
|
||||
|
||||
ReturnValue_t PayloadPcduHandler::handleDoubleParamUpdate(std::string key,
|
||||
ParameterWrapper* parameterWrapper,
|
||||
const ParameterWrapper* newValues) {
|
||||
double newValue = 0.0;
|
||||
ReturnValue_t result = newValues->getElement<double>(&newValue, 0, 0);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
params.setValue(key, newValue);
|
||||
// Do this so the dumping and loading with the framework works as well
|
||||
doubleDummy = newValue;
|
||||
parameterWrapper->set(doubleDummy);
|
||||
return params.writeJsonFile();
|
||||
}
|
||||
|
||||
#ifdef FSFW_OSAL_LINUX
|
||||
ReturnValue_t PayloadPcduHandler::extConvAsTwoCallback(SpiComIF* comIf, SpiCookie* cookie,
|
||||
const uint8_t* sendData, size_t sendLen,
|
||||
|
@ -111,6 +111,15 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
||||
bool adcCmdExecuted = false;
|
||||
bool periodicPrintout = false;
|
||||
bool jsonFileInitComplete = false;
|
||||
double doubleDummy = 0.0;
|
||||
|
||||
bool ssrToDroInjectionRequested = false;
|
||||
bool droToX8InjectionRequested = false;
|
||||
bool x8ToTxInjectionRequested = false;
|
||||
bool txToMpaInjectionRequested = false;
|
||||
bool mpaToHpaInjectionRequested = false;
|
||||
bool allOnInjectRequested = false;
|
||||
|
||||
PeriodicOperationDivider opDivider = PeriodicOperationDivider(5);
|
||||
uint8_t tempReadDivisor = 1;
|
||||
Countdown countdown = Countdown(5000);
|
||||
@ -141,6 +150,8 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
|
||||
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper* parameterWrapper,
|
||||
const ParameterWrapper* newValues, uint16_t startAtIndex) override;
|
||||
|
||||
void handleExtConvRead(const uint8_t* bufStart);
|
||||
void handlePrintout();
|
||||
@ -150,7 +161,10 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
||||
void stateMachineToNormal();
|
||||
bool checkVoltage(float val, float lowerBound, float upperBound, Event event);
|
||||
bool checkCurrent(float val, float upperBound, Event event);
|
||||
void handleFailureInjection(std::string output, Event event);
|
||||
ReturnValue_t serializeFloat(uint32_t& param, float val);
|
||||
ReturnValue_t handleDoubleParamUpdate(std::string key, ParameterWrapper* parameterWrapper,
|
||||
const ParameterWrapper* newValues);
|
||||
};
|
||||
|
||||
#endif /* LINUX_DEVICES_PLPCDUHANDLER_H_ */
|
||||
|
@ -35,6 +35,53 @@ enum PlPcduAdcChannels : uint8_t {
|
||||
NUM_CHANNELS = 12
|
||||
};
|
||||
|
||||
enum PlPcduParamIds : uint8_t {
|
||||
NEG_V_LOWER_BOUND = 0,
|
||||
NEG_V_UPPER_BOUND = 1,
|
||||
DRO_U_LOWER_BOUND = 2,
|
||||
DRO_U_UPPER_BOUND = 3,
|
||||
DRO_I_UPPER_BOUND = 4,
|
||||
X8_U_LOWER_BOUND = 5,
|
||||
X8_U_UPPER_BOUND = 6,
|
||||
X8_I_UPPER_BOUND = 7,
|
||||
TX_U_LOWER_BOUND = 8,
|
||||
TX_U_UPPER_BOUND = 9,
|
||||
TX_I_UPPER_BOUND = 10,
|
||||
MPA_U_LOWER_BOUND = 11,
|
||||
MPA_U_UPPER_BOUND = 12,
|
||||
MPA_I_UPPER_BOUND = 13,
|
||||
HPA_U_LOWER_BOUND = 14,
|
||||
HPA_U_UPPER_BOUND = 15,
|
||||
HPA_I_UPPER_BOUND = 16,
|
||||
|
||||
SSR_TO_DRO_WAIT_TIME = 17,
|
||||
DRO_TO_X8_WAIT_TIME = 18,
|
||||
X8_TO_TX_WAIT_TIME = 19,
|
||||
TX_TO_MPA_WAIT_TIME = 20,
|
||||
MPA_TO_HPA_WAIT_TIME = 21,
|
||||
|
||||
INJECT_SSR_TO_DRO_FAILURE = 30,
|
||||
INJECT_DRO_TO_X8_FAILURE = 31,
|
||||
INJECT_X8_TO_TX_FAILURE = 32,
|
||||
INJECT_TX_TO_MPA_FAILURE = 33,
|
||||
INJECT_MPA_TO_HPA_FAILURE = 34,
|
||||
INJECT_ALL_ON_FAILURE = 35
|
||||
};
|
||||
|
||||
static std::map<PlPcduParamIds, std::string> PARAM_KEY_MAP = {
|
||||
{NEG_V_LOWER_BOUND, "negVoltLowerBound"}, {NEG_V_UPPER_BOUND, "negVoltUpperBound"},
|
||||
{DRO_U_LOWER_BOUND, "droVoltLowerBound"}, {DRO_U_UPPER_BOUND, "droVoltUpperBound"},
|
||||
{DRO_I_UPPER_BOUND, "droCurrUpperBound"}, {X8_U_LOWER_BOUND, "x8VoltLowerBound"},
|
||||
{X8_U_UPPER_BOUND, "x8VoltUpperBound"}, {X8_I_UPPER_BOUND, "x8CurrUpperBound"},
|
||||
{TX_U_LOWER_BOUND, "txVoltLowerBound"}, {TX_U_UPPER_BOUND, "txVoltUpperBound"},
|
||||
{TX_I_UPPER_BOUND, "txCurrUpperBound"}, {MPA_U_LOWER_BOUND, "mpaVoltLowerBound"},
|
||||
{MPA_U_UPPER_BOUND, "mpaVoltUpperBound"}, {MPA_I_UPPER_BOUND, "mpaCurrUpperBound"},
|
||||
{HPA_U_LOWER_BOUND, "hpaVoltLowerBound"}, {HPA_U_UPPER_BOUND, "hpaVoltUpperBound"},
|
||||
{HPA_I_UPPER_BOUND, "hpaCurrUpperBound"}, {SSR_TO_DRO_WAIT_TIME, "ssrToDroWait"},
|
||||
{DRO_TO_X8_WAIT_TIME, "droToX8Wait"}, {X8_TO_TX_WAIT_TIME, "x8ToTxWait"},
|
||||
{TX_TO_MPA_WAIT_TIME, "txToMpaWait"}, {MPA_TO_HPA_WAIT_TIME, "mpaToHpaWait"},
|
||||
};
|
||||
|
||||
enum PlPcduPoolIds : uint32_t { CHANNEL_VEC = 0, PROCESSED_VEC = 1, TEMP = 2 };
|
||||
|
||||
static constexpr size_t MAX_ADC_REPLY_SIZE = 64;
|
||||
@ -83,36 +130,36 @@ static constexpr float SCALE_CURRENT_DRO = MAX122X_SCALE / (GAIN_INA169 * R_SHUN
|
||||
|
||||
// TODO: Make these configurable parameters using a JSON file
|
||||
// Upper bound of currents in milliamperes [mA]
|
||||
static constexpr double NEG_V_LOWER_BOUND = -6.5;
|
||||
static constexpr double NEG_V_UPPER_BOUND = -2.7;
|
||||
static constexpr double DFT_NEG_V_LOWER_BOUND = -6.5;
|
||||
static constexpr double DFT_NEG_V_UPPER_BOUND = -2.7;
|
||||
|
||||
static constexpr double DRO_U_LOWER_BOUND = 5.0;
|
||||
static constexpr double DRO_U_UPPER_BOUND = 7.0;
|
||||
// Max Current DRO + Max Current Neg V | 40 + 15
|
||||
static constexpr double DRO_I_UPPER_BOUND = 55.0;
|
||||
|
||||
static constexpr double X8_U_LOWER_BOUND = 2.6;
|
||||
static constexpr double X8_U_UPPER_BOUND = 4.0;
|
||||
static constexpr double X8_I_UPPER_BOUND = 100.0;
|
||||
static constexpr double DFT_X8_U_LOWER_BOUND = 2.6;
|
||||
static constexpr double DFT_X8_U_UPPER_BOUND = 4.0;
|
||||
static constexpr double DFT_X8_I_UPPER_BOUND = 100.0;
|
||||
|
||||
static constexpr double TX_U_LOWER_BOUND = 2.6;
|
||||
static constexpr double TX_U_UPPER_BOUND = 4.0;
|
||||
static constexpr double TX_I_UPPER_BOUND = 250.0;
|
||||
static constexpr double DFT_TX_U_LOWER_BOUND = 2.6;
|
||||
static constexpr double DFT_TX_U_UPPER_BOUND = 4.0;
|
||||
static constexpr double DFT_TX_I_UPPER_BOUND = 250.0;
|
||||
|
||||
static constexpr double MPA_U_LOWER_BOUND = 2.6;
|
||||
static constexpr double MPA_U_UPPER_BOUND = 4.0;
|
||||
static constexpr double MPA_I_UPPER_BOUND = 650.0;
|
||||
static constexpr double DFT_MPA_U_LOWER_BOUND = 2.6;
|
||||
static constexpr double DFT_MPA_U_UPPER_BOUND = 4.0;
|
||||
static constexpr double DFT_MPA_I_UPPER_BOUND = 650.0;
|
||||
|
||||
static constexpr double HPA_U_LOWER_BOUND = 9.4;
|
||||
static constexpr double HPA_U_UPPER_BOUND = 11.0;
|
||||
static constexpr double HPA_I_UPPER_BOUND = 3000.0;
|
||||
static constexpr double DFT_HPA_U_LOWER_BOUND = 9.4;
|
||||
static constexpr double DFT_HPA_U_UPPER_BOUND = 11.0;
|
||||
static constexpr double DFT_HPA_I_UPPER_BOUND = 3000.0;
|
||||
|
||||
// Wait time in floating point seconds
|
||||
static constexpr double SSR_TO_DRO_WAIT_TIME = 5.0;
|
||||
static constexpr double DRO_TO_X8_WAIT_TIME = 905.0;
|
||||
static constexpr double X8_TO_TX_WAIT_TIME = 5.0;
|
||||
static constexpr double TX_TO_MPA_WAIT_TIME = 5.0;
|
||||
static constexpr double MPA_TO_HPA_WAIT_TIME = 5.0;
|
||||
static constexpr double DFT_SSR_TO_DRO_WAIT_TIME = 5.0;
|
||||
static constexpr double DFT_DRO_TO_X8_WAIT_TIME = 905.0;
|
||||
static constexpr double DFT_X8_TO_TX_WAIT_TIME = 5.0;
|
||||
static constexpr double DFT_TX_TO_MPA_WAIT_TIME = 5.0;
|
||||
static constexpr double DFT_MPA_TO_HPA_WAIT_TIME = 5.0;
|
||||
|
||||
/**
|
||||
* The current of the processed values is calculated and stored as a milliamperes [mA].
|
||||
@ -131,74 +178,49 @@ class PlPcduAdcSet : public StaticLocalDataSet<DATASET_ENTRIES> {
|
||||
|
||||
class PlPcduParameter : 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";
|
||||
|
||||
static constexpr char NEG_V_LOWER_BOUND_K[] = "negVoltLowerBound";
|
||||
static constexpr char NEG_V_UPPER_BOUND_K[] = "negVoltUpperBound";
|
||||
|
||||
static constexpr char DRO_U_LOWER_BOUND_K[] = "droVoltLowerBound";
|
||||
static constexpr char DRO_U_UPPER_BOUND_K[] = "droVoltUpperBound";
|
||||
static constexpr char DRO_I_UPPER_BOUND_K[] = "droCurrUpperBound";
|
||||
|
||||
static constexpr char X8_U_LOWER_BOUND_K[] = "x8VoltLowerBound";
|
||||
static constexpr char X8_U_UPPER_BOUND_K[] = "x8VoltUpperBound";
|
||||
static constexpr char X8_I_UPPER_BOUND_K[] = "x8CurrUpperBound";
|
||||
|
||||
static constexpr char TX_U_LOWER_BOUND_K[] = "txVoltLowerBound";
|
||||
static constexpr char TX_U_UPPER_BOUND_K[] = "txVoltUpperBound";
|
||||
static constexpr char TX_I_UPPER_BOUND_K[] = "txCurrUpperBound";
|
||||
|
||||
static constexpr char MPA_U_LOWER_BOUND_K[] = "mpaVoltLowerBound";
|
||||
static constexpr char MPA_U_UPPER_BOUND_K[] = "mpaVoltUpperBound";
|
||||
static constexpr char MPA_I_UPPER_BOUND_K[] = "mpaCurrUpperBound";
|
||||
|
||||
static constexpr char HPA_U_LOWER_BOUND_K[] = "hpaVoltLowerBound";
|
||||
static constexpr char HPA_U_UPPER_BOUND_K[] = "hpaVoltUpperBound";
|
||||
static constexpr char HPA_I_UPPER_BOUND_K[] = "hpaCurrUpperBound";
|
||||
|
||||
PlPcduParameter() : NVMParameterBase(""), mountPrefix("") {
|
||||
using namespace plpcdu;
|
||||
// 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);
|
||||
insertValue(NEG_V_LOWER_BOUND_K, NEG_V_LOWER_BOUND);
|
||||
insertValue(NEG_V_UPPER_BOUND_K, NEG_V_UPPER_BOUND);
|
||||
insertValue(DRO_U_LOWER_BOUND_K, DRO_U_LOWER_BOUND);
|
||||
insertValue(DRO_U_UPPER_BOUND_K, DRO_U_UPPER_BOUND);
|
||||
insertValue(DRO_I_UPPER_BOUND_K, DRO_I_UPPER_BOUND);
|
||||
insertValue(X8_U_LOWER_BOUND_K, X8_U_LOWER_BOUND);
|
||||
insertValue(X8_U_UPPER_BOUND_K, X8_U_UPPER_BOUND);
|
||||
insertValue(X8_I_UPPER_BOUND_K, X8_I_UPPER_BOUND);
|
||||
insertValue(TX_U_LOWER_BOUND_K, TX_U_LOWER_BOUND);
|
||||
insertValue(TX_U_UPPER_BOUND_K, TX_U_UPPER_BOUND);
|
||||
insertValue(TX_I_UPPER_BOUND_K, TX_I_UPPER_BOUND);
|
||||
insertValue(MPA_U_LOWER_BOUND_K, MPA_U_LOWER_BOUND);
|
||||
insertValue(MPA_U_UPPER_BOUND_K, MPA_U_UPPER_BOUND);
|
||||
insertValue(MPA_I_UPPER_BOUND_K, MPA_I_UPPER_BOUND);
|
||||
insertValue(HPA_U_LOWER_BOUND_K, HPA_U_LOWER_BOUND);
|
||||
insertValue(HPA_U_UPPER_BOUND_K, HPA_U_UPPER_BOUND);
|
||||
insertValue(HPA_I_UPPER_BOUND_K, HPA_I_UPPER_BOUND);
|
||||
resetValues();
|
||||
}
|
||||
|
||||
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
|
||||
// File does not exist or reading JSON failed for various reason. Rewrite the JSON file
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::info << "Creating PL PCDU JSON file at " << getFullName() << std::endl;
|
||||
#endif
|
||||
resetValues();
|
||||
writeJsonFile();
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
void resetValues() {
|
||||
insertValue(PARAM_KEY_MAP[SSR_TO_DRO_WAIT_TIME], DFT_SSR_TO_DRO_WAIT_TIME);
|
||||
insertValue(PARAM_KEY_MAP[DRO_TO_X8_WAIT_TIME], DFT_DRO_TO_X8_WAIT_TIME);
|
||||
insertValue(PARAM_KEY_MAP[X8_TO_TX_WAIT_TIME], DFT_X8_TO_TX_WAIT_TIME);
|
||||
insertValue(PARAM_KEY_MAP[TX_TO_MPA_WAIT_TIME], DFT_TX_TO_MPA_WAIT_TIME);
|
||||
insertValue(PARAM_KEY_MAP[MPA_TO_HPA_WAIT_TIME], DFT_MPA_TO_HPA_WAIT_TIME);
|
||||
insertValue(PARAM_KEY_MAP[NEG_V_LOWER_BOUND], DFT_NEG_V_LOWER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[NEG_V_UPPER_BOUND], DFT_NEG_V_UPPER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[DRO_U_LOWER_BOUND], DFT_DRO_U_LOWER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[DRO_U_UPPER_BOUND], DFT_DRO_U_UPPER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[DRO_I_UPPER_BOUND], DFT_DRO_I_UPPER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[X8_U_LOWER_BOUND], DFT_X8_U_LOWER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[X8_U_UPPER_BOUND], DFT_X8_U_UPPER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[X8_I_UPPER_BOUND], DFT_X8_I_UPPER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[TX_U_LOWER_BOUND], DFT_TX_U_LOWER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[TX_U_UPPER_BOUND], DFT_TX_U_UPPER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[TX_I_UPPER_BOUND], DFT_TX_I_UPPER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[MPA_U_LOWER_BOUND], DFT_MPA_U_LOWER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[MPA_U_UPPER_BOUND], DFT_MPA_U_UPPER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[MPA_I_UPPER_BOUND], DFT_MPA_I_UPPER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[HPA_U_LOWER_BOUND], DFT_HPA_U_LOWER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[HPA_U_UPPER_BOUND], DFT_HPA_U_UPPER_BOUND);
|
||||
insertValue(PARAM_KEY_MAP[HPA_I_UPPER_BOUND], DFT_HPA_I_UPPER_BOUND);
|
||||
}
|
||||
|
||||
private:
|
||||
std::string mountPrefix;
|
||||
|
@ -11,7 +11,12 @@ ReturnValue_t NVMParameterBase::readJsonFile() {
|
||||
if (std::filesystem::exists(fullName)) {
|
||||
// Read JSON file content into object
|
||||
std::ifstream i(fullName);
|
||||
i >> json;
|
||||
try {
|
||||
i >> json;
|
||||
} catch (nlohmann::json::exception& e) {
|
||||
sif::warning << "Reading JSON file failed with error " << e.what() << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
|
||||
@ -19,7 +24,12 @@ ReturnValue_t NVMParameterBase::readJsonFile() {
|
||||
|
||||
ReturnValue_t NVMParameterBase::writeJsonFile() {
|
||||
std::ofstream o(fullName);
|
||||
o << std::setw(4) << json << std::endl;
|
||||
try {
|
||||
o << std::setw(4) << json << std::endl;
|
||||
} catch (nlohmann::json::exception& e) {
|
||||
sif::warning << "Writing JSON file failed with error " << e.what() << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
||||
Subproject commit 9a487c7407eb450e3d07e1ddf3649a267ced99c2
|
||||
Subproject commit 07601b734eec162771251e8e5f5fae16d20f1655
|
Loading…
Reference in New Issue
Block a user