Skip to content

Commit

Permalink
edits to a_scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
antara-chugh committed Aug 5, 2024
1 parent 506022c commit 98aca1f
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions src/antara_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ int Scheduler::getNextTask(DeploymentSchedule_t **p_next_task, std::uint32_t *p_
{
int i = numTasks - 1;

while (i >= 0)
for(; i>=0; i--)
{
bool canSet = true;
int runTime = tasks[i].nextRunTime;
int delay = current_time - tasks[i].nextRunTime;
int delay = current_time - runTime;
if (delay > 0)
{
runTime = current_time;
Expand All @@ -52,15 +52,13 @@ int Scheduler::getNextTask(DeploymentSchedule_t **p_next_task, std::uint32_t *p_
}
if (delay == tasks[i].maxDelay)
{
*p_next_task = &(tasks[i]);
tasks[i].nextRunTime = runTime + tasks[i].ensembleInterval;
return runTime;
//send warning
}
int completion = runTime + tasks[i].maxDuration;
int j = 0;
while (j < i && canSet)
{
if (tasks[j].nextRunTime < completion)
if (tasks[j].nextRunTime< completion)
{
canSet = false;
}
Expand All @@ -69,27 +67,13 @@ int Scheduler::getNextTask(DeploymentSchedule_t **p_next_task, std::uint32_t *p_
if (canSet)
{
*p_next_task = &(tasks[i]);
tasks[i].nextRunTime += delay + tasks[i].ensembleInterval;
tasks[i].nextRunTime = runTime + tasks[i].ensembleInterval;
return runTime;
}

i--;
}

*p_next_task = &(tasks[0]);
tasks[0].measurementCount++;
int runTime = tasks[0].nextRunTime;
int delay = current_time - (tasks[0].nextRunTime);
if (delay > 0)
{
runTime = current_time;
}
else
{
delay = 0;

}
tasks[0].nextRunTime += delay + tasks[0].ensembleInterval;

return runTime;
return -1;
}
#endif

0 comments on commit 98aca1f

Please sign in to comment.