734 lines
34 KiB
Matlab
Executable File
734 lines
34 KiB
Matlab
Executable File
% Funzione che legge i valori di calibrazione per i vari sensori
|
|
|
|
function [DCalTLTot,DCalHDTot,DCalHDVRTot,DCalTLHRTot,DCalTLHTot,DCalTLHRHTot,DCalPLTot,DCalBLTot,...
|
|
DCalALTot,DCalLLTot,DCalKLTot,DCalKLHRTot,DCalRLTot,DCalThLTot,DCalPT100Tot,...
|
|
DCalIPLTot,DCalIPLHRTot,DCalWLTot,DCalPETot,Barometri,yesTL,yesHD,yesHDVR,yesTLHR,yesTLH,...
|
|
yesTLHRH,yesPL,yesBL,yesAL,yesLL,yesKL,yesKLHR,yesThL,yesPT100,yesIPL,yesIPLHR,yesWL] = ...
|
|
letturaCal(IDcentralina,DTcatena,catena,yesTL,yesHD,yesHDVR,yesTLHR,yesTLH,yesTLHRH,...
|
|
yesPL,yesBL,yesAL,yesLL,yesKL,yesKLHR,yesThL,yesPT100,yesIPL,yesIPLHR,yesWL,...
|
|
rTL,rHD,rHDVR,rPL,rBL,rTLHR,rAL,rTLH,rTLHRH,rLL,rThL,rKL,rKLHR,rRL,rPT100,rIPL,rIPLHR,...
|
|
rWL,rPE,NodoTiltLink,NodoTiltLinkHD,NodoTiltLinkHDVR,NodoTiltLinkH,NodoPiezoLink,NodoBaroLink,...
|
|
NodoLoadLink,NodoKlinoLink,NodoKlinoLinkHR,NodoInPlaceLink,NodoInPlaceLinkHR,NodoWeirLink,...
|
|
NodoPendulum,NodoRainLink,NodoThermLink,conn,FileName)
|
|
|
|
fileID = fopen(FileName,'a');
|
|
fmt = '%s \r';
|
|
text = 'letturaCal function started';
|
|
fprintf(fileID,fmt,text);
|
|
|
|
[rC,~] = size(catena);
|
|
idNodo = cell2mat(catena(:,1));
|
|
if isempty(NodoTiltLink) == 1
|
|
DCalTLTot = [];
|
|
else
|
|
if strcmp(NodoTiltLink(1,4),'ADC') || strcmp(NodoTiltLink(1,4),'null') || isempty(NodoTiltLink(1,4)) == 1
|
|
DCalTLTot = cell(rTL,14);
|
|
elseif strcmp(NodoTiltLink(1,4),'g')
|
|
DCalTLTot = cell(rTL,3);
|
|
end
|
|
end
|
|
|
|
if isempty(NodoTiltLinkHD) == 1
|
|
DCalHDTot = [];
|
|
else
|
|
DCalHDTot = cell(rHD,3);
|
|
end
|
|
|
|
if isempty(NodoTiltLinkHDVR) == 1
|
|
DCalHDVRTot = [];
|
|
else
|
|
DCalHDVRTot = cell(rHDVR,3);
|
|
end
|
|
|
|
DCalTLHRTot = cell(rTLHR,4); % matrice che concatena i dati relativi a ciascun nodo Tilt Link HR V
|
|
|
|
if isempty(NodoTiltLinkH) == 1
|
|
DCalTLHTot = [];
|
|
else
|
|
if strcmp(NodoTiltLinkH(1,4),'ADC') || strcmp(NodoTiltLinkH{1,4},'null') || isempty(NodoTiltLinkH{1,4}) == 1
|
|
DCalTLHTot = cell(rTLH,11);
|
|
elseif strcmp(NodoTiltLinkH(1,4),'Gradi') || strcmp(NodoTiltLinkH(1,4),'g')
|
|
DCalTLHTot = [];
|
|
end
|
|
end
|
|
|
|
DCalTLHRHTot = cell(rTLHRH,4); % matrice che concatena i dati relativi a ciascun nodo Tilt Link HR H
|
|
|
|
if isempty(NodoPiezoLink) == 1
|
|
DCalPLTot = [];
|
|
else
|
|
if strcmp(NodoPiezoLink(1,4),'VW kg/cm2') == 1
|
|
DCalPLTot = cell(rPL,3); % matrice che concatena i dati relativi a ciascun nodo Piezo Link [VW]
|
|
elseif strcmp(NodoPiezoLink(1,4),'VW kPa') == 1
|
|
DCalPLTot = cell(rPL,4); % matrice che concatena i dati relativi a ciascun nodo Piezo Link MUMS
|
|
else
|
|
DCalPLTot = cell(rPL,5); % matrice che concatena i dati relativi a ciascun nodo Piezo Link MUMS
|
|
end
|
|
end
|
|
|
|
if isempty(NodoBaroLink) == 1
|
|
DCalBLTot = [];
|
|
elseif strcmp(NodoBaroLink(1,4),'hPa') == 1
|
|
DCalBLTot = [];
|
|
elseif strcmp(NodoBaroLink{1,4},'null') || isempty(NodoBaroLink{1,4}) == 1 || strcmp(NodoBaroLink(1,4),'ADC') == 1
|
|
DCalBLTot = cell(rBL,4); % matrice che concatena i dati relativi a ciascun nodo Baro Link
|
|
end
|
|
|
|
DCalALTot = cell(rAL,4); % matrice che concatena i dati relativi a ciascun nodo Analog Link
|
|
|
|
if isempty(NodoLoadLink) == 1
|
|
DCalLLTot = [];
|
|
else
|
|
if strcmp(NodoLoadLink(1,4),'4-20 mA')
|
|
DCalLLTot = cell(rLL,3); % matrice che concatena i dati relativi a ciascun nodo Load Link [4-20mA]
|
|
elseif strcmp(NodoLoadLink(1,4),'mV/V') || strcmp(NodoLoadLink(1,4),'ADC')
|
|
DCalLLTot = cell(rLL,2); % matrice che concatena i dati relativi a ciascun nodo Load Link [mV/V]
|
|
end
|
|
end
|
|
|
|
if isempty(NodoThermLink) == 1
|
|
DCalThLTot = [];
|
|
elseif strcmp(NodoThermLink{1,4},'null') || isempty(NodoThermLink{1,4}) == 1 || strcmp(NodoThermLink(1,4),'ADC') == 1
|
|
DCalThLTot = cell(rThL,2); % matrice che concatena i dati relativi a ciascun nodo Therm Link
|
|
elseif strcmp(NodoThermLink{1,4},'°C')
|
|
DCalThLTot = [];
|
|
end
|
|
|
|
if isempty(NodoKlinoLink) == 1
|
|
DCalKLTot = [];
|
|
else
|
|
if strcmp(NodoKlinoLink(1,4),'ADC') || strcmp(NodoKlinoLink{1,4},'null') || isempty(NodoKlinoLink{1,4}) == 1
|
|
DCalKLTot = cell(rKL,11); % matrice che concatena i dati relativi a ciascun nodo Klino Link
|
|
elseif strcmp(NodoKlinoLink(1,4),'digit')
|
|
DCalKLTot = cell(rKL,6); % matrice che concatena i dati relativi a ciascun nodo Klino Link
|
|
elseif strcmp(NodoKlinoLink(1,4),'Gradi')
|
|
DCalKLTot = [];
|
|
elseif strcmp(NodoKlinoLink(1,4),'g')
|
|
DCalKLTot = [];
|
|
end
|
|
end
|
|
|
|
if isempty(NodoKlinoLinkHR) == 1
|
|
DCalKLHRTot = [];
|
|
else
|
|
if strcmp(NodoKlinoLinkHR(1,4),'ADC') || strcmp(NodoKlinoLinkHR{1,4},'null') || isempty(NodoKlinoLinkHR{1,4}) == 1
|
|
DCalKLHRTot = cell(rKLHR,6); % matrice che concatena i dati relativi a ciascun nodo Klino Link
|
|
elseif strcmp(NodoKlinoLinkHR(1,4),'digit')
|
|
DCalKLHRTot = cell(rKLHR,6); % matrice che concatena i dati relativi a ciascun nodo Klino Link
|
|
end
|
|
end
|
|
|
|
DCalRLTot = cell(rRL,1); % matrice che concatena i dati relativi a ciascun nodo Rain Link
|
|
|
|
DCalPT100Tot = cell(rPT100,2); % matrice che concatena i dati relativi a ciascun nodo PT100 Link
|
|
|
|
if isempty(NodoInPlaceLink) == 1
|
|
DCalIPLTot = [];
|
|
else
|
|
if strcmp(NodoInPlaceLink(1,4),'ADC') || strcmp(NodoInPlaceLink{1,4},'null') || isempty(NodoInPlaceLink{1,4}) == 1
|
|
DCalIPLTot = cell(rIPL,14);
|
|
elseif strcmp(NodoInPlaceLink(1,4),'digit')
|
|
DCalIPLTot = cell(rIPL,6);
|
|
elseif strcmp(NodoInPlaceLink(1,4),'0-10 V')
|
|
DCalIPLTot = cell(rIPL,9);
|
|
elseif strcmp(NodoInPlaceLink(1,4),'g') || strcmp(NodoInPlaceLink(1,4),'Gradi')
|
|
DCalIPLTot = [];
|
|
end
|
|
end
|
|
|
|
if isempty(NodoInPlaceLinkHR) == 1
|
|
DCalIPLHRTot = [];
|
|
else
|
|
if strcmp(NodoInPlaceLinkHR(1,4),'ADC') || strcmp(NodoInPlaceLinkHR{1,4},'null') || isempty(NodoInPlaceLinkHR{1,4}) == 1
|
|
DCalIPLHRTot = cell(rIPLHR,4); % matrice che concatena i dati relativi a ciascun nodo In Place Link HR
|
|
elseif strcmp(NodoInPlaceLinkHR(1,4),'digit')
|
|
DCalIPLHRTot = cell(rIPLHR,6); % matrice che concatena i dati relativi a ciascun nodo Klino Link
|
|
end
|
|
end
|
|
if isempty(NodoWeirLink) == 1
|
|
DCalWLTot = [];
|
|
else
|
|
if strcmp(NodoWeirLink(1,4),'Hz') == 1
|
|
DCalWLTot = cell(rWL,3);
|
|
else
|
|
DCalWLTot = cell(rWL,2);
|
|
end
|
|
end
|
|
if isempty(NodoPendulum) == 1
|
|
DCalPETot = [];
|
|
else
|
|
if strcmp(NodoPendulum(1,4),'4-20 mA') == 1
|
|
DCalPETot = cell(rPE,1);
|
|
else
|
|
DCalPETot = [];
|
|
end
|
|
end
|
|
|
|
% Matrice con testi di conferma lettura o warning di lettura per le varie tipologie di nodi
|
|
TL = 1;
|
|
HD = 1;
|
|
HDVR = 1;
|
|
TLHR = 1;
|
|
PL = 1;
|
|
BL = 1;
|
|
TLH = 1;
|
|
TLHRH = 1;
|
|
AL = 1;
|
|
LL = 1;
|
|
ThL = 1;
|
|
KL = 1;
|
|
KLHR = 1;
|
|
RL = 1;
|
|
PT100 = 1;
|
|
IPL = 1;
|
|
IPLHR = 1;
|
|
WL = 1;
|
|
PE = 1;
|
|
|
|
for a = 1:rC
|
|
nNodo = mat2str(cell2mat(catena(a,3)));
|
|
|
|
if idNodo(a,1) == 1 % Tilt Link V
|
|
if strcmp(NodoTiltLink(1,4),'ADC') || strcmp(NodoTiltLink{1,4},'null') || isempty(NodoTiltLink{1,4}) == 1
|
|
%% Importazione dei dati di calibrazione per Tilt Link V
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4, Cal5, Cal6, Cal7, Cal8, CalA, CalB, CalC, CalD, CalE '...
|
|
'from CalibrationView where UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
elseif strcmp(NodoTiltLink(1,4),'g')
|
|
comando = ['select CalC, CalD, CalE from CalibrationView where UnitName = ''' IDcentralina ''' and ToolNameID = ''' ...
|
|
DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
end
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalTL = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Tilt Link V
|
|
[rr,cc] = size(DCalTL);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Tilt Link V number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesTL = 0;
|
|
else
|
|
DCalTLTot(TL,:) = DCalTL;
|
|
TL = TL+1;
|
|
ok = ['Calibration parameters of node Tilt Link V number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 67 % Tilt Link HD
|
|
if cell2mat(NodoTiltLinkHD(HD,5)) == 1
|
|
comando = ['select CalC, CalD, CalE from CalibrationView where UnitName = ''' ...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalHD = curs.Data;
|
|
[rr,cc] = size(DCalHD);
|
|
if rr==1 && cc==1 || isnan(cell2mat(DCalHD(1))) == 1
|
|
w = ['Warning: there was an error reading calibration values of node Tilt Link HD number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
DCalHDTot(HD,:) = num2cell(0);
|
|
else
|
|
DCalHDTot(HD,:) = DCalHD;
|
|
ok = ['Calibration parameters of node Tilt Link HD number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
HD = HD+1;
|
|
end
|
|
|
|
elseif idNodo(a,1) == 61 % Tilt Link HD VR
|
|
if cell2mat(NodoTiltLinkHDVR(HDVR,5)) == 1
|
|
comando = ['select CalC, CalD, CalE from CalibrationView where UnitName = ''' ...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalHDVR = curs.Data;
|
|
[rr,cc] = size(DCalHDVR);
|
|
if rr==1 && cc==1 || isnan(cell2mat(DCalHDVR(1))) == 1
|
|
w = ['Warning: there was an error reading calibration values of node Tilt Link HD VR number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
DCalHDVRTot(HDVR,:) = num2cell(0);
|
|
else
|
|
DCalHDVRTot(HDVR,:) = DCalHDVR;
|
|
ok = ['Calibration parameters of node Tilt Link HD VR number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
HDVR = HDVR+1;
|
|
end
|
|
|
|
elseif idNodo(a,1) == 11 % Tilt Link H
|
|
if strcmp(NodoTiltLinkH(1,4),'ADC') || strcmp(NodoTiltLinkH{1,4},'null') || isempty(NodoTiltLinkH{1,4}) == 1
|
|
%% Importazione dei dati di calibrazione per Tilt link H
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4, Cal5, Cal6, Cal7, Cal8, CalA, CalB from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalTLH = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Tilt Link H
|
|
[rr,cc] = size(DCalTLH);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Tilt Link H number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesTLH = 0;
|
|
else
|
|
DCalTLHTot(TLH,:) = DCalTLH;
|
|
TLH = TLH+1;
|
|
ok = ['Calibration parameters of node Tilt Link H number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
else
|
|
ok = ['Calibration parameters of node Tilt Link H number ' nNodo ' unnecessary'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 2 % Piezo Link
|
|
%% Importazione dei dati di calibrazione per Piezo Link
|
|
if strcmp(NodoPiezoLink(1,4),'VW kPa') == 1 || strcmp(NodoPiezoLink(1,4),'VW kg/cm2') == 1
|
|
comando = ['select Cal0, Cal1, Cal2 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
colonne = 3;
|
|
else
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
colonne = 4;
|
|
end
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalPL = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Piezo Link
|
|
[rr,cc] = size(DCalPL);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Piezo Link number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesPL = 0;
|
|
else
|
|
if strcmp(NodoPiezoLink(1,4),'VW kPa') == 1
|
|
if cell2mat(DCalPL(1,3)) == 0
|
|
comando = ['select Cal3 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalPL_T = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Piezo Link
|
|
DCalPL = [DCalPL DCalPL_T];
|
|
colonne = 4;
|
|
end
|
|
end
|
|
if colonne == 3
|
|
DCalPLTot(PL,1:3) = DCalPL;
|
|
DCalPLTot(PL,4) = num2cell(0);
|
|
else
|
|
DCalPLTot(PL,:) = DCalPL;
|
|
end
|
|
PL = PL+1;
|
|
ok = ['Calibration parameters of node Piezo Link number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 3 % Baro Link
|
|
if strcmp(NodoBaroLink(1,4),'hPa') == 1
|
|
else
|
|
%% Importazione dei dati di calibrazione per Baro link
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalBL = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Baro Link
|
|
[rr,cc] = size(DCalBL);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Baro Link number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesBL = 0;
|
|
else
|
|
DCalBLTot(BL,:) = DCalBL;
|
|
BL = BL+1;
|
|
ok = ['Calibration parameters of node Baro Link number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
end
|
|
|
|
elseif idNodo(a,1) == 4 % Therm Link
|
|
if strcmp(NodoThermLink{1,4},'°C')
|
|
else
|
|
%% Importazione dei dati di calibrazione per Therm link
|
|
comando = ['select Cal0, Cal1 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalThL = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Therm Link
|
|
[rr,cc] = size(DCalThL);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Therm Link number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesThL = 0;
|
|
else
|
|
DCalThLTot(ThL,:) = DCalThL;
|
|
ThL = ThL+1;
|
|
ok = ['Calibration parameters of node Therm Link number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
end
|
|
|
|
elseif idNodo(a,1) == 5 % Tilt Link HR V
|
|
%% Importazione dei dati di calibrazione per Tilt Link HR V
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalTLHR = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Tilt Link HR
|
|
[rr,cc] = size(DCalTLHR);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Tilt Link HR V number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesTLHR = 0;
|
|
else
|
|
if isnan(cell2mat(DCalTLHR(1,4))) == 1 % Ampolle con guadagno unico per asse X e asse Y
|
|
DCalTLHRTot(TLHR,1:4) = [DCalTLHR(1,1:3) 0];
|
|
else
|
|
DCalTLHRTot(TLHR,:) = DCalTLHR;
|
|
end
|
|
TLHR = TLHR+1;
|
|
ok = ['Calibration parameters of node Tilt Link HR V number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 12 % Tilt Link HR H
|
|
%% Importazione dei dati di calibrazione per Tilt Link HR H
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalTLHRH = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Tilt Link HR H
|
|
[rr,cc] = size(DCalTLHRH);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Tilt Link HR H number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesTLHRH = 0;
|
|
else
|
|
DCalTLHRHTot(TLHRH,:) = DCalTLHRH;
|
|
TLHRH = TLHRH+1;
|
|
ok = ['Calibration parameters of node Tilt Link HR H number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 8 % Analog Link
|
|
%% Importazione dei dati di calibrazione per Analog Link
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''' '];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalAL = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Analog Link
|
|
[rr,cc] = size(DCalAL);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Analog Link number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesAL = 0;
|
|
else
|
|
DCalALTot(AL,:) = DCalAL;
|
|
AL = AL+1;
|
|
ok = ['Calibration parameters of node Analog Link number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 15 % Load Link
|
|
%% Importazione dei dati di calibrazione per Load Link
|
|
if strcmp(NodoLoadLink(1,4),'4-20 mA')
|
|
comando = ['select Cal0, Cal1, Cal2 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''' '];
|
|
elseif strcmp(NodoLoadLink(1,4),'mV/V') || strcmp(NodoLoadLink(1,4),'ADC')
|
|
comando = ['select Cal1, Cal2 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''' '];
|
|
end
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalLL = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Load Link
|
|
[rr,cc] = size(DCalLL);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Load Link number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesLL = 0;
|
|
else
|
|
DCalLLTot(LL,:) = DCalLL;
|
|
LL = LL+1;
|
|
ok = ['Calibration parameters of node Load Link number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 44 % Klino Link HR
|
|
%% Importazione dei dati di calibrazione per Klino Link HR
|
|
if strcmp(NodoKlinoLinkHR(1,4),'ADC') || strcmp(NodoKlinoLinkHR{1,4} ,'null') || isempty(NodoKlinoLinkHR{1,4}) == 1
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4, Cal5 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
elseif strcmp(NodoKlinoLinkHR{1,4} ,'digit')
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4, Cal5 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
end
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalKLHR = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Klino Link
|
|
[rr,cc] = size(DCalKLHR);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Klino Link HR number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesKLHR = 0;
|
|
else
|
|
DCalKLHRTot(KLHR,:) = DCalKLHR;
|
|
KLHR = KLHR+1;
|
|
ok = ['Calibration of node Klino Link HR number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 26 % Klino Link
|
|
%% Importazione dei dati di calibrazione per Klino Link
|
|
if strcmp(NodoKlinoLink(1,4),'ADC') || strcmp(NodoKlinoLink{1,4} ,'null') || isempty(NodoKlinoLink{1,4}) == 1
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4, Cal5, Cal6, Cal7, Cal8, CalA, CalB from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalKL = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Klino Link
|
|
[rr,cc] = size(DCalKL);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Klino Link number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesKL = 0;
|
|
else
|
|
DCalKLTot(KL,:) = DCalKL;
|
|
KL = KL+1;
|
|
ok = ['Calibration of node Klino Link number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
else
|
|
ok = ['Calibration parameters of node Klino Link number ' nNodo ' unnecessary'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 27 % Rain Link
|
|
if strcmp(NodoRainLink(1,4),'mm')
|
|
DCalRLTot = [];
|
|
else
|
|
%% Importazione dei dati di calibrazione per Rain Link
|
|
comando = ['select Cal0 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalRL = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Rain Link
|
|
DCalRLTot(RL,:) = DCalRL;
|
|
RL = RL+1;
|
|
ok = ['Calibration parameters of node Rain Link number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 28 % PT100 Link
|
|
%% Importazione dei dati di calibrazione per PT100 Link
|
|
comando = ['select Cal0, Cal1 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalPT100 = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo PT100 Link
|
|
[rr,cc] = size(DCalPT100);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node PT100 Link number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesPT100 = 0;
|
|
else
|
|
DCalPT100Tot(PT100,:) = DCalPT100;
|
|
PT100 = PT100+1;
|
|
ok = ['Calibration parameters of node PT100 Link number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 42 % In Place Link
|
|
%% Importazione dei dati di calibrazione per In Place Link
|
|
if strcmp(NodoInPlaceLink(1,4),'ADC') || strcmp(NodoInPlaceLink{1,4} ,'null') || isempty(NodoInPlaceLink{1,4}) == 1
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4, Cal5, Cal6, Cal7, Cal8, CalA, CalB, CalC, CalD, CalE '...
|
|
'from CalibrationView where UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
esci = 0;
|
|
elseif strcmp(NodoInPlaceLink{1,4} ,'digit')
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4, Cal5 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
esci = 0;
|
|
elseif strcmp(NodoInPlaceLink(1,4),'0-10 V') == 1
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4, Cal5, Cal6, Cal7, Cal8 '...
|
|
'from CalibrationView where UnitName = ''' IDcentralina ''' and ToolNameID = ''' ...
|
|
DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
esci = 0;
|
|
else
|
|
ok = ['Calibration parameters of node In Place Link number ' nNodo ' unnecessary'];
|
|
fprintf(fileID,fmt,ok);
|
|
esci = 1;
|
|
end
|
|
if esci == 0
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalIPL = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo In Place Link
|
|
[rr,cc] = size(DCalIPL);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node In Place Link number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesIPL = 0;
|
|
else
|
|
DCalIPLTot(IPL,:) = DCalIPL;
|
|
IPL = IPL+1;
|
|
ok = ['Calibration parameters of node In Place Link number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
end
|
|
|
|
elseif idNodo(a,1) == 43 % In Place Link HR
|
|
%% Importazione dei dati di calibrazione per In Place Link HR
|
|
if strcmp(NodoInPlaceLinkHR(1,4),'ADC') || strcmp(NodoInPlaceLinkHR{1,4} ,'null') || isempty(NodoInPlaceLinkHR{1,4}) == 1
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
elseif strcmp(NodoInPlaceLinkHR{1,4} ,'digit')
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4, Cal5 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
|
end
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalIPLHR = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo In Place Link HR
|
|
[rr,cc] = size(DCalIPLHR);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node In Place Link HR number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesIPLHR = 0;
|
|
else
|
|
DCalIPLHRTot(IPLHR,:) = DCalIPLHR;
|
|
IPLHR = IPLHR+1;
|
|
ok = ['Calibration of node In Place Link HR number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 53 % Weir Link
|
|
%% Importazione dei dati di calibrazione per Weir Link
|
|
if strcmp(NodoWeirLink(1,4),'Hz')
|
|
comando = ['select Cal0, Cal1, Cal2 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''' '];
|
|
end
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalWL = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Weir Link
|
|
[rr,cc] = size(DCalWL);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Weir Link number ' nNodo ''];
|
|
fprintf(fileID,fmt,w);
|
|
yesWL = 0;
|
|
else
|
|
DCalWLTot(WL,:) = DCalWL;
|
|
WL = WL+1;
|
|
ok = ['Calibration parameters of node Weir Link number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
|
|
elseif idNodo(a,1) == 52 % Pendulum
|
|
%% Importazione dei dati di calibrazione per Pendulum
|
|
if strcmp(NodoPendulum(1,4),'4-20 mA')
|
|
comando = ['select Cal0 from CalibrationView where UnitName = '''...
|
|
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''' '];
|
|
end
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalPETot(PE,:) = curs.Data; % non è possibile fare il controllo dei dati di calibrazione nei Pendulum
|
|
PE = PE+1;
|
|
ok = ['Calibration parameters of node Pendulum number ' nNodo ' downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
end
|
|
end
|
|
|
|
%% Occorre considerare anche le installazioni che non hanno nodo Barometro
|
|
% ma lo devono prendere da un'altra catena nello stesso sito
|
|
if yesBL == 0
|
|
if yesPL == 1 && strcmp(NodoPiezoLink(1,4),'VW kPa') == 0 && strcmp(NodoPiezoLink(1,4),'VW kg/cm2') == 0
|
|
% Cerco tutte le centraline presenti in quel sito
|
|
comando = ['select site_id from units where name = ''' IDcentralina ''' ']; % il rapporto centralina sito è di 1 a 1
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
siteID = curs.Data;
|
|
|
|
comando = ['select id, name from units where site_id = ''' num2str(cell2mat(siteID)) ''' ']; % il rapporto centralina sito è di 1 a 1
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
unitID = curs.Data;
|
|
|
|
col = size(unitID);
|
|
chainID = cell(1,3);
|
|
ini = 1;
|
|
for c = 1:col(1,1)
|
|
% dalle centraline presenti, risalgo alle catene disponibili
|
|
comando = ['select id, unit_id, name from tools where unit_id = ''' num2str(cell2mat(unitID(c,1))) ''' '];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
chainID_down = curs.Data; % id tool, id centralina
|
|
[fin,~] = size(chainID_down);
|
|
fin = fin+ini-1;
|
|
chainID(ini:fin,:) = chainID_down;
|
|
ini = fin+1;
|
|
end
|
|
|
|
% seleziono solo le catene che hanno barometro
|
|
[col,~] = size(chainID);
|
|
BaroID = cell(1,2);
|
|
row = 1;
|
|
for c = 1:col(1,1)
|
|
% dalle centraline presenti, risalgo alle catene disponibili (ID
|
|
% catena e numero del nodo barometrico)
|
|
comando = ['select tool_id, num from nodes where tool_id = ''' num2str(cell2mat(chainID(c,1))) ''' and nodetype_id = 3 '];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
BaroID_down = curs.Data;
|
|
[x,y] = size(BaroID_down);
|
|
if x == 1 && y == 1
|
|
else
|
|
BaroID(row,:) = BaroID_down;
|
|
row = row+1;
|
|
end
|
|
end
|
|
|
|
[r,~] = size(BaroID); % Numero di catene con barometro
|
|
DCalBLTot = cell(r,4);
|
|
Barometri = cell(r,2);
|
|
row = 1;
|
|
for n = 1:r
|
|
% Trovo la catena con il barometro
|
|
Baro = cell2mat(BaroID(n,1));
|
|
MUMS = cell2mat(chainID(:,1));
|
|
index = find(ismember(MUMS,Baro));
|
|
DTcatenaBaro = char(chainID(index,3));
|
|
Barometri(n,1) = cellstr(DTcatenaBaro);
|
|
% trovo la centralina con il barometro
|
|
DL = cell2mat(chainID(index,2));
|
|
index2 = find(ismember(cell2mat(unitID(:,1)),DL));
|
|
IDunitBaro = char(unitID(index2,2));
|
|
Barometri(n,2) = cellstr(IDunitBaro);
|
|
% trovo il numero del nodo
|
|
index3 = find(ismember(cell2mat(BaroID),Baro));
|
|
nNodoBaro = num2str(cell2mat(BaroID(index3,2)));
|
|
% scarico i dati di calibrazione
|
|
comando = ['select Cal0, Cal1, Cal2, Cal3 from CalibrationView where UnitName = '''...
|
|
IDunitBaro ''' and ToolNameID = ''' DTcatenaBaro ''' and NodeNum = ''' nNodoBaro ''''];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
DCalBL = curs.Data;
|
|
[rr,cc] = size(DCalBL);
|
|
if rr==1 && cc==1
|
|
w = ['Warning: there was an error reading calibration values of node Baro Link number ' nNodoBaro ' for the ' DTcatenaBaro ' chain and ' IDunitBaro ' unit!'];
|
|
fprintf(fileID,fmt,w);
|
|
else
|
|
DCalBLTot(row,:) = DCalBL;
|
|
ok = ['Calibration of node BaroLink number ' nNodoBaro ' for chain ' DTcatenaBaro ' and ' IDunitBaro ' unit chain downloaded correctly'];
|
|
fprintf(fileID,fmt,ok);
|
|
row = row+1;
|
|
end
|
|
end
|
|
else
|
|
Barometri = [];
|
|
end
|
|
else
|
|
Barometri = [];
|
|
end
|
|
|
|
% Nuova conversione da fare per il nuovo database
|
|
[DCalTLTot,DCalTLHTot,DCalPLTot,DCalBLTot,DCalTLHRTot,DCalTLHRHTot,...
|
|
DCalALTot,DCalLLTot,DCalThLTot,DCalKLTot,DCalKLHRTot,DCalRLTot,DCalPT100Tot,...
|
|
DCalIPLTot,DCalIPLHRTot,DCalWLTot,DCalPETot] = NuovaConversione(DCalTLTot,...
|
|
DCalTLHTot,DCalPLTot,DCalBLTot,DCalTLHRTot,DCalTLHRHTot,DCalALTot,DCalLLTot,...
|
|
DCalThLTot,DCalKLTot,DCalKLHRTot,DCalRLTot,DCalPT100Tot,DCalIPLTot,DCalIPLHRTot,...
|
|
DCalWLTot,DCalPETot,FileName);
|
|
|
|
text = 'letturaCal function closed';
|
|
fprintf(fileID,fmt,text);
|
|
fclose(fileID);
|
|
|
|
end |