control: Remove JSON event precondition support

Event preconditions are essentially specialized actions that load events
after a certain condition is met. JSON configured fan control will just
utilize actions that are configured & created to enable or disable
events based on some state.

Change-Id: I8e8faf3c137062943ffaa9b3adc20d93da3a123c
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/event.cpp b/control/json/event.cpp
index 7bb26ec..6e2c080 100644
--- a/control/json/event.cpp
+++ b/control/json/event.cpp
@@ -42,25 +42,17 @@
     ConfigBase(jsonObj),
     _bus(util::SDBusPlus::getBus()), _manager(mgr), _zones(zones)
 {
-    // Event could have a precondition
-    if (!jsonObj.contains("precondition"))
+    // Event groups are optional
+    if (jsonObj.contains("groups"))
     {
-        // Event groups are optional
-        if (jsonObj.contains("groups"))
-        {
-            setGroups(jsonObj, _groups);
-        }
-        // Event actions are optional
-        if (jsonObj.contains("actions"))
-        {
-            setActions(jsonObj);
-        }
-        setTriggers(jsonObj);
+        setGroups(jsonObj, _groups);
     }
-    else
+    // Event actions are optional
+    if (jsonObj.contains("actions"))
     {
-        setPrecond(jsonObj);
+        setActions(jsonObj);
     }
+    setTriggers(jsonObj);
 }
 
 auto& Event::getAvailGroups()
@@ -104,21 +96,6 @@
     }
 }
 
-void Event::setPrecond(const json& jsonObj)
-{
-    const auto& precond = jsonObj["precondition"];
-    if (!precond.contains("name") || !precond.contains("groups") ||
-        !precond.contains("triggers") || !precond.contains("events"))
-    {
-        log<level::ERR>("Missing required event precondition attributes",
-                        entry("JSON=%s", precond.dump().c_str()));
-        throw std::runtime_error(
-            "Missing required event precondition attributes");
-    }
-    setGroups(precond, _groups);
-    setTriggers(precond);
-}
-
 void Event::setGroups(const json& jsonObj, std::vector<Group>& groups)
 {
     auto& availGroups = getAvailGroups();
diff --git a/control/json/event.hpp b/control/json/event.hpp
index a37d9be..305ff25 100644
--- a/control/json/event.hpp
+++ b/control/json/event.hpp
@@ -39,25 +39,14 @@
  * how fan control should function. These events contain the configured
  * attributes that result in how fans are controlled within a system. Events
  * are made up of groups of sensors, triggers from those sensors, and actions
- * to be run when a trigger occurs. Events may also have a precondition that
- * must exist before the event is loaded into fan control. The triggers,
- * actions, and preconditions configured must be available within the fan
- * control application source.
+ * to be run when a trigger occurs. The triggers and actions configured must be
+ * available within the fan control application source.
  *
  * When no events exist, the configured fans are set to their corresponding
  * zone's `full_speed` value.
  */
 class Event : public ConfigBase
 {
-    static constexpr auto precondName = 0;
-    static constexpr auto precondGroups = 1;
-    static constexpr auto precondEvents = 2;
-    using Precondition =
-        std::tuple<std::string,
-                   std::vector<std::tuple<std::string, std::string, std::string,
-                                          PropertyVariantType>>,
-                   std::vector<Event>>;
-
   public:
     /* JSON file name for events */
     static constexpr auto confFileName = "events.json";
@@ -81,16 +70,6 @@
           std::map<configKey, std::unique_ptr<Zone>>& zones);
 
     /**
-     * @brief Get the precondition
-     *
-     * @return The precondition details of the event
-     */
-    inline const auto& getPrecond() const
-    {
-        return _precond;
-    }
-
-    /**
      * @brief Get the actions
      *
      * @return List of actions to perform for the event
@@ -107,9 +86,6 @@
     /* The event's manager */
     Manager* _manager;
 
-    /* A precondition the event has in order to be enabled */
-    Precondition _precond;
-
     /* List of groups associated with the event */
     std::vector<Group> _groups;
 
@@ -137,15 +113,6 @@
     void configGroup(Group& group, const json& jsonObj);
 
     /**
-     * @brief Parse and set the event's precondition(OPTIONAL)
-     *
-     * @param[in] jsonObj - JSON object for the event
-     *
-     * Sets the precondition of the event in order to be enabled
-     */
-    void setPrecond(const json& jsonObj);
-
-    /**
      * @brief Parse and set the event's groups(OPTIONAL)
      *
      * @param[in] jsonObj - JSON object for the event