control: Add power on/off triggers
Add two new classes of triggers: powerOn and powerOff. They are only
called during the power on and power off state changes, respectively.
They behave the same as the existing init trigger.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I9d39210843192b9c343c7838c604fcce7c8d3f3d
diff --git a/control/json/manager.cpp b/control/json/manager.cpp
index 61924ea..20f13e9 100644
--- a/control/json/manager.cpp
+++ b/control/json/manager.cpp
@@ -233,6 +233,16 @@
std::for_each(_zones.begin(), _zones.end(), [](const auto& entry) {
entry.second->setTarget(entry.second->getPoweronTarget());
});
+
+ // Tell events to run their power on triggers
+ std::for_each(_events.begin(), _events.end(),
+ [](const auto& entry) { entry.second->powerOn(); });
+ }
+ else
+ {
+ // Tell events to run their power off triggers
+ std::for_each(_events.begin(), _events.end(),
+ [](const auto& entry) { entry.second->powerOff(); });
}
}