apply auto-formatter

This commit is contained in:
2022-05-05 20:55:28 +02:00
parent c2a9db8ac8
commit c88a534e1c
42 changed files with 1667 additions and 1859 deletions

View File

@ -1,217 +1,220 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include "FsfwTestController.h"
#include <fsfw/datapool/PoolReadGuard.h>
FsfwTestController::FsfwTestController(object_id_t objectId, object_id_t device0,
object_id_t device1, uint8_t verboseLevel):
TestController(objectId, objects::NO_OBJECT, 5), device0Id(device0),
device1Id(device1), deviceDataset0(device0), deviceDataset1(device1) {
object_id_t device1, uint8_t verboseLevel)
: TestController(objectId, objects::NO_OBJECT, 5),
device0Id(device0),
device1Id(device1),
deviceDataset0(device0),
deviceDataset1(device1) {}
FsfwTestController::~FsfwTestController() {}
ReturnValue_t FsfwTestController::handleCommandMessage(CommandMessage* message) {
return HasReturnvaluesIF::RETURN_OK;
}
FsfwTestController::~FsfwTestController() {
}
ReturnValue_t FsfwTestController::handleCommandMessage(CommandMessage *message) {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t FsfwTestController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
return HasReturnvaluesIF::RETURN_OK;
ReturnValue_t FsfwTestController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
return HasReturnvaluesIF::RETURN_OK;
}
void FsfwTestController::performControlOperation() {
// We will trace variables if we received an update notification or snapshots
if (verboseLevel >= 1) {
if(not traceVariable) {
return;
}
switch(currentTraceType) {
case(NONE): {
break;
}
case(TRACE_DEV_0_UINT8): {
if(traceCounter == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Tracing finished" << std::endl;
#else
sif::printInfo("Tracing finished\n");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
traceVariable = false;
traceCounter = traceCycles;
currentTraceType = TraceTypes::NONE;
break;
}
PoolReadGuard readHelper(&deviceDataset0.testUint8Var);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Tracing device 0 variable 0 (UINT8), current value: " <<
static_cast<int>(deviceDataset0.testUint8Var.value) << std::endl;
#else
sif::printInfo("Tracing device 0 variable 0 (UINT8), current value: %d\n",
deviceDataset0.testUint8Var.value);
#endif
traceCounter--;
break;
}
case(TRACE_DEV_0_VECTOR): {
break;
}
}
// We will trace variables if we received an update notification or snapshots
if (verboseLevel >= 1) {
if (not traceVariable) {
return;
}
switch (currentTraceType) {
case (NONE): {
break;
}
case (TRACE_DEV_0_UINT8): {
if (traceCounter == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Tracing finished" << std::endl;
#else
sif::printInfo("Tracing finished\n");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
traceVariable = false;
traceCounter = traceCycles;
currentTraceType = TraceTypes::NONE;
break;
}
PoolReadGuard readHelper(&deviceDataset0.testUint8Var);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Tracing device 0 variable 0 (UINT8), current value: "
<< static_cast<int>(deviceDataset0.testUint8Var.value) << std::endl;
#else
sif::printInfo("Tracing device 0 variable 0 (UINT8), current value: %d\n",
deviceDataset0.testUint8Var.value);
#endif
traceCounter--;
break;
}
case (TRACE_DEV_0_VECTOR): {
break;
}
}
}
}
ReturnValue_t FsfwTestController::initializeAfterTaskCreation() {
namespace td = testdevice;
ReturnValue_t result = TestController::initializeAfterTaskCreation();
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
HasLocalDataPoolIF* device0 = ObjectManager::instance()->get<HasLocalDataPoolIF>(
deviceDataset0.getCreatorObjectId());
if(device0 == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 0 "
"handle invalid!" << std::endl;
#else
sif::printWarning("TestController::initializeAfterTaskCreation: Test device handler 0 "
"handle invalid!");
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
ProvidesDataPoolSubscriptionIF* subscriptionIF = device0->getSubscriptionInterface();
if(subscriptionIF != nullptr) {
/* For DEVICE_0, we only subscribe for notifications */
subscriptionIF->subscribeForSetUpdateMessage(td::TEST_SET_ID, getObjectId(),
getCommandQueue(), false);
subscriptionIF->subscribeForVariableUpdateMessage(td::PoolIds::TEST_UINT8_ID,
getObjectId(), getCommandQueue(), false);
}
HasLocalDataPoolIF* device1 = ObjectManager::instance()->get<HasLocalDataPoolIF>(
deviceDataset0.getCreatorObjectId());
if(device1 == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 1 "
"handle invalid!" << std::endl;
#else
sif::printWarning("TestController::initializeAfterTaskCreation: Test device handler 1 "
"handle invalid!");
#endif
}
subscriptionIF = device1->getSubscriptionInterface();
if(subscriptionIF != nullptr) {
/* For DEVICE_1, we will subscribe for snapshots */
subscriptionIF->subscribeForSetUpdateMessage(td::TEST_SET_ID, getObjectId(),
getCommandQueue(), true);
subscriptionIF->subscribeForVariableUpdateMessage(td::PoolIds::TEST_UINT8_ID,
getObjectId(), getCommandQueue(), true);
}
namespace td = testdevice;
ReturnValue_t result = TestController::initializeAfterTaskCreation();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
HasLocalDataPoolIF* device0 =
ObjectManager::instance()->get<HasLocalDataPoolIF>(deviceDataset0.getCreatorObjectId());
if (device0 == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 0 "
"handle invalid!"
<< std::endl;
#else
sif::printWarning(
"TestController::initializeAfterTaskCreation: Test device handler 0 "
"handle invalid!");
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
ProvidesDataPoolSubscriptionIF* subscriptionIF = device0->getSubscriptionInterface();
if (subscriptionIF != nullptr) {
/* For DEVICE_0, we only subscribe for notifications */
subscriptionIF->subscribeForSetUpdateMessage(td::TEST_SET_ID, getObjectId(), getCommandQueue(),
false);
subscriptionIF->subscribeForVariableUpdateMessage(td::PoolIds::TEST_UINT8_ID, getObjectId(),
getCommandQueue(), false);
}
HasLocalDataPoolIF* device1 =
ObjectManager::instance()->get<HasLocalDataPoolIF>(deviceDataset0.getCreatorObjectId());
if (device1 == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 1 "
"handle invalid!"
<< std::endl;
#else
sif::printWarning(
"TestController::initializeAfterTaskCreation: Test device handler 1 "
"handle invalid!");
#endif
}
subscriptionIF = device1->getSubscriptionInterface();
if (subscriptionIF != nullptr) {
/* For DEVICE_1, we will subscribe for snapshots */
subscriptionIF->subscribeForSetUpdateMessage(td::TEST_SET_ID, getObjectId(), getCommandQueue(),
true);
subscriptionIF->subscribeForVariableUpdateMessage(td::PoolIds::TEST_UINT8_ID, getObjectId(),
getCommandQueue(), true);
}
return result;
}
LocalPoolDataSetBase* FsfwTestController::getDataSetHandle(sid_t sid) {
return nullptr;
}
LocalPoolDataSetBase* FsfwTestController::getDataSetHandle(sid_t sid) { return nullptr; }
ReturnValue_t FsfwTestController::checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) {
return HasReturnvaluesIF::RETURN_OK;
uint32_t* msToReachTheMode) {
return HasReturnvaluesIF::RETURN_OK;
}
void FsfwTestController::handleChangedDataset(sid_t sid, store_address_t storeId,
bool* clearMessage) {
using namespace std;
bool* clearMessage) {
using namespace std;
if (verboseLevel >= 1) {
char const* printout = nullptr;
if(storeId == storeId::INVALID_STORE_ADDRESS) {
printout = "Notification";
}
else {
printout = "Snapshot";
}
if (verboseLevel >= 1) {
char const* printout = nullptr;
if (storeId == storeId::INVALID_STORE_ADDRESS) {
printout = "Notification";
} else {
printout = "Snapshot";
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "FsfwTestController::handleChangedDataset: " << printout << " update"
"from object ID " << setw(8) << setfill('0') << hex << sid.objectId <<
" and set ID " << sid.ownerSetId << dec << setfill(' ') << endl;
sif::info << "FsfwTestController::handleChangedDataset: " << printout
<< " update"
"from object ID "
<< setw(8) << setfill('0') << hex << sid.objectId << " and set ID " << sid.ownerSetId
<< dec << setfill(' ') << endl;
#else
sif::printInfo("FsfwTestController::handleChangedPoolVariable: %s update from"
"object ID 0x%08x and set ID %lu\n", printout, sid.objectId, sid.ownerSetId);
sif::printInfo(
"FsfwTestController::handleChangedPoolVariable: %s update from"
"object ID 0x%08x and set ID %lu\n",
printout, sid.objectId, sid.ownerSetId);
#endif
if (storeId == storeId::INVALID_STORE_ADDRESS) {
if(sid.objectId == device0Id) {
PoolReadGuard readHelper(&deviceDataset0.testFloat3Vec);
float floatVec[3];
floatVec[0] = deviceDataset0.testFloat3Vec.value[0];
floatVec[1] = deviceDataset0.testFloat3Vec.value[1];
floatVec[2] = deviceDataset0.testFloat3Vec.value[2];
if (storeId == storeId::INVALID_STORE_ADDRESS) {
if (sid.objectId == device0Id) {
PoolReadGuard readHelper(&deviceDataset0.testFloat3Vec);
float floatVec[3];
floatVec[0] = deviceDataset0.testFloat3Vec.value[0];
floatVec[1] = deviceDataset0.testFloat3Vec.value[1];
floatVec[2] = deviceDataset0.testFloat3Vec.value[2];
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Current float vector (3) values: [" << floatVec[0] << ", " <<
floatVec[1] << ", " << floatVec[2] << "]" << std::endl;
sif::info << "Current float vector (3) values: [" << floatVec[0] << ", " << floatVec[1]
<< ", " << floatVec[2] << "]" << std::endl;
#else
sif::printInfo("Current float vector (3) values: [%f, %f, %f]\n",
floatVec[0], floatVec[1], floatVec[2]);
sif::printInfo("Current float vector (3) values: [%f, %f, %f]\n", floatVec[0], floatVec[1],
floatVec[2]);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
}
}
}
}
}
/* We will trace the variables for snapshots and update notifications */
if(not traceVariable) {
traceVariable = true;
traceCounter = traceCycles;
currentTraceType = TraceTypes::TRACE_DEV_0_VECTOR;
}
/* We will trace the variables for snapshots and update notifications */
if (not traceVariable) {
traceVariable = true;
traceCounter = traceCycles;
currentTraceType = TraceTypes::TRACE_DEV_0_VECTOR;
}
}
void FsfwTestController::handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId,
bool* clearMessage) {
bool* clearMessage) {
using namespace std;
using namespace std;
if (verboseLevel >= 1) {
char const* printout = nullptr;
if (storeId == storeId::INVALID_STORE_ADDRESS) {
printout = "Notification";
}
else {
printout = "Snapshot";
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TestController::handleChangedPoolVariable: " << printout << " update from object "
"ID 0x" << setw(8) << setfill('0') << hex << globPoolId.objectId <<
" and local pool ID " << globPoolId.localPoolId << dec << setfill(' ') << endl;
#else
sif::printInfo("TestController::handleChangedPoolVariable: %s update from object ID 0x%08x and "
"local pool ID %lu\n", printout, globPoolId.objectId, globPoolId.localPoolId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
if (storeId == storeId::INVALID_STORE_ADDRESS) {
if(globPoolId.objectId == device0Id) {
PoolReadGuard readHelper(&deviceDataset0.testUint8Var);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Current test variable 0 (UINT8) value: " << static_cast<int>(
deviceDataset0.testUint8Var.value) << std::endl;
#else
sif::printInfo("Current test variable 0 (UINT8) value %d\n",
deviceDataset0.testUint8Var.value);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
}
}
if (verboseLevel >= 1) {
char const* printout = nullptr;
if (storeId == storeId::INVALID_STORE_ADDRESS) {
printout = "Notification";
} else {
printout = "Snapshot";
}
/* We will trace the variables for snapshots and update notifications */
if(not traceVariable) {
traceVariable = true;
traceCounter = traceCycles;
currentTraceType = TraceTypes::TRACE_DEV_0_UINT8;
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TestController::handleChangedPoolVariable: " << printout
<< " update from object "
"ID 0x"
<< setw(8) << setfill('0') << hex << globPoolId.objectId << " and local pool ID "
<< globPoolId.localPoolId << dec << setfill(' ') << endl;
#else
sif::printInfo(
"TestController::handleChangedPoolVariable: %s update from object ID 0x%08x and "
"local pool ID %lu\n",
printout, globPoolId.objectId, globPoolId.localPoolId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
if (storeId == storeId::INVALID_STORE_ADDRESS) {
if (globPoolId.objectId == device0Id) {
PoolReadGuard readHelper(&deviceDataset0.testUint8Var);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Current test variable 0 (UINT8) value: "
<< static_cast<int>(deviceDataset0.testUint8Var.value) << std::endl;
#else
sif::printInfo("Current test variable 0 (UINT8) value %d\n",
deviceDataset0.testUint8Var.value);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
}
}
}
/* We will trace the variables for snapshots and update notifications */
if (not traceVariable) {
traceVariable = true;
traceCounter = traceCycles;
currentTraceType = TraceTypes::TRACE_DEV_0_UINT8;
}
}

View File

@ -4,50 +4,41 @@
#include "fsfw/controller/ExtendedControllerBase.h"
#include "fsfw_tests/integration/controller/TestController.h"
class FsfwTestController: public TestController {
public:
FsfwTestController(object_id_t objectId, object_id_t device0, object_id_t device1,
uint8_t verboseLevel = 0);
virtual~ FsfwTestController();
ReturnValue_t handleCommandMessage(CommandMessage *message) override;
class FsfwTestController : public TestController {
public:
FsfwTestController(object_id_t objectId, object_id_t device0, object_id_t device1,
uint8_t verboseLevel = 0);
virtual ~FsfwTestController();
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
/**
* Periodic helper from ControllerBase, implemented by child class.
*/
void performControlOperation() override;
/**
* Periodic helper from ControllerBase, implemented by child class.
*/
void performControlOperation() override;
private:
private:
object_id_t device0Id;
object_id_t device1Id;
testdevice::TestDataSet deviceDataset0;
testdevice::TestDataSet deviceDataset1;
object_id_t device0Id;
object_id_t device1Id;
testdevice::TestDataSet deviceDataset0;
testdevice::TestDataSet deviceDataset1;
uint8_t verboseLevel = 0;
bool traceVariable = false;
uint8_t traceCycles = 5;
uint8_t traceCounter = traceCycles;
uint8_t verboseLevel = 0;
bool traceVariable = false;
uint8_t traceCycles = 5;
uint8_t traceCounter = traceCycles;
enum TraceTypes {
NONE,
TRACE_DEV_0_UINT8,
TRACE_DEV_0_VECTOR
};
TraceTypes currentTraceType = TraceTypes::NONE;
ReturnValue_t initializeAfterTaskCreation() override;
void handleChangedDataset(sid_t sid, store_address_t storeId,
bool* clearMessage) override;
void handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId,
bool* clearMessage) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) override ;
enum TraceTypes { NONE, TRACE_DEV_0_UINT8, TRACE_DEV_0_VECTOR };
TraceTypes currentTraceType = TraceTypes::NONE;
ReturnValue_t initializeAfterTaskCreation() override;
void handleChangedDataset(sid_t sid, store_address_t storeId, bool* clearMessage) override;
void handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId,
bool* clearMessage) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t* msToReachTheMode) override;
};
#endif /* EXAMPLE_COMMON_EXAMPLE_CONTROLLER_FSFWTESTCONTROLLER_H_ */

View File

@ -1,22 +1,10 @@
#include "GenericFactory.h"
#include "OBSWConfig.h"
#include "fsfw/FSFW.h"
#include "tmtc/apid.h"
#include "tmtc/pusIds.h"
#include "objects/systemObjectList.h"
#include "example/utility/TmFunnel.h"
#include "example/test/FsfwExampleTask.h"
#include "example/test/FsfwReaderTask.h"
#include "fsfw_tests/internal/InternalUnitTester.h"
#include "fsfw_tests/integration/assemblies/TestAssembly.h"
#include "fsfw_tests/integration/devices/TestCookie.h"
#include "fsfw_tests/integration/devices/TestDeviceHandler.h"
#include "fsfw_tests/integration/devices/TestEchoComIF.h"
#include "fsfw_tests/integration/controller/TestController.h"
#include "example/utility/TmFunnel.h"
#include "fsfw/FSFW.h"
#include "fsfw/devicehandlers/CookieIF.h"
#include "fsfw/events/EventManager.h"
#include "fsfw/health/HealthTable.h"
@ -34,126 +22,125 @@
#include "fsfw/tcdistribution/PUSDistributor.h"
#include "fsfw/timemanager/TimeStamper.h"
#include "fsfw/tmtcpacket/pus/tm.h"
#include "fsfw_tests/integration/assemblies/TestAssembly.h"
#include "fsfw_tests/integration/controller/TestController.h"
#include "fsfw_tests/integration/devices/TestCookie.h"
#include "fsfw_tests/integration/devices/TestDeviceHandler.h"
#include "fsfw_tests/integration/devices/TestEchoComIF.h"
#include "fsfw_tests/internal/InternalUnitTester.h"
#include "objects/systemObjectList.h"
#include "tmtc/apid.h"
#include "tmtc/pusIds.h"
void ObjectFactory::produceGenericObjects() {
#if OBSW_ADD_CORE_COMPONENTS == 1
/* Framework objects */
new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE);
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
new TimeStamper(objects::TIME_STAMPER);
new CCSDSDistributor(apid::APID, objects::CCSDS_DISTRIBUTOR);
new PUSDistributor(apid::APID, objects::PUS_DISTRIBUTOR,
objects::CCSDS_DISTRIBUTOR);
new TmFunnel(objects::TM_FUNNEL);
/* Framework objects */
new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE);
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
new TimeStamper(objects::TIME_STAMPER);
new CCSDSDistributor(apid::APID, objects::CCSDS_DISTRIBUTOR);
new PUSDistributor(apid::APID, objects::PUS_DISTRIBUTOR, objects::CCSDS_DISTRIBUTOR);
new TmFunnel(objects::TM_FUNNEL);
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
/* PUS stack */
/* PUS stack */
#if OBSW_ADD_PUS_STACK == 1
new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION,
apid::APID, pus::PUS_SERVICE_1, objects::TM_FUNNEL, 5);
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS,
apid::APID, pus::PUS_SERVICE_2, 3, 10);
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::APID, pus::PUS_SERVICE_3);
new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING,
apid::APID, pus::PUS_SERVICE_5, 50);
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT,
apid::APID, pus::PUS_SERVICE_8, 3, 10);
new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::APID,
pus::PUS_SERVICE_9);
new Service17Test(objects::PUS_SERVICE_17_TEST, apid::APID,
pus::PUS_SERVICE_17);
new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::APID,
pus::PUS_SERVICE_20);
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT,
apid::APID, pus::PUS_SERVICE_200);
new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::APID,
pus::PUS_SERVICE_1, objects::TM_FUNNEL, 5);
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, apid::APID, pus::PUS_SERVICE_2, 3,
10);
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::APID, pus::PUS_SERVICE_3);
new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::APID, pus::PUS_SERVICE_5,
50);
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::APID,
pus::PUS_SERVICE_8, 3, 10);
new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::APID, pus::PUS_SERVICE_9);
new Service17Test(objects::PUS_SERVICE_17_TEST, apid::APID, pus::PUS_SERVICE_17);
new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::APID,
pus::PUS_SERVICE_20);
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::APID,
pus::PUS_SERVICE_200);
#endif /* OBSW_ADD_PUS_STACK == 1 */
#if OBSW_ADD_TASK_EXAMPLE == 1
/* Demo objects */
new FsfwExampleTask(objects::TEST_DUMMY_1);
new FsfwExampleTask(objects::TEST_DUMMY_2);
new FsfwExampleTask(objects::TEST_DUMMY_3);
/* Demo objects */
new FsfwExampleTask(objects::TEST_DUMMY_1);
new FsfwExampleTask(objects::TEST_DUMMY_2);
new FsfwExampleTask(objects::TEST_DUMMY_3);
bool enablePrintout = false;
bool enablePrintout = false;
#if OBSW_TASK_EXAMPLE_PRINTOUT == 1
enablePrintout = true;
enablePrintout = true;
#endif
new FsfwReaderTask(objects::TEST_DUMMY_4, enablePrintout);
new FsfwReaderTask(objects::TEST_DUMMY_4, enablePrintout);
#endif /* OBSW_ADD_TASK_EXAMPLE == 1 */
#if OBSW_ADD_DEVICE_HANDLER_DEMO == 1
#if OBSW_DEVICE_HANDLER_PRINTOUT == 1
bool enableInfoPrintout = true;
bool enableInfoPrintout = true;
#else
bool enableInfoPrintout = false;
bool enableInfoPrintout = false;
#endif /* OBSW_DEVICE_HANDLER_PRINTOUT == 1 */
/* Demo device handler object */
size_t expectedMaxReplyLen = 64;
CookieIF* testCookie = new TestCookie(
static_cast<address_t>(testdevice::DeviceIndex::DEVICE_0), expectedMaxReplyLen);
new TestEchoComIF(objects::TEST_ECHO_COM_IF);
new TestDevice(objects::TEST_DEVICE_HANDLER_0, objects::TEST_ECHO_COM_IF, testCookie,
testdevice::DeviceIndex::DEVICE_0, enableInfoPrintout);
testCookie = new TestCookie(static_cast<address_t>(testdevice::DeviceIndex::DEVICE_1),
expectedMaxReplyLen);
new TestDevice(objects::TEST_DEVICE_HANDLER_1, objects::TEST_ECHO_COM_IF, testCookie,
testdevice::DeviceIndex::DEVICE_1, enableInfoPrintout);
/* Demo device handler object */
size_t expectedMaxReplyLen = 64;
CookieIF* testCookie = new TestCookie(static_cast<address_t>(testdevice::DeviceIndex::DEVICE_0),
expectedMaxReplyLen);
new TestEchoComIF(objects::TEST_ECHO_COM_IF);
new TestDevice(objects::TEST_DEVICE_HANDLER_0, objects::TEST_ECHO_COM_IF, testCookie,
testdevice::DeviceIndex::DEVICE_0, enableInfoPrintout);
testCookie = new TestCookie(static_cast<address_t>(testdevice::DeviceIndex::DEVICE_1),
expectedMaxReplyLen);
new TestDevice(objects::TEST_DEVICE_HANDLER_1, objects::TEST_ECHO_COM_IF, testCookie,
testdevice::DeviceIndex::DEVICE_1, enableInfoPrintout);
new TestAssembly(objects::TEST_ASSEMBLY, objects::NO_OBJECT, objects::TEST_DEVICE_HANDLER_0,
objects::TEST_DEVICE_HANDLER_1);
new TestAssembly(objects::TEST_ASSEMBLY, objects::NO_OBJECT, objects::TEST_DEVICE_HANDLER_0,
objects::TEST_DEVICE_HANDLER_1);
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */
/* Demo controller object */
/* Demo controller object */
#if OBSW_ADD_CONTROLLER_DEMO == 1
#if OBSW_CONTROLLER_PRINTOUT == 1
#endif
new TestController(objects::TEST_CONTROLLER, objects::NO_OBJECT);
new TestController(objects::TEST_CONTROLLER, objects::NO_OBJECT);
#endif /* OBSW_ADD_CONTROLLER_DEMO == 1 */
#if OBSW_PERFORM_INTERNAL_UNITTEST == 1
InternalUnitTester::TestConfig testCfg;
testCfg.testArrayPrinter = false;
InternalUnitTester::TestConfig testCfg;
testCfg.testArrayPrinter = false;
#if defined FSFW_OSAL_HOST
// Not implemented yet for hosted OSAL (requires C++20)
testCfg.testSemaphores = false;
// Not implemented yet for hosted OSAL (requires C++20)
testCfg.testSemaphores = false;
#endif
InternalUnitTester unittester;
unittester.performTests(testCfg);
InternalUnitTester unittester;
unittester.performTests(testCfg);
#endif /* OBSW_PERFORM_INTERNAL_UNITTEST == 1 */
}
void Factory::setStaticFrameworkObjectIds() {
MonitoringReportContent<float>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<double>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<uint32_t>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<int32_t>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<int16_t>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<uint16_t>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<float>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<double>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<uint32_t>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<int32_t>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<int16_t>::timeStamperId = objects::TIME_STAMPER;
MonitoringReportContent<uint16_t>::timeStamperId = objects::TIME_STAMPER;
TmFunnel::downlinkDestination = objects::DOWNLINK_DESTINATION;
// No storage object for now.
TmFunnel::storageDestination = objects::NO_OBJECT;
TmFunnel::downlinkDestination = objects::DOWNLINK_DESTINATION;
// No storage object for now.
TmFunnel::storageDestination = objects::NO_OBJECT;
PusServiceBase::packetSource = objects::PUS_DISTRIBUTOR;
PusServiceBase::packetDestination = objects::TM_FUNNEL;
PusServiceBase::packetSource = objects::PUS_DISTRIBUTOR;
PusServiceBase::packetDestination = objects::TM_FUNNEL;
CommandingServiceBase::defaultPacketSource = objects::PUS_DISTRIBUTOR;
CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL;
CommandingServiceBase::defaultPacketSource = objects::PUS_DISTRIBUTOR;
CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL;
VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION;
TmPacketBase::timeStamperId = objects::TIME_STAMPER;
VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION;
TmPacketBase::timeStamperId = objects::TIME_STAMPER;
}

