Move signals to event triggers
Move the generation and initialization of signals to be included in the
available event triggers. The signal trigger consists of subscribing to
a given signal match where when the signal is received and handled, it
causes the event actions to be called.
Tested:
All current event signals are still registered and received
Speed changes occur based on temperature sensor change signals
Change-Id: Iab4ccabb50ad910d5d566bd8c1922109638bd760
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/zone.hpp b/control/zone.hpp
index 6da3091..59f9743 100644
--- a/control/zone.hpp
+++ b/control/zone.hpp
@@ -64,6 +64,36 @@
const ZoneDefinition& def);
/**
+ * @brief Get the zone's bus
+ *
+ * @return The bus used by the zone
+ */
+ inline auto& getBus()
+ {
+ return _bus;
+ }
+
+ /**
+ * @brief Get the zone's path
+ *
+ * @return The path of this zone
+ */
+ inline auto& getPath()
+ {
+ return _path;
+ }
+
+ /**
+ * @brief Get the zone's hosted interfaces
+ *
+ * @return The interfaces hosted by this zone
+ */
+ inline auto& getIfaces()
+ {
+ return _ifaces;
+ }
+
+ /**
* Sets all fans in the zone to the speed
* passed in when the zone is active
*
@@ -107,6 +137,22 @@
}
/**
+ * @brief Sets a given object's event data for a property on this zone
+ *
+ * @param[in] object - Name of the object containing the property
+ * @param[in] interface - Interface name containing the property
+ * @param[in] property - Property name
+ * @param[in] data - Property value
+ */
+ inline void setObjectData(const std::string& object,
+ const std::string& interface,
+ const std::string& property,
+ EventData* data)
+ {
+ _objects[object][interface][property] = data;
+ }
+
+ /**
* @brief Sets a given object's property value
*
* @param[in] object - Name of the object containing the property
@@ -124,6 +170,23 @@
};
/**
+ * @brief Sets a given object's property value
+ *
+ * @param[in] object - Name of the object containing the property
+ * @param[in] interface - Interface name containing the property
+ * @param[in] property - Property name
+ * @param[in] value - Property value
+ */
+ template <typename T>
+ void setPropertyValue(const std::string& object,
+ const std::string& interface,
+ const std::string& property,
+ T value)
+ {
+ _properties[object][interface][property] = value;
+ };
+
+ /**
* @brief Get the value of an object's property
*
* @param[in] object - Name of the object containing the property
@@ -368,7 +431,7 @@
* @return - Iterator to the stored signal event
*/
std::vector<SignalEvent>::iterator findSignal(
- const Signal& signal,
+ const Trigger& signal,
const Group& eGroup,
const std::vector<Action>& eActions);
@@ -470,6 +533,28 @@
int32_t depth);
/**
+ * @brief Dbus signal change callback handler
+ *
+ * @param[in] msg - Expanded sdbusplus message data
+ * @param[in] eventData - The single event's data
+ */
+ void handleEvent(sdbusplus::message::message& msg,
+ const EventData* eventData);
+
+ /**
+ * @brief Add a signal to the list of signal based events
+ *
+ * @param[in] data - Event data for signal
+ * @param[in] match - Subscribed signal match
+ */
+ inline void addSignal(
+ std::unique_ptr<EventData>&& data,
+ std::unique_ptr<sdbusplus::server::match::match>&& match)
+ {
+ _signalEvents.emplace_back(std::move(data), std::move(match));
+ }
+
+ /**
* @brief Set a property to be persisted
*
* @param[in] intf - Interface containing property
@@ -739,15 +824,6 @@
{
return (_requestSpeedBase != 0) ? _requestSpeedBase : _targetSpeed;
};
-
- /**
- * @brief Dbus signal change callback handler
- *
- * @param[in] msg - Expanded sdbusplus message data
- * @param[in] eventData - The single event's data
- */
- void handleEvent(sdbusplus::message::message& msg,
- const EventData* eventData);
};
}