summaryrefslogtreecommitdiff
path: root/navit/script/gps_emu4
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-09-23 22:04:38 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-09-23 22:04:38 +0000
commit24742177e27ea519d714a6860eca859d70236c39 (patch)
treef3f40450b2cbb5393304102ebd32667886b141a9 /navit/script/gps_emu4
parent24ac49e89cdb852bce558de707a4aabbdae7d350 (diff)
downloadnavit-24742177e27ea519d714a6860eca859d70236c39.tar.gz
Add:script:Added graphical gps emulator
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1407 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/script/gps_emu4')
-rwxr-xr-xnavit/script/gps_emu494
1 files changed, 94 insertions, 0 deletions
diff --git a/navit/script/gps_emu4 b/navit/script/gps_emu4
new file mode 100755
index 000000000..f86618f64
--- /dev/null
+++ b/navit/script/gps_emu4
@@ -0,0 +1,94 @@
+#! /usr/bin/perl
+use Glib qw/TRUE FALSE/;
+use Gtk2 '-init';
+
+sub process_one_packet
+{
+ $pos[$idx++]=tell(STDIN);
+ while (<STDIN>) {
+ print $_;
+ if (/^\$GPRMC/) {
+ my($dummy,$time,$dummy)=split(/,/,$_);
+ $label->set_label($time);
+ return;
+ }
+ }
+}
+
+sub process_one_packet_at_idx
+{
+ ($idx)=@_;
+ seek(STDIN,$pos[$idx],SEEK_SET);
+ process_one_packet();
+}
+
+sub forward
+{
+ process_one_packet();
+ return 1;
+}
+
+sub backward
+{
+ if ($idx > 1) {
+ process_one_packet_at_idx($idx-2);
+ }
+ return 1;
+}
+
+sub add_timeout
+{
+ my ($interval,$dir)=@_;
+
+ if ($timeout > 0) {
+ Glib::Source->remove($timeout);
+ }
+ if ($dir > 0) {
+ forward();
+ $timeout=Glib::Timeout->add ($interval, \&forward);
+ }
+ if ($dir < 0) {
+ backward();
+ $timeout=Glib::Timeout->add ($interval, \&backward);
+ }
+}
+
+$oldfh = select(STDOUT); $| = 1; select($oldfh);
+$window = Gtk2::Window->new('toplevel');
+$box = Gtk2::HBox->new();
+$window->add($box);
+$button = Gtk2::Button->new("Stop");
+$button->signal_connect(clicked => sub { add_timeout(0,0) });
+$box->add($button);
+$button = Gtk2::Button->new("100 Hz");
+$button->signal_connect(clicked => sub { add_timeout(10,-1); });
+$box->add($button);
+$button = Gtk2::Button->new("10 Hz");
+$button->signal_connect(clicked => sub { add_timeout(100,-1); });
+$box->add($button);
+$button = Gtk2::Button->new("1 Hz");
+$button->signal_connect(clicked => sub { add_timeout(1000,-1); });
+$box->add($button);
+$button = Gtk2::Button->new("-");
+$button->signal_connect(clicked => sub { add_timeout(0,0) ; backward() });
+$box->add($button);
+$label = Gtk2::Button->new("???");
+$box->add($label);
+$button = Gtk2::Button->new("+");
+$button->signal_connect(clicked => sub { add_timeout(0,0) ; forward() });
+$box->add($button);
+$button = Gtk2::Button->new("1 Hz");
+$button->signal_connect(clicked => sub { add_timeout(1000,1); });
+$box->add($button);
+$button = Gtk2::Button->new("10 Hz");
+$button->signal_connect(clicked => sub { add_timeout(100,1); });
+$box->add($button);
+$button = Gtk2::Button->new("100 Hz");
+$button->signal_connect(clicked => sub { add_timeout(10,1); });
+$box->add($button);
+$button = Gtk2::Button->new("Max");
+$button->signal_connect(clicked => sub { add_timeout(1,1); });
+$box->add($button);
+$window->show_all;
+Gtk2->main;
+0;