View File

@ -11,7 +11,6 @@ namespace ObjectFactory {
*/
void produceGenericObjects();
}
} // namespace ObjectFactory
#endif /* MISSION_CORE_GENERICFACTORY_H_ */

View File

@ -3,10 +3,8 @@
//#include "fsfw_tests/integration/TestDeviceHandler.h"
//
//class FsfwTestDeviceHandler: public TestDeviceHandler {
// class FsfwTestDeviceHandler: public TestDeviceHandler {
//
//};
#endif /* EXAMPLE_COMMON_DEVICES_TESTDEVICEHANDLER_H_ */

View File

@ -1,264 +1,238 @@
#include "FsfwExampleTask.h"
#include <fsfw/ipc/CommandMessage.h>
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tasks/TaskFactory.h>
#include "OBSWConfig.h"
#include "commonSystemObjects.h"
#include "objects/systemObjectList.h"
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/tasks/TaskFactory.h>
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/ipc/CommandMessage.h>
FsfwExampleTask::FsfwExampleTask(object_id_t objectId): SystemObject(objectId),
poolManager(this, nullptr), demoSet(this),
monitor(objectId, MONITOR_ID, gp_id_t(objectId, FsfwDemoSet::VARIABLE_LIMIT), 30, 10)
{
commandQueue = QueueFactory::instance()->createMessageQueue(10,
CommandMessage::MAX_MESSAGE_SIZE);
FsfwExampleTask::FsfwExampleTask(object_id_t objectId)
: SystemObject(objectId),
poolManager(this, nullptr),
demoSet(this),
monitor(objectId, MONITOR_ID, gp_id_t(objectId, FsfwDemoSet::VARIABLE_LIMIT), 30, 10) {
commandQueue = QueueFactory::instance()->createMessageQueue(10, CommandMessage::MAX_MESSAGE_SIZE);
}
FsfwExampleTask::~FsfwExampleTask() {
}
FsfwExampleTask::~FsfwExampleTask() {}
ReturnValue_t FsfwExampleTask::performOperation(uint8_t operationCode) {
if(operationCode == OpCodes::DELAY_SHORT){
TaskFactory::delayTask(5);
if (operationCode == OpCodes::DELAY_SHORT) {
TaskFactory::delayTask(5);
}
// TODO: Move this to new test controller?
ReturnValue_t result = performMonitoringDemo();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (operationCode == OpCodes::SEND_RAND_NUM) {
result = performSendOperation();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
}
// TODO: Move this to new test controller?
ReturnValue_t result = performMonitoringDemo();
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (operationCode == OpCodes::RECEIVE_RAND_NUM) {
result = performReceiveOperation();
}
if (operationCode == OpCodes::SEND_RAND_NUM) {
result = performSendOperation();
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
}
if (operationCode == OpCodes::RECEIVE_RAND_NUM) {
result = performReceiveOperation();
}
return 0;
return 0;
}
object_id_t FsfwExampleTask::getNextRecipient() {
switch(this->getObjectId()) {
case(objects::TEST_DUMMY_1): {
return objects::TEST_DUMMY_2;
switch (this->getObjectId()) {
case (objects::TEST_DUMMY_1): {
return objects::TEST_DUMMY_2;
}
case(objects::TEST_DUMMY_2): {
return objects::TEST_DUMMY_3;
case (objects::TEST_DUMMY_2): {
return objects::TEST_DUMMY_3;
}
case(objects::TEST_DUMMY_3): {
return objects::TEST_DUMMY_1;
case (objects::TEST_DUMMY_3): {
return objects::TEST_DUMMY_1;
}
default:
return objects::TEST_DUMMY_1;
}
return objects::TEST_DUMMY_1;
}
}
object_id_t FsfwExampleTask::getSender() {
switch(this->getObjectId()) {
case(objects::TEST_DUMMY_1): {
return objects::TEST_DUMMY_3;
switch (this->getObjectId()) {
case (objects::TEST_DUMMY_1): {
return objects::TEST_DUMMY_3;
}
case(objects::TEST_DUMMY_2): {
return objects::TEST_DUMMY_1;
case (objects::TEST_DUMMY_2): {
return objects::TEST_DUMMY_1;
}
case(objects::TEST_DUMMY_3): {
return objects::TEST_DUMMY_2;
case (objects::TEST_DUMMY_3): {
return objects::TEST_DUMMY_2;
}
default:
return objects::TEST_DUMMY_1;
}
return objects::TEST_DUMMY_1;
}
}
ReturnValue_t FsfwExampleTask::initialize() {
// Get the dataset of the sender. Will be cached for later checks.
object_id_t sender = getSender();
HasLocalDataPoolIF* senderIF = ObjectManager::instance()->get<HasLocalDataPoolIF>(sender);
if(senderIF == nullptr) {
// Get the dataset of the sender. Will be cached for later checks.
object_id_t sender = getSender();
HasLocalDataPoolIF* senderIF = ObjectManager::instance()->get<HasLocalDataPoolIF>(sender);
if (senderIF == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::initialize: Sender object invalid!" << std::endl;
sif::error << "FsfwDemoTask::initialize: Sender object invalid!" << std::endl;
#else
sif::printError("FsfwDemoTask::initialize: Sender object invalid!\n");
sif::printError("FsfwDemoTask::initialize: Sender object invalid!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_FAILED;
}
// we need a private copy of the previous dataset.. or we use the shared dataset.
senderSet = new FsfwDemoSet(senderIF);
if(senderSet == nullptr) {
// we need a private copy of the previous dataset.. or we use the shared dataset.
senderSet = new FsfwDemoSet(senderIF);
if (senderSet == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::initialize: Sender dataset invalid!" << std::endl;
sif::error << "FsfwDemoTask::initialize: Sender dataset invalid!" << std::endl;
#else
sif::printError("FsfwDemoTask::initialize: Sender dataset invalid!\n");
sif::printError("FsfwDemoTask::initialize: Sender dataset invalid!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
return poolManager.initialize(commandQueue);
return HasReturnvaluesIF::RETURN_FAILED;
}
return poolManager.initialize(commandQueue);
}
ReturnValue_t FsfwExampleTask::initializeAfterTaskCreation() {
return poolManager.initializeAfterTaskCreation();
return poolManager.initializeAfterTaskCreation();
}
object_id_t FsfwExampleTask::getObjectId() const {
return SystemObject::getObjectId();
}
object_id_t FsfwExampleTask::getObjectId() const { return SystemObject::getObjectId(); }
MessageQueueId_t FsfwExampleTask::getMessageQueueId(){
return commandQueue->getId();
}
MessageQueueId_t FsfwExampleTask::getMessageQueueId() { return commandQueue->getId(); }
void FsfwExampleTask::setTaskIF(PeriodicTaskIF* task){
this->task = task;
}
void FsfwExampleTask::setTaskIF(PeriodicTaskIF* task) { this->task = task; }
LocalPoolDataSetBase* FsfwExampleTask::getDataSetHandle(sid_t sid) {
return &demoSet;
}
LocalPoolDataSetBase* FsfwExampleTask::getDataSetHandle(sid_t sid) { return &demoSet; }
uint32_t FsfwExampleTask::getPeriodicOperationFrequency() const {
return task->getPeriodMs();
}
uint32_t FsfwExampleTask::getPeriodicOperationFrequency() const { return task->getPeriodMs(); }
ReturnValue_t FsfwExampleTask::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE_LIMIT, new PoolEntry<uint16_t>({0}));
return HasReturnvaluesIF::RETURN_OK;
ReturnValue_t FsfwExampleTask::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE_LIMIT, new PoolEntry<uint16_t>({0}));
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t FsfwExampleTask::performMonitoringDemo() {
ReturnValue_t result = demoSet.variableLimit.read(
MutexIF::TimeoutType::WAITING, 20);
if(result != HasReturnvaluesIF::RETURN_OK) {
/* Configuration error */
ReturnValue_t result = demoSet.variableLimit.read(MutexIF::TimeoutType::WAITING, 20);
if (result != HasReturnvaluesIF::RETURN_OK) {
/* Configuration error */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DummyObject::performOperation: Could not read variableLimit!" << std::endl;
sif::error << "DummyObject::performOperation: Could not read variableLimit!" << std::endl;
#else
sif::printError("DummyObject::performOperation: Could not read variableLimit!\n");
sif::printError("DummyObject::performOperation: Could not read variableLimit!\n");
#endif
return result;
return result;
}
if (this->getObjectId() == objects::TEST_DUMMY_5) {
if (demoSet.variableLimit.value > 20) {
demoSet.variableLimit.value = 0;
}
if(this->getObjectId() == objects::TEST_DUMMY_5){
if(demoSet.variableLimit.value > 20){
demoSet.variableLimit.value = 0;
}
demoSet.variableLimit.value++;
demoSet.variableLimit.commit(20);
monitor.check();
}
return HasReturnvaluesIF::RETURN_OK;
demoSet.variableLimit.value++;
demoSet.variableLimit.commit(20);
monitor.check();
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t FsfwExampleTask::performSendOperation() {
object_id_t nextRecipient = getNextRecipient();
FsfwExampleTask* target = ObjectManager::instance()->get<FsfwExampleTask>(nextRecipient);
if (target == nullptr) {
/* Configuration error */
object_id_t nextRecipient = getNextRecipient();
FsfwExampleTask* target = ObjectManager::instance()->get<FsfwExampleTask>(nextRecipient);
if (target == nullptr) {
/* Configuration error */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DummyObject::performOperation: Next recipient does not exist!" << std::endl;
sif::error << "DummyObject::performOperation: Next recipient does not exist!" << std::endl;
#else
sif::printError("DummyObject::performOperation: Next recipient does not exist!\n");
sif::printError("DummyObject::performOperation: Next recipient does not exist!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_FAILED;
}
uint32_t randomNumber = rand() % 100;
CommandMessage message;
message.setParameter(randomNumber);
message.setParameter2(this->getMessageQueueId());
uint32_t randomNumber = rand() % 100;
CommandMessage message;
message.setParameter(randomNumber);
message.setParameter2(this->getMessageQueueId());
/* Send message using own message queue */
ReturnValue_t result = commandQueue->sendMessage(target->getMessageQueueId(), &message);
if (result != HasReturnvaluesIF::RETURN_OK
&& result != MessageQueueIF::FULL) {
/* Send message using own message queue */
ReturnValue_t result = commandQueue->sendMessage(target->getMessageQueueId(), &message);
if (result != HasReturnvaluesIF::RETURN_OK && result != MessageQueueIF::FULL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::performSendOperation: Send failed with " << result <<
std::endl;
sif::error << "FsfwDemoTask::performSendOperation: Send failed with " << result << std::endl;
#else
sif::printError("FsfwDemoTask::performSendOperation: Send failed with %hu\n", result);
sif::printError("FsfwDemoTask::performSendOperation: Send failed with %hu\n", result);
#endif
}
}
/* Send message without via MessageQueueSenderIF */
result = MessageQueueSenderIF::sendMessage(target->getMessageQueueId(), &message,
commandQueue->getId());
if (result != HasReturnvaluesIF::RETURN_OK
&& result != MessageQueueIF::FULL) {
/* Send message without via MessageQueueSenderIF */
result = MessageQueueSenderIF::sendMessage(target->getMessageQueueId(), &message,
commandQueue->getId());
if (result != HasReturnvaluesIF::RETURN_OK && result != MessageQueueIF::FULL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::performSendOperation: Send failed with " << result << std::endl;
sif::error << "FsfwDemoTask::performSendOperation: Send failed with " << result << std::endl;
#else
sif::printError("FsfwDemoTask::performSendOperation: Send failed with %hu\n", result);
sif::printError("FsfwDemoTask::performSendOperation: Send failed with %hu\n", result);
#endif
}
}
demoSet.variableWrite.value = randomNumber;
result = demoSet.variableWrite.commit(20);
demoSet.variableWrite.value = randomNumber;
result = demoSet.variableWrite.commit(20);
return result;
return result;
}
ReturnValue_t FsfwExampleTask::performReceiveOperation() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
while (result != MessageQueueIF::EMPTY) {
CommandMessage receivedMessage;
result = commandQueue->receiveMessage(&receivedMessage);
if (result != HasReturnvaluesIF::RETURN_OK
&& result != MessageQueueIF::EMPTY) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
while (result != MessageQueueIF::EMPTY) {
CommandMessage receivedMessage;
result = commandQueue->receiveMessage(&receivedMessage);
if (result != HasReturnvaluesIF::RETURN_OK && result != MessageQueueIF::EMPTY) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Receive failed with " << result << std::endl;
sif::debug << "Receive failed with " << result << std::endl;
#endif
break;
}
if (result != MessageQueueIF::EMPTY) {
break;
}
if (result != MessageQueueIF::EMPTY) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
#if OBSW_VERBOSE_LEVEL >= 2
sif::debug << "Message Received by " << getObjectId() << " from Queue " <<
receivedMessage.getSender() << " ObjectId " << receivedMessage.getParameter() <<
" Queue " << receivedMessage.getParameter2() << std::endl;
sif::debug << "Message Received by " << getObjectId() << " from Queue "
<< receivedMessage.getSender() << " ObjectId " << receivedMessage.getParameter()
<< " Queue " << receivedMessage.getParameter2() << std::endl;
#endif
#endif
if(senderSet == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
if (senderSet == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
result = senderSet->variableRead.read(MutexIF::TimeoutType::WAITING,
20);
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if(senderSet->variableRead.value != receivedMessage.getParameter()) {
result = senderSet->variableRead.read(MutexIF::TimeoutType::WAITING, 20);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (senderSet->variableRead.value != receivedMessage.getParameter()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::performReceiveOperation: Variable " << std::hex <<
"0x" << senderSet->variableRead.getDataPoolId() << std::dec <<
" has wrong value." << std::endl;
sif::error << "Value: " << demoSet.variableRead.value << ", expected: " <<
receivedMessage.getParameter() << std::endl;
sif::error << "FsfwDemoTask::performReceiveOperation: Variable " << std::hex << "0x"
<< senderSet->variableRead.getDataPoolId() << std::dec << " has wrong value."
<< std::endl;
sif::error << "Value: " << demoSet.variableRead.value
<< ", expected: " << receivedMessage.getParameter() << std::endl;
#endif
}
}
}
}
return result;
}
return result;
}
MessageQueueId_t FsfwExampleTask::getCommandQueue() const {
return commandQueue->getId();
}
MessageQueueId_t FsfwExampleTask::getCommandQueue() const { return commandQueue->getId(); }
LocalDataPoolManager* FsfwExampleTask::getHkManagerHandle() {
return &poolManager;
}
LocalDataPoolManager* FsfwExampleTask::getHkManagerHandle() { return &poolManager; }

View File

@ -1,18 +1,17 @@
#ifndef MISSION_DEMO_FSFWDEMOTASK_H_
#define MISSION_DEMO_FSFWDEMOTASK_H_
#include "testdefinitions/demoDefinitions.h"
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/monitoring/AbsLimitMonitor.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include "testdefinitions/demoDefinitions.h"
class PeriodicTaskIF;
/**
* @brief This demo set shows the local data pool functionality and fixed
* timeslot capabilities of the FSFW.
@ -25,91 +24,82 @@ class PeriodicTaskIF;
* value directly from the sender via the local data pool interface.
* If the timing is set up correctly, the values will always be the same.
*/
class FsfwExampleTask:
public ExecutableObjectIF,
public SystemObject,
public HasLocalDataPoolIF {
public:
enum OpCodes {
SEND_RAND_NUM,
RECEIVE_RAND_NUM,
DELAY_SHORT
};
class FsfwExampleTask : public ExecutableObjectIF, public SystemObject, public HasLocalDataPoolIF {
public:
enum OpCodes { SEND_RAND_NUM, RECEIVE_RAND_NUM, DELAY_SHORT };
static constexpr uint8_t MONITOR_ID = 2;
static constexpr uint8_t MONITOR_ID = 2;
/**
* @brief Simple constructor, only expects object ID.
* @param objectId
*/
FsfwExampleTask(object_id_t objectId);
/**
* @brief Simple constructor, only expects object ID.
* @param objectId
*/
FsfwExampleTask(object_id_t objectId);
virtual ~FsfwExampleTask();
virtual ~FsfwExampleTask();
/**
* @brief The performOperation method is executed in a task.
* @details There are no restrictions for calls within this method, so any
* other member of the class can be used.
* @return Currently, the return value is ignored.
*/
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
/**
* @brief The performOperation method is executed in a task.
* @details There are no restrictions for calls within this method, so any
* other member of the class can be used.
* @return Currently, the return value is ignored.
*/
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
/**
* @brief This function will be called by the global object manager
* @details
* This function will always be called before any tasks are started.
* It can also be used to return error codes in the software initialization
* process cleanly.
* @return
*/
virtual ReturnValue_t initialize() override;
/**
* @brief This function will be called by the global object manager
* @details
* This function will always be called before any tasks are started.
* It can also be used to return error codes in the software initialization
* process cleanly.
* @return
*/
virtual ReturnValue_t initialize() override;
/**
* @brief This function will be called by the OSAL task handlers
* @details
* This function will be called before the first #performOperation
* call after the tasks have been started. It can be used if some
* initialization process requires task specific properties like
* periodic intervals (by using the PeriodicTaskIF* handle).
* @return
*/
virtual ReturnValue_t initializeAfterTaskCreation() override;
/**
* @brief This function will be called by the OSAL task handlers
* @details
* This function will be called before the first #performOperation
* call after the tasks have been started. It can be used if some
* initialization process requires task specific properties like
* periodic intervals (by using the PeriodicTaskIF* handle).
* @return
*/
virtual ReturnValue_t initializeAfterTaskCreation() override;
/**
* This function will be called by the OSAL task handler. The
* task interface handle can be cached to access task specific properties.
* @param task
*/
void setTaskIF(PeriodicTaskIF* task) override;
/**
* This function will be called by the OSAL task handler. The
* task interface handle can be cached to access task specific properties.
* @param task
*/
void setTaskIF(PeriodicTaskIF* task) override;
object_id_t getObjectId() const override;
object_id_t getObjectId() const override;
MessageQueueId_t getMessageQueueId();
MessageQueueId_t getMessageQueueId();
private:
LocalDataPoolManager poolManager;
FsfwDemoSet* senderSet = nullptr;
FsfwDemoSet demoSet;
AbsLimitMonitor<int32_t> monitor;
PeriodicTaskIF* task = nullptr;
MessageQueueIF* commandQueue = nullptr;
private:
LocalDataPoolManager poolManager;
FsfwDemoSet* senderSet = nullptr;
FsfwDemoSet demoSet;
AbsLimitMonitor<int32_t> monitor;
PeriodicTaskIF* task = nullptr;
MessageQueueIF* commandQueue = nullptr;
/* HasLocalDatapoolIF overrides */
MessageQueueId_t getCommandQueue() const override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
uint32_t getPeriodicOperationFrequency() const override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
LocalDataPoolManager* getHkManagerHandle() override;
/* HasLocalDatapoolIF overrides */
MessageQueueId_t getCommandQueue() const override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
uint32_t getPeriodicOperationFrequency() const override;
ReturnValue_t initializeLocalDataPool(
localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
LocalDataPoolManager* getHkManagerHandle() override;
object_id_t getNextRecipient();
object_id_t getSender();
object_id_t getNextRecipient();
object_id_t getSender();
ReturnValue_t performMonitoringDemo();
ReturnValue_t performSendOperation();
ReturnValue_t performReceiveOperation();
ReturnValue_t performMonitoringDemo();
ReturnValue_t performSendOperation();
ReturnValue_t performReceiveOperation();
};
#endif /* MISSION_DEMO_FSFWDEMOTASK_H_ */

View File

@ -1,55 +1,54 @@
#include "FsfwReaderTask.h"
#include <OBSWConfig.h>
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tasks/TaskFactory.h>
#include <fsfw/timemanager/Stopwatch.h>
#include <OBSWConfig.h>
FsfwReaderTask::FsfwReaderTask(object_id_t objectId, bool enablePrintout):
SystemObject(objectId), printoutEnabled(enablePrintout), opDivider(10),
readSet(this->getObjectId(),
gp_id_t(objects::TEST_DUMMY_1, FsfwDemoSet::PoolIds::VARIABLE),
gp_id_t(objects::TEST_DUMMY_2, FsfwDemoSet::PoolIds::VARIABLE),
gp_id_t(objects::TEST_DUMMY_3, FsfwDemoSet::PoolIds::VARIABLE)) {
/* Special protection for set reading because each variable is read from a different pool */
readSet.setReadCommitProtectionBehaviour(true);
FsfwReaderTask::FsfwReaderTask(object_id_t objectId, bool enablePrintout)
: SystemObject(objectId),
printoutEnabled(enablePrintout),
opDivider(10),
readSet(this->getObjectId(), gp_id_t(objects::TEST_DUMMY_1, FsfwDemoSet::PoolIds::VARIABLE),
gp_id_t(objects::TEST_DUMMY_2, FsfwDemoSet::PoolIds::VARIABLE),
gp_id_t(objects::TEST_DUMMY_3, FsfwDemoSet::PoolIds::VARIABLE)) {
/* Special protection for set reading because each variable is read from a different pool */
readSet.setReadCommitProtectionBehaviour(true);
}
FsfwReaderTask::~FsfwReaderTask() {
}
FsfwReaderTask::~FsfwReaderTask() {}
ReturnValue_t FsfwReaderTask::initializeAfterTaskCreation() {
/* Give other task some time to set up local data pools. */
TaskFactory::delayTask(20);
return HasReturnvaluesIF::RETURN_OK;
/* Give other task some time to set up local data pools. */
TaskFactory::delayTask(20);
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t FsfwReaderTask::performOperation(uint8_t operationCode) {
PoolReadGuard readHelper(&readSet);
PoolReadGuard readHelper(&readSet);
uint32_t variable1 = readSet.variable1.value;
uint32_t variable2 = readSet.variable2.value;
uint32_t variable3 = readSet.variable3.value;
uint32_t variable1 = readSet.variable1.value;
uint32_t variable2 = readSet.variable2.value;
uint32_t variable3 = readSet.variable3.value;
#if OBSW_VERBOSE_LEVEL >= 1
if(opDivider.checkAndIncrement() and printoutEnabled) {
if (opDivider.checkAndIncrement() and printoutEnabled) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "FsfwPeriodicTask::performOperation: Reading variables." << std::endl;
sif::info << "Variable read from demo object 1: " << variable1 << std::endl;
sif::info << "Variable read from demo object 2: " << variable2 << std::endl;
sif::info << "Variable read from demo object 3: " << variable3 << std::endl;
sif::info << "FsfwPeriodicTask::performOperation: Reading variables." << std::endl;
sif::info << "Variable read from demo object 1: " << variable1 << std::endl;
sif::info << "Variable read from demo object 2: " << variable2 << std::endl;
sif::info << "Variable read from demo object 3: " << variable3 << std::endl;
#else
sif::printInfo("FsfwPeriodicTask::performOperation: Reading variables.\n\r");
sif::printInfo("Variable read from demo object 1: %d\n\r", variable1);
sif::printInfo("Variable read from demo object 2: %d\n\r", variable2);
sif::printInfo("Variable read from demo object 3: %d\n\r", variable3);
sif::printInfo("FsfwPeriodicTask::performOperation: Reading variables.\n\r");
sif::printInfo("Variable read from demo object 1: %d\n\r", variable1);
sif::printInfo("Variable read from demo object 2: %d\n\r", variable2);
sif::printInfo("Variable read from demo object 3: %d\n\r", variable3);
#endif
}
}
#else
if(variable1 and variable2 and variable3) {};
if (variable1 and variable2 and variable3) {
};
#endif
return HasReturnvaluesIF::RETURN_OK;
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -1,24 +1,24 @@
#ifndef MISSION_DEMO_FSFWPERIODICTASK_H_
#define MISSION_DEMO_FSFWPERIODICTASK_H_
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include "testdefinitions/demoDefinitions.h"
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <fsfw/objectmanager/SystemObject.h>
class FsfwReaderTask : public ExecutableObjectIF, public SystemObject {
public:
FsfwReaderTask(object_id_t objectId, bool enablePrintout);
~FsfwReaderTask() override;
class FsfwReaderTask: public ExecutableObjectIF, public SystemObject {
public:
FsfwReaderTask(object_id_t objectId, bool enablePrintout);
~FsfwReaderTask() override;
ReturnValue_t initializeAfterTaskCreation() override;
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
ReturnValue_t initializeAfterTaskCreation() override;
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
private:
bool printoutEnabled = false;
PeriodicOperationDivider opDivider;
CompleteDemoReadSet readSet;
private:
bool printoutEnabled = false;
PeriodicOperationDivider opDivider;
CompleteDemoReadSet readSet;
};
#endif /* MISSION_DEMO_FSFWPERIODICTASK_H_ */

View File

@ -1,12 +1,11 @@
#include "FsfwTestTask.h"
FsfwTestTask::FsfwTestTask(object_id_t objectId, bool periodicEvent):
TestTask(objectId), periodicEvent(periodicEvent) {
}
FsfwTestTask::FsfwTestTask(object_id_t objectId, bool periodicEvent)
: TestTask(objectId), periodicEvent(periodicEvent) {}
ReturnValue_t FsfwTestTask::performPeriodicAction() {
if(periodicEvent) {
triggerEvent(TEST_EVENT, 0x1234, 0x4321);
}
return HasReturnvaluesIF::RETURN_OK;
if (periodicEvent) {
triggerEvent(TEST_EVENT, 0x1234, 0x4321);
}
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -1,21 +1,20 @@
#ifndef EXAMPLE_COMMON_EXAMPLE_TEST_FSFWTESTTASK_H_
#define EXAMPLE_COMMON_EXAMPLE_TEST_FSFWTESTTASK_H_
#include "events/subsystemIdRanges.h"
#include "fsfw/events/Event.h"
#include "fsfw_tests/integration/task/TestTask.h"
#include "fsfw/events/Event.h"
#include "events/subsystemIdRanges.h"
class FsfwTestTask : public TestTask {
public:
FsfwTestTask(object_id_t objectId, bool periodicEvent);
class FsfwTestTask: public TestTask {
public:
FsfwTestTask(object_id_t objectId, bool periodicEvent);
ReturnValue_t performPeriodicAction() override;
ReturnValue_t performPeriodicAction() override;
private:
bool periodicEvent = false;
static constexpr uint8_t subsystemId = SUBSYSTEM_ID::TEST_TASK_ID;
static constexpr Event TEST_EVENT = event::makeEvent(subsystemId, 0, severity::INFO);
private:
bool periodicEvent = false;
static constexpr uint8_t subsystemId = SUBSYSTEM_ID::TEST_TASK_ID;
static constexpr Event TEST_EVENT = event::makeEvent(subsystemId, 0, severity::INFO);
};
#endif /* EXAMPLE_COMMON_EXAMPLE_TEST_FSFWTESTTASK_H_ */

View File

@ -3,45 +3,43 @@
#include <fsfw/ipc/MutexFactory.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
void MutexExample::example() {
MutexIF* mutex = MutexFactory::instance()->createMutex();
MutexIF* mutex2 = MutexFactory::instance()->createMutex();
void MutexExample::example(){
MutexIF* mutex = MutexFactory::instance()->createMutex();
MutexIF* mutex2 = MutexFactory::instance()->createMutex();
ReturnValue_t result = mutex->lockMutex(MutexIF::TimeoutType::WAITING,
2 * 60 * 1000);
if (result != HasReturnvaluesIF::RETURN_OK) {
ReturnValue_t result = mutex->lockMutex(MutexIF::TimeoutType::WAITING, 2 * 60 * 1000);
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Lock Failed with " << result << std::endl;
sif::error << "MutexExample::example: Lock Failed with " << result << std::endl;
#else
sif::printError("MutexExample::example: Lock Failed with %hu\n", result);
sif::printError("MutexExample::example: Lock Failed with %hu\n", result);
#endif
}
}
result = mutex2->lockMutex(MutexIF::TimeoutType::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) {
result = mutex2->lockMutex(MutexIF::TimeoutType::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Lock Failed with " << result << std::endl;
sif::error << "MutexExample::example: Lock Failed with " << result << std::endl;
#else
sif::printError("MutexExample::example: Lock Failed with %hu\n", result);
sif::printError("MutexExample::example: Lock Failed with %hu\n", result);
#endif
}
}
result = mutex->unlockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) {
result = mutex->unlockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Unlock Failed with " << result << std::endl;
sif::error << "MutexExample::example: Unlock Failed with " << result << std::endl;
#else
sif::printError("MutexExample::example: Unlock Failed with %hu\n", result);
sif::printError("MutexExample::example: Unlock Failed with %hu\n", result);
#endif
}
}
result = mutex2->unlockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) {
result = mutex2->unlockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Unlock Failed with " << result << std::endl;
sif::error << "MutexExample::example: Unlock Failed with " << result << std::endl;
#else
sif::printError("MutexExample::example: Unlock Failed with %hu\n", result);
sif::printError("MutexExample::example: Unlock Failed with %hu\n", result);
#endif
}
}
}

View File

@ -2,7 +2,7 @@
#define EXAMPLE_COMMON_MUTEXEXAMPLE_H_
namespace MutexExample {
void example();
void example();
};
#endif /* EXAMPLE_COMMON_MUTEXEXAMPLE_H_ */

View File

@ -1,8 +1,8 @@
#ifndef MISSION_DEMO_DEMODEFINITIONS_H_
#define MISSION_DEMO_DEMODEFINITIONS_H_
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
/**
* @brief This demo set showcases the local data pool functionality of the
@ -11,27 +11,22 @@
* Each demo object will have an own instance of this set class, which contains
* pool variables (for read and write access respectively).
*/
class FsfwDemoSet: public StaticLocalDataSet<3> {
public:
class FsfwDemoSet : public StaticLocalDataSet<3> {
public:
static constexpr uint32_t DEMO_SET_ID = 0;
static constexpr uint32_t DEMO_SET_ID = 0;
enum PoolIds { VARIABLE, VARIABLE_LIMIT };
enum PoolIds {
VARIABLE,
VARIABLE_LIMIT
};
FsfwDemoSet(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, DEMO_SET_ID) {}
FsfwDemoSet(HasLocalDataPoolIF* hkOwner):
StaticLocalDataSet(hkOwner, DEMO_SET_ID) {}
lp_var_t<uint32_t> variableRead = lp_var_t<uint32_t>(sid.objectId,
PoolIds::VARIABLE, this, pool_rwm_t::VAR_READ);
lp_var_t<uint32_t> variableWrite = lp_var_t<uint32_t>(sid.objectId,
PoolIds::VARIABLE, this, pool_rwm_t::VAR_WRITE);
lp_var_t<uint16_t> variableLimit = lp_var_t<uint16_t>(sid.objectId,
PoolIds::VARIABLE_LIMIT, this);
private:
lp_var_t<uint32_t> variableRead =
lp_var_t<uint32_t>(sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_READ);
lp_var_t<uint32_t> variableWrite =
lp_var_t<uint32_t>(sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_WRITE);
lp_var_t<uint16_t> variableLimit =
lp_var_t<uint16_t>(sid.objectId, PoolIds::VARIABLE_LIMIT, this);
private:
};
/**
@ -39,25 +34,21 @@ private:
* above. An example application would be a consumer object like a controller
* which reads multiple sensor values at once.
*/
class CompleteDemoReadSet: public StaticLocalDataSet<3> {
public:
static constexpr uint32_t DEMO_SET_ID = 0;
class CompleteDemoReadSet : public StaticLocalDataSet<3> {
public:
static constexpr uint32_t DEMO_SET_ID = 0;
CompleteDemoReadSet(object_id_t owner, gp_id_t variable1,
gp_id_t variable2, gp_id_t variable3):
StaticLocalDataSet(sid_t(owner, DEMO_SET_ID)),
variable1(variable1, this, pool_rwm_t::VAR_READ),
variable2(variable2, this, pool_rwm_t::VAR_READ),
variable3(variable3, this, pool_rwm_t::VAR_READ) {}
CompleteDemoReadSet(object_id_t owner, gp_id_t variable1, gp_id_t variable2, gp_id_t variable3)
: StaticLocalDataSet(sid_t(owner, DEMO_SET_ID)),
variable1(variable1, this, pool_rwm_t::VAR_READ),
variable2(variable2, this, pool_rwm_t::VAR_READ),
variable3(variable3, this, pool_rwm_t::VAR_READ) {}
lp_var_t<uint32_t> variable1;
lp_var_t<uint32_t> variable2;
lp_var_t<uint32_t> variable3;
lp_var_t<uint32_t> variable1;
lp_var_t<uint32_t> variable2;
lp_var_t<uint32_t> variable3;
private:
private:
};
#endif /* MISSION_DEMO_DEMODEFINITIONS_H_ */

View File

@ -1,10 +1,9 @@
#include <fsfw/tmtcpacket/pus/tc.h>
#include <fsfw/tmtcpacket/pus/tm.h>
#include <fsfw/globalfunctions/arrayprinter.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tmtcpacket/pus/tc.h>
#include <fsfw/tmtcpacket/pus/tm.h>
#include <mission/utility/PusPacketCreator.h>
void PusPacketCreator::createPusPacketAndPrint() {
// TODO: use TC packet stored here instead..
// TODO: use TC packet stored here instead..
}

View File

@ -9,8 +9,8 @@
#define MISSION_UTILITY_PUSPACKETCREATOR_H_
class PusPacketCreator {
public:
static void createPusPacketAndPrint();
public:
static void createPusPacketAndPrint();
};
#endif /* MISSION_UTILITY_PUSPACKETCREATOR_H_ */

View File

@ -8,15 +8,14 @@ namespace task {
void printInitError(const char* objName, object_id_t objectId) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "InitMission: Adding object " << objName << "("
<< std::setw(8) << std::setfill('0') << std::hex << objectId
<< std::dec << ") failed." << std::endl;
sif::error << "InitMission: Adding object " << objName << "(" << std::setw(8) << std::setfill('0')
<< std::hex << objectId << std::dec << ") failed." << std::endl;
#else
sif::printError("InitMission: Adding object %s (0x%08x) failed.\n",
objName, static_cast<unsigned int>(objectId));
sif::printError("InitMission: Adding object %s (0x%08x) failed.\n", objName,
static_cast<unsigned int>(objectId));
#endif
}
}
} // namespace task
#endif /* MISSION_UTILITY_TASKCREATION_H_ */

View File

@ -2,119 +2,113 @@
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/tmtcpacket/pus/tm.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tmtcpacket/pus/tm.h>
object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT;
object_id_t TmFunnel::storageDestination = objects::NO_OBJECT;
TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth):
SystemObject(objectId), messageDepth(messageDepth) {
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
storageQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth)
: SystemObject(objectId), messageDepth(messageDepth) {
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
storageQueue = QueueFactory::instance()->createMessageQueue(
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE);
}
TmFunnel::~TmFunnel() {
}
TmFunnel::~TmFunnel() {}
MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) {
return tmQueue->getId();
return tmQueue->getId();
}
ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
TmTcMessage currentMessage;
ReturnValue_t status = tmQueue->receiveMessage(&currentMessage);
while(status == HasReturnvaluesIF::RETURN_OK)
{
status = handlePacket(&currentMessage);
if(status != HasReturnvaluesIF::RETURN_OK){
break;
}
status = tmQueue->receiveMessage(&currentMessage);
TmTcMessage currentMessage;
ReturnValue_t status = tmQueue->receiveMessage(&currentMessage);
while (status == HasReturnvaluesIF::RETURN_OK) {
status = handlePacket(&currentMessage);
if (status != HasReturnvaluesIF::RETURN_OK) {
break;
}
status = tmQueue->receiveMessage(&currentMessage);
}
if (status == MessageQueueIF::EMPTY) {
return HasReturnvaluesIF::RETURN_OK;
}
else {
return status;
}
if (status == MessageQueueIF::EMPTY) {
return HasReturnvaluesIF::RETURN_OK;
} else {
return status;
}
}
ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) {
uint8_t* packetData = nullptr;
size_t size = 0;
ReturnValue_t result = tmPool->modifyData(message->getStorageId(),
&packetData, &size);
if(result != HasReturnvaluesIF::RETURN_OK){
return result;
}
TmPacketPusC packet(packetData);
packet.setPacketSequenceCount(this->sourceSequenceCount);
sourceSequenceCount++;
sourceSequenceCount = sourceSequenceCount %
SpacePacketBase::LIMIT_SEQUENCE_COUNT;
packet.setErrorControl();
result = tmQueue->sendToDefault(message);
if(result != HasReturnvaluesIF::RETURN_OK){
tmPool->deleteData(message->getStorageId());
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::handlePacket: Error sending to downlink handler" << std::endl;
#endif
return result;
}
if(storageDestination != objects::NO_OBJECT) {
result = storageQueue->sendToDefault(message);
if(result != HasReturnvaluesIF::RETURN_OK){
tmPool->deleteData(message->getStorageId());
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::handlePacket: Error sending to storage handler" << std::endl;
#endif
return result;
}
}
uint8_t* packetData = nullptr;
size_t size = 0;
ReturnValue_t result = tmPool->modifyData(message->getStorageId(), &packetData, &size);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
TmPacketPusC packet(packetData);
packet.setPacketSequenceCount(this->sourceSequenceCount);
sourceSequenceCount++;
sourceSequenceCount = sourceSequenceCount % SpacePacketBase::LIMIT_SEQUENCE_COUNT;
packet.setErrorControl();
result = tmQueue->sendToDefault(message);
if (result != HasReturnvaluesIF::RETURN_OK) {
tmPool->deleteData(message->getStorageId());
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::handlePacket: Error sending to downlink handler" << std::endl;
#endif
return result;
}
if (storageDestination != objects::NO_OBJECT) {
result = storageQueue->sendToDefault(message);
if (result != HasReturnvaluesIF::RETURN_OK) {
tmPool->deleteData(message->getStorageId());
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::handlePacket: Error sending to storage handler" << std::endl;
#endif
return result;
}
}
return result;
}
ReturnValue_t TmFunnel::initialize() {
tmPool = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if(tmPool == nullptr) {
tmPool = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (tmPool == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::initialize: TM store not set." << std::endl;
sif::error << "Make sure the tm store is set up properly and implements StorageManagerIF" <<
std::endl;
sif::error << "TmFunnel::initialize: TM store not set." << std::endl;
sif::error << "Make sure the tm store is set up properly and implements StorageManagerIF"
<< std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
return ObjectManagerIF::CHILD_INIT_FAILED;
}
AcceptsTelemetryIF* tmTarget = ObjectManager::instance()->
get<AcceptsTelemetryIF>(downlinkDestination);
if(tmTarget == nullptr){
AcceptsTelemetryIF* tmTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(downlinkDestination);
if (tmTarget == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl;
sif::error << "Make sure the downlink destination object is set up properly and implements "
"AcceptsTelemetryIF" << std::endl;
sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl;
sif::error << "Make sure the downlink destination object is set up properly and implements "
"AcceptsTelemetryIF"
<< std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue());
// Storage destination is optional.
if(storageDestination == objects::NO_OBJECT) {
return SystemObject::initialize();
}
AcceptsTelemetryIF* storageTarget = ObjectManager::instance()->
get<AcceptsTelemetryIF>(storageDestination);
if(storageTarget != nullptr) {
storageQueue->setDefaultDestination(
storageTarget->getReportReceptionQueue());
}
return ObjectManagerIF::CHILD_INIT_FAILED;
}
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue());
// Storage destination is optional.
if (storageDestination == objects::NO_OBJECT) {
return SystemObject::initialize();
}
AcceptsTelemetryIF* storageTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(storageDestination);
if (storageTarget != nullptr) {
storageQueue->setDefaultDestination(storageTarget->getReportReceptionQueue());
}
return SystemObject::initialize();
}

View File

@ -1,13 +1,13 @@
#ifndef MISSION_UTILITY_TMFUNNEL_H_
#define MISSION_UTILITY_TMFUNNEL_H_
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/tmtcservices/TmTcMessage.h>
namespace Factory{
namespace Factory {
void setStaticFrameworkObjectIds();
}
@ -19,33 +19,30 @@ void setStaticFrameworkObjectIds();
* @ingroup utility
* @author J. Meier
*/
class TmFunnel:
public AcceptsTelemetryIF,
public ExecutableObjectIF,
public SystemObject {
friend void (Factory::setStaticFrameworkObjectIds)();
public:
TmFunnel(object_id_t objectId, uint32_t messageDepth = 20);
virtual ~TmFunnel();
class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public SystemObject {
friend void(Factory::setStaticFrameworkObjectIds)();
virtual MessageQueueId_t getReportReceptionQueue(
uint8_t virtualChannel = 0) override;
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual ReturnValue_t initialize() override;
public:
TmFunnel(object_id_t objectId, uint32_t messageDepth = 20);
virtual ~TmFunnel();
protected:
static object_id_t downlinkDestination;
static object_id_t storageDestination;
virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override;
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual ReturnValue_t initialize() override;
private:
uint16_t sourceSequenceCount = 0;
MessageQueueIF* tmQueue = nullptr;
MessageQueueIF* storageQueue = nullptr;
protected:
static object_id_t downlinkDestination;
static object_id_t storageDestination;
StorageManagerIF* tmPool = nullptr;
uint32_t messageDepth = 0;
private:
uint16_t sourceSequenceCount = 0;
MessageQueueIF* tmQueue = nullptr;
MessageQueueIF* storageQueue = nullptr;
ReturnValue_t handlePacket(TmTcMessage* message);
StorageManagerIF* tmPool = nullptr;
uint32_t messageDepth = 0;
ReturnValue_t handlePacket(TmTcMessage* message);
};
#endif /* MISSION_UTILITY_TMFUNNEL_H_ */

View File

@ -5,14 +5,17 @@
* Authors:
*
* Assembled from the code released on Stackoverflow by:
* Dennis (instructable.com/member/nqtronix) | https://stackoverflow.com/questions/23032002/c-c-how-to-get-integer-unix-timestamp-of-build-time-not-string
* Dennis (instructable.com/member/nqtronix) |
* https://stackoverflow.com/questions/23032002/c-c-how-to-get-integer-unix-timestamp-of-build-time-not-string
* and
* Alexis Wilke | https://stackoverflow.com/questions/10538444/do-you-know-of-a-c-macro-to-compute-unix-time-and-date
* Alexis Wilke |
* https://stackoverflow.com/questions/10538444/do-you-know-of-a-c-macro-to-compute-unix-time-and-date
*
* Assembled by Jean Rabault
*
* UNIX_TIMESTAMP gives the UNIX timestamp (unsigned long integer of seconds since 1st Jan 1970) of compilation from macros using the compiler defined __TIME__ macro.
* This should include Gregorian calendar leap days, in particular the 29ths of February, 100 and 400 years modulo leaps.
* UNIX_TIMESTAMP gives the UNIX timestamp (unsigned long integer of seconds since 1st Jan 1970) of
* compilation from macros using the compiler defined __TIME__ macro. This should include Gregorian
* calendar leap days, in particular the 29ths of February, 100 and 400 years modulo leaps.
*
* Careful: __TIME__ is the local time of the computer, NOT the UTC time in general!
*
@ -22,76 +25,66 @@
#define COMPILE_TIME_H_
// Some definitions for calculation
#define SEC_PER_MIN 60UL
#define SEC_PER_HOUR 3600UL
#define SEC_PER_DAY 86400UL
#define SEC_PER_YEAR (SEC_PER_DAY*365)
#define SEC_PER_MIN 60UL
#define SEC_PER_HOUR 3600UL
#define SEC_PER_DAY 86400UL
#define SEC_PER_YEAR (SEC_PER_DAY * 365)
// extracts 1..4 characters from a string and interprets it as a decimal value
#define CONV_STR2DEC_1(str, i) (str[i]>'0'?str[i]-'0':0)
#define CONV_STR2DEC_2(str, i) (CONV_STR2DEC_1(str, i)*10 + str[i+1]-'0')
#define CONV_STR2DEC_3(str, i) (CONV_STR2DEC_2(str, i)*10 + str[i+2]-'0')
#define CONV_STR2DEC_4(str, i) (CONV_STR2DEC_3(str, i)*10 + str[i+3]-'0')
#define CONV_STR2DEC_1(str, i) (str[i] > '0' ? str[i] - '0' : 0)
#define CONV_STR2DEC_2(str, i) (CONV_STR2DEC_1(str, i) * 10 + str[i + 1] - '0')
#define CONV_STR2DEC_3(str, i) (CONV_STR2DEC_2(str, i) * 10 + str[i + 2] - '0')
#define CONV_STR2DEC_4(str, i) (CONV_STR2DEC_3(str, i) * 10 + str[i + 3] - '0')
// Custom "glue logic" to convert the month name to a usable number
#define GET_MONTH(str, i) (str[i]=='J' && str[i+1]=='a' && str[i+2]=='n' ? 1 : \
str[i]=='F' && str[i+1]=='e' && str[i+2]=='b' ? 2 : \
str[i]=='M' && str[i+1]=='a' && str[i+2]=='r' ? 3 : \
str[i]=='A' && str[i+1]=='p' && str[i+2]=='r' ? 4 : \
str[i]=='M' && str[i+1]=='a' && str[i+2]=='y' ? 5 : \
str[i]=='J' && str[i+1]=='u' && str[i+2]=='n' ? 6 : \
str[i]=='J' && str[i+1]=='u' && str[i+2]=='l' ? 7 : \
str[i]=='A' && str[i+1]=='u' && str[i+2]=='g' ? 8 : \
str[i]=='S' && str[i+1]=='e' && str[i+2]=='p' ? 9 : \
str[i]=='O' && str[i+1]=='c' && str[i+2]=='t' ? 10 : \
str[i]=='N' && str[i+1]=='o' && str[i+2]=='v' ? 11 : \
str[i]=='D' && str[i+1]=='e' && str[i+2]=='c' ? 12 : 0)
#define GET_MONTH(str, i) \
(str[i] == 'J' && str[i + 1] == 'a' && str[i + 2] == 'n' ? 1 \
: str[i] == 'F' && str[i + 1] == 'e' && str[i + 2] == 'b' ? 2 \
: str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'r' ? 3 \
: str[i] == 'A' && str[i + 1] == 'p' && str[i + 2] == 'r' ? 4 \
: str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'y' ? 5 \
: str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'n' ? 6 \
: str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'l' ? 7 \
: str[i] == 'A' && str[i + 1] == 'u' && str[i + 2] == 'g' ? 8 \
: str[i] == 'S' && str[i + 1] == 'e' && str[i + 2] == 'p' ? 9 \
: str[i] == 'O' && str[i + 1] == 'c' && str[i + 2] == 't' ? 10 \
: str[i] == 'N' && str[i + 1] == 'o' && str[i + 2] == 'v' ? 11 \
: str[i] == 'D' && str[i + 1] == 'e' && str[i + 2] == 'c' ? 12 \
: 0)
// extract the information from the time string given by __TIME__ and __DATE__
#define __TIME_SECONDS__ CONV_STR2DEC_2(__TIME__, 6)
#define __TIME_MINUTES__ CONV_STR2DEC_2(__TIME__, 3)
#define __TIME_HOURS__ CONV_STR2DEC_2(__TIME__, 0)
#define __TIME_DAYS__ CONV_STR2DEC_2(__DATE__, 4)
#define __TIME_MONTH__ GET_MONTH(__DATE__, 0)
#define __TIME_YEARS__ CONV_STR2DEC_4(__DATE__, 7)
#define __TIME_SECONDS__ CONV_STR2DEC_2(__TIME__, 6)
#define __TIME_MINUTES__ CONV_STR2DEC_2(__TIME__, 3)
#define __TIME_HOURS__ CONV_STR2DEC_2(__TIME__, 0)
#define __TIME_DAYS__ CONV_STR2DEC_2(__DATE__, 4)
#define __TIME_MONTH__ GET_MONTH(__DATE__, 0)
#define __TIME_YEARS__ CONV_STR2DEC_4(__DATE__, 7)
// Days in February
#define _UNIX_TIMESTAMP_FDAY(year) \
(((year) % 400) == 0UL ? 29UL : \
(((year) % 100) == 0UL ? 28UL : \
(((year) % 4) == 0UL ? 29UL : \
28UL)))
(((year) % 400) == 0UL ? 29UL \
: (((year) % 100) == 0UL ? 28UL : (((year) % 4) == 0UL ? 29UL : 28UL)))
// Days in the year
#define _UNIX_TIMESTAMP_YDAY(year, month, day) \
( \
/* January */ day \
/* February */ + (month >= 2 ? 31UL : 0UL) \
/* March */ + (month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) \
/* April */ + (month >= 4 ? 31UL : 0UL) \
/* May */ + (month >= 5 ? 30UL : 0UL) \
/* June */ + (month >= 6 ? 31UL : 0UL) \
/* July */ + (month >= 7 ? 30UL : 0UL) \
/* August */ + (month >= 8 ? 31UL : 0UL) \
/* September */+ (month >= 9 ? 31UL : 0UL) \
/* October */ + (month >= 10 ? 30UL : 0UL) \
/* November */ + (month >= 11 ? 31UL : 0UL) \
/* December */ + (month >= 12 ? 30UL : 0UL) \
)
#define _UNIX_TIMESTAMP_YDAY(year, month, day) \
(/* January */ day /* February */ + (month >= 2 ? 31UL : 0UL) /* March */ + \
(month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) /* April */ + \
(month >= 4 ? 31UL : 0UL) /* May */ + (month >= 5 ? 30UL : 0UL) /* June */ + \
(month >= 6 ? 31UL : 0UL) /* July */ + (month >= 7 ? 30UL : 0UL) /* August */ + \
(month >= 8 ? 31UL : 0UL) /* September */ + (month >= 9 ? 31UL : 0UL) /* October */ + \
(month >= 10 ? 30UL : 0UL) /* November */ + (month >= 11 ? 31UL : 0UL) /* December */ + \
(month >= 12 ? 30UL : 0UL))
// get the UNIX timestamp from a digits representation
#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \
( /* time */ second \
+ minute * SEC_PER_MIN \
+ hour * SEC_PER_HOUR \
+ /* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY \
+ /* year */ (year - 1970UL) * SEC_PER_YEAR \
+ ((year - 1969UL) / 4UL) * SEC_PER_DAY \
- ((year - 1901UL) / 100UL) * SEC_PER_DAY \
+ ((year - 1601UL) / 400UL) * SEC_PER_DAY \
)
#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \
(/* time */ second + minute * SEC_PER_MIN + hour * SEC_PER_HOUR + \
/* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY + \
/* year */ (year - 1970UL) * SEC_PER_YEAR + ((year - 1969UL) / 4UL) * SEC_PER_DAY - \
((year - 1901UL) / 100UL) * SEC_PER_DAY + ((year - 1601UL) / 400UL) * SEC_PER_DAY)
// the UNIX timestamp
#define UNIX_TIMESTAMP (_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, __TIME_MINUTES__, __TIME_SECONDS__))
#define UNIX_TIMESTAMP \
(_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, \
__TIME_MINUTES__, __TIME_SECONDS__))
#endif

View File

@ -1,22 +1,22 @@
#include "utility.h"
#include <FSFWConfig.h>
#include <OBSWVersion.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
void utility::commonInitPrint(const char *const os, const char* const board) {
if(os == nullptr or board == nullptr) {
return;
}
void utility::commonInitPrint(const char* const os, const char* const board) {
if (os == nullptr or board == nullptr) {
return;
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
std::cout << "-- FSFW Example (" << os<< ") v" << FSFW_EXAMPLE_VERSION << "." <<
FSFW_EXAMPLE_SUBVERSION << "." << FSFW_EXAMPLE_REVISION << " --" << std::endl;
std::cout << "-- Compiled for " << board << " --" << std::endl;
std::cout << "-- Compiled on " << __DATE__ << " " << __TIME__ << " --" << std::endl;
std::cout << "-- FSFW Example (" << os << ") v" << FSFW_EXAMPLE_VERSION << "."
<< FSFW_EXAMPLE_SUBVERSION << "." << FSFW_EXAMPLE_REVISION << " --" << std::endl;
std::cout << "-- Compiled for " << board << " --" << std::endl;
std::cout << "-- Compiled on " << __DATE__ << " " << __TIME__ << " --" << std::endl;
#else
printf("\n\r-- FSFW Example (%s) v%d.%d.%d --\n", os, FSFW_EXAMPLE_VERSION,
FSFW_EXAMPLE_SUBVERSION, FSFW_EXAMPLE_REVISION);
printf("-- Compiled for %s --\n", board);
printf("-- Compiled on %s %s --\n", __DATE__, __TIME__);
printf("\n\r-- FSFW Example (%s) v%d.%d.%d --\n", os, FSFW_EXAMPLE_VERSION,
FSFW_EXAMPLE_SUBVERSION, FSFW_EXAMPLE_REVISION);
printf("-- Compiled for %s --\n", board);
printf("-- Compiled on %s %s --\n", __DATE__, __TIME__);
#endif
}

View File

@ -3,9 +3,8 @@
namespace utility {
void commonInitPrint(const char *const os, const char* const board);
void commonInitPrint(const char* const os, const char* const board);
}
#endif /* COMMON_UTILITY_UTILITY_H_ */