diff --git a/CMakeLists.txt b/CMakeLists.txt index 50c416bbd0ee88fef12adb1af819d0675a4e5d51..fb561a7167901794677f8bd21dcc4ecec0c20a7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,6 @@ add_library(common OBJECT src/Services/ParameterService.cpp src/Services/RequestVerificationService.cpp src/Services/TestService.cpp - src/Services/TimeManagementService.cpp src/Services/LargePacketTransferService.cpp src/Services/EventActionService.cpp src/Services/TimeBasedSchedulingService.cpp diff --git a/inc/ServicePool.hpp b/inc/ServicePool.hpp index 51c1fa201b856c3f1b0225113c1e60860f36ff1a..293b00c3b51ce2a33522dcb40a6d47214e4cd72d 100644 --- a/inc/ServicePool.hpp +++ b/inc/ServicePool.hpp @@ -5,7 +5,6 @@ #include "Services/TimeBasedSchedulingService.hpp" #include "Services/LargePacketTransferService.hpp" #include "Services/RequestVerificationService.hpp" -#include "Services/TimeManagementService.hpp" #include "Services/EventReportService.hpp" #include "Services/EventActionService.hpp" #include "Services/ParameterService.hpp" @@ -65,10 +64,6 @@ public: TestService testService; #endif -#ifdef SERVICE_TIME - TimeManagementService timeManagement; -#endif - #ifdef SERVICE_TIMESCHEDULING TimeBasedSchedulingService timeBasedScheduling; #endif diff --git a/inc/Services/TimeManagementService.hpp b/inc/Services/TimeManagementService.hpp deleted file mode 100644 index 9083c7f8574c20c98f6ddffca8043f467f336312..0000000000000000000000000000000000000000 --- a/inc/Services/TimeManagementService.hpp +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef ECSS_SERVICES_TIMEMANAGEMENTSERVICE_HPP -#define ECSS_SERVICES_TIMEMANAGEMENTSERVICE_HPP - -#include <Service.hpp> -#include "Helpers/TimeHelper.hpp" - -/** - * Implementation of the ST[09] time management. - * - * @ingroup Services - * @note - * 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 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`) - * - * 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 - * @todo check if the final GPS receiver support NMEA protocol - * @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) - */ - -class TimeManagementService : public Service { -public: - - inline static const uint8_t ServiceType = 9; - - enum MessageType : uint8_t { - CdsTimeReport = 3, - }; - - TimeManagementService() { - serviceType = 9; - } - - /** - * 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) - * - * @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, - * consisting of the service type and message subtype.>> Check if we need to implement that - * or should ignore the standard? - */ - - void cdsTimeReport(TimeAndDate& TimeInfo); - - /** - * TC[9,128] CDS time request. - * - * 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) - * - * @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 - */ - TimeAndDate cdsTimeRequest(Message &message); - - /** - * It is responsible to call the suitable function that executes a telecommand packet. The source of that packet - * is the ground station. - * - * @note This function is called from the main execute() that is defined in the file MessageParser.hpp - * @param message Contains the necessary parameters to call the suitable subservice - */ - void execute(Message& message); -}; - -#endif // ECSS_SERVICES_TIMEMANAGEMENTSERVICE_HPP diff --git a/src/MessageParser.cpp b/src/MessageParser.cpp index b3a082ca954afda75806e6add9fbe64b14378a4b..48f533b0374b793496f5a3b73c9256de3f79ed79 100644 --- a/src/MessageParser.cpp +++ b/src/MessageParser.cpp @@ -27,12 +27,6 @@ void MessageParser::execute(Message& message) { break; #endif -#ifdef SERVICE_TIME - case 9: - Services.timeManagement.execute(message); // ST[09] - break; -#endif - #ifdef SERVICE_TIMESCHEDULING case 11: Services.timeBasedScheduling.execute(message); // ST[11] diff --git a/src/Platform/x86/main.cpp b/src/Platform/x86/main.cpp index a3cc0c9e403e5d635913ccbfc1afc8cd45d7eb9b..b74c6eab60a719933816cb5a5ce68ede6f52d684 100644 --- a/src/Platform/x86/main.cpp +++ b/src/Platform/x86/main.cpp @@ -9,7 +9,6 @@ #include "Services/MemoryManagementService.hpp" #include "Services/EventReportService.hpp" #include "Services/FunctionManagementService.hpp" -#include "Services/TimeManagementService.hpp" #include "Services/EventActionService.hpp" #include "Services/LargePacketTransferService.hpp" #include "Services/TimeBasedSchedulingService.hpp" @@ -166,18 +165,6 @@ int main() { errorMessage.appendBits(2, 7); errorMessage.appendByte(15); - // ST[09] test - TimeManagementService& timeReport = Services.timeManagement; - TimeAndDate timeInfo; - // 10/04/1998 10:15:00 - timeInfo.year = 1998; - timeInfo.month = 4; - timeInfo.day = 10; - timeInfo.hour = 10; - timeInfo.minute = 15; - timeInfo.second = 0; - timeReport.cdsTimeReport(timeInfo); - // ST[05] (5,5 to 5,8) test [works] EventReportService::Event eventIDs[] = {EventReportService::HighSeverityUnknownEvent, EventReportService::MediumSeverityUnknownEvent}; diff --git a/src/Services/TimeManagementService.cpp b/src/Services/TimeManagementService.cpp deleted file mode 100644 index f4e6a361407a36d59ead19d5f61020eeadd1b922..0000000000000000000000000000000000000000 --- a/src/Services/TimeManagementService.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "ECSS_Configuration.hpp" -#ifdef SERVICE_TIME - -#include "Services/TimeManagementService.hpp" - -void TimeManagementService::cdsTimeReport(TimeAndDate& TimeInfo) { - // TM[9,3] CDS time report - - Message timeReport = createTM(TimeManagementService::MessageType::CdsTimeReport); - - uint64_t timeFormat = TimeHelper::generateCDSTimeFormat(TimeInfo); - - timeReport.appendHalfword(static_cast<uint16_t>(timeFormat >> 32)); - timeReport.appendWord(static_cast<uint32_t>(timeFormat)); - - storeMessage(timeReport); -} - -TimeAndDate TimeManagementService::cdsTimeRequest(Message& message) { - // TC[9,128] CDS time request - message.assertTC(TimeManagementService::ServiceType, 128); - - // 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); - - TimeAndDate timeInfo = TimeHelper::parseCDStimeFormat(message.data); - - return timeInfo; -} - -void TimeManagementService::execute(Message& message) { - switch (message.messageType) { - case 128: - cdsTimeRequest(message); // TC[9,128] - break; - default: - ErrorHandler::reportInternalError(ErrorHandler::OtherMessageType); - break; - } -} - -#endif diff --git a/test/Services/TimeManagementService.cpp b/test/Services/TimeManagementService.cpp deleted file mode 100644 index da62d828dcef9ace5b3e2c6d4ab83748884cd8f4..0000000000000000000000000000000000000000 --- a/test/Services/TimeManagementService.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include <catch2/catch.hpp> -#include <Services/TimeManagementService.hpp> -#include "ServiceTests.hpp" - -TimeManagementService& timeService = Services.timeManagement; - -TEST_CASE("TM[9,3]", "[service][st09]") { - TimeAndDate TimeInfo; - - // 10/04/2020 10:15:00 - TimeInfo.year = 2020; - TimeInfo.month = 4; - TimeInfo.day = 10; - TimeInfo.hour = 10; - TimeInfo.minute = 15; - TimeInfo.second = 0; - - uint32_t currTime = TimeHelper::utcToSeconds(TimeInfo); - - uint16_t elapsedDays = currTime / 86400; - uint32_t msOfDay = currTime % 86400 * 1000; - uint64_t timeFormat = (static_cast<uint64_t>(elapsedDays) << 32 | msOfDay); - - timeService.cdsTimeReport(TimeInfo); - Message response = ServiceTests::get(0); - CHECK(response.serviceType == TimeManagementService::ServiceType); - CHECK(response.messageType == TimeManagementService::MessageType::CdsTimeReport); - CHECK(response.packetType == Message::TM); - CHECK(response.readHalfword() == static_cast<uint16_t>(timeFormat >> 32)); - CHECK(response.readWord() == static_cast<uint32_t>(timeFormat)); - - Message message = Message(TimeManagementService::ServiceType, 128, Message::TC, 3); - message.appendHalfword(static_cast<uint16_t>(timeFormat >> 32)); - message.appendWord(static_cast<uint32_t>(timeFormat)); - - MessageParser::execute(message); - TimeInfo = timeService.cdsTimeRequest(message); - CHECK(TimeInfo.year == 2020); - CHECK(TimeInfo.month == 4); - CHECK(TimeInfo.day == 10); - CHECK(TimeInfo.hour == 10); - CHECK(TimeInfo.minute == 15); - CHECK(TimeInfo.second == 0); - - // 1/1/2019 00:00:00 - TimeInfo.year = 2019; - TimeInfo.month = 1; - TimeInfo.day = 1; - TimeInfo.hour = 0; - TimeInfo.minute = 0; - TimeInfo.second = 0; - - currTime = TimeHelper::utcToSeconds(TimeInfo); - - elapsedDays = currTime / 86400; - msOfDay = currTime % 86400 * 1000; - timeFormat = (static_cast<uint64_t>(elapsedDays) << 32 | msOfDay); - - timeService.cdsTimeReport(TimeInfo); - response = ServiceTests::get(1); - CHECK(response.serviceType == TimeManagementService::ServiceType); - CHECK(response.messageType == TimeManagementService::MessageType::CdsTimeReport); - CHECK(response.packetType == Message::TM); - CHECK(response.readHalfword() == static_cast<uint16_t>(timeFormat >> 32)); - CHECK(response.readWord() == static_cast<uint32_t>(timeFormat)); - - message = Message(TimeManagementService::ServiceType, 128, Message::TC, 3); - message.appendHalfword(static_cast<uint16_t>(timeFormat >> 32)); - message.appendWord(static_cast<uint32_t>(timeFormat)); - - TimeInfo = timeService.cdsTimeRequest(message); - CHECK(TimeInfo.year == 2019); - CHECK(TimeInfo.month == 1); - CHECK(TimeInfo.day == 1); - CHECK(TimeInfo.hour == 0); - CHECK(TimeInfo.minute == 0); - CHECK(TimeInfo.second == 0); -}