00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef VETSIM_PCKEXPLR_H
00022 #define VETSIM_PCKEXPLR_H
00023
00024 #ifdef _WIN32
00025 #define _CRT_SECURE_NO_DEPRECATE // it appears that something in listctrl.h is linking against string.h
00026 #define _CRT_SECURE_NO_WARNINGS // and making use of old-school strcpy() and other insecure routines
00027 #endif // I cant do anything about it; these defines just remove the warning spam
00028
00029 #include <vector>
00030 #include <map>
00031 #include <wx/listctrl.h>
00032 #include "vetprot.h"
00033
00041 namespace cornelluniversity {
00042
00043 static const wxString UNDEF_RESULT = wxT("undefined");
00044 static const wxString PROTOCOL_CTRL_CHAR[] = { wxT("NUL"), wxT("SOH"), wxT("STX"), wxT("ETX"), wxT("EOT"), wxT("ENQ"), wxT("ACK"), wxT("NAK"), wxT("N/A"), wxT("N/A"), wxT("N/A"), wxT("N/A"), wxT("N/A"), wxT("N/A"), wxT("N/A"), wxT("SYN") };
00045 static const wxString PROTOCOL_CMNDS[] = { wxT("CMD_CNTRL"), wxT("CMD_REQSTAT"), wxT("CMD_RSPSTAT"), wxT("CMD_PLAY_MP3"), wxT("CMD_STOP_MP3") };
00056 class PacketExplorer : public wxListCtrl {
00057 public:
00062 struct PERow {
00063 bool error;
00064 int index;
00065 wxString byte;
00066 wxString value;
00067 wxString data;
00068 };
00069
00080 PacketExplorer( wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxListCtrlNameStr) :
00081 wxListCtrl( parent, id, pos, size, style, validator, name ), byte_col_wd_(0), val_col_wd_(0), data_col_wd_(0), rows_(new std::vector<PERow>()){;}
00087 virtual ~PacketExplorer( void );
00095 inline void PESetColumnWidths( int c1, int c2, int c3 ) { byte_col_wd_ = c1; val_col_wd_ = c2; data_col_wd_ = c3; }
00104 void PEDisplayHeader( int colwidth_1, int colwidth_2, int colwidth_3 );
00111 void PEDisplayHeader( void );
00117 inline void PEDisplayPacket( cornelluniversity::vetserial::base_command * bc ) { this->PEDisplayPacket( bc->packet(), bc->packet_size() ); }
00127 void PEDisplayPacket( const unsigned char * pkt, unsigned int nbytes );
00128
00129 private:
00135 PacketExplorer( void ){;}
00141 PacketExplorer( const PacketExplorer & copyref ){;}
00147 inline void PEInsertRow( const PERow & r ){ this->PEInsertRow(r.byte, r.value, r.data, r.error); }
00157 void PEInsertRow( const wxString & byte_col, const wxString & value_col, const wxString & data_col, bool inerror = false );
00164 void PEPublishRows( void );
00172 const wxString & CtrlCharString( const unsigned char index );
00180 const wxString & ProtoCmdString( const unsigned char index );
00188 const wxString & ProtoErrString( const unsigned char index );
00196 const wxString ProtoFlagString( const unsigned char index );
00197
00198 int byte_col_wd_;
00199 int val_col_wd_;
00200 int data_col_wd_;
00201 std::vector<PERow> *rows_;
00202 };
00203 }
00204
00205 #endif