implement relative timeshift #173
@ -2,10 +2,9 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "fsfw/events/EventManagerIF.h"
|
||||
#include "fsfw/pus/servicepackets/Service9Packets.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/serialize/SerializeAdapter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/timemanager/CCSDSTime.h"
|
||||
|
||||
Service9TimeManagement::Service9TimeManagement(PsbParams params) : PusServiceBase(params) {
|
||||
@ -19,7 +18,10 @@ ReturnValue_t Service9TimeManagement::performService() { return returnvalue::OK;
|
||||
ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
|
||||
switch (subservice) {
|
||||
case Subservice::SET_TIME: {
|
||||
return setTime();
|
||||
reportCurrentTime();
|
||||
ReturnValue_t result = setTime();
|
||||
reportCurrentTime();
|
||||
|
||||
return result;
|
||||
}
|
||||
case Subservice::DUMP_TIME: {
|
||||
timeval newTime;
|
||||
@ -36,6 +38,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
triggerEvent(CLOCK_DUMP, currentTime.tv_sec, currentTime.tv_usec);
|
||||
|
||||
if (currentPacket.getUserDataLen() != 8) {
|
||||
return AcceptsTelecommandsIF::ILLEGAL_APPLICATION_DATA;
|
||||
@ -63,8 +66,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
|
||||
}
|
||||
result = Clock::setClock(&newTime);
|
||||
muellerr marked this conversation as resolved
Outdated
meggert
commented
see above see above
|
||||
if (result == returnvalue::OK) {
|
||||
// Report new time as event.
|
||||
triggerEvent(CLOCK_DUMP, newTime.tv_sec, newTime.tv_usec);
|
||||
reportTime(newTime);
|
||||
meggert
commented
the same here the same here
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -83,17 +85,20 @@ ReturnValue_t Service9TimeManagement::setTime() {
|
||||
return result;
|
||||
}
|
||||
|
||||
timeval time;
|
||||
Clock::getClock_timeval(&time);
|
||||
result = Clock::setClock(&timeToSet);
|
||||
|
||||
if (result == returnvalue::OK) {
|
||||
timeval newTime;
|
||||
Clock::getClock_timeval(&newTime);
|
||||
triggerEvent(CLOCK_SET, time.tv_sec, newTime.tv_sec);
|
||||
return returnvalue::OK;
|
||||
} else {
|
||||
if (result != returnvalue::OK) {
|
||||
triggerEvent(CLOCK_SET_FAILURE, result, 0);
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Service9TimeManagement::reportCurrentTime() {
|
||||
timeval currentTime{};
|
||||
Clock::getClock_timeval(¤tTime);
|
||||
triggerEvent(CLOCK_DUMP, currentTime.tv_sec, currentTime.tv_usec);
|
||||
}
|
||||
|
||||
void Service9TimeManagement::reportTime(timeval time) {
|
||||
triggerEvent(CLOCK_DUMP, time.tv_sec, time.tv_usec);
|
||||
meggert
commented
best function ever best function ever
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
#ifndef FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_
|
||||
#define FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_
|
||||
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/tmtcservices/PusServiceBase.h"
|
||||
|
||||
class Service9TimeManagement : public PusServiceBase {
|
||||
public:
|
||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_9;
|
||||
|
||||
static constexpr uint32_t NANOS_PER_SECOND= 1'000'000'000;
|
||||
static constexpr uint32_t NANOS_PER_SECOND = 1'000'000'000;
|
||||
|
||||
//!< Clock has been set. P1: old timeval seconds. P2: new timeval seconds.
|
||||
static constexpr Event CLOCK_SET = MAKE_EVENT(0, severity::INFO);
|
||||
@ -32,6 +33,9 @@ class Service9TimeManagement : public PusServiceBase {
|
||||
*/
|
||||
ReturnValue_t handleRequest(uint8_t subservice) override;
|
||||
|
||||
void reportCurrentTime();
|
||||
void reportTime(timeval time);
|
||||
|
||||
virtual ReturnValue_t setTime();
|
||||
|
||||
private:
|
||||
|
Loading…
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