Garmin Fleet Management Controller  2.19.0
CLogViewerDlg Class Reference

Modeless log viewer dialog. More...

#include <CLogViewerDlg.h>

+ Inheritance diagram for CLogViewerDlg:

Public Member Functions

 CLogViewerDlg (LogParser *aLogParser, CWnd *aParent=NULL, BOOL aOpenOther=FALSE)
 Constructor. More...
 
virtual ~CLogViewerDlg ()
 Destructor. More...
 
void onEvent (EventId aEventId, uint32 aEventData, void *aEventDataPtr, BOOL handleNow)
 Handles event callbacks by translating an EventId into a windows message. More...
 

Protected Types

enum  SearchDirectionType {
  SEARCH_UP,
  SEARCH_DOWN
}
 Search direction. Indexes must correspond to the radio buttons in the IDC_LOG_RDO_UP radio group. More...
 

Protected Member Functions

virtual void DoDataExchange (CDataExchange *aDataExchange)
 Perform dialog data exchange and validation. More...
 
afx_msg void OnBnClickedClearLog ()
 Click handler for the Clear Log button. More...
 
afx_msg void OnBnClickedFindNext ()
 Click handler for the Find Next button. More...
 
afx_msg void OnBnClickedOk ()
 Click handler for the OK button; destroys the window. More...
 
afx_msg void OnBnClickedSaveAs ()
 Click handler for the Save As button. More...
 
afx_msg void OnBnClickedViewCurrent ()
 Click handler for the View Current button. More...
 
afx_msg void OnBnClickedViewOther ()
 Click handler for the View Other button. More...
 
afx_msg void OnCancel ()
 Handler for the Cancel action; destroys the window. More...
 
afx_msg void OnGetMinMaxInfo (MINMAXINFO *aMinMaxInfo)
 Called on every resize to get the resize bounds. More...
 
BOOL OnInitDialog ()
 Initialize the dialog. More...
 
afx_msg void OnLbnSelchangeLog ()
 Selection Changed handler for the packet list. More...
 
afx_msg LPARAM OnPacketLogged (WPARAM, LPARAM)
 Handles the Packet Logged event from Com; updates the packet list. More...
 
afx_msg void OnSize (UINT aType, int aClientWidth, int aClientHeight)
 Called after the dialog is resized; repositions the contents of the display. More...
 
void PostNcDestroy ()
 Perform final cleanup on the log viewer. More...
 
void resendPacket ()
 Retransmit the selected packet for debugging purposes. More...
 
void resetView ()
 Reset the log view. More...
 
void UpdateLogDisplay ()
 Reads the log file and updates the packet list. If a packet was selected, keeps the packet selected and visible in the list. More...
 
BOOL updateView ()
 Update the log view. More...
 

Protected Attributes

CButton mClearButton
 Reference to the Clear button. More...
 
CButton mCloseButton
 Reference to the Close button. More...
 
CStatic mCurrentPacketControl
 Reference to a control containing the currently selected packet, formatted. More...
 
CStatic mCurrentPacketTitleLabel
 Label above the current packet text box. More...
 
CButton mFindNextButton
 Reference to the Find Next button. More...
 
CStatic mLogNameControl
 Control containing the log name. More...
 
CString mLogNameText
 The string describing the log being viewed ("Current execution's" or a file name) More...
 
CStatic mLogNameTitleLabel
 Label for the log name control. More...
 
LogParsermLogParser
 The log parser. More...
 
BOOL mOpenOtherLog
 If TRUE, the Open File dialog should be presented (to aOpenOther another log) More...
 
CColoredListBox mPacketListBox
 Reference to the packet list box. More...
 
CStatic mPacketListTitleLabel
 Label above the packet list. More...
 
CButton mResendButton
 Reference to the Resend button. More...
 
CButton mSaveButton
 Reference to the Save button. More...
 
int mSearchDirection
 Search direction. More...
 
CButton mSearchDownRadioButton
 Reference to the Search Down radio button. More...
 
CButton mSearchGroupBox
 Reference to the Search group box. More...
 
CString mSearchText
 Contents of the Search Text edit box. More...
 
CEdit mSearchTextControl
 Reference to the Search Text edit box. More...
 
