diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 17170252..2bf36743 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -239,10 +239,9 @@ ReturnValue_t ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF, } void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialComIF* uartComIF, - PowerSwitchIF* pwrSwitcher) { + PowerSwitchIF& pwrSwitcher) { using namespace gpio; GpioCookie* gpioCookieAcsBoard = new GpioCookie(); - std::vector> assemblyChildren; std::stringstream consumer; GpiodRegularByLineName* gpio = nullptr; @@ -344,6 +343,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo #if OBSW_ADD_ACS_BOARD == 1 std::string spiDev = q7s::SPI_DEFAULT_DEV; + std::array assemblyChildren; SpiCookie* spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); @@ -352,7 +352,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo objects::MGM_0_LIS3_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::LIS3_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::MGM_0_LIS3_HANDLER); mgmLis3Handler0->setCustomFdir(fdir); - assemblyChildren.push_back(*mgmLis3Handler0); + assemblyChildren[0] = mgmLis3Handler0; #if OBSW_TEST_ACS == 1 mgmLis3Handler->setStartUpImmediately(); mgmLis3Handler->setToGoToNormalMode(true); @@ -369,7 +369,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo spi::RM3100_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::MGM_1_RM3100_HANDLER); mgmRm3100Handler1->setCustomFdir(fdir); - assemblyChildren.push_back(*mgmRm3100Handler1); + assemblyChildren[1] = mgmRm3100Handler1; #if OBSW_TEST_ACS == 1 mgmRm3100Handler->setStartUpImmediately(); mgmRm3100Handler->setToGoToNormalMode(true); @@ -385,7 +385,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo objects::MGM_2_LIS3_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::LIS3_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::MGM_2_LIS3_HANDLER); mgmLis3Handler2->setCustomFdir(fdir); - assemblyChildren.push_back(*mgmLis3Handler2); + assemblyChildren[2] = mgmLis3Handler2; #if OBSW_TEST_ACS == 1 mgmLis3Handler->setStartUpImmediately(); mgmLis3Handler->setToGoToNormalMode(true); @@ -402,7 +402,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo spi::RM3100_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::MGM_3_RM3100_HANDLER); mgmRm3100Handler3->setCustomFdir(fdir); - assemblyChildren.push_back(*mgmRm3100Handler3); + assemblyChildren[3] = mgmRm3100Handler3; #if OBSW_TEST_ACS == 1 mgmRm3100Handler->setStartUpImmediately(); mgmRm3100Handler->setToGoToNormalMode(true); @@ -421,7 +421,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo ADIS1650X::Type::ADIS16505); fdir = new AcsBoardFdir(objects::GYRO_0_ADIS_HANDLER); adisHandler->setCustomFdir(fdir); - assemblyChildren.push_back(*adisHandler); + assemblyChildren[4] = adisHandler; #if OBSW_TEST_ACS == 1 adisHandler->setStartUpImmediately(); adisHandler->setToGoToNormalModeImmediately(); @@ -437,7 +437,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo objects::GYRO_1_L3G_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::L3G_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::GYRO_1_L3G_HANDLER); gyroL3gHandler1->setCustomFdir(fdir); - assemblyChildren.push_back(*gyroL3gHandler1); + assemblyChildren[5] = gyroL3gHandler1; #if OBSW_TEST_ACS == 1 gyroL3gHandler->setStartUpImmediately(); gyroL3gHandler->setToGoToNormalMode(true); @@ -454,7 +454,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo spiCookie, ADIS1650X::Type::ADIS16505); fdir = new AcsBoardFdir(objects::GYRO_2_ADIS_HANDLER); adisHandler->setCustomFdir(fdir); - assemblyChildren.push_back(*adisHandler); + assemblyChildren[6] = adisHandler; #if OBSW_TEST_ACS == 1 adisHandler->setStartUpImmediately(); adisHandler->setToGoToNormalModeImmediately(); @@ -467,7 +467,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo objects::GYRO_3_L3G_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::L3G_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::GYRO_3_L3G_HANDLER); gyroL3gHandler3->setCustomFdir(fdir); - assemblyChildren.push_back(*gyroL3gHandler3); + assemblyChildren[7] = gyroL3gHandler3; #if OBSW_TEST_ACS == 1 gyroL3gHandler->setStartUpImmediately(); gyroL3gHandler->setToGoToNormalMode(true); @@ -485,22 +485,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo new GpsHyperionLinuxController(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps); gpsCtrl->setResetPinTriggerFunction(gps::triggerGpioResetPin, &RESET_ARGS_GNSS); - AcsBoardHelper acsBoardHelper = AcsBoardHelper( - objects::MGM_0_LIS3_HANDLER, objects::MGM_1_RM3100_HANDLER, objects::MGM_2_LIS3_HANDLER, - objects::MGM_3_RM3100_HANDLER, objects::GYRO_0_ADIS_HANDLER, objects::GYRO_1_L3G_HANDLER, - objects::GYRO_2_ADIS_HANDLER, objects::GYRO_3_L3G_HANDLER, objects::GPS_CONTROLLER); - auto acsAss = - new AcsBoardAssembly(objects::ACS_BOARD_ASS, pwrSwitcher, acsBoardHelper, gpioComIF); - static_cast(acsAss); - for (auto& assChild : assemblyChildren) { - ReturnValue_t result = assChild.get().connectModeTreeParent(*acsAss); - if (result != returnvalue::OK) { - sif::error << "Connecting assembly for ACS board component " << assChild.get().getObjectId() - << " failed" << std::endl; - } - } - gpsCtrl->connectModeTreeParent(*acsAss); - acsAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); + ObjectFactory::createAcsBoardAssy(pwrSwitcher, assemblyChildren, gpsCtrl, gpioComIF); #endif /* OBSW_ADD_ACS_HANDLERS == 1 */ } @@ -692,33 +677,24 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF, std::array rwIds = {objects::RW1, objects::RW2, objects::RW3, objects::RW4}; std::array rwGpioIds = {gpioIds::EN_RW1, gpioIds::EN_RW2, gpioIds::EN_RW3, gpioIds::EN_RW4}; - std::array rws = {}; + std::array rws = {}; for (uint8_t idx = 0; idx < rwCookies.size(); idx++) { rwCookies[idx] = new SpiCookie(rwCookieParams[idx].first, rwCookieParams[idx].second, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); - rws[idx] = new RwHandler(rwIds[idx], objects::SPI_RW_COM_IF, rwCookies[idx], gpioComIF, - rwGpioIds[idx]); + auto* rwHandler = new RwHandler(rwIds[idx], objects::SPI_RW_COM_IF, rwCookies[idx], gpioComIF, + rwGpioIds[idx]); rwCookies[idx]->setCallbackArgs(rws[idx]); #if OBSW_TEST_RW == 1 rws[idx]->setStartUpImmediately(); #endif #if OBSW_DEBUG_RW == 1 - rws[idx]->setDebugMode(true); + rwHandler->setDebugMode(true); #endif + rws[idx] = rwHandler; } - RwHelper rwHelper(rwIds); - auto* rwAss = - new RwAssembly(objects::RW_ASS, pwrSwitcher, pcdu::Switches::PDU2_CH2_RW_5V, rwHelper); - for (uint8_t idx = 0; idx < rws.size(); idx++) { - ReturnValue_t result = rws[idx]->connectModeTreeParent(*rwAss); - if (result != returnvalue::OK) { - sif::error << "Connecting RW " << static_cast(idx) << " to RW assembly failed" - << std::endl; - } - } - rwAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); + createRwAssy(*pwrSwitcher, pcdu::Switches::PDU2_CH2_RW_5V, rws, rwIds); #endif /* OBSW_ADD_RW == 1 */ } diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 61b629c8..9d0e4ea3 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -33,7 +33,7 @@ void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF, void createTmpComponents(); ReturnValue_t createRadSensorComponent(LinuxLibgpioIF* gpioComIF, Stack5VHandler& handler); void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialComIF* uartComIF, - PowerSwitchIF* pwrSwitcher); + PowerSwitchIF& pwrSwitcher); void createHeaterComponents(GpioIF* gpioIF, PowerSwitchIF* pwrSwitcher, HealthTableIF* healthTable, HeaterHandler*& heaterHandler); void createImtqComponents(PowerSwitchIF* pwrSwitcher); diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index 2aad7a23..ad76d308 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -221,12 +221,10 @@ void scheduling::initTasks() { if (result != returnvalue::OK) { scheduling::printAddObjectError("TCS_SUBSYSTEM", objects::TCS_SUBSYSTEM); } -#if OBSW_ADD_RTD_DEVICES == 1 result = tcsSystemTask->addComponent(objects::TCS_BOARD_ASS); if (result != returnvalue::OK) { scheduling::printAddObjectError("TCS_BOARD_ASS", objects::TCS_BOARD_ASS); } -#endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TCS_CTRL == 1 result = tcsSystemTask->addComponent(objects::THERMAL_CONTROLLER); if (result != returnvalue::OK) { diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 1a838b17..1f94e0d6 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "OBSWConfig.h" #include "bsp_q7s/core/CoreController.h" @@ -54,7 +55,7 @@ void ObjectFactory::produce(void* args) { createPcduComponents(gpioComIF, &pwrSwitcher); #endif - dummy::createDummies(dummyCfg, *pwrSwitcher); + dummy::createDummies(dummyCfg, *pwrSwitcher, gpioComIF); new CoreController(objects::CORE_CONTROLLER); @@ -74,7 +75,7 @@ void ObjectFactory::produce(void* args) { // createRadSensorComponent(gpioComIF); #if OBSW_ADD_ACS_BOARD == 1 - createAcsBoardComponents(gpioComIF, uartComIF, pwrSwitcher); + createAcsBoardComponents(gpioComIF, uartComIF, *pwrSwitcher); #endif #if OBSW_ADD_MGT == 1 @@ -115,5 +116,5 @@ void ObjectFactory::produce(void* args) { HeaterHandler* heaterHandler = nullptr; ObjectFactory::createGenericHeaterComponents(*gpioComIF, *pwrSwitcher, heaterHandler); createThermalController(*heaterHandler); - satsystem::com::init(); + satsystem::init(); } diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 4ca45e43..f04766eb 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -39,11 +39,11 @@ void ObjectFactory::produce(void* args) { createRadSensorComponent(gpioComIF, *stackHandler); #endif #if OBSW_ADD_SUN_SENSORS == 1 - createSunSensorComponents(gpioComIF, spiMainComIF, pwrSwitcher, q7s::SPI_DEFAULT_DEV, true); + createSunSensorComponents(gpioComIF, spiMainComIF, *pwrSwitcher, q7s::SPI_DEFAULT_DEV, true); #endif #if OBSW_ADD_ACS_BOARD == 1 - createAcsBoardComponents(gpioComIF, uartComIF, pwrSwitcher); + createAcsBoardComponents(gpioComIF, uartComIF, *pwrSwitcher); #endif HeaterHandler* heaterHandler; createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler); diff --git a/dummies/CMakeLists.txt b/dummies/CMakeLists.txt index 330aecfe..810cc048 100644 --- a/dummies/CMakeLists.txt +++ b/dummies/CMakeLists.txt @@ -14,12 +14,16 @@ target_sources( PduDummy.cpp P60DockDummy.cpp SaDeploymentDummy.cpp - GpsDummy.cpp + GpsDhbDummy.cpp + GpsCtrlDummy.cpp GyroAdisDummy.cpp GyroL3GD20Dummy.cpp MgmLIS3MDLDummy.cpp PlPcduDummy.cpp + ScexDummy.cpp CoreControllerDummy.cpp + PlocMpsocDummy.cpp + PlocSupervisorDummy.cpp helpers.cpp MgmRm3100Dummy.cpp Tmp1075Dummy.cpp) diff --git a/dummies/GpsCtrlDummy.cpp b/dummies/GpsCtrlDummy.cpp new file mode 100644 index 00000000..e69261b4 --- /dev/null +++ b/dummies/GpsCtrlDummy.cpp @@ -0,0 +1,21 @@ +#include "GpsCtrlDummy.h" + +GpsCtrlDummy::GpsCtrlDummy(object_id_t objectId) : ExtendedControllerBase(objectId, 20) {} + +ReturnValue_t GpsCtrlDummy::handleCommandMessage(CommandMessage* message) { + return returnvalue::OK; +} + +void GpsCtrlDummy::performControlOperation() {} + +ReturnValue_t GpsCtrlDummy::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) { + return returnvalue::OK; +} + +ReturnValue_t GpsCtrlDummy::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + return returnvalue::OK; +} + +LocalPoolDataSetBase* GpsCtrlDummy::getDataSetHandle(sid_t sid) { return nullptr; } diff --git a/dummies/GpsCtrlDummy.h b/dummies/GpsCtrlDummy.h new file mode 100644 index 00000000..128a9a85 --- /dev/null +++ b/dummies/GpsCtrlDummy.h @@ -0,0 +1,20 @@ +#ifndef DUMMIES_GPSCTRLDUMMY_H_ +#define DUMMIES_GPSCTRLDUMMY_H_ + +#include + +class GpsCtrlDummy : public ExtendedControllerBase { + public: + GpsCtrlDummy(object_id_t objectId); + + private: + ReturnValue_t handleCommandMessage(CommandMessage* message) override; + void performControlOperation() override; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; +}; + +#endif /* DUMMIES_GPSCTRLDUMMY_H_ */ diff --git a/dummies/GpsDummy.cpp b/dummies/GpsDhbDummy.cpp similarity index 53% rename from dummies/GpsDummy.cpp rename to dummies/GpsDhbDummy.cpp index 893e8464..d46e6265 100644 --- a/dummies/GpsDummy.cpp +++ b/dummies/GpsDhbDummy.cpp @@ -1,42 +1,44 @@ -#include "GpsDummy.h" - +#include #include -GpsDummy::GpsDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) +GpsDhbDummy::GpsDhbDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) : DeviceHandlerBase(objectId, comif, comCookie) {} -GpsDummy::~GpsDummy() {} +GpsDhbDummy::~GpsDhbDummy() {} -void GpsDummy::doStartUp() {} +void GpsDhbDummy::doStartUp() {} -void GpsDummy::doShutDown() {} +void GpsDhbDummy::doShutDown() {} -ReturnValue_t GpsDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; } - -ReturnValue_t GpsDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { +ReturnValue_t GpsDhbDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; } -ReturnValue_t GpsDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen) { +ReturnValue_t GpsDhbDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t GpsDhbDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { return returnvalue::OK; } -ReturnValue_t GpsDummy::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, - size_t *foundLen) { +ReturnValue_t GpsDhbDummy::scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) { return returnvalue::OK; } -ReturnValue_t GpsDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t GpsDhbDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { return returnvalue::OK; } -void GpsDummy::fillCommandAndReplyMap() {} +void GpsDhbDummy::fillCommandAndReplyMap() {} -uint32_t GpsDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } +uint32_t GpsDhbDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } -ReturnValue_t GpsDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { +ReturnValue_t GpsDhbDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0}, 1)); localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0}, 1)); localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); diff --git a/dummies/GpsDhbDummy.h b/dummies/GpsDhbDummy.h new file mode 100644 index 00000000..a1df7e45 --- /dev/null +++ b/dummies/GpsDhbDummy.h @@ -0,0 +1,33 @@ +#ifndef DUMMIES_GPSDHBDUMMY_H_ +#define DUMMIES_GPSDHBDUMMY_H_ + +#include + +class GpsDhbDummy : public DeviceHandlerBase { + public: + static const DeviceCommandId_t SIMPLE_COMMAND = 1; + static const DeviceCommandId_t PERIODIC_REPLY = 2; + + static const uint8_t SIMPLE_COMMAND_DATA = 1; + static const uint8_t PERIODIC_REPLY_DATA = 2; + + GpsDhbDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + virtual ~GpsDhbDummy(); + + protected: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; +}; + +#endif /* DUMMIES_GPSDHBDUMMY_H_ */ diff --git a/dummies/PlocMpsocDummy.cpp b/dummies/PlocMpsocDummy.cpp new file mode 100644 index 00000000..2df55b1d --- /dev/null +++ b/dummies/PlocMpsocDummy.cpp @@ -0,0 +1,42 @@ +#include "PlocMpsocDummy.h" + +PlocMpsocDummy::PlocMpsocDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) + : DeviceHandlerBase(objectId, comif, comCookie) {} + +PlocMpsocDummy::~PlocMpsocDummy() {} + +void PlocMpsocDummy::doStartUp() {} + +void PlocMpsocDummy::doShutDown() {} + +ReturnValue_t PlocMpsocDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t PlocMpsocDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t PlocMpsocDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + return returnvalue::OK; +} + +ReturnValue_t PlocMpsocDummy::scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) { + return returnvalue::OK; +} + +ReturnValue_t PlocMpsocDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + return returnvalue::OK; +} + +void PlocMpsocDummy::fillCommandAndReplyMap() {} + +uint32_t PlocMpsocDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } + +ReturnValue_t PlocMpsocDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + return returnvalue::OK; +} diff --git a/dummies/GpsDummy.h b/dummies/PlocMpsocDummy.h similarity index 83% rename from dummies/GpsDummy.h rename to dummies/PlocMpsocDummy.h index b32b7f17..7beaa76b 100644 --- a/dummies/GpsDummy.h +++ b/dummies/PlocMpsocDummy.h @@ -1,9 +1,8 @@ -#ifndef DUMMIES_GPSDUMMY_H_ -#define DUMMIES_GPSDUMMY_H_ +#pragma once #include -class GpsDummy : public DeviceHandlerBase { +class PlocMpsocDummy : public DeviceHandlerBase { public: static const DeviceCommandId_t SIMPLE_COMMAND = 1; static const DeviceCommandId_t PERIODIC_REPLY = 2; @@ -11,8 +10,8 @@ class GpsDummy : public DeviceHandlerBase { static const uint8_t SIMPLE_COMMAND_DATA = 1; static const uint8_t PERIODIC_REPLY_DATA = 2; - GpsDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); - virtual ~GpsDummy(); + PlocMpsocDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + virtual ~PlocMpsocDummy(); protected: void doStartUp() override; @@ -29,5 +28,3 @@ class GpsDummy : public DeviceHandlerBase { ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; }; - -#endif /* DUMMIES_GPSDUMMY_H_ */ diff --git a/dummies/PlocSupervisorDummy.cpp b/dummies/PlocSupervisorDummy.cpp new file mode 100644 index 00000000..d4730fe9 --- /dev/null +++ b/dummies/PlocSupervisorDummy.cpp @@ -0,0 +1,44 @@ +#include "PlocSupervisorDummy.h" + +PlocSupervisorDummy::PlocSupervisorDummy(object_id_t objectId, object_id_t comif, + CookieIF *comCookie) + : DeviceHandlerBase(objectId, comif, comCookie) {} + +PlocSupervisorDummy::~PlocSupervisorDummy() {} + +void PlocSupervisorDummy::doStartUp() {} + +void PlocSupervisorDummy::doShutDown() {} + +ReturnValue_t PlocSupervisorDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t PlocSupervisorDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t PlocSupervisorDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + return returnvalue::OK; +} + +ReturnValue_t PlocSupervisorDummy::scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) { + return returnvalue::OK; +} + +ReturnValue_t PlocSupervisorDummy::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t *packet) { + return returnvalue::OK; +} + +void PlocSupervisorDummy::fillCommandAndReplyMap() {} + +uint32_t PlocSupervisorDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } + +ReturnValue_t PlocSupervisorDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + return returnvalue::OK; +} diff --git a/dummies/PlocSupervisorDummy.h b/dummies/PlocSupervisorDummy.h new file mode 100644 index 00000000..4118c893 --- /dev/null +++ b/dummies/PlocSupervisorDummy.h @@ -0,0 +1,30 @@ +#pragma once + +#include + +class PlocSupervisorDummy : public DeviceHandlerBase { + public: + static const DeviceCommandId_t SIMPLE_COMMAND = 1; + static const DeviceCommandId_t PERIODIC_REPLY = 2; + + static const uint8_t SIMPLE_COMMAND_DATA = 1; + static const uint8_t PERIODIC_REPLY_DATA = 2; + + PlocSupervisorDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + virtual ~PlocSupervisorDummy(); + + protected: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; +}; diff --git a/dummies/ScexDummy.cpp b/dummies/ScexDummy.cpp new file mode 100644 index 00000000..303570ff --- /dev/null +++ b/dummies/ScexDummy.cpp @@ -0,0 +1,40 @@ +#include "ScexDummy.h" + +ScexDummy::ScexDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) + : DeviceHandlerBase(objectId, comif, comCookie) {} + +ScexDummy::~ScexDummy() {} + +void ScexDummy::doStartUp() {} + +void ScexDummy::doShutDown() {} + +ReturnValue_t ScexDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; } + +ReturnValue_t ScexDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t ScexDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + return returnvalue::OK; +} + +ReturnValue_t ScexDummy::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) { + return returnvalue::OK; +} + +ReturnValue_t ScexDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + return returnvalue::OK; +} + +void ScexDummy::fillCommandAndReplyMap() {} + +uint32_t ScexDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } + +ReturnValue_t ScexDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + return returnvalue::OK; +} diff --git a/dummies/ScexDummy.h b/dummies/ScexDummy.h new file mode 100644 index 00000000..98762db3 --- /dev/null +++ b/dummies/ScexDummy.h @@ -0,0 +1,30 @@ +#pragma once + +#include + +class ScexDummy : public DeviceHandlerBase { + public: + static const DeviceCommandId_t SIMPLE_COMMAND = 1; + static const DeviceCommandId_t PERIODIC_REPLY = 2; + + static const uint8_t SIMPLE_COMMAND_DATA = 1; + static const uint8_t PERIODIC_REPLY_DATA = 2; + + ScexDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + virtual ~ScexDummy(); + + protected: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; +}; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index 7c8fab1c..a5b84451 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -5,7 +5,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -14,20 +15,29 @@ #include #include #include +#include +#include #include #include +#include #include #include #include +#include #include +#include #include "TemperatureSensorInserter.h" #include "dummies/Max31865Dummy.h" #include "dummies/Tmp1075Dummy.h" +#include "mission/core/GenericFactory.h" +#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" +#include "mission/system/tree/acsModeTree.h" +#include "mission/system/tree/comModeTree.h" +#include "mission/system/tree/payloadModeTree.h" +#include "mission/system/tree/tcsModeTree.h" -using namespace dummy; - -void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { +void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpioIF) { new ComIFDummy(objects::DUMMY_COM_IF); auto* comCookieDummy = new ComCookieDummy(); new BpxDummy(objects::BPX_BATT_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); @@ -37,17 +47,25 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { if (cfg.addRtdComIFDummy) { new ComIFDummy(objects::SPI_RTD_COM_IF); } - new RwDummy(objects::RW1, objects::DUMMY_COM_IF, comCookieDummy); - new RwDummy(objects::RW2, objects::DUMMY_COM_IF, comCookieDummy); - new RwDummy(objects::RW3, objects::DUMMY_COM_IF, comCookieDummy); - new RwDummy(objects::RW4, objects::DUMMY_COM_IF, comCookieDummy); + std::array rwIds = {objects::RW1, objects::RW2, objects::RW3, objects::RW4}; + std::array rws; + rws[0] = new RwDummy(objects::RW1, objects::DUMMY_COM_IF, comCookieDummy); + rws[1] = new RwDummy(objects::RW2, objects::DUMMY_COM_IF, comCookieDummy); + rws[2] = new RwDummy(objects::RW3, objects::DUMMY_COM_IF, comCookieDummy); + rws[3] = new RwDummy(objects::RW4, objects::DUMMY_COM_IF, comCookieDummy); + ObjectFactory::createRwAssy(pwrSwitcher, pcdu::Switches::PDU2_CH2_RW_5V, rws, rwIds); new SaDeplDummy(objects::SOLAR_ARRAY_DEPL_HANDLER); - new StarTrackerDummy(objects::STAR_TRACKER, objects::DUMMY_COM_IF, comCookieDummy); + auto* strDummy = + new StarTrackerDummy(objects::STAR_TRACKER, objects::DUMMY_COM_IF, comCookieDummy); + strDummy->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); if (cfg.addSyrlinksDummies) { - new SyrlinksDummy(objects::SYRLINKS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + auto* syrlinksDummy = + new SyrlinksDummy(objects::SYRLINKS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + syrlinksDummy->connectModeTreeParent(satsystem::com::SUBSYSTEM); } auto* imtqDummy = new ImtqDummy(objects::IMTQ_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); imtqDummy->enableThermalModule(ThermalStateCfg()); + imtqDummy->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); if (cfg.addPowerDummies) { new AcuDummy(objects::ACU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); new PduDummy(objects::PDU1_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); @@ -56,103 +74,147 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { } if (cfg.addAcsBoardDummies) { - new GyroAdisDummy(objects::GYRO_0_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new GyroL3GD20Dummy(objects::GYRO_1_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new GyroAdisDummy(objects::GYRO_2_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new GyroL3GD20Dummy(objects::GYRO_3_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new MgmLIS3MDLDummy(objects::MGM_0_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new MgmLIS3MDLDummy(objects::MGM_2_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new MgmRm3100Dummy(objects::MGM_1_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new MgmRm3100Dummy(objects::MGM_3_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new GpsDummy(objects::GPS_CONTROLLER, objects::DUMMY_COM_IF, comCookieDummy); + std::array assemblyDhbs; + assemblyDhbs[0] = + new MgmLIS3MDLDummy(objects::MGM_0_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[1] = + new MgmLIS3MDLDummy(objects::MGM_2_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[2] = + new MgmRm3100Dummy(objects::MGM_1_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[3] = + new MgmRm3100Dummy(objects::MGM_3_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[4] = + new GyroAdisDummy(objects::GYRO_0_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[5] = + new GyroL3GD20Dummy(objects::GYRO_1_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[6] = + new GyroAdisDummy(objects::GYRO_2_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[7] = + new GyroL3GD20Dummy(objects::GYRO_3_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + auto* gpsCtrl = new GpsCtrlDummy(objects::GPS_CONTROLLER); + ObjectFactory::createAcsBoardAssy(pwrSwitcher, assemblyDhbs, gpsCtrl, gpioIF); } if (cfg.addSusDummies) { - new SusDummy(objects::SUS_0_N_LOC_XFYFZM_PT_XF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_1_N_LOC_XBYFZM_PT_XB, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_2_N_LOC_XFYBZB_PT_YB, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_3_N_LOC_XFYBZF_PT_YF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_4_N_LOC_XMYFZF_PT_ZF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_5_N_LOC_XFYMZB_PT_ZB, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_6_R_LOC_XFYBZM_PT_XF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_7_R_LOC_XBYBZM_PT_XB, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_8_R_LOC_XBYBZB_PT_YB, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_9_R_LOC_XBYBZB_PT_YF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_10_N_LOC_XMYBZF_PT_ZF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_11_R_LOC_XBYMZB_PT_ZB, objects::DUMMY_COM_IF, comCookieDummy); + std::array suses; + suses[0] = + new SusDummy(objects::SUS_0_N_LOC_XFYFZM_PT_XF, objects::DUMMY_COM_IF, comCookieDummy); + suses[1] = + new SusDummy(objects::SUS_1_N_LOC_XBYFZM_PT_XB, objects::DUMMY_COM_IF, comCookieDummy); + suses[2] = + new SusDummy(objects::SUS_2_N_LOC_XFYBZB_PT_YB, objects::DUMMY_COM_IF, comCookieDummy); + suses[3] = + new SusDummy(objects::SUS_3_N_LOC_XFYBZF_PT_YF, objects::DUMMY_COM_IF, comCookieDummy); + suses[4] = + new SusDummy(objects::SUS_4_N_LOC_XMYFZF_PT_ZF, objects::DUMMY_COM_IF, comCookieDummy); + suses[5] = + new SusDummy(objects::SUS_5_N_LOC_XFYMZB_PT_ZB, objects::DUMMY_COM_IF, comCookieDummy); + suses[6] = + new SusDummy(objects::SUS_6_R_LOC_XFYBZM_PT_XF, objects::DUMMY_COM_IF, comCookieDummy); + suses[7] = + new SusDummy(objects::SUS_7_R_LOC_XBYBZM_PT_XB, objects::DUMMY_COM_IF, comCookieDummy); + suses[8] = + new SusDummy(objects::SUS_8_R_LOC_XBYBZB_PT_YB, objects::DUMMY_COM_IF, comCookieDummy); + suses[9] = + new SusDummy(objects::SUS_9_R_LOC_XBYBZB_PT_YF, objects::DUMMY_COM_IF, comCookieDummy); + suses[10] = + new SusDummy(objects::SUS_10_N_LOC_XMYBZF_PT_ZF, objects::DUMMY_COM_IF, comCookieDummy); + suses[11] = + new SusDummy(objects::SUS_11_R_LOC_XBYMZB_PT_ZB, objects::DUMMY_COM_IF, comCookieDummy); + ObjectFactory::createSusAssy(pwrSwitcher, suses); } if (cfg.addTempSensorDummies) { - std::map tempSensorDummies; - tempSensorDummies.emplace(objects::RTD_0_IC3_PLOC_HEATSPREADER, - new Max31865Dummy(objects::RTD_0_IC3_PLOC_HEATSPREADER, - objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace(objects::RTD_1_IC4_PLOC_MISSIONBOARD, - new Max31865Dummy(objects::RTD_1_IC4_PLOC_MISSIONBOARD, - objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + std::map rtdSensorDummies; + rtdSensorDummies.emplace(objects::RTD_0_IC3_PLOC_HEATSPREADER, + new Max31865Dummy(objects::RTD_0_IC3_PLOC_HEATSPREADER, + objects::DUMMY_COM_IF, comCookieDummy)); + rtdSensorDummies.emplace(objects::RTD_1_IC4_PLOC_MISSIONBOARD, + new Max31865Dummy(objects::RTD_1_IC4_PLOC_MISSIONBOARD, + objects::DUMMY_COM_IF, comCookieDummy)); + rtdSensorDummies.emplace( objects::RTD_2_IC5_4K_CAMERA, new Max31865Dummy(objects::RTD_2_IC5_4K_CAMERA, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace(objects::RTD_3_IC6_DAC_HEATSPREADER, - new Max31865Dummy(objects::RTD_3_IC6_DAC_HEATSPREADER, - objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace(objects::RTD_3_IC6_DAC_HEATSPREADER, + new Max31865Dummy(objects::RTD_3_IC6_DAC_HEATSPREADER, + objects::DUMMY_COM_IF, comCookieDummy)); + rtdSensorDummies.emplace( objects::RTD_4_IC7_STARTRACKER, new Max31865Dummy(objects::RTD_4_IC7_STARTRACKER, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_5_IC8_RW1_MX_MY, new Max31865Dummy(objects::RTD_5_IC8_RW1_MX_MY, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_6_IC9_DRO, new Max31865Dummy(objects::RTD_6_IC9_DRO, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_7_IC10_SCEX, new Max31865Dummy(objects::RTD_7_IC10_SCEX, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_8_IC11_X8, new Max31865Dummy(objects::RTD_8_IC11_X8, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_9_IC12_HPA, new Max31865Dummy(objects::RTD_9_IC12_HPA, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_10_IC13_PL_TX, new Max31865Dummy(objects::RTD_10_IC13_PL_TX, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_11_IC14_MPA, new Max31865Dummy(objects::RTD_11_IC14_MPA, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_12_IC15_ACU, new Max31865Dummy(objects::RTD_12_IC15_ACU, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, - new Max31865Dummy(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, - objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, + new Max31865Dummy(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, + objects::DUMMY_COM_IF, comCookieDummy)); + rtdSensorDummies.emplace( objects::RTD_14_IC17_TCS_BOARD, new Max31865Dummy(objects::RTD_14_IC17_TCS_BOARD, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_15_IC18_IMTQ, new Max31865Dummy(objects::RTD_15_IC18_IMTQ, objects::DUMMY_COM_IF, comCookieDummy)); - std::map tempTmpSensorDummies; - tempTmpSensorDummies.emplace( + std::map tmpSensorDummies; + tmpSensorDummies.emplace( objects::TMP1075_HANDLER_TCS_0, new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_0, objects::DUMMY_COM_IF, comCookieDummy)); - tempTmpSensorDummies.emplace( + tmpSensorDummies.emplace( objects::TMP1075_HANDLER_TCS_1, new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_1, objects::DUMMY_COM_IF, comCookieDummy)); - tempTmpSensorDummies.emplace( + tmpSensorDummies.emplace( objects::TMP1075_HANDLER_PLPCDU_0, new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_0, objects::DUMMY_COM_IF, comCookieDummy)); - tempTmpSensorDummies.emplace( + tmpSensorDummies.emplace( objects::TMP1075_HANDLER_PLPCDU_1, new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_1, objects::DUMMY_COM_IF, comCookieDummy)); - tempTmpSensorDummies.emplace( + tmpSensorDummies.emplace( objects::TMP1075_HANDLER_IF_BOARD, new Tmp1075Dummy(objects::TMP1075_HANDLER_IF_BOARD, objects::DUMMY_COM_IF, comCookieDummy)); - new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, tempSensorDummies, - tempTmpSensorDummies); + new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, rtdSensorDummies, + tmpSensorDummies); + TcsBoardAssembly* tcsBoardAssy = ObjectFactory::createTcsBoardAssy(pwrSwitcher); + for (auto& rtd : rtdSensorDummies) { + rtd.second->connectModeTreeParent(*tcsBoardAssy); + } + for (auto& tmp : tmpSensorDummies) { + tmp.second->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); + } + } + auto* camSwitcher = new CamSwitcher(objects::CAM_SWITCHER, pwrSwitcher, power::NO_SWITCH); + camSwitcher->connectModeTreeParent(satsystem::pl::SUBSYSTEM); + auto* scexDummy = new ScexDummy(objects::SCEX, objects::DUMMY_COM_IF, comCookieDummy); + scexDummy->connectModeTreeParent(satsystem::pl::SUBSYSTEM); + auto* plPcduDummy = + new PlPcduDummy(objects::PLPCDU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + plPcduDummy->connectModeTreeParent(satsystem::pl::SUBSYSTEM); + if (cfg.addPlocDummies) { + auto* plocMpsocDummy = + new PlocMpsocDummy(objects::PLOC_MPSOC_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + plocMpsocDummy->connectModeTreeParent(satsystem::pl::SUBSYSTEM); + auto* plocSupervisorDummy = new PlocSupervisorDummy(objects::PLOC_SUPERVISOR_HANDLER, + objects::DUMMY_COM_IF, comCookieDummy); + plocSupervisorDummy->connectModeTreeParent(satsystem::pl::SUBSYSTEM); } - new CamSwitcher(objects::CAM_SWITCHER, pwrSwitch, power::NO_SWITCH); - new PlPcduDummy(objects::PLPCDU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); } diff --git a/dummies/helpers.h b/dummies/helpers.h index bbaab34d..2181c79c 100644 --- a/dummies/helpers.h +++ b/dummies/helpers.h @@ -2,6 +2,8 @@ #include +class GpioIF; + namespace dummy { struct DummyCfg { @@ -12,8 +14,9 @@ struct DummyCfg { bool addSusDummies = true; bool addTempSensorDummies = true; bool addRtdComIFDummy = true; + bool addPlocDummies = true; }; -void createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch); +void createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch, GpioIF* gpioIF); } // namespace dummy diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 1003ead4..1686eb03 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,7 @@ #include "mission/system/tree/tcsModeTree.h" void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, - PowerSwitchIF* pwrSwitcher, std::string spiDev, + PowerSwitchIF& pwrSwitcher, std::string spiDev, bool swap0And6) { using namespace gpio; GpioCookie* gpioCookieSus = new GpioCookie(); @@ -173,22 +174,8 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo fdir = new SusFdir(objects::SUS_11_R_LOC_XBYMZB_PT_ZB); susHandlers[11]->setCustomFdir(fdir); - std::array susIds = { - objects::SUS_0_N_LOC_XFYFZM_PT_XF, objects::SUS_1_N_LOC_XBYFZM_PT_XB, - objects::SUS_2_N_LOC_XFYBZB_PT_YB, objects::SUS_3_N_LOC_XFYBZF_PT_YF, - objects::SUS_4_N_LOC_XMYFZF_PT_ZF, objects::SUS_5_N_LOC_XFYMZB_PT_ZB, - objects::SUS_6_R_LOC_XFYBZM_PT_XF, objects::SUS_7_R_LOC_XBYBZM_PT_XB, - objects::SUS_8_R_LOC_XBYBZB_PT_YB, objects::SUS_9_R_LOC_XBYBZB_PT_YF, - objects::SUS_10_N_LOC_XMYBZF_PT_ZF, objects::SUS_11_R_LOC_XBYMZB_PT_ZB}; - SusAssHelper susAssHelper = SusAssHelper(susIds); - auto susAss = new SusAssembly(objects::SUS_BOARD_ASS, pwrSwitcher, susAssHelper); for (auto& sus : susHandlers) { if (sus != nullptr) { - ReturnValue_t result = sus->connectModeTreeParent(*susAss); - if (result != returnvalue::OK) { - sif::error << "Connecting SUS " << sus->getObjectId() << " to SUS assembly failed" - << std::endl; - } #if OBSW_TEST_SUS == 1 sus->setStartUpImmediately(); sus->setToGoToNormalMode(true); @@ -198,7 +185,11 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo #endif } } - susAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); + std::array susDhbs; + for (unsigned i = 0; i < susDhbs.size(); i++) { + susDhbs[i] = susHandlers[i]; + } + createSusAssy(pwrSwitcher, susDhbs); #endif /* OBSW_ADD_SUN_SENSORS == 1 */ } @@ -279,32 +270,13 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, {addresses::RTD_IC_18, gpioIds::RTD_IC_18}, }}; // HSPD: Heatspreader - std::array, NUM_RTDS> rtdInfos = {{ - {objects::RTD_0_IC3_PLOC_HEATSPREADER, "RTD_0_PLOC_HSPD"}, - {objects::RTD_1_IC4_PLOC_MISSIONBOARD, "RTD_1_PLOC_MISSIONBRD"}, - {objects::RTD_2_IC5_4K_CAMERA, "RTD_2_4K_CAMERA"}, - {objects::RTD_3_IC6_DAC_HEATSPREADER, "RTD_3_DAC_HSPD"}, - {objects::RTD_4_IC7_STARTRACKER, "RTD_4_STARTRACKER"}, - {objects::RTD_5_IC8_RW1_MX_MY, "RTD_5_RW1_MX_MY"}, - {objects::RTD_6_IC9_DRO, "RTD_6_DRO"}, - {objects::RTD_7_IC10_SCEX, "RTD_7_SCEX"}, - {objects::RTD_8_IC11_X8, "RTD_8_X8"}, - {objects::RTD_9_IC12_HPA, "RTD_9_HPA"}, - {objects::RTD_10_IC13_PL_TX, "RTD_10_PL_TX,"}, - {objects::RTD_11_IC14_MPA, "RTD_11_MPA"}, - {objects::RTD_12_IC15_ACU, "RTD_12_ACU"}, - {objects::RTD_13_IC16_PLPCDU_HEATSPREADER, "RTD_13_PLPCDU_HSPD"}, - {objects::RTD_14_IC17_TCS_BOARD, "RTD_14_TCS_BOARD"}, - {objects::RTD_15_IC18_IMTQ, "RTD_15_IMTQ"}, - }}; + std::array rtdCookies = {}; std::array rtds = {}; RtdFdir* rtdFdir = nullptr; - TcsBoardHelper helper(rtdInfos); - TcsBoardAssembly* tcsBoardAss = new TcsBoardAssembly( - objects::TCS_BOARD_ASS, pwrSwitcher, pcdu::Switches::PDU1_CH0_TCS_BOARD_3V3, helper); - tcsBoardAss->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); + TcsBoardAssembly* tcsBoardAss = ObjectFactory::createTcsBoardAssy(*pwrSwitcher); + // Create special low level reader communication interface new Max31865RtdReader(objects::SPI_RTD_COM_IF, comIF, gpioComIF); for (uint8_t idx = 0; idx < NUM_RTDS; idx++) { @@ -312,16 +284,16 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, MAX31865::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); rtdCookies[idx]->setMutexParams(MutexIF::TimeoutType::WAITING, spi::RTD_CS_TIMEOUT); Max31865ReaderCookie* rtdLowLevelCookie = - new Max31865ReaderCookie(rtdInfos[idx].first, idx, rtdInfos[idx].second, rtdCookies[idx]); + new Max31865ReaderCookie(RTD_INFOS[idx].first, idx, RTD_INFOS[idx].second, rtdCookies[idx]); rtds[idx] = - new Max31865EiveHandler(rtdInfos[idx].first, objects::SPI_RTD_COM_IF, rtdLowLevelCookie); - rtds[idx]->setDeviceInfo(idx, rtdInfos[idx].second); + new Max31865EiveHandler(RTD_INFOS[idx].first, objects::SPI_RTD_COM_IF, rtdLowLevelCookie); + rtds[idx]->setDeviceInfo(idx, RTD_INFOS[idx].second); ReturnValue_t result = rtds[idx]->connectModeTreeParent(*tcsBoardAss); if (result != returnvalue::OK) { sif::error << "Connecting RTD " << static_cast(idx) << " to RTD Assembly failed" << std::endl; } - rtdFdir = new RtdFdir(rtdInfos[idx].first); + rtdFdir = new RtdFdir(RTD_INFOS[idx].first); rtds[idx]->setCustomFdir(rtdFdir); #if OBSW_DEBUG_RTD == 1 rtds[idx]->setDebugMode(true, 5); diff --git a/linux/ObjectFactory.h b/linux/ObjectFactory.h index c7b12f9b..0a7ab516 100644 --- a/linux/ObjectFactory.h +++ b/linux/ObjectFactory.h @@ -20,7 +20,7 @@ class AcsController; namespace ObjectFactory { -void createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF* pwrSwitcher, +void createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF& pwrSwitcher, std::string spiDev, bool swap0And6); void createRtdComponents(std::string spiDev, GpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher, SpiComIF* comIF); diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 8c05ed4f..992c0093 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -35,6 +40,8 @@ #include "eive/definitions.h" #include "fsfw/pus/Service11TelecommandScheduling.h" #include "mission/cfdp/Config.h" +#include "mission/system/objects/RwAssembly.h" +#include "mission/system/tree/acsModeTree.h" #include "mission/system/tree/tcsModeTree.h" #include "objects/systemObjectList.h" #include "tmtc/pusIds.h" @@ -218,3 +225,68 @@ void ObjectFactory::createThermalController(HeaterHandler& heaterHandler) { auto* tcsCtrl = new ThermalController(objects::THERMAL_CONTROLLER, heaterHandler); tcsCtrl->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); } +void ObjectFactory::createRwAssy(PowerSwitchIF& pwrSwitcher, power::Switch_t theSwitch, + std::array rws, + std::array rwIds) { + RwHelper rwHelper(rwIds); + auto* rwAss = new RwAssembly(objects::RW_ASS, &pwrSwitcher, theSwitch, rwHelper); + for (uint8_t idx = 0; idx < rwIds.size(); idx++) { + ReturnValue_t result = rws[idx]->connectModeTreeParent(*rwAss); + if (result != returnvalue::OK) { + sif::error << "Connecting RW " << static_cast(idx) << " to RW assembly failed" + << std::endl; + } + } + rwAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); +} + +void ObjectFactory::createSusAssy(PowerSwitchIF& pwrSwitcher, + std::array suses) { + std::array susIds = { + objects::SUS_0_N_LOC_XFYFZM_PT_XF, objects::SUS_1_N_LOC_XBYFZM_PT_XB, + objects::SUS_2_N_LOC_XFYBZB_PT_YB, objects::SUS_3_N_LOC_XFYBZF_PT_YF, + objects::SUS_4_N_LOC_XMYFZF_PT_ZF, objects::SUS_5_N_LOC_XFYMZB_PT_ZB, + objects::SUS_6_R_LOC_XFYBZM_PT_XF, objects::SUS_7_R_LOC_XBYBZM_PT_XB, + objects::SUS_8_R_LOC_XBYBZB_PT_YB, objects::SUS_9_R_LOC_XBYBZB_PT_YF, + objects::SUS_10_N_LOC_XMYBZF_PT_ZF, objects::SUS_11_R_LOC_XBYMZB_PT_ZB}; + SusAssHelper susAssHelper = SusAssHelper(susIds); + auto susAss = new SusAssembly(objects::SUS_BOARD_ASS, &pwrSwitcher, susAssHelper); + for (auto& sus : suses) { + if (sus != nullptr) { + ReturnValue_t result = sus->connectModeTreeParent(*susAss); + if (result != returnvalue::OK) { + sif::error << "Connecting SUS " << sus->getObjectId() << " to SUS assembly failed" + << std::endl; + } + } + } + susAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); +} + +void ObjectFactory::createAcsBoardAssy(PowerSwitchIF& pwrSwitcher, + std::array assemblyDhbs, + ExtendedControllerBase* gpsCtrl, GpioIF* gpioComIF) { + AcsBoardHelper acsBoardHelper = AcsBoardHelper( + objects::MGM_0_LIS3_HANDLER, objects::MGM_1_RM3100_HANDLER, objects::MGM_2_LIS3_HANDLER, + objects::MGM_3_RM3100_HANDLER, objects::GYRO_0_ADIS_HANDLER, objects::GYRO_1_L3G_HANDLER, + objects::GYRO_2_ADIS_HANDLER, objects::GYRO_3_L3G_HANDLER, objects::GPS_CONTROLLER); + auto acsAss = + new AcsBoardAssembly(objects::ACS_BOARD_ASS, &pwrSwitcher, acsBoardHelper, gpioComIF); + for (auto& assChild : assemblyDhbs) { + ReturnValue_t result = assChild->connectModeTreeParent(*acsAss); + if (result != returnvalue::OK) { + sif::error << "Connecting assembly for ACS board component " << assChild->getObjectId() + << " failed" << std::endl; + } + } + gpsCtrl->connectModeTreeParent(*acsAss); + acsAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); +} + +TcsBoardAssembly* ObjectFactory::createTcsBoardAssy(PowerSwitchIF& pwrSwitcher) { + TcsBoardHelper helper(RTD_INFOS); + TcsBoardAssembly* tcsBoardAss = new TcsBoardAssembly( + objects::TCS_BOARD_ASS, &pwrSwitcher, pcdu::Switches::PDU1_CH0_TCS_BOARD_3V3, helper); + tcsBoardAss->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); + return tcsBoardAss; +} diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index 04802d51..30f2d6bb 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -1,13 +1,38 @@ #ifndef MISSION_CORE_GENERICFACTORY_H_ #define MISSION_CORE_GENERICFACTORY_H_ +#include + +#include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/power/PowerSwitchIF.h" #include "fsfw_hal/common/gpio/GpioIF.h" +#include "mission/devices/devicedefinitions/Max31865Definitions.h" class HeaterHandler; class HealthTableIF; class PusTmFunnel; class CfdpTmFunnel; +class ExtendedControllerBase; +class TcsBoardAssembly; + +const std::array, EiveMax31855::NUM_RTDS> RTD_INFOS = {{ + {objects::RTD_0_IC3_PLOC_HEATSPREADER, "RTD_0_PLOC_HSPD"}, + {objects::RTD_1_IC4_PLOC_MISSIONBOARD, "RTD_1_PLOC_MISSIONBRD"}, + {objects::RTD_2_IC5_4K_CAMERA, "RTD_2_4K_CAMERA"}, + {objects::RTD_3_IC6_DAC_HEATSPREADER, "RTD_3_DAC_HSPD"}, + {objects::RTD_4_IC7_STARTRACKER, "RTD_4_STARTRACKER"}, + {objects::RTD_5_IC8_RW1_MX_MY, "RTD_5_RW1_MX_MY"}, + {objects::RTD_6_IC9_DRO, "RTD_6_DRO"}, + {objects::RTD_7_IC10_SCEX, "RTD_7_SCEX"}, + {objects::RTD_8_IC11_X8, "RTD_8_X8"}, + {objects::RTD_9_IC12_HPA, "RTD_9_HPA"}, + {objects::RTD_10_IC13_PL_TX, "RTD_10_PL_TX,"}, + {objects::RTD_11_IC14_MPA, "RTD_11_MPA"}, + {objects::RTD_12_IC15_ACU, "RTD_12_ACU"}, + {objects::RTD_13_IC16_PLPCDU_HEATSPREADER, "RTD_13_PLPCDU_HSPD"}, + {objects::RTD_14_IC17_TCS_BOARD, "RTD_14_TCS_BOARD"}, + {objects::RTD_15_IC18_IMTQ, "RTD_15_IMTQ"}, +}}; namespace ObjectFactory { @@ -17,6 +42,13 @@ void createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& pwrSwitcher, HeaterHandler*& heaterHandler); void createThermalController(HeaterHandler& heaterHandler); +void createRwAssy(PowerSwitchIF& pwrSwitcher, power::Switch_t theSwitch, + std::array rws, std::array rwIds); +void createSusAssy(PowerSwitchIF& pwrSwitcher, std::array suses); +void createAcsBoardAssy(PowerSwitchIF& pwrSwitcher, std::array assemblyDhbs, + ExtendedControllerBase* gpsCtrl, GpioIF* gpioComIF); +TcsBoardAssembly* createTcsBoardAssy(PowerSwitchIF& pwrSwitcher); + } // namespace ObjectFactory #endif /* MISSION_CORE_GENERICFACTORY_H_ */