From 400c56472b3388a7f30c2f7fcf429e9f1af19567 Mon Sep 17 00:00:00 2001 From: Dimitrios Stoupis <dimitris.apple@gmail.com> Date: Tue, 12 Mar 2019 20:36:01 +0000 Subject: [PATCH] The main crucial function are defined - Enable, Disable and Rest function are implemented - Activity insertion function is partially implemented and it is dependant on the Time helper to get the time --- .../TimeBasedCommandSchedulingService.cpp | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/Services/TimeBasedCommandSchedulingService.cpp b/src/Services/TimeBasedCommandSchedulingService.cpp index 7419f005..1fa26ca1 100644 --- a/src/Services/TimeBasedCommandSchedulingService.cpp +++ b/src/Services/TimeBasedCommandSchedulingService.cpp @@ -1,4 +1,69 @@ #include "Services/TimeBasedCommandSchedulingService.hpp" +void TimeBasedCommandSchedulingService::enableScheduleExecution(Message &request) { + + // Check if the correct packet is being processed + assert(request.serviceType == 11); + assert(request.messageType == 1); + + executionFunctionStatus = true; // Enable the service +} + +void TimeBasedCommandSchedulingService::disableScheduleExecution(Message &request) { + + // Check if the correct packet is being processed + assert(request.serviceType == 11); + assert(request.messageType == 2); + + executionFunctionStatus = false; // Disable the service +} + +void TimeBasedCommandSchedulingService::resetSchedule(Message &request) { + + // Check if the correct packet is being processed + assert(request.serviceType == 11); + assert(request.messageType == 3); + + executionFunctionStatus = false; // Disable the service + scheduledActivities.clear(); // Delete all scheduled activities + // todo: Add resetting for sub-schedules and groups, if defined +} + +void TimeBasedCommandSchedulingService::insertActivities(Message &request) { + + // Check if the correct packet is being processed + assert(request.serviceType == 11); + assert(request.messageType == 4); + + 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 releaseTime = 0; // Temporary release time + uint32_t currentTime = 50; // Temporary current time + // Message receivedPacket; // Temporary message field + + if ((currentNumberOfActivities >= MAX_NUMBER_OF_ACTIVITIES) || (releaseTime < + (currentTime + + TIME_MARGIN_FOR_ACTIVATION))) { + // todo: Send a failed start of execution + } else { + ScheduledActivity newActivity; + // newActivity.request = receivedTCPacket; + newActivity.requestReleaseTime = releaseTime; + + scheduledActivities.push_back(newActivity); // Insert the new activity into the schedule + } + // If the verification passes then do the following + // Create a new scheduled activity in the schedule + // Place the request specified in that instruction into the new scheduled activity + // Set the release time of the new activity to the specified one + } + +} + + -- GitLab