From: geoghegan Date: Sun, 24 Oct 2010 18:18:22 +0000 (+0000) Subject: Add:Core: Adds more logging parameters as per #611 | Thanks mvglasow X-Git-Tag: navit-0.5.0.5194svn~1578 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c261ff4edecac3ce1b8868220ace617d74bf5d84;p=profile%2Fivi%2Fnavit.git Add:Core: Adds more logging parameters as per #611 | Thanks mvglasow git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3614 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- diff --git a/navit/navit/attr.c b/navit/navit/attr.c index 80a5ae0..10c59e5 100644 --- a/navit/navit/attr.c +++ b/navit/navit/attr.c @@ -666,6 +666,14 @@ attr_from_line(char *line, char *name, int *pos, char *val_ret, char *name_ret) return 0; } +/** + * Check if an enumeration of attribute types contains a specific attribute. + * + * @param types Pointer to the attr_type enumeration to be searched + * @param type The attr_type to be searched for + * + * @return 1 if the attribute type was found, 0 if it was not found or if a null pointer was passed as types + */ int attr_types_contains(enum attr_type *types, enum attr_type type) { @@ -677,6 +685,16 @@ attr_types_contains(enum attr_type *types, enum attr_type type) return 0; } +/** + * Check if an enumeration of attribute types contains a specific attribute. + * It is different from attr_types_contains in that it returns a caller-defined value if the pointer to the enumeration is NULL. + * + * @param types Pointer to the attr_type enumeration to be searched + * @param type The attr_type to be searched for + * @param deflt The default value to return if types is NULL. + * + * @return 1 if the attribute type was found, 0 if it was not found, the value of the deflt argument if types is NULL. + */ int attr_types_contains_default(enum attr_type *types, enum attr_type type, int deflt) { diff --git a/navit/navit/vehicle.c b/navit/navit/vehicle.c index d25c748..54d890b 100644 --- a/navit/navit/vehicle.c +++ b/navit/navit/vehicle.c @@ -173,9 +173,9 @@ vehicle_attr_iter_destroy(struct attr_iter *iter) /** * Generic get function * - * @param this_ A vehicle + * @param this_ Pointer to a vehicle structure * @param type The attribute type to look for - * @param attr A struct attr to store the attribute + * @param attr Pointer to an attr structure to store the attribute * @param iter A vehicle attr_iter */ int @@ -197,9 +197,9 @@ vehicle_get_attr(struct vehicle *this_, enum attr_type type, struct attr *attr, /** * Generic set function * - * @param this_ A vehicle - * @param attr - * @param attrs + * @param this_ Pointer to a vehicle structure + * @param attr Pointer to an attr structure for the attribute to be set + * @return nonzero on success, zero on failure */ int vehicle_set_attr(struct vehicle *this_, struct attr *attr) @@ -405,6 +405,12 @@ vehicle_draw_do(struct vehicle *this_, int lazy) } } +/** + * Writes to an NMEA log. + * + * @param this_ Pointer to the vehicle structure of the data source + * @param log Pointer to a log structure for the log file + */ static void vehicle_log_nmea(struct vehicle *this_, struct log *log) { @@ -449,6 +455,12 @@ vehicle_log_gpx_add_tag(char *tag, char **logstr) g_free(end); } +/** + * Writes to a GPX log. + * + * @param this_ Pointer to the vehicle structure of the data source + * @param log Pointer to a log structure for the log file + */ static void vehicle_log_gpx(struct vehicle *this_, struct log *log) { @@ -484,6 +496,22 @@ vehicle_log_gpx(struct vehicle *this_, struct log *log) g_free(this_->gpx_desc); this_->gpx_desc = NULL; } + if (attr_types_contains_default(attr_types, attr_position_height,0) && this_->meth.position_attr_get(this_->priv, attr_position_height, &attr)) + logstr=g_strconcat_printf(logstr,"\t%.6f\n",*attr.u.numd); + // magnetic variation in degrees; we might use position_magnetic_direction and position_direction to figure it out + // Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message (field 11, which vehicle_wince.c ignores) + // GPS name (arbitrary) + // comment + // Source of data + // Link to additional information (URL) + // Text of GPS symbol name + // Type (classification) + // Type of GPS fix {'none'|'2d'|'3d'|'dgps'|'pps'}, leave out if unknown. Similar to position_fix_type but more detailed. + if (attr_types_contains_default(attr_types, attr_position_sats_used,0) && this_->meth.position_attr_get(this_->priv, attr_position_sats_used, &attr)) + logstr=g_strconcat_printf(logstr,"\t%d\n",attr.u.num); + if (attr_types_contains_default(attr_types, attr_position_hdop,0) && this_->meth.position_attr_get(this_->priv, attr_position_hdop, &attr)) + logstr=g_strconcat_printf(logstr,"\t%.6f\n",*attr.u.numd); + // , Vertical and position dilution of precision, no corresponding attribute if (attr_types_contains_default(attr_types, attr_position_direction,0) && this_->meth.position_attr_get(this_->priv, attr_position_direction, &attr)) logstr=g_strconcat_printf(logstr,"\t%.1f\n",*attr.u.numd); if (attr_types_contains_default(attr_types, attr_position_speed, 0) && this_->meth.position_attr_get(this_->priv, attr_position_speed, &attr)) @@ -505,6 +533,12 @@ vehicle_log_gpx(struct vehicle *this_, struct log *log) g_free(logstr); } +/** + * Writes to a text log. + * + * @param this_ Pointer to the vehicle structure of the data source + * @param log Pointer to a log structure for the log file + */ static void vehicle_log_textfile(struct vehicle *this_, struct log *log) { @@ -523,6 +557,12 @@ vehicle_log_textfile(struct vehicle *this_, struct log *log) log_write(log, logstr, strlen(logstr), 0); } +/** + * Writes to a binary log. + * + * @param this_ Pointer to the vehicle structure of the data source + * @param log Pointer to a log structure for the log file + */ static void vehicle_log_binfile(struct vehicle *this_, struct log *log) { @@ -577,6 +617,12 @@ vehicle_log_binfile(struct vehicle *this_, struct log *log) } } +/** + * Register a new log to receive data. + * + * @param this_ Pointer to the vehicle structure of the data source + * @param log Pointer to a log structure for the log file + */ static int vehicle_add_log(struct vehicle *this_, struct log *log) {