diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-10-20 07:07:32 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-10-20 07:07:32 +0000 |
commit | ade15646ce22ddcff9d38d1f29c1b5b2c7248778 (patch) | |
tree | bee4caa9431a899b31bc060be32e6ff08d0fd1b0 /navit/vehicle | |
parent | 919e61244c897a10c9327842eb68948c482951c7 (diff) | |
download | navit-ade15646ce22ddcff9d38d1f29c1b5b2c7248778.tar.gz |
Add:Core:New vehicle type null
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2678 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/vehicle')
-rw-r--r-- | navit/vehicle/Makefile.am | 3 | ||||
-rw-r--r-- | navit/vehicle/null/Makefile.am | 5 | ||||
-rw-r--r-- | navit/vehicle/null/vehicle_null.c | 168 |
3 files changed, 176 insertions, 0 deletions
diff --git a/navit/vehicle/Makefile.am b/navit/vehicle/Makefile.am index cfcd3becb..f9f803ca4 100644 --- a/navit/vehicle/Makefile.am +++ b/navit/vehicle/Makefile.am @@ -17,6 +17,9 @@ endif if VEHICLE_GYPSY SUBDIRS += gypsy endif +if VEHICLE_NULL + SUBDIRS += null +endif if VEHICLE_WINCE SUBDIRS += wince endif diff --git a/navit/vehicle/null/Makefile.am b/navit/vehicle/null/Makefile.am new file mode 100644 index 000000000..5141637e2 --- /dev/null +++ b/navit/vehicle/null/Makefile.am @@ -0,0 +1,5 @@ +include $(top_srcdir)/Makefile.inc +AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=vehicle_null +modulevehicle_LTLIBRARIES = libvehicle_null.la +libvehicle_null_la_SOURCES = vehicle_null.c +libvehicle_null_la_LDFLAGS = -module -avoid-version @MODULE_LDFLAGS@ diff --git a/navit/vehicle/null/vehicle_null.c b/navit/vehicle/null/vehicle_null.c new file mode 100644 index 000000000..a0b7fafb6 --- /dev/null +++ b/navit/vehicle/null/vehicle_null.c @@ -0,0 +1,168 @@ +/** @file vehicle_null.c + * @brief null uses dbus signals + * + * Navit, a modular navigation system. + * Copyright (C) 2005-2008 Navit Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * @Author Tim Niemeyer <reddog@mastersword.de> + * @date 2008-2009 + */ + +#include <config.h> +#include <string.h> +#include <glib.h> +#include <math.h> +#include <time.h> +#include "debug.h" +#include "callback.h" +#include "plugin.h" +#include "coord.h" +#include "item.h" +#include "null.h" +#include "vehicle.h" + +struct vehicle_priv { + struct callback_list *cbl; + struct coord_geo geo; + double speed; + double direction; + double height; + double radius; + int fix_type; + time_t fix_time; + char fixiso8601[128]; + int sats; + int sats_used; + int have_coords; + struct attr ** attrs; +}; + +/** + * @brief Free the null_vehicle + * + * @param priv + * @returns nothing + */ +static void +vehicle_null_destroy(struct vehicle_priv *priv) +{ + dbg(0,"enter\n"); + g_free(priv); +} + +/** + * @brief Provide the outside with information + * + * @param priv + * @param type TODO: What can this be? + * @param attr + * @returns true/false + */ +static int +vehicle_null_position_attr_get(struct vehicle_priv *priv, + enum attr_type type, struct attr *attr) +{ + dbg(1,"enter %s\n",attr_to_name(type)); + switch (type) { +#if 0 + case attr_position_fix_type: + attr->u.num = priv->fix_type; + break; +#endif + case attr_position_height: + attr->u.numd = &priv->height; + break; + case attr_position_speed: + attr->u.numd = &priv->speed; + break; + case attr_position_direction: + attr->u.numd = &priv->direction; + break; + case attr_position_radius: + attr->u.numd = &priv->radius; + break; + +#if 0 + case attr_position_qual: + attr->u.num = priv->sats; + break; + case attr_position_sats_used: + attr->u.num = priv->sats_used; + break; +#endif + case attr_position_coord_geo: + attr->u.coord_geo = &priv->geo; + if (!priv->have_coords) + return 0; + break; + case attr_position_time_iso8601: + attr->u.str=priv->fixiso8601; + break; + default: + return 0; + } + dbg(1,"ok\n"); + attr->type = type; + return 1; +} + +int vehicle_null_set_attr(struct vehicle_priv *priv, struct attr *attr, struct attr **attrs) +{ + return 1; +} + + +struct vehicle_methods vehicle_null_methods = { + vehicle_null_destroy, + vehicle_null_position_attr_get, + vehicle_null_set_attr, +}; + +/** + * @brief Create null_vehicle + * + * @param meth + * @param cbl + * @param attrs + * @returns vehicle_priv + */ +static struct vehicle_priv * +vehicle_null_new_null(struct vehicle_methods *meth, + struct callback_list *cbl, + struct attr **attrs) +{ + struct vehicle_priv *ret; + + dbg(0, "enter\n"); + ret = g_new0(struct vehicle_priv, 1); + ret->cbl = cbl; + *meth = vehicle_null_methods; + dbg(0, "return\n"); + return ret; +} + +/** + * @brief register vehicle_null + * + * @returns nothing + */ +void +plugin_init(void) +{ + dbg(0, "enter\n"); + plugin_register_vehicle_type("null", vehicle_null_new_null); +} |