diff options
| author | Patrick Venture <venture@google.com> | 2019-02-14 11:43:59 -0800 |
|---|---|---|
| committer | Patrick Venture <venture@google.com> | 2019-02-14 13:39:55 -0800 |
| commit | 18b1311e7588769c3da0a0250c28c80214cba2af (patch) | |
| tree | be96890caf597cf212bd021dbf2f276f83ff86a7 | |
| parent | 4cb7c058011760f6d1a485b865a72855f102c663 (diff) | |
| download | phosphor-pid-control-18b1311e7588769c3da0a0250c28c80214cba2af.tar.gz phosphor-pid-control-18b1311e7588769c3da0a0250c28c80214cba2af.zip | |
build: drop support for YAML configurations
phosphor-pid-control now only supports json configurations and no longer
builds from a YAML configuration.
Change-Id: I25fa7766399a1345dca89aac20e7b49caa46797e
Signed-off-by: Patrick Venture <venture@google.com>
| -rw-r--r-- | Makefile.am | 17 | ||||
| -rw-r--r-- | configure.ac | 16 | ||||
| -rw-r--r-- | dbus/dbusconfiguration.cpp | 6 | ||||
| -rw-r--r-- | examples/README | 82 | ||||
| -rw-r--r-- | examples/fan-info.json | 10 | ||||
| -rw-r--r-- | main.cpp | 33 | ||||
| -rw-r--r-- | scripts/README | 25 | ||||
| -rw-r--r-- | scripts/pid-example.txt | 24 | ||||
| -rw-r--r-- | scripts/pid-example.yaml | 59 | ||||
| -rw-r--r-- | scripts/pid_gen.py | 60 | ||||
| -rw-r--r-- | scripts/sensor-example.txt | 29 | ||||
| -rw-r--r-- | scripts/sensor-example.yaml | 31 | ||||
| -rw-r--r-- | scripts/sensor_gen.py | 60 | ||||
| -rw-r--r-- | scripts/writepid.mako.cpp | 57 | ||||
| -rw-r--r-- | scripts/writesensor.mako.cpp | 36 | ||||
| -rw-r--r-- | scripts/writezone.mako.cpp | 22 | ||||
| -rw-r--r-- | scripts/zone-example.txt | 4 | ||||
| -rw-r--r-- | scripts/zone-example.yaml | 3 | ||||
| -rw-r--r-- | scripts/zone_gen.py | 60 |
19 files changed, 107 insertions, 527 deletions
diff --git a/Makefile.am b/Makefile.am index 264ae1c..9a31124 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,20 +2,6 @@ AM_DEFAULT_SOURCE_EXT = .cpp sbin_PROGRAMS = swampd setsensor -if !CONFIGURE_DBUS -BUILT_SOURCES = sensorlist-gen.cpp pidlist-gen.cpp zoneinfo-gen.cpp -endif -CLEANFILES = $(BUILT_SOURCES) - -sensorlist-gen.cpp: - $(AM_V_GEN)@SENSORGEN@ -o $(top_builddir) generate-cpp - -pidlist-gen.cpp: - $(AM_V_GEN)@PIDGEN@ -o $(top_builddir) generate-cpp - -zoneinfo-gen.cpp: - $(AM_V_GEN)@ZONEGEN@ -o $(top_builddir) generate-cpp - setsensor_SOURCES = setsensor.cpp setsensor_LDADD = \ $(SDBUSPLUS_LIBS) \ @@ -76,8 +62,7 @@ libswampd_la_SOURCES = \ pid/pidthread.cpp \ threads/busthread.cpp \ build/buildjson.cpp \ - experiments/drive.cpp \ - $(BUILT_SOURCES) + experiments/drive.cpp if CONFIGURE_DBUS libswampd_la_SOURCES += dbus/dbusconfiguration.cpp diff --git a/configure.ac b/configure.ac index d7d34ff..978df6a 100644 --- a/configure.ac +++ b/configure.ac @@ -12,10 +12,6 @@ AM_PROG_AR AC_PROG_INSTALL AC_PROG_MAKE_SET -# Python -AM_PATH_PYTHON([2.7], [AC_SUBST([PYTHON], [echo "$PYTHON"])], -[AC_MSG_ERROR([Could not find python-2.7 installed...python-2.7 is required])]) - # Checks for typedefs, structures, and compiler characteristics. AX_CXX_COMPILE_STDCXX_17([noext]) AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CXXFLAGS]) @@ -93,18 +89,6 @@ AS_IF([test "x$enable_oe_sdk" == "xyes"], AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) ) -AS_IF([test "x$SENSOR_YAML_GEN" == "x"], [SENSOR_YAML_GEN="sensor-example.yaml"]) -SENSORGEN="$PYTHON ${srcdir}/scripts/sensor_gen.py -i $SENSOR_YAML_GEN" -AC_SUBST(SENSORGEN) - -AS_IF([test "x$PID_YAML_GEN" == "x"], [PID_YAML_GEN="pid-example.yaml"]) -PIDGEN="$PYTHON ${srcdir}/scripts/pid_gen.py -i $PID_YAML_GEN" -AC_SUBST(PIDGEN) - -AS_IF([test "x$ZONE_YAML_GEN" == "x"], [ZONE_YAML_GEN="zone-example.yaml"]) -ZONEGEN="$PYTHON ${srcdir}/scripts/zone_gen.py -i $ZONE_YAML_GEN" -AC_SUBST(ZONEGEN) - AC_ARG_ENABLE([configure-dbus], AS_HELP_STRING( [--enable-configure-dbus], [Enable configuring pid from D-Bus.] diff --git a/dbus/dbusconfiguration.cpp b/dbus/dbusconfiguration.cpp index fa7a3dd..5fceaa9 100644 --- a/dbus/dbusconfiguration.cpp +++ b/dbus/dbusconfiguration.cpp @@ -32,9 +32,9 @@ static constexpr bool DEBUG = false; // enable to print found configuration -std::map<std::string, struct SensorConfig> sensorConfig = {}; -std::map<int64_t, PIDConf> zoneConfig = {}; -std::map<int64_t, struct ZoneConfig> zoneDetailsConfig = {}; +extern std::map<std::string, struct SensorConfig> sensorConfig; +extern std::map<int64_t, PIDConf> zoneConfig; +extern std::map<int64_t, struct ZoneConfig> zoneDetailsConfig; constexpr const char* pidConfigurationInterface = "xyz.openbmc_project.Configuration.Pid"; diff --git a/examples/README b/examples/README new file mode 100644 index 0000000..33c2077 --- /dev/null +++ b/examples/README @@ -0,0 +1,82 @@ +# Sensor Config + +This program is only meant to control fans given thermal sensor readings. + +All sensors in phosphor-dbus-interfaces for OpenBMC use Sensor.Value as their +accessor. This provides read-only access to information. The goal of the +configuration is to specify how it can be read and if it's a fan, how the PID +output can be written. Initially there'll only be sysfs and passive dbus +access. If a writePath for a sensor is a dbus path, then the system will need +to verify which Control.Fan* interfaces is registered and send values to the +Target property of that interface. + +The min/max specified are to range a writePercent to the sensor. The current +FanController object outputs the new fan speed goal as a PWM percentage. Other +fan PID control objects may not, and they can leave the fields as 0 & 0. + +The only requirement for a sensor is that it isn't writeonly. Only fans are +expected to have a writePath set, and in this current version non-fan sensors +are assumed readonly. + +The sensor names are unique across all zones. + +"sensors" : [ + { + "name": "fan1", /* Name of the sensor. */ + "type": "fan", /* Type of sensor, fan, temp, margin */ + "readPath": "", /* How the sensor can be read[1] */ + "writePath": "", /* How the sensor can be set[2] */ + "min": 0, /* The minimum value used for scaling writes (int64) */ + "max": 255, /* The maximum value used for scaling writes (int64) */ + "timeout": 0 /* The timeout value for the sensor, used for failsafe, 0 + * means no timeout (int64) */ + }, +] + +[1] readPath has multiple options: +* If it has "/xyz/openbmc_project/extsensors/" in it, it's an EXTERNAL or + host-provided sensor. +* If it has "/xyz/openbmc_project/" in it, it's a sensor whose value is + received passively over dbus. +* If it has "/sys/" in it, it's a sensor read directly from sysfs. + +[2] +* This can be left blank if the sensor is read-only. +* If it has "/sys/" in it, it's a sensor written to sysfs. + * If min and max are non-zero, it'll convert the value to within the range. + and output that modified value. So, if it receives a value of .90 and min + is 0, and max is 255, it'll convert that to a value of 229.5 that is then + cast to int64_t. + +# PID Config + +The PID configuration is a list of PIDs per zone. + +"zones" : [ + { + "id": 1, /* zone id. */ + "minThermalRpm": 3000.0, /* The minimum thermal RPM value. (double) */ + "failsafePercent": 75.0, /* The percent to use when the zone is in fail-safe mode. (double) */ + "pids": [ + { + "name": "fan1-5", /* PID name */ + "type": "fan", /* Type of PID, fan, temp, or margin. */ + "inputs": ["fan1", "fan5"], /* Sensor names that are inputs for the PID */ + "setpoint": 90.0, /* For temp/margin PIDs this is the setpoint, ignored otherwise (double) */ + "pid": { + "samplePeriod": 0.1, /* The input sample period. (double) */ + "proportionalCoeff": 0.0, /* The proportional coefficient. (double) */ + "integralCoeff": 0.0, /* The integral coefficient. (double) */ + "feedFwdOffOffsetCoeff": 0.0, /* The feed-forward offset coefficient. (double) */ + "feedFwdGainCoeff": 0.010, /* The feed-forward gain coefficient. (double) */ + "integralLimit_min": 0.0, /* The integral limit clamp, min, max (double) */ + "integralLimit_max": 0.0, + "outLim_min": 30.0, /* the PID output clamp, min, max (double) */ + "outLim_max": 100.0, + "slewNeg": 0.0, /* The slew negative value. (double) */ + "slewPos": 0.0 /* The slew positive value. (double) */ + } + } + ] + } +] diff --git a/examples/fan-info.json b/examples/fan-info.json index 45afe3f..15c2d09 100644 --- a/examples/fan-info.json +++ b/examples/fan-info.json @@ -71,7 +71,7 @@ "inputs": ["fan1", "fan5"], "setpoint": 90.0, "pid": { - "sampleperiod": 0.1, + "samplePeriod": 0.1, "proportionalCoeff": 0.0, "integralCoeff": 0.0, "feedFwdOffOffsetCoeff": 0.0, @@ -90,7 +90,7 @@ "inputs": ["fan2", "fan6"], "setpoint": 90.0, "pid": { - "sampleperiod": 0.1, + "samplePeriod": 0.1, "proportionalCoeff": 0.0, "integralCoeff": 0.0, "feedFwdOffOffsetCoeff": 0.0, @@ -109,7 +109,7 @@ "inputs": ["fan3", "fan7"], "setpoint": 90.0, "pid": { - "sampleperiod": 0.1, + "samplePeriod": 0.1, "proportionalCoeff": 0.0, "integralCoeff": 0.0, "feedFwdOffOffsetCoeff": 0.0, @@ -128,7 +128,7 @@ "inputs": ["fan4", "fan8"], "setpoint": 90.0, "pid": { - "sampleperiod": 0.1, + "samplePeriod": 0.1, "proportionalCoeff": 0.0, "integralCoeff": 0.0, "feedFwdOffOffsetCoeff": 0.0, @@ -147,7 +147,7 @@ "inputs": ["fleeting0"], "setpoint": 10, "pid": { - "sampleperiod": 1, + "samplePeriod": 1, "proportionalCoeff": 750.0, "integralCoeff": 16.0, "feedFwdOffOffsetCoeff": 0.0, @@ -46,11 +46,11 @@ #endif /* The YAML converted sensor list. */ -extern std::map<std::string, struct SensorConfig> sensorConfig; +std::map<std::string, struct SensorConfig> sensorConfig = {}; /* The YAML converted PID list. */ -extern std::map<int64_t, PIDConf> zoneConfig; +std::map<int64_t, PIDConf> zoneConfig = {}; /* The YAML converted Zone configuration. */ -extern std::map<int64_t, struct ZoneConfig> zoneDetailsConfig; +std::map<int64_t, struct ZoneConfig> zoneDetailsConfig = {}; /** the swampd daemon will check for the existence of this file. */ constexpr auto jsonConfigurationPath = "/usr/share/swampd/config.json"; @@ -97,27 +97,26 @@ int main(int argc, char* argv[]) { dbus_configuration::init(modeControlBus); } -#endif +#else + const std::string& path = + (configPath.length() > 0) ? configPath : jsonConfigurationPath; /* * When building the sensors, if any of the dbus passive ones aren't on the * bus, it'll fail immediately. */ - if (configPath.length() > 0) + try { - try - { - auto jsonData = parseValidateJson(configPath); - sensorConfig = buildSensorsFromJson(jsonData); - std::tie(zoneConfig, zoneDetailsConfig) = - buildPIDsFromJson(jsonData); - } - catch (const std::exception& e) - { - std::cerr << "Failed during building: " << e.what() << "\n"; - exit(EXIT_FAILURE); /* fatal error. */ - } + auto jsonData = parseValidateJson(path); + sensorConfig = buildSensorsFromJson(jsonData); + std::tie(zoneConfig, zoneDetailsConfig) = buildPIDsFromJson(jsonData); + } + catch (const std::exception& e) + { + std::cerr << "Failed during building: " << e.what() << "\n"; + exit(EXIT_FAILURE); /* fatal error. */ } +#endif SensorManager mgmr = buildSensors(sensorConfig); std::unordered_map<int64_t, std::unique_ptr<PIDZone>> zones = diff --git a/scripts/README b/scripts/README deleted file mode 100644 index 8695774..0000000 --- a/scripts/README +++ /dev/null @@ -1,25 +0,0 @@ -# Sensor Config -This program is only meant to control fans given thermal sensor readings. - -All sensors in phosphor-dbus-interfaces for OpenBMC use Sensor.Value as their -accessor. This provides read-only access to information. The goal of the -configuration is to specify how it can be read and if it's a fan, how the PID -output can be written. Initially there'll only be sysfs and passive dbus -access. If a writePath for a sensor is a dbus path, then the system will need -to verify which Control.Fan* interfaces is registered and send values to the -Target property of that interface. - -The min/max specified are to range a writePercent to the sensor. The current -FanController object outputs the new fan speed goal as a PWM percentage. Other -fan PID control objects may not, and they can leave the fields as 0 & 0. - -The only requirement for a sensor is that it isn't writeonly. Only fans are -expected to have a writePath set, and in this current version non-fan sensors -are assumed readonly. - -The sensor names are unique across all zones. - -# PID Config - -The PID configuration is a list of PIDs per zone. - diff --git a/scripts/pid-example.txt b/scripts/pid-example.txt deleted file mode 100644 index 5161d7f..0000000 --- a/scripts/pid-example.txt +++ /dev/null @@ -1,24 +0,0 @@ -0x01: /* zone ID */ - fan2-6: /* PID name */ - type: fan /* Type of PID, fan, temp, or margin. */ - inputs: /* Sensor names that are inputs for the PID */ - fan2 - fan6 - /* For temp/margin PIDs this is the setpoint, ignored otherwise (double) */ - setpoint: 90.0 - pid: /* The PID calculation configuration. */ - samplePeriod: 0.1 /* The input sample period. (double) */ - proportionalCoeff: 0.01 /* The proportional coefficient. (double) */ - integralCoeff: 0.001 /* The integral coefficient. (double) */ - /* The feed-forward offset coefficient. (double) */ - feedFwdOffOffsetCoeff: 0.0 - /* The feed-forward gain coefficient. (double) */ - feedFwdGainCoeff: 0.0 - integralCoeff: /* The integral limit clamp, min, max (double) */ - min: 0 - max: 100 - outLimit: /* the PID output clamp, min, max (double) */ - min: 0 - max: 100 - slewNeg: -100 /* The slew negative value. (double) */ - slewPos: 0 /* The slew positive value. (double) */ diff --git a/scripts/pid-example.yaml b/scripts/pid-example.yaml deleted file mode 100644 index 001eab1..0000000 --- a/scripts/pid-example.yaml +++ /dev/null @@ -1,59 +0,0 @@ -0x01: - fan2-6: - type: fan - inputs: - fan2 - fan6 - setpoint: 90.0 - pid: - samplePeriod: 0.1 - proportionalCoeff: 0.01 - integralCoeff: 0.001 - feedFwdOffOffsetCoeff: 0.0 - feedFwdGainCoeff: 0.0 - integralLimit: - min: 0 - max: 100 - outLimit: - min: 0 - max: 100 - slewNeg: 0 - slewPos: 0 - temp1: - type: temp - inputs: - temp1 - setpoint: 30.0 - pid: - samplePeriod: 1 - proportionalCoeff: 94.0 - integralCoeff: 2.0 - feedFwdOffOffsetCoeff: 0.0 - feedFwdGainCoeff: 0.0 - integralLimit: - min: 3000 - max: 10000 - outLimit: - min: 3000 - max: 10000 - slewNeg: 0 - slewPos: 0 - sluggish0: - type: margin - inputs: - sluggish0 - setpoint: 50 - pid: - samplePeriod: 1 - proportionalCoeff: 94.0 - integralCoeff: 2.0 - feedFwdOffOffsetCoeff: 0.0 - feedFwdGainCoeff: 0.0 - integralLimit: - min: 3000 - max: 10000 - outLimit: - min: 3000 - max: 10000 - slewNeg: 0 - slewPos: 0 diff --git a/scripts/pid_gen.py b/scripts/pid_gen.py deleted file mode 100644 index cd62199..0000000 --- a/scripts/pid_gen.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -import yaml -import argparse -from mako.template import Template - - -def generate_cpp(sensor_yaml, output_dir): - with open(os.path.join(script_dir, sensor_yaml), 'r') as f: - ifile = yaml.safe_load(f) - if not isinstance(ifile, dict): - ifile = {} - - # Render the mako template - - t = Template(filename=os.path.join( - script_dir, - "writepid.mako.cpp")) - - output_cpp = os.path.join(output_dir, "pidlist-gen.cpp") - with open(output_cpp, 'w') as fd: - fd.write(t.render(PIDDict=ifile)) - - -def main(): - - valid_commands = { - 'generate-cpp': generate_cpp - } - parser = argparse.ArgumentParser( - description="IPMI Sensor parser and code generator") - - parser.add_argument( - '-i', '--sensor_yaml', dest='sensor_yaml', - default='example.yaml', help='input sensor yaml file to parse') - - parser.add_argument( - "-o", "--output-dir", dest="outputdir", - default=".", - help="output directory") - - parser.add_argument( - 'command', metavar='COMMAND', type=str, - choices=valid_commands.keys(), - help='Command to run.') - - args = parser.parse_args() - - if (not (os.path.isfile(os.path.join(script_dir, args.sensor_yaml)))): - sys.exit("Can not find input yaml file " + args.sensor_yaml) - - function = valid_commands[args.command] - function(args.sensor_yaml, args.outputdir) - - -if __name__ == '__main__': - script_dir = os.path.dirname(os.path.realpath(__file__)) - main() diff --git a/scripts/sensor-example.txt b/scripts/sensor-example.txt deleted file mode 100644 index b1318b8..0000000 --- a/scripts/sensor-example.txt +++ /dev/null @@ -1,29 +0,0 @@ -fan2: /* Name of the sensor. */ - type: fan /* Type of sensor, fan, temp, margin */ - /* How the sensor can be read[1] */ - readPath: /xyz/openbmc_project/sensors/fan_tach/fan2 - /* How the sensor can be set[2] */ - writePath: /sys/class/hwmon/hwmon0/pwm1 - /* The minimum value used for scaling writes (int64) */ - min: 0 - /* The maximum value used for scaling writes (int64) */ - max: 255 - /* The timeout value for the sensor, used for failsafe, 0 means no timeout - * (int64) - */ - timeout: 0 - -[1] readPath has multiple options: -* If it has "/xyz/openbmc_project/extsensors/" in it, it's an EXTERNAL or - host-provided sensor. -* If it has "/xyz/openbmc_project/" in it, it's a sensor whose value is - received passively over dbus. -* If it has "/sys/" in it, it's a sensor read directly from sysfs. - -[2] -* This can be left blank if the sensor is read-only. -* If it has "/sys/" in it, it's a sensor written to sysfs. - * If min and max are non-zero, it'll convert the value to within the range. - and output that modified value. So, if it receives a value of .90 and min - is 0, and max is 255, it'll convert that to a value of 229.5 that is then - cast to int64_t. diff --git a/scripts/sensor-example.yaml b/scripts/sensor-example.yaml deleted file mode 100644 index 1debe3e..0000000 --- a/scripts/sensor-example.yaml +++ /dev/null @@ -1,31 +0,0 @@ -fan2: - type: fan - readPath: /xyz/openbmc_project/sensors/fan_tach/fan2 - writePath: /sys/class/hwmon/hwmon0/pwm1 - min: 0 - max: 255 - timeout: 0 - -fan6: - type: fan - readPath: /xyz/openbmc_project/sensors/fan_tach/fan6 - writePath: - min: 0 - max: 0 - timeout: 0 - -temp1: - type: temp - readPath: /xyz/openbmc_project/sensors/temperature/temp1 - writePath: - min: 0 - max: 0 - timeout: 0 - -sluggish0: - type: margin - readPath: /xyz/openbmc_project/extsensors/margin/sluggish0 - writePath: - min: 0 - max: 0 - timeout: 0 diff --git a/scripts/sensor_gen.py b/scripts/sensor_gen.py deleted file mode 100644 index 7e9c6ca..0000000 --- a/scripts/sensor_gen.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -import yaml -import argparse -from mako.template import Template - - -def generate_cpp(sensor_yaml, output_dir): - with open(os.path.join(script_dir, sensor_yaml), 'r') as f: - ifile = yaml.safe_load(f) - if not isinstance(ifile, dict): - ifile = {} - - # Render the mako template - - t = Template(filename=os.path.join( - script_dir, - "writesensor.mako.cpp")) - - output_cpp = os.path.join(output_dir, "sensorlist-gen.cpp") - with open(output_cpp, 'w') as fd: - fd.write(t.render(sensorDict=ifile)) - - -def main(): - - valid_commands = { - 'generate-cpp': generate_cpp - } - parser = argparse.ArgumentParser( - description="IPMI Sensor parser and code generator") - - parser.add_argument( - '-i', '--sensor_yaml', dest='sensor_yaml', - default='example.yaml', help='input sensor yaml file to parse') - - parser.add_argument( - "-o", "--output-dir", dest="outputdir", - default=".", - help="output directory") - - parser.add_argument( - 'command', metavar='COMMAND', type=str, - choices=valid_commands.keys(), - help='Command to run.') - - args = parser.parse_args() - - if (not (os.path.isfile(os.path.join(script_dir, args.sensor_yaml)))): - sys.exit("Can not find input yaml file " + args.sensor_yaml) - - function = valid_commands[args.command] - function(args.sensor_yaml, args.outputdir) - - -if __name__ == '__main__': - script_dir = os.path.dirname(os.path.realpath(__file__)) - main()
\ No newline at end of file diff --git a/scripts/writepid.mako.cpp b/scripts/writepid.mako.cpp deleted file mode 100644 index 2e6738d..0000000 --- a/scripts/writepid.mako.cpp +++ /dev/null @@ -1,57 +0,0 @@ -## This file is a template. The comment below is emitted -## into the rendered file; feel free to edit this file. - -// !!! WARNING: This is GENERATED Code... Please do NOT edit !!! - -#include <map> -#include "conf.hpp" - -std::map<int64_t, PIDConf> zoneConfig = { -% for zone in PIDDict.iterkeys(): - % if zone: - {${zone}, - { - % for key, details in PIDDict[zone].iteritems(): - {"${key}", - {"${details['type']}", - { - % for item in details['inputs'].split(): - "${item}", - % endfor - }, - <% - # If the PID type is a fan, setpoint field is unused, - # so just use a default of 0. If the PID is not a type - # of fan, require the setpoint field. - if 'fan' == details['type']: - setpoint = 0 - else: - setpoint = details['setpoint'] - - neg_hysteresis = 0 - pos_hysteresis = 0 - if 'neg_hysteresis' in details['pid']: - neg_hysteresis = details['pid']['neg_hysteresis'] - if 'pos_hysteresis' in details['pid']: - pos_hysteresis = details['pid']['pos_hysteresis'] - %> - ${setpoint}, - {${details['pid']['samplePeriod']}, - ${details['pid']['proportionalCoeff']}, - ${details['pid']['integralCoeff']}, - ${details['pid']['feedFwdOffOffsetCoeff']}, - ${details['pid']['feedFwdGainCoeff']}, - {${details['pid']['integralLimit']['min']}, ${details['pid']['integralLimit']['max']}}, - {${details['pid']['outLimit']['min']}, ${details['pid']['outLimit']['max']}}, - ${details['pid']['slewNeg']}, - ${details['pid']['slewPos']}, - ${neg_hysteresis}, - ${pos_hysteresis}}, - }, - }, - % endfor - }, - }, - % endif -% endfor -}; diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp deleted file mode 100644 index 56e7965..0000000 --- a/scripts/writesensor.mako.cpp +++ /dev/null @@ -1,36 +0,0 @@ -## This file is a template. The comment below is emitted -## into the rendered file; feel free to edit this file. - -// !!! WARNING: This is GENERATED Code... Please do NOT edit !!! - -#include <map> -#include "conf.hpp" - -std::map<std::string, struct SensorConfig> sensorConfig = { -% for key in sensorDict.iterkeys(): - % if key: - <% - sensor = sensorDict[key] - type = sensor["type"] - readPath = sensor["readPath"] - writePath = sensor.get("writePath", "") - min = sensor.get("min", 0) - max = sensor.get("max", 0) - # Presently only thermal inputs have their timeout - # checked, but we should default it as 2s, which is - # the previously hard-coded value. - # If it's a fan sensor though, let's set the default - # to 0. - if type == "fan": - timeout = sensor.get("timeout", 0) - else: - timeout = sensor.get("timeout", 2) - %> - {"${key}", - {"${type}","${readPath}","${writePath}", ${min}, ${max}, ${timeout}}, - }, - % endif -% endfor -}; - - diff --git a/scripts/writezone.mako.cpp b/scripts/writezone.mako.cpp deleted file mode 100644 index f466060..0000000 --- a/scripts/writezone.mako.cpp +++ /dev/null @@ -1,22 +0,0 @@ -## This file is a template. The comment below is emitted -## into the rendered file; feel free to edit this file. - -// !!! WARNING: This is GENERATED Code... Please do NOT edit !!! - -#include <map> -#include "conf.hpp" - -std::map<int64_t, struct ZoneConfig> zoneDetailsConfig = { -% for zone in ZoneDict.iterkeys(): - % if zone: - <% - zConf = ZoneDict[zone] - min = zConf["minThermalRpm"] - percent = zConf["failsafePercent"] - %> - {${zone}, - {${min}, ${percent}}, - }, - % endif -% endfor -}; diff --git a/scripts/zone-example.txt b/scripts/zone-example.txt deleted file mode 100644 index 3f987a2..0000000 --- a/scripts/zone-example.txt +++ /dev/null @@ -1,4 +0,0 @@ -0x01: /* The zone ID */ - minThermalRpm: 3000.0 /* The minimum thermal RPM value. (double) */ - /* The percent to use when the zone is in fail-safe mode. (double) */ - failsafePercent: 90.0 diff --git a/scripts/zone-example.yaml b/scripts/zone-example.yaml deleted file mode 100644 index 8fecf71..0000000 --- a/scripts/zone-example.yaml +++ /dev/null @@ -1,3 +0,0 @@ -0x01: - minThermalRpm: 3000.0 - failsafePercent: 90.0 diff --git a/scripts/zone_gen.py b/scripts/zone_gen.py deleted file mode 100644 index a98a3b5..0000000 --- a/scripts/zone_gen.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -import yaml -import argparse -from mako.template import Template - - -def generate_cpp(zoneinfo_yaml, output_dir): - with open(os.path.join(script_dir, zoneinfo_yaml), 'r') as f: - ifile = yaml.safe_load(f) - if not isinstance(ifile, dict): - ifile = {} - - # Render the mako template - - t = Template(filename=os.path.join( - script_dir, - "writezone.mako.cpp")) - - output_cpp = os.path.join(output_dir, "zoneinfo-gen.cpp") - with open(output_cpp, 'w') as fd: - fd.write(t.render(ZoneDict=ifile)) - - -def main(): - - valid_commands = { - 'generate-cpp': generate_cpp - } - parser = argparse.ArgumentParser( - description="IPMI Zone info parser and code generator") - - parser.add_argument( - '-i', '--zoneinfo_yaml', dest='zoneinfo_yaml', - default='example.yaml', help='input zone yaml file to parse') - - parser.add_argument( - "-o", "--output-dir", dest="outputdir", - default=".", - help="output directory") - - parser.add_argument( - 'command', metavar='COMMAND', type=str, - choices=valid_commands.keys(), - help='Command to run.') - - args = parser.parse_args() - - if (not (os.path.isfile(os.path.join(script_dir, args.zoneinfo_yaml)))): - sys.exit("Can not find input yaml file " + args.zoneinfo_yaml) - - function = valid_commands[args.command] - function(args.zoneinfo_yaml, args.outputdir) - - -if __name__ == '__main__': - script_dir = os.path.dirname(os.path.realpath(__file__)) - main() |

