/users/dtb26/GITROOT/vs-vetserial-poc/src/wxguipoc.h

Go to the documentation of this file.
00001 
00012 /*
00013 * AUTHOR    : David Brooks (dtb26@cornell.edu)
00014 * PLATFORM  : non-specific
00015 * DATE      : 4/4/2012 9:18:44 AM
00016 * COPYRIGHT : TBD
00017 *
00018 * File      : $Source:$
00019 * Revision  : $Revision:$
00020 * Author    : $Author:$
00021 * Date      : $Date:$
00022 * Tag name  : $Name:$
00023 * Locker    : $Locker:$
00024 * State     : $State: Exp $
00025 */
00026 #ifndef MAIN_APP_HEADER
00027 #define MAIN_APP_HEADER
00028 
00029 
00030 #if defined(unix) || defined(__unix__) || defined(__unix) || defined(__linux__) 
00031 extern "C" {
00032         #include <stdio.h> //for sprintf()
00033 }
00034 #endif
00035 
00036 // for the app
00037 #include <boost/bind.hpp>
00038 #include <boost/asio.hpp>
00039 #include <boost/asio/serial_port.hpp>
00040 #include <boost/thread.hpp>
00041 #include <boost/lexical_cast.hpp>
00042 #include <boost/date_time/posix_time/posix_time_types.hpp>
00043 #include "asserial.h"
00044 #include "vetprot.h"
00045 #include "pcktexplr.h"
00046 
00047 // for wxWidgets
00048 #include <wx/wx.h>
00049 #include <wx/aui/aui.h>         // not part of wx.h
00050 
00051 namespace cu = cornelluniversity;
00052 
00066 class VetSerialApp : public wxApp {
00067         public:
00068         virtual bool OnInit();
00069 };//eoc VetSerialApp
00070 
00077 class MainFrame : public wxFrame 
00078 {
00079         private:
00085                 void DoProtocolRx( const std::string & msg );
00091                 void DoProtocolTx( cornelluniversity::vetserial::base_command * bc );
00096                 void SetProtocolFlags( cornelluniversity::vetserial::base_command * bc );
00102                 void ToListBox( wxListBox *box, const wxString * msg );
00107                 void SerialReaderThread( boost::asio::io_service * ios );
00113                 wxString ToHexStr( const unsigned char * rawbuf, unsigned int len );
00114 
00115                 boost::asio::io_service                     serial_ios_;        
00116                 cornelluniversity::vetserial::asynch_serial serialport_;        
00117                 std::string                                 serial_device_; 
00118                 unsigned int                                serial_baud_;       
00119                 cu::vetserial::COMMAND_ID                                       cmnd_to_tx_;    
00121         protected:
00125                 enum {
00126                         FRAME_MAIN_FRAME = 1000,        
00127                         WXPANEL_SERIAL_CONTROLS,        
00128                         TEXT_SERIAL_DEVICE,                     
00129                         STATIC_LABEL_BAUD,                      
00130                         CHOICE_BAUD_RATE,                       
00131                         CHOICE_SERIAL_PARITY,           
00132                         CHOICE_SERIAL_DATA_BITS,        
00133                         CHOICE_SERIAL_STOP_BITS,        
00134                         BUTTON_CONNECT,                         
00135                         BUTTON_DISCONNECT,                      
00136                         WXPANEL_PROTO_CONTROLS,         
00137                         RAD_PROTO_CNTRL_REQ,            
00138                         RAD_PROTO_STATUS_REQ,           
00139                         RAD_PROTO_PLAY_MP3_REQ,     
00140                         RAD_PROTO_STOP_MP3_REQ,         
00141                         TXT_MP3OPTS_DEVICE,                     
00142                         TXT_MP3OPTS_TRACK,                      
00143                         TXT_MP3OPTS_DURATION,           
00144                         CHKBX_PACKETOPTS_ACK,           
00145                         CHKBX_PACKETOPTS_NAK,           
00146                         CHKBX_PACKETOPTS_ECHO,          
00147                         TXT_PACKETOPTS_ECHO_VALUE,      
00148                         BUT_PACKET_TRANSMIT,            
00149                         BUT_PACKET_RESET,                       
00150                         LISTBOX_RX_OUTPUT,                      
00151                         LISTBOX_TX_OUTPUT,                      
00152                         STATUS_MAIN_FRAME,                      
00153                         MENU_MAIN_MENU,                         
00154                         MENU_FILE_SERIAL_CONNECT,       
00155                         MENU_FILE_SERIAL_DISCONNECT,
00156                         MENU_FILE_QUIT,                         
00157                         MENU_HELP_ABOUT,                        
00158                         PANEL_TX_OUTPUT,                        
00159                         PANEL_RX_OUTPUT,                        
00160                         WXPANEL_PACKET_EXPLORER,        
00161                         LISTCTRL_PACKET_EXPLORER,       
00162                 };
00163                 
00164                 /* all the private member pointers to the actual controls.  
00165                 I've tried to name the vars in a self descriptive way, so 
00166                 i'm not going to waste time defining each one          */
00167                 wxPanel*                        m_panel_serial;
00168                 wxStaticText*           m_label_serport;
00169                 wxTextCtrl*                     m_text_serial_device;
00170                 wxStaticText*           m_label_baud;
00171                 wxChoice*                       m_choice_baud;
00172                 wxStaticText*           m_label_parity;
00173                 wxChoice*                       m_choice_parity;
00174                 wxStaticText*           m_label_data_bits;
00175                 wxChoice*                       m_choice_data_bits;
00176                 wxStaticText*           m_label_stop_bits;
00177                 wxChoice*                       m_choice_stop_bits;
00178                 wxButton*                       m_button_connect;
00179                 wxButton*                       m_button_disconnect;
00180                 wxPanel*                        m_panel_proto_controls;
00181                 wxRadioButton*          m_radio_control_req;
00182                 wxRadioButton*          m_radio_status_req;
00183                 wxRadioButton*          m_radio_play_mp3_req;
00184                 wxRadioButton*          m_radio_stop_mp3_req;
00185                 wxStaticText*           m_label_mp3opts_device;
00186                 wxTextCtrl*                     m_txt_mp3opts_device;
00187                 wxStaticText*           m_label_device_hint;
00188                 wxStaticText*           m_label_mp3opts_track;
00189                 wxTextCtrl*                     m_txt_mp3opts_track;
00190                 wxStaticText*           m_label_track_hint;
00191                 wxStaticText*           m_label_mp3opts_duration;
00192                 wxTextCtrl*                     m_txt_mp3opts_duration;
00193                 wxStaticText*           m_label_duration_hint;
00194                 wxCheckBox*                     m_checkBox_packetopts_ack;
00195                 wxCheckBox*                     m_checkBox_packetopts_nak;
00196                 wxCheckBox*                     m_checkBox_packetopts_echo;
00197                 wxStaticText*           m_label_packetopts_echo_value;
00198                 wxTextCtrl*                     m_text_packetopts_echo_value;
00199                 wxStaticText*           m_label_echo_value_hint;
00200                 wxButton*                       m_button_packet_transmit;
00201                 wxButton*                       m_button_packet_reset;
00202                 wxListBox*                      m_listBox_rx_output;
00203                 wxListBox*                      m_listBox_tx_output;
00204                 wxStatusBar*            m_status_main;
00205                 wxMenuBar*                      m_menubar_main;
00206                 wxMenu*                         m_menu_file;
00207                 wxMenu*                         m_menu_file_serial;
00208                 wxMenu*                         m_menu_help;
00209                 wxPanel*                        m_panel_tx_output;
00210                 wxPanel*                        m_panel_rx_output;
00211                 wxPanel*                        m_panel_packet_explorer;
00212                 cu::PacketExplorer*     m_packet_explorer;
00213 
00218                 virtual void doSerialConnect( wxCommandEvent& event );
00223                 virtual void doSerialQuit( wxCommandEvent& event );
00228                 virtual void onRadioCntrlPktSelect( wxCommandEvent& event );
00233                 virtual void onRadioStatusPktSelect( wxCommandEvent& event );
00238                 virtual void onRadioPlayMp3PktSelect( wxCommandEvent& event );
00243                 virtual void onRadioStopMp3PktSelect( wxCommandEvent& event );
00248                 virtual void onMp3OptsDeviceText( wxCommandEvent& event );
00253                 virtual void onMp3OptsDeviceEnter( wxCommandEvent& event );
00258                 virtual void onMp3OptsTrackText( wxCommandEvent& event );
00263                 virtual void onMp3OptsTrackEnter( wxCommandEvent& event );
00268                 virtual void onMp3OptsDurationText( wxCommandEvent& event );
00273                 virtual void onMp3OptsDurationEnter( wxCommandEvent& event );
00280                 virtual void onSelectPacketOptsAck( wxCommandEvent& event );
00287                 virtual void onSelectPacketOptsNak( wxCommandEvent& event );
00294                 virtual void onSelectPacketOptsEcho( wxCommandEvent& event );
00299                 virtual void onPacketOptsEchoText( wxCommandEvent& event );
00304                 virtual void onPacketOptsEchoEnter( wxCommandEvent& event );
00305                 
00314                 virtual void onPacketTransmit( wxCommandEvent& event );
00319                 virtual void onPacketReset( wxCommandEvent& event );
00324                 virtual void doApplicationQuit( wxCommandEvent& event );
00329                 virtual void doApplicationAbout( wxCommandEvent& event );
00337                 virtual void onRxListBoxDblClk( wxCommandEvent& event );
00345                 virtual void onTxListBoxDblClk( wxCommandEvent& event );
00346         
00347         public:
00348                 wxAuiManager m_mgr;
00349                 wxString validator_echo_data;           
00350                 wxString validator_track_data;          
00351                 wxString validator_device_data;         
00352                 wxString validator_duration_data;       
00354                 MainFrame( wxWindow* parent, wxWindowID id = FRAME_MAIN_FRAME, const wxString& title = wxT("VetSim Serial PoC"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 1036,585 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );         
00355                 ~MainFrame();
00356 };
00357 
00358 #endif /*MAIN_APP_HEADER*/

Generated on Sat Nov 10 10:03:36 2012 for Vet Serial Interfaces (w/ proof-of-concept application) by  doxygen 1.4.7