First Version of ACS Controller #329

Merged
muellerr merged 106 commits from acs-ctrl-v1 into develop 2022-12-02 16:21:58 +01:00
3 changed files with 71 additions and 95 deletions
Showing only changes of commit c430caadd7 - Show all commits

View File

@ -1,87 +1,43 @@
#include "SusDummy.h" #include "SusDummy.h"
#include <fsfw/datapool/PoolReadGuard.h> SusDummy::SusDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie)
#include <objects/systemObjectList.h> : DeviceHandlerBase(objectId, comif, comCookie), susSet(this) {}
#include <cmath> SusDummy::~SusDummy() {}
#include <cstdlib>
SusDummy::SusDummy() : ExtendedControllerBase(objects::SUS_0_N_LOC_XFYFZM_PT_XF), susSet(this) { void SusDummy::doStartUp() {}
ObjectManager::instance()->insert(objects::SUS_6_R_LOC_XFYBZM_PT_XF, this);
ObjectManager::instance()->insert(objects::SUS_1_N_LOC_XBYFZM_PT_XB, this); void SusDummy::doShutDown() {}
ObjectManager::instance()->insert(objects::SUS_7_R_LOC_XBYBZM_PT_XB, this);
ObjectManager::instance()->insert(objects::SUS_2_N_LOC_XFYBZB_PT_YB, this); ReturnValue_t SusDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; }
ObjectManager::instance()->insert(objects::SUS_8_R_LOC_XBYBZB_PT_YB, this);
ObjectManager::instance()->insert(objects::SUS_3_N_LOC_XFYBZF_PT_YF, this); ReturnValue_t SusDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) {
ObjectManager::instance()->insert(objects::SUS_9_R_LOC_XBYBZB_PT_YF, this); return NOTHING_TO_SEND;
ObjectManager::instance()->insert(objects::SUS_4_N_LOC_XMYFZF_PT_ZF, this);
ObjectManager::instance()->insert(objects::SUS_10_N_LOC_XMYBZF_PT_ZF, this);
ObjectManager::instance()->insert(objects::SUS_5_N_LOC_XFYMZB_PT_ZB, this);
ObjectManager::instance()->insert(objects::SUS_11_R_LOC_XBYMZB_PT_ZB, this);
} }
ReturnValue_t SusDummy::initialize() { ReturnValue_t SusDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
static bool done = false; const uint8_t *commandData, size_t commandDataLen) {
if (not done) {
done = true;
ReturnValue_t result = ExtendedControllerBase::initialize();
if (result != returnvalue::OK) {
return result;
}
}
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t SusDummy::handleCommandMessage(CommandMessage* message) { ReturnValue_t SusDummy::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId,
return returnvalue::FAILED; size_t *foundLen) {
return returnvalue::OK;
} }
void SusDummy::performControlOperation() { ReturnValue_t SusDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) {
// value = sin(iteration / 80. * M_PI + 10) * 10 - 10; return returnvalue::OK;
susSet.read();
// susSet.temperatureCelcius = value;
// if ((iteration % 100) < 20) {
// susSet.setValidity(false, true);
// } else {
// susSet.setValidity(true, true);
// }
susSet.channels[0] = 3913;
susSet.channels[1] = 3912;
susSet.channels[2] = 3799;
susSet.channels[3] = 3797;
susSet.channels[4] = 4056;
susSet.setValidity(true, true);
susSet.commit();
iteration++;
} }
ReturnValue_t SusDummy::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, void SusDummy::fillCommandAndReplyMap() {}
LocalDataPoolManager& poolManager) {
uint32_t SusDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
ReturnValue_t SusDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(SUS::SusPoolIds::TEMPERATURE_C, new PoolEntry<float>({0}, 1, true)); localDataPoolMap.emplace(SUS::SusPoolIds::TEMPERATURE_C, new PoolEntry<float>({0}, 1, true));
localDataPoolMap.emplace(SUS::SusPoolIds::CHANNEL_VEC, localDataPoolMap.emplace(SUS::SusPoolIds::CHANNEL_VEC,
new PoolEntry<uint16_t>({0, 0, 0, 0, 0, 0}, true)); new PoolEntry<uint16_t>({0, 0, 0, 0, 0, 0},true));
return returnvalue::OK; return returnvalue::OK;
} }
LocalPoolDataSetBase* SusDummy::getDataSetHandle(sid_t sid) {
switch (sid.ownerSetId) {
case SUS::SUS_DATA_SET_ID:
return &susSet;
default:
return nullptr;
}
}
ReturnValue_t SusDummy::checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t* msToReachTheMode) {
if (submode != SUBMODE_NONE) {
return INVALID_SUBMODE;
}
if ((mode != MODE_OFF) && (mode != MODE_ON) && (mode != MODE_NORMAL)) {
return INVALID_MODE;
}
return returnvalue::OK;
}

View File

@ -1,27 +1,36 @@
#pragma once #ifndef DUMMIES_SUSDUMMY_H_
#define DUMMIES_SUSDUMMY_H_
#include <fsfw/controller/ExtendedControllerBase.h> #include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <mission/devices/devicedefinitions/SusDefinitions.h>
class SusDummy : public ExtendedControllerBase { #include "mission/devices/devicedefinitions/SusDefinitions.h"
class SusDummy : public DeviceHandlerBase {
public: public:
SusDummy(); static const DeviceCommandId_t SIMPLE_COMMAND = 1;
static const DeviceCommandId_t PERIODIC_REPLY = 2;
ReturnValue_t initialize() override; static const uint8_t SIMPLE_COMMAND_DATA = 1;
static const uint8_t PERIODIC_REPLY_DATA = 2;
SusDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie);
virtual ~SusDummy();
protected: protected:
virtual ReturnValue_t handleCommandMessage(CommandMessage* message) override;
virtual void performControlOperation() override;
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
// Mode abstract functions
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t* msToReachTheMode) override;
private:
int iteration = 0;
float value = 0;
SUS::SusDataset susSet; SUS::SusDataset susSet;
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_SUSDUMMY_H_ */

View File

@ -1,3 +1,5 @@
#include "helpers.h"
#include <dummies/AcuDummy.h> #include <dummies/AcuDummy.h>
#include <dummies/BpxDummy.h> #include <dummies/BpxDummy.h>
#include <dummies/ComCookieDummy.h> #include <dummies/ComCookieDummy.h>
@ -19,8 +21,6 @@
#include <dummies/SyrlinksDummy.h> #include <dummies/SyrlinksDummy.h>
#include <dummies/TemperatureSensorsDummy.h> #include <dummies/TemperatureSensorsDummy.h>
#include "helpers.h"
using namespace dummy; using namespace dummy;
void dummy::createDummies(DummyCfg cfg) { void dummy::createDummies(DummyCfg cfg) {
@ -63,7 +63,18 @@ void dummy::createDummies(DummyCfg cfg) {
} }
if (cfg.addSusDummies) { if (cfg.addSusDummies) {
new SusDummy(); 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);
} }
if (cfg.addTempSensorDummies) { if (cfg.addTempSensorDummies) {