din e ain
This commit is contained in:
8
.vstags
8
.vstags
@@ -7,11 +7,11 @@
|
|||||||
checkCompanyDBGrant SetupNewComp.pl 124;" s
|
checkCompanyDBGrant SetupNewComp.pl 124;" s
|
||||||
checkCompanyDBSet SetupNewComp.pl 55;" s
|
checkCompanyDBSet SetupNewComp.pl 55;" s
|
||||||
emailSend AlertNotReceived.pl 81;" s
|
emailSend AlertNotReceived.pl 81;" s
|
||||||
emailSend LoadCSVData.pl 361;" s
|
emailSend LoadCSVData.pl 364;" s
|
||||||
emailSend prova_mail.pl 76;" s
|
emailSend prova_mail.pl 76;" s
|
||||||
generateRandomPassword SetupNewComp.pl 46;" s
|
generateRandomPassword SetupNewComp.pl 46;" s
|
||||||
getLoggingTime AlertNotReceived.pl 21;" s
|
getLoggingTime AlertNotReceived.pl 21;" s
|
||||||
getMatlabCmd LoadCSVData.pl 290;" s
|
getMatlabCmd LoadCSVData.pl 292;" s
|
||||||
getNodesType LoadCSVData.pl 233;" s
|
getNodesType LoadCSVData.pl 233;" s
|
||||||
getTimeStamp LoadCSVData.pl 49;" s
|
getTimeStamp LoadCSVData.pl 49;" s
|
||||||
getTimeStamp SetupNewComp.pl 26;" s
|
getTimeStamp SetupNewComp.pl 26;" s
|
||||||
@@ -19,11 +19,11 @@ getTimeStamp UnitCsvReceiverSmart.pl 14;" s
|
|||||||
getTimeStamp aruba/UnitCsvReceiverSmart.pl 15;" s
|
getTimeStamp aruba/UnitCsvReceiverSmart.pl 15;" s
|
||||||
getTimeStamp aruba/UnitCsvRetransmit.pl 14;" s
|
getTimeStamp aruba/UnitCsvRetransmit.pl 14;" s
|
||||||
getTimeStamp prova_mail.pl 17;" s
|
getTimeStamp prova_mail.pl 17;" s
|
||||||
getUdbPwd LoadCSVData.pl 266;" s
|
getUdbPwd LoadCSVData.pl 268;" s
|
||||||
getUnitName UnitCsvReceiverSmart.pl 28;" s
|
getUnitName UnitCsvReceiverSmart.pl 28;" s
|
||||||
getUnitName aruba/UnitCsvReceiverSmart.pl 29;" s
|
getUnitName aruba/UnitCsvReceiverSmart.pl 29;" s
|
||||||
makeEmailMsg AlertNotReceived.pl 28;" s
|
makeEmailMsg AlertNotReceived.pl 28;" s
|
||||||
makeEmailMsg LoadCSVData.pl 319;" s
|
makeEmailMsg LoadCSVData.pl 322;" s
|
||||||
makeEmailMsg prova_mail.pl 36;" s
|
makeEmailMsg prova_mail.pl 36;" s
|
||||||
matlabCalc LoadCSVData.pl 91;" s
|
matlabCalc LoadCSVData.pl 91;" s
|
||||||
setCompanyDBGrant SetupNewComp.pl 151;" s
|
setCompanyDBGrant SetupNewComp.pl 151;" s
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ sub writeOutSql {
|
|||||||
sub matlabCalc {
|
sub matlabCalc {
|
||||||
getMatlabCmd();
|
getMatlabCmd();
|
||||||
$matlab_timestamp = getTimeStamp("db_ts");
|
$matlab_timestamp = getTimeStamp("db_ts");
|
||||||
print getTimeStamp("log") . " - pid $$ >> $tool MatLab calc started...\n";
|
print getTimeStamp("log") . " - pid $$ >> $unit - $tool MatLab calc started...\n";
|
||||||
if ($matlab_cmd =~ /_lnx$/) {
|
if ($matlab_cmd =~ /_lnx$/) {
|
||||||
$matlab_cmd = './run_' . $matlab_cmd . '.sh';
|
$matlab_cmd = './run_' . $matlab_cmd . '.sh';
|
||||||
|
|
||||||
@@ -118,14 +118,14 @@ sub matlabCalc {
|
|||||||
$matlab_cmd = 'matlab_' . uc $matlab_cmd . '.cmd';
|
$matlab_cmd = 'matlab_' . uc $matlab_cmd . '.cmd';
|
||||||
my @out_matlab = `ssh1 $matlab_ip 'cmd /c $matlab_cmd ' $tool`;
|
my @out_matlab = `ssh1 $matlab_ip 'cmd /c $matlab_cmd ' $tool`;
|
||||||
if (index($out_matlab[-1], "Failure") != -1) {
|
if (index($out_matlab[-1], "Failure") != -1) {
|
||||||
print getTimeStamp("log"). " - pid $$ >> $tool MatLab calc failed.\n";
|
print getTimeStamp("log"). " - pid $$ >> $unit - $tool MatLab calc failed.\n";
|
||||||
makeEmailMsg();
|
makeEmailMsg();
|
||||||
emailSend();
|
emailSend();
|
||||||
print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
|
print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print getTimeStamp("log"). " - pid $$ >> $tool MatLab calc executed.\n";
|
print getTimeStamp("log"). " - pid $$ >> $unit - $tool MatLab calc executed.\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ sub trxelab {
|
|||||||
|
|
||||||
my $fileelab;
|
my $fileelab;
|
||||||
if ( $ftp_filename eq "" ) {
|
if ( $ftp_filename eq "" ) {
|
||||||
$fileelab ='/var/lib/mysql-files/'. $tool . '_'. getTimeStamp(). '.csv'; #mettere quello che si prende da query
|
$fileelab ='/var/lib/mysql-files/'. $tool . '_'. getTimeStamp(). '.csv'; #mettere quello che si prende da query *** aggiungere $unit
|
||||||
}else {
|
}else {
|
||||||
$ftp_filename =~ s/(\$\w+)/$1/eeg;
|
$ftp_filename =~ s/(\$\w+)/$1/eeg;
|
||||||
$ftp_filename =~ s/\s/_/g;
|
$ftp_filename =~ s/\s/_/g;
|
||||||
@@ -178,7 +178,7 @@ sub trxelab {
|
|||||||
XShift, YShift, ZShift , X, Y, Z, HShift, HShiftDir, HShift_local,
|
XShift, YShift, ZShift , X, Y, Z, HShift, HShiftDir, HShift_local,
|
||||||
speed, speed_local, acceleration, acceleration_local, T_node, water_level, pressure, load_value, AlfaX, AlfaY, calcerr
|
speed, speed_local, acceleration, acceleration_local, T_node, water_level, pressure, load_value, AlfaX, AlfaY, calcerr
|
||||||
from ElabDataView
|
from ElabDataView
|
||||||
where ToolNameID = '$tool' and updated_at > '$matlab_timestamp'
|
where UnitName = '$unit', ToolNameID = '$tool' and updated_at > '$matlab_timestamp'
|
||||||
order by ToolNameID DESC, EventDate, EventTime, convert(`NodeNum`, decimal) DESC
|
order by ToolNameID DESC, EventDate, EventTime, convert(`NodeNum`, decimal) DESC
|
||||||
) resulting_set
|
) resulting_set
|
||||||
into outfile '$fileelab'
|
into outfile '$fileelab'
|
||||||
@@ -198,7 +198,7 @@ sub trxelab {
|
|||||||
$ftp_parms{'Debug'} = 0;
|
$ftp_parms{'Debug'} = 0;
|
||||||
$ftp_parms{'Passive'} = 1;
|
$ftp_parms{'Passive'} = 1;
|
||||||
|
|
||||||
print getTimeStamp("log") . " - pid $$ >> $tool ftp parm:\n" . Dumper(%ftp_parms);
|
print getTimeStamp("log") . " - pid $$ >> $unit - $tool ftp parm:\n" . Dumper(%ftp_parms);
|
||||||
|
|
||||||
if ( !defined $duedate
|
if ( !defined $duedate
|
||||||
or($duedate eq '0000-00-00 00:00:00')
|
or($duedate eq '0000-00-00 00:00:00')
|
||||||
@@ -222,9 +222,9 @@ sub trxelab {
|
|||||||
print getTimeStamp("log"). " - pid $$ >> ftp target lists ". scalar @{ $ftp->ls() }. " elements.\n";
|
print getTimeStamp("log"). " - pid $$ >> ftp target lists ". scalar @{ $ftp->ls() }. " elements.\n";
|
||||||
|
|
||||||
$ftp->quit;
|
$ftp->quit;
|
||||||
print getTimeStamp("log"). " - pid $$ >> $tool: $fileelab ftp put executed.\n";
|
print getTimeStamp("log"). " - pid $$ >> $unit - $tool: $fileelab ftp put executed.\n";
|
||||||
} else {
|
} else {
|
||||||
print getTimeStamp("log"). " - pid $$ >> $tool: $fileelab ftp put didn't executed because due date reached.\n";
|
print getTimeStamp("log"). " - pid $$ >> $unit - $tool: $fileelab ftp put didn't executed because due date reached.\n";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -235,15 +235,16 @@ sub getNodesType {
|
|||||||
or die getTimeStamp("log"). " - pid $$ >> Could not connect to database: $DBI::errstr";
|
or die getTimeStamp("log"). " - pid $$ >> Could not connect to database: $DBI::errstr";
|
||||||
|
|
||||||
my $sth = $dbh->prepare(
|
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.din as din
|
'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
|
from nodes as n
|
||||||
inner join tools as t on t.id = n.tool_id
|
inner join tools as t on t.id = n.tool_id
|
||||||
|
inner join units as u on u.id = t.unit_id
|
||||||
inner join nodetypes as y on n.nodetype_id = y.id
|
inner join nodetypes as y on n.nodetype_id = y.id
|
||||||
where t.name = "' . $tool . '" order by 3;'
|
where t.name = "' . $tool . '" and u.name = "' . $unit . '" order by 3;'
|
||||||
) or die getTimeStamp("log") . " - pid $$ >> $DBI::errstr";
|
) or die getTimeStamp("log") . " - pid $$ >> $DBI::errstr";
|
||||||
|
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
print getTimeStamp("log"). " - pid $$ >> $tool: " . $sth->rows . " rows selected to get node type/din/channels.\n";
|
print getTimeStamp("log"). " - pid $$ >> $unit - $tool: " . $sth->rows . " rows selected to get node type/Ain/Din/channels.\n";
|
||||||
if ( $sth->rows < 0 ) {
|
if ( $sth->rows < 0 ) {
|
||||||
die getTimeStamp("log") . " - pid $$ >> No node channels selected.\n";
|
die getTimeStamp("log") . " - pid $$ >> No node channels selected.\n";
|
||||||
}else {
|
}else {
|
||||||
@@ -251,6 +252,7 @@ sub getNodesType {
|
|||||||
while ( my $results = $sth->fetchrow_hashref ) {
|
while ( my $results = $sth->fetchrow_hashref ) {
|
||||||
$channels[$row] = $results->{'channels'};
|
$channels[$row] = $results->{'channels'};
|
||||||
$nodetype[$row] = $results->{'type'};
|
$nodetype[$row] = $results->{'type'};
|
||||||
|
$ain[$row] = $results->{'ain'};
|
||||||
$din[ $row++ ] = $results->{'din'};
|
$din[ $row++ ] = $results->{'din'};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -294,7 +296,8 @@ sub getMatlabCmd {
|
|||||||
my $sth = $dbh->prepare(
|
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 from matfuncs as m
|
||||||
inner join tools as t on t.matfunc = m.id
|
inner join tools as t on t.matfunc = m.id
|
||||||
where t.name = "' . $tool . '" ;'
|
inner join units as u on u.id = t.unit_id
|
||||||
|
where t.name = "' . $tool . '" and u.name = "' . $unit . '";'
|
||||||
) or die getTimeStamp("log") . " - pid $$ >> $DBI::errstr";
|
) or die getTimeStamp("log") . " - pid $$ >> $DBI::errstr";
|
||||||
|
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
@@ -464,51 +467,49 @@ while ( my $line = <FILE> ) {
|
|||||||
#print Dumper \@din;
|
#print Dumper \@din;
|
||||||
|
|
||||||
}elsif ( $tooltype eq "LOC" ) {
|
}elsif ( $tooltype eq "LOC" ) {
|
||||||
if ( !defined $din[0] or ($din[0] eq '0') ) {
|
|
||||||
print getTimeStamp("log"). " - pid $$ >> Din not defined.\n";
|
|
||||||
print getTimeStamp("log"). " - pid $$ >> Execution ended.\n";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
my ( $Vbat, $Tmod, $Ain1, $Ain2, $Din1, $Din2 ) =
|
my ( $Vbat, $Tmod, $Ain1, $Ain2, $Din1, $Din2 ) =
|
||||||
split( /;/, $NodeData );
|
split( /;/, $NodeData );
|
||||||
|
|
||||||
my $idx = 0;
|
if ( scalar @din ) {
|
||||||
my ($chDin1, $chDin2) = split("", $channels[0]);
|
print getTimeStamp("log"). " - pid $$ >> Ain/Din not defined.\n";
|
||||||
|
print getTimeStamp("log"). " - pid $$ >> Execution ended.\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $idx = 0;
|
||||||
$CSVData[$idx++] = $Vbat . ";" . $Tmod;
|
$CSVData[$idx++] = $Vbat . ";" . $Tmod;
|
||||||
|
|
||||||
if ($din[0] eq '1') {
|
my $used_din = 0;
|
||||||
if ( ($chDin1 eq '1') and ($chDin2 eq '9') ) {
|
my $used_ain = 0;
|
||||||
|
for my $i (0 .. $#din){
|
||||||
|
if ($din[i] eq 1) {
|
||||||
|
if ($used_din eq 0) {
|
||||||
$CSVData[$idx++] = $Din1;
|
$CSVData[$idx++] = $Din1;
|
||||||
}elsif ( ($chDin1 eq '9') and ($chDin2 eq '1') ){
|
$used_din = 1;
|
||||||
$CSVData[$idx++] = $Din2;
|
|
||||||
}elsif ( ($chDin1 eq '2') and ($chDin2 eq '9') ){
|
|
||||||
$CSVData[$idx++] = $Din1 . ";" . $Ain1;
|
|
||||||
}elsif ( ($chDin1 eq '9') and ($chDin2 eq '2') ){
|
|
||||||
$CSVData[$idx++] = $Din2 . ";" . $Ain2;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
}elsif ($din[0] eq '2') {
|
|
||||||
if ( ($chDin1 eq '1') and ($chDin2 eq '1') ) {
|
|
||||||
$CSVData[$idx++] = $Din1;
|
|
||||||
$CSVData[$idx++] = $Din2;
|
$CSVData[$idx++] = $Din2;
|
||||||
}elsif ( ($chDin1 eq '2') and ($chDin2 eq '1') ){
|
|
||||||
$CSVData[$idx++] = $Din1 . ";" . $Ain1;
|
|
||||||
$CSVData[$idx++] = $Din2;
|
|
||||||
}elsif ( ($chDin1 eq '1') and ($chDin2 eq '2') ){
|
|
||||||
$CSVData[$idx++] = $Din1;
|
|
||||||
$CSVData[$idx++] = $Din1 . ";" . $Ain1;
|
|
||||||
}elsif ( ($chDin1 eq '2') and ($chDin2 eq '2') ){
|
|
||||||
$CSVData[$idx++] = $Din1 . ";" . $Ain1;
|
|
||||||
$CSVData[$idx++] = $Din2 . ";" . $Ain2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
elsif ($ain[i] eq 1) {
|
||||||
# $CSVData[1] = $Din1;
|
if ($used_ain eq 0) {
|
||||||
|
$CSVData[$idx++] = $Ain1;
|
||||||
|
$used_ain = 1;
|
||||||
}elsif ( $tooltype eq "GD" ) {
|
}
|
||||||
|
else {
|
||||||
|
$CSVData[$idx++] = $Ain2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ($din[i] eq 2) {
|
||||||
|
$CSVData[$idx++] = $Din1 . ";" . $Din2;
|
||||||
|
}
|
||||||
|
elsif ($ain[i] eq 2) {
|
||||||
|
$CSVData[$idx++] = $Ain1 . ";" . $Ain2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ( $tooltype eq "GD" ) {
|
||||||
my ( $div, $Vbat, $Tmod ) =
|
my ( $div, $Vbat, $Tmod ) =
|
||||||
split( /;/, $NodeData );
|
split( /;/, $NodeData );
|
||||||
$CSVData[0] = $Vbat . ";" . $Tmod;
|
$CSVData[0] = $Vbat . ";" . $Tmod;
|
||||||
@@ -553,7 +554,7 @@ while ( my $line = <FILE> ) {
|
|||||||
$nodenum++;
|
$nodenum++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close FILE;
|
close FILE;
|
||||||
$sql[ ( $outcount % $maxsqllines ) - 1 ] =~ s/,$/;/g;
|
$sql[ ( $outcount % $maxsqllines ) - 1 ] =~ s/,$/;/g;
|
||||||
@@ -562,6 +563,7 @@ if ( $tooltype eq "GD" ) {
|
|||||||
print getTimeStamp("log") . " - pid $$ >> tool GD: nothing to do.\n";
|
print getTimeStamp("log") . " - pid $$ >> tool GD: nothing to do.\n";
|
||||||
}else {
|
}else {
|
||||||
matlabCalc();
|
matlabCalc();
|
||||||
|
|
||||||
if ($ftp_send) {
|
if ($ftp_send) {
|
||||||
if ( $tool eq 'DT0076' ) {
|
if ( $tool eq 'DT0076' ) {
|
||||||
sleep(600);
|
sleep(600);
|
||||||
|
|||||||
Reference in New Issue
Block a user