job scheduler works with run once and run periodic schedules. Stop logic is not fully thought through.

Dependencies:   LinkedList

Dependents:   JobSchedulerDemo Borsch

Revision:
16:f61b62b119dd
Parent:
8:4ead1f4ab741
--- a/schedules.h	Wed Aug 02 22:03:50 2017 +0000
+++ b/schedules.h	Thu Aug 03 00:00:13 2017 +0000
@@ -6,16 +6,24 @@
 
     class RunOnceSchedule: public ISchedule {
         public:
-            RunOnceSchedule(time_t time): _time(time) {};
+            RunOnceSchedule(time_t time): _time(time) {}
             
-            virtual ~RunOnceSchedule() {};
+            time_t AtTime() {
+                return _time;
+            }
+            
+            virtual ~RunOnceSchedule() {}
             
             virtual time_t NextRunTime(time_t from) {
                 time_t current = _time;
                 _time = 0;
                 return current;
-            };
-        
+            }
+            
+            virtual int ScheduleType() {
+                return 1;  // matches protocol_ScheduleType_RunOnce in job.pb.h
+            }
+                    
         private:
             time_t _time;
     };
@@ -25,7 +33,7 @@
             RunPeriodicSchedule(time_t period, int limit = 0)
             : _period(period), _limit(limit), _counter(0) {};
             
-            virtual ~RunPeriodicSchedule() {};
+            virtual ~RunPeriodicSchedule() {}
             
             virtual time_t NextRunTime(time_t from) {
                 if (_limit > 0 && _counter == _limit) {
@@ -35,7 +43,11 @@
                 _counter++;
                 time_t next = from + _period;
                 return next;
-            };
+            }
+            
+            virtual int ScheduleType() {
+                return 2;  // matches protocol_ScheduleType_Periodic in job.pb.h
+            }
         
         private:
             time_t _period;