Merge branch 'mueller/system-subsystems' into mueller/master
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
This commit is contained in:
commit
60f9bf8fe5
@ -1,57 +0,0 @@
|
||||
#ifndef FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_
|
||||
#define FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_
|
||||
|
||||
#include <OBSWConfig.h>
|
||||
|
||||
namespace pcduSwitches {
|
||||
/* Switches are uint8_t datatype and go from 0 to 255 */
|
||||
enum SwitcherList {
|
||||
Q7S,
|
||||
PAYLOAD_PCDU_CH1,
|
||||
RW,
|
||||
TCS_BOARD_8V_HEATER_IN,
|
||||
SUS_REDUNDANT,
|
||||
DEPLOYMENT_MECHANISM,
|
||||
PAYLOAD_PCDU_CH6,
|
||||
ACS_BOARD_SIDE_B,
|
||||
PAYLOAD_CAMERA,
|
||||
TCS_BOARD_3V3,
|
||||
SYRLINKS,
|
||||
STAR_TRACKER,
|
||||
MGT,
|
||||
SUS_NOMINAL,
|
||||
SOLAR_CELL_EXP,
|
||||
PLOC,
|
||||
ACS_BOARD_SIDE_A,
|
||||
NUMBER_OF_SWITCHES
|
||||
};
|
||||
|
||||
static const uint8_t ON = 1;
|
||||
static const uint8_t OFF = 0;
|
||||
|
||||
/* Output states after reboot of the PDUs */
|
||||
static const uint8_t INIT_STATE_Q7S = ON;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF;
|
||||
static const uint8_t INIT_STATE_RW = OFF;
|
||||
#if BOARD_TE0720 == 1
|
||||
/* Because the TE0720 is not connected to the PCDU, this switch is always on */
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON;
|
||||
#else
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF;
|
||||
#endif
|
||||
static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF;
|
||||
static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF;
|
||||
static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF;
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF;
|
||||
static const uint8_t INIT_STATE_SYRLINKS = OFF;
|
||||
static const uint8_t INIT_STATE_STAR_TRACKER = OFF;
|
||||
static const uint8_t INIT_STATE_MGT = OFF;
|
||||
static const uint8_t INIT_STATE_SUS_NOMINAL = OFF;
|
||||
static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF;
|
||||
static const uint8_t INIT_STATE_PLOC = OFF;
|
||||
static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF;
|
||||
} // namespace pcduSwitches
|
||||
|
||||
#endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */
|
@ -736,7 +736,7 @@ void ObjectFactory::createHeaterComponents() {
|
||||
heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio);
|
||||
|
||||
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie,
|
||||
objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN);
|
||||
objects::PCDU_HANDLER, pcduSwitches::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V);
|
||||
}
|
||||
|
||||
void ObjectFactory::createSolarArrayDeploymentComponents() {
|
||||
@ -756,8 +756,8 @@ 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::DEPLOYMENT_MECHANISM, gpioIds::DEPLSA1,
|
||||
gpioIds::DEPLSA2, 1000);
|
||||
pcduSwitches::Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V,
|
||||
gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000);
|
||||
}
|
||||
|
||||
void ObjectFactory::createSyrlinksComponents() {
|
||||
|
@ -20,6 +20,7 @@ enum: uint8_t {
|
||||
PDEC_HANDLER = 119,
|
||||
STR_HELPER = 120,
|
||||
PL_PCDU_HANDLER = 121,
|
||||
ACS_BOARD_ASS = 122,
|
||||
COMMON_SUBSYSTEM_ID_END
|
||||
};
|
||||
}
|
||||
|
@ -6,54 +6,58 @@
|
||||
#include <cstdint>
|
||||
|
||||
namespace pcduSwitches {
|
||||
/* Switches are uint8_t datatype and go from 0 to 255 */
|
||||
enum SwitcherList: uint8_t {
|
||||
Q7S,
|
||||
PAYLOAD_PCDU_CH1,
|
||||
RW,
|
||||
TCS_BOARD_8V_HEATER_IN,
|
||||
SUS_REDUNDANT,
|
||||
DEPLOYMENT_MECHANISM,
|
||||
PAYLOAD_PCDU_CH6,
|
||||
ACS_BOARD_SIDE_B,
|
||||
PAYLOAD_CAMERA,
|
||||
TCS_BOARD_3V3,
|
||||
SYRLINKS,
|
||||
STAR_TRACKER,
|
||||
MGT,
|
||||
SUS_NOMINAL,
|
||||
SOLAR_CELL_EXP,
|
||||
PLOC,
|
||||
ACS_BOARD_SIDE_A,
|
||||
NUMBER_OF_SWITCHES
|
||||
};
|
||||
/* Switches are uint8_t datatype and go from 0 to 255 */
|
||||
enum Switches: uint8_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,
|
||||
|
||||
static const uint8_t ON = 1;
|
||||
static const uint8_t OFF = 0;
|
||||
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
|
||||
};
|
||||
|
||||
/* Output states after reboot of the PDUs */
|
||||
static const uint8_t INIT_STATE_Q7S = ON;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF;
|
||||
static const uint8_t INIT_STATE_RW = OFF;
|
||||
static const uint8_t ON = 1;
|
||||
static const uint8_t OFF = 0;
|
||||
|
||||
/* Output states after reboot of the PDUs */
|
||||
#if BOARD_TE0720 == 1
|
||||
/* Because the TE0720 is not connected to the PCDU, this switch is always on */
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON;
|
||||
/* Because the TE0720 is not connected to the PCDU, this switch is always on */
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON;
|
||||
#else
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF;
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF;
|
||||
#endif
|
||||
static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF;
|
||||
static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF;
|
||||
static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF;
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF;
|
||||
static const uint8_t INIT_STATE_SYRLINKS = OFF;
|
||||
static const uint8_t INIT_STATE_STAR_TRACKER = OFF;
|
||||
static const uint8_t INIT_STATE_MGT = OFF;
|
||||
static const uint8_t INIT_STATE_SUS_NOMINAL = OFF;
|
||||
static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF;
|
||||
static const uint8_t INIT_STATE_PLOC = OFF;
|
||||
static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF;
|
||||
static const uint8_t INIT_STATE_SYRLINKS = OFF;
|
||||
static const uint8_t INIT_STATE_STAR_TRACKER = OFF;
|
||||
static const uint8_t INIT_STATE_MGT = OFF;
|
||||
static const uint8_t INIT_STATE_SUS_NOMINAL = OFF;
|
||||
static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF;
|
||||
static const uint8_t INIT_STATE_PLOC = OFF;
|
||||
static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF;
|
||||
|
||||
static const uint8_t INIT_STATE_Q7S = ON;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF;
|
||||
static const uint8_t INIT_STATE_RW = OFF;
|
||||
static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF;
|
||||
static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF;
|
||||
static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF;
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
||||
Subproject commit 75c56280ad139640d2c12ac4ab78ce66c25fb495
|
||||
Subproject commit 4e6c1cb72ad623208ea8e08349f6ab39bfa45ed0
|
@ -28,6 +28,14 @@ LocalPoolDataSetBase *GPSHyperionLinuxController::getDataSetHandle(sid_t sid) {
|
||||
|
||||
ReturnValue_t GPSHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
uint32_t *msToReachTheMode) {
|
||||
if (not modeCommanded) {
|
||||
if (mode == MODE_ON or mode == MODE_OFF) {
|
||||
// 10 minutes time to reach fix
|
||||
*msToReachTheMode = 600000;
|
||||
maxTimeToReachFix.resetTimer();
|
||||
modeCommanded = true;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@ -114,6 +122,13 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
// 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix
|
||||
gpsSet.fixMode.value = gps->fix.mode;
|
||||
if (gps->fix.mode == 0 or gps->fix.mode == 1) {
|
||||
if (modeCommanded and maxTimeToReachFix.hasTimedOut()) {
|
||||
// We are supposed to be on and functioning, but not fix was found
|
||||
if (mode == MODE_ON or mode == MODE_NORMAL) {
|
||||
mode = MODE_OFF;
|
||||
}
|
||||
modeCommanded = false;
|
||||
}
|
||||
gpsSet.setValidity(false, true);
|
||||
} else if (gps->satellites_used > 0) {
|
||||
gpsSet.setValidity(true, true);
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
class GPSHyperionLinuxController : public ExtendedControllerBase {
|
||||
public:
|
||||
static constexpr uint32_t MAX_SECONDS_TO_REACH_FIX = 600;
|
||||
GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId,
|
||||
bool debugHyperionGps = false);
|
||||
virtual ~GPSHyperionLinuxController();
|
||||
@ -46,6 +47,8 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
|
||||
|
||||
private:
|
||||
GpsPrimaryDataset gpsSet;
|
||||
Countdown maxTimeToReachFix = Countdown(MAX_SECONDS_TO_REACH_FIX * 1000);
|
||||
bool modeCommanded = true;
|
||||
gpsmm myGpsmm;
|
||||
bool debugHyperionGps = false;
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
#ifndef FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_
|
||||
#define FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
namespace pcduSwitches {
|
||||
/* Switches are uint8_t datatype and go from 0 to 255 */
|
||||
enum SwitcherList : uint8_t {
|
||||
Q7S,
|
||||
PAYLOAD_PCDU_CH1,
|
||||
RW,
|
||||
TCS_BOARD_8V_HEATER_IN,
|
||||
SUS_REDUNDANT,
|
||||
DEPLOYMENT_MECHANISM,
|
||||
PAYLOAD_PCDU_CH6,
|
||||
ACS_BOARD_SIDE_B,
|
||||
PAYLOAD_CAMERA,
|
||||
TCS_BOARD_3V3,
|
||||
SYRLINKS,
|
||||
STAR_TRACKER,
|
||||
MGT,
|
||||
SUS_NOMINAL,
|
||||
SOLAR_CELL_EXP,
|
||||
PLOC,
|
||||
ACS_BOARD_SIDE_A,
|
||||
NUMBER_OF_SWITCHES
|
||||
};
|
||||
|
||||
static const uint8_t ON = 1;
|
||||
static const uint8_t OFF = 0;
|
||||
|
||||
/* Output states after reboot of the PDUs */
|
||||
static const uint8_t INIT_STATE_Q7S = ON;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF;
|
||||
static const uint8_t INIT_STATE_RW = OFF;
|
||||
#if BOARD_TE0720 == 1
|
||||
/* Because the TE0720 is not connected to the PCDU, this switch is always on */
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON;
|
||||
#else
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF;
|
||||
#endif
|
||||
static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF;
|
||||
static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF;
|
||||
static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF;
|
||||
static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF;
|
||||
static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF;
|
||||
static const uint8_t INIT_STATE_SYRLINKS = OFF;
|
||||
static const uint8_t INIT_STATE_STAR_TRACKER = OFF;
|
||||
static const uint8_t INIT_STATE_MGT = OFF;
|
||||
static const uint8_t INIT_STATE_SUS_NOMINAL = OFF;
|
||||
static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF;
|
||||
static const uint8_t INIT_STATE_PLOC = OFF;
|
||||
static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF;
|
||||
} // namespace pcduSwitches
|
||||
|
||||
#endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */
|
@ -1,10 +1,12 @@
|
||||
#include "PCDUHandler.h"
|
||||
|
||||
#include <OBSWConfig.h>
|
||||
#include <devices/powerSwitcherList.h>
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <fsfw/housekeeping/HousekeepingSnapshot.h>
|
||||
#include <fsfw/ipc/MutexFactory.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
|
||||
#include <objects/systemObjectList.h>
|
||||
|
||||
PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize)
|
||||
: SystemObject(setObjectId),
|
||||
@ -15,6 +17,7 @@ PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize)
|
||||
auto mqArgs = MqArgs(setObjectId, static_cast<void*>(this));
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
||||
cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
||||
pwrMutex = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
PCDUHandler::~PCDUHandler() {}
|
||||
@ -75,24 +78,26 @@ ReturnValue_t PCDUHandler::initialize() {
|
||||
}
|
||||
|
||||
void PCDUHandler::initializeSwitchStates() {
|
||||
switchStates[pcduSwitches::Q7S] = pcduSwitches::INIT_STATE_Q7S;
|
||||
switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1;
|
||||
switchStates[pcduSwitches::RW] = pcduSwitches::INIT_STATE_RW;
|
||||
switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] =
|
||||
using namespace pcduSwitches;
|
||||
switchStates[Switches::PDU2_CH0_Q7S] = pcduSwitches::INIT_STATE_Q7S;
|
||||
switchStates[Switches::PDU2_CH6_PL_PCDU_BATT_1_14V8] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1;
|
||||
switchStates[Switches::PDU2_CH2_RW_5V] = pcduSwitches::INIT_STATE_RW;
|
||||
switchStates[Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V] =
|
||||
pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN;
|
||||
switchStates[pcduSwitches::SUS_REDUNDANT] = pcduSwitches::INIT_STATE_SUS_REDUNDANT;
|
||||
switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM;
|
||||
switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6;
|
||||
switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B;
|
||||
switchStates[pcduSwitches::PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA;
|
||||
switchStates[pcduSwitches::TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3;
|
||||
switchStates[pcduSwitches::SYRLINKS] = pcduSwitches::INIT_STATE_SYRLINKS;
|
||||
switchStates[pcduSwitches::STAR_TRACKER] = pcduSwitches::INIT_STATE_STAR_TRACKER;
|
||||
switchStates[pcduSwitches::MGT] = pcduSwitches::INIT_STATE_MGT;
|
||||
switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL;
|
||||
switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP;
|
||||
switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC;
|
||||
switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A;
|
||||
switchStates[Switches::PDU2_CH4_SUS_REDUNDANT_3V3] = pcduSwitches::INIT_STATE_SUS_REDUNDANT;
|
||||
switchStates[Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V] =
|
||||
pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM;
|
||||
switchStates[Switches::PDU2_CH6_PL_PCDU_BATT_1_14V8] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6;
|
||||
switchStates[Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B;
|
||||
switchStates[Switches::PDU2_CH8_PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA;
|
||||
switchStates[Switches::PDU1_CH0_TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3;
|
||||
switchStates[Switches::PDU1_CH1_SYRLINKS_12V] = pcduSwitches::INIT_STATE_SYRLINKS;
|
||||
switchStates[Switches::PDU1_CH2_STAR_TRACKER_5V] = pcduSwitches::INIT_STATE_STAR_TRACKER;
|
||||
switchStates[Switches::PDU1_CH3_MGT_5V] = pcduSwitches::INIT_STATE_MGT;
|
||||
switchStates[Switches::PDU1_CH4_SUS_NOMINAL_3V3] = pcduSwitches::INIT_STATE_SUS_NOMINAL;
|
||||
switchStates[Switches::PDU1_CH5_SOLAR_CELL_EXP_5V] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP;
|
||||
switchStates[Switches::PDU1_CH6_PLOC_12V] = pcduSwitches::INIT_STATE_PLOC;
|
||||
switchStates[Switches::PDU1_CH7_ACS_A_SIDE_3V3] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A;
|
||||
}
|
||||
|
||||
void PCDUHandler::readCommandQueue() {
|
||||
@ -153,36 +158,50 @@ void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSet
|
||||
}
|
||||
|
||||
void PCDUHandler::updatePdu2SwitchStates() {
|
||||
// TODO: pool read helper
|
||||
if (pdu2HkTableDataset.read() == RETURN_OK) {
|
||||
switchStates[pcduSwitches::Q7S] = pdu2HkTableDataset.outEnabledQ7S.value;
|
||||
switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pdu2HkTableDataset.outEnabledPlPCDUCh1.value;
|
||||
switchStates[pcduSwitches::RW] = pdu2HkTableDataset.outEnabledReactionWheels.value;
|
||||
switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] =
|
||||
using namespace pcduSwitches;
|
||||
PoolReadGuard rg(&pdu2HkTableDataset);
|
||||
if (rg.getReadResult() == RETURN_OK) {
|
||||
MutexGuard mg(pwrMutex);
|
||||
switchStates[Switches::PDU2_CH0_Q7S] = pdu2HkTableDataset.outEnabledQ7S.value;
|
||||
switchStates[Switches::PDU2_CH1_PL_PCDU_BATT_0_14V8] =
|
||||
pdu2HkTableDataset.outEnabledPlPCDUCh1.value;
|
||||
switchStates[Switches::PDU2_CH2_RW_5V] = pdu2HkTableDataset.outEnabledReactionWheels.value;
|
||||
switchStates[Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V] =
|
||||
pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value;
|
||||
switchStates[pcduSwitches::SUS_REDUNDANT] = pdu2HkTableDataset.outEnabledSUSRedundant.value;
|
||||
switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] =
|
||||
switchStates[Switches::PDU2_CH4_SUS_REDUNDANT_3V3] =
|
||||
pdu2HkTableDataset.outEnabledSUSRedundant.value;
|
||||
switchStates[Switches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V] =
|
||||
pdu2HkTableDataset.outEnabledDeplMechanism.value;
|
||||
switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pdu2HkTableDataset.outEnabledPlPCDUCh6.value;
|
||||
switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pdu2HkTableDataset.outEnabledAcsBoardSideB.value;
|
||||
switchStates[pcduSwitches::PAYLOAD_CAMERA] = pdu2HkTableDataset.outEnabledPayloadCamera.value;
|
||||
switchStates[Switches::PDU2_CH6_PL_PCDU_BATT_1_14V8] =
|
||||
pdu2HkTableDataset.outEnabledPlPCDUCh6.value;
|
||||
switchStates[Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3] =
|
||||
pdu2HkTableDataset.outEnabledAcsBoardSideB.value;
|
||||
switchStates[Switches::PDU2_CH8_PAYLOAD_CAMERA] =
|
||||
pdu2HkTableDataset.outEnabledPayloadCamera.value;
|
||||
} else {
|
||||
sif::debug << "PCDUHandler::updatePdu2SwitchStates: Failed to read PDU2 Hk Dataset"
|
||||
<< std::endl;
|
||||
}
|
||||
pdu2HkTableDataset.commit();
|
||||
}
|
||||
|
||||
void PCDUHandler::updatePdu1SwitchStates() {
|
||||
if (pdu1HkTableDataset.read() == RETURN_OK) {
|
||||
switchStates[pcduSwitches::TCS_BOARD_3V3] = pdu1HkTableDataset.voltageOutTCSBoard3V3.value;
|
||||
switchStates[pcduSwitches::SYRLINKS] = pdu1HkTableDataset.voltageOutSyrlinks.value;
|
||||
switchStates[pcduSwitches::STAR_TRACKER] = pdu1HkTableDataset.voltageOutStarTracker.value;
|
||||
switchStates[pcduSwitches::MGT] = pdu1HkTableDataset.voltageOutMGT.value;
|
||||
switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value;
|
||||
switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value;
|
||||
switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value;
|
||||
switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value;
|
||||
using namespace pcduSwitches;
|
||||
PoolReadGuard rg(&pdu1HkTableDataset);
|
||||
if (rg.getReadResult() == RETURN_OK) {
|
||||
MutexGuard mg(pwrMutex);
|
||||
switchStates[Switches::PDU1_CH0_TCS_BOARD_3V3] = pdu1HkTableDataset.outEnabledTCSBoard3V3.value;
|
||||
switchStates[Switches::PDU1_CH1_SYRLINKS_12V] = pdu1HkTableDataset.outEnabledSyrlinks.value;
|
||||
switchStates[Switches::PDU1_CH2_STAR_TRACKER_5V] =
|
||||
pdu1HkTableDataset.outEnabledStarTracker.value;
|
||||
switchStates[Switches::PDU1_CH3_MGT_5V] = pdu1HkTableDataset.outEnabledMGT.value;
|
||||
switchStates[Switches::PDU1_CH4_SUS_NOMINAL_3V3] =
|
||||
pdu1HkTableDataset.outEnabledSUSNominal.value;
|
||||
switchStates[Switches::PDU1_CH5_SOLAR_CELL_EXP_5V] =
|
||||
pdu1HkTableDataset.outEnabledSolarCellExp.value;
|
||||
switchStates[Switches::PDU1_CH6_PLOC_12V] = pdu1HkTableDataset.outEnabledPLOC.value;
|
||||
switchStates[Switches::PDU1_CH7_ACS_A_SIDE_3V3] =
|
||||
pdu1HkTableDataset.outEnabledAcsBoardSideA.value;
|
||||
switchStates[Switches::PDU1_CH8_UNOCCUPIED] = pdu1HkTableDataset.outEnabledChannel8.value;
|
||||
} else {
|
||||
sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl;
|
||||
}
|
||||
@ -192,24 +211,110 @@ void PCDUHandler::updatePdu1SwitchStates() {
|
||||
LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { return &poolManager; }
|
||||
|
||||
void PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const {
|
||||
using namespace pcduSwitches;
|
||||
ReturnValue_t result;
|
||||
uint16_t memoryAddress;
|
||||
uint16_t memoryAddress = 0;
|
||||
size_t parameterValueSize = sizeof(uint8_t);
|
||||
uint8_t parameterValue;
|
||||
GomspaceDeviceHandler* pdu;
|
||||
uint8_t parameterValue = 0;
|
||||
GomspaceDeviceHandler* pdu = nullptr;
|
||||
|
||||
switch (switchNr) {
|
||||
case pcduSwitches::TCS_BOARD_8V_HEATER_IN:
|
||||
case pcduSwitches::PDU1_CH0_TCS_BOARD_3V3: {
|
||||
memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU1_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU1_CH1_SYRLINKS_12V: {
|
||||
memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_SYRLINKS;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU1_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU1_CH2_STAR_TRACKER_5V: {
|
||||
memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_STAR_TRACKER;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU1_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU1_CH3_MGT_5V: {
|
||||
memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_MGT;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU1_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU1_CH4_SUS_NOMINAL_3V3: {
|
||||
memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU1_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU1_CH5_SOLAR_CELL_EXP_5V: {
|
||||
memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU1_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU1_CH6_PLOC_12V: {
|
||||
memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_PLOC;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU1_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU1_CH7_ACS_A_SIDE_3V3: {
|
||||
memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU1_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU1_CH8_UNOCCUPIED: {
|
||||
memoryAddress = PDU1::CONFIG_ADDRESS_OUT_EN_CHANNEL8;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU1_HANDLER);
|
||||
break;
|
||||
}
|
||||
// That does not really make sense but let's keep it here for completeness reasons..
|
||||
case pcduSwitches::PDU2_CH0_Q7S: {
|
||||
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_Q7S;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU2_CH1_PL_PCDU_BATT_0_14V8: {
|
||||
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH1;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU2_CH2_RW_5V: {
|
||||
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_RW;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V: {
|
||||
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
|
||||
break;
|
||||
case pcduSwitches::DEPLOYMENT_MECHANISM:
|
||||
}
|
||||
case pcduSwitches::PDU2_CH4_SUS_REDUNDANT_3V3: {
|
||||
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_SUS_REDUNDANT;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU2_CH5_DEPLOYMENT_MECHANISM_8V: {
|
||||
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
case pcduSwitches::PDU2_CH6_PL_PCDU_BATT_1_14V8: {
|
||||
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3: {
|
||||
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_B;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
|
||||
break;
|
||||
}
|
||||
case pcduSwitches::PDU2_CH8_PAYLOAD_CAMERA: {
|
||||
memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA;
|
||||
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (onOff) {
|
||||
@ -252,7 +357,10 @@ ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const {
|
||||
sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
if (switchStates[switchNr] == 1) {
|
||||
pwrMutex->lockMutex();
|
||||
uint8_t currentState = switchStates[switchNr];
|
||||
pwrMutex->unlockMutex();
|
||||
if (currentState == 1) {
|
||||
return PowerSwitchIF::SWITCH_ON;
|
||||
} else {
|
||||
return PowerSwitchIF::SWITCH_OFF;
|
||||
|
@ -47,6 +47,7 @@ class PCDUHandler : public PowerSwitchIF,
|
||||
|
||||
private:
|
||||
uint32_t pstIntervalMs = 0;
|
||||
MutexIF* pwrMutex = nullptr;
|
||||
|
||||
/** Housekeeping manager. Handles updates of local pool variables. */
|
||||
LocalDataPoolManager poolManager;
|
||||
|
@ -460,7 +460,7 @@ ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker,
|
||||
channelSwitchHook(pdu, 5, unpacker.getParameter()[0], hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6PLOC): {
|
||||
case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6): {
|
||||
channelSwitchHook(pdu, 6, unpacker.getParameter()[0], hookArgs);
|
||||
break;
|
||||
}
|
||||
|
@ -2,9 +2,8 @@
|
||||
#define MISSION_DEVICES_RADIATIONSENSORHANDLER_H_
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||
#include <mission/devices/devicedefinitions/RadSensorDefinitions.h>
|
||||
#include <fsfw_hal/common/gpio/GpioIF.h>
|
||||
|
||||
#include <mission/devices/devicedefinitions/RadSensorDefinitions.h>
|
||||
|
||||
/**
|
||||
* @brief This is the device handler class for radiation sensor on the OBC IF Board. The
|
||||
|
@ -848,7 +848,7 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_RW = 0x4A;
|
||||
static const uint16_t CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN = 0x4B;
|
||||
static const uint16_t CONFIG_ADDRESS_OUT_EN_SUS_REDUNDANT = 0x4C;
|
||||
static const uint16_t CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM = 0x4D;
|
||||
static const uint16_t CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6PLOC = 0x4E;
|
||||
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;
|
||||
|
||||
|
@ -1 +1,432 @@
|
||||
#include "AcsBoardAssembly.h"
|
||||
|
||||
#include <devices/gpioIds.h>
|
||||
#include <fsfw/power/PowerSwitchIF.h>
|
||||
#include <fsfw/serviceinterface.h>
|
||||
|
||||
AcsBoardAssembly::AcsBoardAssembly(object_id_t objectId, object_id_t parentId,
|
||||
PowerSwitchIF* switcher, AcsBoardHelper helper, GpioIF* gpioIF)
|
||||
: AssemblyBase(objectId, parentId), pwrSwitcher(switcher), helper(helper), gpioIF(gpioIF) {
|
||||
if (switcher == nullptr) {
|
||||
sif::error << "AcsBoardAssembly::AcsBoardAssembly: Invalid Power Switcher "
|
||||
"IF passed"
|
||||
<< std::endl;
|
||||
}
|
||||
if (gpioIF == nullptr) {
|
||||
sif::error << "AcsBoardAssembly::AcsBoardAssembly: Invalid GPIO IF passed" << std::endl;
|
||||
}
|
||||
ModeListEntry entry;
|
||||
initModeTableEntry(helper.mgm0Lis3IdSideA, entry);
|
||||
initModeTableEntry(helper.mgm1Rm3100IdSideA, entry);
|
||||
initModeTableEntry(helper.mgm2Lis3IdSideB, entry);
|
||||
initModeTableEntry(helper.mgm3Rm3100IdSideB, entry);
|
||||
initModeTableEntry(helper.gyro0AdisIdSideA, entry);
|
||||
initModeTableEntry(helper.gyro1L3gIdSideA, entry);
|
||||
initModeTableEntry(helper.gyro2AdisIdSideB, entry);
|
||||
initModeTableEntry(helper.gyro3L3gIdSideB, entry);
|
||||
initModeTableEntry(helper.gpsId, entry);
|
||||
}
|
||||
|
||||
ReturnValue_t AcsBoardAssembly::commandChildren(Mode_t mode, Submode_t submode) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
refreshHelperModes();
|
||||
powerStateMachine(mode, submode);
|
||||
if (mode == DeviceHandlerIF::MODE_NORMAL or mode == MODE_ON) {
|
||||
if (state == States::MODE_COMMANDING) {
|
||||
handleNormalOrOnModeCmd(mode, submode);
|
||||
}
|
||||
} else {
|
||||
modeTable[ModeTableIdx::GYRO_0_A].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::GYRO_0_A].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::GYRO_1_A].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::GYRO_1_A].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::GYRO_2_B].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::GYRO_2_B].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::GYRO_3_B].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::GYRO_3_B].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::MGM_0_A].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::MGM_0_A].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::MGM_1_A].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::MGM_1_A].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::MGM_2_B].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::MGM_2_B].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::MGM_3_B].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::MGM_3_B].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::GPS].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::GPS].setSubmode(SUBMODE_NONE);
|
||||
}
|
||||
|
||||
HybridIterator<ModeListEntry> tableIter(modeTable.begin(), modeTable.end());
|
||||
executeTable(tableIter);
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t AcsBoardAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) {
|
||||
refreshHelperModes();
|
||||
if (submode == A_SIDE) {
|
||||
if ((helper.gyro0SideAMode != wantedMode and helper.gyro1SideAMode != wantedMode) or
|
||||
(helper.mgm0SideAMode != wantedMode and helper.mgm1SideAMode != wantedMode) or
|
||||
helper.gpsMode != wantedMode) {
|
||||
submode = B_SIDE;
|
||||
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
|
||||
}
|
||||
return RETURN_OK;
|
||||
} else if (submode == B_SIDE) {
|
||||
if ((helper.gyro2SideBMode != wantedMode and helper.gyro3SideBMode != wantedMode) or
|
||||
(helper.mgm2SideBMode != wantedMode and helper.mgm3SideBMode != wantedMode) or
|
||||
helper.gpsMode != wantedMode) {
|
||||
submode = DUAL_MODE;
|
||||
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
|
||||
}
|
||||
return RETURN_OK;
|
||||
} else if (submode == DUAL_MODE) {
|
||||
if ((helper.gyro0SideAMode != wantedMode and helper.gyro1SideAMode != wantedMode and
|
||||
helper.gyro2AdisIdSideB != wantedMode and helper.gyro3SideBMode != wantedMode) or
|
||||
(helper.mgm0SideAMode != wantedMode and helper.mgm1SideAMode != wantedMode and
|
||||
helper.mgm2SideBMode != wantedMode and helper.mgm3SideBMode != wantedMode) or
|
||||
helper.gpsMode != wantedMode) {
|
||||
// Trigger event, but don't start any other transitions. This is the last fallback mode.
|
||||
if (dualModeErrorSwitch) {
|
||||
triggerEvent(NOT_ENOUGH_DEVICES_DUAL_MODE, 0, 0);
|
||||
dualModeErrorSwitch = false;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
auto cmdSeq = [&](object_id_t objectId, Mode_t devMode, ModeTableIdx tableIdx) {
|
||||
if (mode == DeviceHandlerIF::MODE_NORMAL) {
|
||||
if (isUseable(objectId, devMode)) {
|
||||
if (mode != MODE_OFF) {
|
||||
modeTable[tableIdx].setMode(devMode);
|
||||
modeTable[tableIdx].setSubmode(SUBMODE_NONE);
|
||||
} else {
|
||||
result = NEED_SECOND_STEP;
|
||||
modeTable[tableIdx].setMode(MODE_ON);
|
||||
modeTable[tableIdx].setSubmode(SUBMODE_NONE);
|
||||
}
|
||||
}
|
||||
} else if (devMode == MODE_ON) {
|
||||
if (isUseable(objectId, devMode)) {
|
||||
modeTable[tableIdx].setMode(MODE_ON);
|
||||
modeTable[tableIdx].setSubmode(SUBMODE_NONE);
|
||||
}
|
||||
}
|
||||
};
|
||||
switch (this->submode) {
|
||||
case (A_SIDE): {
|
||||
cmdSeq(helper.gyro0AdisIdSideA, helper.gyro0SideAMode, ModeTableIdx::GYRO_0_A);
|
||||
cmdSeq(helper.gyro1L3gIdSideA, helper.gyro1SideAMode, ModeTableIdx::GYRO_1_A);
|
||||
cmdSeq(helper.mgm0Lis3IdSideA, helper.mgm0SideAMode, ModeTableIdx::MGM_0_A);
|
||||
cmdSeq(helper.mgm1Rm3100IdSideA, helper.mgm1SideAMode, ModeTableIdx::MGM_1_A);
|
||||
cmdSeq(helper.gpsId, helper.gpsMode, ModeTableIdx::GPS);
|
||||
ReturnValue_t result = gpioIF->pullLow(gpioIds::GNSS_SELECT);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::error << "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull GNSS select low"
|
||||
<< std::endl;
|
||||
#endif
|
||||
}
|
||||
modeTable[ModeTableIdx::GYRO_2_B].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::GYRO_2_B].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::GYRO_3_B].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::GYRO_3_B].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::MGM_2_B].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::MGM_2_B].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::MGM_3_B].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::MGM_3_B].setSubmode(SUBMODE_NONE);
|
||||
return result;
|
||||
}
|
||||
case (B_SIDE): {
|
||||
cmdSeq(helper.gyro2AdisIdSideB, helper.gyro2SideBMode, ModeTableIdx::GYRO_2_B);
|
||||
cmdSeq(helper.gyro3L3gIdSideB, helper.gyro3SideBMode, ModeTableIdx::GYRO_3_B);
|
||||
cmdSeq(helper.mgm2Lis3IdSideB, helper.mgm2SideBMode, ModeTableIdx::MGM_2_B);
|
||||
cmdSeq(helper.mgm3Rm3100IdSideB, helper.mgm3SideBMode, ModeTableIdx::MGM_3_B);
|
||||
cmdSeq(helper.gpsId, helper.gpsMode, ModeTableIdx::GPS);
|
||||
gpioIF->pullHigh(gpioIds::GNSS_SELECT);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::error << "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull GNSS select high"
|
||||
<< std::endl;
|
||||
#endif
|
||||
}
|
||||
modeTable[ModeTableIdx::GYRO_0_A].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::GYRO_0_A].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::GYRO_1_A].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::GYRO_1_A].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::MGM_0_A].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::MGM_0_A].setSubmode(SUBMODE_NONE);
|
||||
modeTable[ModeTableIdx::MGM_1_A].setMode(MODE_OFF);
|
||||
modeTable[ModeTableIdx::MGM_1_A].setSubmode(SUBMODE_NONE);
|
||||
return result;
|
||||
}
|
||||
case (DUAL_MODE): {
|
||||
cmdSeq(helper.gpsId, helper.gpsMode, ModeTableIdx::GPS);
|
||||
cmdSeq(helper.gyro0AdisIdSideA, helper.gyro0SideAMode, ModeTableIdx::GYRO_0_A);
|
||||
cmdSeq(helper.gyro1L3gIdSideA, helper.gyro1SideAMode, ModeTableIdx::GYRO_1_A);
|
||||
cmdSeq(helper.mgm0Lis3IdSideA, helper.mgm0SideAMode, ModeTableIdx::MGM_0_A);
|
||||
cmdSeq(helper.mgm1Rm3100IdSideA, helper.mgm1SideAMode, ModeTableIdx::MGM_1_A);
|
||||
cmdSeq(helper.gyro2AdisIdSideB, helper.gyro2SideBMode, ModeTableIdx::GYRO_2_B);
|
||||
cmdSeq(helper.gyro3L3gIdSideB, helper.gyro3SideBMode, ModeTableIdx::GYRO_3_B);
|
||||
cmdSeq(helper.mgm2Lis3IdSideB, helper.mgm2SideBMode, ModeTableIdx::MGM_2_B);
|
||||
cmdSeq(helper.mgm3Rm3100IdSideB, helper.mgm3SideBMode, ModeTableIdx::MGM_3_B);
|
||||
if (defaultSubmode == Submodes::A_SIDE) {
|
||||
result = gpioIF->pullLow(gpioIds::GNSS_SELECT);
|
||||
} else {
|
||||
result = gpioIF->pullHigh(gpioIds::GNSS_SELECT);
|
||||
}
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::error << "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull GNSS select to"
|
||||
"default side for dual mode"
|
||||
<< std::endl;
|
||||
#endif
|
||||
}
|
||||
return result;
|
||||
}
|
||||
default: {
|
||||
sif::error << "AcsBoardAssembly::handleNormalModeCmd: Unknown submode" << std::endl;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void AcsBoardAssembly::powerStateMachine(Mode_t mode, Submode_t submode) {
|
||||
ReturnValue_t switchStateA = RETURN_OK;
|
||||
ReturnValue_t switchStateB = RETURN_OK;
|
||||
if (state == States::IDLE or state == States::SWITCHING_POWER) {
|
||||
switchStateA = pwrSwitcher->getSwitchState(SWITCH_A);
|
||||
switchStateB = pwrSwitcher->getSwitchState(SWITCH_B);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (mode == MODE_OFF) {
|
||||
if (switchStateA == PowerSwitchIF::SWITCH_OFF and switchStateB == PowerSwitchIF::SWITCH_OFF) {
|
||||
state = States::MODE_COMMANDING;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
switch (this->submode) {
|
||||
case (A_SIDE): {
|
||||
if (switchStateA == PowerSwitchIF::SWITCH_ON and
|
||||
switchStateB == PowerSwitchIF::SWITCH_OFF) {
|
||||
state = States::MODE_COMMANDING;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (B_SIDE): {
|
||||
if (switchStateA == PowerSwitchIF::SWITCH_OFF and
|
||||
switchStateB == PowerSwitchIF::SWITCH_ON) {
|
||||
state = States::MODE_COMMANDING;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (DUAL_MODE): {
|
||||
if (switchStateA == PowerSwitchIF::SWITCH_ON and switchStateB == PowerSwitchIF::SWITCH_ON) {
|
||||
state = States::MODE_COMMANDING;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state == States::IDLE) {
|
||||
if (mode == MODE_OFF) {
|
||||
if (switchStateA != PowerSwitchIF::SWITCH_OFF) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_A, false);
|
||||
}
|
||||
if (switchStateB != PowerSwitchIF::SWITCH_OFF) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_B, false);
|
||||
}
|
||||
} else {
|
||||
switch (submode) {
|
||||
case (A_SIDE): {
|
||||
if (switchStateA != PowerSwitchIF::SWITCH_ON) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_A, true);
|
||||
}
|
||||
if (switchStateB != PowerSwitchIF::SWITCH_OFF) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_B, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (B_SIDE): {
|
||||
if (switchStateA != PowerSwitchIF::SWITCH_OFF) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_A, false);
|
||||
}
|
||||
if (switchStateB != PowerSwitchIF::SWITCH_ON) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_B, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (DUAL_MODE): {
|
||||
if (switchStateA != PowerSwitchIF::SWITCH_ON) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_A, true);
|
||||
}
|
||||
if (switchStateB != PowerSwitchIF::SWITCH_ON) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_B, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
state = States::SWITCHING_POWER;
|
||||
}
|
||||
if (state == States::SWITCHING_POWER) {
|
||||
// TODO: Could check for a timeout (temporal or cycles) here and resend command
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t AcsBoardAssembly::initialize() {
|
||||
ReturnValue_t result = registerChild(helper.gyro0AdisIdSideA);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = registerChild(helper.gyro1L3gIdSideA);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = registerChild(helper.gyro2AdisIdSideB);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = registerChild(helper.gyro3L3gIdSideB);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = registerChild(helper.mgm0Lis3IdSideA);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = registerChild(helper.mgm1Rm3100IdSideA);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = registerChild(helper.mgm2Lis3IdSideB);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = registerChild(helper.mgm3Rm3100IdSideB);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t AcsBoardAssembly::isModeCombinationValid(Mode_t mode, Submode_t submode) {
|
||||
if (submode != A_SIDE and submode != B_SIDE and submode != DUAL_MODE) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
bool AcsBoardAssembly::isUseable(object_id_t object, Mode_t mode) {
|
||||
if (healthHelper.healthTable->isFaulty(object)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if device is already in target mode
|
||||
if (childrenMap[object].mode == mode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (healthHelper.healthTable->isCommandable(object)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AcsBoardAssembly::handleModeReached() {
|
||||
AssemblyBase::handleModeReached();
|
||||
state = States::IDLE;
|
||||
tryingOtherSide = false;
|
||||
dualModeErrorSwitch = true;
|
||||
}
|
||||
|
||||
void AcsBoardAssembly::handleChildrenLostMode(ReturnValue_t result) {
|
||||
// Some ACS board components are required for Safe-Mode. It would be good if the software
|
||||
// transitions from A side to B side and from B side to dual mode autonomously
|
||||
// to ensure that that enough sensors are available without an operators intervention.
|
||||
// Therefore, the lost mode handler was overwritten to start these transitions
|
||||
Submode_t nextSubmode = Submodes::A_SIDE;
|
||||
if (submode == Submodes::A_SIDE) {
|
||||
nextSubmode = Submodes::B_SIDE;
|
||||
}
|
||||
if (not tryingOtherSide) {
|
||||
triggerEvent(CANT_KEEP_MODE, mode, submode);
|
||||
startTransition(mode, nextSubmode);
|
||||
tryingOtherSide = true;
|
||||
} else {
|
||||
// Not sure when this would happen. This flag is reset if the mode was reached. If it
|
||||
// was not reached, the transition failure handler should be called.
|
||||
sif::error << "AcsBoardAssembly::handleChildrenLostMode: Wrong handler called" << std::endl;
|
||||
triggerEvent(TRANSITION_OTHER_SIDE_FAILED, mode, targetSubmode);
|
||||
startTransition(mode, Submodes::DUAL_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
void AcsBoardAssembly::handleModeTransitionFailed(ReturnValue_t result) {
|
||||
Submode_t nextSubmode = Submodes::A_SIDE;
|
||||
if (submode == Submodes::A_SIDE) {
|
||||
nextSubmode = Submodes::B_SIDE;
|
||||
}
|
||||
// Check whether the transition was started because the mode could not be kept (not commanded).
|
||||
// If this is not the case, start transition to other side. If it is the case, start
|
||||
// transition to dual mode.
|
||||
if (not tryingOtherSide) {
|
||||
triggerEvent(CANT_KEEP_MODE, mode, submode);
|
||||
startTransition(mode, nextSubmode);
|
||||
tryingOtherSide = true;
|
||||
} else {
|
||||
triggerEvent(TRANSITION_OTHER_SIDE_FAILED, mode, targetSubmode);
|
||||
startTransition(mode, Submodes::DUAL_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
void AcsBoardAssembly::setPreferredSide(Submodes submode) {
|
||||
if (submode != Submodes::A_SIDE and submode != Submodes::B_SIDE) {
|
||||
return;
|
||||
}
|
||||
this->defaultSubmode = submode;
|
||||
}
|
||||
|
||||
void AcsBoardAssembly::selectGpsInDualMode(Submodes side) {
|
||||
if (submode != Submodes::DUAL_MODE) {
|
||||
return;
|
||||
}
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
if (side == Submodes::A_SIDE) {
|
||||
result = gpioIF->pullLow(gpioIds::GNSS_SELECT);
|
||||
} else {
|
||||
result = gpioIF->pullHigh(gpioIds::GNSS_SELECT);
|
||||
}
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::error << "AcsBoardAssembly::switchGpsInDualMode: Switching GPS failed" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void AcsBoardAssembly::refreshHelperModes() {
|
||||
helper.gyro0SideAMode = childrenMap[helper.gyro0AdisIdSideA].mode;
|
||||
helper.gyro1SideAMode = childrenMap[helper.gyro1L3gIdSideA].mode;
|
||||
helper.gyro2SideBMode = childrenMap[helper.gyro2AdisIdSideB].mode;
|
||||
helper.gyro3SideBMode = childrenMap[helper.gyro2AdisIdSideB].mode;
|
||||
helper.mgm0SideAMode = childrenMap[helper.mgm0Lis3IdSideA].mode;
|
||||
helper.mgm1SideAMode = childrenMap[helper.mgm1Rm3100IdSideA].mode;
|
||||
helper.mgm2SideBMode = childrenMap[helper.mgm2Lis3IdSideB].mode;
|
||||
helper.mgm3SideBMode = childrenMap[helper.mgm3Rm3100IdSideB].mode;
|
||||
}
|
||||
|
||||
void AcsBoardAssembly::initModeTableEntry(object_id_t id, ModeListEntry& entry) {
|
||||
entry.setObject(id);
|
||||
entry.setMode(MODE_OFF);
|
||||
entry.setSubmode(SUBMODE_NONE);
|
||||
entry.setInheritSubmode(false);
|
||||
modeTable.insert(entry);
|
||||
}
|
||||
|
@ -1,4 +1,122 @@
|
||||
#ifndef MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
|
||||
#define MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
|
||||
|
||||
#include <common/config/commonSubsystemIds.h>
|
||||
#include <devices/powerSwitcherList.h>
|
||||
#include <fsfw/devicehandlers/AssemblyBase.h>
|
||||
#include <fsfw/objectmanager/frameworkObjects.h>
|
||||
|
||||
struct AcsBoardHelper {
|
||||
AcsBoardHelper(object_id_t mgm0Id, object_id_t mgm1Id, object_id_t mgm2Id, object_id_t mgm3Id,
|
||||
object_id_t gyro0Id, object_id_t gyro1Id, object_id_t gyro2Id, object_id_t gyro3Id,
|
||||
object_id_t gpsId)
|
||||
: mgm0Lis3IdSideA(mgm0Id),
|
||||
mgm1Rm3100IdSideA(mgm1Id),
|
||||
mgm2Lis3IdSideB(mgm2Id),
|
||||
mgm3Rm3100IdSideB(mgm3Id),
|
||||
gyro0AdisIdSideA(gyro0Id),
|
||||
gyro1L3gIdSideA(gyro1Id),
|
||||
gyro2AdisIdSideB(gyro2Id),
|
||||
gyro3L3gIdSideB(gyro3Id) {}
|
||||
|
||||
object_id_t mgm0Lis3IdSideA = objects::NO_OBJECT;
|
||||
object_id_t mgm1Rm3100IdSideA = objects::NO_OBJECT;
|
||||
object_id_t mgm2Lis3IdSideB = objects::NO_OBJECT;
|
||||
object_id_t mgm3Rm3100IdSideB = objects::NO_OBJECT;
|
||||
|
||||
object_id_t gyro0AdisIdSideA = objects::NO_OBJECT;
|
||||
object_id_t gyro1L3gIdSideA = objects::NO_OBJECT;
|
||||
object_id_t gyro2AdisIdSideB = objects::NO_OBJECT;
|
||||
object_id_t gyro3L3gIdSideB = objects::NO_OBJECT;
|
||||
|
||||
object_id_t gpsId = objects::NO_OBJECT;
|
||||
|
||||
Mode_t gyro0SideAMode = HasModesIF::MODE_OFF;
|
||||
Mode_t gyro1SideAMode = HasModesIF::MODE_OFF;
|
||||
Mode_t gyro2SideBMode = HasModesIF::MODE_OFF;
|
||||
Mode_t gyro3SideBMode = HasModesIF::MODE_OFF;
|
||||
Mode_t mgm0SideAMode = HasModesIF::MODE_OFF;
|
||||
Mode_t mgm1SideAMode = HasModesIF::MODE_OFF;
|
||||
Mode_t mgm2SideBMode = HasModesIF::MODE_OFF;
|
||||
Mode_t mgm3SideBMode = HasModesIF::MODE_OFF;
|
||||
Mode_t gpsMode = HasModesIF::MODE_OFF;
|
||||
};
|
||||
|
||||
enum ModeTableIdx : uint8_t {
|
||||
MGM_0_A = 0,
|
||||
MGM_1_A = 1,
|
||||
MGM_2_B = 2,
|
||||
MGM_3_B = 3,
|
||||
GYRO_0_A = 4,
|
||||
GYRO_1_A = 5,
|
||||
GYRO_2_B = 6,
|
||||
GYRO_3_B = 7,
|
||||
GPS = 8
|
||||
};
|
||||
|
||||
class PowerSwitchIF;
|
||||
class GpioIF;
|
||||
|
||||
class AcsBoardAssembly : public AssemblyBase {
|
||||
public:
|
||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::ACS_BOARD_ASS;
|
||||
static constexpr Event TRANSITION_OTHER_SIDE_FAILED =
|
||||
event::makeEvent(SUBSYSTEM_ID, 0, severity::HIGH);
|
||||
static constexpr Event NOT_ENOUGH_DEVICES_DUAL_MODE =
|
||||
event::makeEvent(SUBSYSTEM_ID, 1, severity::HIGH);
|
||||
static constexpr uint8_t NUMBER_DEVICES_MODE_TABLE = 9;
|
||||
|
||||
enum Submodes : Submode_t { A_SIDE = 0, B_SIDE = 1, DUAL_MODE = 2 };
|
||||
|
||||
AcsBoardAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
|
||||
AcsBoardHelper helper, GpioIF* gpioIF);
|
||||
|
||||
void setPreferredSide(Submodes submode);
|
||||
|
||||
/**
|
||||
* In dual mode, the A side or the B side GPS device can be used, but not both.
|
||||
* This function can be used to switch the used GPS device.
|
||||
* @param side
|
||||
*/
|
||||
void selectGpsInDualMode(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;
|
||||
|
||||
enum class States { IDLE, SWITCHING_POWER, MODE_COMMANDING } state = States::IDLE;
|
||||
|
||||
PowerSwitchIF* pwrSwitcher = nullptr;
|
||||
bool tryingOtherSide = false;
|
||||
AcsBoardHelper helper;
|
||||
GpioIF* gpioIF = nullptr;
|
||||
Submodes defaultSubmode = Submodes::A_SIDE;
|
||||
bool dualModeErrorSwitch = true;
|
||||
FixedArrayList<ModeListEntry, NUMBER_DEVICES_MODE_TABLE> modeTable;
|
||||
|
||||
ReturnValue_t initialize() override;
|
||||
|
||||
// AssemblyBase overrides
|
||||
ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) override;
|
||||
ReturnValue_t checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) override;
|
||||
ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
|
||||
void handleModeReached() override;
|
||||
void handleModeTransitionFailed(ReturnValue_t result) override;
|
||||
void handleChildrenLostMode(ReturnValue_t result) override;
|
||||
|
||||
/**
|
||||
* Check whether it makes sense to send mode commands to the device
|
||||
* @param object
|
||||
* @param mode
|
||||
* @return
|
||||
*/
|
||||
bool isUseable(object_id_t object, Mode_t mode);
|
||||
ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode);
|
||||
void powerStateMachine(Mode_t mode, Submode_t submode);
|
||||
void initModeTableEntry(object_id_t id, ModeListEntry& entry);
|
||||
void refreshHelperModes();
|
||||
};
|
||||
|
||||
#endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */
|
||||
|
@ -1,5 +1,6 @@
|
||||
target_sources(${LIB_EIVE_MISSION} PRIVATE
|
||||
AcsBoardAssembly.cpp
|
||||
SusAssembly.cpp
|
||||
AcsSubsystem.cpp
|
||||
TcsSubsystem.cpp
|
||||
EiveSystem.cpp
|
||||
|
233
mission/system/SusAssembly.cpp
Normal file
233
mission/system/SusAssembly.cpp
Normal file
@ -0,0 +1,233 @@
|
||||
#include "SusAssembly.h"
|
||||
|
||||
#include <devices/powerSwitcherList.h>
|
||||
#include <fsfw/power/PowerSwitchIF.h>
|
||||
#include <fsfw/serviceinterface.h>
|
||||
|
||||
SusAssembly::SusAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
|
||||
SusAssHelper helper)
|
||||
: AssemblyBase(objectId, parentId), helper(helper), pwrSwitcher(pwrSwitcher) {
|
||||
ModeListEntry entry;
|
||||
for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS; idx++) {
|
||||
initModeTableEntry(helper.susIds[idx], entry);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t SusAssembly::commandChildren(Mode_t mode, Submode_t submode) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
refreshHelperModes();
|
||||
powerStateMachine(mode, submode);
|
||||
if (mode == DeviceHandlerIF::MODE_NORMAL or mode == MODE_ON) {
|
||||
if (state == States::MODE_COMMANDING) {
|
||||
handleNormalOrOnModeCmd(mode, submode);
|
||||
}
|
||||
} else {
|
||||
for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS; idx++) {
|
||||
modeTable[idx].setMode(MODE_OFF);
|
||||
modeTable[idx].setSubmode(SUBMODE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
HybridIterator<ModeListEntry> tableIter(modeTable.begin(), modeTable.end());
|
||||
executeTable(tableIter);
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
auto cmdSeq = [&](object_id_t objectId, uint8_t tableIdx) {
|
||||
if (mode == DeviceHandlerIF::MODE_NORMAL) {
|
||||
if (isUseable(objectId, mode)) {
|
||||
if (helper.susModes[tableIdx] != MODE_OFF) {
|
||||
modeTable[tableIdx].setMode(mode);
|
||||
modeTable[tableIdx].setSubmode(SUBMODE_NONE);
|
||||
} else {
|
||||
result = NEED_SECOND_STEP;
|
||||
modeTable[tableIdx].setMode(MODE_ON);
|
||||
modeTable[tableIdx].setSubmode(SUBMODE_NONE);
|
||||
}
|
||||
}
|
||||
} else if (mode == MODE_ON) {
|
||||
if (isUseable(objectId, mode)) {
|
||||
modeTable[tableIdx].setMode(MODE_ON);
|
||||
modeTable[tableIdx].setSubmode(SUBMODE_NONE);
|
||||
}
|
||||
}
|
||||
};
|
||||
switch (submode) {
|
||||
case (NOMINAL): {
|
||||
for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS_ONE_SIDE; idx++) {
|
||||
cmdSeq(helper.susIds[idx], idx);
|
||||
// Switch off devices on redundant side
|
||||
modeTable[idx + NUMBER_SUN_SENSORS_ONE_SIDE].setMode(MODE_OFF);
|
||||
modeTable[idx + NUMBER_SUN_SENSORS_ONE_SIDE].setSubmode(SUBMODE_NONE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
case (REDUNDANT): {
|
||||
for (uint8_t idx = NUMBER_SUN_SENSORS_ONE_SIDE; idx < NUMBER_SUN_SENSORS; idx++) {
|
||||
cmdSeq(helper.susIds[idx], idx);
|
||||
// Switch devices on nominal side
|
||||
modeTable[idx - NUMBER_SUN_SENSORS_ONE_SIDE].setMode(MODE_OFF);
|
||||
modeTable[idx - NUMBER_SUN_SENSORS_ONE_SIDE].setSubmode(SUBMODE_NONE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
case (DUAL_MODE): {
|
||||
for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS; idx++) {
|
||||
cmdSeq(helper.susIds[idx], idx);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SusAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) {
|
||||
refreshHelperModes();
|
||||
if (wantedSubmode == NOMINAL) {
|
||||
for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS_ONE_SIDE; idx++) {
|
||||
if (helper.susModes[idx] != wantedMode) {
|
||||
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
} else if (wantedSubmode == REDUNDANT) {
|
||||
for (uint8_t idx = NUMBER_SUN_SENSORS_ONE_SIDE; idx < NUMBER_SUN_SENSORS; idx++) {
|
||||
if (helper.susModes[idx] != wantedMode) {
|
||||
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
// Trigger event if devices are faulty? This is the last fallback mode, returning
|
||||
// a failure here would trigger a transition to MODE_OFF unless handleModeTransitionFailed
|
||||
// is overriden
|
||||
return RETURN_OK;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SusAssembly::isModeCombinationValid(Mode_t mode, Submode_t submode) {
|
||||
if (submode != NOMINAL and submode != REDUNDANT and submode != DUAL_MODE) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SusAssembly::initialize() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
for (const auto& id : helper.susIds) {
|
||||
result = registerChild(id);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SusAssembly::isUseable(object_id_t object, Mode_t mode) {
|
||||
if (healthHelper.healthTable->isFaulty(object)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if device is already in target mode
|
||||
if (childrenMap[object].mode == mode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (healthHelper.healthTable->isCommandable(object)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SusAssembly::powerStateMachine(Mode_t mode, Submode_t submode) {
|
||||
ReturnValue_t switchStateNom = RETURN_OK;
|
||||
ReturnValue_t switchStateRed = RETURN_OK;
|
||||
if (state == States::IDLE or state == States::SWITCHING_POWER) {
|
||||
switchStateNom = pwrSwitcher->getSwitchState(SWITCH_NOM);
|
||||
switchStateRed = pwrSwitcher->getSwitchState(SWITCH_RED);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (mode == MODE_OFF) {
|
||||
if (switchStateNom == PowerSwitchIF::SWITCH_OFF and
|
||||
switchStateRed == PowerSwitchIF::SWITCH_OFF) {
|
||||
state = States::MODE_COMMANDING;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (state == States::IDLE) {
|
||||
if (mode == MODE_OFF) {
|
||||
if (switchStateNom != PowerSwitchIF::SWITCH_OFF) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_NOM, false);
|
||||
}
|
||||
if (switchStateRed != PowerSwitchIF::SWITCH_OFF) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_RED, false);
|
||||
}
|
||||
} else {
|
||||
switch (submode) {
|
||||
case (NOMINAL): {
|
||||
if (switchStateNom != PowerSwitchIF::SWITCH_ON) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_NOM, true);
|
||||
}
|
||||
if (switchStateRed != PowerSwitchIF::SWITCH_OFF) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_RED, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (REDUNDANT): {
|
||||
if (switchStateRed != PowerSwitchIF::SWITCH_OFF) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_RED, false);
|
||||
}
|
||||
if (switchStateNom != PowerSwitchIF::SWITCH_ON) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_NOM, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (DUAL_MODE): {
|
||||
if (switchStateNom != PowerSwitchIF::SWITCH_ON) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_NOM, true);
|
||||
}
|
||||
if (switchStateRed != PowerSwitchIF::SWITCH_ON) {
|
||||
pwrSwitcher->sendSwitchCommand(SWITCH_RED, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
state = States::SWITCHING_POWER;
|
||||
}
|
||||
if (state == States::SWITCHING_POWER) {
|
||||
// TODO: Could check for a timeout (temporal or cycles) here and resend command
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SusAssembly::handleModeReached() {
|
||||
AssemblyBase::handleModeReached();
|
||||
state = States::IDLE;
|
||||
}
|
||||
|
||||
void SusAssembly::handleModeTransitionFailed(ReturnValue_t result) {
|
||||
// The sun-sensors are required for the Safe-Mode. It would be good if the software
|
||||
// transitions from nominal side to redundant side and from redundant side to dual mode
|
||||
// autonomously to ensure that that enough sensors are available witout an operators intervention.
|
||||
// Therefore, the failure handler is overriden to perform these steps.
|
||||
// TODO: Implement transitions mentioned above
|
||||
}
|
||||
|
||||
void SusAssembly::refreshHelperModes() {
|
||||
for (uint8_t idx = 0; idx < helper.susModes.size(); idx++) {
|
||||
helper.susModes[idx] = childrenMap[helper.susIds[idx]].mode;
|
||||
}
|
||||
}
|
||||
|
||||
void SusAssembly::initModeTableEntry(object_id_t id, ModeListEntry& entry) {
|
||||
entry.setObject(id);
|
||||
entry.setMode(MODE_OFF);
|
||||
entry.setSubmode(SUBMODE_NONE);
|
||||
entry.setInheritSubmode(false);
|
||||
modeTable.insert(entry);
|
||||
}
|
61
mission/system/SusAssembly.h
Normal file
61
mission/system/SusAssembly.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef MISSION_SYSTEM_SUSASSEMBLY_H_
|
||||
#define MISSION_SYSTEM_SUSASSEMBLY_H_
|
||||
|
||||
#include <devices/powerSwitcherList.h>
|
||||
#include <fsfw/devicehandlers/AssemblyBase.h>
|
||||
|
||||
struct SusAssHelper {
|
||||
public:
|
||||
SusAssHelper(std::array<object_id_t, 12> susIds) : susIds(susIds) {}
|
||||
std::array<object_id_t, 12> susIds = {objects::NO_OBJECT};
|
||||
std::array<Mode_t, 12> susModes = {HasModesIF::MODE_OFF};
|
||||
};
|
||||
|
||||
class PowerSwitchIF;
|
||||
|
||||
class SusAssembly : AssemblyBase {
|
||||
public:
|
||||
static constexpr uint8_t NUMBER_SUN_SENSORS_ONE_SIDE = 6;
|
||||
static constexpr uint8_t NUMBER_SUN_SENSORS = 12;
|
||||
|
||||
static constexpr Submode_t NOMINAL = 0;
|
||||
static constexpr Submode_t REDUNDANT = 1;
|
||||
static constexpr Submode_t DUAL_MODE = 2;
|
||||
|
||||
SusAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
|
||||
SusAssHelper helper);
|
||||
|
||||
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;
|
||||
FixedArrayList<ModeListEntry, NUMBER_SUN_SENSORS> modeTable;
|
||||
|
||||
SusAssHelper helper;
|
||||
PowerSwitchIF* pwrSwitcher = nullptr;
|
||||
|
||||
ReturnValue_t initialize() override;
|
||||
|
||||
// AssemblyBase overrides
|
||||
ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) override;
|
||||
ReturnValue_t checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) override;
|
||||
ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
|
||||
void handleModeReached() override;
|
||||
void handleModeTransitionFailed(ReturnValue_t result) override;
|
||||
|
||||
/**
|
||||
* Check whether it makes sense to send mode commands to the device
|
||||
* @param object
|
||||
* @param mode
|
||||
* @return
|
||||
*/
|
||||
bool isUseable(object_id_t object, Mode_t mode);
|
||||
void powerStateMachine(Mode_t mode, Submode_t submode);
|
||||
ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode);
|
||||
void initModeTableEntry(object_id_t id, ModeListEntry& entry);
|
||||
void refreshHelperModes();
|
||||
};
|
||||
|
||||
#endif /* MISSION_SYSTEM_SUSASSEMBLY_H_ */
|
@ -15,10 +15,12 @@ class EventManagerMock : public EventManager {
|
||||
void clearEventList();
|
||||
|
||||
bool isEventInEventList(object_id_t object, Event event);
|
||||
bool isEventInEventList(object_id_t object, Event event, uint32_t parameter1, uint32_t parameter2);
|
||||
bool isEventInEventList(object_id_t object, Event event, uint32_t parameter1,
|
||||
uint32_t parameter2);
|
||||
|
||||
bool isEventInEventList(object_id_t object, EventId_t eventId);
|
||||
bool isEventInEventList(object_id_t object, EventId_t eventId, uint32_t parameter1, uint32_t parameter2);
|
||||
bool isEventInEventList(object_id_t object, EventId_t eventId, uint32_t parameter1,
|
||||
uint32_t parameter2);
|
||||
|
||||
private:
|
||||
std::list<EventMessage> eventList;
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <fsfw/objectmanager/frameworkObjects.h>
|
||||
|
||||
|
||||
HouseKeepingMock::HouseKeepingMock() : SystemObject(objects::PUS_SERVICE_3_HOUSEKEEPING) {}
|
||||
|
||||
MessageQueueId_t HouseKeepingMock::getHkQueue() const { return MessageQueueIF::NO_QUEUE; }
|
@ -2,8 +2,8 @@
|
||||
#define HOUSEKEEPINGMOCK_H_
|
||||
|
||||
#include <fsfw/housekeeping/AcceptsHkPacketsIF.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/ipc/MessageQueueIF.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
|
||||
class HouseKeepingMock : public SystemObject, public AcceptsHkPacketsIF {
|
||||
public:
|
||||
@ -12,5 +12,4 @@ class HouseKeepingMock : public SystemObject, public AcceptsHkPacketsIF {
|
||||
virtual MessageQueueId_t getHkQueue() const;
|
||||
};
|
||||
|
||||
|
||||
#endif /*HOUSEKEEPINGMOCK_H_*/
|
Loading…
Reference in New Issue
Block a user