Garmin Fleet Management Controller  2.19.0
CPingStatusDlg.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * MODULE NAME:
4 * CPingStatusDlg.cpp
5 *
6 * Copyright 2008-2009 by Garmin Ltd. or its subsidiaries.
7 *---------------------------------------------------------------------
8 * $NoKeywords$
9 *********************************************************************/
10 #include "stdafx.h"
11 #include "CFmiApplication.h"
12 #include "CPingStatusDlg.h"
13 #include "CFmiPcAppDlg.h"
14 #include "Event.h"
15 
16 IMPLEMENT_DYNAMIC( CPingStatusDlg, CDialog )
17 
18 BEGIN_MESSAGE_MAP( CPingStatusDlg, CDialog )
19  ON_BN_CLICKED( IDC_PING_BTN_RESET_CLIENT, OnBnClickedResetClient )
20  ON_BN_CLICKED( IDC_PING_BTN_RESET_SERVER, OnBnClickedResetServer )
21  ON_MESSAGE( WM_EVENT( EVENT_FMI_PING_RECEIVED ), OnPingEvent )
22  ON_MESSAGE( WM_EVENT( EVENT_FMI_PING_RESPONSE_RECEIVED ), OnPingEvent )
23  ON_BN_CLICKED( IDC_PING_BTN_SEND, OnBnClickedSendPing )
24 END_MESSAGE_MAP()
25 
26 //----------------------------------------------------------------------
30 //----------------------------------------------------------------------
31 CPingStatusDlg::CPingStatusDlg
32  (
33  CWnd * aParent,
34  FmiApplicationLayer & aCom
35  )
36  : CDialog( IDD_PING_STATUS, aParent )
37  , mCom( aCom )
38 {
39 }
40 
41 //----------------------------------------------------------------------
43 //----------------------------------------------------------------------
45 {
46 }
47 
48 //----------------------------------------------------------------------
51 //----------------------------------------------------------------------
53  (
54  CDataExchange * aDataExchange
55  )
56 {
57  CDialog::DoDataExchange( aDataExchange );
58 
59  DDX_Text( aDataExchange, IDC_PING_TXT_SERVER_PINGS, mServerPingCount );
60  DDX_Text( aDataExchange, IDC_PING_TXT_SERVER_PING_TS, mServerPingTime );
61  DDX_Text( aDataExchange, IDC_PING_TXT_CLIENT_PINGS, mClientPingCount );
62  DDX_Text( aDataExchange, IDC_PING_TXT_CLIENT_PING_TS, mClientPingTime );
63 }
64 
65 //----------------------------------------------------------------------
71 //----------------------------------------------------------------------
73 {
74  CDialog::OnInitDialog();
75 
77  return TRUE;
78 } /* OnInitDialog() */
79 
80 
81 //----------------------------------------------------------------------
84 //----------------------------------------------------------------------
86 {
89 } /* OnBnClickedResetClient() */
90 
91 //----------------------------------------------------------------------
94 //----------------------------------------------------------------------
96 {
99 } /* OnBnClickedResetServer() */
100 
101 //----------------------------------------------------------------------
106 //----------------------------------------------------------------------
107 afx_msg LRESULT CPingStatusDlg::OnPingEvent( WPARAM, LPARAM )
108 {
110  return 0;
111 } /* OnPingEvent() */
112 
113 //----------------------------------------------------------------------
117 //----------------------------------------------------------------------
119 {
120  mClientPingCount.Format( _T(" %d"), mCom.mClientPingCount );
121  if( mCom.mClientPingCount > 0 )
122  {
123  mClientPingTime.Format( mCom.mLastClientPingTime.Format("%I:%M:%S %p") );
124  }
125  else
126  {
127  mClientPingTime.Format( _T("") );
128  }
129 
130  mServerPingCount.Format( _T(" %d"), mCom.mServerPingCount );
131  if( mCom.mServerPingCount > 0 )
132  {
133  mServerPingTime.Format( mCom.mLastServerPingTime.Format("%I:%M:%S %p") );
134  }
135  else
136  {
137  mServerPingTime.Format( _T("") );
138  }
139  UpdateData( FALSE );
140 }
141 
142 //----------------------------------------------------------------------
146 //----------------------------------------------------------------------
148 {
149  mCom.sendPing();
150 } /* OnBnClickedSendPing() */
afx_msg LRESULT OnPingEvent(WPARAM, LPARAM)
Handler for the Ping event from FmiApplicationLayer.
#define IDC_PING_BTN_RESET_CLIENT
Definition: resource.h:277
virtual ~CPingStatusDlg()
Destructor.
afx_msg void OnBnClickedResetServer()
Click handler for the Reset (Server) button.
virtual void DoDataExchange(CDataExchange *aDataExchange)
Perform dialog data exchange and validation.
CTime mLastClientPingTime
Last time when a client to server ping was received.
#define IDC_PING_TXT_SERVER_PING_TS
Definition: resource.h:287
#define IDC_PING_TXT_CLIENT_PING_TS
Definition: resource.h:285
#define FALSE
Definition: garmin_types.h:46
#define IDD_PING_STATUS
Definition: resource.h:34
#define IDC_PING_TXT_CLIENT_PINGS
Definition: resource.h:286
CString mClientPingTime
Time when the last client to server ping was received, in the form HH:MM:SS AA (AA is am or pm) ...
#define TRUE
Definition: garmin_types.h:45
CTime mLastServerPingTime
Last time when a server to client ping was received.
CString mClientPingCount
Number of client to server pings received.
#define IDC_PING_BTN_RESET_SERVER
Definition: resource.h:278
int mServerPingCount
Number of server-to-client pings sent; can be reset by the user.
Serial communication controller for Garmin and FMI packets.
#define IDC_PING_TXT_SERVER_PINGS
Definition: resource.h:288
CString mServerPingTime
Time when the last server to client ping was sent, in the form HH:MM:SS AA (AA is am or pm) ...
int mClientPingCount
Number of client-to-server pings received; can be reset by the user.
FmiApplicationLayer & mCom
Reference to the FMI communication controller.
BOOL OnInitDialog()
Initialize the dialog.
void updateTextFields()
Update the text boxes.
CString mServerPingCount
Number of server to client pings sent.
Modeless dialog allowing the user to view ping status and send a ping.
#define WM_EVENT(_event)
Translation from an application event to the corresponding Windows message.
void sendPing()
Send a ping packet to the client.
afx_msg void OnBnClickedResetClient()
Click handler for the Reset (Client) button.
afx_msg void OnBnClickedSendPing()
Click handler for the Send Ping button.
#define IDC_PING_BTN_SEND
Definition: resource.h:279