eive-obsw/linux/ObjectFactory.cpp

356 lines
19 KiB
C++
Raw Permalink Normal View History

2022-03-26 16:38:42 +01:00
#include "ObjectFactory.h"
#include <fsfw/power/PowerSwitchIF.h>
2022-09-30 14:30:30 +02:00
#include <fsfw/subsystem/Subsystem.h>
2022-03-26 16:38:42 +01:00
#include <fsfw_hal/common/gpio/GpioCookie.h>
#include <fsfw_hal/common/gpio/GpioIF.h>
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
2022-11-10 18:07:59 +01:00
#include <fsfw_hal/linux/serial/SerialCookie.h>
2022-03-26 16:38:42 +01:00
#include <fsfw_hal/linux/spi/SpiComIF.h>
#include <fsfw_hal/linux/spi/SpiCookie.h>
2023-03-24 21:01:00 +01:00
#include <linux/acs/SusPolling.h>
2022-03-26 16:38:42 +01:00
#include <linux/callbacks/gpioCallbacks.h>
2023-03-26 16:42:00 +02:00
#include <linux/tcs/Max31865RtdPolling.h>
2023-03-24 20:50:33 +01:00
#include <mission/acs/SusHandler.h>
2022-08-15 09:58:18 +02:00
#include <mission/controller/AcsController.h>
2023-06-07 11:33:09 +02:00
#include <mission/controller/PowerController.h>
2023-03-26 16:42:00 +02:00
#include <mission/genericFactory.h>
#include <mission/payload/ScexDeviceHandler.h>
2023-03-24 20:50:33 +01:00
#include <mission/system/acs/SusAssembly.h>
#include <mission/system/acs/SusFdir.h>
2023-04-13 23:54:23 +02:00
#include <mission/system/tcs/RtdFdir.h>
#include <mission/system/tcs/TcsBoardAssembly.h>
2023-03-26 16:42:00 +02:00
#include <mission/tcs/Max31865EiveHandler.h>
2022-03-26 16:38:42 +01:00
#include "OBSWConfig.h"
#include "devConf.h"
#include "devices/gpioIds.h"
2023-03-24 20:50:33 +01:00
#include "mission/system/acs/acsModeTree.h"
2024-04-09 13:33:56 +02:00
#include "mission/system/payload/payloadModeTree.h"
2023-09-28 12:00:04 +02:00
#include "mission/system/power/epsModeTree.h"
2022-03-26 16:38:42 +01:00
void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF,
2023-02-13 11:49:26 +01:00
PowerSwitchIF& pwrSwitcher, std::string spiDev,
2023-01-19 11:39:59 +01:00
bool swap0And6) {
2022-03-26 16:38:42 +01:00
using namespace gpio;
2023-03-01 16:36:21 +01:00
new SusPolling(objects::SUS_POLLING_TASK, *spiComIF, *gpioComIF);
2022-03-26 16:38:42 +01:00
GpioCookie* gpioCookieSus = new GpioCookie();
GpioCallback* susgpio = nullptr;
susgpio = new GpioCallback("Chip select SUS 0", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_0, susgpio);
susgpio = new GpioCallback("Chip select SUS 1", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio);
susgpio = new GpioCallback("Chip select SUS 2", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio);
susgpio = new GpioCallback("Chip select SUS 3", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio);
susgpio = new GpioCallback("Chip select SUS 4", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio);
susgpio = new GpioCallback("Chip select SUS 5", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio);
susgpio = new GpioCallback("Chip select SUS 6", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio);
susgpio = new GpioCallback("Chip select SUS 7", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio);
susgpio = new GpioCallback("Chip select SUS 8", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio);
susgpio = new GpioCallback("Chip select SUS 9", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio);
susgpio = new GpioCallback("Chip select SUS 10", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio);
susgpio = new GpioCallback("Chip select SUS 11", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio);
2022-04-28 18:38:38 +02:00
gpioChecker(gpioComIF->addGpios(gpioCookieSus), "Sun Sensors");
2022-03-26 16:38:42 +01:00
#if OBSW_ADD_SUN_SENSORS == 1
SusFdir* fdir = nullptr;
std::array<SusHandler*, 12> susHandlers = {};
2023-02-28 19:14:15 +01:00
SpiCookie* spiCookie =
new SpiCookie(addresses::SUS_0, gpioIds::CS_SUS_0, susMax1227::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[0] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_0_N_LOC_XFYFZM_PT_XF, 0, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_0_N_LOC_XFYFZM_PT_XF);
2022-03-26 16:38:42 +01:00
susHandlers[0]->setCustomFdir(fdir);
2023-02-28 19:14:15 +01:00
spiCookie = new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1, susMax1227::MAX_CMD_SIZE,
2022-03-26 16:38:42 +01:00
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[1] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_1_N_LOC_XBYFZM_PT_XB, 1, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_1_N_LOC_XBYFZM_PT_XB);
2022-03-26 16:38:42 +01:00
susHandlers[1]->setCustomFdir(fdir);
2023-02-28 19:14:15 +01:00
spiCookie = new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2, susMax1227::MAX_CMD_SIZE,
2022-03-26 16:38:42 +01:00
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[2] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_2_N_LOC_XFYBZB_PT_YB, 2, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_2_N_LOC_XFYBZB_PT_YB);
2022-03-26 16:38:42 +01:00
susHandlers[2]->setCustomFdir(fdir);
2023-02-28 19:14:15 +01:00
spiCookie = new SpiCookie(addresses::SUS_3, gpioIds::CS_SUS_3, susMax1227::MAX_CMD_SIZE,
2022-03-26 16:38:42 +01:00
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[3] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_3_N_LOC_XFYBZF_PT_YF, 3, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_3_N_LOC_XFYBZF_PT_YF);
2022-03-26 16:38:42 +01:00
susHandlers[3]->setCustomFdir(fdir);
2023-02-28 19:14:15 +01:00
spiCookie = new SpiCookie(addresses::SUS_4, gpioIds::CS_SUS_4, susMax1227::MAX_CMD_SIZE,
2022-03-26 16:38:42 +01:00
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[4] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_4_N_LOC_XMYFZF_PT_ZF, 4, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_4_N_LOC_XMYFZF_PT_ZF);
2022-03-26 16:38:42 +01:00
susHandlers[4]->setCustomFdir(fdir);
2023-02-28 19:14:15 +01:00
spiCookie = new SpiCookie(addresses::SUS_5, gpioIds::CS_SUS_5, susMax1227::MAX_CMD_SIZE,
2022-03-26 16:38:42 +01:00
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[5] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_5_N_LOC_XFYMZB_PT_ZB, 5, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_5_N_LOC_XFYMZB_PT_ZB);
2022-03-26 16:38:42 +01:00
susHandlers[5]->setCustomFdir(fdir);
2023-02-28 19:14:15 +01:00
spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, susMax1227::MAX_CMD_SIZE,
2023-02-06 15:52:49 +01:00
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[6] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_6_R_LOC_XFYBZM_PT_XF, 6, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_6_R_LOC_XFYBZM_PT_XF);
2022-03-26 16:38:42 +01:00
susHandlers[6]->setCustomFdir(fdir);
2023-02-28 19:14:15 +01:00
spiCookie = new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7, susMax1227::MAX_CMD_SIZE,
2022-03-26 16:38:42 +01:00
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[7] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_7_R_LOC_XBYBZM_PT_XB, 7, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_7_R_LOC_XBYBZM_PT_XB);
2022-03-26 16:38:42 +01:00
susHandlers[7]->setCustomFdir(fdir);
2023-02-28 19:14:15 +01:00
spiCookie = new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8, susMax1227::MAX_CMD_SIZE,
2022-03-26 16:38:42 +01:00
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[8] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_8_R_LOC_XBYBZB_PT_YB, 8, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_8_R_LOC_XBYBZB_PT_YB);
2022-03-26 16:38:42 +01:00
susHandlers[8]->setCustomFdir(fdir);
2023-02-28 19:14:15 +01:00
spiCookie = new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9, susMax1227::MAX_CMD_SIZE,
2022-03-26 16:38:42 +01:00
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[9] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_9_R_LOC_XBYBZB_PT_YF, 9, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_9_R_LOC_XBYBZB_PT_YF);
2022-03-26 16:38:42 +01:00
susHandlers[9]->setCustomFdir(fdir);
2023-02-28 19:14:15 +01:00
spiCookie = new SpiCookie(addresses::SUS_10, gpioIds::CS_SUS_10, susMax1227::MAX_CMD_SIZE,
2022-03-26 16:38:42 +01:00
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[10] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_10_N_LOC_XMYBZF_PT_ZF, 10, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_10_N_LOC_XMYBZF_PT_ZF);
2022-03-26 16:38:42 +01:00
susHandlers[10]->setCustomFdir(fdir);
2023-02-28 19:14:15 +01:00
spiCookie = new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11, susMax1227::MAX_CMD_SIZE,
2022-03-26 16:38:42 +01:00
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
2023-02-12 20:41:20 +01:00
spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, spi::SUS_CS_TIMEOUT);
2022-05-05 16:46:04 +02:00
susHandlers[11] =
2023-03-01 16:36:21 +01:00
new SusHandler(objects::SUS_11_R_LOC_XBYMZB_PT_ZB, 11, objects::SUS_POLLING_TASK, spiCookie);
2022-05-05 16:46:04 +02:00
fdir = new SusFdir(objects::SUS_11_R_LOC_XBYMZB_PT_ZB);
2022-03-26 16:38:42 +01:00
susHandlers[11]->setCustomFdir(fdir);
for (auto& sus : susHandlers) {
if (sus != nullptr) {
#if OBSW_TEST_SUS == 1
sus->setStartUpImmediately();
sus->setToGoToNormalMode(true);
#endif
#if OBSW_DEBUG_SUS == 1
sus->enablePeriodicPrintout(true, 3);
#endif
}
}
2023-02-13 11:49:26 +01:00
std::array<DeviceHandlerBase*, 12> susDhbs;
for (unsigned i = 0; i < susDhbs.size(); i++) {
susDhbs[i] = susHandlers[i];
}
createSusAssy(pwrSwitcher, susDhbs);
2022-03-26 16:38:42 +01:00
#endif /* OBSW_ADD_SUN_SENSORS == 1 */
}
2022-03-31 17:58:16 +02:00
void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF,
2022-05-12 12:21:47 +02:00
PowerSwitchIF* pwrSwitcher, SpiComIF* comIF) {
2022-03-31 17:58:16 +02:00
using namespace gpio;
GpioCookie* rtdGpioCookie = new GpioCookie;
GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_0, gpioRtdIc0);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_1, gpioRtdIc1);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_2, gpioRtdIc2);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc3);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc4);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc5);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc6);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc7);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc8);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc9);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc10);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc11);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc12);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc13);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc14);
2022-03-31 17:58:16 +02:00
GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", Direction::OUT, Levels::HIGH,
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
2023-10-25 17:48:28 +02:00
rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc15);
2022-03-31 17:58:16 +02:00
2022-04-28 18:38:38 +02:00
gpioChecker(gpioComIF->addGpios(rtdGpioCookie), "RTDs");
2022-03-31 17:58:16 +02:00
#if OBSW_ADD_RTD_DEVICES == 1
using namespace EiveMax31855;
2023-10-25 17:48:28 +02:00
// ! NOTE !
// The chip selects for device 9 and 11 are swapped here. It is strongly suspected the cables
// for those devices were swapped during integration. This is probably the easiest way to
// fix the issue.
std::array<std::pair<address_t, gpioId_t>, NUM_RTDS> cookieArgs = {{
2023-10-25 17:48:28 +02:00
{addresses::RTD_IC_0, gpioIds::RTD_IC_0},
{addresses::RTD_IC_1, gpioIds::RTD_IC_1},
{addresses::RTD_IC_2, gpioIds::RTD_IC_2},
2022-03-31 17:58:16 +02:00
{addresses::RTD_IC_3, gpioIds::RTD_IC_3},
{addresses::RTD_IC_4, gpioIds::RTD_IC_4},
{addresses::RTD_IC_5, gpioIds::RTD_IC_5},
{addresses::RTD_IC_6, gpioIds::RTD_IC_6},
{addresses::RTD_IC_7, gpioIds::RTD_IC_7},
{addresses::RTD_IC_8, gpioIds::RTD_IC_8},
{addresses::RTD_IC_11, gpioIds::RTD_IC_11},
2023-10-25 17:48:28 +02:00
{addresses::RTD_IC_10, gpioIds::RTD_IC_10},
{addresses::RTD_IC_9, gpioIds::RTD_IC_9},
2022-03-31 17:58:16 +02:00
{addresses::RTD_IC_12, gpioIds::RTD_IC_12},
{addresses::RTD_IC_13, gpioIds::RTD_IC_13},
{addresses::RTD_IC_14, gpioIds::RTD_IC_14},
{addresses::RTD_IC_15, gpioIds::RTD_IC_15},
}};
2022-05-13 10:33:35 +02:00
// HSPD: Heatspreader
2023-02-13 17:04:04 +01:00
std::array<SpiCookie*, NUM_RTDS> rtdCookies = {};
2022-05-14 15:26:08 +02:00
std::array<Max31865EiveHandler*, NUM_RTDS> rtds = {};
2022-03-31 17:58:16 +02:00
RtdFdir* rtdFdir = nullptr;
2022-09-29 17:06:19 +02:00
2023-04-11 22:58:13 +02:00
TcsBoardAssembly* tcsBoardAss =
ObjectFactory::createTcsBoardAssy(*pwrSwitcher, tcs::TCS_BOARD_SHORTLY_UNAVAILABLE);
2023-02-13 17:04:04 +01:00
2022-05-14 15:26:08 +02:00
// Create special low level reader communication interface
2023-02-21 02:59:28 +01:00
new Max31865RtdPolling(objects::SPI_RTD_COM_IF, comIF, gpioComIF);
for (uint8_t idx = 0; idx < NUM_RTDS; idx++) {
2022-05-12 09:48:41 +02:00
rtdCookies[idx] = new SpiCookie(cookieArgs[idx].first, cookieArgs[idx].second,
MAX31865::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
2022-05-14 11:34:25 +02:00
rtdCookies[idx]->setMutexParams(MutexIF::TimeoutType::WAITING, spi::RTD_CS_TIMEOUT);
2022-05-14 15:26:08 +02:00
Max31865ReaderCookie* rtdLowLevelCookie =
2023-02-13 17:04:04 +01:00
new Max31865ReaderCookie(RTD_INFOS[idx].first, idx, RTD_INFOS[idx].second, rtdCookies[idx]);
2022-05-14 15:26:08 +02:00
rtds[idx] =
2023-02-13 17:04:04 +01:00
new Max31865EiveHandler(RTD_INFOS[idx].first, objects::SPI_RTD_COM_IF, rtdLowLevelCookie);
rtds[idx]->setDeviceInfo(idx, RTD_INFOS[idx].second);
2022-09-30 13:30:22 +02:00
ReturnValue_t result = rtds[idx]->connectModeTreeParent(*tcsBoardAss);
2022-09-30 14:30:30 +02:00
if (result != returnvalue::OK) {
2022-09-30 13:30:22 +02:00
sif::error << "Connecting RTD " << static_cast<int>(idx) << " to RTD Assembly failed"
2022-09-30 14:30:30 +02:00
<< std::endl;
2022-09-30 13:30:22 +02:00
}
2023-02-13 17:04:04 +01:00
rtdFdir = new RtdFdir(RTD_INFOS[idx].first);
2022-03-31 17:58:16 +02:00
rtds[idx]->setCustomFdir(rtdFdir);
2022-04-26 10:37:25 +02:00
#if OBSW_DEBUG_RTD == 1
2022-05-14 15:26:08 +02:00
rtds[idx]->setDebugMode(true, 5);
2022-04-26 10:37:25 +02:00
#endif
2022-03-31 17:58:16 +02:00
#if OBSW_TEST_RTD == 1
2022-05-14 15:26:08 +02:00
rtds[idx]->setInstantNormal(true);
rtds[idx]->setStartUpImmediately();
2022-05-14 15:26:08 +02:00
#endif
2022-03-31 17:58:16 +02:00
}
2022-03-31 17:58:16 +02:00
#endif // OBSW_ADD_RTD_DEVICES == 1
}
2022-04-28 18:38:38 +02:00
void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher,
SdCardMountedIF& mountedIF, bool onImmediately,
2022-09-27 18:54:48 +02:00
std::optional<power::Switch_t> switchId) {
2023-03-22 02:20:14 +01:00
auto* cookie = new SerialCookie(objects::SCEX, uartDev, serial::SCEX_BAUD, 4096);
2022-10-05 18:44:52 +02:00
cookie->setTwoStopBits();
2022-10-10 17:40:30 +02:00
// cookie->setParityEven();
2022-05-29 17:52:13 +02:00
auto scexUartReader = new ScexUartReader(objects::SCEX_UART_READER);
auto scexHandler = new ScexDeviceHandler(objects::SCEX, *scexUartReader, cookie, mountedIF);
2022-09-27 18:54:48 +02:00
if (onImmediately) {
scexHandler->setStartUpImmediately();
}
if (switchId) {
2022-09-27 18:54:48 +02:00
scexHandler->setPowerSwitcher(*pwrSwitcher, switchId.value());
}
2023-03-14 11:21:37 +01:00
scexHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM);
2022-05-26 12:04:27 +02:00
}
2023-11-29 16:59:03 +01:00
AcsController* ObjectFactory::createAcsController(bool connectSubsystem, bool enableHkSets,
SdCardMountedIF& mountedIF) {
auto acsCtrl = new AcsController(objects::ACS_CONTROLLER, enableHkSets, mountedIF);
2022-09-30 14:30:30 +02:00
if (connectSubsystem) {
acsCtrl->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM);
2022-09-30 14:30:30 +02:00
}
return acsCtrl;
2022-09-29 19:40:00 +02:00
}
2022-08-15 09:58:18 +02:00
2023-09-28 12:00:04 +02:00
PowerController* ObjectFactory::createPowerController(bool connectSubsystem, bool enableHkSets) {
2023-06-07 11:33:09 +02:00
auto pwrCtrl = new PowerController(objects::POWER_CONTROLLER, enableHkSets);
2023-09-28 12:00:04 +02:00
if (connectSubsystem) {
pwrCtrl->connectModeTreeParent(satsystem::eps::EPS_SUBSYSTEM);
}
2023-06-07 11:33:09 +02:00
return pwrCtrl;
}
2022-04-28 18:38:38 +02:00
void ObjectFactory::gpioChecker(ReturnValue_t result, std::string output) {
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-04-28 18:38:38 +02:00
sif::error << "ObjectFactory: Adding GPIOs failed for " << output << std::endl;
}
}