summaryrefslogtreecommitdiffstats
path: root/scripts/writesensor.mako.cpp
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-02-23 17:29:08 +0530
committerRatan Gupta <ratagupt@in.ibm.com>2017-03-15 09:45:16 +0530
commit0065905e1aad15bd35edc4957a56e5fd7fca963a (patch)
treeab1f405a03b8cbca49a6c856a78ba3467d5db4f4 /scripts/writesensor.mako.cpp
parentb12b0c011f41d3cad863b19285f710aec5000748 (diff)
downloadphosphor-host-ipmid-0065905e1aad15bd35edc4957a56e5fd7fca963a.tar.gz
phosphor-host-ipmid-0065905e1aad15bd35edc4957a56e5fd7fca963a.zip
inventory: write sensor yaml parser
Write python-based parser for sensor.yaml. The parser generates sensor-gen.cpp,which is having a map of sensorid(key) and sensorinfo(value). Change-Id: I5aa2d2bc871ced06e5e4c164a67eeb5974031d5d Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'scripts/writesensor.mako.cpp')
-rw-r--r--scripts/writesensor.mako.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp
new file mode 100644
index 0000000..0b8d5f1
--- /dev/null
+++ b/scripts/writesensor.mako.cpp
@@ -0,0 +1,54 @@
+## This file is a template. The comment below is emitted
+## into the rendered file; feel free to edit this file.
+
+// !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!!
+
+#include "types.hpp"
+using namespace ipmi::sensor;
+
+extern const IdInfoMap sensors = {
+% for key in sensorDict.iterkeys():
+ % if key:
+{${key},{
+<%
+ sensor = sensorDict[key]
+ interfaces = sensor["interfaces"]
+ path = sensor["path"]
+ sensorType = sensor["sensorType"]
+ readingType = sensor["sensorReadingType"]
+%>
+ ${sensorType},"${path}",${readingType},{
+ % for interface,properties in interfaces.iteritems():
+ {"${interface}",{
+ % for dbus_property,property_value in properties.iteritems():
+ {"${dbus_property}",{
+ % for offset,values in property_value.iteritems():
+ { ${offset},{
+<%
+ valueType = values["type"]
+%>
+ % for name,value in values.iteritems():
+ % if name == "type":
+<%
+ continue
+%>
+ % endif
+ % if valueType == "string":
+ std::string("${value}"),
+ % else:
+ ${value},
+ % endif
+ % endfor
+ }
+ },
+ % endfor
+ }},
+ % endfor
+ }},
+ % endfor
+ }
+}},
+ % endif
+% endfor
+};
+
OpenPOWER on IntegriCloud