Convert aos over to flatbuffers
Everything builds, and all the tests pass. I suspect that some entries
are missing from the config files, but those will be found pretty
quickly on startup.
There is no logging or live introspection of queue messages.
Change-Id: I496ee01ed68f202c7851bed7e8786cee30df29f5
diff --git a/aos/input/driver_station_data.cc b/aos/input/driver_station_data.cc
index 8898ca1..9e3bc52 100644
--- a/aos/input/driver_station_data.cc
+++ b/aos/input/driver_station_data.cc
@@ -1,20 +1,39 @@
#include "aos/input/driver_station_data.h"
+#include "glog/logging.h"
+
namespace aos {
namespace input {
namespace driver_station {
Data::Data() : current_values_(), old_values_() {}
-void Data::Update(const JoystickState &new_values) {
+void Data::Update(const JoystickState *new_values) {
old_values_ = current_values_;
- current_values_ = new_values;
+ CHECK(new_values->has_joysticks());
+ CHECK_EQ(new_values->joysticks()->size(), current_values_.joysticks.size());
+ for (size_t i = 0; i < current_values_.joysticks.size(); ++i) {
+ const Joystick *joystick = new_values->joysticks()->Get(i);
+ current_values_.joysticks[i].buttons =
+ joystick->buttons();
+ current_values_.joysticks[i].pov = joystick->pov();
+ for (size_t j = 0; j < joystick->axis()->size(); ++j) {
+ current_values_.joysticks[i].axis[j] = joystick->axis()->Get(j);
+ }
+
+ current_values_.joysticks[i].pov = joystick->pov();
+ }
+ current_values_.test_mode = new_values->test_mode();
+ current_values_.fms_attached = new_values->fms_attached();
+ current_values_.enabled = new_values->enabled();
+ current_values_.autonomous = new_values->autonomous();
+ current_values_.team_id = new_values->team_id();
+ current_values_.switch_left = new_values->switch_left();
+ current_values_.scale_left = new_values->scale_left();
}
-namespace {
-
-bool GetButton(const ButtonLocation location,
- const JoystickState &values) {
+bool Data::GetButton(const ButtonLocation location,
+ const Data::SavedJoystickState &values) {
if (location.joystick() < 0 ||
location.joystick() > static_cast<int>(values.joysticks.size())) {
return false;
@@ -23,15 +42,16 @@
return false;
}
return values.joysticks[location.joystick() - 1].buttons &
- (1 << (location.number() - 1));
+ (1 << (location.number() - 1));
}
-bool DoGetPOV(const POVLocation location, const JoystickState &values) {
+bool Data::DoGetPOV(const POVLocation location,
+ const Data::SavedJoystickState &values) {
return values.joysticks[location.joystick() - 1].pov == location.number();
}
-bool GetControlBitValue(const ControlBit bit,
- const JoystickState &values) {
+bool Data::GetControlBitValue(const ControlBit bit,
+ const Data::SavedJoystickState &values) {
switch (bit) {
case ControlBit::kTestMode:
return values.test_mode;
@@ -46,8 +66,6 @@
}
}
-} // namespace
-
bool Data::IsPressed(const ButtonLocation location) const {
return GetButton(location, current_values_);
}