Garmin Fleet Management Controller  2.19.0
CMsgThrottlingDlg.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * MODULE NAME:
4 * CMsgThrottlingDlg.cpp
5 *
6 * Copyright 2008-2012 by Garmin Ltd. or its subsidiaries.
7 *---------------------------------------------------------------------
8 * $NoKeywords$
9 *********************************************************************/
10 #include "stdafx.h"
11 #include "CFmiApplication.h"
12 #include "CFmiPcAppDlg.h"
13 #include "CMsgThrottlingDlg.h"
14 #include "Event.h"
15 
16 IMPLEMENT_DYNAMIC( CMsgThrottlingDlg, CDialog )
17 
18 BEGIN_MESSAGE_MAP( CMsgThrottlingDlg, CDialog )
19  ON_BN_CLICKED( IDC_THROTTLE_BTN_CANCEL, OnBnClickedBack )
20  ON_BN_CLICKED( IDC_THROTTLE_BTN_UPDATE, OnBnClickedUpdate )
21  ON_BN_CLICKED( IDC_THROTTLE_CHK_ALL, OnBnClickedCheckAll )
22 #if( FMI_SUPPORT_A605 )
23  ON_MESSAGE( WM_EVENT( EVENT_FMI_MSG_THROTTLE_QUERY_RESP_RECEIVED ), OnThrottleQueryResponse )
24 #endif
25 END_MESSAGE_MAP()
26 
27 //----------------------------------------------------------------------
31 //----------------------------------------------------------------------
32 CMsgThrottlingDlg::CMsgThrottlingDlg
33  (
34  CWnd * aParent,
35  FmiApplicationLayer & aCom
36  )
37  : CDialog( IDD_MSG_THROTTLING, aParent )
38  , mCom( aCom )
39  , mMessageStatus( FALSE )
40  , mRefreshCannedResponseList( FALSE )
41  , mRefreshCannedMessageList( FALSE )
42  , mClientToServerTextMessage( FALSE )
43  , mStopStatus( FALSE )
44  , mEta( FALSE )
45  , mDriverIdUpdate( FALSE )
46  , mDriverStatusList( FALSE )
47  , mDriverStatusUpdate( FALSE )
48  , mPing( FALSE )
49  , mWaypointDeleted( FALSE )
50 {
51 }
52 
53 //----------------------------------------------------------------------
55 //----------------------------------------------------------------------
57 {
58 }
59 
60 //----------------------------------------------------------------------
63 //----------------------------------------------------------------------
65  (
66  CDataExchange * aDataExchange
67  )
68 {
69  CDialog::DoDataExchange( aDataExchange );
70 
71  DDX_Check( aDataExchange, IDC_THROTTLE_CHK_MESSAGE_STATUS, mMessageStatus );
75  DDX_Check( aDataExchange, IDC_THROTTLE_CHK_STOP_STATUS, mStopStatus );
76  DDX_Check( aDataExchange, IDC_THROTTLE_CHK_ETA, mEta );
77  DDX_Check( aDataExchange, IDC_THROTTLE_CHK_DRIVER_ID_UPDATE, mDriverIdUpdate );
80  DDX_Check( aDataExchange, IDC_THROTTLE_CHK_PING, mPing );
81  DDX_Check( aDataExchange, IDC_THROTTLE_CHK_WAYPOINT_DELETED, mWaypointDeleted );
82  DDX_Check( aDataExchange, IDC_THROTTLE_CHK_ALL, mSelectAll );
83 }
84 
85 //----------------------------------------------------------------------
92 //----------------------------------------------------------------------
94 {
95  CDialog::OnInitDialog();
96 
107 #if FMI_SUPPORT_A607
109 #endif
110 
121 #if FMI_SUPPORT_A607
123 #endif
124 
125  // set all to false for now
126  for( int i = 0; i < NUM_THROTTLED_PROTOCOLS; i++)
127  {
128  *( mProtocolStateLookup[i] ) = FALSE;
129  mOriginalValues[i] = FALSE;
130  }
131 
132 #if( FMI_SUPPORT_A605 )
133  // Query the throttling to get the real check values
135 
136  UpdateData( FALSE );
137 #endif
138  return TRUE;
139 } /* OnInitDialog() */
140 
141 //----------------------------------------------------------------------
143 //----------------------------------------------------------------------
145 {
146  OnCancel();
147 } /* OnBnClickedBack() */
148 
149 //----------------------------------------------------------------------
156 //----------------------------------------------------------------------
158 {
159  int i;
160 
161  UpdateData( TRUE );
162 
163  // Check to see which protocols actually changed
164  for( i = 0; i < NUM_THROTTLED_PROTOCOLS; ++i )
165  {
166  if( *( mProtocolStateLookup[i] ) != mOriginalValues[i] )
167  {
169  (
170  mPacketIdLookup[i],
172  );
173  }
175  }
176 
177  OnOK();
178 } /* OnBnClickedUpdate() */
179 
180 //----------------------------------------------------------------------
183 //----------------------------------------------------------------------
185 {
186  UpdateData( TRUE );
187  int i;
188 
189  for( i = 0; i < NUM_THROTTLED_PROTOCOLS; i++ )
190  {
192  }
193 
194  UpdateData( FALSE );
195 }
196 
197 #if( FMI_SUPPORT_A605 )
198 //----------------------------------------------------------------------
208 //----------------------------------------------------------------------
210  (
211  WPARAM aResponseCount,
212  LPARAM aResponseList
213  )
214 {
216  uint32 listCount = (uint32)aResponseCount;
217 
218  UpdateData( TRUE );
219  for( uint32 listIdx = 0; listIdx < listCount; ++listIdx )
220  {
221  for( uint32 localIdx = 0; localIdx < NUM_THROTTLED_PROTOCOLS; ++localIdx )
222  {
223  if( mPacketIdLookup[localIdx] == list[listIdx].packet_id )
224  {
225  *mProtocolStateLookup[localIdx] = !( (BOOL) list[listIdx].new_state );
226  mOriginalValues[localIdx] = *mProtocolStateLookup[localIdx];
227  }
228  }
229  }
230  UpdateData( FALSE );
231 
232  return 0;
233 }
234 #endif
BOOL * mProtocolStateLookup[NUM_THROTTLED_PROTOCOLS]
Pointers to BOOLs indicating the requested throttle state.
#define IDC_THROTTLE_CHK_REFRESH_CAN_RESP
Definition: resource.h:332
uint16 mPacketIdLookup[NUM_THROTTLED_PROTOCOLS]
Lookup table from array indexes to protocol (packet) IDs.
BOOL mSelectAll
If TRUE, the Select All check box is selected.
#define IDC_THROTTLE_CHK_ALL
Definition: resource.h:323
BOOL mWaypointDeleted
If TRUE, the Waypoint Deleted check box is selected.
BOOL mRefreshCannedResponseList
If TRUE, the Refresh Canned Response List check box is selected.
#define IDC_THROTTLE_CHK_DRIVER_STATUS_UPDATE
Definition: resource.h:327
FmiApplicationLayer & mCom
Reference to the FMI communication controller.
void sendMessageThrottlingUpdate(uint16 aPacketId, uint16 aNewState)
Sends an update to the client to tell it whether to enable or disable a protocol. ...
#define IDC_THROTTLE_CHK_WAYPOINT_DELETED
Definition: resource.h:335
Modal dialog allowing the user to throttle (disable) or un-throttle (enable) certain client-initiated...
#define FALSE
Definition: garmin_types.h:46
virtual ~CMsgThrottlingDlg()
Destructor.
BOOL mOriginalValues[NUM_THROTTLED_PROTOCOLS]
The current throttle state on the client.
#define IDC_THROTTLE_BTN_CANCEL
Definition: resource.h:321
#define TRUE
Definition: garmin_types.h:45
BOOL mPing
If TRUE, the Client to Server Ping check box is selected.
BOOL mStopStatus
If TRUE, the Stop Status check box is selected.
BOOL mMessageStatus
If TRUE, the Message Status check box is selected.
BOOL mRefreshCannedMessageList
If TRUE, the Refresh Canned Message List check box is selected.
#define IDC_THROTTLE_CHK_STOP_STATUS
Definition: resource.h:333
afx_msg void OnBnClickedUpdate()
Click handler for the Update button.
#define IDC_THROTTLE_CHK_DRIVER_STATUS_LIST_REFRESH
Definition: resource.h:326
afx_msg void OnBnClickedBack()
Click handler for the Back button; closes the dialog.
BOOL mDriverStatusList
If TRUE, the Driver Status List Refresh check box is selected.
Serial communication controller for Garmin and FMI packets.
BOOL mDriverIdUpdate
If TRUE, the Driver ID Update check box is selected.
#define IDD_MSG_THROTTLING
Definition: resource.h:33
BOOL mDriverStatusUpdate
If TRUE, the Driver Status Update check box is selected.
afx_msg LRESULT OnThrottleQueryResponse(WPARAM aResponseCount, LPARAM aResponseList)
Event handler that processes a throttling query response event.
unsigned short int uint16
16-bit unsigned integer
Definition: garmin_types.h:64
#define IDC_THROTTLE_CHK_PING
Definition: resource.h:330
#define IDC_THROTTLE_CHK_REFRESH_CAN_MSG_LIST
Definition: resource.h:331
BOOL OnInitDialog()
Initialize the dialog.
#define NUM_THROTTLED_PROTOCOLS
Number of throttled protocols that are supported.
#define IDC_THROTTLE_CHK_MESSAGE_STATUS
Definition: resource.h:329
Data type for the Message Throttling Command Packet ID and Message Throttling Response Packet ID...
Definition: fmi.h:1579
BOOL mEta
If TRUE, the ETA check box is selected.
#define IDC_THROTTLE_CHK_CLIENT_TO_SERVER_OPEN_TXT_MSG
Definition: resource.h:324
afx_msg void OnBnClickedCheckAll()
Click handler for the Select All check box.
#define IDC_THROTTLE_CHK_ETA
Definition: resource.h:328
#define IDC_THROTTLE_CHK_DRIVER_ID_UPDATE
Definition: resource.h:325
#define WM_EVENT(_event)
Translation from an application event to the corresponding Windows message.
unsigned long int uint32
32-bit unsigned integer
Definition: garmin_types.h:66
virtual void DoDataExchange(CDataExchange *aDataExchange)
Perform dialog data exchange and validation.
BOOL mClientToServerTextMessage
If TRUE, the Client to Server Text Message check box is selected.
void sendMessageThrottlingQuery()
Initiate the Message Throttling Query protocol.
#define IDC_THROTTLE_BTN_UPDATE
Definition: resource.h:322