diff --git a/LoadCSVData.pl b/LoadCSVData.pl index 7ed3888..6ef6cdb 100644 --- a/LoadCSVData.pl +++ b/LoadCSVData.pl @@ -365,6 +365,8 @@ if ( $filename = m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)$/i ) { # GD801 $fileTime = $strings[3] . ":" . $strings[4] . ":" . $strings[5]; $unittype = $strings[6]; $unit = $strings[7]; + $tool = $strings[8]; + $tooltype = 'MUX'; } while ( my $line = ) { @@ -455,10 +457,15 @@ while ( my $line = ) { } else { my ( $y, $m, $d, $t ) = split( /[\s\/]/, $first ); + if (length($y) != 4) { # G201 con la data invertita + my $w = $y; + $y = $d; + $m = sprintf('%02d',$m); + $d = sprintf('%02d',$w); + } foreach (@data) { if ( $sql[ ( $outcount % $maxsqllines ) ] eq "" ) { - $sql[ ( $outcount % $maxsqllines ) ] = -"('$unit','$tool','$nodenum','$y-$m-$d','$t','$toolbatt','$tooltemp'"; + $sql[ ( $outcount % $maxsqllines ) ] = "('$unit','$tool','$nodenum','$y-$m-$d','$t','$toolbatt','$tooltemp'"; } $sql[ ( $outcount % $maxsqllines ) ] .= ",'" . $_ . "'"; } diff --git a/UnitCsvReceiverSmart.pl b/UnitCsvReceiverSmart.pl index a8e7ec6..caacd80 100644 --- a/UnitCsvReceiverSmart.pl +++ b/UnitCsvReceiverSmart.pl @@ -26,13 +26,21 @@ sub getTimeStamp } sub getUnitName { # parm => file received ($trfile) - my ($filename) = @_; - open FILE, $filename - or warn getTimeStamp("log") . " >> Error: opening input file $filename\n"; - my ( $fileDate, $fileTime ) = split( /\s/, ); - my ( $unittype, $unit ) = split( /\s/, uc ); - $unit =~ s/;+$//; - close FILE; + if ( $filename = m/^(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)$/i ) { # GD201 + my @strings = $filename =~ /(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2})_(.{1,4})_(.{1,6})_(.{1,6}).*/; + $fileDate = $strings[0] . "/" . $strings[1] . "/" . $strings[2];; + $fileTime = $strings[3] . ":" . $strings[4] . ":" . $strings[5]; + $unittype = $strings[6]; + $unit = $strings[7]; + } else { + my ($filename) = @_; + open FILE, $filename + or warn getTimeStamp("log") . " >> Error: opening input file $filename\n"; + my ( $fileDate, $fileTime ) = split( /\s/, ); + my ( $unittype, $unit ) = split( /\s/, uc ); + $unit =~ s/;+$//; + close FILE; + } return $unit; } @@ -96,8 +104,8 @@ while ( my $line = $tail->GetLine() ) { chmod 0664, $dest; my @fname = ($dest); chown $uid, $gid, @fname; - if ( $filename =~ - m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)$/i + if ( ($filename =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)$/i + or $filename =~ m/^(\d\d\d\d\d\d\d\d\d\d\d\d\d\d_)(G201_ID\d\d\d\d_DT\d\d\d\d)$/i) and ( $unit ne 'ID9999' ) and ( $truser ne 'corra' ) ) {