Skip to content

Commit

Permalink
!chore: merged in consoldated scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
charliekush committed Aug 12, 2024
1 parent 310d33c commit f071ea2
Show file tree
Hide file tree
Showing 15 changed files with 248 additions and 229 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set(GTEST_SOURCE_FILES
src/antara_scheduler.cpp
src/charlie_scheduler.cpp
tests/fixed_google_tests.cpp
src/scheduler.cpp
#tests/file_google_tests.cpp
#tests/overlap_google_tests.cpp
tests/scheduler_test_flog.cpp
Expand All @@ -32,6 +33,7 @@ set(EXAMINE_BEHAVIOR_SOURCE_FILES
tests/test_ensembles.cpp
src/charlie_scheduler.cpp
src/antara_scheduler.cpp
src/scheduler.cpp
tests/scheduler_test_flog.cpp
tests/examine_behavior.cpp
)
Expand Down
12 changes: 10 additions & 2 deletions src/abstractScheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define __ABSTRACT_SCHEDULER_HPP__
#include <cstdint>
#include "deploymentSchedule.hpp"

#include <cstdint>


class AbstractScheduler {
Expand All @@ -25,8 +25,16 @@ class AbstractScheduler {
* @return 0 if successful, otherwise error code to be defined by
* implementation
*/
virtual int getNextTask(DeploymentSchedule_t** p_next_task,
virtual SCH_error_e getNextTask(DeploymentSchedule_t** p_next_task,
std::uint32_t* p_next_runtime,
std::uint32_t current_time) = 0;
};

typedef enum error_
{
SUCCESS,
TASK_SEARCH_FAIL,
FLOG_SCHEDULER_DELAY_EXCEEDED
}SCH_error_e;

#endif // __ABSTRACT_SCHEDULER_HPP__
6 changes: 1 addition & 5 deletions src/antara_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ class Scheduler : public AbstractScheduler
std::uint32_t current_time);
void initializeScheduler();
};
typedef enum error_
{
SUCCESS,
TASK_SEARCH_FAIL,
}SCH_error_e;



#endif
Expand Down
6 changes: 1 addition & 5 deletions src/charlie_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ class Scheduler : public AbstractScheduler {

};

typedef enum error_
{
SUCCESS,
TASK_SEARCH_FAIL,
}SCH_error_e;




Expand Down
7 changes: 2 additions & 5 deletions src/ensembles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@

#ifndef __ENSEMBLES_HPP__
#define __ENSEMBLES_HPP__

#if SCHEDULER_VERSION == CHARLIE_VERSION
#include "charlie_scheduler.hpp"
#else
#include "antara_scheduler.hpp"
#endif
#include "scheduler.hpp"

#endif
#endif //__ENSEMBLES_HPP__
4 changes: 1 addition & 3 deletions src/rideTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
#include "vers.hpp"
#include "ensembles.hpp"
#include "cli/flog.hpp"
#if SCHEDULER_VERSION == CHARLIE_VERSION
#include "charlie_scheduler.hpp"
#else
#include "antara_scheduler.hpp"
#endif
#include "scheduler.hpp"

/**
* @brief creates file name for log
Expand Down
5 changes: 3 additions & 2 deletions src/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#else
#include "scheduler_test_system.hpp"
#endif
#include <cstdint>
#include "cli/conio.hpp"
#include "ensembles.hpp"
#include "scheduler.hpp"
Expand All @@ -35,7 +36,7 @@ void Scheduler::initializeScheduler()
tableSize++;
memset(&(pDeployment->state), 0,
sizeof(StateInformation));
pDeployment->state.lastMeasurementTime = UINT32_MAX;

pDeployment->init(pDeployment);
pDeployment++;
}
Expand Down Expand Up @@ -88,7 +89,7 @@ int Scheduler::getNextTask(DeploymentSchedule_t** p_nextEvent,
{
delay = 0;
}
if (delay == currentEvent.maxDelay)
if (delay >= currentEvent.maxDelay)
{
//send warning
}
Expand Down
37 changes: 9 additions & 28 deletions src/scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @version 1
*/
#ifndef __CONSOLODATED_SCHEDULER__HPP__
#define __CHARLIE_SCHEDULER__HPP__
#define __CONSOLODATED_SCHEDULER__HPP__
#include "product.hpp"
#if SCHEDULER_VERSION == CONSOLODATED_VERSION

Expand All @@ -19,7 +19,7 @@
#include "Particle.h"
#else
#include "scheduler_test_system.hpp"
#endif
#endif // TEST_VERSION


/**
Expand Down Expand Up @@ -50,11 +50,10 @@ typedef void (*EnsembleInit)(DeploymentSchedule_t* pDeployment);
struct StateInformation
{
//! how many times ensemble was scheduled
uint32_t measurementCount;
std::uint32_t measurementCount;

//! store the next time the task should run
uint32_t nextRunTime;

std::uint32_t nextRunTime;

};
/**
Expand Down Expand Up @@ -91,7 +90,7 @@ class Scheduler : public AbstractScheduler {
DeploymentSchedule_t* scheduleTable;




Scheduler(DeploymentSchedule_t* scheduler);

Expand All @@ -116,31 +115,13 @@ class Scheduler : public AbstractScheduler {
* @param nextStartTime The proposed start time of the current task.
* @return True if there is an overlap with another task; false otherwise.
*/
int getNextTask(DeploymentSchedule_t** p_next_task,
SCH_error_e getNextTask(DeploymentSchedule_t** p_next_task,
uint32_t* p_next_runtime,
uint32_t current_time);

bool willOverlap(uint32_t i, system_tick_t currentTime,
uint32_t nextStartTime);

};

typedef enum error_
{
SUCCESS,
TASK_SEARCH_FAIL,
}SCH_error_e;











#endif

#endif //__CHARLIE_SCHEDULER__HPP__
#endif //SCHEDULER_VERSION
#endif //__CONSOLODATED_SCHEDULER__HPP__
Loading

0 comments on commit f071ea2

Please sign in to comment.