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);
|
||||
if (result == returnvalue::OK) {
|
||||
// Report new time as event.
|
||||
triggerEvent(CLOCK_DUMP, newTime.tv_sec, newTime.tv_usec);
|
||||
reportTime(newTime);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -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