Garmin Fleet Management Controller  2.19.0
CDashcamNtfctnFromClient.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * MODULE NAME:
4 * CDashcamNtfctnFromClient.cpp
5 *
6 * Copyright 2015 by Garmin Ltd. or its subsidiaries.
7 *---------------------------------------------------------------------
8 * $NoKeywords$
9 *********************************************************************/
10 #include "stdafx.h"
11 #include "FmiLogParser.h"
12 #include "CFmiApplication.h"
14 #include "util.h"
15 
16 #if( FMI_SUPPORT_A622 )
17 
18 IMPLEMENT_DYNAMIC( CDashcamNtfctnFromClient, CDialog )
19 
20 BEGIN_MESSAGE_MAP( CDashcamNtfctnFromClient, CDialog )
21 END_MESSAGE_MAP()
22 
23 //----------------------------------------------------------------------
28 //----------------------------------------------------------------------
29 CDashcamNtfctnFromClient::CDashcamNtfctnFromClient
30  (
31  CWnd * aParent,
32  FmiApplicationLayer & aCom,
34  )
35  : CDialog( IDD_DASHCAM_NTFCTN_FROM_CLIENT, aParent )
36  , mCom( aCom )
37  , mOriginationTime( _T("") )
38  , mType( _T("") )
39  , mLongitude( _T("") )
40  , mLatitude( _T("") )
41  , mIncidentFilename( _T("") )
42 
43 {
44  init( aEvent.origination_time, aEvent.scposn, aEvent.ntfctn_type );
45 }
46 
47 //----------------------------------------------------------------------
52 //----------------------------------------------------------------------
54  (
55  CWnd * aParent,
56  FmiApplicationLayer & aCom,
58  )
59  : CDialog( IDD_DASHCAM_NTFCTN_FROM_CLIENT, aParent )
60  , mCom( aCom )
61  , mOriginationTime( _T("") )
62  , mType( _T("") )
63  , mLongitude( _T("") )
64  , mLatitude( _T("") )
65  , mIncidentFilename( _T("") )
66 
67 {
68  init( aEvent.origination_time, aEvent.scposn, aEvent.ntfctn_type );
69 
70  mIncidentFilename = CString( aEvent.incident_fname );
71 }
72 
73 //----------------------------------------------------------------------
75 //----------------------------------------------------------------------
77 {
78 }
79 
80 //----------------------------------------------------------------------
83 //----------------------------------------------------------------------
85  (
86  CDataExchange * aDataExchange
87  )
88 {
89  CDialog::DoDataExchange( aDataExchange );
90  DDX_Text( aDataExchange, IDC_DASHCAM_NTFCTN_TIMESTAMP, mOriginationTime );
91  DDX_Text( aDataExchange, IDC_DASHCAM_NTFCTN_TYPE, mType );
92  DDX_Text( aDataExchange, IDC_DASHCAM_NTFCTN_LON, mLongitude );
93  DDX_Text( aDataExchange, IDC_DASHCAM_NTFCTN_LAT, mLatitude );
94  DDX_Text( aDataExchange, IDC_DASHCAM_NTFCTN_INCIDENT_FNAME, mIncidentFilename );
95 }
96 
97 //----------------------------------------------------------------------
99 //----------------------------------------------------------------------
101  (
102  time_type origination_time,
103  sc_position_type scposn,
104  uint8 ntfctn_type
105  )
106 {
107  TCHAR stringBuffer[200];
108  time_type localTime;
109  date_time_data_type localDateTime;
110  char localTimeString[13];
111 
112  UTIL_convert_UTC_to_local( &origination_time, &localTime );
113  UTIL_convert_seconds_to_time_type( &localTime, &localDateTime );
114  UTIL_format_time_string( &localDateTime, localTimeString, sizeof( localTimeString ) );
115 
116  MultiByteToWideChar( mCom.mClientCodepage, 0, localTimeString, -1, stringBuffer, 13 );
117  stringBuffer[13] = '\0';
118  mOriginationTime.Format( _T(" %s"), stringBuffer );
119 
120  switch( ntfctn_type )
121  {
123  {
124  mType = _T(" Incident");
125  break;
126  }
127  case DASHCAM_FCW_NTFCTN:
128  {
129  mType = _T(" Fwd Collision Warning");
130  break;
131  }
132  case DASHCAM_LDW_NTFCTN:
133  {
134  mType = _T(" Lane Departure Warning");
135  break;
136  }
137  default:
138  {
139  mType = _T(" Unrecognized" );
140  break;
141  }
142  }
143 
144  if( scposn.lat != INVALID_LAT )
145  {
146  double longitudeDegrees = UTIL_convert_semicircles_to_degrees( scposn.lon );
147  double latitudeDegrees = UTIL_convert_semicircles_to_degrees( scposn.lat );
148 
149  if( latitudeDegrees < 0 )
150  {
151  mLatitude.Format( _T( "%08.6f °S" ), latitudeDegrees * -1 );
152  }
153  else
154  {
155  mLatitude.Format( _T( "%08.6f °N" ), latitudeDegrees );
156  }
157 
158  if( longitudeDegrees < 0 )
159  {
160  mLongitude.Format( _T( "%08.6f °W" ), longitudeDegrees * -1 );
161  }
162  else
163  {
164  mLongitude.Format( _T( "%08.6f °E" ), longitudeDegrees );
165  }
166  }
167 }
168 #endif
#define IDC_DASHCAM_NTFCTN_TIMESTAMP
Definition: resource.h:560
virtual void DoDataExchange(CDataExchange *aDataExchange)
Perform dialog data exchange and validation.
Data type for Dashcam Notification Packet ID (0X160C) from client to server (request) ...
Definition: fmi.h:2337
#define IDC_DASHCAM_NTFCTN_INCIDENT_FNAME
Definition: resource.h:566
Data type for Dashcam Notification Packet ID (0X1606) from client to server (request) ...
Definition: fmi.h:2328
void UTIL_format_time_string(const date_time_data_type *aDateTime, char *aResultString, int aResultStringSize)
Converts a time structure (date_time_data_type) to a time string representation.
Definition: util.cpp:575
FmiApplicationLayer & mCom
Reference to the FMI communication controller.
void UTIL_convert_seconds_to_time_type(const time_type *aSeconds, date_time_data_type *aDateTime)
Converts from a Garmin time to a structure containing separate members for hour, minute, and second (time_type).
Definition: util.cpp:274
Date & time data type with separate fields for month, day, year, hour, minute, and second...
Definition: garmin_types.h:150
double UTIL_convert_semicircles_to_degrees(sint32 aSemicircles)
Converts a latitude/longitude from semicircles to degrees.
Definition: util.cpp:260
void init(time_type origination_time, sc_position_type scposn, uint8 ntfctn_type)
Initialize the field data.
sint32 lat
latitude in semicircles
Definition: garmin_types.h:126
#define IDC_DASHCAM_NTFCTN_TYPE
Definition: resource.h:180
codepage_type mClientCodepage
Code page used for encoding of text fields when communicating with the client.
virtual ~CDashcamNtfctnFromClient()
Destructor.
Serial communication controller for Garmin and FMI packets.
#define INVALID_LAT
placeholder for invalid latitude value
Definition: fmi.h:136
#define IDC_DASHCAM_NTFCTN_LON
Definition: resource.h:564
CDashcamNtfctnFromClient(CWnd *aParent, FmiApplicationLayer &aCom, const fmi_dashcam_ntfctn_req_data_type &aEvent)
Constructor.
#define IDD_DASHCAM_NTFCTN_FROM_CLIENT
Definition: resource.h:65
Indicates a latitude and longitude in semicircles.
Definition: garmin_types.h:124
unsigned char uint8
8-bit unsigned integer
Definition: garmin_types.h:62
#define IDC_DASHCAM_NTFCTN_LAT
Definition: resource.h:562
Modal pop up dialog displaying a client to server dashcam notification.
void UTIL_convert_UTC_to_local(const time_type *aUtcTime, time_type *aLocalTime)
Converts a time_type from UTC to local time.
Definition: util.cpp:526
sint32 lon
longitude in semicircles
Definition: garmin_types.h:127
uint32 time_type
Absolute time (number of seconds since 12/31/1989 12:00 am UTC)
Definition: garmin_types.h:97