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

Almost done with the timeshift function

parent ced8f19a
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ void TimeBasedSchedulingService::insertActivities(Message &request) {
// Temporary definitions until the Time helper is ready
uint32_t releaseTime = 0; // Temporary release time
uint32_t currentTime = 50; // Temporary current time
// Message receivedPacket; // Temporary message field
Message receivedTCPacket; // Temporary message field
if ((currentNumberOfActivities >= MAX_NUMBER_OF_ACTIVITIES) || (releaseTime <
(currentTime +
......@@ -52,7 +52,7 @@ void TimeBasedSchedulingService::insertActivities(Message &request) {
// todo: Send a failed start of execution
} else {
ScheduledActivity newActivity;
// newActivity.request = receivedTCPacket;
newActivity.request = receivedTCPacket;
newActivity.requestReleaseTime = releaseTime;
scheduledActivities.push_back(newActivity); // Insert the new activity into the schedule
......@@ -71,15 +71,20 @@ void TimeBasedSchedulingService::timeShiftAllActivities(Message &request) {
assert(request.serviceType == 11);
assert(request.messageType == 15);
uint16_t iterationCount = request.readUint16(); // Get the iteration count, (N)
for (std::size_t i = 0; i < iterationCount; i++) {
uint32_t relativeOffset = request.readUint32();
// todo: define the enumeration types for the source ID and application process ID
uint16_t receivedSequenceCount = request.readUint16(); // Get the sequence count
/*
* Perform a search in the vector containing the activity definitions to find a match for
* the received parameters
*/
// Temporary variables
uint32_t current_time = 0;
const auto[earliestRelease, latestRelease] = etl::minmax_element(scheduledActivities.front()
.requestReleaseTime,
scheduledActivities.back().requestReleaseTime);
uint32_t relativeOffset = request.readUint32(); // Get the relative offset
if ((earliestRelease + relativeOffset) < (current_time + TIME_MARGIN_FOR_ACTIVATION)) {
// todo: generate a failed start of execution error
} else {
for (auto &activity : scheduledActivities) {
activity.requestReleaseTime += relativeOffset; // Time shift each activity
}
}
}
......@@ -122,12 +127,13 @@ void TimeBasedSchedulingService::detailReportAllActivities(Message &request) {
// todo: add an extra check for the vector size to make sure it matches with
// currentNumberOfActivities?
for (auto const& activity : scheduledActivities) {
for (auto const &activity : scheduledActivities) {
// Create the report message object of telemetry message subtype 10 for each activity
Message report = createTM(10);
// todo: append sub-schedule and group ID if they are defined
// todo: append the release time of the current activity "activity.requestReleaseTime;"
// todo: append the request contained in the activity "activity.request;"
// todo: important todo, implement append TC packet in the Message header
storeMessage(report); // Save the report
request.resetRead(); // todo: define if this statement is required
}
......
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