diff --git a/LoadCSVData.pl b/LoadCSVData.pl
index 46e19f8..9e790a0 100755
--- a/LoadCSVData.pl
+++ b/LoadCSVData.pl
@@ -122,76 +122,69 @@ sub writeOutSql {
}
sub matlabCalc {
- getMatlabCmd();
- if ( $tool_status eq 'Monitoring Completed' ) {
+
+ $matlab_timestamp = getTimeStamp("db_ts");
+ 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";
+
+ #print $ENV{"HOME"} . "\n";
+ $ENV{"HOME"} = "/" . $ENV{"HOME"};
+ chdir($matlab_func_dir)
+ or die "cannot change: $!\n";
print getTimeStamp("log")
- . " - pid $$ >> $unit - $tool - Monitoring completed: MatLab calc by-passed.\n";
+ . " - pid $$ >> current dir: $matlab_func_dir\n";
+ my @args =
+ ( 'timeout', $matlab_timeout, $matlab_cmd, $matlab_rt, $unit, $tool );
+ if ( system(@args) != 0 ) {
+ open( my $fh, '<', $MatlabErrorFilename )
+ or warn print getTimeStamp("log")
+ . " - pid $$ >> Cannot open Matlab output error file: ${MatlabErrorFilename}\n";
+ {
+ chomp( @matlabOutputErrorArray = <$fh> );
+ }
+ close($fh);
+ @matlabOutputErrorArray = grep( /\S/, @matlabOutputErrorArray );
+ @errors = grep( /^Error/, @matlabOutputErrorArray );
+ @warnings = grep( !/^Error/, @matlabOutputErrorArray );
+ $MatlabErrors = join( "
", @errors );
+ $MatlabWarnings = join( "
", uniq(@warnings) );
+ my $exit_value = $? >> 8;
+
+ 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";
+ }
+ else {
+ print getTimeStamp("log")
+ . " - pid $$ >> system @args failed: return code $exit_value - $?\n";
+ $matlab_error = "Matlab elab failed: $exit_value - $?";
+ }
+ makeEmailMsg();
+ emailSend();
+ print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
+ exit(1);
+ }
}
else {
- $matlab_timestamp = getTimeStamp("db_ts");
- 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";
-
- #print $ENV{"HOME"} . "\n";
- $ENV{"HOME"} = "/" . $ENV{"HOME"};
- chdir($matlab_func_dir)
- or die "cannot change: $!\n";
+ $matlab_cmd = 'matlab_' . uc $matlab_cmd . '.cmd';
+ my @out_matlab = `ssh1 $matlab_ip 'cmd /c $matlab_cmd ' $tool`;
+ if ( index( $out_matlab[-1], "Failure" ) != -1 ) {
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 ) {
- open( my $fh, '<', $MatlabErrorFilename )
- or warn print getTimeStamp("log")
- . " - pid $$ >> Cannot open Matlab output error file: ${MatlabErrorFilename}\n";
- {
- chomp( @matlabOutputErrorArray = <$fh> );
- }
- close($fh);
- @matlabOutputErrorArray = grep( /\S/, @matlabOutputErrorArray );
- @errors = grep( /^Error/, @matlabOutputErrorArray );
- @warnings = grep( !/^Error/, @matlabOutputErrorArray );
- $MatlabErrors = join( "
", @errors );
- $MatlabWarnings = join( "
", uniq(@warnings) );
- my $exit_value = $? >> 8;
-
- 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";
- }
- else {
- print getTimeStamp("log")
- . " - pid $$ >> system @args failed: return code $exit_value - $?\n";
- $matlab_error = "Matlab elab failed: $exit_value - $?";
- }
- makeEmailMsg();
- emailSend();
- print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
- exit(1);
- }
+ . " - pid $$ >> $unit - $tool MatLab calc failed.\n";
+ makeEmailMsg();
+ emailSend();
+ print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
+ exit(1);
}
- else {
- $matlab_cmd = 'matlab_' . uc $matlab_cmd . '.cmd';
- my @out_matlab = `ssh1 $matlab_ip 'cmd /c $matlab_cmd ' $tool`;
- if ( index( $out_matlab[-1], "Failure" ) != -1 ) {
- print getTimeStamp("log")
- . " - pid $$ >> $unit - $tool MatLab calc failed.\n";
- makeEmailMsg();
- emailSend();
- print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
- exit(1);
- }
- }
- print getTimeStamp("log")
- . " - pid $$ >> $unit - $tool MatLab calc executed.\n";
}
+ print getTimeStamp("log")
+ . " - pid $$ >> $unit - $tool MatLab calc executed.\n";
+
return;
}
@@ -292,9 +285,10 @@ sub getMatlabCmd {
. " - pid $$ >> Could not connect to database: $DBI::errstr";
my $sth = $dbh->prepare(
- 'select m.matcall, t.ftp_send , t.unit_id from matfuncs as m
+'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";
@@ -627,13 +621,24 @@ if ( $tooltype eq "GD" ) {
print getTimeStamp("log") . " - pid $$ >> tool GD: nothing to do.\n";
}
else {
- matlabCalc();
- if ($ftp_send) {
- if ( $tool eq 'DT0076' ) {
- sleep(600);
+ 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 {
+
+ matlabCalc();
+
+ if ($ftp_send) {
+ if ( $tool eq 'DT0076' ) {
+ sleep(600);
+ }
+ trxelab();
}
- trxelab();
}
}