summaryrefslogtreecommitdiff
path: root/lib/Travel/Routing/DE/HAFAS
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2023-11-09 21:27:26 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2023-11-09 21:27:26 +0100
commit83eeb9fcdd0e72ba288a2b0dee123b4841ac26cc (patch)
treeb0aa7e2f7a019d71ff9f839d7b2b5b6c3c9e1f0c /lib/Travel/Routing/DE/HAFAS
parent5582b16066642f60b8fdb884aee415d007477142 (diff)
Section: parse and expose messages
Diffstat (limited to 'lib/Travel/Routing/DE/HAFAS')
-rw-r--r--lib/Travel/Routing/DE/HAFAS/Connection/Section.pm33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm b/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm
index 6b85f1a..9120e69 100644
--- a/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm
+++ b/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm
@@ -28,6 +28,29 @@ sub new {
my $locs = $opt{locL};
my @prodL = @{ $opt{common}{prodL} // [] };
+ # himL may only be present in departure monitor mode
+ my @remL = @{ $opt{common}{remL} // [] };
+ my @himL = @{ $opt{common}{himL} // [] };
+
+ my @msgL = (
+ @{ $sec->{dep}{msgL} // [] },
+ @{ $sec->{arr}{msgL} // [] },
+ @{ $sec->{jny}{msgL} // [] }
+ );
+
+ my @messages;
+ for my $msg (@msgL) {
+ if ( $msg->{type} eq 'REM' and defined $msg->{remX} ) {
+ push( @messages, $hafas->add_message( $remL[ $msg->{remX} ] ) );
+ }
+ elsif ( $msg->{type} eq 'HIM' and defined $msg->{himX} ) {
+ push( @messages, $hafas->add_message( $himL[ $msg->{himX} ], 1 ) );
+ }
+ else {
+ say "Unknown message type $msg->{type}";
+ }
+ }
+
my $strptime = DateTime::Format::Strptime->new(
pattern => '%Y%m%dT%H%M%S',
time_zone => 'Europe/Berlin'
@@ -58,6 +81,7 @@ sub new {
arr_datetime => $rt_arr // $sched_arr,
dep_loc => $locs->[ $sec->{dep}{locX} ],
arr_loc => $locs->[ $sec->{arr}{locX} ],
+ messages => \@messages,
};
if ( $sched_dep and $rt_dep ) {
@@ -110,6 +134,15 @@ sub new {
# {{{ Accessors
+sub messages {
+ my ($self) = @_;
+
+ if ( $self->{messages} ) {
+ return @{ $self->{messages} };
+ }
+ return;
+}
+
# }}}
1;