eive-obsw/mission/controller/acs/SensorValues.cpp

147 lines
3.2 KiB
C++
Raw Normal View History

2022-09-19 15:37:05 +02:00
/*
* SensorValues.cpp
*
* Created on: 30 Mar 2022
* Author: rooob
*/
2022-09-27 11:06:11 +02:00
#include "SensorValues.h"
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/LocalPoolVector.h>
2022-09-19 15:37:05 +02:00
#include <stddef.h>
2022-09-19 15:37:05 +02:00
#include <cmath>
namespace ACS {
SensorValues::SensorValues() {}
2022-09-19 15:37:05 +02:00
SensorValues::~SensorValues() {}
2022-09-19 15:37:05 +02:00
ReturnValue_t SensorValues::updateMgm() {
2023-02-08 15:30:14 +01:00
std::vector<ReturnValue_t> results;
{
2023-02-08 17:02:59 +01:00
PoolReadGuard pgMgm(&mgm0Lis3Set);
results.push_back(pgMgm.getReadResult());
2023-02-08 15:30:14 +01:00
}
{
PoolReadGuard pgMgm(&mgm1Rm3100Set);
results.push_back(pgMgm.getReadResult());
}
{
PoolReadGuard pgMgm(&mgm2Lis3Set);
results.push_back(pgMgm.getReadResult());
}
{
PoolReadGuard pgMgm(&mgm3Rm3100Set);
results.push_back(pgMgm.getReadResult());
}
{
PoolReadGuard pgMgm(&imtqMgmSet);
results.push_back(pgMgm.getReadResult());
}
for (const auto& result : results) {
if (result != returnvalue::OK) {
return result;
}
}
return returnvalue::OK;
2022-09-19 15:37:05 +02:00
}
ReturnValue_t SensorValues::updateSus() {
2023-02-08 17:02:59 +01:00
std::vector<ReturnValue_t> results;
for (auto& susSet : susSets) {
{
PoolReadGuard pgSus(&susSet);
results.push_back(pgSus.getReadResult());
}
}
for (const auto& result : results) {
if (result != returnvalue::OK) {
return result;
}
}
return returnvalue::OK;
}
2022-09-19 15:37:05 +02:00
ReturnValue_t SensorValues::updateGyr() {
2023-02-08 17:02:59 +01:00
std::vector<ReturnValue_t> results;
{
PoolReadGuard pgGyr(&gyr0AdisSet);
results.push_back(pgGyr.getReadResult());
}
{
PoolReadGuard pgGyr(&gyr1L3gSet);
results.push_back(pgGyr.getReadResult());
}
{
PoolReadGuard pgGyr(&gyr2AdisSet);
results.push_back(pgGyr.getReadResult());
}
{
PoolReadGuard pgGyr(&gyr3L3gSet);
results.push_back(pgGyr.getReadResult());
}
for (const auto& result : results) {
if (result != returnvalue::OK) {
return result;
}
}
return returnvalue::OK;
}
2022-10-12 10:27:01 +02:00
ReturnValue_t SensorValues::updateStr() {
PoolReadGuard pgStr(&strSet);
2023-02-08 15:30:14 +01:00
return pgStr.getReadResult();
2022-10-12 10:27:01 +02:00
}
2022-10-12 15:06:24 +02:00
ReturnValue_t SensorValues::updateGps() {
PoolReadGuard pgGps(&gpsSet);
2023-02-08 15:30:14 +01:00
return pgGps.getReadResult();
2022-10-12 15:06:24 +02:00
}
ReturnValue_t SensorValues::updateRw() {
2023-02-08 17:02:59 +01:00
std::vector<ReturnValue_t> results;
{
PoolReadGuard pgRw(&rw1Set);
results.push_back(pgRw.getReadResult());
}
{
PoolReadGuard pgRw(&rw2Set);
results.push_back(pgRw.getReadResult());
}
{
PoolReadGuard pgRw(&rw3Set);
results.push_back(pgRw.getReadResult());
}
{
PoolReadGuard pgRw(&rw4Set);
results.push_back(pgRw.getReadResult());
}
for (const auto& result : results) {
if (result != returnvalue::OK) {
return result;
}
}
return returnvalue::OK;
2022-10-12 15:06:24 +02:00
}
ReturnValue_t SensorValues::update() {
ReturnValue_t mgmUpdate = updateMgm();
ReturnValue_t susUpdate = updateSus();
ReturnValue_t gyrUpdate = updateGyr();
2022-10-12 10:27:01 +02:00
ReturnValue_t strUpdate = updateStr();
ReturnValue_t gpsUpdate = updateGps();
ReturnValue_t rwUpdate = updateRw();
2022-10-12 15:18:07 +02:00
if ((mgmUpdate && susUpdate && gyrUpdate && strUpdate && gpsUpdate && rwUpdate) ==
returnvalue::FAILED) {
return returnvalue::FAILED;
};
return returnvalue::OK;
}
} // namespace ACS