From 6223561894d2ab60cf4af2c5b5cc930c0a26d8c2 Mon Sep 17 00:00:00 2001 From: Emily Shaffer Date: Wed, 14 Jun 2017 13:06:26 -0700 Subject: 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 Signed-off-by: Patrick Venture --- scripts/writesensor.mako.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'scripts') 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 @@ extern const IdInfoMap sensors = { 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 @@ extern const IdInfoMap sensors = { 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 @@ except KeyError, e: % endfor }}, % endfor - } + }, }}, % endif % endfor -- cgit v1.2.1