Archived
1
0

Add features to debug notation process

This commit is contained in:
Mercier Pierre-Olivier 2013-09-12 12:00:18 +02:00
parent 67b5a79301
commit d3e723f65a
3 changed files with 66 additions and 13 deletions

View File

@ -46,7 +46,7 @@ sub create_from_trace ($$)
for my $id (sort( keys %{ $trace->{ids} } ))
{
my $p = Point->new(0, $id, 0, 0);
my $p = Point->new($trace->{ids}{$id}, $id, 0, 0);
push @{ $g->{tree} }, $p;
}
@ -264,7 +264,7 @@ sub compute ($$$;$$)
@current;
}
else {
$res = $current[0];
$res = $current[0] // 0;
}
$res = $res * $self->{factor};
@ -287,6 +287,7 @@ package Point;
use v5.10.1;
use strict;
use warnings;
use Term::ANSIColor qw(:constants);
sub new ($$$$$)
{
@ -315,12 +316,16 @@ sub to_string ($$$)
$parent->appendChild($point);
}
sub getValue ($$)
sub getValue ($$;$)
{
my $self = shift;
my $ids = shift;
my $justMatch = shift;
if ($self->{value} eq "") {
if (!$justMatch && !$ids->{ $self->{ref} } // 0) {
return 0;
}
elsif ($self->{value} eq "") {
return $ids->{ $self->{ref} } // 0;
}
else {
@ -347,6 +352,16 @@ sub compute ($$$;$$)
}
}
if ($main::debug)
{
my $str = "not=".($self->{not}//0).", qversion".($self->{qversion}//"*").", ref=".($self->{ref}//"").",\tvalue=".$self->getValue( $ids, 1 ).", got=".($ret // 0);
if ($ret) {
say GREEN, ">>>", RESET, " Matching point: ", $str;
} else {
say RED, " * ", RESET, " Skipped point: ", $str;
}
}
return $ret;
}

View File

@ -7,21 +7,51 @@ use Getopt::Long;
use Pod::Usage;
use lib "..";
use ACU::Defense;
use ACU::Grading;
use ACU::Log;
use ACU::Trace;
my $grade = Grading->new();
my $lastid = "";
do {
my $name = shift;
my $file;
if (-f $name) {
$file = $name;
$name = "rendu-1";
}
else {
$file = shift;
}
my $id_name = $name;
$id_name =~ s/[^a-zA-Z0-9_]/_/g;
my $xml;
open $xml, "<", shift or die $!;
open $xml, "<", $file or die $!;
binmode $xml;
my $trace = Trace->new($xml);
my $trace;
eval {
$trace = Trace->new($xml);
};
if ($@) {
open $xml, "<", $file or die $!;
binmode $xml;
eval {
$trace = Defense->new($xml);
};
if ($@) {
log ERROR, "Unknown file type: $file";
}
}
close $xml unless $xml eq *STDIN;
$grade->create_from_trace("rendu_1", "rendu-1", $trace);
$grade->create_from_trace($id_name, $name, $trace);
} while ($#ARGV >= 0);

View File

@ -13,11 +13,13 @@ use ACU::Log;
use ACU::Trace;
# Parse arguments
our $debug;
my $input; my $format = "csv";
my $help; my $man;
GetOptions ("help|h|?" => \$help,
"man" => \$man,
"format|F=s" => \$format,
"debug|d|v" => \$debug,
"" => \$input)
or pod2usage(2);
pod2usage(1) if $help;
@ -52,12 +54,18 @@ while ($#ARGV >= -1)
}
else
{
open my $xmltrace, "<", $arg or die $!;
binmode $xmltrace;
my $trace = Trace->new($xmltrace);
close $xmltrace;
if (-f $arg)
{
open my $xmltrace, "<", $arg or die "$arg: $!";
binmode $xmltrace;
my $trace = Trace->new($xmltrace);
close $xmltrace;
$grade->fill($trace->getIds);
$who = $trace->getFirstWho() // basename $arg, ".xml", ".trace", ".traces", ".defense", ".defenses", ".mill";
$grade->fill($trace->getIds);
$who = $trace->getFirstWho() // basename $arg, ".xml", ".trace", ".traces", ".defense", ".defenses", ".mill";
}
else {
log WARN, "No trace file: $arg, skip";
}
}
}