run once and run periodic example work

Dependencies:   JobScheduler

Files at this revision

API Documentation at this revision

Comitter:
sgnezdov
Date:
Wed Aug 02 22:04:02 2017 +0000
Parent:
8:8a65353ec8f3
Commit message:
added JobList testing

Changed in this revision

JobScheduler.lib Show annotated file Show diff for this revision Revisions of this file
source/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/JobScheduler.lib	Fri Jul 14 00:01:13 2017 +0000
+++ b/JobScheduler.lib	Wed Aug 02 22:04:02 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/sgnezdov/code/JobScheduler/#df18df016d7e
+https://developer.mbed.org/users/sgnezdov/code/JobScheduler/#6b8fa5dff770
--- a/source/main.cpp	Fri Jul 14 00:01:13 2017 +0000
+++ b/source/main.cpp	Wed Aug 02 22:04:02 2017 +0000
@@ -28,6 +28,21 @@
     printf("Job B\n");
 }
 
+void printJobs(JobScheduler::Scheduler& scheduler)
+{
+    LinkedList<JobScheduler::Job> jobs;
+    scheduler.JobList(jobs);
+    printf("  Job List:\n");
+    node<JobScheduler::Job>* jn = jobs.pop(1);
+    while (jn != NULL) {
+        printf("Job ID: %d\n", jn->data->GetID());
+        jobs.remove(1);
+        jn = jobs.pop(1);
+    }
+    printf("  Job List Completed\n");
+}
+
+
 void runScheduler() 
 {
     /* Setup tracing */
@@ -77,18 +92,25 @@
     time_t nowSecs = time(NULL);
     JobScheduler::Response<JobScheduler::JobID> res = scheduler.JobAdd(1, new JobScheduler::RunOnceSchedule(nowSecs + 2), NULL);
     printf("job A add response error: %d, jobID: %d\n", res.error, res.data);
+    
+    printJobs(scheduler);
     wait(5);
     
     printf("periodic with 2 sec period and limit 3\n");
     res = scheduler.JobAdd(2, new JobScheduler::RunPeriodicSchedule(2, 3), NULL);
     printf("job B add response error: %d, jobID: %d\n", res.error, res.data);
+    printJobs(scheduler);
     wait(10);
+    printJobs(scheduler);
     scheduler.Stop();
     scheduler.WaitToStop();
 }
 
 int main()
 {
+    Serial pc(USBTX, USBRX);
+    pc.baud(115200);
+
     printf("\nJob Scheduler Demo\n");
     runScheduler();
     printf("done\n");