summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/DBInfoscreen.pm19
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm20
2 files changed, 33 insertions, 6 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm
index 1fd3674..174fc97 100644
--- a/lib/DBInfoscreen.pm
+++ b/lib/DBInfoscreen.pm
@@ -273,6 +273,25 @@ sub startup {
}
);
+ $self->helper(
+ 'get_rt_time_class' => sub {
+ my ( $self, $train ) = @_;
+ if ( $train->{has_realtime}
+ and not $train->{is_bit_delayed}
+ and not $train->{is_delayed} )
+ {
+ return 'on-time';
+ }
+ if ( $train->{is_bit_delayed} ) {
+ return 'a-bit-delayed';
+ }
+ if ( $train->{is_delayed} ) {
+ return 'delayed';
+ }
+ return q{};
+ }
+ );
+
my $r = $self->routes;
$r->get('/_redirect')->to('stationboard#redirect_to_station');
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 8e1e7df..f81074b 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -1875,11 +1875,15 @@ sub handle_result {
} $result->qos_messages
],
},
- station => $result->station,
- moreinfo => $moreinfo,
- delay => $delay,
+ station => $result->station,
+ moreinfo => $moreinfo,
+ delay => $delay,
+ is_bit_delayed =>
+ ( $delay and $delay > 0 and $delay < 5 ? 1 : 0 ),
+ is_delayed => ( $delay and $delay >= 5 ? 1 : 0 ),
arrival_delay => $result->arrival_delay,
departure_delay => $result->departure_delay,
+ has_realtime => $result->has_realtime,
missing_realtime => (
not $result->has_realtime
and $result->start < $now ? 1 : 0
@@ -1939,9 +1943,13 @@ sub handle_result {
station => $result->station,
moreinfo => $moreinfo,
delay => $delay,
- replaced_by => [],
- replacement_for => [],
- route_pre => $admode eq 'arr'
+ is_bit_delayed =>
+ ( $delay and $delay > 0 and $delay < 5 ? 1 : 0 ),
+ is_delayed => ( $delay and $delay >= 5 ? 1 : 0 ),
+ has_realtime => defined $delay ? 1 : 0,
+ replaced_by => [],
+ replacement_for => [],
+ route_pre => $admode eq 'arr'
? [ map { $_->loc->name } $result->route ]
: [],
route_post => $admode eq 'arr' ? []