15 #if( FMI_SUPPORT_A618 ) 16 #define LONG_STOP_TEMP_FILE _T( "long_stop_temp.bin" ) 22 ON_BN_CLICKED( IDOK, OnBnClickedOk )
27 #if( FMI_SUPPORT_A602 ) 30 #if( FMI_SUPPORT_A603 ) 34 #if( FMI_SUPPORT_A618 ) 45 CStopNewDlg::CStopNewDlg
52 , mLatitudeStr( _T("") )
53 , mLongitudeStr( _T("") )
54 , mMessageStr( _T("") )
55 , mCompressLongStop(
TRUE )
57 #if( FMI_SUPPORT_A618 ) 58 mStopProtocol = STOP_PROTOCOL_A618;
59 #elif( FMI_SUPPORT_A603 ) 60 mStopProtocol = STOP_PROTOCOL_A603;
61 #elif( FMI_SUPPORT_A602 ) 62 mStopProtocol = STOP_PROTOCOL_A602;
64 mStopProtocol = STOP_PROTOCOL_LEGACY;
81 CDataExchange * aDataExchange
84 CDialog::DoDataExchange( aDataExchange );
86 DDX_Text( aDataExchange, IDC_STOPNEW_EDIT_LAT,
mLatitudeStr );
87 DDX_Text( aDataExchange, IDC_STOPNEW_EDIT_LON,
mLongitudeStr );
88 DDX_Text( aDataExchange, IDC_STOPNEW_EDIT_NAME,
mMessageStr );
89 DDX_Radio( aDataExchange, IDC_STOPNEW_RDO_A618,
mStopProtocol );
90 #if( FMI_SUPPORT_A603 ) 105 CDialog::OnInitDialog();
106 #if( !FMI_SUPPORT_A618 ) 107 CButton * rdo618 = (CButton *)GetDlgItem( IDC_STOPNEW_RDO_A618 );
108 rdo618->SetCheck( BST_UNCHECKED );
109 rdo618->EnableWindow(
FALSE );
113 #if( FMI_SUPPORT_A603 ) 116 #if( !FMI_SUPPORT_A603 ) 117 CButton * rdo603 = (CButton *)GetDlgItem( IDC_STOPNEW_RDO_A603 );
118 rdo603->SetCheck( BST_UNCHECKED );
119 rdo603->EnableWindow(
FALSE );
122 #if( !FMI_SUPPORT_A602 ) 124 rdo602->SetCheck( BST_UNCHECKED );
125 rdo602->EnableWindow(
FALSE );
127 #if( !FMI_SUPPORT_LEGACY ) 128 CButton * rdoLegacy = (CButton *)GetDlgItem( IDC_STOPNEW_RDO_LEGACY );
129 rdoLegacy->SetCheck( BST_UNCHECKED );
130 rdoLegacy->EnableWindow(
FALSE );
144 bool formIsValid =
true;
147 char stopIdString[11];
148 memset( stopIdString, 0,
sizeof( stopIdString ) );
168 #if( FMI_SUPPORT_A603 ) 173 #if( FMI_SUPPORT_A618 ) 181 BOOL stopIdEnabled =
FALSE;
183 #if( FMI_SUPPORT_A618 ) 187 stopIdEnabled =
TRUE;
191 #if( FMI_SUPPORT_A603 ) 194 stopIdEnabled =
TRUE;
196 if( 0 != WideCharToMultiByte( CP_ACP, 0,
mStopId.GetBuffer(),
mStopId.GetLength(), stopIdString,
sizeof( stopIdString ), NULL, NULL ) )
214 GetDlgItem( IDOK )->EnableWindow( formIsValid );
228 #if( FMI_SUPPORT_A603 ) 237 message[1999] =
'\0';
245 #if( FMI_SUPPORT_A618 ) 250 stopId = _tstoi(
mStopId.GetBuffer() );
255 MessageBox( _T(
"Unable to open temp file for building long stop payload" ), _T(
"Send Stop" ), MB_ICONWARNING | MB_OK );
262 tmpFile.Write( (
const void* )
"STOP", 4 );
263 tmpFile.Write( (
const void* ) &ver,
sizeof( ver ) );
264 tmpFile.Write( (
const void* ) &origination_time,
sizeof( origination_time ) );
265 tmpFile.Write( (
const void* ) &stopId,
sizeof( stopId ) );
266 tmpFile.Write( (
const void* ) message, ( UINT ) strlen( message ) + 1 );
267 tmpFile.Write( (
const void* ) &pos.lat,
sizeof( pos.lat ) );
268 tmpFile.Write( (
const void* ) &pos.lon,
sizeof( pos.lon ) );
272 char file[MAX_PATH+1];
274 file[MAX_PATH] =
'\0';
276 char versionString[35];
280 memset( version, 0,
sizeof( version ) );
281 WideCharToMultiByte(
mCom.
mClientCodepage, 0, _T(
"1" ), -1, versionString, 34, NULL, NULL );
282 versionString[34] =
'\0';
283 versionLength = (
uint8)
minval( 16, strlen( versionString ) );
284 memmove( version, versionString, versionLength );
289 stopListItem.
setId( stopId );
297 #if( FMI_SUPPORT_A603 ) 302 stopId = _tstoi(
mStopId.GetBuffer() );
306 #if( FMI_SUPPORT_A602 ) 311 #if( FMI_SUPPORT_LEGACY ) 313 mCom.sendLegacyStop( lat, lon, message );
#define IDC_STOPNEW_RDO_A603
sint32 UTIL_convert_degrees_to_semicircles(double aDegrees)
Converts a latitude/longitude from degrees to semicircles.
afx_msg void OnFormChanged()
Change handler for all radio buttons and edit boxes on this dialog.
#define IDC_STOPNEW_RDO_LEGACY
void setId(const key_type &aId)
Set item's ID.
#define IDC_STOPNEW_EDIT_NAME
BOOL mCompressLongStop
Flag to determine if A618 stop "file" should be compressed.
BOOL OnInitDialog()
Initialize the dialog.
afx_msg void OnBnClickedOk()
Click handler for the OK button.
#define IDC_STOPNEW_EDIT_STOPID
void put(T &aValue)
Add (or replace) an item in the map.
CString mMessageStr
Text in the Destination Name/Message edit box.
#define LONG_STOP_TEMP_FILE
int mStopProtocol
Index of the selected mStopProtocol.
bool UTIL_data_is_uint32(const char *aData)
Determine whether an array of characters consists only of numeric, and that the value when converted ...
CString mLatitudeStr
Text in the Latitude edit box.
virtual void DoDataExchange(CDataExchange *aDataExchange)
Perform dialog data exchange and validation.
#define IDC_STOPNEW_EDIT_LAT
FileBackedMap< StopListItem > mA603Stops
Map of unique ID to stop details for all A603 stops on the client.
void setValid(BOOL aValid=TRUE)
Set this item as valid.
Data structure to hold details of an A603 stop that the server needs to keep.
#define IDC_STOPNEW_LBL_STOPID
void sendA602Stop(double aLatitude, double aLongitude, char *aStopName)
Initiates the A602 stop protocol.
Modal dialog allowing the user to send a new stop to the client.
sint32 lat
latitude in semicircles
#define IDC_STOPNEW_RDO_A618
CString mStopId
Text in the Stop ID edit box.
void setCurrentName(CString aName)
Set the current name of the stop.
#define minval(_x, _y)
The smaller of _x and _y.
codepage_type mClientCodepage
Code page used for encoding of text fields when communicating with the client.
#define IDC_COMPRESS_LONG_STOP
Serial communication controller for Garmin and FMI packets.
uint32 getNextStopId()
Find an available stop ID.
#define IDC_STOPNEW_EDIT_LON
virtual ~CStopNewDlg()
Destructor.
#define IDC_STOPNEW_RDO_A602
void sendA603Stop(double aLatitude, double aLongitude, char *aStopName, uint32 aStopId)
Initiates the A603 stop protocol.
FmiApplicationLayer & mCom
Reference to the FMI communication controller.
Indicates a latitude and longitude in semicircles.
void setStopStatus(stop_status_status_type aStatus)
Set the stop status.
unsigned char uint8
8-bit unsigned integer
void sendFile(char *aFilename, uint8 aVersionLength, uint8 *aVersion, uint8 aFileType, BOOL gzipIt=FALSE)
Start a file transfer protocol.
time_type UTIL_get_current_garmin_time()
Get the current server time in Garmin format.
CString mLongitudeStr
Text in the Longitude edit box.
unsigned long int uint32
32-bit unsigned integer
uint32 time_type
Absolute time (number of seconds since 12/31/1989 12:00 am UTC)