run afmt
This commit is contained in:
@ -11,11 +11,11 @@
|
||||
#include "objects/systemObjectList.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);
|
||||
: 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() {}
|
||||
@ -47,45 +47,43 @@ ReturnValue_t FsfwExampleTask::performOperation(uint8_t operationCode) {
|
||||
|
||||
object_id_t FsfwExampleTask::getNextRecipient() {
|
||||
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_3): {
|
||||
return objects::TEST_DUMMY_1;
|
||||
}
|
||||
default:
|
||||
return objects::TEST_DUMMY_1;
|
||||
case (objects::TEST_DUMMY_1): {
|
||||
return objects::TEST_DUMMY_2;
|
||||
}
|
||||
case (objects::TEST_DUMMY_2): {
|
||||
return objects::TEST_DUMMY_3;
|
||||
}
|
||||
case (objects::TEST_DUMMY_3): {
|
||||
return objects::TEST_DUMMY_1;
|
||||
}
|
||||
default:
|
||||
return objects::TEST_DUMMY_1;
|
||||
}
|
||||
}
|
||||
|
||||
object_id_t FsfwExampleTask::getSender() {
|
||||
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_3): {
|
||||
return objects::TEST_DUMMY_2;
|
||||
}
|
||||
default:
|
||||
return objects::TEST_DUMMY_1;
|
||||
case (objects::TEST_DUMMY_1): {
|
||||
return objects::TEST_DUMMY_3;
|
||||
}
|
||||
case (objects::TEST_DUMMY_2): {
|
||||
return objects::TEST_DUMMY_1;
|
||||
}
|
||||
case (objects::TEST_DUMMY_3): {
|
||||
return objects::TEST_DUMMY_2;
|
||||
}
|
||||
default:
|
||||
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);
|
||||
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");
|
||||
#endif
|
||||
@ -97,8 +95,7 @@ ReturnValue_t FsfwExampleTask::initialize() {
|
||||
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");
|
||||
#endif
|
||||
@ -111,45 +108,31 @@ ReturnValue_t FsfwExampleTask::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; }
|
||||
|
||||
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}));
|
||||
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);
|
||||
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;
|
||||
}
|
||||
@ -166,17 +149,13 @@ ReturnValue_t FsfwExampleTask::performMonitoringDemo() {
|
||||
|
||||
ReturnValue_t FsfwExampleTask::performSendOperation() {
|
||||
object_id_t nextRecipient = getNextRecipient();
|
||||
FsfwExampleTask *target =
|
||||
ObjectManager::instance()->get<FsfwExampleTask>(nextRecipient);
|
||||
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;
|
||||
}
|
||||
@ -187,30 +166,23 @@ ReturnValue_t FsfwExampleTask::performSendOperation() {
|
||||
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) {
|
||||
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) {
|
||||
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
|
||||
}
|
||||
|
||||
@ -225,8 +197,7 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
|
||||
while (result != MessageQueueIF::EMPTY) {
|
||||
CommandMessage receivedMessage;
|
||||
result = commandQueue->receiveMessage(&receivedMessage);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK &&
|
||||
result != MessageQueueIF::EMPTY) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK && result != MessageQueueIF::EMPTY) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "Receive failed with " << result << std::endl;
|
||||
#endif
|
||||
@ -236,9 +207,8 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
|
||||
#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;
|
||||
<< receivedMessage.getSender() << " ObjectId " << receivedMessage.getParameter()
|
||||
<< " Queue " << receivedMessage.getParameter2() << std::endl;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -252,13 +222,11 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
|
||||
}
|
||||
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()
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -266,10 +234,6 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
|
||||
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; }
|
||||
|
@ -24,10 +24,8 @@ 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:
|
||||
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;
|
||||
@ -80,7 +78,7 @@ public:
|
||||
|
||||
MessageQueueId_t getMessageQueueId();
|
||||
|
||||
private:
|
||||
private:
|
||||
LocalDataPoolManager poolManager;
|
||||
FsfwDemoSet *senderSet = nullptr;
|
||||
FsfwDemoSet demoSet;
|
||||
@ -92,9 +90,8 @@ private:
|
||||
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;
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) override;
|
||||
LocalDataPoolManager *getHkManagerHandle() override;
|
||||
|
||||
object_id_t getNextRecipient();
|
||||
|
@ -7,9 +7,10 @@
|
||||
#include <fsfw/timemanager/Stopwatch.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),
|
||||
: 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
|
||||
@ -35,14 +36,12 @@ ReturnValue_t FsfwReaderTask::performOperation(uint8_t operationCode) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
if (opDivider.checkAndIncrement() and printoutEnabled) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "FsfwPeriodicTask::performOperation: Reading variables."
|
||||
<< 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("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);
|
||||
|
@ -8,14 +8,14 @@
|
||||
#include "testdefinitions/demoDefinitions.h"
|
||||
|
||||
class FsfwReaderTask : public ExecutableObjectIF, public SystemObject {
|
||||
public:
|
||||
public:
|
||||
FsfwReaderTask(object_id_t objectId, bool enablePrintout);
|
||||
~FsfwReaderTask() override;
|
||||
|
||||
ReturnValue_t initializeAfterTaskCreation() override;
|
||||
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
bool printoutEnabled = false;
|
||||
PeriodicOperationDivider opDivider;
|
||||
CompleteDemoReadSet readSet;
|
||||
|
@ -6,16 +6,15 @@
|
||||
#include "fsfw_tests/integration/task/TestTask.h"
|
||||
|
||||
class FsfwTestTask : public TestTask {
|
||||
public:
|
||||
public:
|
||||
FsfwTestTask(object_id_t objectId, bool periodicEvent);
|
||||
|
||||
ReturnValue_t performPeriodicAction() override;
|
||||
|
||||
private:
|
||||
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);
|
||||
static constexpr Event TEST_EVENT = event::makeEvent(subsystemId, 0, severity::INFO);
|
||||
};
|
||||
|
||||
#endif /* EXAMPLE_COMMON_EXAMPLE_TEST_FSFWTESTTASK_H_ */
|
||||
|
@ -7,12 +7,10 @@ void MutexExample::example() {
|
||||
MutexIF *mutex = MutexFactory::instance()->createMutex();
|
||||
MutexIF *mutex2 = MutexFactory::instance()->createMutex();
|
||||
|
||||
ReturnValue_t result =
|
||||
mutex->lockMutex(MutexIF::TimeoutType::WAITING, 2 * 60 * 1000);
|
||||
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);
|
||||
#endif
|
||||
@ -21,8 +19,7 @@ void MutexExample::example() {
|
||||
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);
|
||||
#endif
|
||||
@ -31,8 +28,7 @@ void MutexExample::example() {
|
||||
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);
|
||||
#endif
|
||||
@ -41,8 +37,7 @@ void MutexExample::example() {
|
||||
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);
|
||||
#endif
|
||||
|
@ -15,8 +15,7 @@
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
|
||||
#define __FILENAME_REL__ (((const char *)__FILE__ + SOURCE_PATH_SIZE))
|
||||
#define __FILENAME__ \
|
||||
(strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
void fmtTests();
|
||||
|
||||
@ -29,34 +28,26 @@ static const char DEBUG_PREFIX[] = "DEBUG";
|
||||
static const char WARNING_PREFIX[] = "WARNING";
|
||||
static const char ERROR_PREFIX[] = "ERROR";
|
||||
|
||||
enum class LogLevel : unsigned int {
|
||||
DEBUG = 0,
|
||||
INFO = 1,
|
||||
WARNING = 2,
|
||||
ERROR = 3
|
||||
};
|
||||
enum class LogLevel : unsigned int { DEBUG = 0, INFO = 1, WARNING = 2, ERROR = 3 };
|
||||
|
||||
static const char *PREFIX_ARR[4] = {DEBUG_PREFIX, INFO_PREFIX, WARNING_PREFIX,
|
||||
ERROR_PREFIX};
|
||||
static const char *PREFIX_ARR[4] = {DEBUG_PREFIX, INFO_PREFIX, WARNING_PREFIX, ERROR_PREFIX};
|
||||
|
||||
static const std::array<fmt::color, 4> LOG_COLOR_ARR = {
|
||||
fmt::color::deep_sky_blue, fmt::color::forest_green, fmt::color::orange_red,
|
||||
fmt::color::red};
|
||||
fmt::color::deep_sky_blue, fmt::color::forest_green, fmt::color::orange_red, fmt::color::red};
|
||||
|
||||
static MutexIF *PRINT_MUTEX = MutexFactory::instance()->createMutex();
|
||||
|
||||
static size_t writeTypePrefix(LogLevel level) {
|
||||
auto idx = static_cast<unsigned int>(level);
|
||||
const auto result = fmt::format_to_n(
|
||||
PRINT_BUF.begin(), PRINT_BUF.size() - 1,
|
||||
fmt::runtime(fmt::format(fg(LOG_COLOR_ARR[idx]), PREFIX_ARR[idx])));
|
||||
const auto result =
|
||||
fmt::format_to_n(PRINT_BUF.begin(), PRINT_BUF.size() - 1,
|
||||
fmt::runtime(fmt::format(fg(LOG_COLOR_ARR[idx]), PREFIX_ARR[idx])));
|
||||
return result.size;
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
size_t logTraced(LogLevel level, const char *file, unsigned int line,
|
||||
bool timed, fmt::format_string<T...> fmt,
|
||||
T &&...args) noexcept {
|
||||
size_t logTraced(LogLevel level, const char *file, unsigned int line, bool timed,
|
||||
fmt::format_string<T...> fmt, T &&...args) noexcept {
|
||||
try {
|
||||
MutexGuard mg(PRINT_MUTEX);
|
||||
size_t bufPos = writeTypePrefix(level);
|
||||
@ -64,17 +55,16 @@ size_t logTraced(LogLevel level, const char *file, unsigned int line,
|
||||
if (timed) {
|
||||
Clock::TimeOfDay_t logTime;
|
||||
Clock::getDateAndTime(&logTime);
|
||||
const auto result =
|
||||
fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos,
|
||||
" | {}[l.{}] | {:02}:{:02}:{:02}.{:03} | {}", file,
|
||||
line, logTime.hour, logTime.minute, logTime.second,
|
||||
logTime.usecond / 1000, fmt::format(fmt, args...));
|
||||
const auto result = fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos,
|
||||
" | {}[l.{}] | {:02}:{:02}:{:02}.{:03} | {}", file, line,
|
||||
logTime.hour, logTime.minute, logTime.second,
|
||||
logTime.usecond / 1000, fmt::format(fmt, args...));
|
||||
*result.out = '\0';
|
||||
bufPos += result.size;
|
||||
} else {
|
||||
const auto result = fmt::format_to_n(
|
||||
currentIter, PRINT_BUF.size() - 1 - bufPos, " | {}[l.{}] | {}", file,
|
||||
line, fmt::format(fmt, args...));
|
||||
const auto result =
|
||||
fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos, " | {}[l.{}] | {}", file,
|
||||
line, fmt::format(fmt, args...));
|
||||
*result.out = '\0';
|
||||
bufPos += result.size;
|
||||
}
|
||||
@ -88,8 +78,7 @@ size_t logTraced(LogLevel level, const char *file, unsigned int line,
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
size_t log(LogLevel level, bool timed, fmt::format_string<T...> fmt,
|
||||
T &&...args) noexcept {
|
||||
size_t log(LogLevel level, bool timed, fmt::format_string<T...> fmt, T &&...args) noexcept {
|
||||
try {
|
||||
MutexGuard mg(PRINT_MUTEX);
|
||||
size_t bufPos = writeTypePrefix(level);
|
||||
@ -98,9 +87,8 @@ size_t log(LogLevel level, bool timed, fmt::format_string<T...> fmt,
|
||||
Clock::TimeOfDay_t logTime;
|
||||
Clock::getDateAndTime(&logTime);
|
||||
const auto result = fmt::format_to_n(
|
||||
currentIter, PRINT_BUF.size() - bufPos,
|
||||
" | {:02}:{:02}:{:02}.{:03} | {}", logTime.hour, logTime.minute,
|
||||
logTime.second, logTime.usecond / 1000, fmt::format(fmt, args...));
|
||||
currentIter, PRINT_BUF.size() - bufPos, " | {:02}:{:02}:{:02}.{:03} | {}", logTime.hour,
|
||||
logTime.minute, logTime.second, logTime.usecond / 1000, fmt::format(fmt, args...));
|
||||
bufPos += result.size;
|
||||
}
|
||||
fmt::print(fmt::runtime(PRINT_BUF.data()));
|
||||
@ -128,56 +116,47 @@ void finfo_t(fmt::format_string<T...> fmt, T &&...args) {
|
||||
log(LogLevel::INFO, true, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T> void finfo(fmt::format_string<T...> fmt, T &&...args) {
|
||||
template <typename... T>
|
||||
void finfo(fmt::format_string<T...> fmt, T &&...args) {
|
||||
log(LogLevel::INFO, false, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void fwarning(const char *file, unsigned int line, fmt::format_string<T...> fmt,
|
||||
T &&...args) {
|
||||
void fwarning(const char *file, unsigned int line, fmt::format_string<T...> fmt, T &&...args) {
|
||||
logTraced(LogLevel::WARNING, file, line, false, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void fwarning_t(const char *file, unsigned int line,
|
||||
fmt::format_string<T...> fmt, T &&...args) {
|
||||
void fwarning_t(const char *file, unsigned int line, fmt::format_string<T...> fmt, T &&...args) {
|
||||
logTraced(LogLevel::WARNING, file, line, true, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void ferror(const char *file, unsigned int line, fmt::format_string<T...> fmt,
|
||||
T &&...args) {
|
||||
void ferror(const char *file, unsigned int line, fmt::format_string<T...> fmt, T &&...args) {
|
||||
logTraced(LogLevel::ERROR, file, line, false, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void ferror_t(const char *file, unsigned int line, fmt::format_string<T...> fmt,
|
||||
T &&...args) {
|
||||
void ferror_t(const char *file, unsigned int line, fmt::format_string<T...> fmt, T &&...args) {
|
||||
logTraced(LogLevel::ERROR, file, line, true, fmt, args...);
|
||||
}
|
||||
|
||||
} // namespace sif
|
||||
} // namespace sif
|
||||
|
||||
#define FSFW_LOGI(format, ...) finfo(FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGIT(format, ...) finfo_t(FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGD(format, ...) \
|
||||
sif::fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGD(format, ...) sif::fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGDT(format, ...) \
|
||||
fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGDT(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGW(format, ...) \
|
||||
fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGW(format, ...) fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGWT(format, ...) \
|
||||
fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGWT(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGE(format, ...) \
|
||||
fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGE(format, ...) fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGET(format, ...) \
|
||||
fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGET(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#endif // FSFW_EXAMPLE_HOSTED_TESTFMT_H
|
||||
#endif // FSFW_EXAMPLE_HOSTED_TESTFMT_H
|
||||
|
@ -12,22 +12,21 @@
|
||||
* pool variables (for read and write access respectively).
|
||||
*/
|
||||
class FsfwDemoSet : public StaticLocalDataSet<3> {
|
||||
public:
|
||||
public:
|
||||
static constexpr uint32_t DEMO_SET_ID = 0;
|
||||
|
||||
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<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:
|
||||
private:
|
||||
};
|
||||
|
||||
/**
|
||||
@ -36,11 +35,10 @@ private:
|
||||
* which reads multiple sensor values at once.
|
||||
*/
|
||||
class CompleteDemoReadSet : public StaticLocalDataSet<3> {
|
||||
public:
|
||||
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)
|
||||
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),
|
||||
@ -50,7 +48,7 @@ public:
|
||||
lp_var_t<uint32_t> variable2;
|
||||
lp_var_t<uint32_t> variable3;
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEMO_DEMODEFINITIONS_H_ */
|
||||
|
Reference in New Issue
Block a user