diff options
author | mvglasow <michael -at- vonglasow.com> | 2017-11-30 13:34:36 +0100 |
---|---|---|
committer | mvglasow <michael -at- vonglasow.com> | 2017-11-30 13:34:36 +0100 |
commit | b64bfe4f7ffb1bdf16a32af7bb0e919bfc13d7e2 (patch) | |
tree | 4c852fcfdb03b748129792f1c5d3510ed8e0a448 /navit/traffic | |
parent | 964054dc486a37c84f55ec54b02fbe1c089274f5 (diff) | |
download | navit-b64bfe4f7ffb1bdf16a32af7bb0e919bfc13d7e2.tar.gz |
Add:traffic/dummy:Send report only once
Signed-off-by: mvglasow <michael -at- vonglasow.com>
Diffstat (limited to 'navit/traffic')
-rw-r--r-- | navit/traffic/dummy/traffic_dummy.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/navit/traffic/dummy/traffic_dummy.c b/navit/traffic/dummy/traffic_dummy.c index cf0b7f24b..119249b01 100644 --- a/navit/traffic/dummy/traffic_dummy.c +++ b/navit/traffic/dummy/traffic_dummy.c @@ -45,6 +45,7 @@ */ struct traffic_priv { struct navit * nav; /*!< The navit instance */ + int is_report_sent; /*!< Whether we have already sent a report */ }; struct traffic_message ** traffic_dummy_get_messages(struct traffic_priv * this_); @@ -52,25 +53,38 @@ struct traffic_message ** traffic_dummy_get_messages(struct traffic_priv * this_ /** * @brief Returns a dummy traffic report. * - * This will report one single message, indicating queuing traffic on the A9 Munich–Nuremberg between - * Neufahrn and Allershausen. This mimics a TMC message in that coordinates are approximate, TMC - * identifiers are supplied for the location and extra data fields which can be inferred from the TMC - * location table are filled. The message purports to just have been received for the first time, and - * expire in 24 hours. + * This method will report one single message when first called. Further calls to this method will + * return `NULL`, indicating that there are no messages to report. + * + * The message indicates queuing traffic on the A9 Munich–Nuremberg between Neufahrn and Allershausen. + * It mimics a TMC message in that coordinates are approximate, TMC identifiers are supplied for the + * location and extra data fields which can be inferred from the TMC location table are filled. The + * timestamps indicate a message that has just been received for the first time, i.e. its “first + * received” and “last updated” timestamps match and are recent. Expiration is after 24 hours, longer + * than the typical lifespan of a TMC message of this kind. * * @return A `NULL`-terminated pointer array. Each element points to one `struct traffic_message`. + * `NULL` is returned (rather than an empty pointer array) if there are no messages to report. */ struct traffic_message ** traffic_dummy_get_messages(struct traffic_priv * this_) { - struct traffic_message ** messages = g_new0(struct traffic_message *, 2); - struct traffic_point * from = traffic_point_new(11.6208, 48.3164, "Neufahrn", "68", "12732-4"); - struct traffic_point * to = traffic_point_new(11.5893, 48.429, "Allershausen", "67", "12732"); - struct traffic_location * location = traffic_location_new(NULL, from, to, "Nürnberg", NULL, - location_dir_one, location_fuzziness_low_res, location_ramps_none, type_highway_land, - NULL, "A9", "58:1", -1); + struct traffic_message ** messages; + struct traffic_point * from; + struct traffic_point * to; + struct traffic_location * location; + + if (this_->is_report_sent) + return NULL; + messages = g_new0(struct traffic_message *, 2); + from = traffic_point_new(11.6208, 48.3164, "Neufahrn", "68", "12732-4"); + to = traffic_point_new(11.5893, 48.429, "Allershausen", "67", "12732"); + location = traffic_location_new(NULL, from, to, "Nürnberg", NULL, location_dir_one, + location_fuzziness_low_res, location_ramps_none, type_highway_land, NULL, "A9", "58:1", -1); messages[0] = traffic_message_new_single_event("dummy:A9-68-67", time(NULL), time(NULL), time(NULL) + 86400, 0, 0, location, event_class_congestion, event_congestion_queue); + this_->is_report_sent = 1; + return messages; } |