Skip to content
Extraits de code Groupes Projets
Valider b454a1b1 rédigé par hieda_kyuko@hpr's avatar hieda_kyuko@hpr
Parcourir les fichiers

PoC: train information

parent 48bf5f04
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
package Ts;
use strict;
use warnings;
use Data::Dumper;
sub dummy
{
return "yay!";
}
sub ts_time_to_string
{
my %timestamp = %{ $_[0] };
my $option = $_[1];
$option eq 'd' ? return $timestamp{'hatsu'}
: $option eq 'a' ? return $timestamp{'chaku'}
: die "Time format must be d or a."
}
sub debug_train_info
{
my @timestamps = @{ $_[0] };
my @consumed = @timestamps;
my $start = 0;
while (!defined $consumed[0])
{
shift @consumed;
$start++;
}
my $end = $start;
while (defined $consumed[0])
{
shift @consumed;
$end++;
}
$end--;
print "Station ($start) @ " . (ts_time_to_string $timestamps[$start], 'd');
print " > Station ($end) @ " . (ts_time_to_string $timestamps[$end], 'a') . "\n";
}
1;
package Ts;
use strict;
use warnings;
sub dummy
{
return "yay!";
}
1;
#!/usr/bin/perl #!/usr/bin/perl
use Module::Load;
use autodie 'open'; use autodie 'open';
use strict; use strict;
use warnings; use warnings;
use feature 'unicode_strings'; use feature 'unicode_strings';
use Perl::Critic; BEGIN
{
unshift @INC, './lib';
}
# load App::Ts;
use FindBin;
use File::Spec;
use lib File::Spec -> catdir ($FindBin::Bin, '..', 'lib');
use App::Ts;
use Perl::Critic;
use Nice::Try; use Nice::Try;
use Marpa::R2; use Marpa::R2;
...@@ -51,10 +65,12 @@ ROSEN_NAME ::= 'Rosenmei=' NAME ...@@ -51,10 +65,12 @@ ROSEN_NAME ::= 'Rosenmei=' NAME
action => Dia::print_line action => Dia::print_line
EKI_ALL ::= EKI_STRUCT+ EKI_ALL ::= EKI_STRUCT+
action => Dia::list_of_eki
EKI_STRUCT ::= EKI_BEGIN EKI_NAME GARBAGE_LINES EKI_STRUCT ::= EKI_BEGIN EKI_NAME GARBAGE_LINES
action => Dia::second
EKI_BEGIN ::= 'Eki.' EKI_BEGIN ::= 'Eki.'
EKI_NAME ::= 'Ekimei=' NAME EKI_NAME ::= 'Ekimei=' NAME
action => Dia::print_sta action => Dia::second
DIA_BEGIN ::= 'Dia.' DIA_BEGIN ::= 'Dia.'
action => Dia::begin_dia_section action => Dia::begin_dia_section
...@@ -159,6 +175,7 @@ GARBAGE_LINE ~ [^\n]* ...@@ -159,6 +175,7 @@ GARBAGE_LINE ~ [^\n]*
endrule endrule
; ;
package Dia; package Dia;
use Data::Dumper; use Data::Dumper;
...@@ -196,21 +213,22 @@ sub Dia::hash_of_ts_ad { shift; my $q = {"mode" => $_[0], ...@@ -196,21 +213,22 @@ sub Dia::hash_of_ts_ad { shift; my $q = {"mode" => $_[0],
"hatsu" => $_[4],}; return $q; } "hatsu" => $_[4],}; return $q; }
sub Dia::list_of_ts sub Dia::list_of_ts
{ {
#print "a" . Dumper(\@_);
shift; shift;
# while (defined $_[0]) print "Making list of ts...\n";
# { return \@_;
# print Dumper $_[0]; }
# shift;
# } sub Dia::list_of_eki
print "Making list of ts..."; {
# TODO use Eki objects
shift;
print Dumper \@_;
return \@_; return \@_;
} }
sub Dia::ts_combine sub Dia::ts_combine
{ {
shift; shift;
# print Dumper $_[1];
my @ts = @{$_[0]}; my @ts = @{$_[0]};
my @res = (); my @res = ();
...@@ -227,12 +245,16 @@ sub Dia::print_sta { shift; print "Found station: "; print $_[1]; print "\n"; } ...@@ -227,12 +245,16 @@ sub Dia::print_sta { shift; print "Found station: "; print $_[1]; print "\n"; }
sub Dia::print_line { shift; print "Working on line: "; print $_[1]; print "\n"; } sub Dia::print_line { shift; print "Working on line: "; print $_[1]; print "\n"; }
sub Dia::format_ressya sub Dia::format_ressya
{ {
shift;
print Dumper(\@_); print Dumper(\@_);
shift; print "Found (" . $_[2] . ") train "; print "Found (" . $_[2] . ") train ";
defined $_[3] ? print $_[3] : print "[no number]"; defined $_[3] ? print $_[3] : print "[no number]";
print ", " . $_[4] if defined $_[4]; print ", " . $_[4] if defined $_[4];
print "\n"; print "\n";
Ts::debug_train_info $_[5];
print "\n";
} }
sub Dia::format_mei sub Dia::format_mei
{ {
shift; shift;
...@@ -243,6 +265,7 @@ sub Dia::format_mei ...@@ -243,6 +265,7 @@ sub Dia::format_mei
sub Dia::return_name { shift; return $_[1]; } sub Dia::return_name { shift; return $_[1]; }
package main; package main;
my $diag = Marpa::R2::Scanless::G->new( my $diag = Marpa::R2::Scanless::G->new(
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter