From 7ddb266bd1c9d6cf633c6417de9633be05e18033 Mon Sep 17 00:00:00 2001 From: antara-chugh Date: Wed, 31 Jul 2024 10:51:34 -0700 Subject: [PATCH] Modifications to scheduler & abstract schedule class. ready to test --- src/a_scheduler.cpp | 8 +- src/a_scheduler.hpp | 2 +- src/abstractScheduler.hpp | 4 +- src/scheduler.hpp | 156 -------------------------------------- 4 files changed, 7 insertions(+), 163 deletions(-) delete mode 100644 src/scheduler.hpp diff --git a/src/a_scheduler.cpp b/src/a_scheduler.cpp index 7d1714e4..c4f0d9d2 100644 --- a/src/a_scheduler.cpp +++ b/src/a_scheduler.cpp @@ -1,10 +1,11 @@ #include "a_scheduler.hpp" -Scheduler:: Scheduler(DeploymentSchedule_t schedule[], int length): AbstractScheduler(schedule){ +Scheduler:: Scheduler(DeploymentSchedule_t schedule[]){ tasks=schedule; - numTasks=length; - for(int i=0; i -#include -#ifndef TEST_VERSION -#include "Particle.h" -#else -#include "../tests/scheduler_test_system.hpp" -#endif - -typedef enum error_ -{ - SUCCESS, - TASK_SEARCH_FAIL, -}error_e; - -/** - * @brief defines type for DeploymentSchedule_ struct below. - - */ - - -//typedef struct DeploymentSchedule_ DeploymentSchedule_t; - -/** - * @brief Ensemble function. - * - * This function executes once to update the ensemble state. This should update - * the accumulators with a new measurement. If the accumulators have - * accumulated the proper amount of data, this function should then record the - * proper data. - * - * Essentially, this will be called every ensembleInterval ms after - * ensembleDelay ms from the start of the deployment. - * - * @param pDeployment the schedule table - */ -//typedef void (*EnsembleFunction)(DeploymentSchedule_t* pDeployment); -/** - * @brief Ensemble initialization function. - * - * This function is executed once when all of the - * @param pDeployment the schedule table - */ -//typedef void (*EnsembleInit)(DeploymentSchedule_t* pDeployment); - -/** - * @brief Records and writes ensemble - * @param pDeployment the schedule table - */ -//typedef void (*EnsembleProccess)(DeploymentSchedule_t* pDeployment); - -struct DeploymentSchedule_ - { - int priority; - void (*measure)(); //!< measurement function - //void (*init)(); //!< initialization function - //EnsembleProccess process; //!< processing function - - //uint32_t measurementsToAccumulate; //!< measurements before processing - uint32_t startDelay; //!< delay after deployment start - uint32_t ensembleInterval; //!< time between ensembles - - // State information - //uint32_t nMeasurements; //!< Total number of measurements to execute - //uint32_t lastMeasurementTime; //!< last time measurement was scheduled - //uint32_t deploymentStartTime; //!< when schedule was initialized - //uint32_t measurementCount; //!< how many times ensemble was scheduled - //void* pData; //!< Buffer to store measurements temporarily - uint32_t maxDuration; //!< store max running time of measurement - char taskName; //!< task name of ensemble - //uint32_t nextRunTime; -}; - - -struct Task_{ - - uint32_t nextRunTime; - uint32_t interval; - uint32_t numRuns; - DeploymentSchedule_ * info; -}; - -class Scheduler{ - - public: - Scheduler(DeploymentSchedule_ d[], int num, int startTime); - int runTimes[3][500]; - int recordRuns; - - void SCH_runSchedule(); - - private: - int numTasks; - Task_ task[3]; - int numDelays; - unsigned long totalDelay; - - -}; - - - - -/* - * @brief Initializes ensemble variables - * - * @param scheduleTable the schedule table - * @param startTime the start time of the deployment - */ -//void SCH_initializeSchedule(DeploymentSchedule_t* scheduleTable, - // system_tick_t startTime); -//void SCH_runSchedule(Task_ tasks[], int numTask); - -/* - * @brief sets next scheduled task and time - * - * @param scheduleTable the schedule table - * @param p_nextEvent the next event to run - * @param p_nextTime time next event will run - * - * Handles all the scheduler logic, focusing on maininting task intervals with - * respect to the initial measurement. See expected behaivor in - * @ref tests/gtests.cpp - * @return outcome enum from - */ -/*uint32_t SCH_getNextEvent(DeploymentSchedule_t* scheduleTable, - DeploymentSchedule_t** p_nextEvent, - system_tick_t* p_nextTime, - system_tick_t currentTime);*/ - -/* - * @brief Determines if a task will overlap with other scheduled tasks. - * - * This function checks if the proposed start and end times of a task - * overlap with any other tasks in the schedule table. It ensures that - * tasks are scheduled without conflicts. - * - * @param scheduleTable The table containing all scheduled tasks. - * @param idx The index of the current task in the schedule table. - * @param currentTime The current system time. - * @param nextStartTime The proposed start time of the current task. - * @return True if there is an overlap with another task; false otherwise. - */ -/*bool SCH_willOverlap(DeploymentSchedule_t* scheduleTable, int i, - system_tick_t currentTime, uint32_t nextStartTime);*/ - -#endif //__SCHEDULER__HPP_ -