CButton mSearchUpRadioButton
 Reference to the Search Up radio button. More...
 
CString mSelectedPacketText
 Formatted representation of the current packet. More...
 
CButton mViewCurrentButton
 Reference to the View Current button. More...
 
CButton mViewOtherButton
 Reference to the View Other button. More...
 

Detailed Description

Modeless log viewer dialog.

This dialog reads, parses, and displays a packet log created by the Com class. The list of packets is displayed on the left side; selecting a packet causes the selected packet to be displayed and formatted into a text box on the right side of the dialog. The user can also search the packet list (header names only), mSaveButton the current log file, or open a previous log.

Definition at line 31 of file CLogViewerDlg.h.

Member Enumeration Documentation

Search direction. Indexes must correspond to the radio buttons in the IDC_LOG_RDO_UP radio group.

Enumerator
SEARCH_UP 
SEARCH_DOWN 

Definition at line 48 of file CLogViewerDlg.h.

Constructor & Destructor Documentation

CLogViewerDlg::CLogViewerDlg ( LogParser aLogParser,
CWnd *  aParentWnd = NULL,
BOOL  aOpenOtherLog = FALSE 
)

Constructor.

Parameters
aLogParserThe LogParser which will format log entries
aParentWndThe parent of this dialog
aOpenOtherLogIf TRUE, the dialog starts by presenting a File/Open dialog to allow the user to select another (i.e., saved, not the current) packet log to view.

Definition at line 47 of file CLogViewerDlg.cpp.

CLogViewerDlg::~CLogViewerDlg ( )
virtual

Destructor.

Definition at line 63 of file CLogViewerDlg.cpp.

References DoDataExchange().

Member Function Documentation

void CLogViewerDlg::DoDataExchange ( CDataExchange *  aDataExchange)
protectedvirtual

Perform dialog data exchange and validation.

Parameters
aDataExchangeThe DDX context

Definition at line 72 of file CLogViewerDlg.cpp.

References IDC_LOG_BTN_RESEND, IDC_LOG_EDIT_SEARCH_TEXT, IDC_LOG_GRP_SEARCH, IDC_LOG_LBL_LOG_NAME, IDC_LOG_LBL_PACKETS, IDC_LOG_LBL_SELECTED_PACKET, IDC_LOG_RDO_DOWN, IDC_LOG_RDO_UP, IDC_LOG_TXT_LOG_NAME, and IDC_LOG_TXT_SELECTED_PACKET.

Referenced by ~CLogViewerDlg().

void CLogViewerDlg::OnBnClickedClearLog ( )
protected

Click handler for the Clear Log button.

Clear (remove all packets from) the log file; also resets the packet list in the UI.

Definition at line 525 of file CLogViewerDlg.cpp.

References Logger::clearLog(), and Logger::LOG_FILE.

void CLogViewerDlg::OnBnClickedFindNext ( )
protected

Click handler for the Find Next button.

Finds the next occurrence of the search string supplied in the list of packets. Note that this only searches the packet description in the list, not the parsed content.

Definition at line 604 of file CLogViewerDlg.cpp.

References TRUE.

void CLogViewerDlg::OnBnClickedOk ( )
protected

Click handler for the OK button; destroys the window.

Definition at line 187 of file CLogViewerDlg.cpp.

void CLogViewerDlg::OnBnClickedSaveAs ( )
protected

Click handler for the Save As button.

Presents the user with a File Save dialog then saves the currently viewed log to the user-specified filename.

Definition at line 538 of file CLogViewerDlg.cpp.

References FALSE.

void CLogViewerDlg::OnBnClickedViewCurrent ( )
protected

Click handler for the View Current button.

Switch to the default (current) packet log and update the log display.

Definition at line 507 of file CLogViewerDlg.cpp.

References Logger::LOG_FILE.

void CLogViewerDlg::OnBnClickedViewOther ( )
protected

Click handler for the View Other button.

Prompt the user (with a FileDialog) to select another packet log to view then update the log display.

Definition at line 439 of file CLogViewerDlg.cpp.

References TRUE.

void CLogViewerDlg::OnCancel ( )
protected

Handler for the Cancel action; destroys the window.

