- my $msg = shift;
- my ($sort, $call, $line) = $msg =~ /^(\w)([^\|]+)\|(.*)$/;
- if ($sort eq 'D') {
- $toplist->insert($toplist->{font}, undef, undef, "$line\n");
- } elsif ($sort eq 'X') {
- $toplist->insert($toplist->{font}, undef, undef, "$line\n");
- } elsif ($sort eq 'Y') {
- $toplist->insert($toplist->{font}, undef, undef, "$line\n");
- } elsif ($sort eq 'V') {
- $toplist->insert($toplist->{font}, undef, undef, "$line\n");
- } elsif ($sort eq 'N') {
- $toplist->insert($toplist->{font}, undef, undef, "$line\n");
- } elsif ($sort eq 'W') {
- $toplist->insert($toplist->{font}, undef, undef, "$line\n");
- } elsif ($sort eq 'Z') {
- Gtk->exit(0);
+ my $line = shift;
+
+ # this is truely evil and I bet there is a better way...
+ chomp $line;
+ my $list;
+ if ($line =~ /^'\w{2,4}',/) {
+ $list = eval qq([$line]);
+ } else {
+ $list = ['cmd', $line];
+ }
+ unless ($@) {
+ no strict 'refs';
+ my $cmd = shift @$list;
+ my $handle = "handle_$cmd";
+ if (__PACKAGE__->can($handle)) {
+ __PACKAGE__->$handle($list);
+ } else {
+ push @$list, $cmd;
+ __PACKAGE__->handle_def($list);
+ }
+ }
+}
+
+sub handle_cmd
+{
+ my $self = shift;
+ my $ref = shift;
+ my ($t, $ts) = (time, '');
+ my $s;
+ $s = ref $ref ? join ', ',@$ref : $ref;
+
+ if (exists $cmdlist->{lasttime} != $t) {
+ $ts = tim($t);
+ $cmdlist->{lasttime} = $t;
+ }
+
+ chomp $s;
+ push @{$cmdlist->{data}}, [$ts, $s];
+}
+
+sub handle_def
+{
+ my $self = shift;
+ my $ref = shift;
+ my $s;
+ $s = ref $ref ? join ', ',@$ref : $ref;
+ my ($t, $ts) = (time, '');
+
+ if (exists $cmdlist->{lasttime} != $t) {
+ $ts = tim($t);
+ $cmdlist->{lasttime} = $t;
+ }
+
+ chomp $s;
+ push @{$cmdlist->{data}}, [$ts, $s];
+}
+
+sub handle_dx
+{
+ my $self = shift;
+ my $ref = shift;
+ my ($t, $ts) = (time, '');
+
+ if (exists $dxlist->{lasttime} != $t) {
+ $ts = tim($t);
+ $dxlist->{lasttime} = $t;
+ }
+ push @{$dxlist->{data}}, [$ts, @$ref[0,1,15,3,4,16], stim($ref->[2]) ];
+
+}
+
+sub handle_ann
+{
+ my $self = shift;
+ my $ref = shift;
+ my ($t, $ts) = (time, '');
+ my $s;
+ $s = ref $ref ? join ', ',@$ref : $ref;
+
+ if (exists $cmdlist->{lasttime} != $t) {
+ $ts = tim($t);
+ $cmdlist->{lasttime} = $t;