Garmin Fleet Management Controller  2.19.0
CDashcamNtfctnDlg.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * MODULE NAME:
4 * CDashcamNtfctnDlg.cpp
5 *
6 * Copyright 2015 by Garmin Ltd. or its subsidiaries.
7 *---------------------------------------------------------------------
8 * $NoKeywords$
9 *********************************************************************/
10 #include "stdafx.h"
11 #include "CDashcamNtfctnDlg.h"
12 #include "Event.h"
13 
14 #if( FMI_SUPPORT_A622 )
15 
16 // CDashcamNtfctn dialog
17 
18 IMPLEMENT_DYNAMIC(CDashcamNtfctnDlg, CDialog)
19 
20 BEGIN_MESSAGE_MAP(CDashcamNtfctnDlg, CDialog)
21  ON_MESSAGE( WM_EVENT( EVENT_FMI_DASHCAM_SET_NTFCTN_RECEIPT ), OnDashcamSetNtfctnReceipt )
22  ON_MESSAGE( WM_EVENT( EVENT_FMI_DASHCAM_GET_NTFCTN_SETTINGS_RESPONSE ), OnGetNtfctnSettingsResponse )
23  ON_BN_CLICKED( IDC_ENABLE_FORWARD_COLLISION_NTFCTN, OnReevaluate )
24  ON_BN_CLICKED( IDC_DISABLE_FORWARD_COLLISION_NTFCTN, OnReevaluate )
25  ON_BN_CLICKED( IDC_ENABLE_LANE_DEPARTURE_WARNING_NTFCTN, OnReevaluate )
26  ON_BN_CLICKED( IDC_DISABLE_LANE_DEPARTURE_WARNING_NTFCTN, OnReevaluate )
27  ON_BN_CLICKED( IDC_ENABLE_INCIDENT_DETECTION_NTFCTN, OnReevaluate )
28  ON_BN_CLICKED( IDC_DISABLE_INCIDENT_DETECTION_NTFCTN, OnReevaluate )
29  ON_BN_CLICKED( IDC_DASHCAM_REFRESH_SETTINGS, OnRefreshNtfctnSettings )
30  ON_BN_CLICKED( IDOK, OnBnClickedSet )
31  ON_BN_CLICKED( IDCANCEL, OnClose )
32 END_MESSAGE_MAP()
33 
34 //----------------------------------------------------------------------
38 //----------------------------------------------------------------------
39 CDashcamNtfctnDlg::CDashcamNtfctnDlg
40  (
41  CWnd * aParent,
42  FmiApplicationLayer & aCom
43  )
44  : CDialog( CDashcamNtfctnDlg::IDD, aParent )
45  , mCom( aCom )
46  , mForwardCollisionNtfctn( -1 )
47  , mLaneDepartureNtfctn( -1 )
48  , mIncidentDetectionNtfctn( -1 )
49 {
50 }
51 
52 //----------------------------------------------------------------------
54 //----------------------------------------------------------------------
56 {
57 }
58 
59 //----------------------------------------------------------------------
65 //----------------------------------------------------------------------
67 {
68  CDialog::OnInitDialog();
69 
70  UpdateData( FALSE );
71  return TRUE;
72 } /* OnInitDialog() */
73 
74 //----------------------------------------------------------------------
77 //----------------------------------------------------------------------
79  (
80  CDataExchange * aDataExchange
81  )
82 {
83  CDialog::DoDataExchange( aDataExchange );
84 
88 }
89 
90 //----------------------------------------------------------------------
94 //----------------------------------------------------------------------
96 {
97  UpdateData( TRUE );
99  getSettings.change_id = GetTickCount();
100  mCom.sendFmiPacket( FMI_DASHCAM_GET_NTFCTN_SETTINGS_REQUEST, (uint8*)&getSettings, sizeof( getSettings) );
101  UpdateData( FALSE );
102 }
103 
104 //----------------------------------------------------------------------
108 //----------------------------------------------------------------------
110 {
112  memset( &setNtfctn, 0, sizeof( setNtfctn ) );
113  setNtfctn.change_id = GetTickCount();
114 
118 
119  mCom.sendFmiPacket( FMI_DASHCAM_SET_NTFCTN_REQUEST, (uint8*)&setNtfctn, sizeof( setNtfctn ) );
120 } /* OnBnClickedSet () */
121 
122 //----------------------------------------------------------------------
125 //----------------------------------------------------------------------
127 {
128  UpdateData( TRUE );
132  UpdateData( FALSE );
133 
134  CDialog::OnCancel();
135 } /* OnClose() */
136 
137 //----------------------------------------------------------------------
140 //----------------------------------------------------------------------
142 {
143  CDialog::PostNcDestroy();
144 } /* PostNcDestroy() */
145 
146 
147 //----------------------------------------------------------------------
149 //----------------------------------------------------------------------
150 LRESULT CDashcamNtfctnDlg::OnDashcamSetNtfctnReceipt ( WPARAM return_code, LPARAM )
151 {
152  CString message;
153 
154  switch( return_code )
155  {
156  case DASHCAM_SUCCESS:
157  {
158  message.Format( _T( "Camera notification settings successfully updated." ) );
159  MessageBox( message, _T( "Camera Notifications Success" ), MB_OK | MB_ICONINFORMATION );
160  break;
161  }
163  {
164  message.Format( _T( "Camera notifications failed.\n Forward Collision Warnings and Lane Departure Warnings not supported on this device." ) );
165  MessageBox( message, _T( "Camera Notifications Failure" ), MB_OK | MB_ICONINFORMATION );
166  break;
167  }
169  {
170  message.Format( _T( "Camera notifications failed. Forward Collision Warning is not enabled on this device." ) );
171  MessageBox( message, _T( "Camera Notifications Failure" ), MB_OK | MB_ICONINFORMATION );
172  break;
173  }
175  {
176  message.Format( _T( "Camera notifications failed. Lane Departure Warning is not enabled on this device." ) );
177  MessageBox( message, _T( "Camera Notifications Failure" ), MB_OK | MB_ICONINFORMATION );
178  break;
179  }
181  {
182  message.Format( _T( "Camera notifications failed. Automatic Incident Detection is not enabled on this device." ) );
183  MessageBox( message, _T( "Camera Notifications Failure" ), MB_OK | MB_ICONINFORMATION );
184  break;
185  }
186  default:
187  {
188  message.Format( _T( "Camera notifications failed. Unrecognized error." ) );
189  MessageBox( message, _T( "Camera Notifications Failure" ), MB_OK | MB_ICONINFORMATION );
190  break;
191  }
192  }
193  return 0;
194 }
195 
196 //----------------------------------------------------------------------
198 //----------------------------------------------------------------------
199 LRESULT CDashcamNtfctnDlg::OnGetNtfctnSettingsResponse ( WPARAM return_code, LPARAM receipt_data )
200 {
201  CString message;
203 
204  switch( return_code )
205  {
206  case DASHCAM_SUCCESS:
207  {
208  UpdateData( TRUE );
212  UpdateData( FALSE );
213 
214  message.Format( _T( "Camera notification settings successfully retrieved." ) );
215  MessageBox( message, _T( "Camera Notifications Success" ), MB_OK | MB_ICONINFORMATION );
216  break;
217  }
219  {
220  message.Format( _T( "Camera notification settings retrieval failed due to internal error." ) );
221  MessageBox( message, _T( "Camera Notifications Failure" ), MB_OK | MB_ICONINFORMATION );
222  break;
223  }
224  default:
225  {
226  message.Format( _T( "Camera notification settings retrieval failed. Unrecognized Reason." ) );
227  MessageBox( message, _T( "Camera Notifications Failure" ), MB_OK | MB_ICONINFORMATION );
228  break;
229  }
230  }
231  return 0;
232 }
233 
234 //----------------------------------------------------------------------
237 //----------------------------------------------------------------------
239 {
240  UpdateData();
241  //checks to make sure all notifications are set
242  //if so, set button is enabled, if not, set button disabled.
243  if( ( -1 != mForwardCollisionNtfctn ) &&
244  ( -1 != mLaneDepartureNtfctn ) &&
245  ( -1 != mIncidentDetectionNtfctn ) )
246  {
247  GetDlgItem( IDOK )->EnableWindow();
248  }
249  else
250  {
251  GetDlgItem( IDOK )->EnableWindow( FALSE );
252  }
253 }
254 
255 #endif
Data type for Get Dashcam Notification Settings Packet ID (0X1609) from client to server...
Definition: fmi.h:2310
#define IDC_ENABLE_LANE_DEPARTURE_WARNING_NTFCTN
Definition: resource.h:559
BOOL OnInitDialog()
Initialize the dialog.
virtual ~CDashcamNtfctnDlg()
Destructor.
void OnClose()
Handler for the Close action.
Browser-based container for listing the Dashcam library.
void PostNcDestroy()
Called by MFC after the window has been destroyed; performs final termination activities.
afx_msg LRESULT OnGetNtfctnSettingsResponse(WPARAM, LPARAM)
This function handles the dashcam set notification receipt event from device.
void OnRefreshNtfctnSettings()
Button handler for the Retrieve Settings button.
virtual void DoDataExchange(CDataExchange *pDX)
Perform dialog data exchange and validation.
void sendFmiPacket(uint16 aFmiPacketId, uint8 *aFmiPayload, uint8 aFmiPayloadSize)
Send an arbitrary FMI packet.
void OnReevaluate()
Change handler for editable controls.
Data type for Dashcam Get Settings Packet ID (0X1604, 0X1608) from server to client.
Definition: fmi.h:2283
#define IDC_DISABLE_LANE_DEPARTURE_WARNING_NTFCTN
Definition: resource.h:555
#define FALSE
Definition: garmin_types.h:46
unsigned char boolean
8-bit value representing FALSE (0) or TRUE (nonzero)
Definition: garmin_types.h:52
#define TRUE
Definition: garmin_types.h:45
void OnBnClickedSet()
Button handler for the Set button.
#define IDC_DISABLE_INCIDENT_DETECTION_NTFCTN
Definition: resource.h:561
Serial communication controller for Garmin and FMI packets.
afx_msg LRESULT OnDashcamSetNtfctnReceipt(WPARAM, LPARAM)
This function handles the dashcam set notification receipt event from device.
#define IDC_ENABLE_FORWARD_COLLISION_NTFCTN
Definition: resource.h:542
unsigned char uint8
8-bit unsigned integer
Definition: garmin_types.h:62
FmiApplicationLayer & mCom
Reference to the FMI communication controller.
#define IDC_ENABLE_INCIDENT_DETECTION_NTFCTN
Definition: resource.h:563
#define WM_EVENT(_event)
Translation from an application event to the corresponding Windows message.
#define IDC_DASHCAM_REFRESH_SETTINGS
Definition: resource.h:6
Data type for Set Dashcam Notification Settings Packet ID (0X1606) from server to client...
Definition: fmi.h:2300
#define IDC_DISABLE_FORWARD_COLLISION_NTFCTN
Definition: resource.h:540