Sync from remote server: 2025-10-12 18:56:41
This commit is contained in:
168
RSN/letturaCal.m
Executable file
168
RSN/letturaCal.m
Executable file
@@ -0,0 +1,168 @@
|
||||
% Funzione che legge i valori di calibrazione per i vari sensori
|
||||
|
||||
function [DCalRSNTot,DCalRSNHRTot,DCalLLTot,DCalDLTot,yesRSN,yesRSNHR,yesLL,yesDL]...
|
||||
= letturaCal(MEMS,IDcentralina,DTcatena,catena,yesRSN,yesRSNHR,yesLL,yesDL,rRSN,...
|
||||
rRSNHR,rLL,rDL,NodoRSNLink,NodoLoadLink,NodoDebrisLink,conn,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'letturaCal function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
% Inizializzo le matrici
|
||||
[rC,~] = size(catena);
|
||||
idNodo = cell2mat(catena(:,1));
|
||||
|
||||
% RSN
|
||||
if isempty(NodoRSNLink) == 1
|
||||
DCalRSNTot = [];
|
||||
else
|
||||
if strcmp(NodoRSNLink(1,4),'ADC') || strcmp(NodoRSNLink(1,4),'null') || isempty(NodoRSNLink(1,4)) == 1
|
||||
DCalRSNTot = cell(rRSN,17); % matrice che concatena i dati di calibrazione relativi a ciascun nodo RSN Link
|
||||
elseif strcmp(NodoRSNLink(1,4),'Gradi')
|
||||
DCalRSNTot = [];
|
||||
end
|
||||
end
|
||||
|
||||
% RSN HR
|
||||
DCalRSNHRTot = cell(rRSNHR,6); % matrice che concatena i dati relativi a ciascun nodo RSN Link HR
|
||||
|
||||
% Load 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
|
||||
|
||||
% Debris LInk
|
||||
if isempty(NodoDebrisLink) == 1
|
||||
DCalDLTot = [];
|
||||
else
|
||||
if strcmp(NodoDebrisLink(1,4),'ADC') || strcmp(NodoDebrisLink(1,4),'null') || isempty(NodoDebrisLink(1,4)) == 1
|
||||
DCalDLTot = cell(rDL,11); % matrice che concatena i dati di calibrazione relativi a ciascun nodo RSN Link
|
||||
elseif strcmp(NodoRSNLink(1,4),'Gradi')
|
||||
DCalDLTot = [];
|
||||
end
|
||||
end
|
||||
|
||||
% Matrice con testi di conferma lettura o warning di lettura per le varie tipologie di nodi
|
||||
RSNL = 1;
|
||||
RSNLHR = 1;
|
||||
LL = 1;
|
||||
DL = 1;
|
||||
|
||||
for a = 1:rC
|
||||
nNodo = mat2str(cell2mat(catena(a,3)));
|
||||
if idNodo(a,1) == 38 % RSN Link
|
||||
if MEMS == 2
|
||||
%% Importazione dei dati di calibrazione per RSN Link
|
||||
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4, Cal5, Cal6, Cal7, Cal8, '...
|
||||
'CalA, CalB, CalC, CalD, CalE, CalF, CalG, CalH from CalibrationView where UnitName = '''...
|
||||
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DCalRSN = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo RSN Link
|
||||
[rr,cc] = size(DCalRSN);
|
||||
if rr==1 && cc==1
|
||||
w = ['Warning: there was an error reading calibration values of RSN Link node number ' nNodo ''];
|
||||
fprintf(fileID,fmt,w);
|
||||
yesRSN = 0;
|
||||
else
|
||||
DCalRSNTot(RSNL,:) = DCalRSN(:,:);
|
||||
RSNL = RSNL+1;
|
||||
ok = ['Calibration parameters of RSN Link node number ' nNodo ' downloaded correctly'];
|
||||
fprintf(fileID,fmt,ok);
|
||||
end
|
||||
else
|
||||
ok = ['Calibration parameters of RSN Link node number ' nNodo ' NOT downloaded because the node is RSN Link 2.0 - Murata MEMS'];
|
||||
fprintf(fileID,fmt,ok);
|
||||
end
|
||||
|
||||
elseif idNodo(a,1) == 39 % RSN Link HR
|
||||
%% Importazione dei dati di calibrazione per RSN Link HR
|
||||
comando = ['select Cal0, Cal1, Cal2, Cal3, Cal4, Cal5 from CalibrationView where UnitName = '''...
|
||||
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''''];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DCalRSNHR = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo RSN Link HR
|
||||
[rr,cc] = size(DCalRSNHR);
|
||||
if rr==1 && cc==1
|
||||
w = ['Warning: there was an error reading calibration values of RSN Link HR node number ' nNodo ''];
|
||||
fprintf(fileID,fmt,w);
|
||||
yesRSNHR = 0;
|
||||
else
|
||||
DCalRSNHRTot(RSNLHR,:) = DCalRSNHR(:,:);
|
||||
RSNLHR = RSNLHR+1;
|
||||
ok = ['Calibration parameters of RSN Link HR node 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')
|
||||
comando = ['select Cal1, Cal2 from CalibrationView where UnitName = '''...
|
||||
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nNodo ''' '];
|
||||
elseif strcmp(NodoLoadLink(1,4),'ADC')
|
||||
comando = ['select Cal0, Cal1 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 of node Load Link number ' nNodo ' downloaded correctly'];
|
||||
fprintf(fileID,fmt,ok);
|
||||
end
|
||||
|
||||
elseif idNodo(a,1) == 49 % Debris Link
|
||||
if MEMS == 2
|
||||
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);
|
||||
DCalDL = curs.Data; % matrice che raccoglie i dati del nodo numero 'a' di tipo Tunnel Link
|
||||
[rr,cc] = size(DCalDL);
|
||||
if rr==1 && cc==1
|
||||
text = ['Warning: there was an error reading Debris Link node number ' nNodo ''];
|
||||
fprintf(fileID,fmt,text);
|
||||
yesDL = 0;
|
||||
else
|
||||
DCalDLTot(DL,:) = DCalDL(:,:);
|
||||
DL = DL+1;
|
||||
text = ['Calibration of Debris Link node number ' nNodo ' downloaded correctly'];
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
else
|
||||
ok = ['Calibration parameters of Debris Link node number ' nNodo ' NOT downloaded because the node is Murata MEMS'];
|
||||
fprintf(fileID,fmt,ok);
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
text = 'NuovaConversione function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
% Nuova conversione da fare per il nuovo database
|
||||
[DCalRSNTot,DCalRSNHRTot,DCalLLTot,DCalDLTot] = NuovaConversione(DCalRSNTot,...
|
||||
DCalRSNHRTot,DCalLLTot,DCalDLTot);
|
||||
|
||||
text = 'NuovaConversione & letturaCal functions ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user