sensorhandler: allow preconfigured unit and scale
Allow specifying the scale and unit for a sensor in the
YAML configuration. This can save clock time by no longer
requiring the daemon to reach out to the sensor owner for
the information.
Change-Id: I5f63286fc32fb9d64ebab7d86d1dbb7ff40591f4
Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp
index c5db13a..e081474 100644
--- a/scripts/writesensor.mako.cpp
+++ b/scripts/writesensor.mako.cpp
@@ -43,6 +43,9 @@
multiplier = sensor.get("multiplierM", 1)
offsetB = sensor.get("offsetB", 0)
exp = sensor.get("bExp", 0)
+ unit = sensor.get("unit", "")
+ scale = sensor.get("scale", 0)
+ hasScale = "true" if "scale" in sensor.keys() else "false"
valueReadingType = sensor["readingType"]
updateFunc = interfaceDict[serviceInterface]["updateFunc"]
updateFunc += sensor["readingType"]
@@ -61,7 +64,9 @@
mutability = sensor.get("mutability", "Mutability::Read")
%>
${sensorType},"${path}","${sensorInterface}",${readingType},${multiplier},
- ${offsetB},${exp},${offsetB * pow(10,exp)},${updateFunc},${getFunc},Mutability(${mutability}),{
+ ${offsetB},${exp},${offsetB * pow(10,exp)},
+ ${hasScale},${scale},"${unit}",
+ ${updateFunc},${getFunc},Mutability(${mutability}),{
% for interface,properties in interfaces.items():
{"${interface}",{
% for dbus_property,property_value in properties.items():
@@ -127,7 +132,7 @@
% endfor
}},
% endfor
- }
+ },
}},
% endif
% endfor