refresh script

This commit is contained in:
2025-04-20 22:00:55 +02:00
parent fab32f1e6a
commit b7fc29ec20
26 changed files with 7943 additions and 128 deletions

View File

@@ -9,15 +9,16 @@ use List::Util qw( max );
use Data::Dumper qw(Dumper);
use Cwd;
use MIME::Lite;
use Time::Piece;
$|++; # Autoflush
my ( $filename, $sqlout );
my $username = 'ase_lar';
my $username = 'aselar';
my $password = 'laravel';
my $db_lar = 'ase_lar';
my $db_sp = 'ase_lar';
my $server = '80.211.107.201';
my $server = '85.235.153.201';
my $db_name = "ase_lar";
my $table = "RAWDATACOR";
my ( @CSVData, @sql );
@@ -28,12 +29,17 @@ my (
$tool, $toolbatt, $tooltemp, $tooltype, @channels,
@NewData, @ain, @din, @nodetype, $GDEventDate
);
my $matlab_proxy_ssh = "80.211.107.201";
my $matlab_proxy_ssh_port = 2222;
my $matlab_exec_user = 'aselab';
my $matlab_proxy_ssh = "localhost"; #"80.211.107.201";
my $matlab_proxy_ssh_port = 22; #2222;
my $matlab_exec_user = 'asega';
my $matlab_cmd = "";
my $matlab_timestamp = "";
my $ftp_send = 1;
my $api_send = 0;
my $inoltro_api = 0;
my $inoltro_api_url = "";
my $inoltro_api_bearer_token = "";
my $unit_duedate = "";
my $ftp_addrs;
my $ftp_user;
my $ftp_passwd;
@@ -48,16 +54,18 @@ my $matlab_func_dir = "/usr/local/matlab_func/";
my $matlab_error = '';
my $matlab_timeout = '1800';
my $email_addr =
'andrea.carri@aseltd.eu,alessandro.battilani@gmail.com,alessandro.valletta@aseltd.eu';
'andrea.carri@aseltd.eu,alessandro.battilani@gmail.com,alessandro.valletta@aseltd.eu,alberto.sillani@aseltd.eu,majd.saidani@aseltd.eu';
my $from = 'ASE Alert System<alert@aseltd.eu>';
my ( $email_msg, $email_obj );
my $G201_fcheck = 0;
my $TLP_fcheck = 0;
my $GS1_fcheck = 0;
my $D2W_fcheck = 0;
my $G301_fcheck = 0;
my $CR1000X_fcheck = 0;
my $FtpToCustomerCmd = 'SendFtpElabData.pl';
my ( $scriptname, $scriptpath );
my $MatlabErrorPath = "/mnt/elab-error/";
my $MatlabErrorPath = "/tmp/";
my $MatlabErrorFilename = $MatlabErrorPath;
my @matlabOutputErrorArray;
my @errors;
@@ -97,16 +105,15 @@ sub writeOutSql {
. $outfile
. ":$!\n" );
print getTimeStamp("log") . " - pid $$ >> file $outfile created\n";
print SQLOUT "/* lock "
. $db_name
. ".$table table */\nLOCK TABLES "
. $db_name
. ".$table WRITE;\n";
print SQLOUT "INSERT IGNORE INTO " . $db_name . ".$table\n";
print SQLOUT
"(`UnitName`,`ToolNameID`,`NodeNum`,`EventDate`,`EventTime`,`BatLevel`,`Temperature`,\n";
print SQLOUT
"`Val0`,`Val1`,`Val2`,`Val3`,`Val4`,`Val5`,`Val6`,`Val7`,`Val8`,`Val9`,`ValA`,`ValB`,`ValC`,`ValD`,`ValE`,`ValF`)\n";
print SQLOUT "(`UnitName`,`ToolNameID`,`NodeNum`,`EventDate`,`EventTime`,`BatLevel`,`Temperature`,\n";
print SQLOUT "`Val0`,`Val1`,`Val2`,`Val3`,`Val4`,`Val5`,`Val6`,`Val7`,`Val8`,`Val9`,`ValA`,`ValB`,`ValC`,`ValD`,`ValE`,`ValF`)\n";
print SQLOUT "VALUES\n";
print SQLOUT @sql;
@sql = ();
@@ -126,11 +133,76 @@ sub writeOutSql {
return;
}
sub matlabCalc {
sub modifyAndWriteOutSql {
my ($tn) = @_;
my $outfile2 = $sqlout . "_" . $outfilenum++;
open SQLOUT, ">", $outfile2
or die( getTimeStamp("log")
. " - pid $$ >> Error: opening output file "
. $outfile2
. ":$!\n" );
print getTimeStamp("log") . " - pid $$ >> file $outfile2 IPI created\n";
print SQLOUT "/* lock "
. $db_name
. ".$table table */\nLOCK TABLES "
. $db_name
. ".$table WRITE;\n";
print SQLOUT "INSERT IGNORE INTO " . $db_name . ".$table\n";
print SQLOUT "(`UnitName`,`ToolNameID`,`NodeNum`,`EventDate`,`EventTime`,`BatLevel`,`Temperature`,\n";
print SQLOUT "`Val0`,`Val1`,`Val2`,`Val3`,`Val4`,`Val5`,`Val6`,`Val7`,`Val8`,`Val9`,`ValA`,`ValB`,`ValC`,`ValD`,`ValE`,`ValF`)\n";
print SQLOUT "VALUES\n";
foreach my $row (@sql) {
my @row_values = split /','/, $row;
if ($row_values[0] eq "('ID0070" && $row_values[1] eq 'DT0111') {
$row_values[0] = "('ID0070";
$row_values[1] = 'DT0111 IPI';
}
elsif ($row_values[0] eq "('ID0071" && $row_values[1] eq 'DT0112') {
$row_values[0] = "('ID0071";
$row_values[1] = 'DT0112 IPI';
}
elsif ($row_values[0] eq "('ID0072" && $row_values[1] eq 'DT0113') {
$row_values[0] = "('ID0072";
$row_values[1] = 'DT0113 IPI';
}
elsif ($row_values[0] eq "('ID0073" && $row_values[1] eq 'DT0114') {
$row_values[0] = "('ID0073";
$row_values[1] = 'DT0114 IPI';
}
elsif ($row_values[0] eq "('ID0273" && $row_values[1] eq 'DT0001') {
$row_values[0] = "('ID0273";
$row_values[1] = 'DT0002';
}
elsif ($row_values[0] eq "('ID00279" && $row_values[1] eq 'DT0008') {
$row_values[0] = "('ID0279";
$row_values[1] = 'DT0008';
}
my $modified_row_string = "" . join("','", @row_values) . "\n";
print SQLOUT $modified_row_string;
#print getTimeStamp("log") . " - pid $$ >> row IPI[".$row_values[0]." ".$row_values[1]."] $modified_row_string\n";
}
print SQLOUT "/* unlock table */\nUNLOCK TABLES;\n";
close SQLOUT
or die( getTimeStamp("log")
. " - pid $$ >> Error in closing file "
. $outfile2
. "\n" );
my @args = ( "mysql", "--login-path=asepath", "-e source " . $outfile2 );
system(@args) == 0
or die( getTimeStamp("log") . " - pid $$ >> system @args failed: $?\n" );
print getTimeStamp("log") . " - pid $$ >> file $outfile2 IPI loaded into DB\n";
unlink $outfile2;
return;
}
sub matlabCalc {
$matlab_timestamp = getTimeStamp("db_ts");
print getTimeStamp("log")
. " - pid $$ >> $unit - $tool MatLab calc started...\n";
print getTimeStamp("log") . " - pid $$ >> $unit - $tool MatLab calc started...\n";
if ( $matlab_cmd =~ /_lnx$/ ) {
$matlab_cmd = './run_' . $matlab_cmd . '.sh';
$MatlabErrorFilename .= "${unit}${tool}_output_error.txt";
@@ -138,18 +210,16 @@ sub matlabCalc {
#print $ENV{"HOME"} . "\n";
$ENV{"HOME"} = "/" . $ENV{"HOME"};
my $cmd_elab =
"timeout $matlab_timeout $matlab_cmd $matlab_rt $unit $tool";
#my $args = "sh -c \'cd $matlab_func_dir; pwd; $cmd_elab\'";
my $args =
"ssh $matlab_exec_user\@$matlab_proxy_ssh -p $matlab_proxy_ssh_port \'cd $matlab_func_dir; $cmd_elab\'";
chdir($matlab_func_dir)
or die "cannot change: $!\n";
print getTimeStamp("log")
. " - pid $$ >> current dir: $matlab_func_dir\n";
my $args = "timeout $matlab_timeout $matlab_cmd $matlab_rt $unit $tool";
if ( system($args) != 0 ) {
my $argscat =
"sh -c \'cd $MatlabErrorPath; cat _${unit}_${tool}*_\*_output_error.txt > ${unit}${tool}_output_error.txt\'";
my $argscat = "cd $MatlabErrorPath; cat _${unit}_${tool}*_\*_output_error.txt > ${unit}${tool}_output_error.txt";
system($argscat);
open( my $fh, '<', $MatlabErrorFilename )
or warn print getTimeStamp("log")
. " - pid $$ >> Cannot open Matlab output error file: ${MatlabErrorFilename}\n";
@@ -167,8 +237,7 @@ sub matlabCalc {
if ( $exit_value == 124 ) {
print getTimeStamp("log")
. " - pid $$ >> system $args excessive duration: killed after $matlab_timeout seconds\n";
$matlab_error =
"Matlab elab excessive duration: killed after $matlab_timeout seconds";
$matlab_error = "Matlab elab excessive duration: killed after $matlab_timeout seconds";
}
else {
print getTimeStamp("log")
@@ -189,8 +258,7 @@ sub matlabCalc {
sub trxelab {
my $user = getpwuid($>);
my $ftpcmd =
"$scriptpath$FtpToCustomerCmd -m \"$matlab_timestamp\" -u $unit -t $tool >> /home/$user/log/loadcsvdata.log 2>&1";
my $ftpcmd = "$scriptpath$FtpToCustomerCmd -m \"$matlab_timestamp\" -u $unit -t $tool >> /home/$user/log/loadcsvdata.log 2>&1";
print getTimeStamp("log")
. " - pid $$ >> Fork FTP command to set GID mysql: $ftpcmd.\n";
@@ -201,14 +269,22 @@ sub trxelab {
}
sub trxelabApi {
print getTimeStamp("log") . " - pid $$ >> DEBUG inoltro ELAB API: /home/battilo/scripts/inoltroViaApiElab.py $matlab_timestamp $unit $tool $inoltro_api_url $inoltro_api_bearer_token\n";
unless ( fork() ) {
exec("/home/battilo/scripts/inoltroViaApiElab.py \"$matlab_timestamp\" \"$unit\" \"$tool\" \"$inoltro_api_url\" \"$inoltro_api_bearer_token\" >> /home/asega/log/logInoltroViaApiElab.log 2>&1");
exit(0);
}
}
sub getNodesType {
my $dbh =
DBI->connect( "DBI:mysql:$db_lar;host=$server", $username, $password )
or die getTimeStamp("log")
. " - pid $$ >> Could not connect to database: $DBI::errstr";
my $sth = $dbh->prepare(
'select t.name as name, n.seq as seq, n.num as num, n.channels as channels, y.type as type, n.ain as ain, n.din as din
my $sth = $dbh->prepare('select t.name as name, n.seq as seq, n.num as num, n.channels as channels, y.type as type, n.ain as ain, n.din as din
from nodes as n
inner join tools as t on t.id = n.tool_id
inner join units as u on u.id = t.unit_id
@@ -261,6 +337,8 @@ sub getUdbPwd {
$sth->execute();
if ( $sth->rows eq 0 ) {
#$password = "laravel";
#$username = "ase_lar";
die getTimeStamp("log") . " - pid $$ >> No password selected.\n";
}
else {
@@ -283,8 +361,7 @@ sub getMatlabCmd {
or die getTimeStamp("log")
. " - pid $$ >> Could not connect to database: $DBI::errstr";
my $sth = $dbh->prepare(
'select m.matcall, t.ftp_send , t.unit_id, s.`desc` as statustools from matfuncs as m
my $sth = $dbh->prepare('select m.matcall, t.ftp_send , t.unit_id, s.`desc` as statustools, t.api_send, u.inoltro_api, u.inoltro_api_url, u.inoltro_api_bearer_token, IFNULL(u.duedate, "") as duedate from matfuncs as m
inner join tools as t on t.matfunc = m.id
inner join units as u on u.id = t.unit_id
inner join statustools as s on t.statustool_id = s.id
@@ -302,6 +379,11 @@ sub getMatlabCmd {
$ftp_send = $results->{'ftp_send'};
$unit_id = $results->{'unit_id'};
$tool_status = $results->{'statustools'};
$api_send = $results->{'api_send'};
$inoltro_api = $results->{'inoltro_api'};
$inoltro_api_url = $results->{'inoltro_api_url'};
$inoltro_api_bearer_token = $results->{'inoltro_api_bearer_token'};
$unit_duedate = $results->{'duedate'};
}
}
@@ -314,8 +396,8 @@ sub getMatlabCmd {
sub makeEmailMsg {
$email_msg = <<"END_MSG";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@@ -363,6 +445,8 @@ END_MSG
sub emailSend {
$email_obj = 'Matlab error on unit ' . $unit . ' - tool ' . $tool;
#print getTimeStamp("log") . " - pid $$ >> $email_msg\n";
#print getTimeStamp("log") . " - pid $$ >> $email_obj\n";
my $msg = MIME::Lite->new(
From => $from,
To => $email_addr,
@@ -370,17 +454,9 @@ sub emailSend {
Data => $email_msg
);
#AuthUser => "alert\@aseltd.eu", #AuthPass => "Ase#2013!20\@bat",
$msg->attr( "content-type" => "text/html" );
if (
$msg->send(
'smtp', "smtps.aruba.it",
AuthUser => "alert\@aseltd.eu",
AuthPass => "Ase#2013!20\@bat",
Port => 465,
SSL => 1,
Debug => 0
)
)
if ($msg->send('smtp', "smtp.aseltd.eu", AuthUser => "alert\@aseltd.eu", AuthPass => "Ase#2013!20\@bat", Port => 587, Debug => 0))
{
print getTimeStamp("log") . " - pid $$ >> $email_obj\n";
print getTimeStamp("log") . " - pid $$ >> Mail sent to: $email_addr.\n";
@@ -393,36 +469,104 @@ sub emailSend {
my $starttime = getTimeStamp("log");
print "$starttime - pid $$ >> Start execution.\n";
GetOptions(
"filename=s" => \$filename,
"sqlout=s" => \$sqlout,
"dbname=s" => \$db_name
) or die("Error in command line arguments\n");
####### EDIT FILE PER ID0013 ##########
open FILE, $filename
or die( "Error: opening input file " . $filename . "\n" );
my ( $filecsvname, $path, $suffix ) = fileparse( $filename, qr/\.[^.]*/ );
if ( $filecsvname =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)_\d*$/i ) {
my @lines = <FILE>; # Read all lines of the file into an array
close(FILE) or die "Error closing1 $filename: $!"; # Close the file after reading all lines
( $fileDate, $fileTime ) = split( /\s/, $lines[0] ); # Assuming first line is File Creation Date
( $unittype, $unit ) = split( /\s/, uc $lines[1] ); # Extract unit from second line
$unit =~ s/;+$//; # Clean up the unit string
if ($unit eq "ID0013") { # Process only for unit "ID0013"
my $section_count = 0;
my $keep = 0;
my @filtered_lines;
my @current_section; # Temporarily store lines of the current section
for my $line (@lines) {
# Identify the start of a new section
if ($line =~ /^File Creation Date:/) {
$section_count++;
# If previous section was marked to be kept, store it
push @filtered_lines, @current_section if $keep;
# Reset section data
@current_section = ();
$keep = 0;
}
# Always store the current section's lines in a buffer
push @current_section, $line;
# If the SD path contains "/modb/", mark this section to be kept
if ($line =~ /SD path: .*?\/modb\//) {
$keep = 1;
}
}
# Ensure the last section is processed
push @filtered_lines, @current_section if $keep;
# Only modify the file if there are 2 or more sections
if ($section_count > 1) {
print getTimeStamp("log") . " - pid $$ >> (EDIT PER ID0013) Detected multiple sections ($section_count). Keeping only /modb/ section.\n";
# Rewrite the file with filtered content (only the relevant section)
open FILE, '>', $filename or die "Error: (EDIT PER ID0013) opening file for writing $filename: $!\n";
print FILE @filtered_lines;
close(FILE) or die "Error closing2 $filename: $!";
print getTimeStamp("log") . " - pid $$ >> File updated, only /modb/ section retained for ID0013.\n";
} else {
print getTimeStamp("log") . " - pid $$ >> Only one section found, no changes made to file.\n";
}
} else {
print getTimeStamp("log") . " - pid $$ >> Unit is not ID0013, continue normal processing.\n";
}
} else {
close(FILE) or die "Error closing3 $filename: $!";
}
######### NORMAL PROCESSING ###########
open FILE, $filename
or die( "Error: opening input file " . $filename . "\n" );
( $scriptname, $scriptpath ) = fileparse($0);
if ( $db_name ne 'asega' ) {
$db_name =~ s/aseu/dbn/;
#$db_name = "ase_lar";
$db_sp = $db_name;
#$db_sp = "ase_lar";
getUdbPwd();
#die getTimeStamp("log") . " - pid $$ >> debug dbname:".$db_name."\n";
$db_lar = $db_name;
#$db_lar = "ase_lar";
}
else {
$db_name = 'ase_lar';
}
my ( $filecsvname, $path, $suffix ) = fileparse( $filename, qr/\.[^.]*/ );
( $filecsvname, $path, $suffix ) = fileparse( $filename, qr/\.[^.]*/ );
if ( $filecsvname =~ m/^(\d\d_\d\d\d\d_|)(DT\d\d\d\d|LOC\d.*|GD\d*)_\d*$/i ) {
( $fileDate, $fileTime ) = split( /\s/, <FILE> );
( $unittype, $unit ) = split( /\s/, uc <FILE> );
$unit =~ s/;+$//;
if ($unit eq "ID0013") {#non mette dati e non fa elab se dentro i dt della id0013 c'è /mums/ nel path sd
my $offset_after_second_line = tell(FILE);#salva la posizione
my @linesTmp = <FILE>;
print getTimeStamp("log") . " - pid $$ >> DEBUG ID0013 - $linesTmp[3]\n";
#my ( $unused_iptext, $unused_ip ) = split( /\s/, $linesTmp[0] );
#my ( $unused_subnettext, $unused_subnet ) = split( /\s/, $linesTmp[1] );
#my ( $unused_gatewaytext, $unused_gatewayip ) = split( /\s/, $linesTmp[2] );
my ( $unused_sdtext, $unused_pathtext, $sd_path ) = split( /\s/, $linesTmp[3] );
if($sd_path =~ /\/mums\//){
print getTimeStamp("log") . " - pid $$ >> in path SD there is /mums/ for unit=$unit, sd_path=$sd_path EXITING the script\n";
close FILE;
exit; # Exit the script successfully
}
seek(FILE, $offset_after_second_line, 0);#torna alla posizione dopo la seconda riga letta
}
}
elsif ( $filecsvname =~ m/^G201_ID\d\d\d\d_DT\d\d\d\d_\d*_\d*$/i ) {
my @strings = $filecsvname =~
/(.{1,4})_(.{1,6})_(.{1,6})_(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
my @strings = $filecsvname =~ /(.{1,4})_(.{1,6})_(.{1,6})_(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
$unittype = $strings[0];
$unit = $strings[1];
$tool = $strings[2];
@@ -430,6 +574,81 @@ elsif ( $filecsvname =~ m/^G201_ID\d\d\d\d_DT\d\d\d\d_\d*_\d*$/i ) {
$fileTime = $strings[6] . ":" . $strings[7] . ":" . $strings[8];
$tooltype = 'MUX';
}
elsif ( $filecsvname =~ m/^G201_ID\d\d\d\d_DT\d\d\d\d\d*_\d*$/i ) {
my @strings = $filecsvname =~ /(.{1,4})_(.{1,6})_(.{1,6})(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
$unittype = $strings[0];
$unit = $strings[1];
$tool = $strings[2];
$fileDate = $strings[3] . "/" . $strings[4] . "/" . $strings[5];
$fileTime = $strings[6] . ":" . $strings[7] . ":" . $strings[8];
$tooltype = 'MUX';
}
elsif ( $filecsvname =~ m/^TLP_ID\d\d\d\d_DT\d\d\d\d_\d*_\d*$/i ) {
my @strings = $filecsvname =~ /(.{1,4})_(.{1,6})_(.{1,6})_(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
$unittype = $strings[0];
$unit = $strings[1];
$tool = $strings[2];
$fileDate = $strings[3] . "/" . $strings[4] . "/" . $strings[5];
$fileTime = $strings[6] . ":" . $strings[7] . ":" . $strings[8];
$tooltype = 'TLP';
}
elsif ( $filecsvname =~ m/^TLP_ID\d\d\d\d_DT\d\d\d\d\d*_\d*$/i ) {
my @strings = $filecsvname =~ /(.{1,4})_(.{1,6})_(.{1,6})(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
$unittype = $strings[0];
$unit = $strings[1];
$tool = $strings[2];
$fileDate = $strings[3] . "/" . $strings[4] . "/" . $strings[5];
$fileTime = $strings[6] . ":" . $strings[7] . ":" . $strings[8];
$tooltype = 'TLP';
}
elsif ( $filecsvname =~ m/^GS1_ID\d\d\d\d_DT\d\d\d\d_\d*_\d*$/i ) {
my @strings = $filecsvname =~ /(.{1,4})_(.{1,6})_(.{1,6})_(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
$unittype = $strings[0];
$unit = $strings[1];
$tool = $strings[2];
$fileDate = $strings[3] . "/" . $strings[4] . "/" . $strings[5];
$fileTime = $strings[6] . ":" . $strings[7] . ":" . $strings[8];
$tooltype = 'GS1';
if($unit eq "ID0273" && $tool eq "DT0001"){
$tool = "DT0002";
}
}
elsif ( $filecsvname =~ m/^GS1_ID\d\d\d\d_DT\d\d\d\d\d*_\d*$/i ) {
my @strings = $filecsvname =~ /(.{1,4})_(.{1,6})_(.{1,6})(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
$unittype = $strings[0];
$unit = $strings[1];
$tool = $strings[2];
$fileDate = $strings[3] . "/" . $strings[4] . "/" . $strings[5];
$fileTime = $strings[6] . ":" . $strings[7] . ":" . $strings[8];
$tooltype = 'GS1';
if($unit eq "ID0273" && $tool eq "DT0001"){
$tool = "DT0002";
}
}
elsif ( $filecsvname =~ m/^GS1_ID\d\d\d\d\d_DT\d\d\d\d_\d*_\d*$/i ) {#per id con 1 cifra in +
my @strings = $filecsvname =~ /(.{1,4})_(.{1,7})_(.{1,6})_(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
$unittype = $strings[0];
$unit = $strings[1];
$tool = $strings[2];
$fileDate = $strings[3] . "/" . $strings[4] . "/" . $strings[5];
$fileTime = $strings[6] . ":" . $strings[7] . ":" . $strings[8];
$tooltype = 'GS1';
if($unit eq "ID00279" && $tool eq "DT0008"){
$unit = "ID0279";
}
}
elsif ( $filecsvname =~ m/^GS1_ID\d\d\d\d\d_DT\d\d\d\d\d*_\d*$/i ) {#per id con 1 cifra in +
my @strings = $filecsvname =~ /(.{1,4})_(.{1,7})_(.{1,6})(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
$unittype = $strings[0];
$unit = $strings[1];
$tool = $strings[2];
$fileDate = $strings[3] . "/" . $strings[4] . "/" . $strings[5];
$fileTime = $strings[6] . ":" . $strings[7] . ":" . $strings[8];
$tooltype = 'GS1';
if($unit eq "ID00279" && $tool eq "DT0008"){
$unit = "ID0279";
}
}
elsif ( $filecsvname =~ m/^D2W_ID\d\d\d\d_DT\d\d\d\d_\d*$/i ) {
my @strings = $filecsvname =~ /(.{1,3})_(.{1,6})_(.{1,6}).*/;
$unittype = $strings[0];
@@ -444,6 +663,15 @@ elsif ( $filecsvname =~ m/^CR1000X_ID\d\d\d\d_DT\d\d\d\d_\d*$/i ) {
$tool = $strings[2];
$tooltype = 'CR1000X';
}
elsif ( $filecsvname =~ m/^Hortus_ID\d\d\d\d_DT\d\d\d\d_\d*_\d*$/i ) {
my @strings = $filecsvname =~ /(.{1,6})_(.{1,6})_(.{1,6})_(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2})_(.{1,4})(.{1,2})(.{1,2})(.{1,2})(.{1,2})(.{1,2}).*/;
$unittype = $strings[0];
$unit = $strings[1];
$tool = $strings[2];
$fileDate = $strings[3] . "/" . $strings[4] . "/" . $strings[5];
$fileTime = $strings[6] . ":" . $strings[7] . ":" . $strings[8];
$tooltype = 'CR1000X';
}
elsif ( $filecsvname =~ m/^(\d*_|)(G301_ID\d\d\d\d_DT\d\d\d\d_\d*)$/i ) {
my $filecsvname_clean =
substr( $filecsvname, index( $filecsvname, "G301" ) );
@@ -453,18 +681,39 @@ elsif ( $filecsvname =~ m/^(\d*_|)(G301_ID\d\d\d\d_DT\d\d\d\d_\d*)$/i ) {
$tool = $strings[2];
$tooltype = 'G301';
}
#print getTimeStamp("log") . " - pid $$ >> DEBUG SONO QUA!!!!!\n";
while ( my $line = <FILE> ) {
#if ( $line =~ m/\A [[:ascii:]]* \Z/xms ) {
#print getTimeStamp("log") . " - pid $$ >> DEBUG $unittype , $tooltype\n";
#print getTimeStamp("log") . " - pid $$ >> DEBUG !!!!!!! $line\n";
if ( $line !~ /\x00/ ) {
$line =~ tr /\,/\;/ if ( $line =~ m/^\"\d\d\d\d.*/i ); #CR1000X
$line =~ s/\"//g;
#print getTimeStamp("log") . " - pid $$ >> DEBUG line: $line\n";
my ( $first, $NodeData ) = split( /;/, $line, 2 );
#print getTimeStamp("log") . " - pid $$ >> DEBUG nodedata: $NodeData\n";
if ( defined $first and ( $first ne '' ) ) {
#print getTimeStamp("log") . " - pid $$ >> DEBUG first:" .$first ."\n";
$first =~ s/;+$//;
$first =~ tr /\-/\//;
#print getTimeStamp("log") . " - pid $$ >> DEBUG first: $first\n";
if ( ( $NodeData =~ m/^;+/ ) ) {#se bat e/o temp sono vuoti metto -1
#print getTimeStamp("log") . " - pid $$ >> DEBUG nodedata: $NodeData\n";
my (@batTempVuotiSplit) = split( /;/, $NodeData );
if($batTempVuotiSplit[0] eq "" || $batTempVuotiSplit[1] eq ""){
if($batTempVuotiSplit[0] eq ""){#bat
$batTempVuotiSplit[0] = "-1";
}
if($batTempVuotiSplit[1] eq ""){#temp
$batTempVuotiSplit[1] = "-273";
}
$NodeData = join(';', @batTempVuotiSplit);
#print getTimeStamp("log") . " - pid $$ >> DEBUG nodedata modificato: $NodeData\n";
}
}
if ( !defined $NodeData or ( $NodeData =~ m/^;+/ ) ) {
#print getTimeStamp("log") . " - pid $$ >> DEBUG NodeData3:" .$NodeData."\n";
my @info = ( split( /[\/,\.]/, $first ) );
if ( defined $info[3] && $info[3] =~ m/^DT\d\d\d\d$/i ) { #G801
$tool = uc $info[3];
@@ -502,6 +751,11 @@ while ( my $line = <FILE> ) {
print getTimeStamp("log")
. " - pid $$ >> Found $tooltype tool name: $tool\n";
}
elsif($unittype eq 'Hortus' and $tooltype eq 'CR1000X'){ #Hortus CR1000X
print getTimeStamp("log")
. " - pid $$ >> Found Hortus $tooltype tool name: $tool\n";
getNodesType();
}
}
else {
$NodeData =~ s/\x0d{0,1}\x0a\Z//s;
@@ -514,6 +768,18 @@ while ( my $line = <FILE> ) {
getNodesType();
$G201_fcheck = 1;
}
if ( $unittype eq 'TLP' and $TLP_fcheck eq 0 ) {
print getTimeStamp("log")
. " - pid $$ >> Found $tooltype tool name: $tool\n";
getNodesType();
$TLP_fcheck = 1;
}
if ( $unittype eq 'GS1' and $GS1_fcheck eq 0 ) {
print getTimeStamp("log")
. " - pid $$ >> Found $tooltype tool name: $tool\n";
getNodesType();
$GS1_fcheck = 1;
}
if ( $unittype eq 'D2W' and $D2W_fcheck eq 0 ) {
print getTimeStamp("log")
. " - pid $$ >> Found $tooltype tool name: $tool\n";
@@ -532,6 +798,11 @@ while ( my $line = <FILE> ) {
getNodesType();
$G301_fcheck = 1;
}
if($unittype eq 'Hortus' and $tooltype eq 'CR1000X'){ #Hortus CR1000X
print getTimeStamp("log")
. " - pid $$ >> Found Hortus $tooltype tool name: $tool\n";
getNodesType();
}
if ( $tooltype eq "MUX"
or $tooltype eq "D2W"
@@ -586,6 +857,8 @@ while ( my $line = <FILE> ) {
my $used_din = 0;
my $used_ain = 0;
for my $i ( 0 .. $#din ) {
#print getTimeStamp("log") . " - pid $$ >> DEBUG LOC din: ". $din[$i] ." ain1:".$Ain1." ain2:".$Ain2." din1:". $Din1. " din2:". $Din2. "\n";
#print getTimeStamp("log") . " - pid $$ >> DEBUG LOC ain: ". $ain[$i] ." ain1:".$Ain1." ain2:".$Ain2." din1:". $Din1. " din2:". $Din2. "\n";
if ( $din[$i] eq 1 ) {
if ( $used_din eq 0 ) {
$CSVData[ $idx++ ] = $Din1;
@@ -605,10 +878,14 @@ while ( my $line = <FILE> ) {
}
}
elsif ( $din[$i] eq 2 ) {
$CSVData[ $idx++ ] = $Din1 . ";" . $Din2;
#$CSVData[ $idx++ ] = $Din1 . ";" . $Din2;
#$CSVData[ $idx++ ] = $Din1;
$CSVData[ $idx++ ] = $Din2;
}
elsif ( $ain[$i] eq 2 ) {
$CSVData[ $idx++ ] = $Ain1 . ";" . $Ain2;
#$CSVData[ $idx++ ] = $Ain1 . ";" . $Ain2;
#$CSVData[ $idx++ ] = $Ain1;
$CSVData[ $idx++ ] = $Ain2;
}
else {
$CSVData[ $idx++ ] = "N/A";
@@ -630,46 +907,126 @@ while ( my $line = <FILE> ) {
. $h . ':'
. ( $min + 1 );
}
elsif( $tooltype eq "TLP") {
@NewData = grep /\S/, split( /\||;/, $NodeData );
if ( scalar(@NewData) != 0 ) {
my $idx = 0;
my $batTempPressione = join( ';', splice( @NewData, 0, 3 ) );#3 valori togliere il terzo e metterlo nell'ultimo nodo che dovrebbe essere sempre vuoto
my @batTempPressioneParts = split(/;/, $batTempPressione);
$CSVData[ $idx++ ] = join( ';', @batTempPressioneParts[0,1] );
#print "inzio\n";
#print $idx++."\n";
#print join( ';', @batTempPressioneParts[0,1] )."\n";
#print "inizio for\n";
foreach my $ch (@channels) {
$CSVData[ $idx++ ] = join( ';', splice( @NewData, 0, $ch ) );
#print $idx++."\n";
#print "canale: $ch\n";
#print join( ';', splice( @NewData, 0, $ch ) )."\n";
#print "fine giro\n";
}
$CSVData[ $idx ] = $batTempPressioneParts[2];
#print $batTempPressioneParts[2];
}
}
elsif( $tooltype eq "GS1") {
@NewData = grep /\S/, split( /\||;/, $NodeData );
if ( scalar(@NewData) != 0 ) {
my $idx = 0;
my $batTempPressione = join( ';', splice( @NewData, 0, 3 ) );#3 valori togliere il terzo e metterlo nell'ultimo nodo che dovrebbe essere sempre vuoto
my @batTempPressioneParts = split(/;/, $batTempPressione);
$CSVData[ $idx++ ] = join( ';', @batTempPressioneParts[0,1] );
#print "inzio\n";
#print $idx++."\n";
#print join( ';', @batTempPressioneParts[0,1] )."\n";
#print "inizio for\n";
foreach my $ch (@channels) {
$CSVData[ $idx++ ] = join( ';', splice( @NewData, 0, $ch ) );
#print $idx++."\n";
#print "canale: $ch\n";
#print join( ';', splice( @NewData, 0, $ch ) )."\n";
#print "fine giro\n";
}
$CSVData[ $idx ] = $batTempPressioneParts[2];
#print $batTempPressioneParts[2];
}
}
else {
@CSVData = split( /\|/, $NodeData );
}
my $nodenum = 0;
foreach (@CSVData) {
$sql[ ( $outcount % $maxsqllines ) ] = "";
my (@data) = grep { /\S/ } split( /\;/, $_ );
if ( $nodenum eq 0 ) {
$toolbatt = $data[0];
$tooltemp = $data[1];
#print getTimeStamp("log") . " - pid $$ >> CSVdata: ". $_ ."\n";
if($_ ne ""){
$sql[ ( $outcount % $maxsqllines ) ] = "";
my (@data) = grep { /\S/ } split( /\;/, $_ );
if ( $nodenum eq 0 ) {
#print getTimeStamp("log") . " - pid $$ >> DEBUG batt: ". $data[0] . " " . $data[1] ."\n";
$toolbatt = $data[0];
$tooltemp = $data[1];
}
else {
my ( $y, $m, $d, $t ) = split( /[\s\/]/, $first );
if ( length($y) != 4 )
{ # G201/G301 con la data invertita
my $w = $y;
$y = $d;
$m = sprintf( '%02d', $m );
$d = sprintf( '%02d', $w );
}
#print getTimeStamp("log") . " - pid $$ >> DEBUG data $y-$m-$d\n";
foreach (@data) {
if ( $sql[ ( $outcount % $maxsqllines ) ] eq "" ) {
$sql[ ( $outcount % $maxsqllines ) ] = "('$unit','$tool','$nodenum','$y-$m-$d','$t','$toolbatt','$tooltemp'";
}
$sql[ ( $outcount % $maxsqllines ) ] .= ",'" . $_ . "'";
}
my $InsCompl = ",NULL" x ( 15 - $#data );
$sql[ ( $outcount % $maxsqllines ) ] .= $InsCompl . ")";
if ( ++$outcount % $maxsqllines eq 0 ) {
$sql[ ( $outcount % $maxsqllines ) - 1 ] .= ";\n";
my $tool_status2 = "";
my $dbh2 = DBI->connect( "DBI:mysql:$db_lar;host=$server", $username, $password ) or die getTimeStamp("log") . " - pid $$ >> Could not connect to database: $DBI::errstr";
my $sth2 = $dbh2->prepare(
'select m.matcall, t.ftp_send , t.unit_id, s.`desc` as statustools from matfuncs as m
inner join tools as t on t.matfunc = m.id
inner join units as u on u.id = t.unit_id
inner join statustools as s on t.statustool_id = s.id
where t.name = "' . $tool . '" and u.name = "' . $unit . '";'
) or die getTimeStamp("log") . " - pid $$ >> $DBI::errstr";
$sth2->execute();
if ( $sth2->rows eq 0 ) {
die getTimeStamp("log")
. " - pid $$ >> Check tool status later - No tool's matlab function selected.\n";
}
else {
while ( my $results2 = $sth2->fetchrow_hashref ) {
$tool_status2 = $results2->{'statustools'};
}
}
$sth2->finish;
# Disconnect
$dbh2->disconnect;
if($tool_status2 eq "Test"){
print getTimeStamp("log") . " - pid $$ >> tool status: $tool_status2 nothing to do.\n";
}else{
if(($unit eq "ID0070" && $tool eq "DT0111") || ($unit eq "ID0071" && $tool eq "DT0112") || ($unit eq "ID0072" && $tool eq "DT0113") || ($unit eq "ID0073" && $tool eq "DT0114") || ($unit eq "ID0273" && $tool eq "DT0001") || ($unit eq "ID0279" && $tool eq "DT0008")){
modifyAndWriteOutSql($tool);
}
writeOutSql($tool);
}
}
else {
$sql[ ( $outcount % $maxsqllines ) - 1 ] .= ",\n";
}
}
$nodenum++;
}
else {
my ( $y, $m, $d, $t ) = split( /[\s\/]/, $first );
if ( length($y) != 4 )
{ # G201/G301 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 ) ] .=
",'" . $_ . "'";
}
my $InsCompl = ",NULL" x ( 15 - $#data );
$sql[ ( $outcount % $maxsqllines ) ] .= $InsCompl . ")";
if ( ++$outcount % $maxsqllines eq 0 ) {
$sql[ ( $outcount % $maxsqllines ) - 1 ] .= ";\n";
writeOutSql($tool);
}
else {
$sql[ ( $outcount % $maxsqllines ) - 1 ] .= ",\n";
}
}
$nodenum++;
}
}
}
@@ -677,29 +1034,151 @@ while ( my $line = <FILE> ) {
}
close FILE;
$sql[ ( $outcount % $maxsqllines ) - 1 ] =~ s/,$/;/g;
writeOutSql($tool);
my $tool_status3 = "";
#FTP INOLTRO RAW
my $inoltro_ftp_raw = 0;
my $ftp_send_raw = "";
my $ftp_mode_raw = "";
my $ftp_addrs_raw = "";
my $ftp_user_raw = "";
my $ftp_passwd_raw = "";
my $ftp_filename_raw = "";
my $ftp_target_raw = "";
#api raw
my $inoltro_api_raw = 0;
my $inoltro_api_url_raw = "";
my $inoltro_api_bearer_token_raw = "";
my $api_send_raw = 0;
#
my $dbh3 = DBI->connect( "DBI:mysql:$db_lar;host=$server", $username, $password ) or die getTimeStamp("log") . " - pid $$ >> Could not connect to database: $DBI::errstr";
my $sth3 = $dbh3->prepare(
'select m.matcall, t.ftp_send_raw, IFNULL(u.ftp_mode_raw, "") as ftp_mode_raw, IFNULL(u.ftp_addrs_raw, "") as ftp_addrs_raw, IFNULL(u.ftp_user_raw, "") as ftp_user_raw, IFNULL(u.ftp_passwd_raw, "") as ftp_passwd_raw, IFNULL(u.ftp_filename_raw, "") as ftp_filename_raw, IFNULL(u.ftp_parm_raw, "") as ftp_parm_raw, IFNULL(u.ftp_target_raw, "") as ftp_target_raw, t.unit_id, s.`desc` as statustools, u.inoltro_ftp_raw,
u.inoltro_api_raw, IFNULL(u.inoltro_api_url_raw, "") as inoltro_api_url_raw, IFNULL(u.inoltro_api_bearer_token_raw, "") as inoltro_api_bearer_token_raw, t.api_send_raw, IFNULL(u.duedate, "") as duedate from matfuncs as m
inner join tools as t on t.matfunc = m.id
inner join units as u on u.id = t.unit_id
inner join statustools as s on t.statustool_id = s.id
where t.name = "' . $tool . '" and u.name = "' . $unit . '";'
) or die getTimeStamp("log") . " - pid $$ >> $DBI::errstr";
$sth3->execute();
if ( $sth3->rows eq 0 ) {
die getTimeStamp("log")
. " - pid $$ >> Check tool status later - No tool's matlab function selected.\n";
}
else {
while ( my $results3 = $sth3->fetchrow_hashref ) {
$tool_status3 = $results3->{'statustools'};
$ftp_send_raw = $results3->{'ftp_send_raw'};
$ftp_mode_raw = $results3->{'ftp_mode_raw'};
$ftp_addrs_raw = $results3->{'ftp_addrs_raw'};
$ftp_user_raw = $results3->{'ftp_user_raw'};
$ftp_passwd_raw = $results3->{'ftp_passwd_raw'};
$ftp_filename_raw = $results3->{'ftp_filename_raw'};
$ftp_target_raw = $results3->{'ftp_target_raw'};
$inoltro_ftp_raw = $results3->{'inoltro_ftp_raw'};
#
$inoltro_api_raw = $results3->{'inoltro_api_raw'};
$inoltro_api_url_raw = $results3->{'inoltro_api_url_raw'};
$inoltro_api_bearer_token_raw = $results3->{'inoltro_api_bearer_token_raw'};
$api_send_raw = $results3->{'api_send_raw'};
#
$unit_duedate = $results3->{'duedate'};
}
}
$sth3->finish;
# Disconnect
$dbh3->disconnect;
#INOLTRO RAW CSV
print getTimeStamp("log") . " - pid $$ >> DEBUG inoltro RAW filename: $filename\n";
#print getTimeStamp("log") . " - pid $$ >> $ftp_send_raw $ftp_addrs_raw $ftp_user_raw $ftp_passwd_raw\n";
if($inoltro_ftp_raw eq 1 && $ftp_send_raw eq 1 && $ftp_addrs_raw ne "" && $ftp_user_raw ne "" && $ftp_passwd_raw ne ""){
if($ftp_target_raw eq ""){
$ftp_target_raw = "/";
}
print getTimeStamp("log") . " - pid $$ >> DEBUG inoltro RAW filenameraw: $ftp_filename_raw -- $tool\n";
if($ftp_filename_raw eq ""){
#print getTimeStamp("log") . " - pid $$ >> DEBUG inoltro RAW: 1\n";
$ftp_filename_raw = $filecsvname;
}else{
#print getTimeStamp("log") . " - pid $$ >> DEBUG inoltro RAW: 2 $filecsvname\n";
$ftp_filename_raw =~ s/\$tool/$filecsvname/g;
}
#$ftp_filename_raw = "test";
if (!defined $unit_duedate || $unit_duedate eq '' || $unit_duedate eq '0000-00-00 00:00:00') {
# duedate is empty or "0000-00-00 00:00:00", so proceed
print getTimeStamp("log") . " - pid $$ >> DEBUG inoltro RAW: /home/battilo/scripts/FTPCSVRAW_v2.sh $ftp_addrs_raw $ftp_target_raw $filename $ftp_filename_raw$suffix $ftp_user_raw $ftp_passwd_raw\n";
system("sh /home/battilo/scripts/FTPCSVRAW_v2.sh $ftp_addrs_raw $ftp_target_raw $filename $ftp_filename_raw$suffix $ftp_user_raw $ftp_passwd_raw");
} else {
my $duedateTmp1 = Time::Piece->strptime($unit_duedate, "%Y-%m-%d %H:%M:%S");
my $now1 = localtime;
if ($duedateTmp1 >= $now1) {
# duedate is valid and not expired, so proceed
print getTimeStamp("log") . " - pid $$ >> DEBUG inoltro RAW: /home/battilo/scripts/FTPCSVRAW_v2.sh $ftp_addrs_raw $ftp_target_raw $filename $ftp_filename_raw$suffix $ftp_user_raw $ftp_passwd_raw\n";
system("sh /home/battilo/scripts/FTPCSVRAW_v2.sh $ftp_addrs_raw $ftp_target_raw $filename $ftp_filename_raw$suffix $ftp_user_raw $ftp_passwd_raw");
}else{
print getTimeStamp("log") . " - pid $$ >> centralina ($filename) scaduta! no ftp inoltro raw.\n";
}
}
}
#INOLTRO RAW API
if($inoltro_api_raw eq 1 && $api_send_raw eq 1 && $inoltro_api_url_raw ne ""){
if (!defined $unit_duedate || $unit_duedate eq '' || $unit_duedate eq '0000-00-00 00:00:00') {
# duedate is empty or "0000-00-00 00:00:00", so proceed
print getTimeStamp("log") . " - pid $$ >> DEBUG inoltro RAW API: /home/battilo/scripts/inoltroViaApiRaw.py $filename $inoltro_api_url_raw $inoltro_api_bearer_token_raw\n";
exec("/home/battilo/scripts/inoltroViaApiRaw.py \"$filename\" \"$inoltro_api_url_raw\" \"$inoltro_api_bearer_token_raw\" >> /home/asega/log/logInoltroViaApiRaw.log 2>&1");
} else {
my $duedateTmp2 = Time::Piece->strptime($unit_duedate, "%Y-%m-%d %H:%M:%S");
my $now2 = localtime;
if ($duedateTmp2 >= $now2) {
# duedate is valid and not expired, so proceed
print getTimeStamp("log") . " - pid $$ >> DEBUG inoltro RAW API: /home/battilo/scripts/inoltroViaApiRaw.py $filename $inoltro_api_url_raw $inoltro_api_bearer_token_raw\n";
exec("/home/battilo/scripts/inoltroViaApiRaw.py \"$filename\" \"$inoltro_api_url_raw\" \"$inoltro_api_bearer_token_raw\" >> /home/asega/log/logInoltroViaApiRaw.log 2>&1");
}else{
print getTimeStamp("log") . " - pid $$ >> centralina ($filename) scaduta! no api inoltro raw.\n";
}
}
}
#
if($tool_status3 eq "Test"){
print getTimeStamp("log") . " - pid $$ >> tool status: $tool_status3 nothing to do.\n";
}else{#insert in RAW table
if(($unit eq "ID0070" && $tool eq "DT0111") || ($unit eq "ID0071" && $tool eq "DT0112") || ($unit eq "ID0072" && $tool eq "DT0113") || ($unit eq "ID0073" && $tool eq "DT0114") || ($unit eq "ID0273" && $tool eq "DT0001") || ($unit eq "ID0279" && $tool eq "DT0008")){
modifyAndWriteOutSql($tool);
}
writeOutSql($tool);
}
if ( $tooltype eq "GD" ) {
print getTimeStamp("log") . " - pid $$ >> tool GD: nothing to do.\n";
}
else {
getMatlabCmd();
print getTimeStamp("log")
. " - pid $$ >> $unit - $tool - Status $tool_status.\n";
if ( $tool_status eq 'Monitoring Completed' ) {
print getTimeStamp("log")
. " - pid $$ >> $unit - $tool - Monitoring completed: MatLab calc by-passed.\n";
}
else {
print getTimeStamp("log") . " - pid $$ >> $unit - $tool - Status $tool_status.\n";
if ( $tool_status eq 'Active' || $tool_status eq 'Manual Upload' ) {
matlabCalc();
if ($ftp_send) {
if ( $tool eq 'DT0076' ) {
sleep(600);
}
trxelab();
}
if($inoltro_api eq 1 && $api_send eq 1){
if (!defined $unit_duedate || $unit_duedate eq '' || $unit_duedate eq '0000-00-00 00:00:00') {
# duedate is empty or "0000-00-00 00:00:00", so proceed
trxelabApi();
} else {
my $duedateTmp = Time::Piece->strptime($unit_duedate, "%Y-%m-%d %H:%M:%S");
my $now = localtime;
if ($duedateTmp >= $now) {
# duedate is valid and not expired, so proceed
trxelabApi();
}else{
print getTimeStamp("log") . " - pid $$ >> $unit: scaduta! no api inoltro elab.\n";
}
}
}
}
else {
print getTimeStamp("log") . " - pid $$ >> $unit - $tool - $tool_status: MatLab calc by-passed.\n";
}
}