Definition at line 196 of file CLogViewerDlg.cpp.

void CWndEventListener::onEvent ( EventId  aEventId,
uint32  aEventData,
void *  aEventDataPtr,
BOOL  handleNow 
)
virtualinherited

Handles event callbacks by translating an EventId into a windows message.

Casts this to a CWnd then posts a Windows message to it. The use of dynamic_cast is used as an alternative to the "dreaded diamond" caused by C++ multiple inheritance.

Parameters
aEventIdThe event ID
aEventDataThe event data
aEventDataPtrPointer to more event data
Note
Interested parties receive these events as Windows messages, i.e., ON_MESSAGE( aEventId, CallbackFunction ). aEventData is the WPARAM, and aEventDataPtr is the LPARAM.

Implements EventListener.

Definition at line 29 of file CWndEventListener.cpp.

References EVENT_ID_CNT, and WM_EVENT.

void CLogViewerDlg::OnGetMinMaxInfo ( MINMAXINFO *  aMinMaxInfo)
protected

Called on every resize to get the resize bounds.

Sets minTrackSize to the minimum dimensions the window can be resized to.

Parameters
aMinMaxInfoPointer to the MINMAXINFO data structure that this function updates

Definition at line 393 of file CLogViewerDlg.cpp.

Referenced by OnSize().

BOOL CLogViewerDlg::OnInitDialog ( )
protected

Initialize the dialog.

This function is called when the window is created. It sets up the parent, so it can get info from and send a message to Com. It also registers to receive events from Com, and initializes the maps of packet and command IDs to names for simplified lookup.

Returns
TRUE, since this function does not set focus to a control

Definition at line 108 of file CLogViewerDlg.cpp.

References FALSE, Logger::LOG_FILE, and TRUE.

void CLogViewerDlg::OnLbnSelchangeLog ( )
protected

Selection Changed handler for the packet list.

Gets the currently selected packet and formats it into the text box. Enables the resend button if a packet is selected and the app is connected to a client.

Definition at line 417 of file CLogViewerDlg.cpp.

References FALSE, SerialPort::getInstance(), and TRUE.

afx_msg LPARAM CLogViewerDlg::OnPacketLogged ( WPARAM  ,
LPARAM   
)
protected

Handles the Packet Logged event from Com; updates the packet list.

Returns
0, always

Definition at line 133 of file CLogViewerDlg.cpp.

void CLogViewerDlg::OnSize ( UINT  aType,
int  aClientWidth,
int  aClientHeight 
)
protected

Called after the dialog is resized; repositions the contents of the display.

Moves/sizes the contents as follows:

  • Moves the search box to the bottom-left corner, keeping its size
  • Moves the packet list to the top-left, expands vertically
  • Moves the packet detail to the right of the list, expands horizontally to fill the dialog and vertically to match the height of the packet list
  • Centers the buttons under the packet detail.
    Parameters
    aTypeThe type of resizing requested (maximized, etc.)
    aClientWidthThe new width of the client area
    aClientHeightThe new height of the client area

Definition at line 233 of file CLogViewerDlg.cpp.

References EDGE_SPACING, FALSE, and OnGetMinMaxInfo().

Referenced by PostNcDestroy().

void CLogViewerDlg::PostNcDestroy ( )
protected

Perform final cleanup on the log viewer.

