Garmin Fleet Management Controller  2.19.0
CTxtMsgFromClient.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * MODULE NAME:
4 * CTxtMsgFromClient.cpp
5 *
6 * Copyright 2008-2009 by Garmin Ltd. or its subsidiaries.
7 *---------------------------------------------------------------------
8 * $NoKeywords$
9 *********************************************************************/
10 #include "stdafx.h"
11 #include "FmiLogParser.h"
12 #include "CFmiApplication.h"
13 #include "CTxtMsgFromClient.h"
14 #include "util.h"
15 
16 IMPLEMENT_DYNAMIC( CTxtMsgFromClient, CDialog )
17 
18 BEGIN_MESSAGE_MAP( CTxtMsgFromClient, CDialog )
19 END_MESSAGE_MAP()
20 
21 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
27 CTxtMsgFromClient::CTxtMsgFromClient
28  (
29  CWnd * aParent,
30  FmiApplicationLayer & aCom,
31  const text_msg_from_client_event_type * aEvent
32  )
33  : CDialog( IDD_TXT_MSG_FROM_CLIENT, aParent )
34  , mTextMessageEvent( *aEvent )
35  , mCom( aCom )
36  , mOriginationTime( _T("") )
37  , mMessageText( _T("") )
38  , mMessageId( _T("") )
39 #if( FMI_SUPPORT_A607 )
40  , mLinkId( _T("") )
41 #endif
42 {
43 }
44 
45 //----------------------------------------------------------------------
47 //----------------------------------------------------------------------
49 {
50 }
51 
52 //----------------------------------------------------------------------
55 //----------------------------------------------------------------------
57  (
58  CDataExchange * aDataExchange
59  )
60 {
61  CDialog::DoDataExchange( aDataExchange );
62  DDX_Text( aDataExchange, IDC_CLIENTMSG_TXT_TIME, mOriginationTime );
63  DDX_Text( aDataExchange, IDC_CLIENTMSG_TXT_MESSAGE, mMessageText );
64  DDX_Text( aDataExchange, IDC_CLIENTMSG_TXT_ID, mMessageId );
65 #if( FMI_SUPPORT_A607 )
66  DDX_Text( aDataExchange, IDC_CLIENTMSG_TXT_LINK_ID, mLinkId );
67  DDX_Text( aDataExchange, IDC_CLIENTMSG_TXT_LON, mLongitude );
68  DDX_Text( aDataExchange, IDC_CLIENTMSG_TXT_LAT, mLatitude );
69 #endif
70 }
71 
72 //----------------------------------------------------------------------
80 //----------------------------------------------------------------------
82 {
83  TCHAR stringBuffer[200];
84  time_type localTime;
85  date_time_data_type localDateTime;
86  char localTimeString[13];
87 
88  CDialog::OnInitDialog();
89 
91  UTIL_convert_seconds_to_time_type( &localTime, &localDateTime );
92  UTIL_format_time_string( &localDateTime, localTimeString, sizeof( localTimeString ) );
93 
94  MultiByteToWideChar( mCom.mClientCodepage, 0, localTimeString, -1, stringBuffer, 13 );
95  stringBuffer[13] = '\0';
96  mOriginationTime.Format( _T(" %s"), stringBuffer );
97 
98  MultiByteToWideChar( mCom.mClientCodepage, 0, mTextMessageEvent.message_text, -1, stringBuffer, 200 );
99  stringBuffer[199] = '\0';
100  mMessageText.Format( _T(" %s"), stringBuffer );
101  mMessageId.Format( _T(" %d"), mTextMessageEvent.message_id );
102 #if( FMI_SUPPORT_A607 )
104  {
107 
108  if( latitudeDegrees < 0 )
109  {
110  mLatitude.Format( _T( "%08.6f °S" ), latitudeDegrees * -1 );
111  }
112  else
113  {
114  mLatitude.Format( _T( "%08.6f °N" ), latitudeDegrees );
115  }
116 
117  if( longitudeDegrees < 0 )
118  {
119  mLongitude.Format( _T( "%08.6f °W" ), longitudeDegrees * -1 );
120  }
121  else
122  {
123  mLongitude.Format( _T( "%08.6f °E" ), longitudeDegrees );
124  }
125  }
126 
128 #endif
129 
130  UpdateData( FALSE );
131 
132  return TRUE;
133 } /* OnInitDialog() */
#define IDC_CLIENTMSG_TXT_LAT
Definition: resource.h:182
sint32 longitude
Longitude of the device sending the message.
Definition: EventId.h:156
FmiApplicationLayer & mCom
Reference to the FMI communication controller.
CString mLatitude
String representation of device latitude.
CString mMessageText
String representation of the text message.
Modal pop up dialog displaying a client to server open text message.
sint32 latitude
Latitude of the device sending the message.
Definition: EventId.h:155
#define IDC_CLIENTMSG_TXT_MESSAGE
Definition: resource.h:177
uint32 message_id
The message ID.
Definition: EventId.h:150
CString mMessageId
String representation of the message ID.
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
#define IDC_CLIENTMSG_TXT_LON
Definition: resource.h:183
#define FALSE
Definition: garmin_types.h:46
virtual void DoDataExchange(CDataExchange *aDataExchange)
Perform dialog data exchange and validation.
#define IDC_CLIENTMSG_TXT_TIME
Definition: resource.h:178
#define TRUE
Definition: garmin_types.h:45
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
CString toCString(codepage_type aCodePage) const
CString representation of the message ID.
Definition: MessageId.cpp:167
text_msg_from_client_event_type mTextMessageEvent
The text message event that caused this dialog to be displayed.
codepage_type mClientCodepage
Code page used for encoding of text fields when communicating with the client.
BOOL OnInitDialog()
Initialize the dialog.
CString mLongitude
String representation of device longitude.
Serial communication controller for Garmin and FMI packets.
#define IDC_CLIENTMSG_TXT_LINK_ID
Definition: resource.h:181
#define INVALID_LAT
placeholder for invalid latitude value
Definition: fmi.h:136
#define IDD_TXT_MSG_FROM_CLIENT
Definition: resource.h:40
time_type origination_time
Origination time on the client.
Definition: EventId.h:151
char message_text[200]
Message sent by the client.
Definition: EventId.h:152
MessageId link_id
ID of server-to-client message that this is a reply for.
Definition: EventId.h:154
CString mOriginationTime
String representation of the origination time on the client.
Structure containing details for a client to server text message.
Definition: EventId.h:148
CString mLinkId
String representation of the link ID (corresponding server to client message ID)
virtual ~CTxtMsgFromClient()
Destructor.
#define IDC_CLIENTMSG_TXT_ID
Definition: resource.h:175
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
uint32 time_type
Absolute time (number of seconds since 12/31/1989 12:00 am UTC)
Definition: garmin_types.h:97