control: Add event name to the action unique name

The unique name of an action was previously just <action name>-ID, where
ID was unique number.  When there are multiple instances of an action,
it can be difficult to tell which action is being referred to when it
shows up in the fan control dump in either the flight recorder or zones
section.

To fix this, add the name of the owning event to the action's name so
now it's <action name>-ID(event name).  Here is an example from the fan
control dump now:

  "floor_holds": {
      "count_state_floor-4(Non-active OCCs)": 18000,
      "mapped_floor-64(Fan floors)": 11200
  }

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I879e05a05da50545319635e82cc9a2d9ebac6b82
diff --git a/control/json/actions/action.hpp b/control/json/actions/action.hpp
index 6c63a07..40547b9 100644
--- a/control/json/actions/action.hpp
+++ b/control/json/actions/action.hpp
@@ -197,6 +197,22 @@
         return _uniqueName;
     }
 
+    /**
+     * @brief Set the name of the owning Event.
+     *
+     * Adds it to the unique name in parentheses. If desired,
+     * the action child classes can do something else with it.
+     *
+     * @param[in] name - The event name
+     */
+    virtual void setEventName(const std::string& name)
+    {
+        if (!name.empty())
+        {
+            _uniqueName += '(' + name + ')';
+        }
+    }
+
   protected:
     /**
      * @brief Logs a message to the flight recorder using
@@ -218,7 +234,7 @@
 
     /* Unique name of the action.
      * It's just the name plus _actionCount at the time of action creation. */
-    const std::string _uniqueName;
+    std::string _uniqueName;
 
     /* Running count of all actions */
     static inline size_t _actionCount = 0;
diff --git a/control/json/actions/pcie_card_floors.hpp b/control/json/actions/pcie_card_floors.hpp
index d3b5710..7b73d39 100644
--- a/control/json/actions/pcie_card_floors.hpp
+++ b/control/json/actions/pcie_card_floors.hpp
@@ -98,6 +98,17 @@
      */
     void run(Zone& zone) override;
 
+    /**
+     * @brief Set the name of the owning Event.
+     *
+     * In the base class it's appending it to the action's unique name.  Don't
+     * do it for this action since there's only one instance of it so no need
+     * to distinguish it from ones under different events and also it just
+     * makes it uglier in the flight recorder.
+     */
+    void setEventName(const std::string& name) override
+    {}
+
   private:
     /**
      * @brief Runs the contents of the action when the settle timer expires.
diff --git a/control/json/event.cpp b/control/json/event.cpp
index a1392e5..0f9ab8a 100644
--- a/control/json/event.cpp
+++ b/control/json/event.cpp
@@ -243,6 +243,7 @@
                 std::move(actionGroups), std::move(actionZones));
             if (actObj)
             {
+                actObj->setEventName(_name);
                 _actions.emplace_back(std::move(actObj));
             }
         }
@@ -254,6 +255,7 @@
                 std::move(actionZones));
             if (actObj)
             {
+                actObj->setEventName(_name);
                 _actions.emplace_back(std::move(actObj));
             }
         }