summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2017-04-12 09:51:41 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-05-04 16:01:30 +0000
commit77d32d1b0b780b9ac773bc49a6c74c19508ff8e8 (patch)
treec86bf7542d3eb1593678f77a89ffed3adaf129ab
parent78498c941d3f0445e2c62894123e05df057258f7 (diff)
downloadphosphor-fan-presence-77d32d1b0b780b9ac773bc49a6c74c19508ff8e8.tar.gz
phosphor-fan-presence-77d32d1b0b780b9ac773bc49a6c74c19508ff8e8.zip
Fan control: Enable data generation
Start running the python script that generates the fan zone data structures during the build. If the paths to the 2 yaml files aren't provided during configure, then the yaml in the example directory will be used instead. Change-Id: I9f67c1b94b5302c30ac87b0f80746854c42776b2 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
-rw-r--r--.gitignore1
-rw-r--r--configure.ac27
-rw-r--r--control/Makefile.am9
-rw-r--r--control/example/fans.yaml28
-rw-r--r--control/example/zones.yaml49
-rw-r--r--control/generated.cpp25
6 files changed, 113 insertions, 26 deletions
diff --git a/.gitignore b/.gitignore
index f3d36e5..b49549b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,4 @@ stamp-h1
fan_detect_defs.cpp
phosphor-fan-presence-tach
phosphor-fan-control
+fan_zone_defs.cpp
diff --git a/configure.ac b/configure.ac
index 12337c3..4a1cecd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,33 @@ AS_IF([test "x$enable_presence" != "xno"], [
])
AS_IF([test "x$enable_control" != "xno"], [
+ # Add optional yaml file arguments
+ AC_ARG_VAR(FAN_DEF_YAML_FILE,
+ [The fan definition file to use])
+ AS_IF([test "x$FAN_DEF_YAML_FILE" == "x"],
+ [FAN_DEF_YAML_FILE="${srcdir}/control/example/fans.yaml"])
+ AC_DEFINE_UNQUOTED([FAN_DEF_YAML_FILE], ["$FAN_DEF_YAML_FILE"],
+ [The fan definition file to use])
+
+ AC_ARG_VAR(FAN_ZONE_YAML_FILE,
+ [The fan zone definition file to use])
+ AS_IF([test "x$FAN_ZONE_YAML_FILE" == "x"],
+ [FAN_ZONE_YAML_FILE="${srcdir}/control/example/zones.yaml"])
+ AC_DEFINE_UNQUOTED([FAN_ZONE_YAML_FILE], ["$FAN_ZONE_YAML_FILE"],
+ [The fan zone definition file to use])
+
+ AC_ARG_VAR(FAN_ZONE_OUTPUT_DIR,
+ [The output directory for the generated fan zone data file])
+ AS_IF([test "x$FAN_ZONE_OUTPUT_DIR" == "x"],
+ [FAN_ZONE_OUTPUT_DIR="${srcdir}/control/"])
+ AC_DEFINE_UNQUOTED([FAN_ZONE_OUTPUT_DIR], ["$FAN_ZONE_OUTPUT_DIR"],
+ [The output directory for the generated fan zone data file])
+
+ AC_SUBST([GEN_FAN_ZONE_DEFS],
+ [$PYTHON ${srcdir}/control/gen-fan-zone-defs.py \
+ -f $FAN_DEF_YAML_FILE \
+ -z $FAN_ZONE_YAML_FILE \
+ -o $FAN_ZONE_OUTPUT_DIR])
AC_CONFIG_FILES([control/Makefile])
])
diff --git a/control/Makefile.am b/control/Makefile.am
index fc2a2dc..04d7d96 100644
--- a/control/Makefile.am
+++ b/control/Makefile.am
@@ -5,12 +5,14 @@ sbin_PROGRAMS = \
phosphor-fan-control
phosphor_fan_control_SOURCES = \
- generated.cpp \
fan.cpp \
main.cpp \
manager.cpp \
zone.cpp
+nodist_phosphor_fan_control_SOURCES = \
+ fan_zone_defs.cpp
+
phosphor_fan_control_LDADD = \
$(top_builddir)/libfan.la \
$(SDBUSPLUS_LIBS) \
@@ -19,3 +21,8 @@ phosphor_fan_control_LDADD = \
phosphor_fan_control_CXXFLAGS = \
$(SDBUSPLUS_CFLAGS) \
$(PHOSPHOR_LOGGING_CFLAGS)
+
+BUILT_SOURCES = fan_zone_defs.cpp
+
+fan_zone_defs.cpp: ${srcdir}/gen-fan-zone-defs.py
+ $(AM_V_GEN)$(GEN_FAN_ZONE_DEFS)
diff --git a/control/example/fans.yaml b/control/example/fans.yaml
new file mode 100644
index 0000000..629c502
--- /dev/null
+++ b/control/example/fans.yaml
@@ -0,0 +1,28 @@
+#Example fan definitions for phosphor-fan-control
+
+#List all fans that need to be known to phosphor-fan-control.
+#For each fan, the inventory path, cooling zone, cooling zone
+#profile, and sensor name(s).
+
+#fans:
+# - inventory: [The system inventory location for the fan]
+# cooling_zone: [The cooling zone number for the fan]
+# cooling_profile: [The cooling profile for the fan]
+# sensors: [The list of sensors for this fan]
+
+#The cooling zone, a number, and the cooling profile, a string,
+#have to match the corresponding values in the fan zone yaml
+#so the fans can be merged into the zone definition.
+
+#Example entries for 2 fan system:
+#fans:
+# - inventory: /system/chassis/motherboard/fan0
+# cooling_zone: 0
+# cooling_profile: all
+# sensors:
+# - fan0
+# - inventory: /system/chassis/motherboard/fan1
+# cooling_zone: 0
+# cooling_profile: air
+# sensors:
+# - fan1
diff --git a/control/example/zones.yaml b/control/example/zones.yaml
new file mode 100644
index 0000000..5f3b549
--- /dev/null
+++ b/control/example/zones.yaml
@@ -0,0 +1,49 @@
+#Example fan zone definitions for phosphor-fan-control
+
+#List the properties of the fan zones that are possible in the system.
+#The zones may be conditional based on certain conditions, such as
+#different chassis types or water cooled models. The fans themselves
+#are not listed in this file. They are in a separate YAML file so it
+#can be machine generated (i.e. from the MRW) if desired.
+
+#The general structure is a list of groups of zones, where a group
+#contains both the zones and the conditions required for the zones
+#to be valid
+
+#The cooling_profile is used along with the zone number to know
+#which fans in the fan yaml belong in this zone instance. For
+#example, a fan may only be in zone 0 if it's the air cooled version
+#of the system, but not with the water cooled version. In that
+#case, the fan yaml would have a cooling_profile of 'air' to match
+#the zone cooling profile.
+
+#- zone_conditions:
+# - name: [Name of a condition, if any. Valid names are TBD]
+#
+# zones:
+# - zone: [zone number]
+# cooling_profiles:
+# - [cooling profile]
+# initial_speed: [Speed to set the zone to when app starts]
+
+#Example:
+#- zone_conditions:
+# - name: air_cooled_chassis
+#
+# zones:
+# - zone: 0
+# cooling_profiles:
+# - air
+# - all
+# initial_speed: 10500
+#
+#- zone_conditions:
+# - name: water_and_air_cooled_chassis
+#
+# zones:
+# - zone: 0
+# cooling_profiles:
+# - water
+# - all
+# initial_speed: 4000
+
diff --git a/control/generated.cpp b/control/generated.cpp
deleted file mode 100644
index e6ed723..0000000
--- a/control/generated.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "manager.hpp"
-
-//This will eventually be generated by a script.
-
-using namespace phosphor::fan::control;
-
-const std::vector<ZoneGroup> Manager::_zoneLayouts
-{
- //Air cooled
- std::make_tuple(std::vector<Condition>{},
- std::vector<ZoneDefinition>{std::make_tuple(0, 10500,
- std::vector<FanDefinition>{
- std::make_tuple("/system/chassis/motherboard/fan0", std::vector<std::string>{"fan0"}),
- std::make_tuple("/system/chassis/motherboard/fan1", std::vector<std::string>{"fan1"}),
- std::make_tuple("/system/chassis/motherboard/fan2", std::vector<std::string>{"fan2"}),
- std::make_tuple("/system/chassis/motherboard/fan3", std::vector<std::string>{"fan3"})})}),
-
- //Water and air cooled
- std::make_tuple(std::vector<Condition>{},
- std::vector<ZoneDefinition>{std::make_tuple(0, 10500,
- std::vector<FanDefinition>{
- std::make_tuple("/system/chassis/motherboard/fan0", std::vector<std::string>{"fan0"}),
- std::make_tuple("/system/chassis/motherboard/fan2", std::vector<std::string>{"fan2"}),
- std::make_tuple("/system/chassis/motherboard/fan3", std::vector<std::string>{"fan3"})})})
-};
OpenPOWER on IntegriCloud