control: Update JSON action objects to run the action

A change in design direction for the JSON configuration path of fan
control is to have it separate than the YAML configuration
functionality. This means that the JSON based action objects will run
the action function directly instead of returning the action function
which is done for YAML based configurations.

Update the default floor action to reflect this change in direction.

Change-Id: I75ade1c7e2e9698573c5ed2495c2f3b7e9cf52f0
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/actions/default_floor.cpp b/control/json/actions/default_floor.cpp
index 6f30bf3..5970ae2 100644
--- a/control/json/actions/default_floor.cpp
+++ b/control/json/actions/default_floor.cpp
@@ -1,5 +1,5 @@
 /**
- * Copyright © 2020 IBM Corporation
+ * Copyright © 2021 IBM Corporation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,12 +15,14 @@
  */
 #include "default_floor.hpp"
 
-#include "actions.hpp"
-#include "functor.hpp"
 #include "types.hpp"
+#include "zone.hpp"
 
 #include <nlohmann/json.hpp>
 
+#include <algorithm>
+#include <tuple>
+
 namespace phosphor::fan::control::json
 {
 
@@ -28,12 +30,23 @@
 
 DefaultFloor::DefaultFloor(const json&) : ActionBase(DefaultFloor::name)
 {
-    // There are no additional JSON configuration parameters for this action
+    // There are no JSON configuration parameters for this action
 }
 
-const Action DefaultFloor::getAction()
+void DefaultFloor::run(Zone& zone, const Group& group)
 {
-    return make_action(action::default_floor_on_missing_owner);
+    // Set/update the services of the group
+    zone.setServices(&group);
+    auto services = zone.getGroupServices(&group);
+    auto defFloor =
+        std::any_of(services.begin(), services.end(),
+                    [](const auto& s) { return !std::get<hasOwnerPos>(s); });
+    if (defFloor)
+    {
+        zone.setFloor(zone.getDefFloor());
+    }
+    // Update fan control floor change allowed
+    zone.setFloorChangeAllow(&group, !defFloor);
 }
 
 } // namespace phosphor::fan::control::json