Move StatusLight to event loop

Change-Id: I862ea7b42c7cd7373652b96e17310bd56145bbbb
diff --git a/y2019/control_loops/superstructure/BUILD b/y2019/control_loops/superstructure/BUILD
index 87afdfa..f43b448 100644
--- a/y2019/control_loops/superstructure/BUILD
+++ b/y2019/control_loops/superstructure/BUILD
@@ -27,6 +27,7 @@
         ":superstructure_queue",
         ":vacuum",
         "//aos/controls:control_loop",
+        "//aos/events:event-loop",
         "//frc971/control_loops/drivetrain:drivetrain_queue",
         "//y2019:constants",
         "//y2019:status_light",
diff --git a/y2019/control_loops/superstructure/superstructure.cc b/y2019/control_loops/superstructure/superstructure.cc
index b6ad9e8..a4796a8 100644
--- a/y2019/control_loops/superstructure/superstructure.cc
+++ b/y2019/control_loops/superstructure/superstructure.cc
@@ -1,33 +1,21 @@
 #include "y2019/control_loops/superstructure/superstructure.h"
 
 #include "aos/controls/control_loops.q.h"
+#include "aos/events/event-loop.h"
 #include "frc971/control_loops/control_loops.q.h"
 #include "frc971/control_loops/drivetrain/drivetrain.q.h"
 #include "frc971/control_loops/static_zeroing_single_dof_profiled_subsystem.h"
-
 #include "y2019/status_light.q.h"
 
 namespace y2019 {
 namespace control_loops {
 namespace superstructure {
 
-namespace {
-
-void SendColors(float red, float green, float blue) {
-  auto new_status_light = status_light.MakeMessage();
-  new_status_light->red = red;
-  new_status_light->green = green;
-  new_status_light->blue = blue;
-
-  if (!new_status_light.Send()) {
-    LOG(ERROR, "Failed to send lights.\n");
-  }
-}
-}  // namespace
-
 Superstructure::Superstructure(::aos::EventLoop *event_loop,
                                const ::std::string &name)
     : aos::controls::ControlLoop<SuperstructureQueue>(event_loop, name),
+      status_light_sender_(
+          event_loop->MakeSender<::y2019::StatusLight>(".y2019.status_light")),
       elevator_(constants::GetValues().elevator.subsystem_params),
       wrist_(constants::GetValues().wrist.subsystem_params),
       intake_(constants::GetValues().intake),
@@ -158,6 +146,17 @@
   }
 }
 
+void Superstructure::SendColors(float red, float green, float blue) {
+  auto new_status_light = status_light_sender_.MakeMessage();
+  new_status_light->red = red;
+  new_status_light->green = green;
+  new_status_light->blue = blue;
+
+  if (!new_status_light.Send()) {
+    LOG(ERROR, "Failed to send lights.\n");
+  }
+}
+
 }  // namespace superstructure
 }  // namespace control_loops
 }  // namespace y2019
diff --git a/y2019/control_loops/superstructure/superstructure.h b/y2019/control_loops/superstructure/superstructure.h
index 2df9026..2d51cff 100644
--- a/y2019/control_loops/superstructure/superstructure.h
+++ b/y2019/control_loops/superstructure/superstructure.h
@@ -2,11 +2,13 @@
 #define Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
 
 #include "aos/controls/control_loop.h"
+#include "aos/events/event-loop.h"
 #include "frc971/control_loops/static_zeroing_single_dof_profiled_subsystem.h"
 #include "y2019/constants.h"
 #include "y2019/control_loops/superstructure/collision_avoidance.h"
 #include "y2019/control_loops/superstructure/superstructure.q.h"
 #include "y2019/control_loops/superstructure/vacuum.h"
+#include "y2019/status_light.q.h"
 
 namespace y2019 {
 namespace control_loops {
@@ -42,6 +44,10 @@
                             SuperstructureQueue::Status *status) override;
 
  private:
+  void SendColors(float red, float green, float blue);
+
+  ::aos::Sender<::y2019::StatusLight> status_light_sender_;
+
   PotAndAbsoluteEncoderSubsystem elevator_;
   PotAndAbsoluteEncoderSubsystem wrist_;
   AbsoluteEncoderSubsystem intake_;
diff --git a/y2019/control_loops/superstructure/superstructure_lib_test.cc b/y2019/control_loops/superstructure/superstructure_lib_test.cc
index dd327ee..aa81380 100644
--- a/y2019/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2019/control_loops/superstructure/superstructure_lib_test.cc
@@ -16,7 +16,6 @@
 #include "y2019/control_loops/superstructure/stilts/stilts_plant.h"
 #include "y2019/control_loops/superstructure/superstructure.h"
 #include "y2019/control_loops/superstructure/wrist/wrist_plant.h"
-#include "y2019/status_light.q.h"
 
 namespace y2019 {
 namespace control_loops {
@@ -290,7 +289,6 @@
             ".y2019.control_loops.superstructure.superstructure_queue."
             "position"),
         superstructure_(&event_loop_) {
-    status_light.Clear();
     ::frc971::control_loops::drivetrain_queue.status.Clear();
     set_team_id(::frc971::control_loops::testing::kTeamNumber);
   }