Garmin Fleet Management Controller  2.19.0
util.h
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * HEADER NAME:
4 * util.h
5 *
6 * Copyright 2008-2011 by Garmin Ltd. or its subsidiaries.
7 *---------------------------------------------------------------------
8 * $NoKeywords$
9 *********************************************************************/
10 #ifndef _UTIL_H_
11 #define _UTIL_H_
12 
13 #include "garmin_types.h"
14 
16 #define PI ( 3.14159265358979323846 )
17 
19 #define INV_DATE_TIME ( 0xFFFFFFFF )
20 
22 #define BASE_YEAR ( 1990 )
23 
25 #define DAYS_IN_4_YEARS ( 365 * 4 + 1 )
26 
28 #define DAYS_IN_1_YEAR ( 365 )
29 
31 #define DAYS_IN_1_WEEK ( 7 )
32 
34 #define SECONDS_PER_WEEK ( 60 * 60 * 24 * 7 )
35 
37 #define SECONDS_PER_DAY ( 60 * 60 * 24 )
38 
40 #define SECONDS_PER_HOUR ( 60 * 60 )
41 
43 #define SECONDS_PER_MINUTE ( 60 )
44 
46 #define FEBRUARY ( 2 )
47 #define MARCH ( 3 )
49 #define DECEMBER ( 12 )
51 
53  (
54  double aDegrees
55  );
56 
58  (
59  double aDegrees
60  );
61 
63  (
64  double aRadians
65  );
66 
68  (
69  sint32 aSemicircles
70  );
71 
73  (
74  const char * aHexString,
75  uint8 * aBinaryData,
76  uint16 aMaxBytes
77  );
78 
80  (
81  const uint8 * aData,
82  char * aOutput,
83  uint8 aNumBytes
84  );
85 
87  (
88  const char * aHexString,
89  uint16 * aBinaryData,
90  uint8 aMaxWords
91  );
92 
94  (
95  const char * aData,
96  int aLength
97  );
98 
100  (
101  const char * aData
102  );
103 
105  (
106  const date_time_data_type * aDateTime,
107  char * aResultString,
108  int aResultStringSize
109  );
110 
112  (
113  const date_time_data_type * aDateTime,
114  char * aResultString,
115  int aResultStringSize
116  );
117 
119  (
120  const time_type * aUtcTime,
121  time_type * aLocalTime
122  );
123 
125  (
126  const time_type * aLocalTime,
127  time_type * aUtcTime
128  );
129 
131  (
132  void
133  );
134 
136  (
137  tm aTimeTm
138  );
139 
141  (
142  const gps_time_type * aGpsTime,
143  time_type * aSeconds
144  );
145 
147  (
148  const date_time_data_type * aDateTime,
149  time_type * aSeconds
150  );
151 
153  (
154  const time_type * aSeconds,
155  date_time_data_type * aDateTime
156  );
157 
159  (
160  const time_type * aSeconds,
161  date_time_data_type * aDateTime
162  );
163 
165  (
166  const date_time_data_type * aDateTime,
167  time_type * aSeconds
168  );
169 
170 double UTIL_calc_2d_speed
171  (
172  float32 aNorthVelocity,
173  float32 aEastVelocity
174  );
175 
177  (
178  float32 aNorthVelocity,
179  float32 aEastVelocity,
180  char * aCardinalDirection,
181  int aCardinalDirectionSize
182  );
183 
184 CString unzip
185  (
186  char * original
187  );
188 
189 BOOL unzip
190  (
191  char * original,
192  LPCTSTR destination
193  );
194 
195 void write
196  (
197  CFile * catalog,
198  char * text
199  );
200 
201 void write
202  (
203  CFile * catalog,
204  LPCTSTR wText
205  );
206 
207 void write
208  (
209  CFile * catalog,
210  LPCTSTR wText,
211  int maxLength
212  );
213 
214 
215 #endif /* _UTIL_H_ */
double UTIL_calc_2d_speed(float32 aNorthVelocity, float32 aEastVelocity)
Determine the two-dimensional velocity.
Definition: util.cpp:674
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
void UTIL_calc_2d_direction(float32 aNorthVelocity, float32 aEastVelocity, char *aCardinalDirection, int aCardinalDirectionSize)
Determine the nearest cardinal aCardinalDirection.
Definition: util.cpp:692
CString unzip(char *original)
This function will uncompress a file into a new file.
Definition: util.cpp:741
sint32 UTIL_convert_degrees_to_semicircles(double aDegrees)
Converts a latitude/longitude from degrees to semicircles.
Definition: util.cpp:204
void UTIL_convert_time_type_to_seconds(const date_time_data_type *aDateTime, time_type *aSeconds)
Converts a time_type to seconds since midnight.
Definition: util.cpp:295
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
void UTIL_format_date_string(const date_time_data_type *aDateTime, char *aResultString, int aResultStringSize)
Format a date as a string.
Definition: util.cpp:657
double UTIL_convert_radians_to_degrees(double aRadians)
Converts a latitude/longitude from radians to degrees.
Definition: util.cpp:247
bool UTIL_data_is_printable(const char *aData, int aLength)
Determine whether an array of characters consists only of printable ASCII.
Definition: util.cpp:471
boolean UTIL_convert_date_time_to_seconds(const date_time_data_type *aDateTime, time_type *aSeconds)
Converts a date from from a structure to a Garmin date.
Definition: util.cpp:114
double UTIL_convert_semicircles_to_degrees(sint32 aSemicircles)
Converts a latitude/longitude from semicircles to degrees.
Definition: util.cpp:260
Date & time data type with separate fields for month, day, year, hour, minute, and second...
Definition: garmin_types.h:150
void UTIL_convert_seconds_to_date_type(const time_type *aSeconds, date_time_data_type *aDateTime)
Converts a Garmin date to a structure containing year, month, and day.
Definition: util.cpp:39
bool UTIL_data_is_uint32(const char *aData)
Determine whether an array of characters consists only of numeric, and that the value when converted ...
Definition: util.cpp:495
float float32
32-bit IEEE-format floating point data. (1 sign bit, 8 exponent bits, and 23 mantissa bits) ...
Definition: garmin_types.h:70
signed long int sint32
32-bit signed integer
Definition: garmin_types.h:59
unsigned short int uint16
16-bit unsigned integer
Definition: garmin_types.h:64
void write(CFile *catalog, char *text)
This function is a helper for writing text to a file.
Definition: util.cpp:799
time_type UTIL_get_current_garmin_time(void)
Get the current server time in Garmin format.
Definition: util.cpp:603
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
uint8 UTIL_hex_to_uint16(const char *aHexString, uint16 *aBinaryData, uint8 aMaxWords)
Converts a null-terminated string in hexadecimal format to an array of uint16 numbers, assuming natural byte ordering in the hex. No prefix should be present in the hex string.
Definition: util.cpp:411
unsigned char uint8
8-bit unsigned integer
Definition: garmin_types.h:62
uint16 UTIL_hex_to_uint8(const char *aHexString, uint8 *aBinaryData, uint16 aMaxBytes)
Convert a hexadecimal ASCII string to an array of uint8.
Definition: util.cpp:323
void UTIL_convert_gps_time_to_seconds(const gps_time_type *aGpsTime, time_type *aSeconds)
Converts from gps_time to Garmin time.
Definition: util.cpp:233
time_type UTIL_get_garmin_time(tm aTimeTm)
Get the current server time in Garmin format.
Definition: util.cpp:619
uint32 time_type
Absolute time (number of seconds since 12/31/1989 12:00 am UTC)
Definition: garmin_types.h:97
void UTIL_convert_local_to_UTC(const time_type *aLocalTime, time_type *aUtcTime)
Converts a time_type from local to UTC time.
Definition: util.cpp:549
void UTIL_uint8_to_hex(const uint8 *aData, char *aOutput, uint8 aNumBytes)
Convert from binary to a hexadecimal string.
Definition: util.cpp:376
double UTIL_convert_degrees_to_radians(double aDegrees)
Converts a latitude/longitude from degrees to radians.
Definition: util.cpp:187
Encapsulates the fields of a GPS time for conversion.
Definition: garmin_types.h:143