23 #ifndef LIAISONCOMMANDER20110609H 24 #define LIAISONCOMMANDER20110609H 26 #include <Wt/WAbstractListModel> 30 #include <Wt/WComboBox> 31 #include <Wt/WCssDecorationStyle> 32 #include <Wt/WDateTime> 34 #include <Wt/WGroupBox> 36 #include <Wt/WLineEdit> 37 #include <Wt/WPushButton> 38 #include <Wt/WSpinBox> 39 #include <Wt/WStackedWidget> 41 #include <Wt/WStringListModel> 42 #include <Wt/WTableCell> 43 #include <Wt/WTableView> 46 #include <Wt/WTreeTable> 47 #include <Wt/WTreeTableNode> 48 #include <Wt/WTreeView> 49 #include <Wt/WVBoxLayout> 50 #include <Wt/WValidator> 52 #include <Wt/Dbo/FixedSqlConnectionPool> 53 #include <Wt/Dbo/Impl> 54 #include <Wt/Dbo/QueryModel> 55 #include <Wt/Dbo/Session> 56 #include <Wt/Dbo/SqlTraits> 57 #include <Wt/Dbo/WtSqlTraits> 58 #include <Wt/Dbo/backend/Sqlite3> 60 #include "goby/common/liaison_container.h" 61 #include "goby/moos/moos_node.h" 62 #include "goby/moos/protobuf/liaison_config.pb.h" 72 Wt::WTreeTableNode* parentNode = 0)
73 : Wt::WTreeTableNode(labelText, labelIcon, parentNode)
75 this->labelArea()->setHeight(Wt::WLength(2.5, Wt::WLength::FontEm));
81 std::string protobuf_name;
82 std::vector<unsigned char> bytes;
89 std::vector<unsigned char> acks;
91 template <
class Action>
void persist(Action& a)
93 Wt::Dbo::field(a, protobuf_name,
"protobuf_name");
94 Wt::Dbo::field(a, bytes,
"bytes");
95 Wt::Dbo::field(a, utime,
"utime");
96 Wt::Dbo::field(a, time,
"time");
97 Wt::Dbo::field(a, comment,
"comment");
98 Wt::Dbo::field(a, address,
"address");
99 Wt::Dbo::field(a, last_ack,
"last_ack");
100 Wt::Dbo::field(a, acks,
"acks");
108 Wt::WContainerWidget* parent = 0);
113 void focus() { commander_timer_.start(); }
115 void unfocus() { commander_timer_.stop(); }
120 std::set<std::string> display_subscriptions_;
122 Wt::WVBoxLayout* main_layout_;
124 struct ControlsContainer : Wt::WGroupBox
126 ControlsContainer(MOOSNode* moos_node,
128 Wt::WStackedWidget* commands_div, Wt::WContainerWidget* parent = 0);
129 void switch_command(
int selection_index);
131 void clear_message();
134 void increment_incoming_messages(
const Wt::WMouseEvent&
event);
135 void decrement_incoming_messages(
const Wt::WMouseEvent& event);
136 void remove_incoming_message(
const Wt::WMouseEvent& event);
142 const std::string& protobuf_name, Wt::Dbo::Session* session);
146 void generate_root();
150 const google::protobuf::FieldDescriptor* field_desc);
152 void generate_tree_field(Wt::WFormWidget*& value_field,
154 const google::protobuf::FieldDescriptor* field_desc,
159 const google::protobuf::FieldDescriptor* field_desc,
160 const std::string& current_value,
161 const std::string& default_value,
162 Wt::WValidator* validator,
int index = -1);
166 const google::protobuf::FieldDescriptor* field_desc,
167 const std::vector<Wt::WString>& strings,
int current_value,
168 const std::string& default_value,
int index = -1);
170 void generate_field_info_box(Wt::WFormWidget*& value_field,
171 const google::protobuf::FieldDescriptor* field_desc);
173 void set_time_field(Wt::WFormWidget* value_field,
174 const google::protobuf::FieldDescriptor* field_desc);
180 void dccl_default_value_field(Wt::WFormWidget*& value_field,
181 const google::protobuf::FieldDescriptor* field_desc);
183 void dccl_default_modify_field(Wt::WFormWidget*& modify_field,
184 const google::protobuf::FieldDescriptor* field_desc);
187 string_from_dccl_double(
double* value,
188 const google::protobuf::FieldDescriptor* field_desc);
192 void handle_toggle_single_message(
const Wt::WMouseEvent& mouse,
194 const google::protobuf::FieldDescriptor* field_desc,
195 Wt::WPushButton* field, Wt::WTreeTableNode* parent);
198 const google::protobuf::FieldDescriptor* field_desc,
199 Wt::WLineEdit* field,
int index);
202 const google::protobuf::FieldDescriptor* field_desc,
203 Wt::WComboBox* field,
int index);
206 const google::protobuf::FieldDescriptor* field_desc,
207 Wt::WTreeTableNode* parent);
209 void handle_database_double_click(
const Wt::WModelIndex& index,
210 const Wt::WMouseEvent& event);
212 enum DatabaseDialogResponse
219 void handle_database_dialog(DatabaseDialogResponse response,
220 boost::shared_ptr<google::protobuf::Message> message);
222 MOOSNode* moos_node_;
223 boost::shared_ptr<google::protobuf::Message> message_;
225 std::map<Wt::WFormWidget*, const google::protobuf::FieldDescriptor*> time_fields_;
228 Wt::WGroupBox* tree_box_;
229 Wt::WTreeTable* tree_table_;
234 Wt::Dbo::Session* session_;
235 Wt::Dbo::QueryModel<Wt::Dbo::ptr<CommandEntry> >* query_model_;
237 Wt::WGroupBox* query_box_;
238 Wt::WTreeView* query_table_;
240 boost::posix_time::ptime last_reload_time_;
242 boost::shared_ptr<Wt::WDialog> database_dialog_;
247 MOOSNode* moos_node_;
249 std::map<std::string, int> commands_;
250 Wt::WLabel* command_label_;
251 Wt::WComboBox* command_selection_;
252 Wt::WContainerWidget* buttons_div_;
253 Wt::WLabel* comment_label_;
254 Wt::WLineEdit* comment_line_;
255 Wt::WPushButton* send_button_;
256 Wt::WPushButton* clear_button_;
257 Wt::WStackedWidget* commands_div_;
259 Wt::WPanel* incoming_message_panel_;
260 Wt::WStackedWidget* incoming_message_stack_;
265 Wt::Dbo::Session session_;
268 Wt::WStackedWidget* commands_div_;
269 ControlsContainer* controls_div_;
271 Wt::WTimer commander_timer_;
274 static boost::posix_time::ptime last_db_update_time_;
275 static boost::mutex dbo_mutex_;
276 static boost::shared_ptr<Wt::Dbo::backend::Sqlite3> sqlite3_;
277 static boost::shared_ptr<Wt::Dbo::FixedSqlConnectionPool> connection_pool_;
The global namespace for the Goby project.
google::protobuf::uint64 uint64
an unsigned 64 bit integer