Add:Core:New vehicle type null
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 20 Oct 2009 07:07:32 +0000 (07:07 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 20 Oct 2009 07:07:32 +0000 (07:07 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@2678 ffa7fe5e-494d-0410-b361-a75ebd5db220

configure.in
navit/vehicle/Makefile.am
navit/vehicle/null/Makefile.am [new file with mode: 0644]
navit/vehicle/null/vehicle_null.c [new file with mode: 0644]

index 1c74170..e94565d 100644 (file)
@@ -55,6 +55,7 @@ vehicle_demo=yes; vehicle_demo_reason=default
 vehicle_file=yes; vehicle_file_reason=default
 vehicle_gpsd=yes; vehicle_gpsd_reason=default
 vehicle_gypsy=yes; vehicle_gypsy_reason=default
+vehicle_null=no; vehicle_null_reason=default
 vehicle_wince=no; vehicle_wince_reason=default
 vehicle_iphone=no; vehicle_iphone_reason=default
 vehicle_android=no; vehicle_android_reason=default
@@ -758,6 +759,9 @@ fi
 AC_SUBST(GYPSY_CFLAGS)
 AC_SUBST(GYPSY_LIBS)
 AM_CONDITIONAL(VEHICLE_GYPSY, test "x${vehicle_gypsy}" = "xyes")
+# null
+AC_ARG_ENABLE(vehicle-null, [  --enable-vehicle-null             enable vehicle type null], vehicle_null=$enableval;vehicle_null_reason="configure parameter")
+AM_CONDITIONAL(VEHICLE_NULL, test "x${vehicle_null}" = "xyes")
 # wince
 AC_ARG_ENABLE(vehicle-wince, [  --disable-vehicle-wince             disable vehicle type wince], vehicle_wince=$enableval;vehicle_wince_reason="configure parameter")
 AM_CONDITIONAL(VEHICLE_WINCE, test "x${vehicle_wince}" = "xyes")
@@ -829,6 +833,7 @@ navit/vehicle/android/Makefile
 navit/vehicle/file/Makefile
 navit/vehicle/gpsd/Makefile
 navit/vehicle/gypsy/Makefile
+navit/vehicle/null/Makefile
 navit/vehicle/demo/Makefile
 navit/vehicle/wince/Makefile
 navit/vehicle/iphone/Makefile
@@ -926,6 +931,7 @@ echo "  demo:              $vehicle_demo ($vehicle_demo_reason)"
 echo "  file:              $vehicle_file ($vehicle_file_reason)"
 echo "  gpsd:              $vehicle_gpsd ($vehicle_gpsd_reason)"
 echo "  gypsy:             $vehicle_gypsy ($vehicle_gypsy_reason)"
+echo "  null:              $vehicle_null ($vehicle_null_reason)"
 echo "  wince:             $vehicle_wince ($vehicle_wince_reason)"
 echo "  iphone:            $vehicle_iphone ($vehicle_iphone_reason)"
 
index cfcd3be..f9f803c 100644 (file)
@@ -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 (file)
index 0000000..5141637
--- /dev/null
@@ -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 (file)
index 0000000..a0b7faf
--- /dev/null
@@ -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);
+}