1 #ifndef LIAISON_JAIABOT_H
2 #define LIAISON_JAIABOT_H
5 #include <Wt/WPushButton>
7 #include <boost/thread/mutex.hpp>
8 #include <boost/units/io.hpp>
11 #include "goby/zeromq/liaison/liaison_container.h"
12 #include <goby/middleware/frontseat/groups.h>
13 #include <goby/middleware/gpsd/groups.h>
14 #include <goby/middleware/protobuf/frontseat_data.pb.h>
15 #include <goby/middleware/protobuf/gpsd.pb.h>
22 #include "config.pb.h"
30 class LiaisonJaiabot :
public goby::zeromq::LiaisonContainerWithComms<LiaisonJaiabot, CommsThread>
33 LiaisonJaiabot(
const goby::apps::zeromq::protobuf::LiaisonConfig& cfg,
34 Wt::WContainerWidget* parent = 0);
37 void post_node_status(
const goby::middleware::frontseat::protobuf::NodeStatus& node_status);
38 void post_tpv(
const goby::middleware::protobuf::gpsd::TimePositionVelocity& tpv);
46 void focus()
override { timer_.start(); }
47 void unfocus()
override { timer_.stop(); }
49 void vehicle_select(Wt::WString
msg);
50 void check_add_vehicle(
int node_id);
51 void key_press(Wt::WKeyEvent key);
52 void key_release(Wt::WKeyEvent key);
55 Wt::WComboBox* vehicle_combo_;
56 Wt::WStackedWidget* vehicle_stack_;
60 VehicleData(Wt::WStackedWidget*,
const protobuf::JaiabotConfig&);
62 Wt::WContainerWidget* vehicle_div;
66 Controls(Wt::WContainerWidget* vehicle_div,
const protobuf::JaiabotConfig& cfg);
104 text->setText(timeout_text_from_value(value));
109 text->setText(dive_text_from_value(value));
116 text->setText(motor_text_from_value(value));
120 Wt::WSlider* stbd_elevator, Wt::WSlider* rudder)
122 text->setText(fins_text_from_value(value, stbd_elevator->value(), rudder->value()));
126 Wt::WSlider* port_elevator, Wt::WSlider* rudder)
128 text->setText(fins_text_from_value(port_elevator->value(), value, rudder->value()));
131 Wt::WSlider* stbd_elevator)
134 fins_text_from_value(port_elevator->value(), stbd_elevator->value(), value));
180 Controls low_level_control;
182 int index_in_stack{0};
184 static std::string timeout_text_from_value(
int value)
186 return "Timeout (X-/V+): " + std::to_string(value);
189 static std::string dive_text_from_value(
int value)
191 return "Dive (Y-/U+): " + std::to_string(value);
194 static std::string motor_text_from_value(
int value)
196 return "Motor (W-/R+): " + std::to_string(value);
198 static std::string fins_text_from_value(
int port_elevator_value,
int stbd_elevator_value,
201 return "Port Elevator (A-/Q+ or D-/E+ for both): " +
202 std::to_string(port_elevator_value) +
203 "<br/>Starboard Elevator (G-/T+ or D-/E+ for both): " +
204 std::to_string(stbd_elevator_value) +
205 "<br/>Rudder (S-/F+): " + std::to_string(rudder_value);
210 std::map<int, VehicleData> vehicle_data_;
213 Wt::WGroupBox* bot_node_status_box_;
214 Wt::WText* bot_node_status_text_;
215 Wt::WGroupBox* bot_tpv_box_;
216 Wt::WText* bot_tpv_text_;
217 Wt::WGroupBox* bot_pt_box_;
218 Wt::WText* bot_pt_text_;
219 Wt::WGroupBox* bot_salinity_box_;
220 Wt::WText* bot_salinity_text_;
221 Wt::WGroupBox* bot_imu_box_;
222 Wt::WText* bot_imu_text_;
223 Wt::WGroupBox* bot_low_control_box_;
224 Wt::WText* bot_low_control_text_;
227 int current_vehicle_{-1};
229 bool motor_go_{
false};
230 static bool dive_start_;
231 static std::chrono::system_clock::time_point dive_expire_;
235 const protobuf::JaiabotConfig& cfg_;
238 class CommsThread :
public goby::zeromq::LiaisonCommsThread<LiaisonJaiabot>
250 interprocess().subscribe<goby::middleware::frontseat::groups::node_status>(
251 [
this](
const goby::middleware::frontseat::protobuf::NodeStatus& node_status) {
256 interprocess().subscribe<goby::middleware::groups::gpsd::tpv>(
257 [
this](
const goby::middleware::protobuf::gpsd::TimePositionVelocity& tpv) {
258 tab_->post_to_wt([=]() { tab_->
post_tpv(tpv); });
264 tab_->post_to_wt([=]() { tab_->
post_pt(pt); });