timemanager update
This commit is contained in:
parent
5ba1932076
commit
c8ddfe598b
@ -1,9 +1,9 @@
|
|||||||
#include "CCSDSTime.h"
|
#include "CCSDSTime.h"
|
||||||
|
#include <FSFWConfig.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <FSFWConfig.h>
|
|
||||||
|
|
||||||
CCSDSTime::CCSDSTime() {
|
CCSDSTime::CCSDSTime() {
|
||||||
}
|
}
|
||||||
@ -53,8 +53,8 @@ ReturnValue_t CCSDSTime::convertToCcsds(Ccs_mseconds* to,
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, const uint8_t* from,
|
ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to,
|
||||||
uint32_t length) {
|
const uint8_t* from, size_t length) {
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
if (length > 0xFF) {
|
if (length > 0xFF) {
|
||||||
return LENGTH_MISMATCH;
|
return LENGTH_MISMATCH;
|
||||||
@ -72,7 +72,7 @@ ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, const uint8_t*
|
|||||||
case CDS:
|
case CDS:
|
||||||
return convertFromCDS(to, from, length);
|
return convertFromCDS(to, from, length);
|
||||||
case CCS: {
|
case CCS: {
|
||||||
uint32_t temp = 0;
|
size_t temp = 0;
|
||||||
return convertFromCCS(to, from, &temp, length);
|
return convertFromCCS(to, from, &temp, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,13 +81,13 @@ ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, const uint8_t*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSTime::convertFromCUC(Clock::TimeOfDay_t* to, const uint8_t* from,
|
ReturnValue_t CCSDSTime::convertFromCUC(Clock::TimeOfDay_t* to,
|
||||||
uint8_t length) {
|
const uint8_t* from, uint8_t length) {
|
||||||
return UNSUPPORTED_TIME_FORMAT;
|
return UNSUPPORTED_TIME_FORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to, const uint8_t* from,
|
ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to,
|
||||||
uint8_t length) {
|
const uint8_t* from, uint8_t length) {
|
||||||
timeval time;
|
timeval time;
|
||||||
ReturnValue_t result = convertFromCDS(&time, from, NULL, length);
|
ReturnValue_t result = convertFromCDS(&time, from, NULL, length);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
@ -96,8 +96,8 @@ ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to, const uint8_t* f
|
|||||||
return convertTimevalToTimeOfDay(to, &time);
|
return convertTimevalToTimeOfDay(to, &time);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* from,
|
ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to,
|
||||||
uint32_t* foundLength, uint32_t maxLength) {
|
const uint8_t* from, size_t* foundLength, size_t maxLength) {
|
||||||
uint8_t subsecondsLength = *from & 0b111;
|
uint8_t subsecondsLength = *from & 0b111;
|
||||||
uint32_t totalLength = subsecondsLength + 8;
|
uint32_t totalLength = subsecondsLength + 8;
|
||||||
if (maxLength < totalLength) {
|
if (maxLength < totalLength) {
|
||||||
@ -152,8 +152,8 @@ ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* f
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* from,
|
ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to,
|
||||||
uint8_t length) {
|
const uint8_t* from, uint8_t length) {
|
||||||
if (length < 19) {
|
if (length < 19) {
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
@ -395,7 +395,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(OBT_FLP* to, const timeval* from) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from,
|
ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from,
|
||||||
uint32_t* foundLength, uint32_t maxLength) {
|
size_t* foundLength, size_t maxLength) {
|
||||||
//We don't expect ascii here. SHOULDDO
|
//We don't expect ascii here. SHOULDDO
|
||||||
uint8_t codeIdentification = (*from >> 4);
|
uint8_t codeIdentification = (*from >> 4);
|
||||||
switch (codeIdentification) {
|
switch (codeIdentification) {
|
||||||
@ -413,7 +413,7 @@ ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, const uint8_t* from,
|
ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, const uint8_t* from,
|
||||||
uint32_t* foundLength, uint32_t maxLength) {
|
size_t* foundLength, size_t maxLength) {
|
||||||
if (maxLength < 1) {
|
if (maxLength < 1) {
|
||||||
return INVALID_TIME_FORMAT;
|
return INVALID_TIME_FORMAT;
|
||||||
}
|
}
|
||||||
@ -491,7 +491,7 @@ ReturnValue_t CCSDSTime::convertTimevalToTimeOfDay(Clock::TimeOfDay_t* to,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from,
|
ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from,
|
||||||
uint32_t* foundLength, uint32_t maxLength) {
|
size_t* foundLength, size_t maxLength) {
|
||||||
uint8_t pField = *from;
|
uint8_t pField = *from;
|
||||||
from++;
|
from++;
|
||||||
//Check epoch
|
//Check epoch
|
||||||
@ -556,12 +556,12 @@ ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, uint8_t pField,
|
ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, uint8_t pField,
|
||||||
const uint8_t* from, uint32_t* foundLength, uint32_t maxLength) {
|
const uint8_t* from, size_t* foundLength, size_t maxLength) {
|
||||||
uint32_t secs = 0;
|
uint32_t secs = 0;
|
||||||
uint32_t subSeconds = 0;
|
uint32_t subSeconds = 0;
|
||||||
uint8_t nCoarse = ((pField & 0b1100) >> 2) + 1;
|
uint8_t nCoarse = ((pField & 0b1100) >> 2) + 1;
|
||||||
uint8_t nFine = (pField & 0b11);
|
uint8_t nFine = (pField & 0b11);
|
||||||
uint32_t totalLength = nCoarse + nFine;
|
size_t totalLength = nCoarse + nFine;
|
||||||
if (foundLength != NULL) {
|
if (foundLength != NULL) {
|
||||||
*foundLength = totalLength;
|
*foundLength = totalLength;
|
||||||
}
|
}
|
||||||
@ -593,7 +593,7 @@ uint32_t CCSDSTime::subsecondsToMicroseconds(uint16_t subseconds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CCSDSTime::convertFromCCS(timeval* to, const uint8_t* from,
|
ReturnValue_t CCSDSTime::convertFromCCS(timeval* to, const uint8_t* from,
|
||||||
uint32_t* foundLength, uint32_t maxLength) {
|
size_t* foundLength, size_t maxLength) {
|
||||||
Clock::TimeOfDay_t tempTime;
|
Clock::TimeOfDay_t tempTime;
|
||||||
ReturnValue_t result = convertFromCCS(&tempTime, from, foundLength,
|
ReturnValue_t result = convertFromCCS(&tempTime, from, foundLength,
|
||||||
maxLength);
|
maxLength);
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#ifndef CCSDSTIME_H_
|
#ifndef FSFW_TIMEMANAGER_CCSDSTIME_H_
|
||||||
#define CCSDSTIME_H_
|
#define FSFW_TIMEMANAGER_CCSDSTIME_H_
|
||||||
|
|
||||||
// COULDDO: have calls in Clock.h which return time quality and use timespec accordingly
|
// COULDDO: have calls in Clock.h which return time quality and use timespec accordingly
|
||||||
|
|
||||||
#include "Clock.h"
|
#include "Clock.h"
|
||||||
|
#include "clockDefinitions.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
@ -154,8 +155,8 @@ public:
|
|||||||
* - @c LENGTH_MISMATCH if the length does not match the P Field
|
* - @c LENGTH_MISMATCH if the length does not match the P Field
|
||||||
* - @c INVALID_TIME_FORMAT if the format or a value is invalid
|
* - @c INVALID_TIME_FORMAT if the format or a value is invalid
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t convertFromCcsds(Clock::TimeOfDay_t *to, uint8_t const *from,
|
static ReturnValue_t convertFromCcsds(Clock::TimeOfDay_t *to,
|
||||||
uint32_t length);
|
uint8_t const *from, size_t length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* not implemented yet
|
* not implemented yet
|
||||||
@ -165,34 +166,34 @@ public:
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t convertFromCcsds(timeval *to, uint8_t const *from,
|
static ReturnValue_t convertFromCcsds(timeval *to, uint8_t const *from,
|
||||||
uint32_t* foundLength, uint32_t maxLength);
|
size_t* foundLength, size_t maxLength);
|
||||||
|
|
||||||
static ReturnValue_t convertFromCUC(Clock::TimeOfDay_t *to, uint8_t const *from,
|
static ReturnValue_t convertFromCUC(Clock::TimeOfDay_t *to,
|
||||||
uint8_t length);
|
uint8_t const *from, uint8_t length);
|
||||||
|
|
||||||
static ReturnValue_t convertFromCUC(timeval *to, uint8_t const *from,
|
static ReturnValue_t convertFromCUC(timeval *to, uint8_t const *from,
|
||||||
uint32_t* foundLength, uint32_t maxLength);
|
size_t* foundLength, size_t maxLength);
|
||||||
|
|
||||||
static ReturnValue_t convertFromCUC(timeval *to, uint8_t pField,
|
static ReturnValue_t convertFromCUC(timeval *to, uint8_t pField,
|
||||||
uint8_t const *from, uint32_t* foundLength, uint32_t maxLength);
|
uint8_t const *from, size_t* foundLength, size_t maxLength);
|
||||||
|
|
||||||
static ReturnValue_t convertFromCCS(timeval *to, uint8_t const *from,
|
static ReturnValue_t convertFromCCS(timeval *to, uint8_t const *from,
|
||||||
uint32_t* foundLength, uint32_t maxLength);
|
size_t* foundLength, size_t maxLength);
|
||||||
|
|
||||||
static ReturnValue_t convertFromCCS(timeval *to, uint8_t pField,
|
static ReturnValue_t convertFromCCS(timeval *to, uint8_t pField,
|
||||||
uint8_t const *from, uint32_t* foundLength, uint32_t maxLength);
|
uint8_t const *from, size_t* foundLength, size_t maxLength);
|
||||||
|
|
||||||
static ReturnValue_t convertFromCDS(Clock::TimeOfDay_t *to, uint8_t const *from,
|
static ReturnValue_t convertFromCDS(Clock::TimeOfDay_t *to,
|
||||||
uint8_t length);
|
uint8_t const *from, uint8_t length);
|
||||||
|
|
||||||
static ReturnValue_t convertFromCDS(timeval *to, uint8_t const *from,
|
static ReturnValue_t convertFromCDS(timeval *to, uint8_t const *from,
|
||||||
uint32_t* foundLength, uint32_t maxLength);
|
size_t* foundLength, size_t maxLength);
|
||||||
|
|
||||||
static ReturnValue_t convertFromCCS(Clock::TimeOfDay_t *to, uint8_t const *from,
|
static ReturnValue_t convertFromCCS(Clock::TimeOfDay_t *to,
|
||||||
uint32_t* foundLength, uint32_t maxLength);
|
uint8_t const *from, size_t* foundLength, size_t maxLength);
|
||||||
|
|
||||||
static ReturnValue_t convertFromASCII(Clock::TimeOfDay_t *to, uint8_t const *from,
|
static ReturnValue_t convertFromASCII(Clock::TimeOfDay_t *to,
|
||||||
uint8_t length);
|
uint8_t const *from, uint8_t length);
|
||||||
|
|
||||||
static uint32_t subsecondsToMicroseconds(uint16_t subseconds);
|
static uint32_t subsecondsToMicroseconds(uint16_t subseconds);
|
||||||
private:
|
private:
|
||||||
@ -230,4 +231,4 @@ private:
|
|||||||
timeval* from);
|
timeval* from);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CCSDSTIME_H_ */
|
#endif /* FSFW_TIMEMANAGER_CCSDSTIME_H_ */
|
||||||
|
@ -1,153 +1,166 @@
|
|||||||
#ifndef FSFW_TIMEMANAGER_CLOCK_H_
|
#ifndef FSFW_TIMEMANAGER_CLOCK_H_
|
||||||
#define FSFW_TIMEMANAGER_CLOCK_H_
|
#define FSFW_TIMEMANAGER_CLOCK_H_
|
||||||
|
|
||||||
|
#include "clockDefinitions.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "../ipc/MutexHelper.h"
|
#include "../ipc/MutexFactory.h"
|
||||||
#include "../globalfunctions/timevalOperations.h"
|
#include "../globalfunctions/timevalOperations.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
//! Don't use these for time points, type is not large enough for UNIX epoch.
|
|
||||||
using dur_millis_t = uint32_t;
|
|
||||||
|
|
||||||
class Clock {
|
class Clock {
|
||||||
public:
|
public:
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t year; //!< Year, A.D.
|
uint32_t year; //!< Year, A.D.
|
||||||
uint32_t month; //!< Month, 1 .. 12.
|
uint32_t month; //!< Month, 1 .. 12.
|
||||||
uint32_t day; //!< Day, 1 .. 31.
|
uint32_t day; //!< Day, 1 .. 31.
|
||||||
uint32_t hour; //!< Hour, 0 .. 23.
|
uint32_t hour; //!< Hour, 0 .. 23.
|
||||||
uint32_t minute; //!< Minute, 0 .. 59.
|
uint32_t minute; //!< Minute, 0 .. 59.
|
||||||
uint32_t second; //!< Second, 0 .. 59.
|
uint32_t second; //!< Second, 0 .. 59.
|
||||||
uint32_t usecond; //!< Microseconds, 0 .. 999999
|
uint32_t usecond; //!< Microseconds, 0 .. 999999
|
||||||
} TimeOfDay_t;
|
} TimeOfDay_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the number of clock ticks per second.
|
* This method returns the number of clock ticks per second.
|
||||||
* In RTEMS, this is typically 1000.
|
* In RTEMS, this is typically 1000.
|
||||||
* @return The number of ticks.
|
* @return The number of ticks.
|
||||||
*
|
*
|
||||||
* @deprecated, we should not worry about ticks, but only time
|
* @deprecated, we should not worry about ticks, but only time
|
||||||
*/
|
*/
|
||||||
static uint32_t getTicksPerSecond(void);
|
static uint32_t getTicksPerSecond(void);
|
||||||
/**
|
/**
|
||||||
* This system call sets the system time.
|
* This system call sets the system time.
|
||||||
* To set the time, it uses a TimeOfDay_t struct.
|
* To set the time, it uses a TimeOfDay_t struct.
|
||||||
* @param time The struct with the time settings to set.
|
* @param time The struct with the time settings to set.
|
||||||
* @return -@c RETURN_OK on success. Otherwise, the OS failure code
|
* @return -@c RETURN_OK on success. Otherwise, the OS failure code
|
||||||
* is returned.
|
* is returned.
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t setClock(const TimeOfDay_t* time);
|
static ReturnValue_t setClock(const TimeOfDay_t* time);
|
||||||
/**
|
/**
|
||||||
* This system call sets the system time.
|
* This system call sets the system time.
|
||||||
* To set the time, it uses a timeval struct.
|
* To set the time, it uses a timeval struct.
|
||||||
* @param time The struct with the time settings to set.
|
* @param time The struct with the time settings to set.
|
||||||
* @return -@c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
* @return -@c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t setClock(const timeval* time);
|
static ReturnValue_t setClock(const timeval* time);
|
||||||
/**
|
/**
|
||||||
* This system call returns the current system clock in timeval format.
|
* This system call returns the current system clock in timeval format.
|
||||||
* The timval format has the fields @c tv_sec with seconds and @c tv_usec with
|
* The timval format has the fields @c tv_sec with seconds and @c tv_usec with
|
||||||
* microseconds since an OS-defined epoch.
|
* microseconds since an OS-defined epoch.
|
||||||
* @param time A pointer to a timeval struct where the current time is stored.
|
* @param time A pointer to a timeval struct where the current time is stored.
|
||||||
* @return @c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
* @return @c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t getClock_timeval(timeval* time);
|
static ReturnValue_t getClock_timeval(timeval* time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the time since boot in a timeval struct
|
* Get the time since boot in a timeval struct
|
||||||
*
|
*
|
||||||
* @param[out] time A pointer to a timeval struct where the uptime is stored.
|
* @param[out] time A pointer to a timeval struct where the uptime is stored.
|
||||||
* @return @c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
* @return @c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
||||||
*
|
*
|
||||||
* @deprecated, I do not think this should be able to fail, use timeval getUptime()
|
* @deprecated, I do not think this should be able to fail, use timeval getUptime()
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t getUptime(timeval* uptime);
|
static ReturnValue_t getUptime(timeval* uptime);
|
||||||
|
|
||||||
static timeval getUptime();
|
static timeval getUptime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the time since boot in milliseconds
|
* Get the time since boot in milliseconds
|
||||||
*
|
*
|
||||||
* This value can overflow! Still, it can be used to calculate time intervalls
|
* This value can overflow! Still, it can be used to calculate time intervalls
|
||||||
* between two calls up to 49 days by always using uint32_t in the calculation
|
* between two calls up to 49 days by always using uint32_t in the calculation
|
||||||
*
|
*
|
||||||
* @param ms uptime in ms
|
* @param ms uptime in ms
|
||||||
* @return RETURN_OK on success. Otherwise, the OS failure code is returned.
|
* @return RETURN_OK on success. Otherwise, the OS failure code is returned.
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t getUptime(uint32_t* uptimeMs);
|
static ReturnValue_t getUptime(uint32_t* uptimeMs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the time in microseconds since an OS-defined epoch.
|
* Returns the time in microseconds since an OS-defined epoch.
|
||||||
* The time is returned in a 64 bit unsigned integer.
|
* The time is returned in a 64 bit unsigned integer.
|
||||||
* @param time A pointer to a 64 bit unisigned integer where the data is stored.
|
* @param time A pointer to a 64 bit unisigned integer where the data is stored.
|
||||||
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
* @return
|
||||||
*/
|
* - @c RETURN_OK on success.
|
||||||
static ReturnValue_t getClock_usecs(uint64_t* time);
|
* - Otherwise, the OS failure code is returned.
|
||||||
/**
|
*/
|
||||||
* Returns the time in a TimeOfDay_t struct.
|
static ReturnValue_t getClock_usecs(uint64_t* time);
|
||||||
* @param time A pointer to a TimeOfDay_t struct.
|
/**
|
||||||
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
* Returns the time in a TimeOfDay_t struct.
|
||||||
*/
|
* @param time A pointer to a TimeOfDay_t struct.
|
||||||
static ReturnValue_t getDateAndTime(TimeOfDay_t* time);
|
* @return
|
||||||
|
* - @c RETURN_OK on success.
|
||||||
|
* - Otherwise, the OS failure code is returned.
|
||||||
|
*/
|
||||||
|
static ReturnValue_t getDateAndTime(TimeOfDay_t* time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a time of day struct to POSIX seconds.
|
* Converts a time of day struct to POSIX seconds.
|
||||||
* @param time The time of day as input
|
* @param time The time of day as input
|
||||||
* @param timeval The corresponding seconds since the epoch.
|
* @param timeval The corresponding seconds since the epoch.
|
||||||
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
* @return
|
||||||
*/
|
* - @c RETURN_OK on success.
|
||||||
static ReturnValue_t convertTimeOfDayToTimeval(const TimeOfDay_t* from,
|
* - Otherwise, the OS failure code is returned.
|
||||||
timeval* to);
|
*/
|
||||||
|
static ReturnValue_t convertTimeOfDayToTimeval(const TimeOfDay_t* from,
|
||||||
|
timeval* to);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a time represented as seconds and subseconds since unix epoch to days since J2000
|
* Converts a time represented as seconds and subseconds since unix
|
||||||
*
|
* epoch to days since J2000
|
||||||
* @param time seconds since unix epoch
|
*
|
||||||
* @param[out] JD2000 days since J2000
|
* @param time seconds since unix epoch
|
||||||
* @return \c RETURN_OK
|
* @param[out] JD2000 days since J2000
|
||||||
*/
|
* @return @c RETURN_OK
|
||||||
static ReturnValue_t convertTimevalToJD2000(timeval time, double* JD2000);
|
*/
|
||||||
|
static ReturnValue_t convertTimevalToJD2000(timeval time, double* JD2000);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates and adds the offset between UTC and TT
|
* Calculates and adds the offset between UTC and TT
|
||||||
*
|
*
|
||||||
* Depends on the leap seconds to be set correctly.
|
* Depends on the leap seconds to be set correctly.
|
||||||
*
|
*
|
||||||
* @param utc timeval, corresponding to UTC time
|
* @param utc timeval, corresponding to UTC time
|
||||||
* @param[out] tt timeval, corresponding to Terrestial Time
|
* @param[out] tt timeval, corresponding to Terrestial Time
|
||||||
* @return \c RETURN_OK on success, \c RETURN_FAILED if leapSeconds are not set
|
* @return
|
||||||
*/
|
* - @c RETURN_OK on success
|
||||||
static ReturnValue_t convertUTCToTT(timeval utc, timeval* tt);
|
* - @c RETURN_FAILED if leapSeconds are not set
|
||||||
|
*/
|
||||||
|
static ReturnValue_t convertUTCToTT(timeval utc, timeval* tt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Leap Seconds since 1972
|
* Set the Leap Seconds since 1972
|
||||||
*
|
*
|
||||||
* @param leapSeconds_
|
* @param leapSeconds_
|
||||||
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
* @return
|
||||||
*/
|
* - @c RETURN_OK on success.
|
||||||
static ReturnValue_t setLeapSeconds(const uint16_t leapSeconds_);
|
* - Otherwise, the OS failure code is returned.
|
||||||
|
*/
|
||||||
|
static ReturnValue_t setLeapSeconds(const uint16_t leapSeconds_);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Leap Seconds since 1972
|
* Get the Leap Seconds since 1972
|
||||||
*
|
*
|
||||||
* Must be set before!
|
* Must be set before!
|
||||||
*
|
*
|
||||||
* @param[out] leapSeconds_
|
* @param[out] leapSeconds_
|
||||||
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
* @return
|
||||||
*/
|
* - @c RETURN_OK on success.
|
||||||
static ReturnValue_t getLeapSeconds(uint16_t *leapSeconds_);
|
* - Otherwise, the OS failure code is returned.
|
||||||
|
*/
|
||||||
|
static ReturnValue_t getLeapSeconds(uint16_t *leapSeconds_);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to check and create the Mutex for the clock
|
* Function to check and create the Mutex for the clock
|
||||||
* @return \c RETURN_OK on success. Otherwise \c RETURN_FAILED if not able to create one
|
* @return
|
||||||
*/
|
* - @c RETURN_OK on success.
|
||||||
static ReturnValue_t checkOrCreateClockMutex();
|
* - Otherwise @c RETURN_FAILED if not able to create one
|
||||||
|
*/
|
||||||
|
static ReturnValue_t checkOrCreateClockMutex();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static MutexIF* timeMutex;
|
static MutexIF* timeMutex;
|
||||||
static uint16_t leapSeconds;
|
static uint16_t leapSeconds;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,14 +1,6 @@
|
|||||||
/**
|
|
||||||
* @file Countdown.cpp
|
|
||||||
* @brief This file defines the Countdown class.
|
|
||||||
* @date 21.03.2013
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "Countdown.h"
|
#include "Countdown.h"
|
||||||
|
|
||||||
Countdown::Countdown(uint32_t initialTimeout) : startTime(0), timeout(initialTimeout) {
|
Countdown::Countdown(uint32_t initialTimeout): timeout(initialTimeout) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Countdown::~Countdown() {
|
Countdown::~Countdown() {
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
/**
|
#ifndef FSFW_TIMEMANAGER_COUNTDOWN_H_
|
||||||
* @file Countdown.h
|
#define FSFW_TIMEMANAGER_COUNTDOWN_H_
|
||||||
* @brief This file defines the Countdown class.
|
|
||||||
* @date 21.03.2013
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COUNTDOWN_H_
|
|
||||||
#define COUNTDOWN_H_
|
|
||||||
|
|
||||||
#include "Clock.h"
|
#include "Clock.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This file defines the Countdown class.
|
||||||
|
* @author baetz
|
||||||
|
*/
|
||||||
class Countdown {
|
class Countdown {
|
||||||
private:
|
|
||||||
uint32_t startTime;
|
|
||||||
public:
|
public:
|
||||||
uint32_t timeout;
|
uint32_t timeout;
|
||||||
Countdown(uint32_t initialTimeout = 0);
|
Countdown(uint32_t initialTimeout = 0);
|
||||||
@ -23,9 +18,14 @@ public:
|
|||||||
|
|
||||||
bool isBusy() const;
|
bool isBusy() const;
|
||||||
|
|
||||||
ReturnValue_t resetTimer(); //!< Use last set timeout value and restart timer.
|
//!< Use last set timeout value and restart timer.
|
||||||
|
ReturnValue_t resetTimer();
|
||||||
|
|
||||||
void timeOut(); //!< Make hasTimedOut() return true
|
//!< Make hasTimedOut() return true
|
||||||
|
void timeOut();
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t startTime = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* COUNTDOWN_H_ */
|
#endif /* FSFW_TIMEMANAGER_COUNTDOWN_H_ */
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
/**
|
#ifndef FSFW_TIMEMANAGER_RECEIVESTIMEINFOIF_H_
|
||||||
* @file ReceivesTimeInfoIF.h
|
#define FSFW_TIMEMANAGER_RECEIVESTIMEINFOIF_H_
|
||||||
* @brief This file defines the ReceivesTimeInfoIF class.
|
|
||||||
* @date 26.02.2013
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef RECEIVESTIMEINFOIF_H_
|
#include "../ipc/MessageQueueSenderIF.h"
|
||||||
#define RECEIVESTIMEINFOIF_H_
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a Interface for classes that receive timing information
|
* This is a Interface for classes that receive timing information
|
||||||
@ -28,4 +23,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* RECEIVESTIMEINFOIF_H_ */
|
#endif /* FSFW_TIMEMANAGER_RECEIVESTIMEINFOIF_H_ */
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
/**
|
|
||||||
* @file TimeMessage.cpp
|
|
||||||
* @brief This file defines the TimeMessage class.
|
|
||||||
* @date 26.02.2013
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "TimeMessage.h"
|
#include "TimeMessage.h"
|
||||||
|
|
||||||
TimeMessage::TimeMessage() {
|
TimeMessage::TimeMessage() {
|
||||||
|
@ -1,15 +1,8 @@
|
|||||||
/**
|
#ifndef FSFW_TIMEMANAGER_TIMEMESSAGE_H_
|
||||||
* @file TimeMessage.h
|
#define FSFW_TIMEMANAGER_TIMEMESSAGE_H_
|
||||||
* @brief This file defines the TimeMessage class.
|
|
||||||
* @date 26.02.2013
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TIMEMESSAGE_H_
|
|
||||||
#define TIMEMESSAGE_H_
|
|
||||||
|
|
||||||
#include "../ipc/MessageQueueMessage.h"
|
|
||||||
#include "Clock.h"
|
#include "Clock.h"
|
||||||
|
#include "../ipc/MessageQueueMessage.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
class TimeMessage : public MessageQueueMessage {
|
class TimeMessage : public MessageQueueMessage {
|
||||||
@ -53,4 +46,4 @@ public:
|
|||||||
uint32_t getCounterValue();
|
uint32_t getCounterValue();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TIMEMESSAGE_H_ */
|
#endif /* FSFW_TIMEMANAGER_TIMEMESSAGE_H_ */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef FRAMEWORK_TIMEMANAGER_TIMESTAMPERIF_H_
|
#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||||
#define FRAMEWORK_TIMEMANAGER_TIMESTAMPERIF_H_
|
#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
|
||||||
|
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
@ -25,4 +25,4 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* FRAMEWORK_TIMEMANAGER_TIMESTAMPERIF_H_ */
|
#endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */
|
||||||
|
13
timemanager/clockDefinitions.h
Normal file
13
timemanager/clockDefinitions.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef FSFW_TIMEMANAGER_CLOCKDEFINITIONS_H_
|
||||||
|
#define FSFW_TIMEMANAGER_CLOCKDEFINITIONS_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
// I'd also like to include the TimeOfDay_t struct here, but that would
|
||||||
|
// break code which uses Clock::TimeOfDay_t. Solution would be to use
|
||||||
|
// a Clock namespace instead of class with static functions.
|
||||||
|
|
||||||
|
//! Don't use these for time points, type is not large enough for UNIX epoch.
|
||||||
|
using dur_millis_t = uint32_t;
|
||||||
|
|
||||||
|
#endif /* FSFW_TIMEMANAGER_CLOCKDEFINITIONS_H_ */
|
Loading…
x
Reference in New Issue
Block a user