implement relative timeshift #173
@ -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: {
|
||||
muellerr marked this conversation as resolved
Outdated
meggert
commented
either still dump milliseconds for P2 or change the description of the event either still dump milliseconds for P2 or change the description of the event
|
||||
@ -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;
|
||||
}
|
||||
muellerr marked this conversation as resolved
Outdated
meggert
commented
see above see above
|
||||
@ -93,12 +88,12 @@ ReturnValue_t Service9TimeManagement::setTime() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void Service9TimeManagement::reportCurrentTime() {
|
||||
void Service9TimeManagement::reportCurrentTime(Event event) {
|
||||
timeval currentTime{};
|
||||
Clock::getClock(¤tTime);
|
||||
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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user
if we are doing this twice, why did we not use the CLOCK_SET event then? it already contained old and new time. or are we really interessted in microseconds here?
events are cheap, and why lose resolution here? The correct approach probably would be to delete the weird
CLOCK_SET
event. If we still want to distinguish events which come from time changes, we could introduce,TIME_DUMP_BEFORE_CLOCK_UPDATE
andTIME_DUMP_AFTER_CLOCK_UPDATE
..I would advise splitting the events in those two types yes. Otherwise, this might be confusing for the operator. Calculating the time delta on ground is going to be more tricky now (but still possible if we store the parameter tm as actual tm). Maybe ask OPS what they prefer here
done