GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing averageguy.github.io — TaskSched: Task Class Reference
Public Types |
Public Member Functions |
Static Public Member Functions |
Friends |
List of all members
Task Class Reference Represents a schedulable task. More...
Detailed DescriptionRepresents a schedulable task. Define a new Task.
The Task class encapsulates a function to be called at regular intervals, along with parameters controlling its execution. Definition at line 80 of file TaskSched.h. Member Typedef Documentation◆ TaskCallback
Definition at line 92 of file TaskSched.h. ◆ VoidCallback
Definition at line 93 of file TaskSched.h. Constructor & Destructor Documentation◆ Task() [1/2]
Constructs a new Task.
Definition at line 7 of file TaskSched.cpp. 8 : mProcWithTask(func), mProcVoid(nullptr), mWithTaskPtr(true)
9 {
10 // Initialize other members...
11 //mProc=func;
12 mInterval=interval;
13 mEnabled=enabled;
14 mIterations=iterations;
15 mName=name;
16 mRunImmediately=runImmediately;
17 mOrig.mEnabled=enabled;
18 mOrig.mInterval=mInterval;
19 mOrig.mIterations=iterations;
20 mOrig.mRunImmediately=runImmediately;
21 mLastStartTime=millis();
22 mIterationCount=0;
23 }
References InitialState::mEnabled, InitialState::mInterval, InitialState::mIterations, and InitialState::mRunImmediately. ◆ Task() [2/2]
Definition at line 25 of file TaskSched.cpp. 26 : mProcWithTask(nullptr), mProcVoid(func), mWithTaskPtr(false)
27 {
28 // Initialize other members...
29 //mProc=func;
30 mInterval=interval;
31 mEnabled=enabled;
32 mIterations=iterations;
33 mName=name;
34 mRunImmediately=runImmediately;
35 mOrig.mEnabled=enabled;
36 mOrig.mInterval=interval;
37 mOrig.mIterations=iterations;
38 mOrig.mRunImmediately=runImmediately;
39 mLastStartTime=millis();
40 mIterationCount=0;
41 }
References InitialState::mEnabled, InitialState::mInterval, InitialState::mIterations, and InitialState::mRunImmediately. Member Function Documentation◆ disable()
disable the task Definition at line 66 of file TaskSched.cpp. 66 {
67 mEnabled=false;
68 mIterationCount=0;
69 return;
70 }
◆ enable()
enable the task Definition at line 128 of file TaskSched.cpp. 128 {
129 mEnabled=true;
130 mLastStartTime=millis();
131 #ifdef DEBUG
132 Serial.printf("Enabling %s\n",mName.c_str());
133 #endif
134 return;
135 }
◆ formatMS()
return a string with a formatted time
Definition at line 87 of file TaskSched.cpp. 87 {
88
89 int minutes = milliseconds / 60000;
90 int seconds = (milliseconds % 60000) / 1000;
91 int ms = (milliseconds % 1000);
92
93 char res[20];
94 sprintf(res, "%02d:%02d.%03d", minutes, seconds, ms);
95 #ifdef DEBUG
96 Serial.printf("%s %d %s\n",__FILE__,__LINE__,res);
97 #endif
98
99 return String(res);
100 }
Referenced by showInit(), and showTaskInfo(). ◆ fRunImmediately()
return true if the run immediately flag is set
◆ getInterval()
return the task interval
Definition at line 183 of file TaskSched.cpp. 184 {
185 return mInterval;
186 }
Referenced by showTaskInfo(). ◆ getIterationCount()
return the iteration count, that is the number of iterations that the task has been run
Definition at line 193 of file TaskSched.cpp. 194 {
195 return mIterationCount;
196 }
◆ getLastStartTime()
return the last start time flag
Definition at line 188 of file TaskSched.cpp. 189 {
190 return mLastStartTime;
191 }
Referenced by showTaskInfo(). ◆ getName()
return string containing name of task
Definition at line 50 of file TaskSched.cpp. 51 {
52 return mName;
53 }
Referenced by Sched::addTask(), Sched::run(), and showTaskInfo(). ◆ getRunImmediately()
return the run immediately flag
Definition at line 178 of file TaskSched.cpp. 179 {
180 return mRunImmediately;
181 }
Referenced by showTaskInfo(). ◆ isEnabled()
return true if task is enabled
Definition at line 124 of file TaskSched.cpp. 124 {
125 return mEnabled;
126 }
Referenced by Sched::run(), and showTaskInfo(). ◆ isFirstIteration()
return true if this is the first iteration
Definition at line 43 of file TaskSched.cpp. 43 {
44 if(mIterationCount == 0) {
45 return true;
46 }
47 return false;
48 }
◆ isLastIteration()
return true if this is the last iteration
Definition at line 55 of file TaskSched.cpp. 55 {
56 // Serial.printf("count = %ld, Iter = %ld\n",mIterationCount,mIterations);
57 if(mIterations <= 0) {
58 return false;
59 }
60 if(mIterationCount >=mIterations-1) {
61 return true;
62 }
63 return false;
64 }
◆ restart()
restart the task with the original parameters, Enable is not restored Definition at line 137 of file TaskSched.cpp. 137 {
138 mInterval=mOrig.mInterval;
139 mIterations=mOrig.mIterations;
140 mEnabled=false;
141 mIterationCount=0;
142 mRunImmediately=mOrig.mRunImmediately;
143 #ifdef DEBUG
144 Serial.printf("Restarting %s\n",mName.c_str());
145 #endif
146 return;
147 }
References InitialState::mInterval, InitialState::mIterations, and InitialState::mRunImmediately. ◆ setCallback() [1/2]
Sets a new callback function for the task.
Definition at line 154 of file TaskSched.cpp. 154 {
155 //mProc=func;
156 mProcWithTask=func;
157 }
◆ setCallback() [2/2]
Sets a new callback function for the task.
Definition at line 149 of file TaskSched.cpp. 149 {
150 //mProc=func;
151 mProcVoid=func;
152 }
◆ setImmediately()
function to set the run immediately flag Definition at line 163 of file TaskSched.cpp. 164 {
165 mRunImmediately = newImmediately;
166 }
◆ setInterval()
function to set a new interval Definition at line 173 of file TaskSched.cpp. 174 {
175 mInterval = newInterval;
176 }
◆ setIterations()
function to set a new iterations value Definition at line 168 of file TaskSched.cpp. 169 {
170 mIterations = newIterations;
171 }
◆ setName()
give the task a new name Definition at line 159 of file TaskSched.cpp. 159 {
160 mName=newName;
161 }
◆ showInit()
display stuff Definition at line 72 of file TaskSched.cpp. 72 {
73 if(!doShow) {
74 return;
75 }
76 doShow=false; // only do it once
77 #ifdef DEBUG
78
79 res = Task::formatMS(mInterval);
80 Serial.printf("%s %d showInit: Name: %s, interval: %s, enabled:%d, iterations:%ld %x\n",
81 __FILE__,__LINE__,mName,res,mEnabled,mIterations,this);
82 #endif
83
84 return;
85 }
static String formatMS(unsigned long milliseconds) return a string with a formatted time Definition: TaskSched.cpp:87 References formatMS(). Referenced by Sched::run(). ◆ showTaskInfo()
function that displays task info
Definition at line 102 of file TaskSched.cpp. 103 {
104
105 char buf[200];
107 String sDiff= Task::formatMS(diff);
109 #ifdef DEBUG
110 Serial.printf("%s %d Task %s, Enabled? %d, Diff %s, Interval %s, RI %d\n",__FILE__,__LINE__,this->getName().c_str(),isEnabled(),sDiff.c_str(),sInt.c_str(),getRunImmediately());
111 if(passedInterval >0) {
112 Serial.printf("For float interval passed in %f, mInterval became %ld\n",passedInterval,mInterval);
113 }
114 #else
115 sprintf(buf,"Task %s, Enabled? %d, Diff %s, Interval %s, RunIm %d\n",this->getName().c_str(),isEnabled(),sDiff.c_str(),sInt.c_str(),getRunImmediately());
116 String ret(buf);
117 return ret;
118
119 #endif
120
121 return "";
122 }
unsigned long getLastStartTime(void) const return the last start time flag Definition: TaskSched.cpp:188 References formatMS(), getInterval(), getLastStartTime(), getName(), getRunImmediately(), and isEnabled(). Friends And Related Function Documentation◆ Sched
Definition at line 88 of file TaskSched.h. The documentation for this class was generated from the following files: Generated by | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||