pid: add direction to stepwise
We now have upper and lower clipping curves, add direction
so we can tell which is which.
Tested-by: GET and PATCH work
Change-Id: I0cdfa159a3a27355a8e67c65e42e765f191f7719
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index d109a19..936d655 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -195,6 +195,14 @@
std::string name = *namePtr;
dbus::utility::escapePathForDbus(name);
nlohmann::json* config = nullptr;
+
+ const std::string* classPtr = nullptr;
+ auto findClass = intfPair.second.find("Class");
+ if (findClass != intfPair.second.end())
+ {
+ classPtr = std::get_if<std::string>(&findClass->second);
+ }
+
if (intfPair.first == pidZoneConfigurationIface)
{
std::string chassis;
@@ -217,6 +225,13 @@
else if (intfPair.first == stepwiseConfigurationIface)
{
+ if (classPtr == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "Pid Class Field illegal";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
nlohmann::json& controller = stepwise[name];
config = &controller;
@@ -230,18 +245,13 @@
controller["@odata.context"] =
"/redfish/v1/"
"$metadata#OemManager.StepwiseController";
+ controller["Direction"] = *classPtr;
}
// pid and fans are off the same configuration
else if (intfPair.first == pidConfigurationIface)
{
- const std::string* classPtr = nullptr;
- auto findClass = intfPair.second.find("Class");
- if (findClass != intfPair.second.end())
- {
- classPtr =
- std::get_if<std::string>(&findClass->second);
- }
+
if (classPtr == nullptr)
{
BMCWEB_LOG_ERROR << "Pid Class Field illegal";
@@ -739,10 +749,12 @@
std::optional<std::vector<std::string>> inputs;
std::optional<double> positiveHysteresis;
std::optional<double> negativeHysteresis;
+ std::optional<std::string> direction; // upper clipping curve vs lower
if (!redfish::json_util::readJson(
it.value(), response->res, "Zones", zones, "Steps", steps,
"Inputs", inputs, "PositiveHysteresis", positiveHysteresis,
- "NegativeHysteresis", negativeHysteresis))
+ "NegativeHysteresis", negativeHysteresis, "Direction",
+ direction))
{
BMCWEB_LOG_ERROR << "Line:" << __LINE__ << ", Illegal Property "
<< it.value().dump();
@@ -805,6 +817,19 @@
{
output["PositiveHysteresis"] = *positiveHysteresis;
}
+ if (direction)
+ {
+ constexpr const std::array<const char*, 2> allowedDirections = {
+ "Ceiling", "Floor"};
+ if (std::find(allowedDirections.begin(), allowedDirections.end(),
+ *direction) == allowedDirections.end())
+ {
+ messages::propertyValueTypeError(response->res, "Direction",
+ *direction);
+ return CreatePIDRet::fail;
+ }
+ output["Class"] = *direction;
+ }
}
else
{
diff --git a/static/redfish/v1/schema/OemManager_v1.xml b/static/redfish/v1/schema/OemManager_v1.xml
index 8f7a6af..171855f 100644
--- a/static/redfish/v1/schema/OemManager_v1.xml
+++ b/static/redfish/v1/schema/OemManager_v1.xml
@@ -265,6 +265,10 @@
<Annotation Term="OData.LongDescription" String="Temperature vs RPM steps for the stepwise controller." />
<Annotation Term="OData.AutoExpand"/>
</Property>
+ <Property Name="Direction" Type="Edm.String">
+ <Annotation Term="OData.Description" String="Direction that the stepwise controller applies."/>
+ <Annotation Term="OData.LongDescription" String="Direction that the stepwise controller applies. Options include Ceiling and Floor."/>
+ </Property>
<NavigationProperty Name="Zones" Type="Collection(OemManager.FanZone)" ContainsTarget="true">
<Annotation Term="OData.Permissions" EnumMember="OData.Permission/Read" />
<Annotation Term="OData.Description" String="Contains the Zones that this controller contributes to." />
@@ -281,7 +285,7 @@
<Annotation Term="OData.Description" String="Fan speed setting for step."/>
<Annotation Term="OData.LongDescription" String="Fan speed setting for step."/>
</Property>
- </ComplexType>
+ </ComplexType>
</Schema>
</edmx:DataServices>
</edmx:Edmx>