summaryrefslogtreecommitdiff
path: root/navit/traffic
diff options
context:
space:
mode:
authormvglasow <michael -at- vonglasow.com>2018-01-04 21:00:09 +0100
committermvglasow <michael -at- vonglasow.com>2018-01-04 21:00:09 +0100
commit83b897ad606608d4897aca9b52f60d3a4bc0a8f8 (patch)
tree609dcf17a8b7556f7eb598333f335bdf9cc95022 /navit/traffic
parent39239c54f54e784282e4199bddeca58f0aef8dfc (diff)
downloadnavit-83b897ad606608d4897aca9b52f60d3a4bc0a8f8.tar.gz
Add:traffic/dummy:Send cancellation after 10 s
Signed-off-by: mvglasow <michael -at- vonglasow.com>
Diffstat (limited to 'navit/traffic')
-rw-r--r--navit/traffic/dummy/traffic_dummy.c66
1 files changed, 42 insertions, 24 deletions
diff --git a/navit/traffic/dummy/traffic_dummy.c b/navit/traffic/dummy/traffic_dummy.c
index 2b55fc6c6..f201746c9 100644
--- a/navit/traffic/dummy/traffic_dummy.c
+++ b/navit/traffic/dummy/traffic_dummy.c
@@ -45,7 +45,7 @@
*/
struct traffic_priv {
struct navit * nav; /*!< The navit instance */
- int is_report_sent; /*!< Whether we have already sent a report */
+ int reports_requested; /*!< How many reports have been requested */
};
struct traffic_message ** traffic_dummy_get_messages(struct traffic_priv * this_);
@@ -53,11 +53,12 @@ struct traffic_message ** traffic_dummy_get_messages(struct traffic_priv * this_
/**
* @brief Returns a dummy traffic report.
*
- * This method will report two messages when first called. Further calls to this method will return
- * `NULL`, indicating that there are no messages to report.
+ * This method will report two messages when first called: The messages indicate queuing traffic on the
+ * A9 Munich–Nuremberg between Neufahrn and Allershausen, and slow traffic on the A96 Lindau–Munich
+ * between Gräfelfing and München-Laim.
*
- * The messages indicate queuing traffic on the A9 Munich–Nuremberg between Neufahrn and Allershausen,
- * and slow traffic on the A96 Lindau–Munich between Gräfelfing and München-Laim.
+ * The 10th call will report a cancellation message for the A96 (no update or cancellation is sent for
+ * the A9).
*
* They mimic TMC messages in that coordinates are approximate, TMC identifiers are supplied for the
* locations and extra data fields which can be inferred from the TMC location table are filled. The
@@ -65,6 +66,8 @@ struct traffic_message ** traffic_dummy_get_messages(struct traffic_priv * this_
* 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.
*
+ * All other calls to this method will return `NULL`, indicating that there are no messages to report.
+ *
* @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.
*/
@@ -74,26 +77,41 @@ struct traffic_message ** traffic_dummy_get_messages(struct traffic_priv * this_
struct traffic_point * to;
struct traffic_location * location;
- if (this_->is_report_sent)
+ this_->reports_requested++;
+
+ switch (this_->reports_requested) {
+ case 1:
+ messages = g_new0(struct traffic_message *, 3);
+
+ 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);
+
+ from = traffic_point_new(11.4481, 48.1266, "Gräfelfing", "36b", "12961-2");
+ to = traffic_point_new(11.5028, 48.1258, "München-Laim", "38", "12961");
+ location = traffic_location_new(NULL, from, to, "München", NULL, location_dir_one,
+ location_fuzziness_low_res, location_ramps_none, type_highway_land, NULL, "A96", "58:1", -1);
+ messages[1] = traffic_message_new_single_event("dummy:A96-36b-38", time(NULL), time(NULL),
+ time(NULL) + 86400, 0, 0, location, event_class_congestion, event_congestion_slow_traffic);
+ break;
+
+ case 11:
+ messages = g_new0(struct traffic_message *, 2);
+
+ from = traffic_point_new(11.4481, 48.1266, "Gräfelfing", "36b", "12961-2");
+ to = traffic_point_new(11.5028, 48.1258, "München-Laim", "38", "12961");
+ location = traffic_location_new(NULL, from, to, "München", NULL, location_dir_one,
+ location_fuzziness_low_res, location_ramps_none, type_highway_land, NULL, "A96", "58:1", -1);
+ messages[0] = traffic_message_new_single_event("dummy:A96-36b-38", time(NULL), time(NULL),
+ time(NULL) + 86400, 1, 0, location, 0, 0);
+ break;
+
+ default:
return NULL;
-
- messages = g_new0(struct traffic_message *, 3);
-
- 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);
-
- from = traffic_point_new(11.4481, 48.1266, "Gräfelfing", "36b", "12961-2");
- to = traffic_point_new(11.5028, 48.1258, "München-Laim", "38", "12961");
- location = traffic_location_new(NULL, from, to, "München", NULL, location_dir_one,
- location_fuzziness_low_res, location_ramps_none, type_highway_land, NULL, "A96", "58:1", -1);
- messages[1] = traffic_message_new_single_event("dummy:A96-36b-38", time(NULL), time(NULL),
- time(NULL) + 86400, 0, 0, location, event_class_congestion, event_congestion_slow_traffic);
-
- this_->is_report_sent = 1;
+ }
return messages;
}