pwmsensor: signal properties changed for opposite iface
When the control interface updates, signal the sensor
and vise versa so they are always in sync.
Change-Id: I8f18ea41547de8e694bcae74f967c39530e0958a
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/PwmSensor.cpp b/src/PwmSensor.cpp
index dabc2f8..047d5ea 100644
--- a/src/PwmSensor.cpp
+++ b/src/PwmSensor.cpp
@@ -44,14 +44,27 @@
throw std::runtime_error("Value out of range");
return -1;
}
+ if (req == resp)
+ {
+ return 1;
+ }
double value = (req / 100) * pwmMax;
setValue(static_cast<int>(value));
resp = req;
+
+ controlInterface->signal_property("Target");
+
return 1;
},
[this](double& curVal) {
float value = 100.0 * (static_cast<float>(getValue()) / pwmMax);
- curVal = value;
+ if (curVal != value)
+ {
+ curVal = value;
+ controlInterface->signal_property("Target");
+ sensorInterface->signal_property("Value");
+ }
+
return curVal;
});
// pwm sensor interface is in percent
@@ -69,12 +82,26 @@
throw std::runtime_error("Value out of range");
return -1;
}
+ if (req == resp)
+ {
+ return 1;
+ }
setValue(req);
resp = req;
+
+ sensorInterface->signal_property("Value");
+
return 1;
},
[this](uint64_t& curVal) {
- curVal = getValue();
+ uint64_t value = getValue();
+ if (curVal != value)
+ {
+ curVal = value;
+ controlInterface->signal_property("Target");
+ sensorInterface->signal_property("Value");
+ }
+
return curVal;
});
sensorInterface->initialize();