diff --git a/inc/Helpers/TimeHelper.hpp b/inc/Helpers/TimeHelper.hpp index ad9c41a31aa27e2059c409dc9ab635be85b63d01..bf34a29149961d8e5fddf2dd2596464456e115c6 100644 --- a/inc/Helpers/TimeHelper.hpp +++ b/inc/Helpers/TimeHelper.hpp @@ -9,7 +9,7 @@ #define SECONDS_PER_DAY 86400 /** - * The time and date provided from Real Time Clock(Real Time Clock). + * The time and date provided from Real Time Clock (Real Time Clock). * * @notes * This struct is similar to the `struct tm` of <ctime> library but it is more embedded-friendly @@ -29,9 +29,13 @@ struct TimeAndDate { /** * This class formats the spacecraft time and cooperates closely with the ST[09] time management. * - * The ECSS standard supports two time formats: the CUC and CSD that are described in - * CCSDS 301.0-B-4 standard. The chosen time format is CDS and it is UTC-based(UTC: Coordinated - * Universal Time) + * The ECSS standard supports two time formats: the CUC and CSD that are described in CCSDS + * 301.0-B-4 standard. The chosen time format is CDS and it is UTC-based (UTC: Coordinated + * Universal Time). It consists of two main fields: the time code preamble field (P-field) and + * the time specification field (T-field). The P-Field is the metadata for the T-Field. The + * T-Field is consisted of two segments: 1)the `DAY` and the 2)`ms of day` segments. The P-field + * won't be included in the code, because as the ECSS standards claims, it can be + * just implicitly declared. * * @note * Since this code is UTC-based, the leap second correction must be made. The leap seconds that @@ -46,22 +50,22 @@ public: TimeHelper() = default; /** - * @param year The year that will be examined if it is a leap year(366 days) + * @param year The year that will be examined if it is a leap year (366 days) * @return if the \p year is a leap year returns true and if it isn't returns false */ static bool IsLeapYear(uint16_t year); /** - * Convert UTC date to elapsed seconds since Unix epoch(1/1/1970 00:00:00). + * Convert UTC date to elapsed seconds since Unix epoch (1/1/1970 00:00:00). * * This is a reimplemented mktime() of <ctime> library in an embedded systems way * * @note * This function can convert UTC dates after 1 January 2019 to elapsed seconds since Unix epoch * - * @param TimeInfo the time information/data from the RTC(UTC format) - * @return the elapsed seconds between a given UTC date(after the Unix epoch) and Unix epoch - * @todo check if we need to change the epoch to ,the recommended from the standard, 1 January + * @param TimeInfo the time information/data from the RTC (UTC format) + * @return the elapsed seconds between a given UTC date (after the Unix epoch) and Unix epoch + * @todo check if we need to change the epoch to the recommended from the standard, 1 January * 1958 */ static uint32_t mkUTCtime(struct TimeAndDate &TimeInfo); @@ -83,14 +87,11 @@ public: /** - * Generate the CDS time format(3.3 in CCSDS 301.0-B-4 standard). + * Generate the CDS time format (3.3 in CCSDS 301.0-B-4 standard). + * + * Converts a UTC date to CDS time format. * - * The CDS time format consists of two main fields: the time code preamble field(P-field) and - * the time specification field(T-field). The P-Field is the metadata for the T-Field. The - * T-Field is consisted of two segments: 1)the `DAY` and the 2)`ms of day` segments. The - * P-field won't be included in the code, because as the ECSS standards claims, it can be - * just implicitly declared. - * @param TimeInfo is the data provided from RTC(Real Time Clock) + * @param TimeInfo is the data provided from RTC (UTC) * @return TimeFormat the CDS time format. More specific, 48 bits are used for the T-field * (16 for the `DAY` and 32 for the `ms of day`) * @todo time security for critical time operations @@ -100,7 +101,7 @@ public: static uint64_t generateCDStimeFormat(struct TimeAndDate &TimeInfo); /** - * Parse the CDS time format(3.3 in CCSDS 301.0-B-4 standard) + * Parse the CDS time format (3.3 in CCSDS 301.0-B-4 standard) * * @param data time information provided from the ground segment. The length of the data is a * fixed size of 48 bits diff --git a/inc/Services/TimeManagementService.hpp b/inc/Services/TimeManagementService.hpp index 6f5044255644232fc27266cdedbdc1b3c4de1d23..533fcd5683f5dddd3258d00d8884c76a5da8b40c 100644 --- a/inc/Services/TimeManagementService.hpp +++ b/inc/Services/TimeManagementService.hpp @@ -10,14 +10,14 @@ * * @notes * There is a noticeable difference between setting the time using GPS and setting the time - * using space packets from the ground segment. The GPS module sent the actual time of UTC(123519 - * is 12:35:19 UTC),while space packets,for time configuration,sent the elapsed time units - * (seconds,days depends on the time format) from a specific epoch(1 January 1958 00:00:00). Time - * updates using GPS have nothing to do with this service, but for consistency and simplicity we + * using space packets from the ground segment. The GPS module sends the actual time of UTC (123519 + * is 12:35:19 UTC), while space packets, for time configuration, sends the elapsed time units + * (seconds, days depends on the time format) from a specific epoch (1 January 1958 00:00:00). Time + * updates using GPS have nothing to do with this service, but for consistency and simplicity we * are trying to set the time with a common way independently of the time source. This is also - * the reason that we chose CDS time format(because it is UTC based, check class `TimeHelper`) + * the reason that we chose CDS time format (because it is UTC based, check class `TimeHelper`) * - * About the GPS receiver,we assume that it outputs NMEA(message format) data + * About the GPS receiver, we assume that it outputs NMEA (message format) data * * @todo check if we need to follow the standard for time-management or we should send the time-data * like GPS @@ -25,7 +25,7 @@ * @todo When the time comes for the application processes we should consider this: All reports * generated by the application process that is identified by APID 0 are time reports * @todo Declare the time accuracy that the standard claims in the spacecraft - * time reference section(6.9.3.d,e) + * time reference section (6.9.3.d,e) */ class TimeManagementService : public Service { @@ -38,9 +38,9 @@ public: * TM[9,3] CDS time report. * * This function sends reports with the spacecraft time that is formatted according to the CDS - * time code format(check class `TimeHelper` for the format) + * time code format (check class `TimeHelper` for the format) * - * @param TimeInfo the time information/data from the RTC(UTC format) + * @param TimeInfo the time information/data from the RTC (UTC format) * @todo check if we need spacecraft time reference status * @todo ECSS standard claims: <<The time reports generated by the time reporting subservice * are spacecraft time packets. A spacecraft time packet does not carry the message type, @@ -53,10 +53,10 @@ public: /** * TC[9,128] CDS time request. * - * This function is a custom subservice(mission specific) with message type 128(as defined + * This function is a custom subservice (mission specific) with message type 128 (as defined * from the standard for custom message types, 5.3.3.1.f) and it parses the data of the * time-management telecommand packet. This data is formatted according to the CDS time code - * format(check class `TimeHelper` for the format) + * format (check class `TimeHelper` for the format) * * @param message the message that will be parsed for its time-data. The data of the \p message * should be a fixed size of 48 bits diff --git a/src/Helpers/TimeHelper.cpp b/src/Helpers/TimeHelper.cpp index 27fe1d822bb30167995249cb1f52c223140f4a25..1dbd5e6ae2358945798c49fccd4aca0b92576e1e 100644 --- a/src/Helpers/TimeHelper.cpp +++ b/src/Helpers/TimeHelper.cpp @@ -11,7 +11,7 @@ bool TimeHelper::IsLeapYear(uint16_t year) { } uint32_t TimeHelper::mkUTCtime(struct TimeAndDate &TimeInfo) { - uint32_t secs = 1546300800; // elapsed seconds from Unix epoch until 1/1/2019 00:00:00(UTC date) + uint32_t secs = 1546300800; // elapsed seconds from Unix epoch until 1/1/2019 00:00:00 (UTC) for (uint16_t y = 2019; y < TimeInfo.year; ++y) { secs += (IsLeapYear(y) ? 366 : 365) * SECONDS_PER_DAY; } @@ -29,7 +29,7 @@ uint32_t TimeHelper::mkUTCtime(struct TimeAndDate &TimeInfo) { } struct TimeAndDate TimeHelper::utcTime(uint32_t seconds) { - seconds -= 1546300800; // elapsed seconds from Unix epoch until 1/1/2019 00:00:00(UTC date) + seconds -= 1546300800; // elapsed seconds from Unix epoch until 1/1/2019 00:00:00 (UTC) struct TimeAndDate TimeInfo = {0}; TimeInfo.year = 2019; TimeInfo.month = 1; @@ -63,7 +63,7 @@ struct TimeAndDate TimeHelper::utcTime(uint32_t seconds) { // calculate days TimeInfo.day = seconds/SECONDS_PER_DAY; seconds -= TimeInfo.day * SECONDS_PER_DAY; - TimeInfo.day++; // add 1 day because we start count from 1 January(and not 0 January!) + TimeInfo.day++; // add 1 day because we start count from 1 January (and not 0 January!) // calculate hours TimeInfo.hour = seconds/SECONDS_PER_HOUR; @@ -81,7 +81,7 @@ struct TimeAndDate TimeHelper::utcTime(uint32_t seconds) { uint64_t TimeHelper::generateCDStimeFormat(struct TimeAndDate &TimeInfo) { /** - * Define the T-field. The total number of octets for the implementation of T-field is 6(2 for + * Define the T-field. The total number of octets for the implementation of T-field is 6 (2 for * the `DAY` and 4 for the `ms of day` */ diff --git a/src/Services/TimeManagementService.cpp b/src/Services/TimeManagementService.cpp index 33301a70c1fc8fc85bb27f4eb150828694b53edf..ad4d8c9208fb2fa558487c4fcf1868633f37a379 100644 --- a/src/Services/TimeManagementService.cpp +++ b/src/Services/TimeManagementService.cpp @@ -14,9 +14,9 @@ void TimeManagementService::cdsTimeReport(struct TimeAndDate &TimeInfo) { } struct TimeAndDate TimeManagementService::cdsTimeRequest(Message &message) { - // TC{9,128] CDS time request + // TC[9,128] CDS time request - // check if we have the correct size of the data. The size should be 6(48 bits) + // check if we have the correct size of the data. The size should be 6 (48 bits) ErrorHandler::assertRequest(message.dataSize == 6, message, ErrorHandler::AcceptanceErrorType::UnacceptableMessage);