distinct clock dump events

This commit is contained in:
Robin Müller 2024-04-09 10:57:00 +02:00
parent 94bd1ba2ab
commit a229748aa4
2 changed files with 13 additions and 16 deletions

View File

@ -18,18 +18,13 @@ ReturnValue_t Service9TimeManagement::performService() { return returnvalue::OK;
ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
switch (subservice) {
case Subservice::SET_TIME: {
reportCurrentTime();
reportCurrentTime(CLOCK_DUMP_BEFORE_SETTING_TIME);
ReturnValue_t result = setTime();
reportCurrentTime();
reportCurrentTime(CLOCK_DUMP_AFTER_SETTING_TIME);
return result;
}
case Subservice::DUMP_TIME: {
timeval newTime;
ReturnValue_t result = Clock::getClock_timeval(&newTime);
if (result != returnvalue::OK) {
return result;
}
triggerEvent(CLOCK_DUMP, newTime.tv_sec, newTime.tv_usec);
reportCurrentTime();
return returnvalue::OK;
}
case Subservice::RELATIVE_TIMESHIFT: {
@ -38,7 +33,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
if (result != returnvalue::OK) {
return result;
}
reportTime(currentTime);
reportTime(CLOCK_DUMP_BEFORE_SETTING_TIME, currentTime);
if (currentPacket.getUserDataLen() != 8) {
return AcceptsTelecommandsIF::ILLEGAL_APPLICATION_DATA;
@ -66,7 +61,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
}
result = Clock::setClock(&newTime);
if (result == returnvalue::OK) {
reportTime(newTime);
reportTime(CLOCK_DUMP_AFTER_SETTING_TIME, newTime);
}
return result;
}
@ -93,12 +88,12 @@ ReturnValue_t Service9TimeManagement::setTime() {
return result;
}
void Service9TimeManagement::reportCurrentTime() {
void Service9TimeManagement::reportCurrentTime(Event event) {
timeval currentTime{};
Clock::getClock(&currentTime);
triggerEvent(CLOCK_DUMP, currentTime.tv_sec, currentTime.tv_usec);
triggerEvent(event, currentTime.tv_sec, currentTime.tv_usec);
}
void Service9TimeManagement::reportTime(timeval time) {
triggerEvent(CLOCK_DUMP, time.tv_sec, time.tv_usec);
void Service9TimeManagement::reportTime(Event event, timeval time) {
triggerEvent(event, time.tv_sec, time.tv_usec);
}

View File

@ -18,6 +18,8 @@ class Service9TimeManagement : public PusServiceBase {
static constexpr Event CLOCK_SET_FAILURE = MAKE_EVENT(2, severity::LOW);
//!< [EXPORT] : [COMMENT] Clock dump event. P1: timeval seconds P2: timeval microseconds.
static constexpr Event CLOCK_DUMP = MAKE_EVENT(3, severity::INFO);
static constexpr Event CLOCK_DUMP_BEFORE_SETTING_TIME = MAKE_EVENT(4, severity::INFO);
static constexpr Event CLOCK_DUMP_AFTER_SETTING_TIME = MAKE_EVENT(5, severity::INFO);
static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_9;
@ -35,8 +37,8 @@ class Service9TimeManagement : public PusServiceBase {
*/
ReturnValue_t handleRequest(uint8_t subservice) override;
void reportCurrentTime();
void reportTime(timeval time);
void reportCurrentTime(Event eventType = CLOCK_DUMP);
void reportTime(Event event, timeval time);
virtual ReturnValue_t setTime();