summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/DBInfoscreen')
-rw-r--r--lib/DBInfoscreen/Controller/Wagenreihung.pm57
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/DBInfoscreen/Controller/Wagenreihung.pm b/lib/DBInfoscreen/Controller/Wagenreihung.pm
index ebda6f3..92af5f3 100644
--- a/lib/DBInfoscreen/Controller/Wagenreihung.pm
+++ b/lib/DBInfoscreen/Controller/Wagenreihung.pm
@@ -1,4 +1,5 @@
package DBInfoscreen::Controller::Wagenreihung;
+
# Copyright (C) 2011-2020 Daniel Friesel
#
# SPDX-License-Identifier: BSD-2-Clause
@@ -6,11 +7,67 @@ package DBInfoscreen::Controller::Wagenreihung;
use Mojo::Base 'Mojolicious::Controller';
use Travel::Status::DE::DBWagenreihung;
+use Travel::Status::DE::DBWagenreihung::Wagon;
my $dbf_version = qx{git describe --dirty} || 'experimental';
chomp $dbf_version;
+sub zugbildung_db {
+ my ($self) = @_;
+
+ my $train_no = $self->param('train');
+
+ my $details = $self->app->train_details_db->{$train_no};
+
+ if ( not $details ) {
+ $self->render( 'not_found',
+ message => "Keine Daten zu Zug ${train_no} bekannt" );
+ return;
+ }
+
+ my @wagons;
+
+ for my $wagon_number ( sort { $a <=> $b } keys %{ $details->{wagon} } ) {
+ my %wagon = (
+ fahrzeugnummer => "",
+ fahrzeugtyp => $details->{wagon}{$wagon_number},
+ kategorie => "",
+ train_no => $train_no,
+ wagenordnungsnummer => $wagon_number,
+ positionamhalt => {
+ startprozent => 0,
+ endeprozent => 0,
+ startmeter => 0,
+ endemeter => 0,
+ }
+ );
+ my $wagon = Travel::Status::DE::DBWagenreihung::Wagon->new(%wagon);
+
+ if ( $details->{type} ) {
+ $wagon->set_traintype( $details->{type} );
+ }
+ push( @wagons, $wagon );
+ }
+
+ my $pos = 0;
+ for my $wagon (@wagons) {
+ $wagon->{position}{start_percent} = $pos;
+ $wagon->{position}{end_percent} = $pos + 4;
+ $pos += 4;
+ }
+
+ $self->render(
+ 'zugbildung_db',
+ wr_error => undef,
+ title => $details->{raw} . ' ' . $train_no,
+ zb => $details,
+ train_no => $train_no,
+ wagons => [@wagons],
+ hide_opts => 1,
+ );
+}
+
sub wagenreihung {
my ($self) = @_;
my $train = $self->stash('train');