Skip to content

Commit 2304ce8

Browse files
committed
Added getters and setters
1 parent 8b98e6a commit 2304ce8

4 files changed

Lines changed: 29 additions & 24 deletions

File tree

src/ProcessScheduler/Includes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ typedef enum ProcessWarning
3636
#define LONGJMP_ISR_CODE -1000
3737
#define LONGJMP_YIELD_CODE -1001
3838

39+
#define ALL_PRIORITY_LEVELS -1
40+
41+
#ifndef SCHEDULER_JOB_QUEUE_SIZE
42+
#define SCHEDULER_JOB_QUEUE_SIZE 20
43+
#endif
44+
3945
#if defined(ARDUINO_ARCH_AVR)
4046
#include <setjmp.h>
4147
#include <util/atomic.h>

src/ProcessScheduler/Process.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "Scheduler.h"
33

44
/*********** PUBLIC *************/
5-
Process::Process(Scheduler &scheduler, ProcPriority priority, unsigned int period,
5+
Process::Process(Scheduler &scheduler, ProcPriority priority, uint32_t period,
66
int iterations, int16_t overSchedThresh)
77
: _scheduler(scheduler), _pLevel(priority)
88
{
@@ -51,13 +51,6 @@
5151
(getIterations() == RUNTIME_FOREVER || getIterations() > 0))));
5252
}
5353

54-
/* GETTERS */
55-
int Process::getID()
56-
{
57-
return _sid;
58-
}
59-
60-
6154

6255

6356
/*********** PROTECTED *************/
@@ -123,7 +116,7 @@
123116

124117
void Process::setTimeout(uint32_t timeout)
125118
{
126-
// Can not let interrupt happen
119+
// Can not let interrupt happen
127120
ATOMIC_START
128121
{
129122
_timeout = timeout;

src/ProcessScheduler/Process.h

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,48 @@ class Process
1111
{
1212
friend class Scheduler;
1313
public:
14-
Process(Scheduler &manager, ProcPriority priority, unsigned int period,
14+
Process(Scheduler &manager, ProcPriority priority, uint32_t period,
1515
int iterations=RUNTIME_FOREVER,
1616
int16_t overSchedThresh = OVERSCHEDULED_NO_WARNING);
1717

18-
int getID();
19-
inline Scheduler &scheduler() { return _scheduler; }
18+
///////////////////// PROCESS OPERATIONS /////////////////////////
2019
bool add(bool enableIfNot=false);
2120
bool disable();
2221
bool enable();
2322
bool destroy();
2423

25-
inline int32_t timeToNextRun() { return (_scheduledTS + _period) - _scheduler.getCurrTS(); }
26-
inline uint32_t getScheduledTS() { return _scheduledTS; } // The ts the most recent iteration should of started
27-
inline uint32_t getActualRunTS() { return _actualTS; }
24+
///////////////////// GETTERS /////////////////////////
25+
inline Scheduler &scheduler() { return _scheduler; }
2826

27+
inline uint8_t getID() { return _sid; };
2928
inline bool isEnabled() { return _enabled; }
3029
inline bool isNotDestroyed() { return _scheduler.isNotDestroyed(*this); }
30+
3131
inline int getIterations() { return _iterations; } // might return RUNTIME_FOREVER
3232
inline unsigned int getPeriod() { return _period; }
3333

34-
inline void force() { _force = true; }
34+
inline ProcPriority getPriority() { return _pLevel; }
35+
36+
inline int32_t timeToNextRun() { return (_scheduledTS + _period) - _scheduler.getCurrTS(); }
37+
inline uint32_t getActualRunTS() { return _actualTS; }
38+
inline uint32_t getScheduledTS() { return _scheduledTS; } // The ts the most recent iteration should of started
3539

36-
inline void resetOverSchedWarning() { _pBehind = 0; }
3740
inline uint16_t getOverSchedThresh() { return _overSchedThresh; }
3841
inline uint16_t getCurrPBehind() { return _pBehind; }
3942

40-
inline ProcPriority getPriority() { return _pLevel; }
43+
///////////////////// SETTERS /////////////////////////
44+
inline void setIterations(int iterations) { _iterations = iterations; }
45+
inline void setPeriod(uint32_t period) { _period = period; }
46+
inline void force() { _force = true; }
47+
48+
inline void resetOverSchedWarning() { _pBehind = 0; }
49+
4150

4251
protected:
52+
///////////////////// GETTERS /////////////////////////
4353
inline uint32_t getStartDelay() { return _actualTS - _scheduledTS; }
54+
55+
///////////////////// VIRTUAL FUNCTIONS /////////////////////////
4456
// Fired on creation/destroy
4557
virtual void setup();
4658
virtual void cleanup();

src/ProcessScheduler/Scheduler.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33

44
#include "Includes.h"
55

6-
#ifndef SCHEDULER_JOB_QUEUE_SIZE
7-
#define SCHEDULER_JOB_QUEUE_SIZE 20
8-
#endif
9-
10-
#define ALL_PRIORITY_LEVELS -1
11-
126
typedef struct RingBuf RingBuf;
137

148
class Process;

0 commit comments

Comments
 (0)