X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=scripts%2Fprint.pl;h=0c5d3f86a20f97adb00675cd4d18b3564711db29;hb=431ef752883869816f880f431349bdab07728bc0;hp=8168856bec36796fca61a52065fd87470ae041ee;hpb=9fe77c6e7f94c1231dda78ff2a24b3d1b9b255c9;p=Biblio-RFID.git diff --git a/scripts/print.pl b/scripts/print.pl index 8168856..0c5d3f8 100755 --- a/scripts/print.pl +++ b/scripts/print.pl @@ -54,11 +54,11 @@ while(<>) { chomp; my @a = split(/\t/,$_); die "invalid: @a in line $_" if $a[0] !~ m/\d{12}/ && $a[1] !~ m/\@/; - push @queue, [ @a ] if ! $numbers->{ $a[0] }; + push @queue, [ @a ] if ! $numbers->{ $a[0] } || $ENV{REPRINT}; } # sort by card number -@queue = sort { $a->[0] <=> $b->[0] } @queue; +@queue = sort { $b->[0] <=> $a->[0] } @queue; print "# queue ", dump @queue; @@ -71,7 +71,7 @@ sub tag { , " AFI: " , uc unpack('H2', $rfid->afi($tag)) , " " - , dump( Biblio::RFID::RFID501->to_hash( $rfid->blocks($tag) ) ) + , dump( $rfid->to_hash( $tag ) ) , $/ ; } @@ -82,10 +82,19 @@ sub iso_date { } sub print_card; +sub render_card; my $log_path = "$log_print/" . iso_date . ".txt"; die "$log_path exists" if -e $log_path; -open(my $log, '>', $log_path) || die "$log_path: $!"; + +sub write_log { + my ( $tag, $number ) = @_; + open(my $log, '>>', $log_path) || die "$log_path: $!"; + my $date = iso_date; + print $log "$date,$tag,$number\n"; + close($log); + print "LOG $date $tag $number\n"; +} while ( $rfid->tags ) { print "ERROR: remove all tags from output printer tray\n"; @@ -116,9 +125,10 @@ do { sleep 1; } - print $log iso_date, ",$tag,$number\n"; + write_log $tag => $number; $programmed->{$tag} = $number; + render_card; # pre-render next one } }, @@ -141,11 +151,26 @@ sub _counters { return $counters; } +sub render_card { + return unless @queue; + my @data = @{$queue[0]}; + my $nr = $data[0]; + + if ( $ENV{REPRINT} ) { + unlink $_ foreach glob("out/$nr.*"); + warn "REPRINT: $nr"; + } + + if ( ! ( -e "out/$nr.front.pbm" && -e "out/$nr.back.pbm" ) ) { + print "RENDER @data\n"; + system "$evolis_dir/scripts/inkscape-render.pl", "$evolis_dir/card/ffzg-2011.svg", @data; + } +} + sub print_card { if ( ! @queue ) { print "QUEUE EMPTY - printing finished\n"; - close($log); print "$log_path ", -s $log_path, " bytes created\n"; exit; } @@ -166,7 +191,7 @@ sub print_card { } else { - system "$evolis_dir/scripts/inkscape-render.pl", "$evolis_dir/card/ffzg-2010.svg", @data; + render_card; system "$evolis_dir/scripts/evolis-driver.pl out/$nr.front.pbm out/$nr.back.pbm > /dev/usb/lp0"; }