Doug Anson / mbedConnectorInterface

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Files at this revision

API Documentation at this revision

Comitter:
ansond
Date:
Sat Sep 05 20:14:22 2015 +0000
Parent:
59:3b99f4901e85
Child:
61:143beb6d8800
Commit message:
update to enable the Threaded (RTOS) based resources that are setup as time-based observers to control their own observation events...

Changed in this revision

api/DynamicResource.cpp Show annotated file Show diff for this revision Revisions of this file
api/DynamicResource.h Show annotated file Show diff for this revision Revisions of this file
api/ThreadedResourceObserver.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/api/DynamicResource.cpp	Sat Jul 25 06:04:40 2015 +0000
+++ b/api/DynamicResource.cpp	Sat Sep 05 20:14:22 2015 +0000
@@ -404,8 +404,20 @@
 
 // default observe behavior
 void DynamicResource::observe() {
+    this->observe(true);
+}
+
+// behavior controlled observe behavior
+void DynamicResource::observe(bool do_notify) {
     if (this->m_observable == true) {
-        this->notify(this->get());
+        if (do_notify) {
+            // get() and notify() --> time-based observationing
+            this->notify(this->get());
+        }
+        else {
+            // get() only (resource controls whether each iteration results in an observation or not...) 
+            this->get();
+        }
     }
 }
 
--- a/api/DynamicResource.h	Sat Jul 25 06:04:40 2015 +0000
+++ b/api/DynamicResource.h	Sat Sep 05 20:14:22 2015 +0000
@@ -157,10 +157,15 @@
     void setDataWrapper(DataWrapper *data_wrapper) { this->m_data_wrapper = data_wrapper; }
     
     /**
-    observe the resource
+    observe the resource (default)
     */
     virtual void observe();
     
+    /**
+    observe the resource (controlled observing)
+    */
+    virtual void observe(bool do_notify);
+    
 protected:
     int notify(uint8_t *data,int data_length);
     DataWrapper *getDataWrapper() { return this->m_data_wrapper; }
--- a/api/ThreadedResourceObserver.cpp	Sat Jul 25 06:04:40 2015 +0000
+++ b/api/ThreadedResourceObserver.cpp	Sat Sep 05 20:14:22 2015 +0000
@@ -54,7 +54,7 @@
      while(true) {
          Thread::wait(me->getSleepTime());
          if (me->isObserving() == true && me->getResource() != NULL && nsdl_endpoint_is_registered() == true) {
-             me->getResource()->observe();
+             me->getResource()->observe(me->getResource()->implementsObservation());
              //__threaded_led = !__threaded_led;
          }
      }