Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: IoT_LED_demo ServoTest uWater_Project hackathon ... more
Revision 61:143beb6d8800, committed 2015-09-06
- Comitter:
- ansond
- Date:
- Sun Sep 06 03:16:02 2015 +0000
- Parent:
- 60:167e8f021e30
- Commit message:
- fixes to observation configuration/toggle switch issues.
Changed in this revision
--- a/api/OptionsBuilder.cpp Sat Sep 05 20:14:22 2015 +0000
+++ b/api/OptionsBuilder.cpp Sun Sep 06 03:16:02 2015 +0000
@@ -150,14 +150,14 @@
OptionsBuilder &OptionsBuilder::addResource(const DynamicResource *resource)
{
// ensure that the boolean isn't mistaken by the compiler for the obs period...
- return this->addResource(resource,NSP_DEFAULT_OBS_PERIOD,!(((DynamicResource *)resource)->implementsObservation()));
+ return this->addResource(resource,NSP_DEFAULT_OBS_PERIOD,((DynamicResource *)resource)->isObservable());
}
// add dynamic resource
OptionsBuilder &OptionsBuilder::addResource(const DynamicResource *resource,const int sleep_time)
{
// ensure that the boolean isn't mistaken by the compiler for the obs period...
- return this->addResource(resource,sleep_time,!(((DynamicResource *)resource)->implementsObservation()));
+ return this->addResource(resource,sleep_time,((DynamicResource *)resource)->isObservable());
}
// add dynamic resource
--- a/api/ThreadedResourceObserver.cpp Sat Sep 05 20:14:22 2015 +0000
+++ b/api/ThreadedResourceObserver.cpp Sun Sep 06 03:16:02 2015 +0000
@@ -54,7 +54,16 @@
while(true) {
Thread::wait(me->getSleepTime());
if (me->isObserving() == true && me->getResource() != NULL && nsdl_endpoint_is_registered() == true) {
- me->getResource()->observe(me->getResource()->implementsObservation());
+ //
+ // implementsObservation(): This switch denotes whether this threaded resource generates its own observations or relies on the heartbeat (time-based) mechanism.
+ // -- if resource itself doesn't implement it, then we can call notify() with the get() on each heartbeat of the threaded resource (see note below)
+ // -- otherwise, we let the resource itself call observe() as part of its observation implementation
+ //
+ // note: this is independent of whether the resource, when declared, is defined as an observable resource or not. If not, then notify() wont be called
+ // as there will be no observations for this resource regardless of this switch value.
+ //
+ bool do_notify = !(me->getResource()->implementsObservation());
+ me->getResource()->observe(do_notify);
//__threaded_led = !__threaded_led;
}
}
--- a/api/TickerResourceObserver.cpp Sat Sep 05 20:14:22 2015 +0000
+++ b/api/TickerResourceObserver.cpp Sun Sep 06 03:16:02 2015 +0000
@@ -44,7 +44,16 @@
// notifier
void TickerResourceObserver::observationNotifier() {
if (this->isObserving() == true && this->getResource() != NULL && nsdl_endpoint_is_registered() == true) {
- this->getResource()->observe();
+ //
+ // implementsObservation(): This switch denotes whether this ticker resource generates its own observations or relies on the ticker (time-based) mechanism.
+ // -- if resource itself doesn't implement it, then we can call notify() with the get() on each heartbeat of the tickered resource (see note below)
+ // -- otherwise, we let the resource itself call observe() as part of its observation implementation
+ //
+ // note: this is independent of whether the resource, when declared, is defined as an observable resource or not. If not, then notify() wont be called
+ // as there will be no observations for this resource regardless of this switch value.
+ //
+ bool do_notify = !(this->getResource()->implementsObservation());
+ this->getResource()->observe(do_notify);
//__ticker_led = !__ticker_led;
}
}
