diff options
-rwxr-xr-x | CMakeLists.txt | 1 | ||||
-rw-r--r-- | navit/traffic.h | 2 | ||||
-rw-r--r-- | navit/traffic/dummy/CMakeLists.txt | 1 | ||||
-rw-r--r-- | navit/traffic/dummy/traffic_dummy.c | 80 |
4 files changed, 82 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 763f75bed..70c833539 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -499,6 +499,7 @@ add_module(plugin/j1850 "Default" FALSE) add_module(speech/android "Default" FALSE) add_module(speech/espeak "Default" FALSE) add_module(speech/iphone "Default" FALSE) +add_module(traffic/dummy "Default" TRUE) add_module(vehicle/android "Default" FALSE) add_module(vehicle/iphone "Default" FALSE) add_module(vehicle/wince "Default" FALSE) diff --git a/navit/traffic.h b/navit/traffic.h index e664c1046..c7ec0c7df 100644 --- a/navit/traffic.h +++ b/navit/traffic.h @@ -702,8 +702,6 @@ struct traffic_event * traffic_message_get_event(struct traffic_message * this_, // TODO function to report traffic message -// TODO plugin functions - /* end of prototypes */ #ifdef __cplusplus } diff --git a/navit/traffic/dummy/CMakeLists.txt b/navit/traffic/dummy/CMakeLists.txt new file mode 100644 index 000000000..83df03b51 --- /dev/null +++ b/navit/traffic/dummy/CMakeLists.txt @@ -0,0 +1 @@ +module_add_library(traffic_dummy traffic_dummy.c) diff --git a/navit/traffic/dummy/traffic_dummy.c b/navit/traffic/dummy/traffic_dummy.c new file mode 100644 index 000000000..381584048 --- /dev/null +++ b/navit/traffic/dummy/traffic_dummy.c @@ -0,0 +1,80 @@ +/** + * Navit, a modular navigation system. + * Copyright (C) 2005-2017 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. + */ + +/** + * @file traffic_dummy.c + * + * @brief A dummy traffic plugin. + * + * This is a dummy plugin to test the traffic framework. + */ + +#include <string.h> +#include <time.h> + +#ifdef _POSIX_C_SOURCE +#include <sys/types.h> +#endif +#include "glib_slice.h" +#include "config.h" +#include "coord.h" +#include "item.h" +#include "traffic.h" +#include "event.h" +#include "callback.h" +#include "debug.h" + +/** + * @brief Stores information about the plugin instance. + */ +struct traffic { + struct navit * nav; /*!< The navit instance */ + struct callback * callback; /*!< The callback function for the idle loop */ + struct event_idle * idle; /*!< The idle event that triggers the idle function */ +}; + +/** + * @brief The idle function for the traffic plugin. + * + * This function polls backends for new messages and processes them by inserting, removing or modifying + * traffic distortions and triggering route recalculations as needed. + */ +void traffic_idle(struct traffic * this_) { + // TODO poll backends and process any new messages + dbg(lvl_error, "THIS IS THE DUMMY TRAFFIC PLUGIN. Got nothing to do yet...\n"); +} + +/** + * @brief Initializes the traffic plugin. + * + * This function is called once on startup. + */ +void plugin_init(void) { + struct traffic * this_; + + dbg(lvl_error, "THIS IS THE DUMMY TRAFFIC PLUGIN. Startup successful, more to come soon...\n"); + + this_ = g_new0(struct traffic, 1); + + // TODO register ourselves as a map plugin (once we have a map provider) + + // FIXME error:navit:event_add_idle:Can't find event system method add_idle. Event system is not set. + this_->callback = callback_new_1(callback_cast(traffic_idle), this_); + this_->idle = event_add_idle(200, this_->callback); // TODO store return value with plugin instance +} |