This is a "monitor", so it is modeless. When it gets the destroy message it must re-enable the main button to open these dialogs (the button was disabled when this window opened to prevent several instances of the log viewer from being displayed. Finally, this function deletes the CLogViewerDlg object since the pointer to it was lost after creation.

Definition at line 210 of file CLogViewerDlg.cpp.

References EVENT_LOG_VIEWER_CLOSED, OnSize(), and Event::post().

void CLogViewerDlg::resendPacket ( )
protected

Retransmit the selected packet for debugging purposes.

Note
This is currently limited to the active log.

Definition at line 405 of file CLogViewerDlg.cpp.

void CLogViewerDlg::resetView ( )
protected

Reset the log view.

Clear the packet list and packet detail, and update the log name.

Definition at line 478 of file CLogViewerDlg.cpp.

References FALSE, Logger::LOG_FILE, and TRUE.

void CLogViewerDlg::UpdateLogDisplay ( )
protected

Reads the log file and updates the packet list. If a packet was selected, keeps the packet selected and visible in the list.

Definition at line 144 of file CLogViewerDlg.cpp.

References FALSE, and TRUE.

BOOL CLogViewerDlg::updateView ( )
protected

Update the log view.

Retrieve any new packet titles from the log parser and add them to the list box.

Definition at line 169 of file CLogViewerDlg.cpp.

References FALSE, and TRUE.

Member Data Documentation

CButton CLogViewerDlg::mClearButton
protected

Reference to the Clear button.

Definition at line 108 of file CLogViewerDlg.h.

CButton CLogViewerDlg::mCloseButton
protected

Reference to the Close button.

Definition at line 96 of file CLogViewerDlg.h.

CStatic CLogViewerDlg::mCurrentPacketControl
protected

Reference to a control containing the currently selected packet, formatted.

Definition at line 141 of file CLogViewerDlg.h.

CStatic CLogViewerDlg::mCurrentPacketTitleLabel
protected

Label above the current packet text box.

Definition at line 144 of file CLogViewerDlg.h.

CButton CLogViewerDlg::mFindNextButton
protected

Reference to the Find Next button.

Definition at line 111 of file CLogViewerDlg.h.

CStatic CLogViewerDlg::mLogNameControl
protected

Control containing the log name.

Definition at line 153 of file CLogViewerDlg.h.

CString CLogViewerDlg::mLogNameText
protected

The string describing the log being viewed ("Current execution's" or a file name)

Definition at line 132 of file CLogViewerDlg.h.

CStatic CLogViewerDlg::mLogNameTitleLabel
protected

Label for the log name control.

Definition at line 150 of file CLogViewerDlg.h.

LogParser* CLogViewerDlg::mLogParser
protected

The log parser.

Definition at line 160 of file CLogViewerDlg.h.

BOOL CLogViewerDlg::mOpenOtherLog
protected

If TRUE, the Open File dialog should be presented (to aOpenOther another log)

Definition at line 93 of file CLogViewerDlg.h.

CColoredListBox CLogViewerDlg::mPacketListBox
protected

Reference to the packet list box.

Definition at line 129 of file CLogViewerDlg.h.

CStatic CLogViewerDlg::mPacketListTitleLabel
protected

Label above the packet list.

Definition at line 147 of file CLogViewerDlg.h.

CButton CLogViewerDlg::mResendButton
protected

Reference to the Resend button.

Definition at line 123 of file CLogViewerDlg.h.

CButton CLogViewerDlg::mSaveButton
protected

Reference to the Save button.

Definition at line 105 of file CLogViewerDlg.h.

int CLogViewerDlg::mSearchDirection
protected

Search direction.

See also
SearchDirectionType for valid values

Definition at line 157 of file CLogViewerDlg.h.

CButton CLogViewerDlg::mSearchDownRadioButton
protected

Reference to the Search Down radio button.

Definition at line 117 of file CLogViewerDlg.h.

CButton CLogViewerDlg::mSearchGroupBox
protected

Reference to the Search group box.

Definition at line 120 of file CLogViewerDlg.h.

CString CLogViewerDlg::mSearchText
protected

Contents of the Search Text edit box.

Definition at line 138 of file CLogViewerDlg.h.

CEdit CLogViewerDlg::mSearchTextControl
protected

Reference to the Search Text edit box.

Definition at line 126 of file CLogViewerDlg.h.

CButton CLogViewerDlg::mSearchUpRadioButton
protected

Reference to the Search Up radio button.

Definition at line 114 of file CLogViewerDlg.h.

CString CLogViewerDlg::mSelectedPacketText
protected

Formatted representation of the current packet.

Definition at line 135 of file CLogViewerDlg.h.

CButton CLogViewerDlg::mViewCurrentButton
protected

Reference to the View Current button.

Definition at line 102 of file CLogViewerDlg.h.

CButton CLogViewerDlg::mViewOtherButton
protected

Reference to the View Other button.

Definition at line 99 of file CLogViewerDlg.h.


The documentation for this class was generated from the following files: