Skip to content
Snippets Groups Projects
Unverified Commit 0d0a477c authored by Dimitrios Stoupis's avatar Dimitrios Stoupis
Browse files

Defined a platform specific time getter

parent 0a458350
No related branches found
No related tags found
No related merge requests found
#ifndef ECSS_SERVICES_TIMEGETTER_HPP
#define ECSS_SERVICES_TIMEGETTER_HPP
#include <iostream>
#include <cstdint>
#include <ctime>
/**
* @brief Get the current time
*/
class TimeGetter {
public:
/**
* @brief Gets the current time in UNIX epoch
* @return Current UNIX epoch time, in elapsed seconds
*/
static inline uint32_t getUnixSeconds() {
return static_cast<uint32_t >(time(nullptr));
}
};
#endif //ECSS_SERVICES_TIMEGETTER_HPP
......@@ -10,6 +10,9 @@
#include "Helpers/CRCHelper.hpp"
#include "Helpers/TimeHelper.hpp"
// Include platform specific files
#include "Platform/x86/TimeGetter.hpp"
/**
* @def SUB_SCHEDULES_ENABLED
* @brief Indicates whether sub-schedules are supported
......@@ -97,17 +100,17 @@ private:
/**
* @brief Hold the scheduled activities
*
* The scheduled activities in this vector are ordered by their release time, as the standard
* requests.
* @details The scheduled activities in this vector are ordered by their release time, as the
* standard requests.
*/
etl::vector<ScheduledActivity, ECSS_MAX_NUMBER_OF_TIME_SCHED_ACTIVITIES> scheduledActivities;
/**
* @brief Define a friend in order to be able to access private members during testing
*
* The private members defined in this class, must not in any way be public to avoid misuse.
* During testing, access to private members for verification is required, so an access friend
* structure is defined here.
* @details The private members defined in this class, must not in any way be public to avoid
* misuse. During testing, access to private members for verification is required, so an
* access friend structure is defined here.
*/
friend struct ::unit_test::Tester;
......@@ -148,7 +151,6 @@ public:
* execution of the schedule and also to make things easier whenever a release time sorted
* report is requested by he corresponding service.
* @param request Provide the received message as a parameter
* @todo Remove the temporary variable for the current time
* @throws failed_start_of_execution If there is request to be inserted and the maximum
* number of activities in the current schedule has been reached, then a failed start of
* execution report is being issued. Also if the release time of the request is less than a
......@@ -163,7 +165,6 @@ public:
* @details All scheduled activities are shifted per user request. The relative time offset
* received and tested against the current time.
* @param request Provide the received message as a parameter
* @todo Remove the temporary variable for the current time
* @throws failed_start_of_execution If the release time of the request is less than a
* set time margin, defined in ECSS_TIME_MARGIN_FOR_ACTIVATION, from the current time a
* failed start of execution report is issued for that instruction.
......@@ -225,7 +226,6 @@ public:
*
* @details Time-shift certain activities by using the unique request identifier
* @param request Provide the received message as a parameter
* @todo Remove the temporary variable for the current time
* @throws failed_start_of_execution If the requested time offset is less than the earliest
* time from the currently scheduled activities plus the ECSS_TIME_MARGIN_FOR_ACTIVATION,
* then the request is rejected and a failed start of execution report is issued. Also if an
......
......@@ -45,10 +45,7 @@ void TimeBasedSchedulingService::insertActivities(Message &request) {
uint16_t iterationCount = request.readUint16(); // Get the iteration count, (N)
for (std::size_t i = 0; i < iterationCount; i++) {
// todo: Get the group ID first, if groups are used
// todo: Read the absolute time using the helper functions from the time service
// Temporary definitions until the Time helper is ready
uint32_t currentTime = 50; // Temporary current time
uint32_t currentTime = TimeGetter::getUnixSeconds(); // Get the current system time
uint32_t releaseTime = request.readUint32(); // Get the specified release time
if ((currentNumberOfActivities >= ECSS_MAX_NUMBER_OF_TIME_SCHED_ACTIVITIES) ||
......@@ -91,8 +88,7 @@ void TimeBasedSchedulingService::timeShiftAllActivities(Message &request) {
assert(request.serviceType == 11);
assert(request.messageType == 15);
// Temporary variables
uint32_t current_time = 0;
uint32_t current_time = TimeGetter::getUnixSeconds(); // Get the current system time
// Find the earliest release time. It will be the first element of the iterator pair
const auto releaseTimes = etl::minmax_element(scheduledActivities.begin(),
......@@ -122,8 +118,7 @@ void TimeBasedSchedulingService::timeShiftActivitiesByID(Message &request) {
assert(request.serviceType == 11);
assert(request.messageType == 7);
// Temporary variables
uint32_t current_time = 0;
uint32_t current_time = TimeGetter::getUnixSeconds(); // Get the current system time
int32_t relativeOffset = request.readSint32(); // Get the offset first
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment