Goby Underwater Autonomy Project
Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
|
00001 #ifndef COMMANDGUI_H 00002 #define COMMANDGUI_H 00003 00004 #include <cctype> 00005 #include <cmath> 00006 #include <fstream> 00007 00008 #include <boost/bind.hpp> 00009 #include <boost/date_time/posix_time/posix_time.hpp> 00010 #include <boost/date_time/gregorian/gregorian.hpp> 00011 #include <boost/thread/mutex.hpp> 00012 00013 #include "MOOSUtilityLib/MOOSGeodesy.h" 00014 #include "MOOSLIB/MOOSLib.h" 00015 00016 #include "commander_cdk.h" 00017 #include "goby/acomms/dccl.h" 00018 #include "goby/moos/libmoos_util/modem_id_convert.h" 00019 00020 class CommandGui 00021 { 00022 public: 00023 CommandGui(); 00024 ~CommandGui(); 00025 00026 bool run(); 00027 void initialize(); 00028 00029 std::string microsec_simple_time_of_day() 00030 { return boost::posix_time::to_simple_string(boost::posix_time::microsec_clock::universal_time().time_of_day()); } 00031 00032 00033 private: 00034 void do_run(); 00035 00036 void main_menu(); 00037 void new_message(); 00038 void open_message(); 00039 void save_message(); 00040 bool do_save(std::string); 00041 bool do_open(std::string); 00042 void import_xml(); 00043 void edit(); 00044 int edit_popup(); 00045 void send(); 00046 void insert_specials(std::string & s); 00047 bool field_check(std::string & s, boost::shared_ptr<goby::acomms::DCCLMessageVar> mp); 00048 void quick_switch(); 00049 void clear_message() { curr_mess_vals_->clear();} 00050 void check_specials(std::string & val, chtype input, int row); 00051 bool edit_precallback(int, int, std::string &, chtype &); 00052 bool edit_menu(int, std::string &, goby::acomms::DCCLType); 00053 bool edit_isprint(int, std::string &, chtype, goby::acomms::DCCLType, boost::shared_ptr<goby::acomms::DCCLMessageVar>); 00054 bool edit_backspace(int, std::string &, goby::acomms::DCCLType); 00055 bool edit_leftright(int, std::string &, chtype, goby::acomms::DCCLType, boost::shared_ptr<goby::acomms::DCCLMessageVar>); 00056 bool edit_postcallback(int, int, std::string &, chtype &); 00057 void prepare_message(std::map<std::string, std::string> & vals, std::vector<std::string> & out_of_range, bool do_substitutes = true, std::vector<std::string> * curr_vals = NULL, goby::acomms::DCCLMessage * curr_message = NULL); 00058 void preview(); 00059 int insert_modem_id(); 00060 void find_lat_lon_rows(int row, int & lat_row, int & lon_row); 00061 void assemble_message_display(std::string & mesg); 00062 00063 private: 00064 std::vector< boost::shared_ptr<goby::acomms::DCCLMessageVar> > fetch_message_vars(goby::acomms::DCCLMessage*); 00065 00066 bool initialized_; 00067 00068 bool refresh_; 00069 00070 std::vector<std::string> * curr_mess_vals_; 00071 bool screen_initialized_; 00072 // used to specify if inserting the special:xy2latlong 00073 bool inserting_x_; 00074 bool inserting_y_; 00075 00076 std::vector<std::string> rowtitle_; 00077 std::vector<std::string> coltitle_; 00078 00079 std::map<int, std::vector<std::string> > open_mess_vals_; 00080 int curr_field_; 00081 goby::acomms::DCCLMessage * curr_message_; 00082 00083 std::map<goby::acomms::DCCLMessage*, int> current_xy_num_; 00084 00085 enum state {s_new, s_open, s_save, s_import, s_exit, s_return, s_menu, s_editing, s_preview, s_send, s_quick_switch, s_clear}; 00086 state state_; 00087 }; 00088 00089 #endif