Sync from remote server: 2025-10-12 18:56:41
This commit is contained in:
18
Tilt/ASSEa.m
Executable file
18
Tilt/ASSEa.m
Executable file
@@ -0,0 +1,18 @@
|
||||
function [Na,Ea,Za]=ASSEa(ax,angle,SpeTL,i,j)
|
||||
|
||||
angle = angle*2*pi/360;
|
||||
|
||||
if ax(i,j)>=0
|
||||
Na = SpeTL(i)*ax(i,j)*cos(angle);
|
||||
Ea = -SpeTL(i)*ax(i,j)*sin(angle);
|
||||
else
|
||||
Na = -SpeTL(i)*ax(i,j)*cos(angle);
|
||||
Ea = SpeTL(i)*ax(i,j)*sin(angle);
|
||||
end
|
||||
|
||||
% calcolo il coseno dell'angolo di inclinazione
|
||||
cosBeta = (1 - ax(i,j)^2)^0.5;
|
||||
Z = SpeTL(i)*cosBeta;
|
||||
Za = SpeTL(i) - Z; % L'abbassamento è POSITIVO
|
||||
|
||||
end
|
||||
19
Tilt/ASSEa_HR.m
Executable file
19
Tilt/ASSEa_HR.m
Executable file
@@ -0,0 +1,19 @@
|
||||
function [Na,Ea,Za]=ASSEa_HR(xAngTLHR,angle,SpeTLHR)
|
||||
|
||||
angle = angle*2*pi/360;
|
||||
ax = sin(xAngTLHR);
|
||||
|
||||
if ax >=0
|
||||
Na = SpeTLHR*ax*cos(angle);
|
||||
Ea = -SpeTLHR*ax*sin(angle);
|
||||
else
|
||||
Na = -SpeTLHR*ax*cos(angle);
|
||||
Ea = SpeTLHR*ax*sin(angle);
|
||||
end
|
||||
|
||||
% calcolo il coseno dell'angolo di inclinazione
|
||||
cosBeta = (1 - ax^2)^0.5;
|
||||
Z = SpeTLHR*cosBeta;
|
||||
Za = SpeTLHR - Z; % L'abbassamento è POSITIVO
|
||||
|
||||
end
|
||||
17
Tilt/ASSEb.m
Executable file
17
Tilt/ASSEb.m
Executable file
@@ -0,0 +1,17 @@
|
||||
function [Nb,Eb,Zb]=ASSEb(ay,angle,SpeTL,i,j)
|
||||
|
||||
angle = angle*2*pi/360;
|
||||
|
||||
if ay(i,j)>=0
|
||||
Nb = SpeTL(i)*ay(i,j)*sin(angle);
|
||||
Eb = SpeTL(i)*ay(i,j)*cos(angle);
|
||||
else
|
||||
Nb = -SpeTL(i)*ay(i,j)*sin(angle);
|
||||
Eb = -SpeTL(i)*ay(i,j)*cos(angle);
|
||||
end
|
||||
|
||||
% calcolo il coseno dell'angolo di inclinazione
|
||||
cosBeta = (1 - ay(i,j)^2)^0.5;
|
||||
Z = SpeTL(i)*cosBeta;
|
||||
Zb = SpeTL(i) - Z; % L'abbassamento è POSITIVO
|
||||
end
|
||||
19
Tilt/ASSEb_HR.m
Executable file
19
Tilt/ASSEb_HR.m
Executable file
@@ -0,0 +1,19 @@
|
||||
function [Nb,Eb,Zb]=ASSEb_HR(yAngTLHR,angle,SpeTLHR)
|
||||
|
||||
angle = angle*2*pi/360;
|
||||
ay = sin(yAngTLHR);
|
||||
|
||||
if ay >=0
|
||||
Nb = SpeTLHR*ay*cos(angle);
|
||||
Eb = SpeTLHR*ay*sin(angle);
|
||||
else
|
||||
Nb = -SpeTLHR*ay*cos(angle);
|
||||
Eb = -SpeTLHR*ay*sin(angle);
|
||||
end
|
||||
|
||||
% calcolo il coseno dell'angolo di inclinazione
|
||||
cosBeta = (1 - ay^2)^0.5;
|
||||
Z = SpeTLHR*cosBeta;
|
||||
Zb = SpeTLHR - Z; % L'abbassamento è POSITIVO
|
||||
|
||||
end
|
||||
19
Tilt/ASSEb_HR_OLD.m
Executable file
19
Tilt/ASSEb_HR_OLD.m
Executable file
@@ -0,0 +1,19 @@
|
||||
function [Nb,Eb,Zb]=ASSEb_HR_OLD(yAngTLHR,angle,SpeTLHR)
|
||||
|
||||
angle = angle*2*pi/360;
|
||||
ay = sin(yAngTLHR);
|
||||
|
||||
if ay >=0
|
||||
Nb = SpeTLHR*ay*cos(angle);
|
||||
Eb = -SpeTLHR*ay*sin(angle);
|
||||
else
|
||||
Nb = -SpeTLHR*ay*cos(angle);
|
||||
Eb = SpeTLHR*ay*sin(angle);
|
||||
end
|
||||
|
||||
% calcolo il coseno dell'angolo di inclinazione
|
||||
cosBeta = (1 - ay^2)^0.5;
|
||||
Z = SpeTLHR*cosBeta;
|
||||
Zb = SpeTLHR - Z; % L'abbassamento è POSITIVO
|
||||
|
||||
end
|
||||
429
Tilt/AlertReport.m
Executable file
429
Tilt/AlertReport.m
Executable file
@@ -0,0 +1,429 @@
|
||||
function [checkALRPT,nomeALRPT_PDF] = AlertReport(IDcentralina,DTcatena,Sito,...
|
||||
NodeNum,Depth,data,DataNum,LVL,TipoDisp,conn,FileName)
|
||||
|
||||
% Funzione per la creazione di report automatici di allertamento
|
||||
|
||||
% *** INPUT ***
|
||||
%%% data -> data corrispondente all'OOA dell'evento
|
||||
%%% DataNum -> numero di valori nel dataset dell'evento
|
||||
%%% LVL -> livello dell'evento
|
||||
%%% NodeNum, Depth -> numero e profondità del nodo
|
||||
%%% TipoDisp -> spostamenti locali o cumulati (LOCALI DA IMPLEMENTARE)
|
||||
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'AlertReport function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
try
|
||||
%% Importo librerie Matlab Report Generator e abilito compilazione DOM
|
||||
import mlreportgen.dom.*
|
||||
import mlreportgen.report.*
|
||||
makeDOMCompilable()
|
||||
|
||||
%% Creo report e info
|
||||
tempoALRPT = datestr(now,'dd-mm-yyyy HH:MM:SS');
|
||||
tempoinvio = datestr(datenum(tempoALRPT),'ddmmyy_HHMMSS');
|
||||
nomeALRPT = ['AlertReport-' IDcentralina '-' DTcatena '-' NodeNum '-' tempoinvio];
|
||||
docALRPT = Report(nomeALRPT,'pdf');
|
||||
nomeALRPT_PDF = [nomeALRPT '.pdf'];
|
||||
open(docALRPT)
|
||||
PG = Chapter;
|
||||
Font_text = '12pt';
|
||||
Font_text2 = '14pt';
|
||||
Font_report = 'Times';
|
||||
|
||||
wm = Watermark('sfondoALRPT.png');
|
||||
docALRPT.Layout.Watermark = wm;
|
||||
|
||||
titolo = Paragraph('Report automatico di allertamento');
|
||||
titolo.Style = {HAlign('center'),FontSize('28pt'),Bold(1),...
|
||||
OuterMargin('0in','0in','0.2in','0in'),FontFamily(Font_report)};
|
||||
sottotitolo = Paragraph(tempoALRPT);
|
||||
sottotitolo.Style = {HAlign('center'),FontSize('12pt'),Bold(1),FontFamily(Font_report)};
|
||||
|
||||
InfoNodo = [NodeNum ' (' Depth ' m)'];
|
||||
dd = data(1:2);
|
||||
mm = data(4:5);
|
||||
yyyy = data(7:10);
|
||||
dataOOA =([yyyy '-' mm '-' dd]);
|
||||
oraOOA = datestr(data,'HH:MM:SS');
|
||||
dataMESE = datestr(datenum(dataOOA)-30, 'yyyy-mm-dd');
|
||||
|
||||
%% costruisco il dataset mensile degli spostamenti
|
||||
% predendo come riferimento data e ora di OOA, scarico tutti i dati
|
||||
% disponibili a partire dal giorno (e ora) localizzato 30gg prima di
|
||||
% OOA per il calcolo della soglia di spostamento equivalente
|
||||
comando = ['select EventDate, EventTime, HShift, EventTimestamp from ElabDataView where EventDate = ''' ...
|
||||
dataMESE ''' and EventTime >= ''' oraOOA ''' and ToolNameID = ''' DTcatena ...
|
||||
''' and UnitName = ''' IDcentralina ...
|
||||
''' and NodeNum = ''' NodeNum ''' order by EventTimestamp'];
|
||||
Dati1 = fetch(conn,comando); % dati del singolo giorno 30gg prima di OOA
|
||||
comando = ['select EventDate, EventTime, HShift, EventTimestamp from ElabDataView where EventDate > ''' ...
|
||||
dataMESE ''' and EventDate < ''' dataOOA ''' and ToolNameID = ''' DTcatena ...
|
||||
''' and UnitName = ''' IDcentralina ...
|
||||
''' and NodeNum = ''' NodeNum ''' order by EventTimestamp'];
|
||||
Dati2 = fetch(conn,comando); % dati da 30gg prima di OOA fino a OOA
|
||||
comando = ['select EventDate, EventTime, HShift, EventTimestamp from ElabDataView where EventDate = ''' ...
|
||||
dataOOA ''' and EventTime < ''' oraOOA ''' and ToolNameID = ''' DTcatena ...
|
||||
''' and UnitName = ''' IDcentralina ...
|
||||
''' and NodeNum = ''' NodeNum ''' order by EventTimestamp'];
|
||||
Dati3 = fetch(conn,comando); % dati da OOA in avanti
|
||||
|
||||
% il dataset di spostamento inizia dal dato subito PRECEDENTE all'OOA -->
|
||||
% lo inserisco all'inizio e lo tolgo dal dataset mensile
|
||||
dataEV(1,1) = Dati3(end,1);
|
||||
oraEV(1,1) = Dati3(end,2);
|
||||
datasetEV(1,1) = Dati3(end,3);
|
||||
Dati3(end,:) = [];
|
||||
|
||||
% riorganizzo i dati
|
||||
datiMESE = [Dati1; Dati2; Dati3];
|
||||
[rDM,~] = size(datiMESE);
|
||||
for m = 1:rDM
|
||||
tempoMESE{m,1} = strjoin(datiMESE(m,1:2));
|
||||
datasetMESE(m,1) = datiMESE(m,3);
|
||||
end
|
||||
|
||||
%% costruisco il dataset dell'evento critico
|
||||
% A partire da data OOA, scarico tutti i dati disponibili e sfrutto DataNum
|
||||
% per prendere il numero giusto di valori (relativi al dataset
|
||||
% dell'evento)
|
||||
|
||||
comando = ['select EventDate, EventTime, EventTimestamp from ElabDataView where EventDate = ''' ...
|
||||
dataOOA ''' and EventTime >= ''' oraOOA ''' and ToolNameID = ''' DTcatena ...
|
||||
''' and UnitName = ''' IDcentralina ...
|
||||
''' and NodeNum = ''' NodeNum ''' order by EventTimestamp'];
|
||||
DateEV1 = fetch(conn,comando);
|
||||
|
||||
comando = ['select EventDate, EventTime, EventTimestamp from ElabDataView where EventDate > ''' ...
|
||||
dataOOA ''' and ToolNameID = ''' DTcatena ''' and UnitName = ''' IDcentralina ...
|
||||
''' and NodeNum = ''' NodeNum ''' order by EventTimestamp'];
|
||||
DateEV2 = fetch(conn,comando);
|
||||
|
||||
DateEV_temp = [DateEV1; DateEV2];
|
||||
DateEV = DateEV_temp(1:DataNum,:);
|
||||
|
||||
[rT,~] = size(DateEV);
|
||||
for tmp = 1:rT
|
||||
conta = tmp+1; % aggiungo dopo il primo dato precedente all'OOA
|
||||
dataEV{conta,1} = datestr(DateEV(tmp,1),'yyyy-mm-dd');
|
||||
oraEV{conta,1} = datestr(DateEV(tmp,2),'HH:MM:SS');
|
||||
comando = ['select HShift from ElabDataView where EventDate = ''' ...
|
||||
dataEV{conta,1} ''' and EventTime = ''' oraEV{conta,1} ''' and ToolNameID = ''' DTcatena ...
|
||||
''' and UnitName = ''' IDcentralina ...
|
||||
''' and NodeNum = ''' NodeNum ''' '];
|
||||
datasetEV(conta,1) = fetch(conn,comando);
|
||||
end
|
||||
|
||||
tempmat = [dataEV oraEV];
|
||||
[rDO,~] = size(tempmat);
|
||||
for d = 1:rDO
|
||||
tempoEV{d,1} = strjoin(tempmat(d,:));
|
||||
end
|
||||
durataevento = datenum(tempoEV(end))-datenum(tempoEV(1));
|
||||
|
||||
% array per grafico -> punto OOA
|
||||
timerefEV = [tempoEV{1,:};tempoEV{1,:}];
|
||||
datarefEV = [0; datasetEV(1,1)];
|
||||
|
||||
%% ricavo soglia di spostamento equivalente
|
||||
% soglia basata sugli spostamenti equivalenti calcolati su un periodo
|
||||
% pari a quello in cui si è verificato l'evento critico
|
||||
|
||||
[rDT,~] = size(datasetMESE);
|
||||
[rDS,~] = size(datasetEV);
|
||||
ind = 1;
|
||||
for c = rDS:rDT
|
||||
if ind == 1 % primo dato
|
||||
eqdispMESE(ind,1) = abs(cell2mat(datasetMESE(c,1)) - cell2mat(datasetMESE(ind,1)));
|
||||
tempoeqdispMESE(ind,1) = tempoMESE(c,:);
|
||||
ind = ind +1;
|
||||
else % dati seguenti
|
||||
% controllo che l'intervallo scelto corrisponda alla durata
|
||||
% dell'evento critico
|
||||
dT1 = abs((datenum(tempoMESE(c,1))-datenum(tempoMESE(ind,1)))-durataevento);
|
||||
dT2 = abs((datenum(tempoMESE(c,1))-datenum(tempoMESE(ind-1,1)))-durataevento);
|
||||
dT3 = abs((datenum(tempoMESE(c,1))-datenum(tempoMESE(ind+1,1)))-durataevento);
|
||||
if abs(dT1)<abs(dT2) && abs(dT1)<abs(dT3)
|
||||
% se la durata dell'intervallo scelto è la più
|
||||
% vicina alla durata effettiva dell'evento, gli spostamenti
|
||||
% sono correttamente riferiti a un intervallo di pari durata
|
||||
eqdispMESE(ind,1) = abs(cell2mat(datasetMESE(c,1)) - cell2mat(datasetMESE(ind,1)));
|
||||
tempoeqdispMESE(ind,1) = tempoMESE(c,:);
|
||||
ind = ind + 1;
|
||||
else
|
||||
% se i controlli non sono verificati è possibile che sia
|
||||
% presente un salto temporale nei dati -> non ha senso
|
||||
% calcolare gli spostamenti equivalenti perchè l'intervallo
|
||||
% temporale è differente, i valori vengono quindi segnati e
|
||||
% successivamente rimossi dal calcolo della soglia
|
||||
eqdispMESE(ind,1) = -99;
|
||||
tempoeqdispMESE(ind,1) = tempoMESE(c,:);
|
||||
ind = ind + 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
% calcolo soglia senza valori anomali
|
||||
eqdispMESEth = eqdispMESE(eqdispMESE ~= -99);
|
||||
mediaMESE = mean(eqdispMESEth);
|
||||
varMESE = std(eqdispMESEth);
|
||||
sogliaMESE = (mediaMESE + 3*varMESE)*1000; % soglia spostamento equivalente (mm)
|
||||
|
||||
%%% dati vari per grafici e tabelle
|
||||
|
||||
% valori anomali pari a 0 nei grafici
|
||||
[red,~] = size(eqdispMESE);
|
||||
for s = 1:red
|
||||
if eqdispMESE(s,1) == -99
|
||||
eqdispMESE(s,1) = 0;
|
||||
end
|
||||
end
|
||||
|
||||
datasetTOT = [datasetMESE; datasetEV];
|
||||
tempoTOT = [tempoMESE; tempoEV];
|
||||
[rTOT,~] = size(datasetTOT);
|
||||
ind = rTOT-rDS*2+1;
|
||||
p = 1;
|
||||
for t = rTOT-rDS+1:rTOT % dataset per grafico spostamenti equivalenti
|
||||
eqdispEV(p,1) = abs(cell2mat(datasetTOT(t,1)) - cell2mat(datasetTOT(ind,1)));
|
||||
tempoeqdispEV(p,1) = tempoTOT(t,:);
|
||||
ind = ind+1;
|
||||
p = p+1;
|
||||
end
|
||||
dispEV = eqdispEV(end,1)*1000; %spostamento dell'evento critico
|
||||
tempodispEV = tempoeqdispEV(end,:);
|
||||
|
||||
eqdispTOT = [eqdispMESE*1000; eqdispEV*1000];
|
||||
tempoeqdispTOT = [tempoeqdispMESE; tempoeqdispEV];
|
||||
|
||||
sogliaPLOT = [sogliaMESE; sogliaMESE];
|
||||
temposogliaPLOT = [datenum(tempoTOT(1,:))-20; datenum(tempoTOT(end,:))+20];
|
||||
|
||||
%immagine del livello di attività del sito
|
||||
if LVL == 5 && dispEV < sogliaMESE
|
||||
imglevel = Image('activity1.jpg');
|
||||
elseif LVL == 4 && incrDIPS >= sogliaMESE
|
||||
imglevel = Image('activity2.jpg');
|
||||
elseif LVL == 5 && dispEV >= sogliaMESE
|
||||
imglevel = Image('activity3.jpg');
|
||||
elseif LVL == 1.5 % falso allarme
|
||||
imglevel = Image('activity4.jpg');
|
||||
else
|
||||
imglevel = Image('activity1.jpg');
|
||||
end
|
||||
imglevel.Style = {Height('2.4cm')};
|
||||
|
||||
%% grafici spostamenti e spostamenti equivalenti
|
||||
|
||||
% SPOSTAMENTI
|
||||
figure(1)
|
||||
subplot(2,1,1); % (righe colonne posizione)
|
||||
pbaspect([3 1 1]);
|
||||
disp = plot(datenum(tempoEV),cell2mat(datasetEV),'Color','b','LineWidth',1);
|
||||
hold on
|
||||
month = plot(datenum(tempoMESE),cell2mat(datasetMESE),'Color','b','LineWidth',1);
|
||||
ref = plot(datenum(timerefEV),cell2mat(datarefEV),':','Color','k','LineWidth',0.75);
|
||||
OOA = plot(datenum(timerefEV(2,:)),cell2mat(datarefEV(2,:)),'.','Color','r','MarkerSize',12);
|
||||
dLIM(1,1) = min(cell2mat(datasetMESE));
|
||||
dLIM(2,1) = min(cell2mat(datasetEV));
|
||||
dLIM(1,2) = max(cell2mat(datasetMESE));
|
||||
dLIM(2,2) = max(cell2mat(datasetEV));
|
||||
MIN = min(dLIM(:,1));
|
||||
MAX = max(dLIM(:,2));
|
||||
ylim([MIN-0.01*MIN MAX+0.01*MAX]);
|
||||
xlim([datenum(tempoTOT(1,:))-5; datenum(tempoTOT(end,:))+5]);
|
||||
if TipoDisp == 1
|
||||
sp = 'locali';
|
||||
else
|
||||
sp = 'cumulati';
|
||||
end
|
||||
title(['Spostamenti ' sp ' - nodo ' NodeNum]);
|
||||
xlabel('Data [gg/mm/aaaa]');
|
||||
ylabel('Spostamento [m]');
|
||||
h = gca;
|
||||
h.XAxis.MinorTick = 'on';
|
||||
datetick('x','dd/mm/yy','keepticks','keeplimits');
|
||||
ax = gca;
|
||||
ax.FontSize = 7;
|
||||
grid on
|
||||
grid minor
|
||||
|
||||
% SPOSTAMENTI EQUIVALENTI
|
||||
hold off
|
||||
subplot(2,1,2); % (righe colonne posizione)
|
||||
pbaspect([3 1 1]);
|
||||
eqplot = plot(datenum(tempoeqdispTOT),eqdispTOT);
|
||||
hold on
|
||||
crit = plot(datenum(tempodispEV),dispEV,'.','Color','k','MarkerSize',15);
|
||||
thr = plot(temposogliaPLOT, sogliaPLOT,'--','Color','r','Linewidth',1);
|
||||
xlim([datenum(tempoeqdispTOT(1,:))-5; datenum(tempoeqdispTOT(end,:))+5]);
|
||||
maxincr = max(eqdispTOT);
|
||||
if maxincr >= sogliaMESE
|
||||
ylim([0 maxincr+0.2*maxincr]);
|
||||
else
|
||||
ylim([0 sogliaMESE+0.2*sogliaMESE]);
|
||||
end
|
||||
title(['Spostamenti equivalenti - nodo ' NodeNum]);
|
||||
xlabel('Data [gg/mm/aaaa]');
|
||||
ylabel('Spostamento [mm]');
|
||||
h = gca;
|
||||
h.XAxis.MinorTick = 'on';
|
||||
ax = gca;
|
||||
ax.FontSize = 7;
|
||||
datetick('x','dd/mm/yy','keepticks','keeplimits');
|
||||
grid on
|
||||
grid minor
|
||||
|
||||
TempName = ['AlertReport-' IDcentralina '-' DTcatena '-' tempoinvio '-EqDisp.png'];
|
||||
saveas(eqplot,TempName);
|
||||
ChartDispEq = Image(TempName);
|
||||
ChartDispEq.Style = {ScaleToFit};
|
||||
close(figure(1))
|
||||
|
||||
% immagine legenda per grafici
|
||||
legIMG = Image('legendaSpEq.png');
|
||||
legIMG.Style = {ScaleToFit,OuterMargin('0in','0in','-0.2in','0in')};
|
||||
|
||||
%% Creo tabelle e campi corrispondenti
|
||||
|
||||
% tabella info sito
|
||||
tabsito(1,1) = Paragraph();
|
||||
tabsito(1,1).Style = {FontSize(Font_text),FontFamily(Font_report)};
|
||||
t1a = Text('Sito: ');
|
||||
t1a.Bold = 1;
|
||||
t1b = Text(Sito);
|
||||
append(tabsito(1,1),t1a);
|
||||
append(tabsito(1,1),t1b);
|
||||
|
||||
tabsito(2,1) = Paragraph();
|
||||
tabsito(2,1).Style = {FontSize(Font_text),FontFamily(Font_report)};
|
||||
t2a = Text('Centralina: ');
|
||||
t2a.Bold = 1;
|
||||
t2b = Text(IDcentralina);
|
||||
append(tabsito(2,1),t2a);
|
||||
append(tabsito(2,1),t2b);
|
||||
|
||||
tabsito(3,1) = Paragraph();
|
||||
tabsito(3,1).Style = {FontSize(Font_text),FontFamily(Font_report)};
|
||||
t3a = Text('Array: ');
|
||||
t3a.Bold = 1;
|
||||
t3b = Text(DTcatena);
|
||||
append(tabsito(3,1),t3a);
|
||||
append(tabsito(3,1),t3b);
|
||||
|
||||
tabsito(4,1) = Paragraph();
|
||||
tabsito(4,1).Style = {FontSize(Font_text),FontFamily(Font_report)};
|
||||
t4a = Text(['Nodo (profondit' char(224) '): ']);
|
||||
t4a.Bold = 1;
|
||||
t4b = Text(InfoNodo);
|
||||
append(tabsito(4,1),t4a);
|
||||
append(tabsito(4,1),t4b);
|
||||
|
||||
tabsito(5,1) = Paragraph();
|
||||
tabsito(5,1).Style = {FontSize(Font_text),FontFamily(Font_report)};
|
||||
t5a = Text('Inizio evento: ');
|
||||
t5a.Bold = 1;
|
||||
t5b = Text(data);
|
||||
append(tabsito(5,1),t5a);
|
||||
append(tabsito(5,1),t5b);
|
||||
|
||||
lot1 = Table({tabsito, imglevel});
|
||||
lot1.TableEntriesStyle = {VAlign('middle')};
|
||||
lot1.Style = {ResizeToFitContents(false),Width("100%"),...
|
||||
OuterMargin('0in','0in','0.3in','0in')};
|
||||
grps(1) = TableColSpecGroup;
|
||||
grps(1).Span = 2;
|
||||
specs(1) = TableColSpec;
|
||||
specs(1).Span = 1;
|
||||
specs(1).Style = {Width("80%")};
|
||||
specs(2) = TableColSpec;
|
||||
specs(2).Span = 1;
|
||||
specs(2).Style = {Width("20%")};
|
||||
grps(1).ColSpecs = specs;
|
||||
lot1.ColSpecGroups = grps;
|
||||
|
||||
% tabella info spostamenti evento
|
||||
tabE1(1,1) = Paragraph('Spostamento generato dall''evento [mm]');
|
||||
tabE1(2,1) = Paragraph(num2str((dispEV),'%0.2f'));
|
||||
tabE2(1,1) = Paragraph('Spostamento totale mensile [mm]');
|
||||
tabE2(2,1) = Paragraph(num2str(((cell2mat(datasetEV(end))-cell2mat(datasetMESE(1)))*1000),'%0.2f'));
|
||||
tabE3(1,1) = Paragraph('Soglia di spostamento [mm]');
|
||||
tabE3(2,1) = Paragraph(num2str((sogliaMESE),'%0.2f'));
|
||||
tabE1(1,1).Style ={FontSize(Font_text),Bold(1),HAlign('center'),...
|
||||
Hyphenation(false),FontFamily(Font_report)};
|
||||
tabE1(2,1).Style ={FontSize(Font_text2),HAlign('center'),...
|
||||
InnerMargin('0in','0in','0.2in','0in'),FontFamily(Font_report)};
|
||||
tabE2(1,1).Style ={FontSize(Font_text),Bold(1),HAlign('center'),...
|
||||
Hyphenation(false),FontFamily(Font_report)};
|
||||
tabE2(2,1).Style ={FontSize(Font_text2),HAlign('center'),...
|
||||
InnerMargin('0in','0in','0.2in','0in'),FontFamily(Font_report)};
|
||||
tabE3(1,1).Style ={FontSize(Font_text),Bold(1),HAlign('center'),...
|
||||
Hyphenation(false),FontFamily(Font_report)};
|
||||
tabE3(2,1).Style ={FontSize(Font_text2),HAlign('center'),...
|
||||
InnerMargin('0in','0in','0.2in','0in'),FontFamily(Font_report)};
|
||||
|
||||
lot2 = Table({tabE1, tabE2, tabE3});
|
||||
lot2.TableEntriesStyle = {VAlign('middle')};
|
||||
lot2.Style = {ResizeToFitContents(false),Width("100%"),...
|
||||
OuterMargin('0in','0in','0.3in','0in')};
|
||||
|
||||
%% Inserisco nel report e chiudo
|
||||
add(PG,titolo);
|
||||
add(PG,sottotitolo);
|
||||
add(PG,lot1);
|
||||
add(PG,ChartDispEq);
|
||||
add(PG,legIMG);
|
||||
add(PG,lot2);
|
||||
add(docALRPT,PG);
|
||||
|
||||
close(docALRPT);
|
||||
|
||||
checkALRPT = 1;
|
||||
|
||||
%% Scrivo nel log
|
||||
fileID = fopen(FileName,'a');
|
||||
text = 'AlertReport function worked correctly - Document created!';
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
catch err
|
||||
FileErrALRPT = ['ErrorFile-AlertReport-' IDcentralina '-' DTcatena '-' datestr(today) '-' datestr(now,'hhMMss') '.txt'];
|
||||
fid = fopen(FileErrALRPT,'a+');
|
||||
fprintf(fid, '%s', err.getReport('extended','hyperlinks','off'));
|
||||
fclose(fid);
|
||||
|
||||
checkALRPT = 0; % non allego il report nella mail (documento non generato)
|
||||
|
||||
% Email
|
||||
setpref('Internet','E_mail','alert@aseltd.eu');
|
||||
setpref('Internet','SMTP_Server','smtps.aruba.it');
|
||||
setpref('Internet','SMTP_Username','alert@aseltd.eu');
|
||||
setpref('Internet','SMTP_Password','Ase#2013!20@bat');
|
||||
props=java.lang.System.getProperties;
|
||||
pp=props.setProperty('mail.smtp.auth','true'); %#ok
|
||||
pp=props.setProperty('mail.smtp.socketFactory.class','javax.net.ssl.SSLSocketFactory'); %#ok
|
||||
pp=props.setProperty('mail.smtp.socketFactory.port','465'); %#ok
|
||||
|
||||
subject_ITA_ALRPT = ('CRASH Alert Report');
|
||||
message_ITA_ALRPT = cellstr(['La funzione Alert Report ha al proprio interno qualche minchiata '...
|
||||
'per cui crasha nel creare il report di allertamento di ' Sito...
|
||||
', centralin ' IDcentralina ' catena ' DTcatena '. Fate qualcosa vi prego!']);
|
||||
messagealrpt = cellstr('Tanti Blip e Blop a voi, ');
|
||||
message2alrpt = cellstr('Tilt - Alert Report');
|
||||
message_ITA_ALRPT = [message_ITA_ALRPT; messagealrpt; message2alrpt];
|
||||
|
||||
recipients_ASEALRPT{1,1} = 'alessandro.valletta@aseltd.eu';
|
||||
recipients_ASEALRPT{2,1} = 'andrea.carri@aseltd.eu';
|
||||
|
||||
allegatoERR_ALR = FileErrALRPT;
|
||||
|
||||
sendmail(recipients_ASEALRPT, subject_ITA_ALRPT, message_ITA_ALRPT, allegatoERR_ALR)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
52
Tilt/Baro.m
Executable file
52
Tilt/Baro.m
Executable file
@@ -0,0 +1,52 @@
|
||||
function [BaroDef,BaroDefT,ARRAYdateBL,ErrBaroLink] = Baro(BaroDef,BaroDefT,...
|
||||
ARRAYdateBL,NuovoZeroBL,NdatiMediaP,Ndatidespike,ErrBaroLink,rBL,marginePiezo,FileName)
|
||||
|
||||
text = 'Baro function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
if NuovoZeroBL == 1
|
||||
if NdatiMediaP > Ndatidespike
|
||||
Ndati = NdatiMediaP;
|
||||
else
|
||||
Ndati = Ndatidespike;
|
||||
end
|
||||
ini = round(Ndati/2)+1;
|
||||
if rem(Ndati,2) == 0
|
||||
ini = ini+1;
|
||||
end
|
||||
clear NDati
|
||||
ini = ini + marginePiezo;
|
||||
if ini < 6
|
||||
ini = 6;
|
||||
end
|
||||
ErrBaroLink = ErrBaroLink(ini:end,:);
|
||||
BaroDef = BaroDef(ini:end,:);
|
||||
BaroDefT = BaroDefT(ini:end,:);
|
||||
ARRAYdateBL = ARRAYdateBL(ini:end,1);
|
||||
end
|
||||
|
||||
[r,~] = size(ErrBaroLink);
|
||||
Matrice_err = zeros(r,rBL);
|
||||
for i = 1:r % date
|
||||
d = 1;
|
||||
for n = 1:rBL % nodi
|
||||
j = 1;
|
||||
err = ErrBaroLink(i,d:d+1);
|
||||
while j <= 2
|
||||
if err(1,j) == 1
|
||||
Matrice_err(i,n) = 1;
|
||||
end
|
||||
j = j+1;
|
||||
end
|
||||
d = d+2;
|
||||
end
|
||||
end
|
||||
ErrBaroLink = Matrice_err';
|
||||
|
||||
text = 'Baro Link elaborated correctly. Baro function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
152
Tilt/CANCELLA.m
Executable file
152
Tilt/CANCELLA.m
Executable file
@@ -0,0 +1,152 @@
|
||||
DTcatena = input('Digitare il nome della catena: ','s');
|
||||
|
||||
dbname = 'ase_lar';
|
||||
username = 'matlab';
|
||||
password = 'Ase@2014';
|
||||
driver = 'com.mysql.jdbc.Driver';
|
||||
dburl = ['jdbc:mysql://160.78.21.55:3306/' dbname];
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'ToolNameID','NodeNum','EventDate','EventTime','XShift','YShift'};
|
||||
% javaclasspath('C:\Program Files\MATLAB\R2008a\java\mysql-connector-java-3.1.14-bin.jar');
|
||||
conn = database(dbname, username, password, driver, dburl);
|
||||
|
||||
comando = ['delete from ELABDATADISP where ToolNameID = ''' DTcatena ''''];
|
||||
curs = exec(conn,comando);
|
||||
close(conn)
|
||||
|
||||
%%
|
||||
% dbname = 'ase_lar';
|
||||
% username = 'matlab';
|
||||
% password = 'Ase@2014';
|
||||
% driver = 'com.mysql.jdbc.Driver';
|
||||
% dburl = ['jdbc:mysql://160.78.21.55:3306/' dbname];
|
||||
%
|
||||
% conn = database(dbname, username, password, driver, dburl);
|
||||
%
|
||||
% DTcatena = 'DT0094';
|
||||
% date = '2019-07-02';
|
||||
% comando = ['delete from ELABDATADISP where ToolNameID = ''' DTcatena ''' and EventDate >= ''' date ''''];
|
||||
%
|
||||
% curs = exec(conn,comando);
|
||||
% close(conn)
|
||||
% disp('Fatto')
|
||||
|
||||
%% 1 Cancello dati prima della data X di un determinato nodo
|
||||
dbname = 'ase_lar';
|
||||
username = 'matlab';
|
||||
password = 'Ase@2014';
|
||||
driver = 'com.mysql.jdbc.Driver';
|
||||
dburl = ['jdbc:mysql://212.237.30.90:3306/' dbname];
|
||||
|
||||
conn = database(dbname, username, password, driver, dburl);
|
||||
|
||||
IDcentralina = 'ID0243';
|
||||
DTcatena = 'DT0252';
|
||||
date = '2023-07-24';
|
||||
NodeNum = '10';
|
||||
|
||||
comando = ['delete from ELABDATADISP where UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena...
|
||||
''' and EventDate <= ''' date ''' and NodeNum = ''' NodeNum ''''];
|
||||
|
||||
curs = exec(conn,comando);
|
||||
close(conn)
|
||||
|
||||
disp('Fine!')
|
||||
|
||||
%% 2 Cancello dati alla data X prima dell'ora Y di un determinato nodo
|
||||
dbname = 'ase_lar';
|
||||
username = 'matlab';
|
||||
password = 'Ase@2014';
|
||||
driver = 'com.mysql.jdbc.Driver';
|
||||
dburl = ['jdbc:mysql://212.237.30.90:3306/' dbname];
|
||||
|
||||
conn = database(dbname, username, password, driver, dburl);
|
||||
|
||||
IDcentralina = 'ID0239';
|
||||
DTcatena = 'DT0003';
|
||||
date = '2023-07-24';
|
||||
time = '11:40:00';
|
||||
NodeNum = '4';
|
||||
|
||||
comando = ['delete from ELABDATADISP where UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena...
|
||||
''' and EventDate = ''' date ''' and EventTime <= ''' time ''' and NodeNum = ''' NodeNum ''''];
|
||||
|
||||
curs = exec(conn,comando);
|
||||
close(conn)
|
||||
|
||||
disp('Fine!')
|
||||
|
||||
%% Tempo
|
||||
dbname = 'ase_lar';
|
||||
username = 'matlab';
|
||||
password = 'Ase@2014';
|
||||
driver = 'com.mysql.jdbc.Driver';
|
||||
dburl = ['jdbc:mysql://212.237.30.90:3306/' dbname];
|
||||
|
||||
conn = database(dbname, username, password, driver, dburl);
|
||||
|
||||
IDcentralina = 'ID0226';
|
||||
DTcatena = 'DT0244';
|
||||
date = '2023-07-25';
|
||||
time = '12:00:00';
|
||||
|
||||
comando = ['delete from ELABDATADISP where UnitName = ''' IDcentralina ''' and ToolNameID = ''' ...
|
||||
DTcatena ''' and EventDate = ''' date ''' and EventTime >= ''' time ''''];
|
||||
|
||||
curs = exec(conn,comando);
|
||||
close(conn)
|
||||
|
||||
disp('Fine!')
|
||||
|
||||
%% 2 Cancello tutti i dati
|
||||
dbname = 'ase_lar';
|
||||
username = 'matlab';
|
||||
password = 'Ase@2014';
|
||||
driver = 'com.mysql.jdbc.Driver';
|
||||
dburl = ['jdbc:mysql://212.237.30.90:3306/' dbname];
|
||||
|
||||
conn = database(dbname, username, password, driver, dburl);
|
||||
|
||||
DTcatena = '13489-S07';
|
||||
IDcentralina = 'TEPBA';
|
||||
comando = ['delete from ELABDATADISP where ToolNameID = ''' DTcatena ''' and UnitName = ''' IDcentralina ''' '];
|
||||
|
||||
curs = exec(conn,comando);
|
||||
close(conn)
|
||||
|
||||
disp('Fine!')
|
||||
|
||||
% TEPBA-13489-S07
|
||||
|
||||
|
||||
%% 3 Cancello dati di un intervallo temporale
|
||||
dbname = 'ase_lar';
|
||||
username = 'matlab';
|
||||
password = 'Ase@2014';
|
||||
driver = 'com.mysql.jdbc.Driver';
|
||||
dburl = ['jdbc:mysql://212.237.30.90:3306/' dbname];
|
||||
|
||||
conn = database(dbname, username, password, driver, dburl);
|
||||
|
||||
IDcentralina = 'ID0236';
|
||||
DTcatena = 'DT0177';
|
||||
date1 = '2023-07-31';
|
||||
date2 = '2023-08-27';
|
||||
comando = ['delete from ELABDATADISP where ToolNameID = ''' DTcatena ''' and Unitname = '''...
|
||||
IDcentralina ''' and EventDate >= ''' date1 ''' and EventDate <= ''' date2 ''' '];
|
||||
|
||||
curs = exec(conn,comando);
|
||||
close(conn)
|
||||
|
||||
disp('Fine!')
|
||||
|
||||
%% 4
|
||||
INI = 1;
|
||||
for i = INI:INI+6
|
||||
DatiInPlaceLink(1,i) = cellstr(num2str(DatiRaw(end,i+1)));
|
||||
end
|
||||
|
||||
INI = 1;
|
||||
for i = INI:INI+5
|
||||
DatiInPlaceLinkHR(1,i) = cellstr(num2str(DatiRaw(end,i+1)));
|
||||
end
|
||||
31
Tilt/CalcoloBiax_TLH.m
Executable file
31
Tilt/CalcoloBiax_TLH.m
Executable file
@@ -0,0 +1,31 @@
|
||||
function [Y_TLH,Z_TLH,asseX_TLH,asseY_TLH,asseZ_TLH,AlfaX_TLH,AlfaY_TLH] = CalcoloBiax_TLH(...
|
||||
SpeTLH,PsTLH,ii,jj,ax,ay,asseX_TLH,asseY_TLH,asseZ_TLH,Y_TLH,Z_TLH,AlfaX_TLH,...
|
||||
AlfaY_TLH,Traversine)
|
||||
|
||||
% Spostamento lungo l'asse X registrato dal nodo i
|
||||
Xi = Traversine * ay(ii,jj);
|
||||
% Spostamento lungo l'asse Y registrato dal nodo i
|
||||
Yi = -1*(SpeTLH(ii,1) - SpeTLH(ii,1) * (1 - ax(ii,jj).^2).^0.5); % SP*cos(alfa)
|
||||
% Spostamento lungo l'asse Z registrato dal nodo i; uso -1 per adattarlo al sistema di riferimento scelto
|
||||
% Zi = -1*SpeTLH(ii,1) * ax(ii,jj); % SP*sin(alfa) % fino a 11/06/2021
|
||||
Zi = SpeTLH(ii,1) * ax(ii,jj); % SP*sin(alfa) % dopo 11/06/2021
|
||||
|
||||
% Rollio
|
||||
AlfaX_TLH(ii,jj) = asind(ay(ii,jj));
|
||||
% Inclinazione
|
||||
AlfaY_TLH(ii,jj) = asind(ax(ii,jj));
|
||||
|
||||
% Matrici singoli spostamenti
|
||||
asseX_TLH(ii,jj) = Xi;
|
||||
asseY_TLH(ii,jj) = Yi;
|
||||
asseZ_TLH(ii,jj) = Zi;
|
||||
|
||||
if ii==1
|
||||
Y_TLH (ii,jj) = PsTLH(ii,1) + asseY_TLH(ii,jj);
|
||||
Z_TLH (ii,jj) = asseZ_TLH(ii,jj);
|
||||
else
|
||||
Y_TLH(ii,jj) = PsTLH(ii,1) + asseY_TLH(ii,jj) + Y_TLH(ii-1,jj) - PsTLH(ii-1,1);
|
||||
Z_TLH(ii,jj) = Z_TLH(ii-1,jj) + asseZ_TLH(ii,jj);
|
||||
end
|
||||
|
||||
end
|
||||
27
Tilt/CalcoloBiax_TLHRH.m
Executable file
27
Tilt/CalcoloBiax_TLHRH.m
Executable file
@@ -0,0 +1,27 @@
|
||||
function [Y_TLHRH,Z_TLHRH,asseY_TLHRH,asseZ_TLHRH,AlfaX_TLHRH,AlfaY_TLHRH]...
|
||||
= CalcoloBiax_TLHRH(SpeTLHRH,PsTLHRH,ii,jj,ax,ay,asseY_TLHRH,asseZ_TLHRH,...
|
||||
Y_TLHRH,Z_TLHRH,AlfaX_TLHRH,AlfaY_TLHRH)
|
||||
|
||||
% Spostamento lungo l'asse Y registrato dal nodo i
|
||||
Yi = -1*(SpeTLHRH(ii,1) - SpeTLHRH(ii,1) * cos(ax(ii,jj))); % SP*cos(alfa)
|
||||
% Spostamento lungo l'asse Z registrato dal nodo i;
|
||||
Zi = SpeTLHRH(ii,1) * sin(ax(ii,jj)); % SP*sin(alfa)
|
||||
|
||||
% Rollio
|
||||
AlfaX_TLHRH(ii,jj) = ay(ii,jj)/0.01745329251994329576923690768489; % Torno in gradi
|
||||
% Inclinazione
|
||||
AlfaY_TLHRH(ii,jj) = ax(ii,jj)/0.01745329251994329576923690768489;
|
||||
|
||||
% Matrici singoli spostamenti
|
||||
asseY_TLHRH(ii,jj) = Yi;
|
||||
asseZ_TLHRH(ii,jj) = Zi;
|
||||
|
||||
if ii==1
|
||||
Y_TLHRH (ii,jj) = PsTLHRH(ii) + asseY_TLHRH(ii,jj);
|
||||
Z_TLHRH (ii,jj) = asseZ_TLHRH(ii,jj);
|
||||
else
|
||||
Y_TLHRH(ii,jj) = PsTLHRH(ii,1) + asseY_TLHRH(ii,jj) + Y_TLHRH(ii-1,jj) - PsTLHRH(ii-1,1);
|
||||
Z_TLHRH(ii,jj) = Z_TLHRH(ii-1,jj) + asseZ_TLHRH(ii,jj);
|
||||
end
|
||||
|
||||
end
|
||||
98
Tilt/CalcoloRain.m
Executable file
98
Tilt/CalcoloRain.m
Executable file
@@ -0,0 +1,98 @@
|
||||
function [Rain,RainCum,ARRAYdateRL,ErrRainLink] = CalcoloRain(Dati_RL,ARRAYdateRL,...
|
||||
DatiElabRainLink,NuovoZeroRL,NdatiMedia,ErrRainLink,rRL,margine,Unit,...
|
||||
IDcentralina,conn,FileName)
|
||||
|
||||
text = 'CalcoloRain function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
if NuovoZeroRL == 1
|
||||
if NdatiMedia == 1
|
||||
ini = 2;
|
||||
Rain_Rif = Dati_RL(2,:) - Dati_RL(1,:);
|
||||
else
|
||||
ini = round(NdatiMedia/2);
|
||||
if rem(NdatiMedia,2) == 0
|
||||
ini = ini+1;
|
||||
end
|
||||
ini = ini + margine;
|
||||
if ini < 6
|
||||
ini = 6;
|
||||
end
|
||||
Rain_Rif = Dati_RL(ini,:) - Dati_RL(ini-1,:);
|
||||
end
|
||||
ErrRainLink = ErrRainLink(ini:end,:)';
|
||||
Dati_RL = Dati_RL(ini:end,:);
|
||||
DatiElabRainLink = DatiElabRainLink(ini:end,:);
|
||||
ARRAYdateRL = ARRAYdateRL(ini:end,1);
|
||||
else
|
||||
ErrRainLink = ErrRainLink';
|
||||
[rR]=size(Dati_RL);
|
||||
if rR > 1
|
||||
Rain_Rif = Dati_RL(2,:) - Dati_RL(1,:);
|
||||
else
|
||||
Rain_Rif = Dati_RL(1,:);
|
||||
end
|
||||
end
|
||||
|
||||
[r,c] = size(Dati_RL);
|
||||
Rain = zeros(r,c);
|
||||
|
||||
comando = ['select type_id from units where name = ''' IDcentralina ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Type = cell2mat(curs.Data);
|
||||
if Type == 7 % NESA
|
||||
Rain = Dati_RL;
|
||||
else
|
||||
if strcmp(Unit,'SwissMetNet')
|
||||
Rain = Dati_RL;
|
||||
else
|
||||
var = diff(Dati_RL',1,2);
|
||||
varT = var';
|
||||
[a,b] = size(varT);
|
||||
for ii = 1:a
|
||||
for jj = 1:b
|
||||
if varT(ii,jj) <0
|
||||
varT(ii,jj) = 0; % in questo modo tengo conto degli eventuali azzeramenti del contatore
|
||||
end
|
||||
if ii == 1 && Rain_Rif(1,b) < 0
|
||||
Rain_Rif(1,b) = 0;
|
||||
end
|
||||
end
|
||||
end
|
||||
Rain(1,:) = Rain_Rif;
|
||||
for ii = 2:r
|
||||
Rain(ii,:) = varT(ii-1,:);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if NuovoZeroRL == 0
|
||||
RainCum = cumsum(Rain);
|
||||
else % se ho dati precedenti, devo sommarli a quelli
|
||||
[~,cE] = size(DatiElabRainLink);
|
||||
Rif_Rain = zeros(1,rRL);
|
||||
cont = 4;
|
||||
n = 1;
|
||||
while cont<=cE
|
||||
Rif_Rain(1,n) = cell2mat(DatiElabRainLink(1,cont)); % ultimo valore di cumulata definitivo su DB
|
||||
cont=cont+4;
|
||||
n = n+1;
|
||||
end
|
||||
RainCum_p = cumsum(Rain)-Rain(1,:); % cumulata dei nuovi dati
|
||||
[row,col] = size(Rain);
|
||||
RainCum = zeros(row,col);
|
||||
for i = 1:row
|
||||
for j = 1:col
|
||||
RainCum(i,j) = RainCum_p(i,j) + Rif_Rain(1,j);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
text = 'Single and cumulated rain values calculated correctly. CalcoloRain function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
39
Tilt/CalcoloSPP.m
Executable file
39
Tilt/CalcoloSPP.m
Executable file
@@ -0,0 +1,39 @@
|
||||
function [SPP,ARRAYdateSPP] = CalcoloSPP(DatiSPPLink,FileName)
|
||||
|
||||
text = 'CalcoloSPP function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
[r,c]=size(DatiSPPLink);
|
||||
Ncorr = 0;
|
||||
% Elimino gli eventuali Not a Number
|
||||
for a = 2:r
|
||||
for b = 1:c
|
||||
check = isnan(DatiSPPLink(a,b));
|
||||
if check == 1
|
||||
DatiSPPLink(a,b) = DatiSPPLink(a-1,b);
|
||||
Ncorr = Ncorr+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = [num2str(Ncorr) ' NaN of SPP Link corrected by CalcoloSPP function'];
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
ARRAYdateSPP = DatiSPPLink(:,1); % data
|
||||
val_SPP = DatiSPPLink(:,2:end); % dati presenza acqua
|
||||
[r,c] = size(val_SPP );
|
||||
SPP = zeros(r,c);
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
if val_SPP(ii,jj) >2.1 % V
|
||||
SPP(ii,jj) = 1; % Modificato 28/06/23
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
text = 'SPP sensor calculated correctly. CalcoloSPP function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
101
Tilt/CalcoloSnow.m
Executable file
101
Tilt/CalcoloSnow.m
Executable file
@@ -0,0 +1,101 @@
|
||||
function [Snow,SnowCum,ARRAYdateSL,ErrSnowLink] = CalcoloSnow(DatiSnowLink,...
|
||||
DatiElabSnowLink,NuovoZeroSL,NdatiMedia,ErrSnowLink,rSL,margine,Unit,...
|
||||
IDcentralina,conn,FileName)
|
||||
|
||||
text = 'CalcoloSnow function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
ARRAYdateSL = DatiSnowLink(:,1);
|
||||
Dati_SL = DatiSnowLink(:,2);
|
||||
|
||||
if NuovoZeroSL == 1
|
||||
if NdatiMedia == 1
|
||||
ini = 2;
|
||||
Snow_Rif = Dati_SL(2,:) - Dati_SL(1,:);
|
||||
else
|
||||
ini = round(NdatiMedia/2);
|
||||
if rem(NdatiMedia,2) == 0
|
||||
ini = ini+1;
|
||||
end
|
||||
ini = ini + margine;
|
||||
if ini < 6
|
||||
ini = 6;
|
||||
end
|
||||
Snow_Rif = Dati_SL(ini,:) - Dati_SL(ini-1,:);
|
||||
end
|
||||
ErrSnowLink = ErrSnowLink(ini:end,:)';
|
||||
Dati_SL = Dati_SL(ini:end,:);
|
||||
DatiElabSnowLink = DatiElabSnowLink(ini:end,:);
|
||||
ARRAYdateSL = ARRAYdateSL(ini:end,1);
|
||||
else
|
||||
ErrSnowLink = ErrSnowLink';
|
||||
[rR]=size(Dati_SL);
|
||||
if rR > 1
|
||||
Snow_Rif = Dati_SL(2,:) - Dati_SL(1,:);
|
||||
else
|
||||
Snow_Rif = Dati_SL(1,:);
|
||||
end
|
||||
end
|
||||
|
||||
[r,c] = size(Dati_SL);
|
||||
Snow = zeros(r,c);
|
||||
|
||||
comando = ['select type_id from units where name = ''' IDcentralina ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Type = cell2mat(curs.Data);
|
||||
if Type == 7 % NESA
|
||||
Snow = Dati_SL;
|
||||
else
|
||||
if strcmp(Unit,'SwissMetNet')
|
||||
Snow = Dati_SL;
|
||||
else
|
||||
var = diff(Dati_SL',1,2);
|
||||
varT = var';
|
||||
[a,b] = size(varT);
|
||||
for ii = 1:a
|
||||
for jj = 1:b
|
||||
if varT(ii,jj) <0
|
||||
varT(ii,jj) = 0; % in questo modo tengo conto degli eventuali azzeramenti del contatore
|
||||
end
|
||||
if ii == 1 && Snow_Rif(1,b) < 0
|
||||
Snow_Rif(1,b) = 0;
|
||||
end
|
||||
end
|
||||
end
|
||||
Snow(1,:) = Snow_Rif;
|
||||
for ii = 2:r
|
||||
Snow(ii,:) = varT(ii-1,:);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if NuovoZeroSL == 0
|
||||
SnowCum = cumsum(Snow);
|
||||
else % se ho dati precedenti, devo sommarli a quelli
|
||||
[~,cE] = size(DatiElabSnowLink);
|
||||
Rif_Rain = zeros(1,rSL);
|
||||
cont = 4;
|
||||
n = 1;
|
||||
while cont<=cE
|
||||
Rif_Rain(1,n) = cell2mat(DatiElabSnowLink(1,cont)); % ultimo valore di cumulata definitivo su DB
|
||||
cont=cont+4;
|
||||
n = n+1;
|
||||
end
|
||||
RainCum_p = cumsum(Snow)-Snow(1,:); % cumulata dei nuovi dati
|
||||
[row,col] = size(Snow);
|
||||
SnowCum = zeros(row,col);
|
||||
for i = 1:row
|
||||
for j = 1:col
|
||||
SnowCum(i,j) = RainCum_p(i,j) + Rif_Rain(1,j);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
text = 'Single and cumulated snow values calculated correctly. CalcoloSnow function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
25
Tilt/DB_date_time.m
Executable file
25
Tilt/DB_date_time.m
Executable file
@@ -0,0 +1,25 @@
|
||||
function idElabData = DB_date_time(IDcentralina,DTcatena,NodeNum,ListaDate,ARRAYdate,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
idElabData = zeros(l,1); % Contiene gli id delle date delle quali ho già dati
|
||||
cc = 1; % contatore
|
||||
for ii=1:l
|
||||
dString = datestr(ARRAYdate(ii),'yyyy-mm-dd');
|
||||
tString = datestr(ARRAYdate(ii),'HH:MM:SS');
|
||||
|
||||
comando = ['select idElabData from ELABDATADISP where UnitName = ''' ...
|
||||
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' ...
|
||||
nNodo ''' and EventDate = ''' dString ''' and EventTime = ''' tString ''' order by EventDate'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
idDate = curs.Data;
|
||||
if strcmp(idDate,'No Data')
|
||||
idElabData(cc,1) = 0; % 0 indica che il dato non è presente su DB
|
||||
else
|
||||
idElabData(cc,1) = cell2mat(idDate);
|
||||
end
|
||||
cc = cc+1;
|
||||
end
|
||||
|
||||
end
|
||||
24
Tilt/DB_date_time_RIS.m
Executable file
24
Tilt/DB_date_time_RIS.m
Executable file
@@ -0,0 +1,24 @@
|
||||
function idElabData_RIS = DB_date_time_RIS(IDcentralina,DTcatena,NodeNum,ListaDate,ARRAYdate,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
idElabData_RIS = zeros(l,1); % Contiene gli id delle date delle quali ho già dati
|
||||
cc = 1; % contatore
|
||||
for ii=1:l
|
||||
dString = datestr(ARRAYdate(ii),'yyyy-mm-dd HH:MM:SS');
|
||||
|
||||
comando = ['select id from ELABDATARISUL where UnitName = ''' ...
|
||||
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' ...
|
||||
nNodo ''' and EventTimestamp = ''' dString ''' order by EventTimestamp'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
idDate = curs.Data;
|
||||
if strcmp(idDate,'No Data')
|
||||
idElabData_RIS(cc,1) = 0; % 0 indica che il dato non è presente su DB
|
||||
else
|
||||
idElabData_RIS(cc,1) = cell2mat(idDate);
|
||||
end
|
||||
cc = cc+1;
|
||||
end
|
||||
|
||||
end
|
||||
39
Tilt/DBwriteBL.m
Executable file
39
Tilt/DBwriteBL.m
Executable file
@@ -0,0 +1,39 @@
|
||||
function DBwriteBL(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
check = isnan(cell2mat(DATAinsert(ii,7)));
|
||||
if check == 0
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','pressure','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),DATAinsert(ii,4),...
|
||||
DATAinsert(ii,5),DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8)];
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','pressure','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),DATAinsert(ii,4),...
|
||||
DATAinsert(ii,5),DATAinsert(ii,6),DATAinsert(ii,8)];
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
end
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
check = isnan(cell2mat(DATAinsert(ii,7)));
|
||||
if check == 0
|
||||
colnames = {'pressure','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8)];
|
||||
else
|
||||
colnames = {'pressure','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,8)];
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
109
Tilt/DBwriteHD.m
Executable file
109
Tilt/DBwriteHD.m
Executable file
@@ -0,0 +1,109 @@
|
||||
function DBwriteHD(DATAinsert,idElabData,idElabData_RIS,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
tablenameRIS = 'ELABDATARISUL';
|
||||
tablename = 'ELABDATADISP';
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero, accelerazione NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20),...
|
||||
DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero, accelerazione NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20),...
|
||||
DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % aggiorno tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' ...
|
||||
nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4)) ''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
idDataRIS = idElabData_RIS(ii,1);
|
||||
if idDataRIS == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
colnamesRIS = {'UnitName','ToolNameID','NodeNum','EventTimestamp',...
|
||||
'ris_acc','ris_mag'};
|
||||
dataRIS = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,25),DATAinsert(ii,23),DATAinsert(ii,24)];
|
||||
fastinsert(conn,tablenameRIS,colnamesRIS,dataRIS);
|
||||
else
|
||||
colnamesRIS = {'ris_acc','ris_mag'};
|
||||
dataRIS = [DATAinsert(ii,23),DATAinsert(ii,24)];
|
||||
whereclauseRIS = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' ...
|
||||
nNodo ''' and EventTimestamp = ''' cell2mat(DATAinsert(ii,25)) ''' '];
|
||||
update(conn,tablenameRIS,colnamesRIS,dataRIS,whereclauseRIS)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
109
Tilt/DBwriteHDVR.m
Executable file
109
Tilt/DBwriteHDVR.m
Executable file
@@ -0,0 +1,109 @@
|
||||
function DBwriteHDVR(DATAinsert,idElabData,idElabData_RIS,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
tablenameRIS = 'ELABDATARISUL';
|
||||
tablename = 'ELABDATADISP';
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero, accelerazione NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20),...
|
||||
DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero, accelerazione NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20),...
|
||||
DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % aggiorno tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' ...
|
||||
nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4)) ''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
idDataRIS = idElabData_RIS(ii,1);
|
||||
if idDataRIS == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
colnamesRIS = {'UnitName','ToolNameID','NodeNum','EventTimestamp',...
|
||||
'ris_acc','ris_mag'};
|
||||
dataRIS = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,25),DATAinsert(ii,23),DATAinsert(ii,24)];
|
||||
fastinsert(conn,tablenameRIS,colnamesRIS,dataRIS);
|
||||
else
|
||||
colnamesRIS = {'ris_acc','ris_mag'};
|
||||
dataRIS = [DATAinsert(ii,23),DATAinsert(ii,24)];
|
||||
whereclauseRIS = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' ...
|
||||
nNodo ''' and EventTimestamp = ''' cell2mat(DATAinsert(ii,25)) ''' '];
|
||||
update(conn,tablenameRIS,colnamesRIS,dataRIS,whereclauseRIS)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
95
Tilt/DBwriteIPL.m
Executable file
95
Tilt/DBwriteIPL.m
Executable file
@@ -0,0 +1,95 @@
|
||||
function DBwriteIPL(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero, accelerazione NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20),...
|
||||
DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero, accelerazione NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20),...
|
||||
DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' ...
|
||||
nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4)) ''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
96
Tilt/DBwriteIPLHR.m
Executable file
96
Tilt/DBwriteIPLHR.m
Executable file
@@ -0,0 +1,96 @@
|
||||
function DBwriteIPLHR(DATAinsert,idElabData,ListaDate,NodeNum,DTcatena,IDcentralina,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20),...
|
||||
DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20)...
|
||||
,DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = ''' ...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
74
Tilt/DBwriteKL.m
Executable file
74
Tilt/DBwriteKL.m
Executable file
@@ -0,0 +1,74 @@
|
||||
function DBwriteKL(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn,NodoKlinoLink)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
checkT = isnan(cell2mat(DATAinsert(ii,9)));
|
||||
if checkT == 1 % il vettore Temperatura č NaN
|
||||
if strcmp(NodoKlinoLink(1,4),'ADC') || strcmp(NodoKlinoLink{1,4} ,'null') ...
|
||||
|| isempty(NodoKlinoLink{1,4}) == 1 || strcmp(NodoKlinoLink{1,4} ,'g')
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'XShift','YShift','ZShift','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,10)];
|
||||
elseif strcmp(NodoKlinoLink{1,4} ,'Gradi')
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'XShift','YShift','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,10)];
|
||||
end
|
||||
else
|
||||
if strcmp(NodoKlinoLink(1,4),'ADC') || strcmp(NodoKlinoLink{1,4} ,'null') ...
|
||||
|| isempty(NodoKlinoLink{1,4}) == 1 || strcmp(NodoKlinoLink{1,4} ,'g')
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'XShift','YShift','ZShift','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),DATAinsert(ii,10)];
|
||||
elseif strcmp(NodoKlinoLink{1,4} ,'Gradi')
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'XShift','YShift','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,9),DATAinsert(ii,10)];
|
||||
end
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
checkT = isnan(cell2mat(DATAinsert(ii,9)));
|
||||
if checkT == 1 % il vettore Temperatura č NaN
|
||||
if strcmp(NodoKlinoLink(1,4),'ADC') || strcmp(NodoKlinoLink{1,4} ,'null') ...
|
||||
|| isempty(NodoKlinoLink{1,4}) == 1 || strcmp(NodoKlinoLink{1,4} ,'g')
|
||||
colnames = {'XShift','YShift','ZShift','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8),...
|
||||
DATAinsert(ii,10)];
|
||||
elseif strcmp(NodoKlinoLink{1,4} ,'Gradi')
|
||||
colnames = {'XShift','YShift','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,10)];
|
||||
end
|
||||
else
|
||||
if strcmp(NodoKlinoLink(1,4),'ADC') || strcmp(NodoKlinoLink{1,4} ,'null') || ...
|
||||
isempty(NodoKlinoLink{1,4}) == 1 || strcmp(NodoKlinoLink{1,4} ,'g')
|
||||
colnames = {'XShift','YShift','ZShift','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8),...
|
||||
DATAinsert(ii,9),DATAinsert(ii,10)];
|
||||
elseif strcmp(NodoKlinoLink{1,4} ,'Gradi')
|
||||
colnames = {'XShift','YShift','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,9),DATAinsert(ii,10)];
|
||||
end
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
43
Tilt/DBwriteKLHR.m
Executable file
43
Tilt/DBwriteKLHR.m
Executable file
@@ -0,0 +1,43 @@
|
||||
function DBwriteKLHR(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
checkT = isnan(cell2mat(DATAinsert(ii,8)));
|
||||
if checkT == 1 % il vettore Temperatura č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'XShift','YShift','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,9)];
|
||||
else
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'XShift','YShift','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9)];
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
checkT = isnan(cell2mat(DATAinsert(ii,8)));
|
||||
if checkT == 1 % il vettore Temperatura č NaN
|
||||
colnames = {'XShift','YShift','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,9)];
|
||||
else
|
||||
colnames = {'XShift','YShift','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8),...
|
||||
DATAinsert(ii,9)];
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
42
Tilt/DBwriteKL_future.m
Executable file
42
Tilt/DBwriteKL_future.m
Executable file
@@ -0,0 +1,42 @@
|
||||
function DBwriteKL(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn,NodoKlinoLink)
|
||||
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
tablename = 'ELABDATADISP';
|
||||
checkT = isnan(cell2mat(DATAinsert(ii,9)));
|
||||
if checkT == 1 % il vettore Temperatura č NaN
|
||||
if strcmp(NodoKlinoLink(1,4),'ADC') || strcmp(NodoKlinoLink{1,4} ,'null') || isempty(NodoKlinoLink{1,4}) == 1
|
||||
comando = ['INSERT INTO ' tablename ' (UnitName,ToolNameID,NodeNum,EventDate,EventTime,XShift,YShift,ZShift,calcerr)' ...
|
||||
' VALUES( ' DATAinsert(ii,1) ',' DATAinsert(ii,2) ',' DATAinsert(ii,3) ',' DATAinsert(ii,4) ','...
|
||||
DATAinsert(ii,5) ',' DATAinsert(ii,6) ',' DATAinsert(ii,7) ',' DATAinsert(ii,8) ',' DATAinsert(ii,10)...
|
||||
'), ON DUPLICATE KEY UPDATE XShift=' DATAinsert(ii,6) ', YShift=' DATAinsert(ii,7) ', ZShift=' DATAinsert(ii,8)...
|
||||
', calcerr=' DATAinsert(ii,10)];
|
||||
elseif strcmp(NodoKlinoLink{1,4} ,'Gradi')
|
||||
comando = ['INSERT INTO ' tablename ' (UnitName,ToolNameID,NodeNum,EventDate,EventTime,XShift,YShift,calcerr)' ...
|
||||
' VALUES( ' DATAinsert(ii,1) ',' DATAinsert(ii,2) ',' DATAinsert(ii,3) ',' DATAinsert(ii,4) ','...
|
||||
DATAinsert(ii,5) ',' DATAinsert(ii,6) ',' DATAinsert(ii,7) ',' DATAinsert(ii,10)...
|
||||
'), ON DUPLICATE KEY UPDATE XShift=' DATAinsert(ii,6) ', YShift=' DATAinsert(ii,7) ', calcerr=' DATAinsert(ii,10)];
|
||||
end
|
||||
else
|
||||
if strcmp(NodoKlinoLink(1,4),'ADC') || strcmp(NodoKlinoLink{1,4} ,'null') || isempty(NodoKlinoLink{1,4}) == 1
|
||||
comando = ['INSERT INTO ' tablename ' (UnitName,ToolNameID,NodeNum,EventDate,EventTime,XShift,YShift,ZShift,T_node,calcerr)' ...
|
||||
' VALUES( ' DATAinsert(ii,1) ',' DATAinsert(ii,2) ',' DATAinsert(ii,3) ',' DATAinsert(ii,4) ','...
|
||||
DATAinsert(ii,5) ',' DATAinsert(ii,6) ',' DATAinsert(ii,7) ',' DATAinsert(ii,8) ',' DATAinsert(ii,9) ', ' DATAinsert(ii,10)...
|
||||
'), ON DUPLICATE KEY UPDATE XShift=' DATAinsert(ii,6) ', YShift=' DATAinsert(ii,7) ', ZShift=' DATAinsert(ii,8)...
|
||||
', T_node = ' DATAinsert(ii,9) ', calcerr=' DATAinsert(ii,10)];
|
||||
elseif strcmp(NodoKlinoLink{1,4} ,'Gradi')
|
||||
comando = ['INSERT INTO ' tablename ' (UnitName,ToolNameID,NodeNum,EventDate,EventTime,XShift,YShift,T_node,calcerr)' ...
|
||||
' VALUES( ''' string(DATAinsert(ii,1)) ''',''' string(DATAinsert(ii,2)) ''',''' string(DATAinsert(ii,3)) ''',''' string(DATAinsert(ii,4)) ''','''...
|
||||
string(DATAinsert(ii,5)) ''',''' string(DATAinsert(ii,6)) ''',''' string(DATAinsert(ii,7)) ''',''' string(DATAinsert(ii,9)) ''', ''' string(DATAinsert(ii,10))...
|
||||
''') ON DUPLICATE KEY UPDATE XShift=''' string(DATAinsert(ii,6)) ''', YShift=''' string(DATAinsert(ii,7)) ...
|
||||
''', T_node=''' string(DATAinsert(ii,9)) ''', calcerr=''' string(DATAinsert(ii,10)) ''' '];
|
||||
end
|
||||
end
|
||||
comando = strjoin(comando);
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
disp(curs.Data)
|
||||
end
|
||||
|
||||
end
|
||||
24
Tilt/DBwriteLL.m
Executable file
24
Tilt/DBwriteLL.m
Executable file
@@ -0,0 +1,24 @@
|
||||
function DBwriteLL(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','load_value','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),DATAinsert(ii,4),...
|
||||
DATAinsert(ii,5),DATAinsert(ii,6),DATAinsert(ii,7)];
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'load_value','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7)];
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena...
|
||||
''' and NodeNum = ''' nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
25
Tilt/DBwritePE.m
Executable file
25
Tilt/DBwritePE.m
Executable file
@@ -0,0 +1,25 @@
|
||||
function DBwritePE(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','XShift','YShift','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),DATAinsert(ii,4),...
|
||||
DATAinsert(ii,5),DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8)];
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'XShift','YShift','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8)];
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' ...
|
||||
cell2mat(DATAinsert(ii,4)) ''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
41
Tilt/DBwritePL.m
Executable file
41
Tilt/DBwritePL.m
Executable file
@@ -0,0 +1,41 @@
|
||||
function DBwritePL(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
check = isnan(cell2mat(DATAinsert(ii,8)));
|
||||
if check == 0
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','water_level','pressure','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),DATAinsert(ii,4),...
|
||||
DATAinsert(ii,5),DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9)];
|
||||
else
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','water_level','pressure','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),DATAinsert(ii,4),...
|
||||
DATAinsert(ii,5),DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,9)];
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
check = isnan(cell2mat(DATAinsert(ii,8)));
|
||||
if check == 0
|
||||
colnames = {'water_level','pressure','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9)];
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
else
|
||||
colnames = {'water_level','pressure','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,9)];
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
end
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
24
Tilt/DBwritePT100.m
Executable file
24
Tilt/DBwritePT100.m
Executable file
@@ -0,0 +1,24 @@
|
||||
function DBwritePT100(DATAinsert,idElabData,ListaDate,NodeNum,DTcatena,IDcentralina,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),DATAinsert(ii,7)];
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'T_node','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7)];
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = '''...
|
||||
cell2mat(DATAinsert(ii,4)) ''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
25
Tilt/DBwriteRL.m
Executable file
25
Tilt/DBwriteRL.m
Executable file
@@ -0,0 +1,25 @@
|
||||
function DBwriteRL(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','ZShift','Z','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),DATAinsert(ii,4),...
|
||||
DATAinsert(ii,5),DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8)];
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'ZShift','Z','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8)];
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
25
Tilt/DBwriteSL.m
Executable file
25
Tilt/DBwriteSL.m
Executable file
@@ -0,0 +1,25 @@
|
||||
function DBwriteSL(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','ZShift','Z','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),DATAinsert(ii,4),...
|
||||
DATAinsert(ii,5),DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8)];
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'ZShift','Z','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8)];
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
25
Tilt/DBwriteSPP.m
Executable file
25
Tilt/DBwriteSPP.m
Executable file
@@ -0,0 +1,25 @@
|
||||
function DBwriteSPP(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non è su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','XShift'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),DATAinsert(ii,4),...
|
||||
DATAinsert(ii,5),DATAinsert(ii,6)];
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = 'XShift';
|
||||
data = DATAinsert(ii,6);
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
107
Tilt/DBwriteTL.m
Executable file
107
Tilt/DBwriteTL.m
Executable file
@@ -0,0 +1,107 @@
|
||||
function DBwriteTL(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero, accelerazione NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20),...
|
||||
DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if strcmp(IDcentralina,'ID0003') && strcmp(DTcatena,'DT0002')
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,20),...
|
||||
DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero, accelerazione NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20),...
|
||||
DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' ...
|
||||
nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4)) ''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
91
Tilt/DBwriteTLH.m
Executable file
91
Tilt/DBwriteTLH.m
Executable file
@@ -0,0 +1,91 @@
|
||||
function DBwriteTLH(DATAinsert,idElabData,ListaDate,NodeNum,DTcatena,IDcentralina,Traversine,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,13)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,11)));
|
||||
if checkV == 1 % NON scrivo velocitŕ ed accelerazione
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,15),DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
else % NON scrivo l'accelerazione
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','speed','speed_local',...
|
||||
'calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,15),DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
end
|
||||
else % Scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','speed','speed_local',...
|
||||
'acceleration','acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
end
|
||||
if Traversine ~= 0 % Sghembo
|
||||
[~,c] = size(colnames);
|
||||
colnames(1,c+1) = {'XShift'};
|
||||
data(1,18) = DATAinsert(ii,18);
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,13)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,11)));
|
||||
if checkV == 1 % NON aggiorno velocitŕ ed accelerazione
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,15),DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
else % NON aggiorno l'accelerazione
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','speed','speed_local',...
|
||||
'calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,15),DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
end
|
||||
else % Aggiorno tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','speed','speed_local',...
|
||||
'acceleration','acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
end
|
||||
if Traversine ~= 0 % Sghembo
|
||||
[~,c] = size(colnames);
|
||||
colnames(1,c+1) = {'XShift'};
|
||||
data(1,18) = DATAinsert(ii,18);
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' ...
|
||||
cell2mat(DATAinsert(ii,4)) ''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
96
Tilt/DBwriteTLHR.m
Executable file
96
Tilt/DBwriteTLHR.m
Executable file
@@ -0,0 +1,96 @@
|
||||
function DBwriteTLHR(DATAinsert,idElabData,ListaDate,NodeNum,DTcatena,IDcentralina,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20),...
|
||||
DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,19)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,17)));
|
||||
if checkV == 1 % il vettore velocitŕ č NaN
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
else % velocitŕ č un numero
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,20)...
|
||||
,DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
else % scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'X','Y','Z','XShift','YShift','ZShift','HShift','HShift_local',...
|
||||
'HShiftDir','T_node','speed','speed_local','acceleration',...
|
||||
'acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17),DATAinsert(ii,18),...
|
||||
DATAinsert(ii,19),DATAinsert(ii,20),DATAinsert(ii,21),DATAinsert(ii,22)];
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = ''' ...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' cell2mat(DATAinsert(ii,4))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
81
Tilt/DBwriteTLHRH.m
Executable file
81
Tilt/DBwriteTLHRH.m
Executable file
@@ -0,0 +1,81 @@
|
||||
function DBwriteTLHRH(DATAinsert,idElabData,ListaDate,NodeNum,DTcatena,IDcentralina,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,13)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,11)));
|
||||
if checkV == 1 % NON scrivo velocitŕ ed accelerazione
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,15),DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
else % NON scrivo l'accelerazione
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','speed','speed_local',...
|
||||
'calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,15),DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
end
|
||||
else % Scrivo tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','speed','speed_local',...
|
||||
'acceleration','acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
checkA = isnan(cell2mat(DATAinsert(ii,13)));
|
||||
if checkA == 1 % il vettore accelerazione č NaN
|
||||
checkV = isnan(cell2mat(DATAinsert(ii,11)));
|
||||
if checkV == 1 % NON aggiorno velocitŕ ed accelerazione
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,15),DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
else % NON aggiorno l'accelerazione
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','speed','speed_local',...
|
||||
'calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,15),DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
end
|
||||
else % Aggiorno tutto
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'Y','Z','YShift','ZShift','T_node','speed','speed_local',...
|
||||
'acceleration','acceleration_local','calcerr','AlfaX','AlfaY'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),...
|
||||
DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9),...
|
||||
DATAinsert(ii,10),DATAinsert(ii,11),DATAinsert(ii,12),...
|
||||
DATAinsert(ii,13),DATAinsert(ii,14),DATAinsert(ii,15),...
|
||||
DATAinsert(ii,16),DATAinsert(ii,17)];
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' ...
|
||||
cell2mat(DATAinsert(ii,4)) ''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
24
Tilt/DBwriteThL.m
Executable file
24
Tilt/DBwriteThL.m
Executable file
@@ -0,0 +1,24 @@
|
||||
function DBwriteThL(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),DATAinsert(ii,7)];
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
colnames = {'T_node','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7)];
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = '''...
|
||||
cell2mat(DATAinsert(ii,4)) ''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
37
Tilt/DBwriteWL.m
Executable file
37
Tilt/DBwriteWL.m
Executable file
@@ -0,0 +1,37 @@
|
||||
function DBwriteWL(DATAinsert,idElabData,ListaDate,NodeNum,IDcentralina,DTcatena,cWL,Therm,conn)
|
||||
|
||||
nNodo = num2str(NodeNum);
|
||||
l = ListaDate;
|
||||
|
||||
for ii=1:l
|
||||
idData = idElabData(ii,1);
|
||||
if idData == 0 % Se la data non č su DB (=0), scrivo i dati
|
||||
tablename = 'ELABDATADISP';
|
||||
if Therm(cWL) == 1 % scrivo la T
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime',...
|
||||
'XShift','water_level','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),DATAinsert(ii,4),DATAinsert(ii,5),...
|
||||
DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9)];
|
||||
else % NON scrivo la T
|
||||
colnames = {'UnitName','ToolNameID','NodeNum','EventDate','EventTime','XShift','water_level','calcerr'};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,9)];
|
||||
end
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
tablename = 'ELABDATADISP';
|
||||
if Therm(cWL) == 1 % scrivo la T
|
||||
colnames = {'XShift','water_level','T_node','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,8),DATAinsert(ii,9)];
|
||||
else % NON scrivo la T
|
||||
colnames = {'XShift','water_level','calcerr'};
|
||||
data = [DATAinsert(ii,6),DATAinsert(ii,7),DATAinsert(ii,9)];
|
||||
end
|
||||
whereclause = ['WHERE UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeNum = ''' nNodo ''' and EventDate = ''' ...
|
||||
cell2mat(DATAinsert(ii,4)) ''' and EventTime = ''' cell2mat(DATAinsert(ii,5)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
712
Tilt/Fukuzono.m
Executable file
712
Tilt/Fukuzono.m
Executable file
@@ -0,0 +1,712 @@
|
||||
function [alert,alert_local,alarm,alarm_local,Date,RQ,RQ_Loc,DataFuK,...
|
||||
DataFuK_local,Tr_mail,Tr_Loc_mail,Tr_Inf,Tr_Inf_Loc,Tr_Sup,Tr_Sup_Loc,...
|
||||
Tr_Loc_HR,DataFuK_local_HR,Number,Number_Loc] = Fukuzono(IDcentralina,...
|
||||
DTcatena,date,ARRAYdate,yes3D,rNL,NodoTilt,NodoTiltHR,NodoTiltHR3D,conn,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
|
||||
text = 'Fukuzono function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
Tr_Loc_HR = [];
|
||||
DataFuK_local_HR = [];
|
||||
|
||||
%% Scarico i dati da DB
|
||||
data_rif = ARRAYdate(end)-30; %30
|
||||
if data_rif > datenum(date)
|
||||
data = datestr(data_rif,'yyyy-mm-dd');
|
||||
else
|
||||
data = date;
|
||||
end
|
||||
for n = 1:rNL
|
||||
NodeNum = num2str(cell2mat(NodoTilt(n,2)));
|
||||
comando = ['select EventDate, EventTime, HShift_local, HShift from ElabDataView where EventDate >= ''' ...
|
||||
data ''' and ToolNameID = ''' DTcatena ''' and UnitName = ''' IDcentralina ...
|
||||
''' and NodeNum = ''' NodeNum ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Dati = curs.Data;
|
||||
% Modifico il formato di data e ora in DATini.
|
||||
[rD,~] = size(Dati);
|
||||
T = [cell2mat(Dati(:,1)) repmat(' ', [rD,1]) cell2mat(Dati(:,2))];
|
||||
Date = datenum(T); % Data
|
||||
HShift_local(:,n) = cell2mat(Dati(:,3)); % Loc 2D
|
||||
HShift(:,n) = cell2mat(Dati(:,4)); % Cum 2D
|
||||
end
|
||||
|
||||
%% Criterio della velocità positiva - Criterio 0
|
||||
[rS,cS] = size(HShift);
|
||||
Criterio_0 = zeros(rS-1,cS);
|
||||
Criterio_0_local = zeros(rS-1,cS);
|
||||
Speed = zeros(rS-1,cS);
|
||||
Speed_local = zeros(rS-1,cS);
|
||||
for i = 1:cS % nodi
|
||||
for j = 4:rS-1 % date
|
||||
% Cumulati
|
||||
Speed(j,i) = (HShift(j+1,i) - HShift(j,i))/(Date(j+1)-Date(j)); % m/g
|
||||
if j == 4
|
||||
Speed(j-1,i) = (HShift(j,i) - HShift(j-1,i))/(Date(j)-Date(j-1)); % m/g
|
||||
Speed(j-2,i) = (HShift(j-1,i) - HShift(j-2,i))/(Date(j-1)-Date(j-2)); % m/g
|
||||
Speed(j-3,i) = (HShift(j-2,i) - HShift(j-3,i))/(Date(j-2)-Date(j-3)); % m/g
|
||||
Speed_local(j-1,i) = (HShift_local(j,i) - HShift_local(j-1,i))/(Date(j)-Date(j-1)); % m/g
|
||||
Speed_local(j-2,i) = (HShift_local(j-1,i) - HShift_local(j-2,i))/(Date(j-1)-Date(j-2)); % m/g
|
||||
Speed_local(j-3,i) = (HShift_local(j-2,i) - HShift_local(j-3,i))/(Date(j-2)-Date(j-3)); % m/g
|
||||
end
|
||||
if Speed(j,i) > 0 && Speed(j-1,i) > 0 && Speed(j-2,i) > 0 && Speed(j-3,i) > 0
|
||||
Criterio_0(j,i) = 1;
|
||||
end
|
||||
% Locali
|
||||
Speed_local(j,i) = (HShift_local(j+1,i) - HShift_local(j,i))/(Date(j+1)-Date(j)); % m/g
|
||||
if Speed_local(j,i) > 0 && Speed_local(j-1,i) > 0 && Speed_local(j-2,i) > 0 && Speed_local(j-3,i) > 0
|
||||
Criterio_0_local(j,i) = 1;
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Date = Date(2:end);
|
||||
text = 'Criterion 0 executed';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Faccio i calcoli
|
||||
[r,c] = size(Speed_local);
|
||||
Delta_Speed_local = zeros(r,c);
|
||||
Delta_Speed = zeros(r,c);
|
||||
diff_Cum = diff(Speed);
|
||||
diff_Loc = diff(Speed_local);
|
||||
Delta_Speed(2:end,:) = diff_Cum;
|
||||
Delta_Speed_local(2:end,:) = diff_Loc;
|
||||
act = zeros(r,c);
|
||||
act_local = zeros(r,c);
|
||||
for i = 1:c % nodi
|
||||
for j = 2:r % date
|
||||
if Delta_Speed(j,i) > 0
|
||||
act(j,i) = 1;
|
||||
elseif Delta_Speed(j,i) < 0
|
||||
act(j,i) = -1;
|
||||
end
|
||||
if Delta_Speed_local(j,i) > 0
|
||||
act_local(j,i) = 1;
|
||||
elseif Delta_Speed_local(j,i) < 0
|
||||
act_local(j,i) = -1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
%% Criterio della Velocità Crescente - Criterio 1
|
||||
Criterio_1 = zeros(r,c);
|
||||
Criterio_1_local = zeros(r,c);
|
||||
alert = zeros(r,c);
|
||||
alert_local = zeros(r,c);
|
||||
if r > 10
|
||||
for i = 1:c % nodi
|
||||
for j = 10:r % date
|
||||
if act(j,i) == 1 && act(j-1,i) == 1 && act(j-2,i) == 1 && act(j-3,i) == 1 || ...
|
||||
act(j,i) == 1 && act(j-1,i) == 1 && act(j-2,i) == 1 || ...
|
||||
act(j,i) == 1 && act(j-1,i) == 1 && act(j-3,i) == 1 || ...
|
||||
act(j,i) == 1 && act(j-2,i) == 1 && act(j-3,i) == 1 || ...
|
||||
act(j-1,i) == 1 && act(j-2,i) == 1 && act(j-3,i) == 1
|
||||
if Criterio_0(j,i) == 1
|
||||
Criterio_1(j,i) = 1;
|
||||
if act(j,i) == 1 && act(j-1,i) == 1 && act(j-2,i) == 1 && act(j-3,i) == 1 && act(j-4,i) == 1
|
||||
alert(j,i) = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
if act_local(j,i) == 1 && act_local(j-1,i) == 1 && act_local(j-2,i) == 1 && act_local(j-3,i) == 1 || ...
|
||||
act_local(j,i) == 1 && act_local(j-1,i) == 1 && act_local(j-2,i) == 1 || ...
|
||||
act_local(j,i) == 1 && act_local(j-1,i) == 1 && act_local(j-3,i) == 1 || ...
|
||||
act_local(j,i) == 1 && act_local(j-2,i) == 1 && act_local(j-3,i) == 1 || ...
|
||||
act_local(j-1,i) == 1 && act_local(j-2,i) == 1 && act_local(j-3,i) == 1
|
||||
if Criterio_0_local(j,i) == 1
|
||||
Criterio_1_local(j,i) = 1;
|
||||
if act_local(j,i) == 1 && act_local(j-1,i) == 1 && act_local(j-2,i) == 1 && act_local(j-3,i) == 1 && act_local(j-4,i) == 1
|
||||
alert_local(j,i) = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
text = 'Criterion 1 executed';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Criterio delle parabole - Criterio 2
|
||||
a = zeros(r,c);
|
||||
a_local = zeros(r,c);
|
||||
Criterio_2 = zeros(r,c);
|
||||
Criterio_2_local = zeros(r,c);
|
||||
for i = 1:c % nodi
|
||||
for j = 13:r % date
|
||||
if Criterio_1(j,i) == 1
|
||||
% j-3
|
||||
x = Date(j-12:j-3);
|
||||
y = Speed(j-12:j-3,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a(j-3,i) = coeff(1,1);
|
||||
% j-2
|
||||
x = Date(j-11:j-2);
|
||||
y = Speed(j-11:j-2,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a(j-2,i) = coeff(1,1);
|
||||
% j-1
|
||||
x = Date(j-10:j-1);
|
||||
y = Speed(j-10:j-1,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a(j-1,i) = coeff(1,1);
|
||||
% j
|
||||
x = Date(j-9:j);
|
||||
y = Speed(j-9:j,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a(j,i) = coeff(1,1);
|
||||
% Criterio 2
|
||||
if a(j,i) > 0 && a(j-1,i) > 0 && a(j-2,i) > 0 && a(j-3,i) > 0 ||...
|
||||
a(j,i) > 0 && a(j-1,i) > 0 && a(j-2,i) > 0 ||...
|
||||
a(j,i) > 0 && a(j-1,i) > 0 && a(j-3,i) > 0 ||...
|
||||
a(j,i) > 0 && a(j-2,i) > 0 && a(j-3,i) > 0 ||...
|
||||
a(j-1,i) > 0 && a(j-2,i) > 0 && a(j-3,i) > 0
|
||||
|
||||
Criterio_2(j,i) = 1;
|
||||
end
|
||||
end
|
||||
if Criterio_1_local(j,i) == 1
|
||||
% j-3
|
||||
x = Date(j-12:j-3);
|
||||
y = Speed_local(j-12:j-3,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a_local(j-3,i) = coeff(1,1);
|
||||
% j-2
|
||||
x = Date(j-11:j-2);
|
||||
y = Speed_local(j-11:j-2,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a_local(j-2,i) = coeff(1,1);
|
||||
% j-1
|
||||
x = Date(j-10:j-1);
|
||||
y = Speed_local(j-10:j-1,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a_local(j-1,i) = coeff(1,1);
|
||||
% j
|
||||
x = Date(j-9:j);
|
||||
y = Speed_local(j-9:j,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a_local(j,i) = coeff(1,1);
|
||||
if a_local(j,i) > 0 && a_local(j-1,i) > 0 && a_local(j-2,i) > 0 && a_local(j-3,i) > 0 || ...
|
||||
a_local(j,i) > 0 && a_local(j-1,i) > 0 && a_local(j-2,i) > 0 || ...
|
||||
a_local(j,i) > 0 && a_local(j-1,i) > 0 && a_local(j-3,i) > 0 || ...
|
||||
a_local(j,i) > 0 && a_local(j-2,i) > 0 && a_local(j-3,i) > 0 || ...
|
||||
a_local(j-1,i) > 0 && a_local(j-2,i) > 0 && a_local(j-3,i) > 0
|
||||
|
||||
Criterio_2_local(j,i) = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
text = 'Criterion 2 executed';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Criterio della concavità crescente - Criterio 3
|
||||
Delta_a = zeros(r,c);
|
||||
Delta_a_local = zeros(r,c);
|
||||
diff_a = diff(a);
|
||||
diff_a_Loc = diff(a_local);
|
||||
Delta_a(2:end,:) = diff_a;
|
||||
Delta_a_local(2:end,:) = diff_a_Loc;
|
||||
Criterio_3 = zeros(r,c);
|
||||
Criterio_3_local = zeros(r,c);
|
||||
for i = 1:c % nodi
|
||||
for j = 13:r % date
|
||||
if Criterio_2(j,i) == 1
|
||||
if Delta_a(j,i) > 0 && Delta_a(j-1,i) > 0 && Delta_a(j-2,i) > 0 && Delta_a(j-3,i) > 0 || ...
|
||||
Delta_a(j,i) > 0 && Delta_a(j-1,i) > 0 && Delta_a(j-2,i) > 0 || ...
|
||||
Delta_a(j,i) > 0 && Delta_a(j-1,i) > 0 && Delta_a(j-3,i) > 0 || ...
|
||||
Delta_a(j,i) > 0 && Delta_a(j-2,i) > 0 && Delta_a(j-3,i) > 0 || ...
|
||||
Delta_a(j-1,i) > 0 && Delta_a(j-2,i) > 0 && Delta_a(j-3,i) > 0
|
||||
|
||||
Criterio_3(j,i) = 1;
|
||||
end
|
||||
end
|
||||
if Criterio_2_local(j,i) == 1
|
||||
if Delta_a_local(j,i) > 0 && Delta_a_local(j-1,i) > 0 && Delta_a_local(j-2,i) > 0 && Delta_a_local(j-3,i) > 0 ||...
|
||||
Delta_a_local(j,i) > 0 && Delta_a_local(j-1,i) > 0 && Delta_a_local(j-2,i) > 0 ||...
|
||||
Delta_a_local(j,i) > 0 && Delta_a_local(j-1,i) > 0 && Delta_a_local(j-3,i) > 0 ||...
|
||||
Delta_a_local(j,i) > 0 && Delta_a_local(j-2,i) > 0 && Delta_a_local(j-3,i) > 0 ||...
|
||||
Delta_a_local(j-1,i) > 0 && Delta_a_local(j-2,i) > 0 && Delta_a_local(j-3,i) > 0
|
||||
|
||||
Criterio_3_local(j,i) = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
text = 'Criterion 3 executed';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Criterio di Fukuzono
|
||||
alarm = zeros(r,c);
|
||||
alarm_local = zeros(r,c);
|
||||
RQ = zeros(r,c);
|
||||
Number = zeros(r,c);
|
||||
RQ_Loc = zeros(r,c);
|
||||
Number_Loc = zeros(r,c);
|
||||
Tr = zeros(r,c) - 99;
|
||||
Tr_Inf = zeros(r,c) - 99;
|
||||
Tr_Sup = zeros(r,c) - 99;
|
||||
Tr_mail = zeros(r,c) - 99;
|
||||
Tr_Loc = zeros(r,c) - 99;
|
||||
Tr_Inf_Loc = zeros(r,c) - 99;
|
||||
Tr_Sup_Loc = zeros(r,c) - 99;
|
||||
Tr_Loc_mail = zeros(r,c) - 99;
|
||||
DataFuK = zeros(r,c);
|
||||
DataFuK_local = zeros(r,c);
|
||||
for i = 1:c % nodi
|
||||
j = 13;
|
||||
% -------------- Cumulati --------------------------
|
||||
while j <=(r-1)
|
||||
hold off
|
||||
GIGI = 0;
|
||||
if Criterio_3(j,i) == 1
|
||||
Tempo = Date(j-3:j); % giorni
|
||||
Vel = 1000*Speed(j-3:j,i); % mm/g
|
||||
Vel(Vel==0) = 0.0000000001;
|
||||
Inv_Vel = 1./Vel;
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m = retta(1,1); % m
|
||||
q = retta(1,2); % q
|
||||
% Time of failure
|
||||
Tr(j,i) = -q/m - Date(j);
|
||||
if Tr(j,i) > 0 && Tr(j,i) < 30 % giorni
|
||||
% RQ
|
||||
RQ(j,i) = rsquare.rsquare;
|
||||
% Grafico Inv V - T
|
||||
Data_Img = datestr(Date(j-3),'dd-mm-yyyy');
|
||||
Tempo_Img = datestr(Date(j-3),'HH-MM-SS');
|
||||
fig = plot(Tempo,Inv_Vel,'-o','LineStyle','none');
|
||||
hold on
|
||||
legend(num2str(RQ(j,i)));
|
||||
Y = m*Tempo + q;
|
||||
plot(Tempo,Y);
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy HH:MM]')
|
||||
ylabel('Inverse of Velocity [d/mm]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Inv_Vel)+max(Inv_Vel)/10])
|
||||
% Grafico Vel - T
|
||||
hold off
|
||||
fig2 = plot(Tempo,Vel,'-o','LineStyle','none');
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy HH:MM]')
|
||||
ylabel('Velocity [mm/d]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Vel)+max(Vel)/10])
|
||||
end
|
||||
% dato successivo
|
||||
for n = 1:(r-j)
|
||||
if Criterio_3(n+j,i) == 1 || Criterio_3(n+j-1,i) == 1
|
||||
Tempo = Date(j-3:j+n); % giorni
|
||||
Vel = 1000*Speed(j-3:j+n,i); % mm/g
|
||||
Vel(Vel==0) = 0.0000000001;
|
||||
Inv_Vel = 1./Vel;
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel,'poly1');
|
||||
RQ(j+n,i) = rsquare.rsquare;
|
||||
retta = coeffvalues(f);
|
||||
m = retta(1,1);
|
||||
q = retta(1,2);
|
||||
% Time of Failure
|
||||
Tr(j+n,i) = -q/m - Date(j+n);
|
||||
if Tr(j+n,i) > 0 && Tr(j+n,i) < 30 % giorni
|
||||
if RQ(j+n,i) >= 0.85
|
||||
Tr_mail(j+n,i) = -q/m - Date(j+n);% attivo
|
||||
Tr_mail(j+n-1,i) = -99; % disattivo
|
||||
alarm(j+n-1,i) = 0; % disattivo
|
||||
alarm(j+n,i) = 1; % attivo
|
||||
DataFuK(j+n,i) = Date(j-3);
|
||||
DataFuK(j,i) = 0;
|
||||
Data_Img = datestr(Date(j-3),'dd-mm-yyyy');
|
||||
Tempo_Img = datestr(Date(j-3),'HH-MM-SS');
|
||||
% Grafico asintotico
|
||||
hold off
|
||||
fig2 = plot(Tempo,Vel,'-o','LineStyle','none');
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy HH:MM]')
|
||||
ylabel('Velocity [mm/d]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Vel)+max(Vel)/10])
|
||||
Nodo = cell2mat(NodoTilt(i,2));
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img,'_',Tempo_Img,'_Vel.jpg');
|
||||
saveas(fig2,filename)
|
||||
% Grafico inverso velocità
|
||||
fig = plot(Tempo,Inv_Vel,'-o','LineStyle','none');
|
||||
hold on
|
||||
legend(num2str(RQ(j+n,i)));
|
||||
Y = m*Tempo + q;
|
||||
Y = [Y; 0];
|
||||
Tempo_End = -q/m;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y);
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy HH:MM]')
|
||||
ylabel('Inverse of Velocity [d/mm]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Inv_Vel)+max(Inv_Vel)/10])
|
||||
LIM = floor(fig.XData(1));
|
||||
Nodo = cell2mat(NodoTilt(i,2));
|
||||
% Variazione statistica dei dati di
|
||||
% monitoraggio
|
||||
% Limite Superiore
|
||||
Inv_Vel_Sup = Inv_Vel + mean(Inv_Vel)*(1-RQ(j+n,i));
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel_Sup,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m_Sup = retta(1,1);
|
||||
q_Sup = retta(1,2);
|
||||
Tr_Sup(j+n,i) = -q_Sup/m_Sup;
|
||||
Tr_Sup(j+n-1,i) = 99;
|
||||
Y_Sup = m_Sup*Tempo + q_Sup;
|
||||
Y_Sup = [Y_Sup; 0];
|
||||
Tempo_End = -q_Sup/m_Sup;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y_Sup,'--');
|
||||
% Limite Inferiore
|
||||
Inv_Vel_Inf = Inv_Vel - mean(Inv_Vel)*(1-RQ(j+n,i));
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel_Inf,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m_Inf = retta(1,1);
|
||||
q_Inf = retta(1,2);
|
||||
Tr_Inf(j+n,i) = -q_Inf/m_Inf;
|
||||
Tr_Inf(j+n-1,i) = 99;
|
||||
Y_Inf = m_Inf*Tempo + q_Inf;
|
||||
Y_Inf = [Y_Inf; 0];
|
||||
Tempo_End = -q_Inf/m_Inf;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y_Inf,'--');
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
GIGI = 1;
|
||||
N = n;
|
||||
Number(j+N,i) = N+4;
|
||||
end
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
if GIGI == 1
|
||||
hold on
|
||||
fig = plot(Date(j+N)+Tr(j+N,i),0,'-d','LineStyle','none','Color','r');
|
||||
plot(Tr_Sup(j+N,i),0,'-v','LineStyle','none','Color','k');
|
||||
LIM_S = ceil(Tr_Sup(j+N,i));
|
||||
plot(Tr_Inf(j+N,i),0,'-v','LineStyle','none','Color','k');
|
||||
legend(['RQ: ' num2str(RQ(j+N,i))]);
|
||||
h = gca; % Get axis to modify
|
||||
h.XAxis.MinorTick = 'on'; % Must turn on minor ticks if they are off
|
||||
h.XAxis.MinorTickValues = LIM(1):1/24:LIM_S(end); % Minor ticks which don't line up with majors
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
grid on
|
||||
grid minor
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img,'_',Tempo_Img,'.jpg');
|
||||
saveas(fig,filename)
|
||||
end
|
||||
j = j+n+1;
|
||||
else
|
||||
j = j+1;
|
||||
end
|
||||
end
|
||||
% -------------- Locali --------------------------
|
||||
j = 13;
|
||||
while j <=(r-1)
|
||||
hold off
|
||||
DIBBA = 0;
|
||||
if Criterio_3_local(j,i) == 1
|
||||
Tempo = Date(j-3:j); % giorni
|
||||
Vel = 1000*Speed_local(j-3:j,i); % mm/g
|
||||
Vel(Vel==0) = 0.0000000001;
|
||||
Inv_Vel = 1./Vel;
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m = retta(1,1);
|
||||
q = retta(1,2);
|
||||
% Time of Failure
|
||||
Tr_Loc(j,i) = -q/m - Date(j);
|
||||
if Tr_Loc(j,i) > 0 && Tr_Loc(j,i) < 30
|
||||
% RQ
|
||||
RQ_Loc(j,i) = rsquare.rsquare;
|
||||
% Grafico Inv V - T
|
||||
Data_Img = datestr(Date(j-3),'dd-mm-yyyy');
|
||||
Tempo_Img = datestr(Date(j-3),'HH-MM-SS');
|
||||
% Grafico
|
||||
fig = plot(Tempo,Inv_Vel,'-o','LineStyle','none');
|
||||
hold on
|
||||
legend(num2str(RQ_Loc(j,i)));
|
||||
Y = m*Tempo + q;
|
||||
plot(Tempo,Y);
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy HH:MM]')
|
||||
ylabel('Inverse of Velocity [d/mm]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Inv_Vel)+max(Inv_Vel)/10])
|
||||
% Grafico Vel - T
|
||||
hold off
|
||||
fig2 = plot(Tempo,Vel,'-o','LineStyle','none');
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy HH:MM]')
|
||||
ylabel('Velocity [mm/d]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Vel)+max(Vel)/10])
|
||||
end
|
||||
% dato successivo
|
||||
for n = 1:(r-j)
|
||||
if Criterio_3_local(n+j,i) == 1 || Criterio_3_local(n+j-1,i) == 1
|
||||
Tempo = Date(j-3:j+n); % giorni
|
||||
Vel = 1000*Speed_local(j-3:j+n,i); % mm/g
|
||||
Vel(Vel==0) = 0.0000000001;
|
||||
Inv_Vel = 1./Vel;
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel,'poly1');
|
||||
RQ_Loc(j+n,i) = rsquare.rsquare;
|
||||
retta = coeffvalues(f);
|
||||
m = retta(1,1);
|
||||
q = retta(1,2);
|
||||
% Time of Failure
|
||||
Tr_Loc(j+n,i) = -q/m - Date(j+n);
|
||||
if Tr_Loc(j+n,i) > 0 && Tr_Loc(j+n,i) < 30 % giorni
|
||||
if RQ_Loc(j+n,i) >= 0.85
|
||||
Tr_Loc_mail(j+n,i) = -q/m - Date(j+n);
|
||||
Tr_Loc_mail(j+n-1,i) = -99; % disattivo
|
||||
alarm_local(j+n-1,i) = 0; % disattivo
|
||||
alarm_local(j+n,i) = 1; % attivo
|
||||
DataFuK_local(j+n,i) = Date(j-3);
|
||||
DataFuK_local(j,i) = 0;
|
||||
Data_Img = datestr(Date(j-3),'dd-mm-yyyy');
|
||||
Tempo_Img = datestr(Date(j-3),'HH-MM-SS');
|
||||
% Grafico Asintotico
|
||||
hold off
|
||||
fig2 = plot(Tempo,Vel,'-o','LineStyle','none');
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy HH:MM]')
|
||||
ylabel('Velocity [mm/d]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Vel)+max(Vel)/10])
|
||||
Nodo = cell2mat(NodoTilt(i,2));
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img,'_',Tempo_Img,'-Local_Vel.jpg');
|
||||
saveas(fig2,filename)
|
||||
% Grafico inverso velocità
|
||||
fig = plot(Tempo,Inv_Vel,'-o','LineStyle','none');
|
||||
hold on
|
||||
legend(num2str(RQ_Loc(j+n,i)));
|
||||
Y = m*Tempo + q;
|
||||
Y = [Y; 0];
|
||||
Tempo_End = -q/m;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y);
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy HH:MM]')
|
||||
ylabel('Inverse of Velocity [d/mm]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Inv_Vel)+max(Inv_Vel)/10])
|
||||
LIM = floor(fig.XData(1));
|
||||
Nodo = cell2mat(NodoTilt(i,2));
|
||||
% Variazione statistica dei dati di
|
||||
% monitoraggio
|
||||
% Limite Superiore
|
||||
Inv_Vel_Sup = Inv_Vel + mean(Inv_Vel)*(1-RQ_Loc(j+n,i));
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel_Sup,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m_Sup = retta(1,1);
|
||||
q_Sup = retta(1,2);
|
||||
Tr_Loc_Sup(j+n,i) = -q_Sup/m_Sup;
|
||||
Tr_Loc_Sup(j+n-1,i) = 99;
|
||||
Y_Sup = m_Sup*Tempo + q_Sup;
|
||||
Y_Sup = [Y_Sup; 0];
|
||||
Tempo_End = -q_Sup/m_Sup;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y_Sup,'--');
|
||||
% Limite Inferiore
|
||||
Inv_Vel_Inf = Inv_Vel - mean(Inv_Vel)*(1-RQ_Loc(j+n,i));
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel_Inf,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m_Inf = retta(1,1);
|
||||
q_Inf = retta(1,2);
|
||||
Tr_Loc_Inf(j+n,i) = -q_Inf/m_Inf;
|
||||
Tr_Loc_Inf(j+n-1,i) = 99;
|
||||
Y_Inf = m_Inf*Tempo + q_Inf;
|
||||
Y_Inf = [Y_Inf; 0];
|
||||
Tempo_End = -q_Inf/m_Inf;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y_Inf,'--');
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
DIBBA = 1;
|
||||
N = n;
|
||||
Number_Loc(j+N,i) = N+4;
|
||||
end
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
if DIBBA == 1
|
||||
hold on
|
||||
fig = plot(Date(j+N)+Tr_Loc(j+N,i),0,'-d','LineStyle','none','Color','r');
|
||||
plot(Tr_Loc_Sup(j+N,i),0,'-v','LineStyle','none','Color','k');
|
||||
LIM_S = ceil(Tr_Sup(j+N,i));
|
||||
plot(Tr_Loc_Inf(j+N,i),0,'-v','LineStyle','none','Color','k');
|
||||
legend(['RQ: ' num2str(RQ_Loc(j+N,i))]);
|
||||
h = gca; % Get axis to modify
|
||||
h.XAxis.MinorTick = 'on'; % Must turn on minor ticks if they are off
|
||||
h.XAxis.MinorTickValues = LIM(1):1/24:LIM_S(end); % Minor ticks which don't line up with majors
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
grid on
|
||||
grid minor
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img,'_',Tempo_Img,'-Local.jpg');
|
||||
saveas(fig,filename)
|
||||
if yes3D == 1
|
||||
HRindex = find(cell2mat(NodoTiltHR3D(:,2))==Nodo);
|
||||
if isempty(HRindex) ~= 1
|
||||
NodeHR = NodoTiltHR3D(HRindex,3);
|
||||
HRprog = find(cell2mat(NodoTiltHR(:,2))==cell2mat(NodeHR));
|
||||
[rT,~] = size(Tempo);
|
||||
DateHR = zeros(rT+1,1);
|
||||
HShift_local_HR = zeros(rT,1);
|
||||
nHR = 1;
|
||||
for tt = 1:rT+1
|
||||
if tt == 1
|
||||
Data_HR = datestr(Date(j-4),'yyyy-mm-dd');
|
||||
Tempo_HR = datestr(Date(j-4),'HH:MM:SS');
|
||||
else
|
||||
Data_HR = datestr(Tempo(tt-1),'yyyy-mm-dd');
|
||||
Tempo_HR = datestr(Tempo(tt-1),'HH:MM:SS');
|
||||
end
|
||||
NodeNum = num2str(cell2mat(NodeHR));
|
||||
comando = ['select EventDate, EventTime, HShift_local from ElabDataView where EventDate = ''' ...
|
||||
Data_HR ''' and EventTime = ''' Tempo_HR ''' and ToolNameID = ''' DTcatena...
|
||||
''' and UnitName = ''' IDcentralina ''' and NodeNum = ''' NodeNum ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Dati_HR = curs.Data;
|
||||
% Modifico il formato di data e ora in DATini.
|
||||
[rD,~] = size(Dati_HR);
|
||||
T = [cell2mat(Dati_HR(:,1)) repmat(' ', [rD,1]) cell2mat(Dati_HR(:,2))];
|
||||
DateHR(nHR,1) = datenum(T); % Data
|
||||
HShift_local_HR(nHR,1) = cell2mat(Dati_HR(:,3)); % Loc 2D
|
||||
nHR = nHR+1;
|
||||
end
|
||||
[rS,~] = size(HShift_local_HR);
|
||||
Speed_local_HR = zeros(rS-1,1);
|
||||
DateGiornoHR = DateHR(2:end);
|
||||
for jH = 4:rS-1 % date
|
||||
% Locali
|
||||
Speed_local_HR(jH,1) = (HShift_local(jH+1,1) - HShift_local(jH,1))/(DateHR(jH+1)-DateHR(jH)); % m/g
|
||||
if jH == 4
|
||||
Speed_local_HR(jH-1,1) = (HShift_local_HR(jH,1) - HShift_local_HR(jH-1,1))/(DateHR(jH)-DateHR(jH-1)); % m/g
|
||||
Speed_local_HR(jH-2,1) = (HShift_local_HR(jH-1,1) - HShift_local_HR(jH-2,1))/(DateHR(jH-1)-DateHR(jH-2)); % m/g
|
||||
Speed_local_HR(jH-3,1) = (HShift_local_HR(jH-2,1) - HShift_local_HR(jH-3,1))/(DateHR(jH-2)-DateHR(jH-3)); % m/g
|
||||
end
|
||||
end
|
||||
|
||||
% Velocità in metri/giorno
|
||||
jH = find(DateHR == Date(j))-1;
|
||||
|
||||
% ---Criterio della velocità positiva Criterio 0---
|
||||
if Speed_local_HR(jH,1) > 0 && ...
|
||||
Speed_local_HR(jH-1,1) > 0 ...
|
||||
&& Speed_local_HR(jH-2,1) > 0 ...
|
||||
&& Speed_local_HR(jH-3,1) > 0
|
||||
|
||||
% --- Calcolo Fukuzono ---
|
||||
TempoHR = DateGiornoHR(jH-3:jH+N); % giorni
|
||||
Vel_HR = 1000*Speed_local_HR(jH-3:jH+N,1); % mm/g
|
||||
Vel_HR(Vel_HR==0) = 0.0000000001;
|
||||
Inv_Vel_HR = 1./Vel_HR;
|
||||
[f,rsquare] = fit(TempoHR,Inv_Vel_HR,'poly1');
|
||||
RQ_Loc_HR(jH+N,HRprog) = rsquare.rsquare;
|
||||
retta = coeffvalues(f);
|
||||
m = retta(1,1);
|
||||
q = retta(1,2);
|
||||
% Time of Failure
|
||||
Tr_Loc_HR(jH+N,HRprog) = -q/m - DateGiornoHR(jH+N);
|
||||
if Tr_Loc_HR(jH+N,HRprog) > 0 && Tr_Loc_HR(jH+N,HRprog) < 30 % giorni
|
||||
if RQ_Loc_HR(jH+N,i) >= 0.85
|
||||
DataFuK_local_HR(jH+N,HRprog) = DateGiornoHR(jH-3);
|
||||
Data_Img_HR = datestr(DateGiornoHR(jH-3),'dd-mm-yyyy');
|
||||
Tempo_Img_HR = datestr(DateGiornoHR(jH-3),'HH-MM-SS');
|
||||
% Grafico Asintotico
|
||||
fig2 = plot(TempoHR,Vel_HR,'-o','LineStyle','none');
|
||||
title('Time of Failure prediction model evaluated with Electrolytic Cell');
|
||||
xlabel('Date [dd/mm/yyyy HH:MM]')
|
||||
ylabel('Velocity [mm/d]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Vel_HR)+max(Vel_HR)/10])
|
||||
Nodo = cell2mat(NodoTiltHR(HRprog,2));
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img_HR,'_',Tempo_Img_HR,'-Local_Vel.jpg');
|
||||
saveas(fig2,filename)
|
||||
% Grafico inverso velocità
|
||||
fig = plot(TempoHR,Inv_Vel_HR,'-o','LineStyle','none');
|
||||
hold on
|
||||
legend(num2str(RQ_Loc_HR(jH+N,i)));
|
||||
Y_HR = m*TempoHR + q;
|
||||
plot(Tempo,Y_HR);
|
||||
title('Time of Failure prediction model evaluated with Electrolytic Cell');
|
||||
xlabel('Date [dd/mm/yyyy HH:MM]')
|
||||
ylabel('Inverse of Velocity [d/mm]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Inv_Vel_HR)+max(Inv_Vel_HR)/10])
|
||||
LIM = floor(fig.XData(1));
|
||||
fig = plot(DateGiornoHR(jH+N)+Tr_Loc_HR(jH+N,HRprog),0,'-d','LineStyle','none','Color','r');
|
||||
LIM_S = ceil(Tr_Loc_HR(jH+N,HRprog)+DateGiornoHR(jH+N));
|
||||
h = gca; % Get axis to modify
|
||||
xlim([LIM LIM_S])
|
||||
h.XAxis.MinorTick = 'on'; % Must turn on minor ticks if they are off
|
||||
h.XAxis.MinorTickValues = LIM:1/4:LIM_S; % Minor ticks which don't line up with majors
|
||||
h.XAxis.TickValues = LIM:1:LIM_S;
|
||||
datetick('x','dd/mm/yyyy')
|
||||
grid on
|
||||
grid minor
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img_HR,'_',Tempo_Img_HR,'-Local.jpg');
|
||||
saveas(fig,filename)
|
||||
else
|
||||
Tr_Loc_HR(jH+N,HRprog) = 0;
|
||||
end
|
||||
else
|
||||
Tr_Loc_HR(jH+N,HRprog) = 0;
|
||||
end
|
||||
else
|
||||
Tr_Loc_HR(jH,HRprog) = 0;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
j = j+n+1;
|
||||
else
|
||||
j = j+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = 'Fukuzono Calculation executed';
|
||||
fprintf(fileID,fmt,text);
|
||||
else
|
||||
alert = zeros(r,c);
|
||||
alert_local = zeros(r,c);
|
||||
alarm = zeros(r,c);
|
||||
alarm_local = zeros(r,c);
|
||||
RQ = zeros(r,c);
|
||||
Number = zeros(r,c);
|
||||
RQ_Loc = zeros(r,c);
|
||||
Number_Loc = zeros(r,c);
|
||||
Tr_Inf = zeros(r,c) - 99;
|
||||
Tr_Sup = zeros(r,c) - 99;
|
||||
Tr_mail = zeros(r,c) - 99;
|
||||
Tr_Inf_Loc = zeros(r,c) - 99;
|
||||
Tr_Sup_Loc = zeros(r,c) - 99;
|
||||
Tr_Loc_mail = zeros(r,c) - 99;
|
||||
DataFuK = zeros(r,c);
|
||||
DataFuK_local = zeros(r,c);
|
||||
end
|
||||
|
||||
text = 'Fukuzono Function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
725
Tilt/Fukuzono_Giornaliero.m
Executable file
725
Tilt/Fukuzono_Giornaliero.m
Executable file
@@ -0,0 +1,725 @@
|
||||
function [alarm_STORICO,alarm_local_STORICO,DateGiorno,Tr_Loc_Sup_S,Tr_Loc_Inf_S,...
|
||||
Tr_Loc_S,Tr_Sup_S,Tr_Inf_S,Tr_S,Tr_Loc_HR_S,Tr_mail_S,Tr_Loc_mail_S,DataFuK_S,...
|
||||
DataFuK_local_S,DataFuK_local_HR_S,Number_S,Number_Loc_S,RQ_S,RQ_Loc_S] = ...
|
||||
Fukuzono_Giornaliero(IDcentralina,DTcatena,date,ARRAYdate,yes3D,rNL,NodoTilt,...
|
||||
NodoTiltHR,NodoTiltHR3D,conn,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
|
||||
text = 'Fukuzono_Giornaliero function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
data_rif = ARRAYdate(end)-45; % 45
|
||||
Tr_Loc_HR_S = [];
|
||||
DataFuK_local_HR_S = [];
|
||||
|
||||
%% Scarico i dati da DB
|
||||
% Tilt Link V
|
||||
if data_rif > datenum(date)
|
||||
data = datestr(data_rif,'yyyy-mm-dd');
|
||||
else
|
||||
data = date;
|
||||
end
|
||||
for n = 1:rNL
|
||||
NodeNum = num2str(cell2mat(NodoTilt(n,2)));
|
||||
comando = ['select EventDate, EventTime, HShift_local, HShift from ElabDataView where EventDate >= ''' ...
|
||||
data ''' and ToolNameID = ''' DTcatena ''' and UnitName = ''' IDcentralina ...
|
||||
''' and NodeNum = ''' NodeNum ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Dati = curs.Data;
|
||||
% Modifico il formato di data e ora in DATini.
|
||||
[rD,~] = size(Dati);
|
||||
T = [cell2mat(Dati(:,1)) repmat(' ', [rD,1]) cell2mat(Dati(:,2))];
|
||||
Date = datenum(T); % Data
|
||||
HShift_local(:,n) = cell2mat(Dati(:,3)); % Loc 2D
|
||||
HShift(:,n) = cell2mat(Dati(:,4)); % Cum 2D
|
||||
end
|
||||
|
||||
%% Calcolo una singola velocità media giornaliera
|
||||
[rDate,~] = size(Date);
|
||||
day = 0;
|
||||
fine = rDate;
|
||||
diffDate = 0;
|
||||
n = 2;
|
||||
period = 1; % calcolo giornaliero
|
||||
Indici(1,1) = rDate;
|
||||
while day <= rDate
|
||||
while diffDate < period
|
||||
day = day+1;
|
||||
if day >= rDate
|
||||
break
|
||||
end
|
||||
diffDate = Date(fine) - Date(rDate-day);
|
||||
end
|
||||
if day >= rDate
|
||||
break
|
||||
end
|
||||
Indici(n,1) = rDate-day;
|
||||
n = n+1;
|
||||
diffDate = 0;
|
||||
fine = rDate-day;
|
||||
end
|
||||
|
||||
Indici = flipud(Indici);
|
||||
[rI,~] = size(Indici);
|
||||
DateGiorno(1,1) = Date(1,1);
|
||||
if rI < 2
|
||||
Speed = [];
|
||||
Speed_local = [];
|
||||
DateGiorno = [];
|
||||
else
|
||||
for s = 2:rI
|
||||
Speed(s,:) = (HShift(Indici(s),:) - HShift(Indici(s-1),:))/(Date(Indici(s),1) - Date(Indici(s-1),:));
|
||||
Speed_local(s,:) = (HShift_local(Indici(s),:) - HShift_local(Indici(s-1),:))/(Date(Indici(s),1) - Date(Indici(s-1),:));
|
||||
DateGiorno(s,1) = Date(Indici(s),1);
|
||||
end
|
||||
end
|
||||
% Velocità in metri/giorno
|
||||
|
||||
%% Criterio della velocità positiva - Criterio 0
|
||||
[rS,cS] = size(Speed);
|
||||
Criterio_0 = zeros(rS,cS);
|
||||
Criterio_0_local = zeros(rS,cS);
|
||||
for i = 1:cS % nodi
|
||||
for j = 4:rS % date
|
||||
if Speed(j,i) > 0 && Speed(j-1,i) > 0 && Speed(j-2,i) > 0 && Speed(j-3,i) > 0
|
||||
Criterio_0(j,i) = 1;
|
||||
end
|
||||
% Locali
|
||||
if Speed_local(j,i) > 0 && Speed_local(j-1,i) > 0 && Speed_local(j-2,i) > 0 && Speed_local(j-3,i) > 0
|
||||
Criterio_0_local(j,i) = 1;
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
text = 'Criterion 0 executed';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Faccio i calcoli
|
||||
Delta_Speed_local = zeros(rS,cS);
|
||||
Delta_Speed = zeros(rS,cS);
|
||||
diff_Cum = diff(Speed);
|
||||
diff_Loc = diff(Speed_local);
|
||||
Delta_Speed(2:end,:) = diff_Cum;
|
||||
Delta_Speed_local(2:end,:) = diff_Loc;
|
||||
act = zeros(rS,cS);
|
||||
act_local = zeros(rS,cS);
|
||||
for i = 1:cS % nodi
|
||||
for j = 2:rS % date
|
||||
if Delta_Speed(j,i) > 0
|
||||
act(j,i) = 1;
|
||||
elseif Delta_Speed(j,i) < 0
|
||||
act(j,i) = -1;
|
||||
end
|
||||
if Delta_Speed_local(j,i) > 0
|
||||
act_local(j,i) = 1;
|
||||
elseif Delta_Speed_local(j,i) < 0
|
||||
act_local(j,i) = -1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
%% Criterio della Velocità Crescente - Criterio 1
|
||||
Criterio_1 = zeros(rS,cS);
|
||||
Criterio_1_local = zeros(rS,cS);
|
||||
if rS > 10
|
||||
for i = 1:cS % nodi
|
||||
for j = 10:rS % date
|
||||
if act(j,i) == 1 && act(j-1,i) == 1 && act(j-2,i) == 1 && act(j-3,i) == 1 || ...
|
||||
act(j,i) == 1 && act(j-1,i) == 1 && act(j-2,i) == 1 || ...
|
||||
act(j,i) == 1 && act(j-1,i) == 1 && act(j-3,i) == 1 || ...
|
||||
act(j,i) == 1 && act(j-2,i) == 1 && act(j-3,i) == 1 || ...
|
||||
act(j-1,i) == 1 && act(j-2,i) == 1 && act(j-3,i) == 1
|
||||
if Criterio_0(j,i) == 1
|
||||
Criterio_1(j,i) = 1;
|
||||
end
|
||||
end
|
||||
if act_local(j,i) == 1 && act_local(j-1,i) == 1 && act_local(j-2,i) == 1 && act_local(j-3,i) == 1 || ...
|
||||
act_local(j,i) == 1 && act_local(j-1,i) == 1 && act_local(j-2,i) == 1 || ...
|
||||
act_local(j,i) == 1 && act_local(j-1,i) == 1 && act_local(j-3,i) == 1 || ...
|
||||
act_local(j,i) == 1 && act_local(j-2,i) == 1 && act_local(j-3,i) == 1 || ...
|
||||
act_local(j-1,i) == 1 && act_local(j-2,i) == 1 && act_local(j-3,i) == 1
|
||||
if Criterio_0_local(j,i) == 1
|
||||
Criterio_1_local(j,i) = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
text = 'Criterion 1 executed';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Criterio delle parabole - Criterio 2
|
||||
a = zeros(rS,cS);
|
||||
a_Loc = zeros(rS,cS);
|
||||
Criterio_2 = zeros(rS,cS);
|
||||
Criterio_2_local = zeros(rS,cS);
|
||||
for i = 1:cS % nodi
|
||||
for j = 13:rS % date
|
||||
if Criterio_1(j,i) == 1
|
||||
% j-3
|
||||
x = DateGiorno(j-12:j-3);
|
||||
y = Speed(j-12:j-3,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a(j-3,i) = coeff(1,1);
|
||||
% j-2
|
||||
x = DateGiorno(j-11:j-2);
|
||||
y = Speed(j-11:j-2,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a(j-2,i) = coeff(1,1);
|
||||
% j-1
|
||||
x = DateGiorno(j-10:j-1);
|
||||
y = Speed(j-10:j-1,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a(j-1,i) = coeff(1,1);
|
||||
% j
|
||||
x = DateGiorno(j-9:j);
|
||||
y = Speed(j-9:j,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a(j,i) = coeff(1,1);
|
||||
% Criterio 2
|
||||
if a(j,i) > 0 && a(j-1,i) > 0 && a(j-2,i) > 0 && a(j-3,i) > 0 ||...
|
||||
a(j,i) > 0 && a(j-1,i) > 0 && a(j-2,i) > 0 ||...
|
||||
a(j,i) > 0 && a(j-1,i) > 0 && a(j-3,i) > 0 ||...
|
||||
a(j,i) > 0 && a(j-2,i) > 0 && a(j-3,i) > 0 ||...
|
||||
a(j-1,i) > 0 && a(j-2,i) > 0 && a(j-3,i) > 0
|
||||
|
||||
Criterio_2(j,i) = 1;
|
||||
end
|
||||
end
|
||||
if Criterio_1_local(j,i) == 1
|
||||
% j-3
|
||||
x = DateGiorno(j-12:j-3);
|
||||
y = Speed_local(j-12:j-3,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a_Loc(j-3,i) = coeff(1,1);
|
||||
% j-2
|
||||
x = DateGiorno(j-11:j-2);
|
||||
y = Speed_local(j-11:j-2,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a_Loc(j-2,i) = coeff(1,1);
|
||||
% j-1
|
||||
x = DateGiorno(j-10:j-1);
|
||||
y = Speed_local(j-10:j-1,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a_Loc(j-1,i) = coeff(1,1);
|
||||
% j
|
||||
x = DateGiorno(j-9:j);
|
||||
y = Speed_local(j-9:j,i);
|
||||
f = fit(x,y,'poly2');
|
||||
coeff = coeffvalues(f);
|
||||
a_Loc(j,i) = coeff(1,1);
|
||||
if a_Loc(j,i) > 0 && a_Loc(j-1,i) > 0 && a_Loc(j-2,i) > 0 && a_Loc(j-3,i) > 0 || ...
|
||||
a_Loc(j,i) > 0 && a_Loc(j-1,i) > 0 && a_Loc(j-2,i) > 0 || ...
|
||||
a_Loc(j,i) > 0 && a_Loc(j-1,i) > 0 && a_Loc(j-3,i) > 0 || ...
|
||||
a_Loc(j,i) > 0 && a_Loc(j-2,i) > 0 && a_Loc(j-3,i) > 0 || ...
|
||||
a_Loc(j-1,i) > 0 && a_Loc(j-2,i) > 0 && a_Loc(j-3,i) > 0
|
||||
|
||||
Criterio_2_local(j,i) = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
text = 'Criterion 2 executed';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Criterio della concavità crescente - Criterio 3
|
||||
Delta_a = zeros(rS,cS);
|
||||
Delta_a_local = zeros(rS,cS);
|
||||
diff_a = diff(a);
|
||||
diff_a_Loc = diff(a_Loc);
|
||||
Delta_a(2:end,:) = diff_a;
|
||||
Delta_a_local(2:end,:) = diff_a_Loc;
|
||||
Criterio_3 = zeros(rS,cS);
|
||||
Criterio_3_local = zeros(rS,cS);
|
||||
for i = 1:cS % nodi
|
||||
for j = 13:rS % date
|
||||
if Criterio_2(j,i) == 1
|
||||
if Delta_a(j,i) > 0 && Delta_a(j-1,i) > 0 && Delta_a(j-2,i) > 0 && Delta_a(j-3,i) > 0 || ...
|
||||
Delta_a(j,i) > 0 && Delta_a(j-1,i) > 0 && Delta_a(j-2,i) > 0 || ...
|
||||
Delta_a(j,i) > 0 && Delta_a(j-1,i) > 0 && Delta_a(j-3,i) > 0 || ...
|
||||
Delta_a(j,i) > 0 && Delta_a(j-2,i) > 0 && Delta_a(j-3,i) > 0 || ...
|
||||
Delta_a(j-1,i) > 0 && Delta_a(j-2,i) > 0 && Delta_a(j-3,i) > 0
|
||||
|
||||
Criterio_3(j,i) = 1;
|
||||
end
|
||||
end
|
||||
if Criterio_2_local(j,i) == 1
|
||||
if Delta_a_local(j,i) > 0 && Delta_a_local(j-1,i) > 0 && Delta_a_local(j-2,i) > 0 && Delta_a_local(j-3,i) > 0 ||...
|
||||
Delta_a_local(j,i) > 0 && Delta_a_local(j-1,i) > 0 && Delta_a_local(j-2,i) > 0 ||...
|
||||
Delta_a_local(j,i) > 0 && Delta_a_local(j-1,i) > 0 && Delta_a_local(j-3,i) > 0 ||...
|
||||
Delta_a_local(j,i) > 0 && Delta_a_local(j-2,i) > 0 && Delta_a_local(j-3,i) > 0 ||...
|
||||
Delta_a_local(j-1,i) > 0 && Delta_a_local(j-2,i) > 0 && Delta_a_local(j-3,i) > 0
|
||||
|
||||
Criterio_3_local(j,i) = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
text = 'Criterion 3 executed';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Criterio di Fukuzono
|
||||
alarm_STORICO = zeros(rS,cS);
|
||||
alarm_local_STORICO = zeros(rS,cS);
|
||||
RQ_S = zeros(rS,cS);
|
||||
RQ_Loc_S = zeros(rS,cS);
|
||||
Number_S = zeros(rS,cS);
|
||||
Number_Loc_S = zeros(rS,cS);
|
||||
Tr_S = zeros(rS,cS) - 99;
|
||||
Tr_Inf_S = zeros(rS,cS) - 99;
|
||||
Tr_Sup_S = zeros(rS,cS) - 99;
|
||||
Tr_mail_S = zeros(rS,cS) - 99;
|
||||
Tr_Loc_S = zeros(rS,cS) - 99;
|
||||
Tr_Loc_Inf_S = zeros(rS,cS) - 99;
|
||||
Tr_Loc_Sup_S = zeros(rS,cS) - 99;
|
||||
Tr_Loc_mail_S = zeros(rS,cS) - 99;
|
||||
DataFuK_S = zeros(rS,cS);
|
||||
DataFuK_local_S = zeros(rS,cS);
|
||||
for i = 1:cS % nodi
|
||||
j = 13;
|
||||
% -------------- Cumulati --------------------------
|
||||
while j <=(rS-1)
|
||||
hold off
|
||||
DEPETRIS = 0;
|
||||
if Criterio_3(j,i) == 1
|
||||
Tempo = DateGiorno(j-3:j); % giorni
|
||||
Vel = 1000*Speed(j-3:j,i); % mm/g
|
||||
Vel(Vel==0) = 0.0000000001;
|
||||
Inv_Vel = 1./Vel;
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m = retta(1,1); % m
|
||||
q = retta(1,2); % q
|
||||
% Time of failure
|
||||
Tr_S(j,i) = -q/m - DateGiorno(j);
|
||||
if Tr_S(j,i) > 0 && Tr_S(j,i) < 30 % giorni
|
||||
% RQ
|
||||
RQ_S(j,i) = rsquare.rsquare;
|
||||
% Grafico Inv V - T
|
||||
Data_Img = datestr(DateGiorno(j-3),'dd-mm-yyyy');
|
||||
Tempo_Img = datestr(DateGiorno(j-3),'HH-MM-SS');
|
||||
fig = plot(Tempo,Inv_Vel,'-o','LineStyle','none');
|
||||
hold on
|
||||
legend(num2str(RQ_S(j,i)));
|
||||
Y = m*Tempo + q;
|
||||
plot(Tempo,Y);
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy]')
|
||||
ylabel('Inverse of Velocity [d/mm]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Inv_Vel)+max(Inv_Vel)/10])
|
||||
% Grafico Vel - T
|
||||
hold off
|
||||
fig2 = plot(Tempo,Vel,'-o','LineStyle','none');
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy]')
|
||||
ylabel('Velocity [mm/d]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Vel)+max(Vel)/10])
|
||||
end
|
||||
% dato successivo
|
||||
for n = 1:(rS-j)
|
||||
if Criterio_3(n+j,i) == 1 || Criterio_3(n+j-1,i) == 1
|
||||
Tempo = DateGiorno(j-3:j+n); % giorni
|
||||
Vel = 1000*Speed(j-3:j+n,i); % mm/g
|
||||
Vel(Vel==0) = 0.0000000001;
|
||||
Inv_Vel = 1./Vel;
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel,'poly1');
|
||||
RQ_S(j+n,i) = rsquare.rsquare;
|
||||
retta = coeffvalues(f);
|
||||
m = retta(1,1);
|
||||
q = retta(1,2);
|
||||
% Time of Failure
|
||||
Tr_S(j+n,i) = -q/m - DateGiorno(j+n);
|
||||
if Tr_S(j+n,i) > 0 && Tr_S(j+n,i) < 30 % giorni
|
||||
if RQ_S(j+n,i) >= 0.85
|
||||
Tr_mail_S(j+n,i) = -q/m - DateGiorno(j+n);% attivo
|
||||
Tr_mail_S(j+n-1,i) = -99; % disattivo
|
||||
alarm_STORICO(j+n-1,i) = 0; % disattivo
|
||||
alarm_STORICO(j+n,i) = 1; % attivo
|
||||
DataFuK_S(j+n,i) = DateGiorno(j-3);
|
||||
DataFuK_S(j,i) = 0;
|
||||
Data_Img = datestr(DateGiorno(j-3),'dd-mm-yyyy');
|
||||
Tempo_Img = datestr(DateGiorno(j-3),'HH-MM-SS');
|
||||
% Grafico asintotico
|
||||
hold off
|
||||
fig2 = plot(Tempo,Vel,'-o','LineStyle','none');
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy]')
|
||||
ylabel('Velocity [mm/d]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Vel)+max(Vel)/10])
|
||||
Nodo = cell2mat(NodoTilt(i,2));
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img,'_',Tempo_Img,'_Vel_Storico.jpg');
|
||||
saveas(fig2,filename)
|
||||
% Grafico inverso velocità
|
||||
fig = plot(Tempo,Inv_Vel,'-o','LineStyle','none');
|
||||
hold on
|
||||
legend(num2str(RQ_S(j+n,i)));
|
||||
Y = m*Tempo + q;
|
||||
Y = [Y; 0];
|
||||
Tempo_End = -q/m;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y);
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy]')
|
||||
ylabel('Inverse of Velocity [d/mm]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Inv_Vel)+max(Inv_Vel)/10])
|
||||
LIM = floor(fig.XData(1));
|
||||
% Variazione statistica dei dati di
|
||||
% monitoraggio
|
||||
% Limite Superiore
|
||||
Inv_Vel_Sup = Inv_Vel + mean(Inv_Vel)*(1-RQ_S(j+n,i));
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel_Sup,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m_Sup = retta(1,1);
|
||||
q_Sup = retta(1,2);
|
||||
Tr_Sup_S(j+n,i) = -q_Sup/m_Sup;
|
||||
Tr_Sup_S(j+n-1,i) = 99;
|
||||
Y_Sup = m_Sup*Tempo + q_Sup;
|
||||
Y_Sup = [Y_Sup; 0];
|
||||
Tempo_End = -q_Sup/m_Sup;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y_Sup,'--');
|
||||
% Limite Inferiore
|
||||
Inv_Vel_Inf = Inv_Vel - mean(Inv_Vel)*(1-RQ_S(j+n,i));
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel_Inf,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m_Inf = retta(1,1);
|
||||
q_Inf = retta(1,2);
|
||||
Tr_Inf_S(j+n,i) = -q_Inf/m_Inf;
|
||||
Tr_Inf_S(j+n-1,i) = 99;
|
||||
Y_Inf = m_Inf*Tempo + q_Inf;
|
||||
Y_Inf = [Y_Inf; 0];
|
||||
Tempo_End = -q_Inf/m_Inf;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y_Inf,'--');
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
DEPETRIS = 1;
|
||||
N = n;
|
||||
Number_S(j+N,i) = N+4;
|
||||
end
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
if DEPETRIS == 1
|
||||
hold on
|
||||
fig = plot(DateGiorno(j+N)+Tr_S(j+N,i),0,'-d','LineStyle','none','Color','r');
|
||||
plot(Tr_Sup_S(j+N,i),0,'-v','LineStyle','none','Color','k');
|
||||
LIM_S = ceil(Tr_Sup_S(j+N,i));
|
||||
plot(Tr_Inf_S(j+N,i),0,'-v','LineStyle','none','Color','k');
|
||||
legend(['RQ: ' num2str(RQ_S(j+N,i))]);
|
||||
h = gca; % Get axis to modify
|
||||
xlim([LIM(1) LIM_S(end)])
|
||||
h.XAxis.MinorTick = 'on'; % Must turn on minor ticks if they are off
|
||||
h.XAxis.MinorTickValues = LIM(1):1/4:LIM_S(end); % Minor ticks which don't line up with majors
|
||||
h.XAxis.TickValues = LIM(1):1:LIM_S(end);
|
||||
datetick('x','dd/mm/yyyy')
|
||||
grid on
|
||||
grid minor
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img,'_',Tempo_Img,'_Storico.jpg');
|
||||
saveas(fig,filename)
|
||||
end
|
||||
j = j+n+1;
|
||||
else
|
||||
j = j+1;
|
||||
end
|
||||
end
|
||||
% -------------- Locali --------------------------
|
||||
j = 13;
|
||||
while j <=(rS-1)
|
||||
hold off
|
||||
GIOLITTI = 0;
|
||||
if Criterio_3_local(j,i) == 1
|
||||
Tempo = DateGiorno(j-3:j); % giorni
|
||||
Vel = 1000*Speed_local(j-3:j,i); % mm/g
|
||||
Vel(Vel==0) = 0.0000000001;
|
||||
Inv_Vel = 1./Vel;
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m = retta(1,1);
|
||||
q = retta(1,2);
|
||||
% Time of Failure
|
||||
Tr_Loc_S(j,i) = -q/m - DateGiorno(j);
|
||||
if Tr_Loc_S(j,i) > 0 && Tr_Loc_S(j,i) < 30
|
||||
% RQ
|
||||
RQ_Loc_S(j,i) = rsquare.rsquare;
|
||||
% Grafico Inv V - T
|
||||
Data_Img = datestr(DateGiorno(j-3),'dd-mm-yyyy');
|
||||
Tempo_Img = datestr(DateGiorno(j-3),'HH-MM-SS');
|
||||
% Grafico
|
||||
fig = plot(Tempo,Inv_Vel,'-o','LineStyle','none');
|
||||
hold on
|
||||
legend(num2str(RQ_Loc_S(j,i)));
|
||||
Y = m*Tempo + q;
|
||||
plot(Tempo,Y);
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy]')
|
||||
ylabel('Inverse of Velocity [d/mm]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Inv_Vel)+max(Inv_Vel)/10])
|
||||
% Grafico Vel - T
|
||||
hold off
|
||||
fig2 = plot(Tempo,Vel,'-o','LineStyle','none');
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy]')
|
||||
ylabel('Velocity [mm/d]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Vel)+max(Vel)/10])
|
||||
end
|
||||
% dato successivo
|
||||
for n = 1:(rS-j)
|
||||
if Criterio_3_local(n+j,i) == 1 || Criterio_3_local(n+j-1,i) == 1
|
||||
Tempo = DateGiorno(j-3:j+n); % giorni
|
||||
Vel = 1000*Speed_local(j-3:j+n,i); % mm/g
|
||||
Vel(Vel==0) = 0.0000000001;
|
||||
Inv_Vel = 1./Vel;
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel,'poly1');
|
||||
RQ_Loc_S(j+n,i) = rsquare.rsquare;
|
||||
retta = coeffvalues(f);
|
||||
m = retta(1,1);
|
||||
q = retta(1,2);
|
||||
% Time of Failure
|
||||
Tr_Loc_S(j+n,i) = -q/m - DateGiorno(j+n);
|
||||
if Tr_Loc_S(j+n,i) > 0 && Tr_Loc_S(j+n,i) < 30 % giorni
|
||||
if RQ_Loc_S(j+n,i) >= 0.85
|
||||
Tr_Loc_mail_S(j+n,i) = -q/m - DateGiorno(j+n);
|
||||
Tr_Loc_mail_S(j+n-1,i) = -99; % disattivo
|
||||
alarm_local_STORICO(j+n-1,i) = 0; % disattivo
|
||||
alarm_local_STORICO(j+n,i) = 1; % attivo
|
||||
DataFuK_local_S(j+n,i) = DateGiorno(j-3);
|
||||
DataFuK_local_S(j,i) = 0;
|
||||
Data_Img = datestr(DateGiorno(j-3),'dd-mm-yyyy');
|
||||
Tempo_Img = datestr(DateGiorno(j-3),'HH-MM-SS');
|
||||
% Grafico Asintotico
|
||||
hold off
|
||||
fig2 = plot(Tempo,Vel,'-o','LineStyle','none');
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy]')
|
||||
ylabel('Velocity [mm/d]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Vel)+max(Vel)/10])
|
||||
Nodo = cell2mat(NodoTilt(i,2));
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img,'_',Tempo_Img,'-Local_Vel_Storico.jpg');
|
||||
saveas(fig2,filename)
|
||||
% Grafico inverso velocità
|
||||
fig = plot(Tempo,Inv_Vel,'-o','LineStyle','none');
|
||||
hold on
|
||||
legend(num2str(RQ_Loc_S(j+n,i)));
|
||||
Y = m*Tempo + q;
|
||||
Y = [Y; 0];
|
||||
Tempo_End = -q/m;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y);
|
||||
title('Time of Failure prediction model');
|
||||
xlabel('Date [dd/mm/yyyy]')
|
||||
ylabel('Inverse of Velocity [d/mm]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Inv_Vel)+max(Inv_Vel)/10])
|
||||
LIM = floor(fig.XData(1));
|
||||
% Variazione statistica dei dati di
|
||||
% monitoraggio
|
||||
% Limite Superiore
|
||||
Inv_Vel_Sup = Inv_Vel + mean(Inv_Vel)*(1-RQ_Loc_S(j+n,i));
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel_Sup,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m_Sup = retta(1,1);
|
||||
q_Sup = retta(1,2);
|
||||
Tr_Loc_Sup_S(j+n,i) = -q_Sup/m_Sup;
|
||||
Tr_Loc_Sup_S(j+n-1,i) = 99;
|
||||
Y_Sup = m_Sup*Tempo + q_Sup;
|
||||
Y_Sup = [Y_Sup; 0];
|
||||
Tempo_End = -q_Sup/m_Sup;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y_Sup,'--');
|
||||
% Limite Inferiore
|
||||
Inv_Vel_Inf = Inv_Vel - mean(Inv_Vel)*(1-RQ_Loc_S(j+n,i));
|
||||
[f,rsquare] = fit(Tempo,Inv_Vel_Inf,'poly1');
|
||||
retta = coeffvalues(f);
|
||||
m_Inf = retta(1,1);
|
||||
q_Inf = retta(1,2);
|
||||
Tr_Loc_Inf_S(j+n,i) = -q_Inf/m_Inf;
|
||||
Tr_Loc_Inf_S(j+n-1,i) = 99;
|
||||
Y_Inf = m_Inf*Tempo + q_Inf;
|
||||
Y_Inf = [Y_Inf; 0];
|
||||
Tempo_End = -q_Inf/m_Inf;
|
||||
Tempo_G = [Tempo; Tempo_End];
|
||||
plot(Tempo_G,Y_Inf,'--');
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
GIOLITTI = 1;
|
||||
N = n;
|
||||
Number_Loc_S(j+N,i) = N+4;
|
||||
end
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
if GIOLITTI == 1
|
||||
hold on
|
||||
fig = plot(DateGiorno(j+N)+Tr_Loc_S(j+N,i),0,'-d','LineStyle','none','Color','r');
|
||||
plot(Tr_Loc_Sup_S(j+N,i),0,'-v','LineStyle','none','Color','k');
|
||||
LIM_S = ceil(Tr_Loc_Sup_S(j+N,i));
|
||||
plot(Tr_Loc_Inf_S(j+N,i),0,'-v','LineStyle','none','Color','k');
|
||||
legend(['RQ: ' num2str(RQ_Loc_S(j+N,i))]);
|
||||
h = gca; % Get axis to modify
|
||||
xlim([LIM(1) LIM_S(end)])
|
||||
h.XAxis.MinorTick = 'on'; % Must turn on minor ticks if they are off
|
||||
h.XAxis.MinorTickValues = LIM(1):1/4:LIM_S(end); % Minor ticks which don't line up with majors
|
||||
h.XAxis.TickValues = LIM(1):1:LIM_S(end);
|
||||
datetick('x','dd/mm/yyyy')
|
||||
grid on
|
||||
grid minor
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img,'_',Tempo_Img,'-Local_Storico.jpg');
|
||||
saveas(fig,filename)
|
||||
if yes3D == 1
|
||||
HRindex = find(cell2mat(NodoTiltHR3D(:,2))==Nodo);
|
||||
if isempty(HRindex) ~= 1
|
||||
NodeHR = NodoTiltHR3D(HRindex,3);
|
||||
HRprog = find(cell2mat(NodoTiltHR(:,2))==cell2mat(NodeHR));
|
||||
[rT,~] = size(Tempo);
|
||||
DateHR = zeros(rT,1);
|
||||
HShift_local_HR = zeros(rT,1);
|
||||
nHR = 1;
|
||||
for tt = 1:rT+1
|
||||
if tt == 1
|
||||
Data_HR = datestr(DateGiorno(j-4),'yyyy-mm-dd');
|
||||
Tempo_HR = datestr(DateGiorno(j-4),'HH:MM:SS');
|
||||
else
|
||||
Data_HR = datestr(Tempo(tt-1),'yyyy-mm-dd');
|
||||
Tempo_HR = datestr(Tempo(tt-1),'HH:MM:SS');
|
||||
end
|
||||
NodeNum = num2str(cell2mat(NodeHR));
|
||||
comando1 = ['select EventDate, EventTime, HShift_local from ElabDataView where EventDate = ''' ...
|
||||
Data_HR ''' and EventTime = ''' Tempo_HR ''' and ToolNameID = ''' DTcatena...
|
||||
''' and UnitName = ''' IDcentralina ''' and NodeNum = ''' NodeNum ''' '];
|
||||
curs = exec(conn,comando1);
|
||||
curs = fetch(curs);
|
||||
Dati_HR = curs.Data;
|
||||
% Modifico il formato di data e ora in DATini.
|
||||
[rD,~] = size(Dati_HR);
|
||||
T = [cell2mat(Dati_HR(:,1)) repmat(' ', [rD,1]) cell2mat(Dati_HR(:,2))];
|
||||
DateHR(nHR,1) = datenum(T); % Data
|
||||
HShift_local_HR(nHR,1) = cell2mat(Dati_HR(:,3)); % Loc 2D
|
||||
nHR = nHR+1;
|
||||
end
|
||||
%% Calcolo una singola velocità media giornaliera
|
||||
[rI,~] = size(DateHR);
|
||||
DateGiornoHR = DateHR(2:end);
|
||||
for s = 2:rI
|
||||
Speed_local_HR(s-1,:) = (HShift_local_HR(s,:) - HShift_local_HR(s-1,:))/(DateHR(s,1) - DateHR(s-1,:));
|
||||
end
|
||||
% Velocità in metri/giorno
|
||||
jHR = find(DateGiornoHR == DateGiorno(j));
|
||||
|
||||
% ---Criterio della velocità positiva Criterio 0---
|
||||
if Speed_local_HR(jHR,1) > 0 && ...
|
||||
Speed_local_HR(jHR-1,1) > 0 ...
|
||||
&& Speed_local_HR(jHR-2,1) > 0 ...
|
||||
&& Speed_local_HR(jHR-3,1) > 0
|
||||
|
||||
% --- Calcolo Fukuzono ---
|
||||
TempoHR = DateGiornoHR(jHR-3:jHR+N); % giorni
|
||||
Vel_HR = 1000*Speed_local_HR(jHR-3:jHR+N,1); % mm/g
|
||||
Vel_HR(Vel_HR==0) = 0.0000000001;
|
||||
Inv_Vel_HR = 1./Vel_HR;
|
||||
[f,rsquare] = fit(TempoHR,Inv_Vel_HR,'poly1');
|
||||
RQ_Loc_HR_S(jHR+N,HRprog) = rsquare.rsquare;
|
||||
retta = coeffvalues(f);
|
||||
m = retta(1,1);
|
||||
q = retta(1,2);
|
||||
% Time of Failure
|
||||
Tr_Loc_HR_S(jHR+N,HRprog) = -q/m - DateGiornoHR(jHR+N);
|
||||
if Tr_Loc_HR_S(jHR+N,HRprog) > 0 && Tr_Loc_HR_S(jHR+N,HRprog) < 30 % giorni
|
||||
if RQ_Loc_HR_S(jHR+N,i) >= 0.85
|
||||
DataFuK_local_HR_S(jHR+N,HRprog) = DateGiornoHR(jHR-3);
|
||||
Data_Img_HR = datestr(DateGiornoHR(jHR-3),'dd-mm-yyyy');
|
||||
Tempo_Img_HR = datestr(DateGiornoHR(jHR-3),'HH-MM-SS');
|
||||
% Grafico Asintotico
|
||||
fig2 = plot(TempoHR,Vel_HR,'-o','LineStyle','none');
|
||||
title('Time of Failure prediction model evaluated with Electrolytic Cell');
|
||||
xlabel('Date [dd/mm/yyyy]')
|
||||
ylabel('Velocity [mm/d]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Vel_HR)+max(Vel_HR)/10])
|
||||
Nodo = cell2mat(NodoTiltHR(HRprog,2));
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img_HR,'_',Tempo_Img_HR,'-Local_Vel_Storico.jpg');
|
||||
saveas(fig2,filename)
|
||||
% Grafico inverso velocità
|
||||
fig = plot(TempoHR,Inv_Vel_HR,'-o','LineStyle','none');
|
||||
hold on
|
||||
legend(num2str(RQ_Loc_HR_S(jHR+N,i)));
|
||||
Y_HR = m*TempoHR + q;
|
||||
plot(Tempo,Y_HR);
|
||||
title('Time of Failure prediction model evaluated with Electrolytic Cell');
|
||||
xlabel('Date [dd/mm/yyyy]')
|
||||
ylabel('Inverse of Velocity [d/mm]')
|
||||
datetick('x','dd/mm/yyyy HH:MM')
|
||||
ylim([0 max(Inv_Vel_HR)+max(Inv_Vel_HR)/10])
|
||||
LIM = floor(fig.XData(1));
|
||||
fig = plot(DateGiornoHR(jHR+N)+Tr_Loc_HR_S(jHR+N,HRprog),0,'-d','LineStyle','none','Color','r');
|
||||
LIM_S = ceil(Tr_Loc_HR_S(jHR+N,HRprog)+DateGiornoHR(jHR+N));
|
||||
h = gca; % Get axis to modify
|
||||
xlim([LIM LIM_S])
|
||||
h.XAxis.MinorTick = 'on'; % Must turn on minor ticks if they are off
|
||||
h.XAxis.MinorTickValues = LIM:1/4:LIM_S; % Minor ticks which don't line up with majors
|
||||
h.XAxis.TickValues = LIM:1:LIM_S;
|
||||
datetick('x','dd/mm/yyyy')
|
||||
grid on
|
||||
grid minor
|
||||
filename = strcat(IDcentralina,'-',DTcatena,'-Node_',num2str(Nodo),'-',Data_Img_HR,'_',Tempo_Img_HR,'-Local_Storico.jpg');
|
||||
saveas(fig,filename)
|
||||
else
|
||||
Tr_Loc_HR_S(jHR+N,HRprog) = 0;
|
||||
end
|
||||
else
|
||||
Tr_Loc_HR_S(jHR+N,HRprog) = 0;
|
||||
end
|
||||
else
|
||||
Tr_Loc_HR_S(jHR,HRprog) = 0;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
j = j+n+1;
|
||||
else
|
||||
j = j+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = 'Fukuzono_Giornaliero Calculation executed';
|
||||
fprintf(fileID,fmt,text);
|
||||
else
|
||||
alarm_STORICO = zeros(rS,cS);
|
||||
alarm_local_STORICO = zeros(rS,cS);
|
||||
Tr_Loc_Sup_S = [];
|
||||
Tr_Loc_Inf_S = [];
|
||||
Tr_Loc_S = [];
|
||||
Tr_Sup_S = [];
|
||||
Tr_Inf_S = [];
|
||||
Tr_S = [];
|
||||
Tr_mail_S = [];
|
||||
Tr_Loc_mail_S = [];
|
||||
DataFuK_local_S = [];
|
||||
DataFuK_S = [];
|
||||
Number_S = [];
|
||||
Number_Loc_S = [];
|
||||
RQ_S = [];
|
||||
RQ_Loc_S = [];
|
||||
end
|
||||
text = 'Fukuzono_Giornaliero function executed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
15
Tilt/IDunit.m
Executable file
15
Tilt/IDunit.m
Executable file
@@ -0,0 +1,15 @@
|
||||
function unitID = IDunit(IDcentralina,conn,FileName)
|
||||
|
||||
text = 'IDunit function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
comando = ['select id from units where name like ''' IDcentralina ''' '];
|
||||
unitID = fetch(conn,comando);
|
||||
|
||||
text = 'Unit ID downloaded correctly, IDunit function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
256
Tilt/Klino.m
Executable file
256
Tilt/Klino.m
Executable file
@@ -0,0 +1,256 @@
|
||||
function [ANGdefKL,TdefKL,ErrKlinoLink,ARRAYdateKL] = Klino(ANGdefKL,TdefKL,...
|
||||
ARRAYdateKL,ErrKlinoLink,NuovoZeroKL,NdatiMedia,Ndatidespike,ris_acc,tolleranzaAcc,...
|
||||
Tmax,Tmin,datainiKL,rKL,IDcentralina,DTcatena,margine,NodoKlinoLink,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'Klino function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
if NuovoZeroKL == 1
|
||||
if NdatiMedia > Ndatidespike
|
||||
Ndati = NdatiMedia;
|
||||
else
|
||||
Ndati = Ndatidespike;
|
||||
end
|
||||
ini = round(Ndati/2)+1;
|
||||
if rem(Ndati,2) == 0
|
||||
ini = ini+1;
|
||||
end
|
||||
clear NDati
|
||||
ini = ini + margine;
|
||||
if ini < 6
|
||||
ini = 6;
|
||||
end
|
||||
[letture,~]=size(ANGdefKL);
|
||||
if ini > letture
|
||||
ini = 1;
|
||||
end
|
||||
ErrKlinoLink = ErrKlinoLink(ini:end,:);
|
||||
ANGdefKL = ANGdefKL(ini:end,:);
|
||||
TdefKL = TdefKL(ini:end,:);
|
||||
ARRAYdateKL = ARRAYdateKL(ini:end,1);
|
||||
ris_acc = ris_acc(ini:end,:);
|
||||
end
|
||||
|
||||
if strcmp(NodoKlinoLink{1,4} ,'Gradi')
|
||||
TempDef = TdefKL';
|
||||
Angolo = ANGdefKL';
|
||||
else
|
||||
%% Controllo delle risultanti di accelerazione
|
||||
clear r
|
||||
clear rr
|
||||
clear c
|
||||
clear cc
|
||||
[r,c] = size(ris_acc);
|
||||
[rr,cc] = size(ANGdefKL);
|
||||
% controllo che le matrici con le risultanti delle accelerazioni e
|
||||
% le matrici con i dati di angolo di inclinazione
|
||||
% abbiano le stesse dimensioni (r con cc e c con rr perchè matrice
|
||||
% ris_acc è trasposta!)
|
||||
|
||||
if c~=cc/3
|
||||
text = '--- Warning! Number of columns of angle data do not correspond to the number of acceleration cosine vector! ---';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
if r~=rr
|
||||
text = '--- Warning! Number of rows of angle data do not correspond to the number of acceleration cosine vector! ---';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
clear i
|
||||
clear j
|
||||
cont = 1; % contatore
|
||||
cont3 = 1; % contatore
|
||||
ris_acc = ris_acc'; % Nodi in riga, date in colonna
|
||||
TempDef = TdefKL';
|
||||
Angolo = ANGdefKL';
|
||||
textA = 'There are not correction of Klino Link based on acceleration vectors filter';
|
||||
textA2 = 'There are not correction of Klino Link based on uncalibrated acceleration vectors';
|
||||
textT = 'There are not correction of Klino Link based on temperature filter';
|
||||
for j = 2:r % Data
|
||||
nodo = 1;
|
||||
for i = 1:c % Nodo
|
||||
% se il valore assoluto della differenza è maggiore della
|
||||
% tolleranza, pongo l'angolo pari al valore precendete
|
||||
if abs(ris_acc(i,j)-ris_acc(i,j-1)) > tolleranzaAcc
|
||||
Angolo(nodo:nodo+2,j) = Angolo(nodo:nodo+2,j-1);
|
||||
textA = ['' num2str(cont) ' correction executed for Klino Link - Acceleration vector filter!'];
|
||||
cont = cont+1;
|
||||
end
|
||||
if ris_acc(i,j) < 0.9 || ris_acc(i,j) > 1.1 % Il nodo è fuori taratura!
|
||||
Angolo(nodo:nodo+2,j) = Angolo(nodo:nodo+2,j-1);
|
||||
TempDef(i,j) = TempDef(i,j-1);
|
||||
textA2 = ['' num2str(cont) ' correction executed for Klino Link - uncalibrated Acceleration vector!'];
|
||||
cont3 = cont3+1;
|
||||
end
|
||||
nodo = nodo+3;
|
||||
end
|
||||
end
|
||||
fprintf(fileID,fmt,textA);
|
||||
fprintf(fileID,fmt,textA2);
|
||||
end
|
||||
|
||||
%% Controllo della temperatura
|
||||
FileTemperature = ['' IDcentralina '-' DTcatena '-KL-Therm.csv'];
|
||||
if isfile(FileTemperature) == 1
|
||||
DatiRaw = csvread(FileTemperature);
|
||||
[rDR,cDR] = size(DatiRaw);
|
||||
DatiRaw(:,1) = DatiRaw(:,1) + 730000;
|
||||
else
|
||||
rDR = 1;
|
||||
cDR = 1;
|
||||
end
|
||||
[~,cEr] = size(ErrKlinoLink);
|
||||
[rr,c] = size(TdefKL);
|
||||
col = cEr/rKL;
|
||||
cont2 = 1;
|
||||
for j = 1:rr % Data
|
||||
jj = col;
|
||||
nodo = 1;
|
||||
for i = 1:c % Nodo
|
||||
% NON considero i dati al di sopra di Tmax o al di sotto di Tmin
|
||||
if TempDef(i,j) > Tmax || TempDef(i,j) < Tmin
|
||||
cont2 = cont2+1;
|
||||
if j == 1
|
||||
if isfile(FileTemperature) == 1
|
||||
RawDate = find(DatiRaw(:,1)<=datenum(datainiKL));
|
||||
if isempty(RawDate) == 1
|
||||
cc = 2;
|
||||
while cc <= Ndate
|
||||
if TempDef(i,cc) > Tmax || TempDef(i,cc) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
TempDef(i,j) = TempDef(i,cc);
|
||||
else
|
||||
if isnan(DatiRaw(RawDate(end),i)) == 0
|
||||
TempDef(i,j) = DatiRaw(RawDate(end),i+1);
|
||||
ErrKlinoLink(j,jj) = 0.5;
|
||||
wardat = 'Temperature data of Klino Link nodes corrected using Raw Data of reference Csv file.';
|
||||
fprintf(fileID,fmt,wardat);
|
||||
else
|
||||
cc = 2;
|
||||
while cc <= c
|
||||
if TempDef(i,cc) > Tmax || TempDef(i,cc) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
TempDef(i,j) = TempDef(i,cc);
|
||||
end
|
||||
end
|
||||
else
|
||||
cc = 2;
|
||||
while cc <= c
|
||||
if TempDef(i,cc) > Tmax || TempDef(i,cc) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
TempDef(i,j) = TempDef(i,cc);
|
||||
end
|
||||
else
|
||||
if col == 3
|
||||
Angolo(nodo:nodo+1,j) = Angolo(nodo:nodo+1,j-1);
|
||||
nodo = nodo+2;
|
||||
elseif col == 4
|
||||
Angolo(nodo:nodo+2,j) = Angolo(nodo:nodo+2,j-1);
|
||||
nodo = nodo+3;
|
||||
end
|
||||
TempDef(i,j) = TempDef(i,j-1);
|
||||
ErrKlinoLink(j,jj) = 0.5;
|
||||
end
|
||||
end
|
||||
textT = ['' num2str(cont2) ' correction executed for Klino Link - Temperature filter!'];
|
||||
jj = jj+cEr/rKL;
|
||||
end
|
||||
end
|
||||
|
||||
if rDR~=1 && cDR~=1 && isempty(DatiRaw) == 0
|
||||
RawDate1 = find(DatiRaw(:,1)<=ARRAYdateKL(1));
|
||||
if isempty(RawDate1) == 1
|
||||
RawDate2 = 1;
|
||||
elseif RawDate1(end) == rDR
|
||||
RawDate2 = find(ARRAYdateKL(:,1)>DatiRaw(end,1));
|
||||
else
|
||||
RawDate2 = find(ARRAYdateKL(:,1)>DatiRaw(RawDate1(end)+1,1));
|
||||
end
|
||||
else
|
||||
RawDate1 = [];
|
||||
RawDate2 = 1;
|
||||
end
|
||||
if isempty(RawDate1) == 0 && isempty(RawDate2) == 0
|
||||
Dati = [DatiRaw(1:RawDate1(end),:); ARRAYdateKL(RawDate2(1):end,1) TempDef(:,RawDate2(1):end)'];
|
||||
elseif isempty(RawDate1) == 1 && isempty(RawDate2) == 0
|
||||
Dati = [ARRAYdateKL TempDef'];
|
||||
else
|
||||
Dati = DatiRaw;
|
||||
end
|
||||
% Elimino appoggio più vecchio di un mese
|
||||
RawDate3 = find(Dati(:,1)<now-30);
|
||||
if isempty(RawDate3) == 0
|
||||
[rDati,~] = size(Dati);
|
||||
if RawDate3(end) == rDati
|
||||
else
|
||||
Dati = Dati(RawDate3(end)+1:end,:);
|
||||
end
|
||||
end
|
||||
if isfile(FileTemperature) == 1
|
||||
delete(FileTemperature);
|
||||
end
|
||||
Dati(:,1) = Dati(:,1) - 730000;
|
||||
csvwrite(FileTemperature,Dati);
|
||||
|
||||
TdefKL = TempDef';
|
||||
ANGdefKL = Angolo';
|
||||
fprintf(fileID,fmt,textT);
|
||||
|
||||
%% Calcolo differenziali
|
||||
NomeFile = ['' IDcentralina '-' DTcatena '-RifKL.csv'];
|
||||
if NuovoZeroKL == 0 % prima elaborazione
|
||||
csvwrite(NomeFile,ANGdefKL(1,:));
|
||||
ANGdefKL = ANGdefKL - ANGdefKL(1,:);
|
||||
else % Ci sono già dei dati elaborati
|
||||
RIF = csvread(NomeFile);
|
||||
ANGdefKL = ANGdefKL - RIF;
|
||||
end
|
||||
|
||||
%% Matrice Errori
|
||||
[r,~] = size(ErrKlinoLink);
|
||||
Matrice_err = zeros(r,rKL);
|
||||
for i = 1:r % date
|
||||
d = 1;
|
||||
if strcmp(NodoKlinoLink(1,4),'ADC') || strcmp(NodoKlinoLink{1,4} ,'null') ...
|
||||
|| isempty(NodoKlinoLink{1,4}) == 1 || strcmp(NodoKlinoLink{1,4},'g') == 1
|
||||
off = 3;
|
||||
elseif strcmp(NodoKlinoLink(1,4),'Gradi')
|
||||
off = 2;
|
||||
end
|
||||
for n = 1:rKL % nodi
|
||||
j = 1;
|
||||
err = ErrKlinoLink(i,d:d+off);
|
||||
while j <= off+1
|
||||
if err(1,j) == 1
|
||||
Matrice_err(i,n) = 1;
|
||||
end
|
||||
j = j+1;
|
||||
end
|
||||
if strcmp(NodoKlinoLink(1,4),'ADC') || strcmp(NodoKlinoLink{1,4} ,'null') ...
|
||||
|| isempty(NodoKlinoLink{1,4}) == 1 || strcmp(NodoKlinoLink{1,4},'g') == 1
|
||||
off = off+4;
|
||||
elseif strcmp(NodoKlinoLink(1,4),'Gradi')
|
||||
off = off+3;
|
||||
end
|
||||
end
|
||||
end
|
||||
ErrKlinoLink = Matrice_err';
|
||||
|
||||
text = 'Klino Link elaborated correctly. Klino function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
194
Tilt/KlinoHR.m
Executable file
194
Tilt/KlinoHR.m
Executable file
@@ -0,0 +1,194 @@
|
||||
function [ANGdefKLHR,TdefKLHR,ErrKlinoLinkHR,ARRAYdateKLHR] = KlinoHR(ANGdefKLHR,...
|
||||
TdefKLHR,ARRAYdateKLHR,ErrKlinoLinkHR,NuovoZeroKLHR,NodoKlinoLinkHR,NdatiMedia,...
|
||||
Ndatidespike,Tmax,Tmin,datainiKLHR,rKLHR,IDcentralina,DTcatena,margine,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'KlinoHR function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
if NuovoZeroKLHR == 1
|
||||
if NdatiMedia > Ndatidespike
|
||||
Ndati = NdatiMedia;
|
||||
else
|
||||
Ndati = Ndatidespike;
|
||||
end
|
||||
ini = round(Ndati/2)+1;
|
||||
if rem(Ndati,2) == 0
|
||||
ini = ini+1;
|
||||
end
|
||||
clear NDati
|
||||
ini = ini + margine;
|
||||
if ini < 6
|
||||
ini = 6;
|
||||
end
|
||||
ErrKlinoLinkHR = ErrKlinoLinkHR(ini:end,:);
|
||||
ANGdefKLHR = ANGdefKLHR(ini:end,:);
|
||||
TdefKLHR = TdefKLHR(ini:end,:);
|
||||
ARRAYdateKLHR = ARRAYdateKLHR(ini:end,1);
|
||||
end
|
||||
|
||||
if strcmp(NodoKlinoLinkHR(1,4),'IPTM') == 1
|
||||
else
|
||||
%% Controllo della temperatura
|
||||
FileTemperature = ['' IDcentralina '-' DTcatena '-KLHR-Therm.csv'];
|
||||
if isfile(FileTemperature) == 1
|
||||
DatiRaw = csvread(FileTemperature);
|
||||
[rDR,cDR] = size(DatiRaw);
|
||||
DatiRaw(:,1) = DatiRaw(:,1) + 730000;
|
||||
else
|
||||
rDR = 1;
|
||||
cDR = 1;
|
||||
end
|
||||
[r,c] = size(ANGdefKLHR);
|
||||
contT = 1; % contatore
|
||||
TempDef = TdefKLHR';
|
||||
Angolo = ANGdefKLHR';
|
||||
textT = 'There are not correction of Klino Link HR based on temperature filter';
|
||||
for j = 1:r % Data
|
||||
nodo = 1;
|
||||
jj = 6;
|
||||
for i = 1:c/2 % Nodo
|
||||
% NON considero i dati al di sopra di TempMAX °C o al di sotto di TempMIN °C!
|
||||
if TempDef(i,j) > Tmax || TempDef(i,j) < Tmin
|
||||
if j == 1
|
||||
if isfile(FileTemperature) == 1
|
||||
RawDate = find(DatiRaw(:,1)<=datenum(datainiKLHR));
|
||||
if isempty(RawDate) == 1
|
||||
cc = 2;
|
||||
while cc <= Ndate
|
||||
if TempDef(i,cc) > Tmax || TempDef(i,cc) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
TempDef(i,j) = TempDef(i,cc);
|
||||
else
|
||||
if isnan(DatiRaw(RawDate(end),jj)) == 0
|
||||
TempDef(i,j) = DatiRaw(RawDate(end),j+1);
|
||||
ErrKlinoLinkHR(j,jj) = 0.5;
|
||||
wardat = 'Temperature data of Klino Link HR nodes corrected using Raw Data of reference Csv file.';
|
||||
fprintf(fileID,fmt,wardat);
|
||||
else
|
||||
cc = 2;
|
||||
while cc <= c
|
||||
if TempDef(i,cc) > Tmax || TempDef(i,cc) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
TempDef(i,j) = TempDef(i,cc);
|
||||
end
|
||||
end
|
||||
else
|
||||
cc = 2;
|
||||
while cc <= c
|
||||
if TempDef(i,cc) > Tmax || TempDef(i,cc) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
TempDef(i,j) = TempDef(i,cc);
|
||||
end
|
||||
else
|
||||
Angolo(nodo:nodo+1,j) = Angolo(nodo:nodo+1,j-1);
|
||||
TempDef(i,j) = TempDef(i,j-1);
|
||||
ErrKlinoLinkHR(j,jj) = 0.5;
|
||||
end
|
||||
end
|
||||
textT = ['' num2str(contT) ' correction executed for Klino Link HR - Temperature filter!'];
|
||||
jj = jj+6;
|
||||
end
|
||||
end
|
||||
|
||||
if rDR~=1 && cDR~=1 && isempty(DatiRaw) == 0
|
||||
RawDate1 = find(DatiRaw(:,1)<=ARRAYdateKLHR(1));
|
||||
if isempty(RawDate1) == 1
|
||||
RawDate2 = 1;
|
||||
elseif RawDate1(end) == rDR
|
||||
RawDate2 = find(ARRAYdateKLHR(:,1)>DatiRaw(end,1));
|
||||
else
|
||||
RawDate2 = find(ARRAYdateKLHR(:,1)>DatiRaw(RawDate1(end)+1,1));
|
||||
end
|
||||
else
|
||||
RawDate1 = [];
|
||||
RawDate2 = 1;
|
||||
end
|
||||
if isempty(RawDate1) == 0 && isempty(RawDate2) == 0
|
||||
Dati = [DatiRaw(1:RawDate1(end),:); ARRAYdateKLHR(RawDate2(1):end,1) TempDef(:,RawDate2(1):end)'];
|
||||
elseif isempty(RawDate1) == 1 && isempty(RawDate2) == 0
|
||||
Dati = [ARRAYdateKLHR TempDef'];
|
||||
else
|
||||
Dati = DatiRaw;
|
||||
end
|
||||
% Elimino appoggio più vecchio di un mese
|
||||
RawDate3 = find(Dati(:,1)<now-30);
|
||||
if isempty(RawDate3) == 0
|
||||
[rDati,~] = size(Dati);
|
||||
if RawDate3(end) == rDati
|
||||
else
|
||||
Dati = Dati(RawDate3(end)+1:end,:);
|
||||
end
|
||||
end
|
||||
if isfile(FileTemperature) == 1
|
||||
delete(FileTemperature);
|
||||
end
|
||||
Dati(:,1) = Dati(:,1) - 730000;
|
||||
csvwrite(FileTemperature,Dati);
|
||||
|
||||
TdefKLHR = TempDef';
|
||||
ANGdefKLHR = Angolo';
|
||||
fprintf(fileID,fmt,textT);
|
||||
|
||||
%% Calcolo differenziali
|
||||
NomeFile = ['' IDcentralina '-' DTcatena '-RifKLHR.csv'];
|
||||
if NuovoZeroKLHR == 0 % prima elaborazione
|
||||
csvwrite(NomeFile,ANGdefKLHR(1,:));
|
||||
ANGdefKLHR = ANGdefKLHR - ANGdefKLHR(1,:);
|
||||
else % Ci sono già dei dati elaborati
|
||||
RIF = csvread(NomeFile);
|
||||
ANGdefKLHR = ANGdefKLHR - RIF;
|
||||
end
|
||||
end
|
||||
|
||||
%% Matrice Errori
|
||||
[r,~] = size(ErrKlinoLinkHR);
|
||||
Matrice_err = zeros(r,rKLHR);
|
||||
for i = 1:r % date
|
||||
d = 1;
|
||||
if strcmp(NodoKlinoLinkHR(1,4),'IPTM') == 1
|
||||
for n = 1:rKLHR % nodi
|
||||
j = 1;
|
||||
err = ErrKlinoLinkHR(i,d:d+2);
|
||||
while j <= 3
|
||||
if err(1,j) == 1
|
||||
Matrice_err(i,n) = 1;
|
||||
end
|
||||
j = j+1;
|
||||
end
|
||||
d = d+3;
|
||||
end
|
||||
else
|
||||
for n = 1:rKLHR % nodi
|
||||
j = 1;
|
||||
err = ErrKlinoLinkHR(i,d:d+5);
|
||||
while j <= 6
|
||||
if err(1,j) == 1
|
||||
Matrice_err(i,n) = 1;
|
||||
end
|
||||
j = j+1;
|
||||
end
|
||||
d = d+6;
|
||||
end
|
||||
end
|
||||
end
|
||||
ErrKlinoLinkHR = Matrice_err';
|
||||
|
||||
text = 'Klino Link HR elaborated correctly. KlinoHR function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
3044
Tilt/LastElab.m
Executable file
3044
Tilt/LastElab.m
Executable file
File diff suppressed because it is too large
Load Diff
42
Tilt/LastElab_bisIPL.m
Executable file
42
Tilt/LastElab_bisIPL.m
Executable file
@@ -0,0 +1,42 @@
|
||||
function DatiElabInPlaceLink = LastElab_bisIPL(conn,NodoInPlaceLink,rIPL,...
|
||||
datainiIPL,tempoiniIPL,IDcentralina,DTcatena,FileName)
|
||||
|
||||
NInPlaceLink = cell2mat(NodoInPlaceLink(:,2));
|
||||
NodeType = 'In Place Link';
|
||||
ii = 1; % contatore
|
||||
col = 16; % contatore colonne
|
||||
while ii <= rIPL
|
||||
ini_col = col-15;
|
||||
nN = num2str(NInPlaceLink(ii,1));
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, HShift, HShift_local, HShiftDir, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate = ''' ...
|
||||
datainiIPL ''' and EventTime >= ''' tempoiniIPL ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoIPLd = curs.Data;
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, HShift, HShift_local, HShiftDir, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate > ''' ...
|
||||
datainiIPL ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoIPL = curs.Data;
|
||||
[~,c1] = size(DATnodoIPL);
|
||||
[~,c2] = size(DATnodoIPLd);
|
||||
if c1==c2
|
||||
DATnodoIPL = [DATnodoIPLd; DATnodoIPL];
|
||||
elseif c1 < c2 % solo giorno di riferimento
|
||||
DATnodoIPL = DATnodoIPLd;
|
||||
end
|
||||
DatiElabInPlaceLink(:,ini_col:col) = DATnodoIPL(:,:);
|
||||
col = col+16;
|
||||
ii = ii+1;
|
||||
end
|
||||
|
||||
text = 'LastElab_bisIPL function worked correctly for In Place Link';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
42
Tilt/LastElab_bisIPLHR.m
Executable file
42
Tilt/LastElab_bisIPLHR.m
Executable file
@@ -0,0 +1,42 @@
|
||||
function DatiElabInPlaceLinkHR = LastElab_bisIPLHR(conn,NodoInPlaceLinkHR,rIPLHR,...
|
||||
datainiIPLHR,tempoiniIPLHR,IDcentralina,DTcatena,FileName)
|
||||
|
||||
NInPlaceLinkHR = cell2mat(NodoInPlaceLinkHR(:,2));
|
||||
NodeType = 'In Place Link HR';
|
||||
ii = 1; % contatore
|
||||
col = 16; % contatore colonne
|
||||
while ii <= rIPLHR
|
||||
ini_col = col-15;
|
||||
nN = num2str(NInPlaceLinkHR(ii,1));
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, HShift, HShift_local, HShiftDir, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate = ''' ...
|
||||
datainiIPLHR ''' and EventTime >= ''' tempoiniIPLHR ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoIPLHRd = curs.Data;
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, HShift, HShift_local, HShiftDir, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate > ''' ...
|
||||
datainiIPLHR ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoIPLHR = curs.Data;
|
||||
[~,c1] = size(DATnodoIPLHR);
|
||||
[~,c2] = size(DATnodoIPLHRd);
|
||||
if c1==c2
|
||||
DATnodoIPLHR = [DATnodoIPLHRd; DATnodoIPLHR];
|
||||
elseif c1 < c2 % solo giorno di riferimento
|
||||
DATnodoIPLHR = DATnodoIPLHRd;
|
||||
end
|
||||
DatiElabInPlaceLinkHR(:,ini_col:col) = DATnodoIPLHR(:,:);
|
||||
col = col+16;
|
||||
ii = ii+1;
|
||||
end
|
||||
|
||||
text = 'LastElab_bisIPLHR function worked correctly for In Place Link HR';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
42
Tilt/LastElab_bisRL.m
Executable file
42
Tilt/LastElab_bisRL.m
Executable file
@@ -0,0 +1,42 @@
|
||||
function DatiElabRainLink = LastElab_bisRL(conn,NodoRainLink,rRL,datainiRL,...
|
||||
tempoiniRL,IDcentralina,DTcatena,FileName)
|
||||
|
||||
NRainLink = cell2mat(NodoRainLink(:,2));
|
||||
NodeType = 'Rain Link';
|
||||
ii = 1; % contatore
|
||||
col = 4; % contatore colonne
|
||||
while ii <= rRL
|
||||
ini_col = col-3;
|
||||
nN = num2str(NRainLink(ii,1));
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, ZShift, Z from ElabDataView where EventDate = ''' ...
|
||||
datainiRL ''' and EventTime >= ''' tempoiniRL ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoRLd = curs.Data;
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, ZShift, Z from ElabDataView where EventDate > ''' ...
|
||||
datainiRL ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoRL = curs.Data;
|
||||
[~,c1] = size(DATnodoRL);
|
||||
[~,c2] = size(DATnodoRLd);
|
||||
if c1==c2
|
||||
DATnodoRL = [DATnodoRLd; DATnodoRL];
|
||||
elseif c1 < c2 % solo giorno di riferimento
|
||||
DATnodoRL = DATnodoRLd;
|
||||
end
|
||||
DatiElabRainLink(:,ini_col:col) = DATnodoRL(:,:);
|
||||
col = col+4;
|
||||
ii = ii+1;
|
||||
end
|
||||
|
||||
text = 'LastElab_bisRL function worked correctly for Rain Link';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
42
Tilt/LastElab_bisSL.m
Executable file
42
Tilt/LastElab_bisSL.m
Executable file
@@ -0,0 +1,42 @@
|
||||
function DatiElabSnowLink = LastElab_bisSL(conn,NodoSnowLink,rSL,datainiSL,...
|
||||
tempoiniSL,IDcentralina,DTcatena,FileName)
|
||||
|
||||
NSnowLink = cell2mat(NodoSnowLink(:,2));
|
||||
NodeType = 'Snow Link';
|
||||
ii = 1; % contatore
|
||||
col = 4; % contatore colonne
|
||||
while ii <= rSL
|
||||
ini_col = col-3;
|
||||
nN = num2str(NSnowLink(ii,1));
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, ZShift, Z from ElabDataView where EventDate = ''' ...
|
||||
datainiSL ''' and EventTime >= ''' tempoiniSL ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoSLd = curs.Data;
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, ZShift, Z from ElabDataView where EventDate > ''' ...
|
||||
datainiSL ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoSL = curs.Data;
|
||||
[~,c1] = size(DATnodoSL);
|
||||
[~,c2] = size(DATnodoSLd);
|
||||
if c1==c2
|
||||
DATnodoSL = [DATnodoSLd; DATnodoSL];
|
||||
elseif c1 < c2 % solo giorno di riferimento
|
||||
DATnodoSL = DATnodoSLd;
|
||||
end
|
||||
DatiElabSnowLink(:,ini_col:col) = DATnodoSL(:,:);
|
||||
col = col+4;
|
||||
ii = ii+1;
|
||||
end
|
||||
|
||||
text = 'LastElab_bisSL function worked correctly for Snow Link';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
42
Tilt/LastElab_bisTL.m
Executable file
42
Tilt/LastElab_bisTL.m
Executable file
@@ -0,0 +1,42 @@
|
||||
function DatiElabTiltLink = LastElab_bisTL(conn,NodoTiltLink,rTL,datainiTL,...
|
||||
tempoiniTL,IDcentralina,DTcatena,FileName)
|
||||
|
||||
NTiltLink = cell2mat(NodoTiltLink(:,2));
|
||||
NodeType = 'Tilt Link';
|
||||
ii = 1; % contatore
|
||||
col = 16; % contatore colonne
|
||||
while ii <= rTL
|
||||
ini_col = col-15;
|
||||
nN = num2str(NTiltLink(ii,1));
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, HShift, HShift_local, HShiftDir, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate = ''' ...
|
||||
datainiTL ''' and EventTime >= ''' tempoiniTL ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoTLd = curs.Data;
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, HShift, HShift_local, HShiftDir, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate > ''' ...
|
||||
datainiTL ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoTL = curs.Data;
|
||||
[~,c1] = size(DATnodoTL);
|
||||
[~,c2] = size(DATnodoTLd);
|
||||
if c1==c2
|
||||
DATnodoTL = [DATnodoTLd; DATnodoTL];
|
||||
elseif c1 < c2 % solo giorno di riferimento
|
||||
DATnodoTL = DATnodoTLd;
|
||||
end
|
||||
DatiElabTiltLink(:,ini_col:col) = DATnodoTL(:,:);
|
||||
col = col+16;
|
||||
ii = ii+1;
|
||||
end
|
||||
|
||||
text = 'LastElab_bisTL function worked correctly for Tilt Link V';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
42
Tilt/LastElab_bisTLH.m
Executable file
42
Tilt/LastElab_bisTLH.m
Executable file
@@ -0,0 +1,42 @@
|
||||
function DatiElabTiltLinkH = LastElab_bisTLH(conn,NodoTiltLinkH,rTLH,datainiTLH,...
|
||||
tempoiniTLH,IDcentralina,DTcatena,FileName)
|
||||
|
||||
NTiltLinkH = cell2mat(NodoTiltLinkH(:,2));
|
||||
NodeType = 'Tilt Link H';
|
||||
ii = 1; % contatore
|
||||
col = 13; % contatore colonne
|
||||
while ii <= rTLH
|
||||
ini_col = col-12;
|
||||
nN = num2str(NTiltLinkH(ii,1));
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate = ''' ...
|
||||
datainiTLH ''' and EventTime >= ''' tempoiniTLH ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoTLHd = curs.Data;
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate > ''' ...
|
||||
datainiTLH ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoTLH = curs.Data;
|
||||
[~,c1] = size(DATnodoTLH);
|
||||
[~,c2] = size(DATnodoTLHd);
|
||||
if c1==c2
|
||||
DATnodoTLH = [DATnodoTLHd; DATnodoTLH];
|
||||
elseif c1 < c2 % solo giorno di riferimento
|
||||
DATnodoTLH = DATnodoTLHd;
|
||||
end
|
||||
DatiElabTiltLinkH(:,ini_col:col) = DATnodoTLH(:,:);
|
||||
col = col+13;
|
||||
ii = ii+1;
|
||||
end
|
||||
|
||||
text = 'LastElab_bisTLH function worked correctly for Tilt Link H';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
42
Tilt/LastElab_bisTLHR.m
Executable file
42
Tilt/LastElab_bisTLHR.m
Executable file
@@ -0,0 +1,42 @@
|
||||
function DatiElabTiltLinkHR = LastElab_bisTLHR(conn,NodoTiltLinkHR,rTLHR,...
|
||||
datainiTLHR,tempoiniTLHR,IDcentralina,DTcatena,FileName)
|
||||
|
||||
NTiltLinkHR = cell2mat(NodoTiltLinkHR(:,2));
|
||||
NodeType = 'Tilt Link HR';
|
||||
ii = 1; % contatore
|
||||
col = 16; % contatore colonne
|
||||
while ii <= rTLHR
|
||||
ini_col = col-15;
|
||||
nN = num2str(NTiltLinkHR(ii,1));
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, HShift, HShift_local, HShiftDir, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate = ''' ...
|
||||
datainiTLHR ''' and EventTime >= ''' tempoiniTLHR ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoTLHRd = curs.Data;
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, HShift, HShift_local, HShiftDir, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate > ''' ...
|
||||
datainiTLHR ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoTLHR = curs.Data;
|
||||
[~,c1] = size(DATnodoTLHR);
|
||||
[~,c2] = size(DATnodoTLHRd);
|
||||
if c1==c2
|
||||
DATnodoTLHR = [DATnodoTLHRd; DATnodoTLHR];
|
||||
elseif c1 < c2 % solo giorno di riferimento
|
||||
DATnodoTLHR = DATnodoTLHRd;
|
||||
end
|
||||
DatiElabTiltLinkHR(:,ini_col:col) = DATnodoTLHR(:,:);
|
||||
col = col+16;
|
||||
ii = ii+1;
|
||||
end
|
||||
|
||||
text = 'LastElab_bisTLHR function worked correctly for Tilt Link HR V';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
43
Tilt/LastElab_bisTLHRH.m
Executable file
43
Tilt/LastElab_bisTLHRH.m
Executable file
@@ -0,0 +1,43 @@
|
||||
function DatiElabTiltLinkHRH = LastElab_bisTLHRH(conn,NodoTiltLinkHRH,rTLHRH,...
|
||||
datainiTLHRH,tempoiniTLHRH,IDcentralina,DTcatena,FileName)
|
||||
|
||||
NTiltLinkHRH = cell2mat(NodoTiltLinkHRH(:,2));
|
||||
NodeType = 'Tilt Link HR H';
|
||||
ii = 1; % contatore
|
||||
col = 13; % contatore colonne
|
||||
while ii <= rTLHRH
|
||||
ini_col = col-12;
|
||||
nN = num2str(NTiltLinkHRH(ii,1));
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate = ''' ...
|
||||
datainiTLHRH ''' and EventTime >= ''' tempoiniTLHRH ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoTLHRHd = curs.Data;
|
||||
% Scarico di dati di spostamenti
|
||||
comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, T_node, speed, speed_local, acceleration, acceleration_local from ElabDataView where EventDate = ''' ...
|
||||
datainiTLHRH ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoTLHRH = curs.Data;
|
||||
DATnodoTLHRH = [DATnodoTLHRHd; DATnodoTLHRH];
|
||||
[~,c1] = size(DATnodoTLHRH);
|
||||
[~,c2] = size(DATnodoTLHRHd);
|
||||
if c1==c2
|
||||
DATnodoTLHRH = [DATnodoTLHRHd; DATnodoTLHRH];
|
||||
elseif c1 < c2 % solo giorno di riferimento
|
||||
DATnodoTLHRH = DATnodoTLHRHd;
|
||||
end
|
||||
DatiElabTiltLinkHRH(:,ini_col:col) = DATnodoTLHRH(:,:);
|
||||
col = col+13;
|
||||
ii = ii+1;
|
||||
end
|
||||
|
||||
text = 'LastElab_bisTLHRH function worked correctly for Tilt Link HR H';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
32
Tilt/MediaDati_BL.m
Executable file
32
Tilt/MediaDati_BL.m
Executable file
@@ -0,0 +1,32 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive per i piezometri
|
||||
% PIEZdef contiene le medie per l'intervallo definito dei valori di
|
||||
% pressione registrati dal piezometro
|
||||
% ARRAYdatePL contiene le date e il tempo per ogni dato (per media
|
||||
% giornaliera, la data di quel giorno)
|
||||
|
||||
function [BaroDef,BaroDefT,ARRAYdateBL] = MediaDati_BL(DatiBaro,DatiBaroT,...
|
||||
TimeBL,NdatiMediaP,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'MediaDati_BL function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Barometro
|
||||
[r,~]=size(DatiBaro);
|
||||
if NdatiMediaP > r
|
||||
NdatiMediaP = r;
|
||||
end
|
||||
BaroDef = smoothdata(DatiBaro,'gaussian',NdatiMediaP);
|
||||
|
||||
ARRAYdateBL = TimeBL;
|
||||
|
||||
%% Termometro
|
||||
BaroDefT = DatiBaroT;
|
||||
|
||||
text = 'Average mean of Baro Link data executed correctly. MediaDati_BL function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
125
Tilt/MediaDati_HD.m
Executable file
125
Tilt/MediaDati_HD.m
Executable file
@@ -0,0 +1,125 @@
|
||||
function [ACCdef_HD,ANGdef_HD,MAGdef_HD,ARRAYdateHD,ACCdefRisHD,MAGdefRisHD] = MediaDati_HD(...
|
||||
accHD,angHD,magHD,TimeHD,ris_acc_HD,ris_mag_HD,tolleranzaAcc,...
|
||||
tolleranzaMag,NdatiMedia,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'MediaDati_HD function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Accelerazione
|
||||
[r,~]=size(accHD);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
ACCdef_HD = smoothdata(accHD,'gaussian',NdatiMedia);
|
||||
|
||||
% Angoli
|
||||
ANGdef_HD = smoothdata(angHD,'gaussian',NdatiMedia);
|
||||
|
||||
%% Matrice date
|
||||
ARRAYdateHD = TimeHD;
|
||||
|
||||
%% Risultante acc
|
||||
ACCdefRisHD = ris_acc_HD; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
% Applico un controllo importante! Se la risultante varia più di 0.01, NON
|
||||
% faccio la media dei dati attorno, che altrimenti ne sono condizionati!
|
||||
[r,c] = size(ACCdefRisHD); % Nodi in colonna, date in riga
|
||||
Win = NdatiMedia/2; % Individuo la finestra da NON mediare
|
||||
cont = 0; % Contatore
|
||||
cont2 = 0;
|
||||
for i = 2:r % data
|
||||
for j = 2:c % nodo
|
||||
% se il valore assoluto della differenza è maggiore della
|
||||
% tolleranza, NON faccio la media
|
||||
if abs(ACCdefRisHD(i,j)-ACCdefRisHD(i-1,j)) > tolleranzaAcc || ACCdefRisHD(i,j) < 0.9 || ACCdefRisHD(i,j) > 1.1
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cax = 3*j-2;
|
||||
Cay = 3*j-1;
|
||||
Caz = 3*j;
|
||||
ACCdef_HD(Sp:Ep,Cax) = accHD(Sp:Ep,Cax); % ax
|
||||
ACCdef_HD(Sp:Ep,Cay) = accHD(Sp:Ep,Cay); % ay
|
||||
ACCdef_HD(Sp:Ep,Caz) = accHD(Sp:Ep,Caz); % az
|
||||
cont = cont+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = ['' num2str(cont) ' values of Tilt Link HD VR accelerometer vector of gravity not subjected to mean process due to values with excessive variations!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
text = ['' num2str(cont2) ' values of Tilt Link HD VR accelerometer vector of gravity not subjected to mean process due to not calibrated values!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Campi magnetici
|
||||
MAGdef_HD = smoothdata(magHD,'gaussian',NdatiMedia);
|
||||
|
||||
% Applico un controllo importante! Se la risultante delle accelerazioni
|
||||
% varia più di 0.01, NON faccio la media dei dati di campo magnetico attorno,
|
||||
% che altrimenti ne sono condizionati!
|
||||
[r,c] = size(ACCdefRisHD); % Nodi in colonna, date in riga
|
||||
Win = NdatiMedia/2; % Individuo la finestra da NON mediare
|
||||
cont = 0;
|
||||
cont2 = 0;
|
||||
for i = 2:r % data
|
||||
for j = 2:c % nodo
|
||||
% se il valore assoluto della differenza è maggiore della
|
||||
% tolleranza, NON faccio la media
|
||||
if abs(ACCdefRisHD(i,j)-ACCdefRisHD(i-1,j)) > tolleranzaMag
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cmx = 3*j-2;
|
||||
Cmy = 3*j-1;
|
||||
Cmz = 3*j;
|
||||
MAGdef_HD(Sp:Ep,Cmx) = magHD(Sp:Ep,Cmx); % mx
|
||||
MAGdef_HD(Sp:Ep,Cmy) = magHD(Sp:Ep,Cmy); % my
|
||||
MAGdef_HD(Sp:Ep,Cmz) = magHD(Sp:Ep,Cmz); % mz
|
||||
cont = cont+1;
|
||||
end
|
||||
if ACCdefRisHD(i,j) < 0.9 || ACCdefRisHD(i,j) > 1.1 % Il nodo è fuori taratura!
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cmx = 3*j-2;
|
||||
Cmy = 3*j-1;
|
||||
Cmz = 3*j;
|
||||
MAGdef_HD(Sp:Ep,Cmx) = magHD(Sp:Ep,Cmx); % mx
|
||||
MAGdef_HD(Sp:Ep,Cmy) = magHD(Sp:Ep,Cmy); % my
|
||||
MAGdef_HD(Sp:Ep,Cmz) = magHD(Sp:Ep,Cmz); % mz
|
||||
cont2 = cont2+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = ['' num2str(cont) ' values of Tilt Link HD VR magnetometer vector not subjected to mean process due to accelerometers values with excessive variations!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
text = ['' num2str(cont2) ' values of Tilt Link HD VR magnetometer vector of gravity not subjected to mean process due to not calibrated accelerometer values!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Risultante campi magnetici
|
||||
MAGdefRisHD = ris_mag_HD; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
text = 'Average mean of Tilt Link HD VR data executed correctly. MediaDati_HD function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
127
Tilt/MediaDati_HDVR.m
Executable file
127
Tilt/MediaDati_HDVR.m
Executable file
@@ -0,0 +1,127 @@
|
||||
function [ACCdef_HDVR,MAGdef_HDVR,ARRAYdateHDVR,ACCdefRisHDVR,MAGdefRisHDVR] = MediaDati_HDVR(...
|
||||
accHDVR,magHDVR,TimeHDVR,ris_acc_HDVR,ris_mag_HDVR,tolleranzaAcc,...
|
||||
tolleranzaMag,NdatiMedia,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'MediaDati_HDVR function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Accelerazione
|
||||
[r,~]=size(accHDVR);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
ACCdef_HDVR = smoothdata(accHDVR,'gaussian',NdatiMedia);
|
||||
|
||||
%% Matrice date
|
||||
ARRAYdateHDVR = TimeHDVR;
|
||||
|
||||
%% Risultante acc
|
||||
ACCdefRisHDVR = ris_acc_HDVR; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
% Applico un controllo importante! Se la risultante varia più di 0.01, NON
|
||||
% faccio la media dei dati attorno, che altrimenti ne sono condizionati!
|
||||
[r,c] = size(ACCdefRisHDVR); % Nodi in colonna, date in riga
|
||||
Win = NdatiMedia/2; % Individuo la finestra da NON mediare
|
||||
cont = 0; % Contatore
|
||||
cont2 = 0;
|
||||
for i = 2:r % data
|
||||
for j = 2:c % nodo
|
||||
% se il valore assoluto della differenza è maggiore della
|
||||
% tolleranza, NON faccio la media
|
||||
if abs(ACCdefRisHDVR(i,j)-ACCdefRisHDVR(i-1,j)) > tolleranzaAcc || ...
|
||||
ACCdefRisHDVR(i,j) < 0.9 || ACCdefRisHDVR(i,j) > 1.1
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cax = 3*j-2;
|
||||
Cay = 3*j-1;
|
||||
Caz = 3*j;
|
||||
ACCdef_HDVR(Sp:Ep,Cax) = accHDVR(Sp:Ep,Cax); % ax
|
||||
ACCdef_HDVR(Sp:Ep,Cay) = accHDVR(Sp:Ep,Cay); % ay
|
||||
ACCdef_HDVR(Sp:Ep,Caz) = accHDVR(Sp:Ep,Caz); % az
|
||||
cont = cont+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = ['' num2str(cont) ' values of Tilt Link HD VR accelerometer vector of '...
|
||||
'gravity not subjected to mean process due to values with excessive variations!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
text = ['' num2str(cont2) ' values of Tilt Link HD VR accelerometer vector of '...
|
||||
'gravity not subjected to mean process due to not calibrated values!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Campi magnetici
|
||||
MAGdef_HDVR = smoothdata(magHDVR,'gaussian',NdatiMedia);
|
||||
|
||||
% Applico un controllo importante! Se la risultante delle accelerazioni
|
||||
% varia più di 0.01, NON faccio la media dei dati di campo magnetico attorno,
|
||||
% che altrimenti ne sono condizionati!
|
||||
[r,c] = size(ACCdefRisHDVR); % Nodi in colonna, date in riga
|
||||
Win = NdatiMedia/2; % Individuo la finestra da NON mediare
|
||||
cont = 0;
|
||||
cont2 = 0;
|
||||
for i = 2:r % data
|
||||
for j = 2:c % nodo
|
||||
% se il valore assoluto della differenza è maggiore della
|
||||
% tolleranza, NON faccio la media
|
||||
if abs(ACCdefRisHDVR(i,j)-ACCdefRisHDVR(i-1,j)) > tolleranzaMag
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cmx = 3*j-2;
|
||||
Cmy = 3*j-1;
|
||||
Cmz = 3*j;
|
||||
MAGdef_HDVR(Sp:Ep,Cmx) = magHDVR(Sp:Ep,Cmx); % mx
|
||||
MAGdef_HDVR(Sp:Ep,Cmy) = magHDVR(Sp:Ep,Cmy); % my
|
||||
MAGdef_HDVR(Sp:Ep,Cmz) = magHDVR(Sp:Ep,Cmz); % mz
|
||||
cont = cont+1;
|
||||
end
|
||||
if ACCdefRisHDVR(i,j) < 0.9 || ACCdefRisHDVR(i,j) > 1.1 % Il nodo è fuori taratura!
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cmx = 3*j-2;
|
||||
Cmy = 3*j-1;
|
||||
Cmz = 3*j;
|
||||
MAGdef_HDVR(Sp:Ep,Cmx) = magHDVR(Sp:Ep,Cmx); % mx
|
||||
MAGdef_HDVR(Sp:Ep,Cmy) = magHDVR(Sp:Ep,Cmy); % my
|
||||
MAGdef_HDVR(Sp:Ep,Cmz) = magHDVR(Sp:Ep,Cmz); % mz
|
||||
cont2 = cont2+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = ['' num2str(cont) ' values of Tilt Link HD VR magnetometer vector not '...
|
||||
'subjected to mean process due to accelerometers values with excessive variations!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
text = ['' num2str(cont2) ' values of Tilt Link HD VR magnetometer vector of '...
|
||||
'gravity not subjected to mean process due to not calibrated accelerometer values!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Risultante campi magnetici
|
||||
MAGdefRisHDVR = ris_mag_HDVR; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
text = 'Average mean of Tilt Link HD VR data executed correctly. MediaDati_HD function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
137
Tilt/MediaDati_IPL.m
Executable file
137
Tilt/MediaDati_IPL.m
Executable file
@@ -0,0 +1,137 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive per i TiltLink
|
||||
% ACCdef contiene le medie per l'intervallo definito delle accelerazioni
|
||||
% ARRAYdate contiene le date e il tempo per ogni dato (per media
|
||||
% giornaliera, la data di quel giorno)
|
||||
|
||||
function [ACCdef_IPL,MAGdef_IPL,ARRAYdateIPL,ACCdefRis_IPL,MAGdefRis_IPL,TempDef_IPL]...
|
||||
= MediaDati_IPL(accIPL,magIPL,TimeIPL,ris_acc_IPL,ris_mag_IPL,tempIPL,tolleranzaAcc,...
|
||||
tolleranzaMag,NdatiMedia,NodoInPlaceLink,MEMS,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'MediaDati_IPL function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Accelerazione o angoli
|
||||
[r,~] = size(accIPL);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
ACCdef_IPL = smoothdata(accIPL,'gaussian',NdatiMedia);
|
||||
|
||||
%% Matrice date
|
||||
ARRAYdateIPL = TimeIPL;
|
||||
|
||||
%% Risultante acc
|
||||
ACCdefRis_IPL = ris_acc_IPL; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
if MEMS == 1 || MEMS == 2 || strcmp(NodoInPlaceLink(1,4),'g') == 1
|
||||
% Applico un controllo importante! Se la risultante varia più di 0.01, NON
|
||||
% faccio la media dei dati attorno, che altrimenti ne sono condizionati!
|
||||
[r,c] = size(ACCdefRis_IPL); % Nodi in colonna, date in riga
|
||||
Win = NdatiMedia/2; % Individuo la finestra da NON mediare
|
||||
cont = 0; % Contatore
|
||||
cont2 = 0;
|
||||
for i = 2:r % data
|
||||
for j = 2:c % nodo
|
||||
% se il valore assoluto della differenza è maggiore della
|
||||
% tolleranza, NON faccio la media
|
||||
if abs(ACCdefRis_IPL(i,j)-ACCdefRis_IPL(i-1,j)) > tolleranzaAcc || ACCdefRis_IPL(i,j) < 0.9 || ACCdefRis_IPL(i,j) > 1.1
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cax = 3*j-2;
|
||||
Cay = 3*j-1;
|
||||
Caz = 3*j;
|
||||
ACCdef_IPL(Sp:Ep,Cax) = accIPL(Sp:Ep,Cax); % ax
|
||||
ACCdef_IPL(Sp:Ep,Cay) = accIPL(Sp:Ep,Cay); % ay
|
||||
ACCdef_IPL(Sp:Ep,Caz) = accIPL(Sp:Ep,Caz); % az
|
||||
cont = cont+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = ['' num2str(cont) ' values of In Place Link accelerometer vector of '...
|
||||
'gravity not subjected to mean process due to values with excessive variations!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
text = ['' num2str(cont2) ' values of In Place Link accelerometer vector of gravity '...
|
||||
'not subjected to mean process due to not calibrated values!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Campi magnetici
|
||||
MAGdef_IPL = smoothdata(magIPL,'gaussian',NdatiMedia);
|
||||
|
||||
% Applico un controllo importante! Se la risultante delle accelerazioni
|
||||
% varia più di 0.01, NON faccio la media dei dati di campo magnetico attorno,
|
||||
% che altrimenti ne sono condizionati!
|
||||
[r,c] = size(ACCdefRis_IPL); % Nodi in colonna, date in riga
|
||||
Win = NdatiMedia/2; % Individuo la finestra da NON mediare
|
||||
cont = 0;
|
||||
cont2 = 0;
|
||||
for i = 2:r % data
|
||||
for j = 2:c % nodo
|
||||
% se il valore assoluto della differenza è maggiore della
|
||||
% tolleranza, NON faccio la media
|
||||
if abs(ACCdefRis_IPL(i,j)-ACCdefRis_IPL(i-1,j)) > tolleranzaMag
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cmx = 3*j-2;
|
||||
Cmy = 3*j-1;
|
||||
Cmz = 3*j;
|
||||
MAGdef_IPL(Sp:Ep,Cmx) = magIPL(Sp:Ep,Cmx); % mx
|
||||
MAGdef_IPL(Sp:Ep,Cmy) = magIPL(Sp:Ep,Cmy); % my
|
||||
MAGdef_IPL(Sp:Ep,Cmz) = magIPL(Sp:Ep,Cmz); % mz
|
||||
cont = cont+1;
|
||||
end
|
||||
if ACCdefRis_IPL(i,j) < 0.9 || ACCdefRis_IPL(i,j) > 1.1 % Il nodo è fuori taratura!
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cmx = 3*j-2;
|
||||
Cmy = 3*j-1;
|
||||
Cmz = 3*j;
|
||||
MAGdef_IPL(Sp:Ep,Cmx) = magIPL(Sp:Ep,Cmx); % mx
|
||||
MAGdef_IPL(Sp:Ep,Cmy) = magIPL(Sp:Ep,Cmy); % my
|
||||
MAGdef_IPL(Sp:Ep,Cmz) = magIPL(Sp:Ep,Cmz); % mz
|
||||
cont2 = cont2+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = ['' num2str(cont) ' values of In Place Link magnetometer vector not subjected to mean process due to accelerometers values with excessive variations!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
text = ['' num2str(cont2) ' values of In Place Link magnetometer vector of gravity not subjected to mean process due to not calibrated accelerometer values!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
else
|
||||
MAGdef_IPL = [];
|
||||
end
|
||||
|
||||
%% Risultante campi magnetici
|
||||
MAGdefRis_IPL = ris_mag_IPL; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
%% Temperatura
|
||||
TempDef_IPL = tempIPL; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
text = 'Average mean of In Place Link data executed correctly. MediaDati_IPL function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
32
Tilt/MediaDati_IPLHR.m
Executable file
32
Tilt/MediaDati_IPLHR.m
Executable file
@@ -0,0 +1,32 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive per i Tilt Link HR
|
||||
% ACCdefTLHR contiene le medie per l'intervallo definito delle accelerazioni
|
||||
% ARRAYdateTLHR contiene le date e il tempo per ogni dato (per media
|
||||
% giornaliera, la data di quel giorno)
|
||||
|
||||
function [ANGdef_IPLHR,ARRAYdateIPLHR,TempDef_IPLHR] = MediaDati_IPLHR(angIPLHR,...
|
||||
TimeIPLHR,tempIPLHR,NdatiMedia,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'MediaDati_IPLHR function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Angoli
|
||||
[r,~]=size(angIPLHR);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
ANGdef_IPLHR = smoothdata(angIPLHR,'gaussian',NdatiMedia);
|
||||
|
||||
%% Matrice date
|
||||
ARRAYdateIPLHR = TimeIPLHR;
|
||||
|
||||
%% Temperature
|
||||
TempDef_IPLHR = tempIPLHR; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
text = 'Average mean of In Place Link HR data executed correctly. MediaDati_IPLHR function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
27
Tilt/MediaDati_KL.m
Executable file
27
Tilt/MediaDati_KL.m
Executable file
@@ -0,0 +1,27 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive
|
||||
|
||||
function [ANGdefKL,TdefKL,ARRAYdateKL] = MediaDati_KL(ang_KL,temp_KL,TimeKL,NdatiMedia,FileName)
|
||||
|
||||
text = 'MediaDati_KL function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Angoli
|
||||
[r,~]=size(ang_KL);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
ANGdefKL = smoothdata(ang_KL,'gaussian',NdatiMedia);
|
||||
|
||||
ARRAYdateKL = TimeKL;
|
||||
|
||||
%% Temperature
|
||||
TdefKL = temp_KL; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
text = 'Mean values of Klino Link data calculated correctly. MediaDati_KL function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
28
Tilt/MediaDati_KLHR.m
Executable file
28
Tilt/MediaDati_KLHR.m
Executable file
@@ -0,0 +1,28 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive
|
||||
|
||||
function [ANGdefKLHR,TdefKLHR,ARRAYdateKLHR] = MediaDati_KLHR(ang_KLHR,...
|
||||
temp_KLHR,TimeKLHR,NdatiMedia,FileName)
|
||||
|
||||
text = 'MediaDati_KLHR function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Angoli
|
||||
[r,~]=size(ang_KLHR);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
ANGdefKLHR = smoothdata(ang_KLHR,'gaussian',NdatiMedia);
|
||||
|
||||
ARRAYdateKLHR = TimeKLHR;
|
||||
|
||||
%% Temperature
|
||||
TdefKLHR = temp_KLHR; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
text = 'Mean values of Klino Link HR data calculated correctly. MediaDati_KLHR function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
27
Tilt/MediaDati_LL.m
Executable file
27
Tilt/MediaDati_LL.m
Executable file
@@ -0,0 +1,27 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive per la cella di carico
|
||||
% LOADdef contiene le medie per l'intervallo definito dei valori di forza
|
||||
% ARRAYdateLL contiene le date e il tempo per ogni dato (per media
|
||||
% giornaliera, la data di quel giorno)
|
||||
|
||||
function [LoadDef,ARRAYdateLL] = MediaDati_LL(DatiLoad,TimeLL,NdatiMedia,FileName)
|
||||
|
||||
text = 'MediaDati_LL function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Cella di carico
|
||||
[r,~]=size(DatiLoad);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
LoadDef = smoothdata(DatiLoad,'gaussian',NdatiMedia);
|
||||
|
||||
ARRAYdateLL = TimeLL;
|
||||
|
||||
text = 'Average mean of Load Link data executed correctly. MediaDati_LL function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
24
Tilt/MediaDati_PE.m
Executable file
24
Tilt/MediaDati_PE.m
Executable file
@@ -0,0 +1,24 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive
|
||||
|
||||
function [Dati_PE,ARRAYdatePE] = MediaDati_PE(Def_PE,TimePE,NdatiMedia,FileName)
|
||||
|
||||
text = 'MediaDati_PE function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Deformazione
|
||||
[r,~]=size(Def_PE);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
Dati_PE = smoothdata(Def_PE,'gaussian',NdatiMedia);
|
||||
|
||||
ARRAYdatePE = TimePE;
|
||||
|
||||
text = 'MediaDati_PE function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
31
Tilt/MediaDati_PL.m
Executable file
31
Tilt/MediaDati_PL.m
Executable file
@@ -0,0 +1,31 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive per i piezometri
|
||||
% PIEZdef contiene le medie per l'intervallo definito dei valori di
|
||||
% pressione registrati dal piezometro
|
||||
% ARRAYdatePL contiene le date e il tempo per ogni dato (per media
|
||||
% giornaliera, la data di quel giorno)
|
||||
|
||||
function [PiezDef,PiezDefT,ARRAYdatePL] = MediaDati_PL(DatiPiez,DatiPiezT,TimePL,NdatiMediaP,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'MediaDati_PL function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Piezometro
|
||||
[r,~]=size(DatiPiez);
|
||||
|
||||
ARRAYdatePL = TimePL;
|
||||
if NdatiMediaP > r
|
||||
NdatiMediaP = r;
|
||||
end
|
||||
PiezDef = smoothdata(DatiPiez,'gaussian',NdatiMediaP);
|
||||
|
||||
%% Termometro
|
||||
PiezDefT = DatiPiezT;
|
||||
|
||||
text = 'Average mean of Piezo Link data executed correctly. MediaDati_PL function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
19
Tilt/MediaDati_PT100.m
Executable file
19
Tilt/MediaDati_PT100.m
Executable file
@@ -0,0 +1,19 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive
|
||||
|
||||
function [Dati_PT100,ARRAYdatePT100] = MediaDati_PT100(val_PT100,TimePT100,FileName)
|
||||
|
||||
%% Temperatura
|
||||
Time = TimePT100;
|
||||
|
||||
Dati_PT100 = val_PT100;
|
||||
|
||||
ARRAYdatePT100 = Time;
|
||||
|
||||
text = 'Mean values of PT100 Link data NOT calculated. MediaDati_PT100 function closed';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
17
Tilt/MediaDati_RL.m
Executable file
17
Tilt/MediaDati_RL.m
Executable file
@@ -0,0 +1,17 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive
|
||||
|
||||
function [Dati_RL,ARRAYdateRL] = MediaDati_RL(val_RL,TimeRL,FileName)
|
||||
|
||||
%% Pioggia
|
||||
|
||||
ARRAYdateRL = TimeRL;
|
||||
Dati_RL = val_RL;
|
||||
|
||||
text = 'Mean values of Rain Link NOT calculated. MediaDati_RL closed';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
131
Tilt/MediaDati_TL.m
Executable file
131
Tilt/MediaDati_TL.m
Executable file
@@ -0,0 +1,131 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive per i TiltLink
|
||||
% ACCdef contiene le medie per l'intervallo definito delle accelerazioni
|
||||
% ARRAYdate contiene le date e il tempo per ogni dato (per media
|
||||
% giornaliera, la data di quel giorno)
|
||||
|
||||
function [ACCdef,MAGdef,ARRAYdateTL,ACCdefRis,MAGdefRis_TL,TempDef_TL] = MediaDati_TL(...
|
||||
accTL,magTL,TimeTL,ris_acc,ris_mag,tempTL,tolleranzaAcc,...
|
||||
tolleranzaMag,NdatiMedia,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'MediaDati_TL function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Accelerazione
|
||||
[r,~]=size(accTL);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
ACCdef = smoothdata(accTL,'gaussian',NdatiMedia);
|
||||
|
||||
%% Matrice date
|
||||
ARRAYdateTL = TimeTL;
|
||||
|
||||
%% Risultante acc
|
||||
ACCdefRis = ris_acc; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
% Applico un controllo importante! Se la risultante varia più di 0.01, NON
|
||||
% faccio la media dei dati attorno, che altrimenti ne sono condizionati!
|
||||
[r,c] = size(ACCdefRis); % Nodi in colonna, date in riga
|
||||
Win = NdatiMedia/2; % Individuo la finestra da NON mediare
|
||||
cont = 0; % Contatore
|
||||
cont2 = 0;
|
||||
for i = 2:r % data
|
||||
for j = 2:c % nodo
|
||||
% se il valore assoluto della differenza è maggiore della
|
||||
% tolleranza, NON faccio la media
|
||||
if abs(ACCdefRis(i,j)-ACCdefRis(i-1,j)) > tolleranzaAcc || ACCdefRis(i,j) < 0.9 || ACCdefRis(i,j) > 1.1
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cax = 3*j-2;
|
||||
Cay = 3*j-1;
|
||||
Caz = 3*j;
|
||||
ACCdef(Sp:Ep,Cax) = accTL(Sp:Ep,Cax); % ax
|
||||
ACCdef(Sp:Ep,Cay) = accTL(Sp:Ep,Cay); % ay
|
||||
ACCdef(Sp:Ep,Caz) = accTL(Sp:Ep,Caz); % az
|
||||
cont = cont+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = ['' num2str(cont) ' values of Tilt Link V accelerometer vector of gravity not subjected to mean process due to values with excessive variations!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
text = ['' num2str(cont2) ' values of Tilt Link V accelerometer vector of gravity not subjected to mean process due to not calibrated values!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Campi magnetici
|
||||
MAGdef = smoothdata(magTL,'gaussian',NdatiMedia);
|
||||
|
||||
% Applico un controllo importante! Se la risultante delle accelerazioni
|
||||
% varia più di 0.01, NON faccio la media dei dati di campo magnetico attorno,
|
||||
% che altrimenti ne sono condizionati!
|
||||
[r,c] = size(ACCdefRis); % Nodi in colonna, date in riga
|
||||
Win = NdatiMedia/2; % Individuo la finestra da NON mediare
|
||||
cont = 0;
|
||||
cont2 = 0;
|
||||
for i = 2:r % data
|
||||
for j = 2:c % nodo
|
||||
% se il valore assoluto della differenza è maggiore della
|
||||
% tolleranza, NON faccio la media
|
||||
if abs(ACCdefRis(i,j)-ACCdefRis(i-1,j)) > tolleranzaMag
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cmx = 3*j-2;
|
||||
Cmy = 3*j-1;
|
||||
Cmz = 3*j;
|
||||
MAGdef(Sp:Ep,Cmx) = magTL(Sp:Ep,Cmx); % mx
|
||||
MAGdef(Sp:Ep,Cmy) = magTL(Sp:Ep,Cmy); % my
|
||||
MAGdef(Sp:Ep,Cmz) = magTL(Sp:Ep,Cmz); % mz
|
||||
cont = cont+1;
|
||||
end
|
||||
if ACCdefRis(i,j) < 0.9 || ACCdefRis(i,j) > 1.1 % Il nodo è fuori taratura!
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cmx = 3*j-2;
|
||||
Cmy = 3*j-1;
|
||||
Cmz = 3*j;
|
||||
MAGdef(Sp:Ep,Cmx) = magTL(Sp:Ep,Cmx); % mx
|
||||
MAGdef(Sp:Ep,Cmy) = magTL(Sp:Ep,Cmy); % my
|
||||
MAGdef(Sp:Ep,Cmz) = magTL(Sp:Ep,Cmz); % mz
|
||||
cont2 = cont2+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = ['' num2str(cont) ' values of Tilt Link V magnetometer vector not subjected to mean process due to accelerometers values with excessive variations!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
text = ['' num2str(cont2) ' values of Tilt Link V magnetometer vector of gravity not subjected to mean process due to not calibrated accelerometer values!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Risultante campi magnetici
|
||||
MAGdefRis_TL = ris_mag; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
%% Temperatura
|
||||
TempDef_TL = tempTL; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
text = 'Average mean of Tilt Link V data executed correctly. MediaDati_TL function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
88
Tilt/MediaDati_TLH.m
Executable file
88
Tilt/MediaDati_TLH.m
Executable file
@@ -0,0 +1,88 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive per i TiltLink
|
||||
% ACCdef contiene le medie per l'intervallo definito delle accelerazioni
|
||||
% ARRAYdate contiene le date e il tempo per ogni dato (per media
|
||||
% giornaliera, la data di quel giorno)
|
||||
|
||||
function [ACCdef_TLH,ARRAYdateTLH,ACCdefRis_TLH,TempDef_TLH] = MediaDati_TLH...
|
||||
(accTLH,TimeTLH,ris_acc_TLH,tempTLH,tolleranzaAcc,NdatiMedia,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'MediaDati_TLH function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Accelerazione
|
||||
[r,~]=size(accTLH);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
ACCdef_TLH = smoothdata(accTLH,'gaussian',NdatiMedia);
|
||||
|
||||
%% Matrice date
|
||||
ARRAYdateTLH = TimeTLH;
|
||||
|
||||
%% Risultante acc
|
||||
ACCdefRis_TLH = ris_acc_TLH; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
% Applico un controllo importante! Se la risultante varia più di 0.01, NON
|
||||
% faccio la media dei dati attorno, che altrimenti ne sono condizionati!
|
||||
[r,c] = size(ACCdefRis_TLH); % Nodi in colonna, date in riga
|
||||
Win = NdatiMedia/2; % Individuo la finestra da NON mediare
|
||||
cont = 0; % Contatore
|
||||
cont2 = 0;
|
||||
for i = 2:r % data
|
||||
for j = 2:c % nodo
|
||||
% se il valore assoluto della differenza è maggiore della
|
||||
% tolleranza, NON faccio la media
|
||||
if abs(ACCdefRis_TLH(i,j)-ACCdefRis_TLH(i-1,j)) > tolleranzaAcc
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cax = 3*j-2;
|
||||
Cay = 3*j-1;
|
||||
Caz = 3*j;
|
||||
ACCdef_TLH(Sp:Ep,Cax) = accTLH(Sp:Ep,Cax); % ax
|
||||
ACCdef_TLH(Sp:Ep,Cay) = accTLH(Sp:Ep,Cay); % ay
|
||||
ACCdef_TLH(Sp:Ep,Caz) = accTLH(Sp:Ep,Caz); % az
|
||||
cont = cont+1;
|
||||
end
|
||||
if ACCdefRis_TLH(i,j) < 0.9 || ACCdefRis_TLH(i,j) > 1.1 % Il nodo è fuori taratura!
|
||||
Sp = i-Win; % Punto di partenza (date)
|
||||
if Sp <= 0
|
||||
Sp = 1;
|
||||
end
|
||||
if i+Win > r
|
||||
Ep = r;
|
||||
else
|
||||
Ep = i+Win; % Punto di arrivo (date)
|
||||
end
|
||||
Cax = 3*j-2;
|
||||
Cay = 3*j-1;
|
||||
Caz = 3*j;
|
||||
ACCdef_TLH(Sp:Ep,Cax) = accTLH(Sp:Ep,Cax); % ax
|
||||
ACCdef_TLH(Sp:Ep,Cay) = accTLH(Sp:Ep,Cay); % ay
|
||||
ACCdef_TLH(Sp:Ep,Caz) = accTLH(Sp:Ep,Caz); % az
|
||||
cont2 = cont2+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
text = [' ' num2str(cont) ' values of Tilt Link H accelerometer vector of gravity not subjected to mean process due to values with excessive variations!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
text = [' ' num2str(cont2) ' values of Tilt Link H accelerometer vector of gravity not subjected to mean process due to not calibrated values!'];
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Temperatura
|
||||
TempDef_TLH = tempTLH; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
text = 'Average mean of Tilt Link H data executed correctly. MediaDati_TLH function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
34
Tilt/MediaDati_TLHR.m
Executable file
34
Tilt/MediaDati_TLHR.m
Executable file
@@ -0,0 +1,34 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive per i Tilt Link HR
|
||||
% ACCdefTLHR contiene le medie per l'intervallo definito delle accelerazioni
|
||||
% ARRAYdateTLHR contiene le date e il tempo per ogni dato (per media
|
||||
% giornaliera, la data di quel giorno)
|
||||
|
||||
function [ANGdef_TLHR,ARRAYdateTLHR,TempDef_TLHR] = MediaDati_TLHR(angTLHR,...
|
||||
TimeTLHR,tempTLHR,NdatiMedia,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'MediaDati_TLHR function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Angoli
|
||||
[r,~]=size(angTLHR);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
ANGdef_TLHR = smoothdata(angTLHR,'gaussian',NdatiMedia);
|
||||
|
||||
%% Matrice date
|
||||
ARRAYdateTLHR = TimeTLHR;
|
||||
|
||||
%% Temperature
|
||||
TempDef_TLHR = tempTLHR; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
text = 'Average mean of Tilt Link HR V data executed correctly. MediaDati_TLHR function ended';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
32
Tilt/MediaDati_TLHRH.m
Executable file
32
Tilt/MediaDati_TLHRH.m
Executable file
@@ -0,0 +1,32 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive per i Tilt Link HR
|
||||
% ACCdefTLHR contiene le medie per l'intervallo definito delle accelerazioni
|
||||
% ARRAYdateTLHR contiene le date e il tempo per ogni dato (per media
|
||||
% giornaliera, la data di quel giorno)
|
||||
|
||||
function [ANGdef_TLHRH,ARRAYdateTLHRH,TempDef_TLHRH] = MediaDati_TLHRH(angTLHRH,...
|
||||
TimeTLHRH,tempTLHRH,NdatiMedia,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'MediaDati_TLHRH function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Angoli
|
||||
[r,~]=size(angTLHRH);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
ANGdef_TLHRH = smoothdata(angTLHRH,'gaussian',NdatiMedia);
|
||||
|
||||
%% Matrice date
|
||||
ARRAYdateTLHRH = TimeTLHRH;
|
||||
|
||||
%% Temperature
|
||||
TempDef_TLHRH = tempTLHRH; % Non faccio la media, mi serve il dato come è per applicare i filtri
|
||||
|
||||
text = 'Average mean of Tilt Link HR H data executed correctly. MediaDati_TLHRH function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
24
Tilt/MediaDati_ThL.m
Executable file
24
Tilt/MediaDati_ThL.m
Executable file
@@ -0,0 +1,24 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive
|
||||
|
||||
function [Dati_ThL,ARRAYdateThL] = MediaDati_ThL(val_ThL,TimeThL,NdatiMedia,FileName)
|
||||
|
||||
text = 'MediaDati_ThL function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Dati Temperatura
|
||||
[r,~]=size(val_ThL);
|
||||
if NdatiMedia > r
|
||||
NdatiMedia = r;
|
||||
end
|
||||
Dati_ThL = smoothdata(val_ThL,'gaussian',NdatiMedia);
|
||||
|
||||
ARRAYdateThL = TimeThL;
|
||||
|
||||
text = 'MediaDati_ThL function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
19
Tilt/MediaDati_WL.m
Executable file
19
Tilt/MediaDati_WL.m
Executable file
@@ -0,0 +1,19 @@
|
||||
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
|
||||
% necessarie per le elaborazioni successive
|
||||
|
||||
function [Dati_WL,ARRAYdateWL] = MediaDati_WL(lev_WL,TimeWL,FileName)
|
||||
|
||||
%% Temperatura
|
||||
Time = TimeWL;
|
||||
|
||||
Dati_WL = lev_WL;
|
||||
|
||||
ARRAYdateWL = Time;
|
||||
|
||||
text = 'Mean values of Weir Link data NOT calculated. MediaDati_WL function closed';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
240
Tilt/NuovaConversione.m
Executable file
240
Tilt/NuovaConversione.m
Executable file
@@ -0,0 +1,240 @@
|
||||
function [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)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'NuovaConversione function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
% Conversione del formato dati che usiamo con il database Ase_New
|
||||
|
||||
%% Tilt Link
|
||||
[r,c] = size(DCalTLTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalTLTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalTLTot = MATconv;
|
||||
end
|
||||
|
||||
%% Tilt Link H
|
||||
[r,c] = size(DCalTLHTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalTLHTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalTLHTot = MATconv;
|
||||
end
|
||||
|
||||
%% Piezo Link
|
||||
[r,c] = size(DCalPLTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalPLTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalPLTot = MATconv;
|
||||
end
|
||||
|
||||
%% Baro Link
|
||||
[r,c] = size(DCalBLTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalBLTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalBLTot = MATconv;
|
||||
end
|
||||
|
||||
%% Tilt Link HR
|
||||
[r,c] = size(DCalTLHRTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalTLHRTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalTLHRTot = MATconv;
|
||||
end
|
||||
|
||||
%% Tilt Link HR H
|
||||
[r,c] = size(DCalTLHRHTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalTLHRHTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalTLHRHTot = MATconv;
|
||||
end
|
||||
|
||||
%% Analog Link
|
||||
[r,c] = size(DCalALTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalALTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalALTot = MATconv;
|
||||
end
|
||||
|
||||
%% Load Link
|
||||
[r,c] = size(DCalLLTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalLLTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalLLTot = MATconv;
|
||||
end
|
||||
|
||||
%% Therm Link
|
||||
[r,c] = size(DCalThLTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalThLTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalThLTot = MATconv;
|
||||
end
|
||||
|
||||
%% Klino Link
|
||||
[r,c] = size(DCalKLTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalKLTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalKLTot = MATconv;
|
||||
end
|
||||
|
||||
%% Klino Link HR
|
||||
[r,c] = size(DCalKLHRTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalKLHRTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalKLHRTot = MATconv;
|
||||
end
|
||||
|
||||
%% Rain Link
|
||||
[r,c] = size(DCalRLTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalRLTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalRLTot = MATconv;
|
||||
end
|
||||
|
||||
%% PT100 Link
|
||||
[r,c] = size(DCalPT100Tot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalPT100Tot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalPT100Tot = MATconv;
|
||||
end
|
||||
|
||||
%% In Place Link
|
||||
[r,c] = size(DCalIPLTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalIPLTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalIPLTot = MATconv;
|
||||
end
|
||||
|
||||
%% In Place Link HR
|
||||
[r,c] = size(DCalIPLHRTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalIPLHRTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalIPLHRTot = MATconv;
|
||||
end
|
||||
|
||||
%% Weir Link
|
||||
[r,c] = size(DCalWLTot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalWLTot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalWLTot = MATconv;
|
||||
end
|
||||
|
||||
%% Pendulum
|
||||
[r,c] = size(DCalPETot);
|
||||
MATconv = zeros(r,c);
|
||||
if r == 0 % Non ci sono dati
|
||||
else
|
||||
for ii = 1:r
|
||||
for jj = 1:c
|
||||
MATconv(ii,jj) = DCalPETot{ii,jj};
|
||||
end
|
||||
end
|
||||
DCalPETot = MATconv;
|
||||
end
|
||||
|
||||
text = 'NuovaConversione function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
134
Tilt/PT100.m
Executable file
134
Tilt/PT100.m
Executable file
@@ -0,0 +1,134 @@
|
||||
function [Dati_PT100,ARRAYdatePT100,ErrPT100Link] = PT100(Dati_PT100,...
|
||||
ARRAYdatePT100,NuovoZeroPT100,ErrPT100Link,NdatiMedia,margine,Tmax,Tmin,...
|
||||
datainiPT100,IDcentralina,DTcatena,FileName)
|
||||
|
||||
text = 'PT100 function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
if NuovoZeroPT100 == 1
|
||||
ini = round(NdatiMedia/2);
|
||||
if rem(NdatiMedia,2) == 0
|
||||
ini = ini+1;
|
||||
end
|
||||
ini = ini + margine;
|
||||
if ini < 6
|
||||
ini = 6;
|
||||
end
|
||||
ErrPT100Link = ErrPT100Link(ini:end,:)';
|
||||
Dati_PT100 = Dati_PT100(ini:end,:);
|
||||
ARRAYdatePT100 = ARRAYdatePT100(ini:end,1);
|
||||
else
|
||||
ErrPT100Link = ErrPT100Link';
|
||||
end
|
||||
|
||||
[r,c] = size(Dati_PT100);
|
||||
FileTemperature = ['' IDcentralina '-' DTcatena '-PT100-Therm.csv'];
|
||||
if isfile(FileTemperature) == 1
|
||||
DatiRaw = csvread(FileTemperature);
|
||||
[rDR,cDR] = size(DatiRaw);
|
||||
DatiRaw(:,1) = DatiRaw(:,1) + 730000;
|
||||
else
|
||||
rDR = 1;
|
||||
cDR = 1;
|
||||
end
|
||||
cont2 = 1;
|
||||
for a = 1:r % Data
|
||||
for b = 1:c % Nodo
|
||||
% NON considero i dati al di sopra dei 80 °C o al di sotto dei -30 °C!
|
||||
if Dati_PT100(a,b) > Tmax || Dati_PT100(a,b) < Tmin
|
||||
cont2 = cont2+1;
|
||||
if a == 1
|
||||
if isfile(FileTemperature) == 1
|
||||
RawDate = find(DatiRaw(:,1)<=datenum(datainiPT100));
|
||||
if isempty(RawDate) == 1
|
||||
cc = 2;
|
||||
while cc <= c
|
||||
if Dati_PT100(cc,b) > Tmax || Dati_PT100(cc,b) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
Dati_PT100(a,b) = Dati_PT100(cc,b);
|
||||
else
|
||||
if isnan(DatiRaw(RawDate(end),b+1)) == 0
|
||||
Dati_PT100(a,b) = DatiRaw(RawDate(end),b+1);
|
||||
ErrPT100Link(b,a) = 1;
|
||||
wardat = 'Temperature data of PT100 Link nodes corrected using Raw Data of reference Csv file.';
|
||||
fprintf(fileID,fmt,wardat);
|
||||
else
|
||||
cc = 2;
|
||||
while cc <= c
|
||||
if Dati_PT100(cc,b) > Tmax || Dati_PT100(cc,b) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
Dati_PT100(a,b) = Dati_PT100(cc,b);
|
||||
end
|
||||
end
|
||||
else
|
||||
cc = 2;
|
||||
while cc <= c
|
||||
if Dati_PT100(cc,b) > Tmax || Dati_PT100(cc,b) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
Dati_PT100(a,b) = Dati_PT100(cc,b);
|
||||
end
|
||||
else
|
||||
Dati_PT100(a,b) = Dati_PT100(a-1,b);
|
||||
ErrPT100Link(b,a) = 1;
|
||||
end
|
||||
textT = ['' num2str(cont2) ' correction executed for PT100 Link - Temperature filter!'];
|
||||
fprintf(fileID,fmt,textT);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if rDR~=1 && cDR~=1 && isempty(DatiRaw) == 0
|
||||
RawDate1 = find(DatiRaw(:,1)<=ARRAYdatePT100(1));
|
||||
if isempty(RawDate1) == 1
|
||||
RawDate2 = 1;
|
||||
elseif RawDate1(end) == rDR
|
||||
RawDate2 = find(ARRAYdatePT100(:,1)>DatiRaw(end,1));
|
||||
else
|
||||
RawDate2 = find(ARRAYdatePT100(:,1)>DatiRaw(RawDate1(end)+1,1));
|
||||
end
|
||||
else
|
||||
RawDate1 = [];
|
||||
RawDate2 = 1;
|
||||
end
|
||||
if isempty(RawDate1) == 0 && isempty(RawDate2) == 0
|
||||
Dati = [DatiRaw(1:RawDate1(end),:); ARRAYdatePT100(RawDate2(1):end) Dati_PT100(RawDate2(1):end,:)];
|
||||
elseif isempty(RawDate1) == 1 && isempty(RawDate2) == 0
|
||||
Dati = [ARRAYdatePT100 Dati_PT100];
|
||||
else
|
||||
Dati = DatiRaw;
|
||||
end
|
||||
% Elimino appoggio più vecchio di un mese
|
||||
RawDate3 = find(Dati(:,1)<now-30);
|
||||
if isempty(RawDate3) == 0
|
||||
[rDati,~] = size(Dati);
|
||||
if RawDate3(end) == rDati
|
||||
else
|
||||
Dati = Dati(RawDate3(end)+1:end,:);
|
||||
end
|
||||
end
|
||||
if isfile(FileTemperature) == 1
|
||||
delete(FileTemperature);
|
||||
end
|
||||
Dati(:,1) = Dati(:,1) - 730000;
|
||||
csvwrite(FileTemperature,Dati);
|
||||
|
||||
|
||||
text = 'PT100 Link elaborated correctly. PT100 function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
169
Tilt/Parametri_Installazione.m
Executable file
169
Tilt/Parametri_Installazione.m
Executable file
@@ -0,0 +1,169 @@
|
||||
%% Funzione che definisce i parametri specifici di elaborazione
|
||||
|
||||
function [MEMS,biax,triax,struct,tolleranzaAcc,tolleranzaMag,segnoNS,...
|
||||
segnoEO,Ndevst,Wdevst,segnoNS_HR,segnoEO_HR,Ndevst_HR,Wdevst_HR,allineato,...
|
||||
NdatiMedia,NdatiMediaP,Ndatidespike,Anchor_real,Tmax,Tmin,Corr_Azimuth,Traversine,...
|
||||
base,altezza,larghezza] = ...
|
||||
Parametri_Installazione(unitID,idTool,DTcatena,yesTL,yesTLHR,yesTLH,yesTLHRH,yesPL,...
|
||||
yesThL,yesKL,yesKLHR,yesPT100,yesIPL,yesIPLHR,yesWL,yesHD,yesHDVR,conn,FileName)
|
||||
|
||||
text = 'Parametri_Installazione function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
comando = ['select avg, despike from software where tool_id like ''' idTool ''' '];
|
||||
Dati = fetch(conn,comando);
|
||||
|
||||
NdatiMedia = cell2mat(Dati(1));
|
||||
Ndatidespike = cell2mat(Dati(2));
|
||||
|
||||
%% MEMS
|
||||
if yesTL == 1 || yesTLH == 1 || yesKL == 1 || yesIPL == 1 || yesHD == 1 || yesHDVR == 1
|
||||
comando = ['select mems, toll_Acc, num_Ds, win_Ds from software where tool_id like ''' idTool ''' '];
|
||||
Dati = fetch(conn,comando);
|
||||
MEMS = cell2mat(Dati(1));
|
||||
tolleranzaAcc = cell2mat(Dati(2));
|
||||
Ndevst = cell2mat(Dati(3));
|
||||
Wdevst = cell2mat(Dati(4));
|
||||
if yesTL == 1 || yesIPL == 1
|
||||
comando = ['select elab, toll_Mag, ns_Sign, eo_Sign from software where tool_id like ''' idTool ''' '];
|
||||
Dati = fetch(conn,comando);
|
||||
elab = cell2mat(Dati(1));
|
||||
if elab == 1
|
||||
triax = 1;
|
||||
biax = 0;
|
||||
struct = 0;
|
||||
elseif elab == 2
|
||||
triax = 0;
|
||||
biax = 1;
|
||||
struct = 0;
|
||||
elseif elab == 3
|
||||
triax = 0;
|
||||
biax = 0;
|
||||
struct = 1;
|
||||
end
|
||||
tolleranzaMag = cell2mat(Dati(2));
|
||||
segnoNS = cell2mat(Dati(3));
|
||||
segnoEO = cell2mat(Dati(4));
|
||||
elseif yesHD == 1 || yesHDVR == 1
|
||||
comando = ['select toll_Mag from software where tool_id like ''' idTool ''' '];
|
||||
Dati = fetch(conn,comando);
|
||||
tolleranzaMag = cell2mat(Dati(1));
|
||||
segnoNS = [];
|
||||
segnoEO = [];
|
||||
triax = [];
|
||||
biax = [];
|
||||
struct = [];
|
||||
else
|
||||
segnoNS = [];
|
||||
segnoEO = [];
|
||||
triax = [];
|
||||
biax = [];
|
||||
struct = [];
|
||||
tolleranzaMag = [];
|
||||
end
|
||||
else
|
||||
MEMS = [];
|
||||
tolleranzaAcc = [];
|
||||
tolleranzaMag = [];
|
||||
Ndevst = [];
|
||||
Wdevst = [];
|
||||
triax = [];
|
||||
biax = [];
|
||||
struct = [];
|
||||
segnoNS = [];
|
||||
segnoEO = [];
|
||||
end
|
||||
|
||||
%% Elettrolitici
|
||||
if yesTLHR == 1 || yesTLHRH == 1 || yesIPLHR == 1
|
||||
comando = ['select num_Ds_HR, win_Ds_HR, align from software where tool_id like ''' idTool ''' '];
|
||||
Dati = fetch(conn,comando);
|
||||
Ndevst_HR = cell2mat(Dati(1));
|
||||
Wdevst_HR = cell2mat(Dati(2));
|
||||
allineato = cell2mat(Dati(3));
|
||||
if yesTLHR == 1 || yesTLHRH == 1
|
||||
comando = ['select ns_Sign_HR, eo_Sign_HR, align from software where tool_id like ''' idTool ''' '];
|
||||
Dati = fetch(conn,comando);
|
||||
segnoNS_HR = cell2mat(Dati(1));
|
||||
segnoEO_HR = cell2mat(Dati(2));
|
||||
allineato = cell2mat(Dati(3));
|
||||
else
|
||||
segnoNS_HR = [];
|
||||
segnoEO_HR = [];
|
||||
end
|
||||
else
|
||||
segnoNS_HR = [];
|
||||
segnoEO_HR = [];
|
||||
Ndevst_HR = [];
|
||||
Wdevst_HR = [];
|
||||
allineato = [];
|
||||
end
|
||||
|
||||
%% Termometri
|
||||
if yesTL == 1 || yesTLH == 1 || yesKL == 1 || yesIPL == 1 || yesTLHR == 1 || ...
|
||||
yesTLHRH == 1 || yesIPLHR == 1 || yesKLHR == 1 || yesThL == 1 || yesPT100 == 1 || ...
|
||||
yesWL == 1 || yesHD == 1 || yesHDVR == 1
|
||||
comando = ['select max_temp, min_temp from software where tool_id like ''' idTool ''' '];
|
||||
Dati = fetch(conn,comando);
|
||||
Tmax = cell2mat(Dati(1));
|
||||
Tmin = cell2mat(Dati(2));
|
||||
else
|
||||
Tmax = [];
|
||||
Tmin = [];
|
||||
end
|
||||
|
||||
if yesIPL == 1 || yesIPLHR == 1 || yesHD == 1 || yesHDVR == 1
|
||||
comando = ['select azimut_guida_a from software where tool_id like ''' idTool ''' '];
|
||||
Dati = fetch(conn,comando);
|
||||
Corr_Azimuth = cell2mat(Dati(1));
|
||||
else
|
||||
Corr_Azimuth = [];
|
||||
end
|
||||
|
||||
%% Piezo Link
|
||||
if yesPL == 1
|
||||
comando = ['select avg_piezo from software where tool_id like ''' idTool ''' '];
|
||||
Dati = fetch(conn,comando);
|
||||
NdatiMediaP = cell2mat(Dati(1));
|
||||
else
|
||||
NdatiMediaP = [];
|
||||
end
|
||||
|
||||
%% Weir Link
|
||||
if yesWL == 1
|
||||
comando = ['select base, altezza, larghezza from software where tool_id like ''' idTool ''' '];
|
||||
Dati = fetch(conn,comando);
|
||||
base = cell2mat(Dati(1));
|
||||
altezza = cell2mat(Dati(1));
|
||||
larghezza = cell2mat(Dati(1));
|
||||
else
|
||||
base = [];
|
||||
altezza = [];
|
||||
larghezza = [];
|
||||
end
|
||||
|
||||
%% Calcolo sghembo binari
|
||||
if yesTLH == 1
|
||||
comando = ['select rail_width from software where tool_id like ''' idTool ''' '];
|
||||
Dati = fetch(conn,comando);
|
||||
Traversine = cell2mat(Dati(1));
|
||||
else
|
||||
Traversine = [];
|
||||
end
|
||||
|
||||
%% Seleziono profondità "reale" dell'ancora
|
||||
comando = ['select anchor_real from tools where unit_id like ''' ...
|
||||
unitID ''' and name like ''' DTcatena ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Anchor_real = cell2mat(curs.Data);
|
||||
if ischar(Anchor_real) == 1
|
||||
Anchor_real = 0;
|
||||
end
|
||||
|
||||
text = 'Chain parameters defined correctly. Parametri_Installazione function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
90
Tilt/Piezo.m
Executable file
90
Tilt/Piezo.m
Executable file
@@ -0,0 +1,90 @@
|
||||
% Funzione che calcola il livello della falda
|
||||
|
||||
function [Livello,PiezDef,PiezDefT,ErrPiezoLink,ARRAYdatePL] = Piezo(PiezDef,PiezDefT,...
|
||||
BaroDef,ARRAYdatePL,NuovoZeroPL,NdatiMediaP,Ndatidespike,NodoPiezoLink,ErrPiezoLink,rPL,...
|
||||
Anchor_real,marginePiezo,FileName)
|
||||
|
||||
text = 'Piezo function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
if NuovoZeroPL == 1
|
||||
if NdatiMediaP > Ndatidespike
|
||||
Ndati = NdatiMediaP;
|
||||
else
|
||||
Ndati = Ndatidespike;
|
||||
end
|
||||
ini = round(Ndati/2)+1;
|
||||
if rem(Ndati,2) == 0
|
||||
ini = ini+1;
|
||||
end
|
||||
clear NDati
|
||||
ini = ini + marginePiezo;
|
||||
ErrPiezoLink = ErrPiezoLink(ini:end,:);
|
||||
PiezDef = PiezDef(ini:end,:);
|
||||
PiezDefT = PiezDefT(ini:end,:);
|
||||
BaroDef = BaroDef(ini:end,:);
|
||||
ARRAYdatePL = ARRAYdatePL(ini:end,1);
|
||||
end
|
||||
|
||||
[dati,~] = size(PiezDef);
|
||||
ProfFalda = zeros(dati,rPL); % in riga le date, in colonna i piezometri
|
||||
for p = 1:rPL
|
||||
if strcmp(NodoPiezoLink(1,4),'VW kPa') == 1 || strcmp(NodoPiezoLink(1,4),'VW kg/cm2') == 1
|
||||
ProfFalda(:,p) = (PiezDef(:,p))/9806.65;
|
||||
else
|
||||
ProfFalda(:,p) = (PiezDef(:,p) - BaroDef(:,1))/9806.65;
|
||||
end
|
||||
end
|
||||
|
||||
if Anchor_real ~= 0 % correggo la profondità del piezometro
|
||||
% Nodi = [cell2mat(catena(:,3)) cell2mat(catena(:,2)) cell2mat(catena(:,1))];
|
||||
% [r,~] = size(Nodi);
|
||||
% % Cerco l'ancora
|
||||
% for i = 1:r
|
||||
% if Nodi(i,3) == 9
|
||||
% break
|
||||
% end
|
||||
% end
|
||||
% diff = Anchor_real - Nodi(i,2);
|
||||
NodoPiezoLink(:,3) = num2cell(cell2mat(NodoPiezoLink(:,3)) - Anchor_real);
|
||||
end
|
||||
|
||||
Livello = zeros(dati,rPL); % Dove sta la falda rispetto al Piano Campagna
|
||||
clear p
|
||||
for ii = 1:dati
|
||||
for p = 1:rPL
|
||||
if ProfFalda(ii,p) <= 0 % La falda è sotto al piezometro e questo non può leggerne dunque la profondità
|
||||
Livello(ii,p) = cell2mat(NodoPiezoLink(p,3));
|
||||
else
|
||||
Livello(ii,p) = cell2mat(NodoPiezoLink(p,3)) + ProfFalda(ii,p);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
% Impacchettamento matrice errori
|
||||
[r,~] = size(ErrPiezoLink);
|
||||
Matrice_err = zeros(r,rPL);
|
||||
for i = 1:r % date
|
||||
d = 1;
|
||||
for n = 1:rPL % nodi
|
||||
j = 1;
|
||||
err = ErrPiezoLink(i,d:d+1);
|
||||
while j <= 2
|
||||
if err(1,j) == 1
|
||||
Matrice_err(i,n) = 1;
|
||||
break
|
||||
end
|
||||
j = j+1;
|
||||
end
|
||||
d = d+2;
|
||||
end
|
||||
end
|
||||
ErrPiezoLink = Matrice_err';
|
||||
|
||||
text = 'Piezo Link elaborated correctly. Piezo function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
175
Tilt/QuaternioniASE.m
Executable file
175
Tilt/QuaternioniASE.m
Executable file
@@ -0,0 +1,175 @@
|
||||
function [DNS,DEO,Dz,becc,roll,imba,q,qy]=QuaternioniASE(axb,ayb,azb,mxb,myb,mzb,SP,MEMS,FileName)
|
||||
|
||||
% OPERAZIONI PRELIMINARI
|
||||
% calcola la norma dell'accelerazione e del campo magnetico
|
||||
Na = (axb^2+ayb^2+azb^2)^0.5;
|
||||
Nm = (mxb^2+myb^2+mzb^2)^0.5;
|
||||
% normalizzo l'accelerazione
|
||||
axbN = axb/Na;
|
||||
aybN = ayb/Na;
|
||||
azbN = azb/Na;
|
||||
% normalizzo il campo magnetico
|
||||
mxbN = mxb/Nm;
|
||||
mybN = myb/Nm;
|
||||
mzbN = mzb/Nm;
|
||||
|
||||
if MEMS == 1 % Correggo i segni degli assi
|
||||
% correggo la direzione degli assi del sistema di coordinate
|
||||
% aggiornato al 15 febbraio 2016
|
||||
axsN = axbN;
|
||||
aysN = aybN;
|
||||
azsN = -azbN;
|
||||
% anche per il campo magnetico...
|
||||
mxsN = -mxbN;
|
||||
mysN = -mybN;
|
||||
mzsN = mzbN;
|
||||
elseif MEMS == 2
|
||||
% correggo la direzione degli assi del sistema di coordinate
|
||||
% aggiornato al 09 febbraio 2017
|
||||
axsN = axbN;
|
||||
aysN = aybN;
|
||||
azsN = -azbN;
|
||||
% anche per il campo magnetico...
|
||||
mxsN = -mxbN;
|
||||
mysN = -mybN;
|
||||
mzsN = mzbN;
|
||||
elseif MEMS == 3
|
||||
% correggo la direzione degli assi del sistema di coordinate
|
||||
% aggiornato al 10 ottobre 2022
|
||||
axsN = axbN;
|
||||
aysN = aybN;
|
||||
azsN = azbN;
|
||||
% anche per il campo magnetico...
|
||||
mxsN = mybN;
|
||||
mysN = mxbN;
|
||||
mzsN = -mzbN;
|
||||
end
|
||||
|
||||
% trovo i vettori dei campi gravitazionale e magnetico
|
||||
VaN = [axsN aysN azsN];
|
||||
VmN = [mxsN mysN mzsN];
|
||||
|
||||
% CONTI SECONDO YUN
|
||||
[qy,~,~] = fqa(VaN',VmN');
|
||||
qy = qy';
|
||||
|
||||
% determino i relativi quaternioni
|
||||
qaN = [0 VaN];
|
||||
qmN = [0 VmN];
|
||||
|
||||
% calcolo il coseno del beccheggio
|
||||
% gamma = acos(azsN); gamma non viene mai usato
|
||||
COSteta = (1-axsN^2)^0.5;
|
||||
|
||||
% VERIFICA DELLA SINGOLARITA'
|
||||
% impongo un epsilon piccolo a piacere
|
||||
epsilon = 0.1;
|
||||
if COSteta <= epsilon
|
||||
% 20 deg espresso in radianti
|
||||
alpha = 0.3491;
|
||||
else
|
||||
alpha = 0;
|
||||
end
|
||||
|
||||
SENalphamezzi = sign(sin(alpha))*((1-cos(alpha))/2)^0.5;
|
||||
COSalphamezzi = ((1+cos(alpha))/2)^0.5;
|
||||
|
||||
%% calcolo il quaternione qalpha e il suo coniugato
|
||||
qalpha = [COSalphamezzi 0 SENalphamezzi 0];
|
||||
qalphaC = quatconj(qalpha);
|
||||
|
||||
% modifico il vettore accelerazione...
|
||||
qacc = quatmultiply(qalpha,qaN);
|
||||
qacc = quatmultiply(qacc,qalphaC);
|
||||
|
||||
% ...e quello campo magnetico
|
||||
qmag = quatmultiply(qalpha,qmN);
|
||||
qmag = quatmultiply(qmag,qalphaC);
|
||||
|
||||
%% CALCOLA IL QUATERNIONE ELEVAZIONE
|
||||
% NB: il valore di COSteta sarà riscritto
|
||||
SENteta = qacc(2);
|
||||
COSteta = (1-SENteta^2)^0.5;
|
||||
SENtetamezzi = sign(SENteta)*((1-COSteta)/2)^0.5;
|
||||
COStetamezzi = ((1+COSteta)/2)^0.5;
|
||||
qe = [COStetamezzi 0 SENtetamezzi 0];
|
||||
|
||||
%% CALCOLA IL QUATERNIONE ROLLIO
|
||||
SENphi = -qacc(3)/COSteta;
|
||||
COSphi = -qacc(4)/COSteta;
|
||||
% caso in cui l'asse x sia orientato verticalmente
|
||||
if COSteta == 0
|
||||
SENphi = 0;
|
||||
COSphi = 1;
|
||||
end
|
||||
% determinazione degli elementi di qr
|
||||
if COSphi == -1
|
||||
SENphimezzi = 1*((1-COSphi)/2)^0.5;
|
||||
COSphimezzi = 0;
|
||||
else
|
||||
SENphimezzi = sign(SENphi)*((1-COSphi)/2)^0.5;
|
||||
COSphimezzi = ((1+COSphi)/2)^0.5;
|
||||
if isreal(SENphimezzi)
|
||||
elseif imag(SENphimezzi)<0.001
|
||||
SENphimezzi=0;
|
||||
text = 'SENphi/2 corrected';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
end
|
||||
% scrittura di qr
|
||||
qr = [COSphimezzi SENphimezzi 0 0];
|
||||
|
||||
%% CALCOLA IL QUATERNIONE AZIMUTALE
|
||||
% Campo magnetico nel sistema di coordinate Earth
|
||||
qaus = quatmultiply(qe,qr);
|
||||
qauC = quatconj(qaus);
|
||||
qEm = quatmultiply(qaus,qmag);
|
||||
qEm = quatmultiply(qEm,qauC);
|
||||
% Campo magnetico di riferimento
|
||||
Nx = 1;
|
||||
Ny = 0;
|
||||
% Normalizzazione delle componenti orizzontali del campo magnetico misurato
|
||||
mxmearot = qEm(2);
|
||||
mymearot = qEm(3);
|
||||
Mx = (1/(mxmearot^2+mymearot^2)^0.5)*mxmearot;
|
||||
My = (1/(mxmearot^2+mymearot^2)^0.5)*mymearot;
|
||||
|
||||
% determino coseno e seno dell'angolo di imbardata
|
||||
COSpsi = Mx*Nx+My*Ny;
|
||||
SENpsi = -My*Nx+Mx*Ny;
|
||||
% determinazione degli elementi di qa
|
||||
SENpsimezzi = sign(SENpsi)*((1-COSpsi)/2)^0.5;
|
||||
COSpsimezzi = ((1+COSpsi)/2)^0.5;
|
||||
% scrittura di qa
|
||||
qa = [COSpsimezzi 0 0 SENpsimezzi];
|
||||
|
||||
% QUATERNIONE FINALE
|
||||
q = quatmultiply(qa,qe);
|
||||
q = quatmultiply(q,qr);
|
||||
qINV = [q(:,1) q(:,2).*-1 q(:,3).*-1 q(:,4).*-1];
|
||||
|
||||
% RIPERCORRE AL CONTRARIO LA ROTAZIONE IMPOSTA PER EVITARE LA SINGOLARITA'
|
||||
q = quatmultiply(q,qalpha);
|
||||
Q0 = q(1);
|
||||
Q1 = q(2);
|
||||
Q2 = q(3);
|
||||
Q3 = q(4);
|
||||
|
||||
% CALCOLO GLI ANGOLI DAI QUATERNIONI
|
||||
roll = atan2(2*(Q0*Q1+Q2*Q3),(1-2*(Q1^2+Q2^2)));
|
||||
becc = asin(2*(Q0*Q2-Q3*Q1));
|
||||
imba = atan2(2*(Q0*Q3+Q1*Q2),(1-2*(Q2^2+Q3^2)));
|
||||
|
||||
% Calcolo degli spostamenti relativi al nodo
|
||||
qVett = [0 0 0 SP];
|
||||
qVettR = quatmultiply(q,qVett);
|
||||
qVettR = quatmultiply(qVettR,qINV);
|
||||
|
||||
DNS = qVettR(2);
|
||||
DEO = qVettR(3);
|
||||
Dz = qVettR(4);
|
||||
|
||||
end
|
||||
249
Tilt/Report_ASE.m
Executable file
249
Tilt/Report_ASE.m
Executable file
@@ -0,0 +1,249 @@
|
||||
function Report_ASE(IDcentralina,unitID,chainID,alarms,Chain_Scheme,num_nodi,...
|
||||
Users_Report,Mail,time,activeEN,siteID,conn,FileName)
|
||||
% Software per la generazione automatica di report sull'attività di
|
||||
% monitoraggio ASE
|
||||
|
||||
% try
|
||||
|
||||
diary on
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'report_ASE function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
RPT_ON = 0; % parametro che regola la creazione o meno del report
|
||||
NomeFile = strcat('Report',siteID,'.txt');
|
||||
meseadesso = str2double(datestr(today,'mm'));
|
||||
if isfile(NomeFile) == 1 % Esiste
|
||||
|
||||
% Scarico la frequenza del report
|
||||
comando = ['select freq_report from sites where id like ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Freq = cell2mat(curs.Data);
|
||||
numgiorni = Freq;
|
||||
|
||||
Filetesto = importdata(NomeFile);
|
||||
[rTXT,~] = size(Filetesto);
|
||||
if rTXT > 1
|
||||
datainvio = Filetesto(1,1); % mese di invio OPPURE data di ultimo invio
|
||||
attivaReport = Filetesto(2,1);
|
||||
else % file txt vuoto
|
||||
if numgiorni == 30
|
||||
datainvio = str2double(datestr(today,'mm'))+1; % mese successivo
|
||||
else
|
||||
datainvio = now;
|
||||
end
|
||||
attivaReport = 1; % report disattivato
|
||||
end
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = ['Report frequency:' num2str(numgiorni) ' days'];
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
if numgiorni == 30
|
||||
adesso = str2double(datestr(today,'mm'));
|
||||
if datainvio == adesso
|
||||
RPT_ON = 1;
|
||||
end
|
||||
else
|
||||
adesso = now;
|
||||
if adesso >= datainvio + numgiorni
|
||||
RPT_ON = 1;
|
||||
end
|
||||
end
|
||||
|
||||
if RPT_ON == 1 && attivaReport == 0
|
||||
try
|
||||
attivaReport = 1;
|
||||
outdat = fopen(NomeFile,'wt+');
|
||||
fopen(NomeFile,'wt');
|
||||
fmt = '%d \r';
|
||||
fileID = fopen(NomeFile,'a');
|
||||
fprintf(fileID,fmt,meseadesso);
|
||||
fprintf(fileID,fmt,attivaReport);
|
||||
fclose(fileID);
|
||||
|
||||
% salvo variabili da caricare in Report
|
||||
nomevar = ['variabili_RPT' siteID '.mat'];
|
||||
save(nomevar, 'unitID', 'chainID', 'alarms', 'Chain_Scheme', 'num_nodi', 'Users_Report', 'Mail', ...
|
||||
'time', 'meseadesso', 'adesso', 'datainvio', 'numgiorni', 'activeEN', 'FileName');
|
||||
|
||||
rilancio = ['/usr/local/matlab_func/run_Report_lnx.sh /usr/local/MATLAB/MATLAB_Runtime/v93 '...
|
||||
siteID ''];
|
||||
|
||||
status = system(rilancio);
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,status);
|
||||
catch err
|
||||
FileErr = ['ErrorFile-Report-' siteID '-' datestr(today) '-' datestr(now,'hhMMss')];
|
||||
fid = fopen(FileErr,'a+');
|
||||
fprintf(fid, '%s', err.getReport('extended','hyperlinks','off'));
|
||||
fclose(fid);
|
||||
|
||||
%% Email
|
||||
setpref('Internet','E_mail','alert@aseltd.eu');
|
||||
setpref('Internet','SMTP_Server','smtps.aruba.it');
|
||||
setpref('Internet','SMTP_Username','alert@aseltd.eu');
|
||||
setpref('Internet','SMTP_Password','Ase#2013!20@bat');
|
||||
props=java.lang.System.getProperties;
|
||||
pp=props.setProperty('mail.smtp.auth','true'); %#ok
|
||||
pp=props.setProperty('mail.smtp.socketFactory.class','javax.net.ssl.SSLSocketFactory'); %#ok
|
||||
pp=props.setProperty('mail.smtp.socketFactory.port','465'); %#ok
|
||||
|
||||
% Uso il siteID per identificare il nome del sito
|
||||
comando = ['select name from sites where id like ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
NomeSito = num2str(cell2mat(curs.Data));
|
||||
|
||||
subject_ITA = ('CRASH funzione Report');
|
||||
testo = cellstr('Ciao Andrea e Alessandro,');
|
||||
testobis = cellstr('');
|
||||
testo2 = cellstr(['Il mostro biblico della funzione Report ha al proprio interno qualche minchiata '...
|
||||
'per cui il SW crasha nel realizzare il report di ' NomeSito '. Vi prego di correggermi '...
|
||||
'o continuer' char(243) ' a crashare e ad assillarvi con questa mail. BUAHAHAH! Troverete l''errore in allegato.']);
|
||||
message_ITA = [testo; testobis; testo2];
|
||||
message = cellstr('Tanti Blip e Blop a voi, ');
|
||||
message2 = cellstr('Software Tilt');
|
||||
message_ITA = [message_ITA; message; message2];
|
||||
|
||||
recipients_ASE{1,1} = 'alessandro.valletta@aseltd.eu';
|
||||
recipients_ASE{2,1} = 'andrea.carri@aseltd.eu';
|
||||
|
||||
allegato = FileErr;
|
||||
|
||||
sendmail(recipients_ASE, subject_ITA, message_ITA, allegato)
|
||||
|
||||
end
|
||||
end
|
||||
else
|
||||
datainvio = meseadesso+1;
|
||||
if datainvio > 12
|
||||
datainvio = datainvio-12;
|
||||
end
|
||||
end
|
||||
%% --- Modifica file di testo --- %%%
|
||||
if numgiorni == 30
|
||||
if datainvio == 12
|
||||
nuovofile = 1;
|
||||
elseif datainvio == 13
|
||||
nuovofile = 13;
|
||||
else
|
||||
nuovofile = adesso+1;
|
||||
end
|
||||
else
|
||||
nuovofile = datainvio + numgiorni;
|
||||
end
|
||||
attivaReport = 0;
|
||||
outdat = fopen(NomeFile,'wt+');
|
||||
fopen(NomeFile,'wt');
|
||||
fmt = '%d \r';
|
||||
fileID = fopen(NomeFile,'a');
|
||||
fprintf(fileID,fmt,nuovofile);
|
||||
fprintf(fileID,fmt,attivaReport);
|
||||
fclose(fileID);
|
||||
|
||||
% catch err
|
||||
% FileErr = ['ErrorFile-' IDcentralina '-' datestr(today) '-' datestr(now,'hhMMss') '.txt'];
|
||||
% fid = fopen(FileErr,'a+');
|
||||
% fprintf(fid, '%s', err.getReport('extended','hyperlinks','off'));
|
||||
% fclose(fid);
|
||||
%
|
||||
% % Scarico la frequenza del report
|
||||
% comando = ['select freq_report from sites where id like ''' siteID ''' '];
|
||||
% curs = exec(conn,comando);
|
||||
% curs = fetch(curs);
|
||||
% Freq = cell2mat(curs.Data);
|
||||
% numgiorni = Freq;
|
||||
% meseadesso = str2double(datestr(today,'mm'));
|
||||
%
|
||||
% NomeFile = strcat('Report',siteID,'.txt');
|
||||
%
|
||||
% if isfile(NomeFile) == 1 % Esiste
|
||||
% Filetesto = importdata(NomeFile);
|
||||
% [rTXT,~] = size(Filetesto);
|
||||
% if rTXT >1
|
||||
% datainvio = Filetesto(1,1); % mese di invio OPPURE data di ultimo invio
|
||||
% else % file txt vuoto
|
||||
% if numgiorni == 30
|
||||
% datainvio = meseadesso;
|
||||
% else
|
||||
% datainvio = now;
|
||||
% end
|
||||
% end
|
||||
% else
|
||||
% datainvio = meseadesso+1;
|
||||
% if datainvio > 12
|
||||
% datainvio = datainvio-12;
|
||||
% end
|
||||
% end
|
||||
%
|
||||
% attivaReport = 0;
|
||||
% outdat = fopen(NomeFile,'wt+');
|
||||
% fopen(NomeFile,'wt');
|
||||
% fmt = '%d \r';
|
||||
% fileID = fopen(NomeFile,'a');
|
||||
% if numgiorni == 30
|
||||
% if datainvio == 12
|
||||
% nuovofile = 12;
|
||||
% elseif datainvio == 13
|
||||
% nuovofile = 13;
|
||||
% else
|
||||
% nuovofile = meseadesso;
|
||||
% end
|
||||
% else
|
||||
% nuovofile = datainvio;
|
||||
% end
|
||||
% fprintf(fileID,fmt,nuovofile);
|
||||
% fprintf(fileID,fmt,attivaReport);
|
||||
% fclose(fileID);
|
||||
%
|
||||
% %% Email
|
||||
% setpref('Internet','E_mail','alert@aseltd.eu');
|
||||
% setpref('Internet','SMTP_Server','smtps.aruba.it');
|
||||
% setpref('Internet','SMTP_Username','alert@aseltd.eu');
|
||||
% setpref('Internet','SMTP_Password','Ase#2013!20@bat');
|
||||
% props=java.lang.System.getProperties;
|
||||
% pp=props.setProperty('mail.smtp.auth','true'); %#ok
|
||||
% pp=props.setProperty('mail.smtp.socketFactory.class','javax.net.ssl.SSLSocketFactory'); %#ok
|
||||
% pp=props.setProperty('mail.smtp.socketFactory.port','465'); %#ok
|
||||
%
|
||||
% % Uso il siteID per identificare il nome del sito
|
||||
% comando = ['select name from sites where id like ''' siteID ''' '];
|
||||
% curs = exec(conn,comando);
|
||||
% curs = fetch(curs);
|
||||
% NomeSito = num2str(cell2mat(curs.Data));
|
||||
%
|
||||
% subject_ITA = (['CRASH del Report Automatico - ' NomeSito '']);
|
||||
% testo = cellstr('Ciao Andrea e Alessandro,');
|
||||
% testobis = cellstr('');
|
||||
% testo2 = cellstr(['Nella funzione del report avete scritto qualche minchiata per cui crasha. Vi prego di correggermi '...
|
||||
% 'o continuer' char(243) ' a crashare e ad assillarvi con questa mail. Troverete l''errore in allegato.']);
|
||||
% message_ITA = [testo; testobis; testo2];
|
||||
% message = cellstr('Tanti Bip e Bop a te, ');
|
||||
% message2 = cellstr('Software Tilt');
|
||||
% message_ITA = [message_ITA; message; message2];
|
||||
%
|
||||
% recipients_ASE{1,1} = 'alessandro.valletta@aseltd.eu';
|
||||
% recipients_ASE{2,1} = 'andrea.carri@aseltd.eu';
|
||||
%
|
||||
% allegato = FileErr;
|
||||
%
|
||||
% sendmail(recipients_ASE, subject_ITA, message_ITA, allegato)
|
||||
|
||||
% end
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'report_ASE function executed correctly';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
diary off
|
||||
|
||||
end
|
||||
932
Tilt/Report_ASE_bckUp.m
Executable file
932
Tilt/Report_ASE_bckUp.m
Executable file
@@ -0,0 +1,932 @@
|
||||
function Report_ASE_LOC(IDcentralina,siteID,unitID,chainID,Chain_Scheme,num_nodi,...
|
||||
alarms,Mail,Users_Report,activeEN,time,conn,FileName)
|
||||
% Software per la generazione automatica di report sull'attività di
|
||||
% monitoraggio ASE
|
||||
|
||||
try
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'report_ASE function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
RPT_ON = 0; % parametro che regola la creazione o meno del report
|
||||
NomeFile = strcat('Report',siteID,'.txt');
|
||||
meseadesso = str2double(datestr(today,'mm'));
|
||||
if isfile(NomeFile) == 1 % Esiste
|
||||
Filetesto = importdata(NomeFile);
|
||||
datainvio = Filetesto(1,1); % mese di invio OPPURE data di ultimo invio
|
||||
attivaReport = Filetesto(2,1);
|
||||
|
||||
% Scarico la frequenza del report
|
||||
comando = ['select freq_report from sites where id like ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Freq = cell2mat(curs.Data);
|
||||
numgiorni = Freq;
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = ['Report frequency:' num2str(numgiorni) ' days'];
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
if numgiorni == 30
|
||||
adesso = str2double(datestr(today,'mm'));
|
||||
if datainvio == adesso
|
||||
RPT_ON = 1;
|
||||
end
|
||||
else
|
||||
adesso = now;
|
||||
if adesso >= datainvio + numgiorni
|
||||
RPT_ON = 1;
|
||||
end
|
||||
end
|
||||
|
||||
if RPT_ON == 1
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'Report creation started';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
if attivaReport == 0
|
||||
attivaReport = 1;
|
||||
outdat = fopen(NomeFile,'wt+');
|
||||
fopen(NomeFile,'wt');
|
||||
fmt = '%d \r';
|
||||
fileID = fopen(NomeFile,'a');
|
||||
fprintf(fileID,fmt,meseadesso);
|
||||
fprintf(fileID,fmt,attivaReport);
|
||||
fclose(fileID);
|
||||
|
||||
recipients_ASE{1,1} = 'alessandro.valletta@aseltd.eu';
|
||||
recipients_ASE{2,1} = 'andrea.carri@aseltd.eu';
|
||||
recipients_ASE{3,1} = 'roberto.savi@aseltd.eu';
|
||||
Mail_ASE = 1;
|
||||
|
||||
if Mail_ASE == 1 || Mail == 1
|
||||
|
||||
% Importo librerie Matlab Report Generator e creo report
|
||||
import mlreportgen.dom.*
|
||||
import mlreportgen.report.*
|
||||
|
||||
FIG = 1; % Contatore Figure
|
||||
FIG_ENG = 1;
|
||||
NomeReport = (['Report_ASE_' siteID]);
|
||||
rpt = Report(NomeReport, 'pdf'); % Crea report
|
||||
NomeReport_ENG = (['Report_ASE_' siteID '_ENG']);
|
||||
rpt_ENG = Report(NomeReport_ENG, 'pdf'); % Crea report
|
||||
Section.number(rpt,false); % elimina numerazione capitoli
|
||||
Section.number(rpt_ENG,false); % elimina numerazione capitoli
|
||||
Font_caption = '8.5pt';
|
||||
Font_table = '9pt';
|
||||
Font_table_Loc = '8pt';
|
||||
Font_section = '14pt';
|
||||
Font_tools = '12pt';
|
||||
Font_Chapter = '16pt';
|
||||
|
||||
%% Ricavo info sul sito
|
||||
|
||||
% Uso il siteID per identificare il nome del sito
|
||||
comando = ['select name from sites where id like ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
NomeSito = num2str(cell2mat(curs.Data));
|
||||
|
||||
[arraysito,arraysitoENG,controlsito,yesTL,yesTLHR,yesTLH,yesTLHRH,yesPL,yesBL,yesLL,...
|
||||
yesRL,yesKL,yesKLHR,yesThL,yesPT100,yesIPL,yesIPLHR,yesTuL,yesRaL,yesPCL,yesPCLHR,...
|
||||
yesPrL,yesEL,yes3DEL,yesWEL,yesMPBEL,yesCrL,yes3DCrL,yesBML,yesHL,...
|
||||
yesLuxL,yesCO2,yesRSN,yesRSNHR,yesTrL,yesSM,yes2DCrL,yesPE,yesWL,yesGF,yesGS,...
|
||||
rTL,rTLHR,rTLH,rTLHRH,rPL,rBL,rLL,rRL,rKL,rKLHR,rThL,rPT100,rIPL,rIPLHR,rTuL,rRaL,...
|
||||
rPCL,rPCLHR,rPrL,rEL,r3DEL,rWEL,rMPBEL,rCrL,r3DCrL,rBML,rHL,rLuxL,rCO2,rRSN,rRSNHR,...
|
||||
rTrL,rSM,r2DCrL,rPE,rWL,rGF,rGS,nCT,...
|
||||
NodoTiltLink,NodoTiltLinkHR,NodoTiltLinkH,NodoTiltLinkHRH,NodoPiezoLink,NodoBaroLink,...
|
||||
NodoLoadLink,NodoRainLink,NodoKlinoLink,NodoKlinoLinkHR,NodoThermLink,NodoPT100Link,...
|
||||
NodoInPlaceLink,NodoInPlaceLinkHR,NodoTunnelLink,NodoRadialLink,NodoPreConvLink,...
|
||||
NodoPreConvLinkHR,NodoPressureLink,NodoExtensometerLink,Nodo3DExtensometerLink,...
|
||||
NodoWireExtensometerLink,NodoMultiPointExtensometerLink,NodoCrackLink,Nodo3DCrackLink,...
|
||||
NodoBaroMusaLink,NodoHumidityLink,NodoLuxLink,NodoCO2Link,NodoRSNLink,NodoRSNHRLink,...
|
||||
NodoTriggerLink,NodoStressMeter,Nodo2DCrackLink,NodoPendulum,NodoWeirLink,NodoGflowLink,...
|
||||
NodoGshockLink,tipoarray,tipoalarms,nVMS,nTL,nCAM,nAL] = info_Sito(chainID,alarms,...
|
||||
Chain_Scheme,conn,num_nodi,FileName);
|
||||
|
||||
info_sito = [chainID(:,2) chainID(:,4)];
|
||||
|
||||
%% Pagina titolo ITA
|
||||
template_cover(rpt);
|
||||
tp = TitlePage;
|
||||
Titolo = Paragraph(['Report di monitoraggio del sito: ' NomeSito]);
|
||||
Titolo.Style = {HAlign('center'),Bold(1), FontSize('32pt'),OuterMargin('0in','0in','3in','0.2in')};
|
||||
tp.Title = (Titolo);
|
||||
sottotitolo = Paragraph('Report automatico - Versione Beta Test');
|
||||
sottotitolo.Style = {FontSize('12pt'),Bold(1),HAlign('center')};
|
||||
tp.Subtitle = sottotitolo;
|
||||
tp.Author = ' ';
|
||||
datapub = Paragraph(datestr(today,'dd-mm-yyyy'));
|
||||
datapub.Style = {FontSize('12pt'),HAlign('center')};
|
||||
tp.PubDate = datapub;
|
||||
add(rpt,tp);
|
||||
|
||||
if activeEN == 1
|
||||
%% Pagina titolo ENG
|
||||
template_cover(rpt_ENG);
|
||||
tp_ENG = TitlePage;
|
||||
Titolo = Paragraph('Monitoring activity report ');
|
||||
Titolo.Style = {HAlign('center'),Bold(1), FontSize('32pt'),OuterMargin('0in','0in','3in','0in')};
|
||||
tp_ENG.Title = (Titolo);
|
||||
sottotitolo = Paragraph(NomeSito);
|
||||
sottotitolo.Style = {HAlign('center'),Bold(1), FontSize('32pt'),OuterMargin('0in','0in','0in','0.2in')};
|
||||
tp_ENG.Subtitle = sottotitolo;
|
||||
report = Paragraph('Automatic report - Alpha test version');
|
||||
report.Style = {FontSize('12pt'),Bold(1),HAlign('center'),OuterMargin('0in','0in','0.4in','0.2in')};
|
||||
tp_ENG.Author = report;
|
||||
datapub = Paragraph(datestr(today,'dd-mm-yyyy'));
|
||||
datapub.Style = {FontSize('12pt'),HAlign('center')};
|
||||
tp_ENG.PubDate = datapub;
|
||||
add(rpt_ENG,tp_ENG);
|
||||
end
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'Title page created';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Pagina sommario
|
||||
% Add a default table of contents object to the report
|
||||
template(rpt);
|
||||
TOC = TableOfContents();
|
||||
TOC.Layout.PageNumberFormat = 'I';
|
||||
add(rpt,TOC);
|
||||
if activeEN == 1
|
||||
template(rpt_ENG);
|
||||
TOC_ENG = TableOfContents();
|
||||
TOC_ENG.Layout.PageNumberFormat = 'I';
|
||||
add(rpt_ENG,TOC_ENG);
|
||||
end
|
||||
text = 'Summary page created';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Disclaimer iniziale
|
||||
disclaimer = Chapter;
|
||||
dis = Heading1('Disclaimer');
|
||||
dis.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
|
||||
disclaimer.Title = dis;
|
||||
text = Paragraph(['Il presente report ' char(232) ' un documento generato automaticamente '...
|
||||
'dal software proprietario sviluppato da ASE S.r.l. Il suo obiettivo ' char(232) ' quello '...
|
||||
'di riassumere i principali risultati ottenuti dalla strumentazione installata '...
|
||||
'in un determinato sito del cliente, nel corso di un periodo temporale di riferimento. '...
|
||||
'Il report riporta le principali informazioni relative al sito monitorato: queste includono '...
|
||||
'numero e tipologia degli Array presenti, data di installazione, data di riferimento '...
|
||||
'per i calcoli successivi, principali caratteristiche dei sensori utilizzati, etc. ']);
|
||||
text2 = Paragraph(['Il report viene creato automaticamente il primo giorno di ogni mese e '...
|
||||
'contiene i dati di monitoraggio elaborati a partire dal mese precedente (o dal mese '...
|
||||
'della redazione dell''ultimo report, nel caso di Array inattivo), fornendo una panoramica generale '...
|
||||
'del livello di attivit' char(224) ' del sito durante il periodo temporale di riferimento. '...
|
||||
'Inoltre, nel caso in cui gli strumenti lo consentano, sono riportati grafici che '...
|
||||
'integrano i dati raccolti da diverse tipologie di sensori, con l''obiettivo di '...
|
||||
'evidenziare eventuali correlazioni tra le grandezze monitorate.']);
|
||||
Link = Paragraph(ExternalLink('https://www2.aseltd.eu','cliccando qui.'));
|
||||
text3 = Paragraph(['Si vuole sottolineare che questo documento ' char(232) ' generato completamente in automatico '...
|
||||
'e non contiene pertanto alcuna valutazione o validazione di carattere tecnico '...
|
||||
'relativamente ai risultati ottenuti dalla strumentazione installata. '...
|
||||
'Si ricorda inoltre che quanto riportato nel report ' char(232) ' inteso come un riassunto dei risultati '...
|
||||
'dell''attivit' char(224) ' di monitoraggio. Per la consultazione completa di tutti i dati '...
|
||||
'relativi al sito in esame, ' char(232) ' possibile accedere con le proprie credenziali '...
|
||||
'alla piattaforma interattiva web-based']);
|
||||
text4 = Paragraph('ASE - Advanced Slope Engineering S.r.l.');
|
||||
text5 = Paragraph('Via Robert Koch 53/A, 43123 Fraz. Pilastrello, Parma - Italy');
|
||||
text6 = Paragraph('Tel: +39 0521 1404292');
|
||||
text7 = Paragraph('REA n. 258983 - Cod Fis. e P.IVA 02687890349');
|
||||
text8 = Paragraph('info@aseltd.eu - www.aseltd.eu');
|
||||
text.HAlign = 'justify';
|
||||
text2.HAlign = 'justify';
|
||||
text3.HAlign = 'justify';
|
||||
text4.Style = {Bold(1),HAlign('left')};
|
||||
text5.Style = {HAlign('left'),OuterMargin('0in','0in','0in','0in'),FontSize('8pt')};
|
||||
text6.Style = {HAlign('left'),OuterMargin('0in','0in','0in','0in'),FontSize('8pt')};
|
||||
text7.Style = {HAlign('left'),OuterMargin('0in','0in','0in','0in'),FontSize('8pt')};
|
||||
text8.Style = {HAlign('left'),OuterMargin('0in','0in','0in','0in'),FontSize('8pt')};
|
||||
|
||||
logo = Image('aselogo.jpeg');
|
||||
logo.Style = {Height('9cm'),HAlign('left')};
|
||||
|
||||
add(disclaimer,text);
|
||||
add(disclaimer,text2);
|
||||
add(disclaimer,text3);
|
||||
Link.Style = {OuterMargin('0in','0in','0in','0in')};
|
||||
add(disclaimer,Link);
|
||||
add(disclaimer,logo);
|
||||
add(disclaimer,text4);
|
||||
add(disclaimer,text5);
|
||||
add(disclaimer,text6);
|
||||
add(disclaimer,text7);
|
||||
add(disclaimer,text8);
|
||||
br = PageBreak();
|
||||
add(disclaimer,br);
|
||||
add(rpt,disclaimer);
|
||||
|
||||
if activeEN == 1
|
||||
disclaimer_ENG = Chapter;
|
||||
dis_ENG = Heading1('Disclaimer');
|
||||
dis_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
|
||||
disclaimer_ENG.Title = dis_ENG;
|
||||
% Disclaimer ENG
|
||||
text = Paragraph(['This report consists of a document automatically generated by ASE proprietary software. Its objective is '...
|
||||
'to summarize the main monitoring results recorded during a specific time interval by the instrumentation installed on-site. Moreover, '...
|
||||
'this document presents all the key information concerning the monitored site, including Arrays number and typology, installation date, '...
|
||||
'reference date, installed sensors features, etc. The report is generated automatically on the first day of each month, and it contains '...
|
||||
'monitoring data elaborated from the beginning of the previous month, in order to provide a general overview of the site activity '...
|
||||
'during the reference time period. For specific typologies of sensors, the report also includes graphs composed of different physical quantities, '...
|
||||
'in order to highlight any correlation between data sampled by these sensors.']);
|
||||
Link = Paragraph(ExternalLink('https://www2.aseltd.eu','this link.'));
|
||||
text2 = Paragraph(['We would like to remind that the report generation is completely automated, therefore it does not contain '...
|
||||
'any technical evaluation or validation concerning the results obtained by the instrumentation installed on-site. '...
|
||||
'Moreover, the report is intended as a resume of the main outcomes resulting from the monitoring activity. The user can access complete datasets '...
|
||||
'and information concerning the monitored site by logging into the interactive web-based platform developed by ASE S.r.l., available at']);
|
||||
text7 = Paragraph('REA n. 258983 - VAT ID 02687890349');
|
||||
text.HAlign = 'justify';
|
||||
text2.HAlign = 'justify';
|
||||
text7.Style = {HAlign('left'),OuterMargin('0in','0in','0in','0in'),FontSize('8pt')};
|
||||
|
||||
add(disclaimer_ENG,text);
|
||||
add(disclaimer_ENG,text2);
|
||||
Link.Style = {OuterMargin('0in','0in','0in','0in')};
|
||||
add(disclaimer_ENG,Link);
|
||||
add(disclaimer_ENG,logo);
|
||||
add(disclaimer_ENG,text4);
|
||||
add(disclaimer_ENG,text5);
|
||||
add(disclaimer_ENG,text6);
|
||||
add(disclaimer_ENG,text7);
|
||||
add(disclaimer_ENG,text8);
|
||||
br = PageBreak();
|
||||
add(disclaimer_ENG,br);
|
||||
add(rpt_ENG,disclaimer_ENG);
|
||||
end
|
||||
|
||||
text = 'Disclaimer page created';
|
||||
fprintf(fileID,fmt,text);
|
||||
fileID = fopen(FileName,'a');
|
||||
|
||||
%% Capitolo 1 - sistema MUMS
|
||||
sys = Chapter;
|
||||
app = Heading1('Sistema MUMS');
|
||||
app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
|
||||
sys.Title = app;
|
||||
testo = Paragraph(['Il monitoraggio ' char(232) ' svolto mediante sistema MUMS '...
|
||||
'(Modular Underground Monitoring System), progettato per il controllo multiparametrico dei movimenti '...
|
||||
'orizzontali o verticali del terreno, delle deformazioni di strutture civili '...
|
||||
'e/o geotecniche, di barriere paramassi o debris flow. In ogni nodo possono essere collocati sensori per monitorare '...
|
||||
'grandezze fisiche di varia natura come spostamenti, inclinazioni, pressione interstiziale, temperatura, etc.']);
|
||||
testo2 = Paragraph(['In particolare, il sito ' char(232) ' caratterizzato dalla presenza di ' arraysito ' e relativo sistema'...
|
||||
' di acquisizione automatico, completato da batteria tampone ed adeguato sistema di ricarica.']);
|
||||
if controlsito ~= 0
|
||||
[rTA,~] = size(tipoalarms);
|
||||
aVMS = 0;
|
||||
aCAM = 0;
|
||||
aAL = 0;
|
||||
aTL = 0;
|
||||
for mm = 1:rTA
|
||||
if strcmp(char(tipoalarms(mm)),'Variable Message System')
|
||||
aVMS = 1;
|
||||
elseif strcmp(char(tipoalarms(mm)),'Traffic Lights')
|
||||
aCAM = 1;
|
||||
elseif strcmp(char(tipoalarms(mm)),'Alarms')
|
||||
aAL = 1;
|
||||
elseif strcmp(char(tipoalarms(mm)),'Camera')
|
||||
aCAM = 1;
|
||||
end
|
||||
end
|
||||
testo2prep = [];
|
||||
spazio = '';
|
||||
if aAL > 0
|
||||
if nAL == 1
|
||||
testo2prep = [num2str(nAL) ' allarme acustico-visivo'];
|
||||
else
|
||||
testo2prep = [num2str(nAL) ' allarmi acustico-visivi'];
|
||||
end
|
||||
spazio = ', ';
|
||||
end
|
||||
if aTL > 0
|
||||
if nTL == 1
|
||||
testo2prep = [testo2prep spazio num2str(nTL) ' impianto semaforico'];
|
||||
else
|
||||
testo2prep = [testo2prep spazio num2str(nTL) ' impianti semaforici'];
|
||||
end
|
||||
spazio = ', ';
|
||||
end
|
||||
if aVMS > 0
|
||||
if nVMS == 1
|
||||
testo2prep = [testo2prep spazio num2str(nVMS) ' pannello a messaggio variabile'];
|
||||
else
|
||||
testo2prep = [testo2prep spazio num2str(nVMS) ' pannelli a messaggio variabile'];
|
||||
end
|
||||
spazio = ', ';
|
||||
end
|
||||
if aCAM > 0
|
||||
if nCAM == 1
|
||||
testo2prep = [testo2prep spazio num2str(nCAM) ' videocamera'];
|
||||
else
|
||||
testo2prep = [testo2prep spazio num2str(nCAM) ' videocamere'];
|
||||
end
|
||||
end
|
||||
testo2bis = Paragraph(['Il sistema inoltre include un dispositivo di allertamento composto da ' testo2prep '.']);
|
||||
else
|
||||
testo2bis = [];
|
||||
end
|
||||
testo3 = Paragraph(['I dati grezzi (punti elettrici) sono salvati su apposito supporto' ...
|
||||
' di memoria locale (scheda SD) ed inviati al centro di elaborazione secondo la frequenza impostata. '...
|
||||
'Una volta ricevute le informazioni, il dato viene salvato su un Database con backup giornaliero automatico, '...
|
||||
'elaborato mediante software con algoritmi proprietari e reso disponibile su piattaforma web ad accesso '...
|
||||
'controllato in pochi secondi.']);
|
||||
testo4 = Paragraph(['Il funzionamento completo del sisema MUMS ' char(232) ' schematizzato nella figura seguente.']);
|
||||
ionh = Image(('ionh.png'));
|
||||
testo.HAlign = 'justify';
|
||||
testo2.HAlign = 'justify';
|
||||
testo3.HAlign = 'justify';
|
||||
testo4.HAlign = 'justify';
|
||||
testo.HAlign = 'justify';
|
||||
testo2.HAlign = 'justify';
|
||||
testo3.HAlign = 'justify';
|
||||
testo4.HAlign = 'justify';
|
||||
ionhcaption = Paragraph(['Fig. ' num2str(FIG) ' - Struttura del sistema di monitoraggio']);
|
||||
FIG = FIG + 1;
|
||||
ionhcaption.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
ionh.Style = {Height('8cm'),HAlign('center')};
|
||||
add(sys,testo);
|
||||
add(sys,testo2);
|
||||
if controlsito ~= 0
|
||||
add(sys,testo2bis);
|
||||
end
|
||||
add(sys,testo3);
|
||||
add(sys,testo4);
|
||||
add(sys,ionh);
|
||||
add(sys,ionhcaption);
|
||||
add(rpt,sys);
|
||||
template(rpt);
|
||||
|
||||
if activeEN == 1
|
||||
sys_ENG = Chapter;
|
||||
app_ENG = Heading1('MUMS System');
|
||||
app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
|
||||
sys_ENG.Title = app_ENG;
|
||||
testo = Paragraph(['The monitoring activity is performed with MUMS '...
|
||||
'(Modular Underground Monitoring System) technology, specifically developed for the '...
|
||||
'multi-parametric monitoring of slopes, civil and/or geotechnical structures, rockfall and '...
|
||||
'debris flow barriers. Each node of the Array can equip sensors able to measure different '...
|
||||
'physical quantities like displacements, tilts, pressure, temperatures, etc.']);
|
||||
testo2 = Paragraph(['In particular, the monitoring system installed on-site includes ' arraysitoENG...
|
||||
', the automatic data acquisition '...
|
||||
'system and a battery, with dedicated recharge apparatus.']);
|
||||
if controlsito ~= 0
|
||||
testo2prep = [];
|
||||
spazio = '';
|
||||
if aAL > 0
|
||||
if aAL == 1
|
||||
testo2prep = [num2str(nAL) ' visual-acoustic alarm'];
|
||||
else
|
||||
testo2prep = [num2str(nAL) ' visual-acoustic alarms'];
|
||||
end
|
||||
spazio = ', ';
|
||||
end
|
||||
if aTL > 0
|
||||
if aTL == 1
|
||||
testo2prep = [testo2prep spazio num2str(nTL) ' traffic light'];
|
||||
else
|
||||
testo2prep = [testo2prep spazio num2str(nTL) ' traffic lights'];
|
||||
end
|
||||
spazio = ', ';
|
||||
end
|
||||
if aVMS > 0
|
||||
if aVMS == 1
|
||||
testo2prep = [testo2prep spazio num2str(nVMS) ' variable message panel (VMP)'];
|
||||
else
|
||||
testo2prep = [testo2prep spazio num2str(nVMS) ' variable message panels (VMPs)'];
|
||||
end
|
||||
spazio = ', ';
|
||||
end
|
||||
if aCAM > 0
|
||||
if aCAM == 1
|
||||
testo2prep = [testo2prep spazio num2str(nCAM) ' camera'];
|
||||
else
|
||||
testo2prep = [testo2prep spazio num2str(nCAM) ' cameras'];
|
||||
end
|
||||
end
|
||||
testo2bis = Paragraph(['Moreover, the following devices are included for early warning purposes: ' testo2prep '.']);
|
||||
end
|
||||
testo3 = Paragraph(['The datalogger saves raw data (electrical signals) on a volatile memory (SD card) and then transmits them '...
|
||||
'to the elaboration centre, according to a predefined frequency. Upon arrival on central server, a proprietary '...
|
||||
'software routine automatically elaborates raw data and converts them into physical units. '...
|
||||
'Results are stored in a "parallel" database from which they can be accessed and analysed '...
|
||||
'thanks to a dedicated web-based platform with private access.']);
|
||||
testo4 = Paragraph('The following image describes the structure of the MUMS-based system.');
|
||||
testo.HAlign = 'justify';
|
||||
testo2.HAlign = 'justify';
|
||||
testo3.HAlign = 'justify';
|
||||
testo4.HAlign = 'justify';
|
||||
ionhcaption = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Structure of the monitoring system']);
|
||||
FIG_ENG = FIG_ENG + 1;
|
||||
ionhcaption.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
ionh.Style = {Height('9cm'),HAlign('center')};
|
||||
add(sys_ENG,testo);
|
||||
add(sys_ENG,testo2);
|
||||
if controlsito ~= 0
|
||||
add(sys_ENG,testo2bis);
|
||||
end
|
||||
add(sys_ENG,testo3);
|
||||
add(sys_ENG,testo4);
|
||||
add(sys_ENG,ionh);
|
||||
add(sys_ENG,ionhcaption);
|
||||
add(rpt_ENG,sys_ENG);
|
||||
template(rpt_ENG);
|
||||
end
|
||||
|
||||
text = 'MUMS system defined';
|
||||
fprintf(fileID,fmt,text);
|
||||
fileID = fopen(FileName,'a');
|
||||
fclose(fileID);
|
||||
|
||||
%% Capitolo 2 - Geografia e composizione
|
||||
geoloc = Chapter;
|
||||
app = Heading1('Caratteristiche del sito');
|
||||
app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
|
||||
geoloc.Title = app;
|
||||
|
||||
testo = Paragraph(['Le principali caratteristiche della strumentazione installata nel sito '...
|
||||
'in esame sono riportate nella seguente tabella. Le figure sottostanti presentano la localizzazione '...
|
||||
'geografica degli Array e del relativo sistema di acquisizione (immagini '...
|
||||
'tratte da Mappe di Bing).']);
|
||||
|
||||
comando = ['select lat, lon from sites where id like ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Coordinate = (cell2mat(curs.Data))';
|
||||
latNS = 'N';
|
||||
lonEO = 'E';
|
||||
if Coordinate(1) < 0
|
||||
latNS = 'S';
|
||||
end
|
||||
if Coordinate(2) < 0
|
||||
lonEO = 'O';
|
||||
end
|
||||
testo.HAlign = 'justify';
|
||||
|
||||
testo2 = Paragraph(['In particolare, il sito in esame si trova '...
|
||||
'alle seguenti coordinate geografiche: Latitudine ' num2str(abs(Coordinate(1))) ...
|
||||
' ' latNS ', Longitudine ' num2str(abs(Coordinate(2,:))) ' ' lonEO '.']);
|
||||
testo2.HAlign = 'justify';
|
||||
|
||||
%--- IMMAGINI GEOGRAFICHE ---%
|
||||
mapsito = ['sito' siteID '.png'];
|
||||
geo = Image((mapsito));
|
||||
geo.Style = [geo.Style {ScaleToFit}];
|
||||
geo_cap = Paragraph(['Fig. ' num2str(FIG) ' - Localizzazione geografica della strumentazione installata e del sistema di acquisizione dati']);
|
||||
FIG = FIG+1;
|
||||
geo_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
mapcatene = ['sito' siteID 'det.png'];
|
||||
sito = Image((mapcatene));
|
||||
sito.Style = [sito.Style {ScaleToFit}];
|
||||
sito_cap = Paragraph(['Fig. ' num2str(FIG) ' - Posizione in sito delle centraline e degli strumenti installati']);
|
||||
FIG = FIG+1;
|
||||
sito_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
|
||||
%--- TABELLA SITO MONITORATO ---%
|
||||
Font_Loc = 0;
|
||||
[Font_Loc,status,firstdata_num,datasample,colonna1,colonna2,colonna2bis,colonna3,...
|
||||
colonna4,colonna5,colonna6,colonna6_short,colonna7,yesKLHR3D,c1trigger,c6trigger,cA] = ...
|
||||
report_table(Font_Loc,info_sito,controlsito,tipoarray,tipoalarms,alarms,chainID,Chain_Scheme,...
|
||||
yesTL,yesTLHR,yesTLH,yesTLHRH,yesPL,yesBL,yesLL,yesRL,yesKL,yesKLHR,yesThL,...
|
||||
yesPT100,yesIPL,yesIPLHR,yesTuL,yesRaL,yesPCL,yesPCLHR,yesPrL,yesEL,yes3DEL,...
|
||||
yesWEL,yesMPBEL,yesCrL,yes3DCrL,yesBML,yesHL,yesLuxL,yesCO2,yesRSN,yesRSNHR,yesTrL,...
|
||||
yesPE,yesWL,yes2DCrL,yesGF,yesGS,rTL,rTLHR,rTLH,rTLHRH,rKL,rKLHR,rIPL,rIPLHR,nCT,...
|
||||
num_nodi,time,conn,FileName) ;
|
||||
|
||||
% Controllo che Colonna 5 (lunghezza Array) abbia dei dati,
|
||||
% altrimenti la elimino
|
||||
[rC5,~] = size(colonna5);
|
||||
C5 = 0;
|
||||
for c = 2:rC5
|
||||
if strcmp(char(colonna5(c)),'-') == 0 % Esiste almeno un valore di lunghezza
|
||||
C5 = 1;
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if C5 == 1
|
||||
tab = FormalTable([colonna1,colonna2,colonna2bis,colonna3,colonna4,colonna5,colonna6_short,colonna7]);
|
||||
else
|
||||
tab = FormalTable([colonna1,colonna2,colonna2bis,colonna3,colonna4,colonna6,colonna7]);
|
||||
end
|
||||
|
||||
% formattazione tabella
|
||||
if Font_Loc == 1
|
||||
tab.TableEntriesStyle = {HAlign('center'),VAlign('middle'),FontSize(Font_table_Loc),InnerMargin('0.5mm')};
|
||||
else
|
||||
tab.TableEntriesStyle = {HAlign('center'),VAlign('middle'),FontSize(Font_table),InnerMargin('0.5mm')};
|
||||
end
|
||||
tab.Style = {ResizeToFitContents(true),Width("100%"),RowSep('solid','black','1px'),...
|
||||
ColSep('solid','black','1px'),Hyphenation(false),BackgroundColor('#E0F1FF')};
|
||||
tab.Border = 'single';
|
||||
tabCaption = Paragraph('Tab. 1 - Tipologia e caratteristiche della strumentazione installata in sito');
|
||||
tabCaption.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
bodyFirstRow = tab.Body.Children(1);
|
||||
bodyFirstRow.Style = [bodyFirstRow.Style {Bold()}];
|
||||
if C5 == 0
|
||||
grps(1) = TableColSpecGroup;
|
||||
grps(1).Span = 7;
|
||||
specs(1) = TableColSpec;
|
||||
specs(1).Span = 1;
|
||||
specs(1).Style = {Width("7.5%")};
|
||||
specs(2) = TableColSpec;
|
||||
specs(2).Span = 3;
|
||||
specs(2).Style = {Width("15%")};
|
||||
specs(3) = TableColSpec;
|
||||
specs(3).Span = 1;
|
||||
specs(3).Style = {Width("10%")};
|
||||
specs(4) = TableColSpec;
|
||||
specs(4).Span = 1;
|
||||
specs(5) = TableColSpec;
|
||||
specs(5).Span = 1;
|
||||
specs(5).Style = {Width("12%")};
|
||||
grps(1).ColSpecs = specs;
|
||||
tab.ColSpecGroups = grps;
|
||||
end
|
||||
|
||||
% Installazione
|
||||
testo3 = Paragraph(['La prima lettura disponibile, riportata in Tab. 1, si riferisce '...
|
||||
'alla data di inizio monitoraggio. Va sottolineato come i primissimi dati '...
|
||||
'rilevati da uno strumento possano essere influenzati dagli assestamenti occorsi in '...
|
||||
'seguito all''installazione o dall''adattamento del sensore in sito. Per questo motivo '...
|
||||
'viene definita la lettura di riferimento come data in cui i dati raccolti non mostrano '...
|
||||
'pi' char(249) ' i caratteri tipici dell''adattamento strumentale in sito (per maggiori informazioni '...
|
||||
'consigliamo di fare riferimento agli standard ISO 18674-1:2015).']);
|
||||
testo3.HAlign = 'justify';
|
||||
|
||||
add(geoloc,testo);
|
||||
add(geoloc,testo2);
|
||||
add(geoloc,testo3);
|
||||
add(geoloc,tabCaption);
|
||||
add(geoloc,tab);
|
||||
add(geoloc,br);
|
||||
add(geoloc,geo);
|
||||
add(geoloc,geo_cap);
|
||||
add(geoloc,sito);
|
||||
add(geoloc,sito_cap);
|
||||
add(rpt,geoloc);
|
||||
template(rpt);
|
||||
|
||||
if activeEN == 1
|
||||
geoloc_ENG = Chapter;
|
||||
app_ENG = Heading1('Site features');
|
||||
app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
|
||||
geoloc_ENG.Title = app_ENG;
|
||||
|
||||
testo = Paragraph(['The table reported below summarizes the main characteristics of the instrumentation installed on-site. '...
|
||||
'Moreover, following images display the geographical position of the monitoring system, including the location of Arrays '...
|
||||
'and acquisition devices (source: Bing Maps).']);
|
||||
|
||||
if Coordinate(2) < 0
|
||||
lonEO = 'W';
|
||||
end
|
||||
testo.HAlign = 'justify';
|
||||
|
||||
testo2 = Paragraph(['Geographical coordinates of the monitored site are: '...
|
||||
'Latitude ' num2str(abs(Coordinate(1))) ...
|
||||
' ' latNS ', Longitude ' num2str(abs(Coordinate(2,:))) ' ' lonEO '.']);
|
||||
testo2.HAlign = 'justify';
|
||||
|
||||
%--- IMMAGINI GEOGRAFICHE ---%
|
||||
geo_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Geographical position of the monitored site']);
|
||||
FIG_ENG = FIG_ENG+1;
|
||||
geo_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
sito_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - On-site location of monitoring devices']);
|
||||
FIG_ENG = FIG_ENG+1;
|
||||
sito_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
|
||||
%--- TABELLA SITO MONITORATO ---%
|
||||
[status,firstdata_num,datasample,colonna1,colonna2,colonna2bis,colonna3,...
|
||||
colonna4,colonna5,colonna6,colonna6_short,colonna7,yesKLHR3D,c1trigger,c6trigger,cA]...
|
||||
= report_table_ENG(info_sito,controlsito,tipoarray,tipoalarms,alarms,chainID,Chain_Scheme,...
|
||||
yesTL,yesTLHR,yesTLH,yesTLHRH,yesPL,yesBL,yesLL,yesRL,yesKL,yesKLHR,yesThL,...
|
||||
yesPT100,yesIPL,yesIPLHR,yesTuL,yesRaL,yesPCL,yesPCLHR,yesPrL,yesEL,yes3DEL,...
|
||||
yesWEL,yesMPBEL,yesCrL,yes3DCrL,yesBML,yesHL,yesLuxL,yesCO2,yesRSN,yesRSNHR,yesTrL,...
|
||||
yesPE,yesWL,yes2DCrL,yesGF,yesGS,rTL,rTLHR,rTLH,rTLHRH,rKL,rKLHR,rIPL,rIPLHR,nCT,...
|
||||
num_nodi,time,conn,FileName);
|
||||
|
||||
% Controllo che Colonna 5 (lunghezza Array) abbia dei dati,
|
||||
% altrimenti la elimino
|
||||
[rC5,~] = size(colonna5);
|
||||
C5 = 0;
|
||||
for c = 2:rC5
|
||||
if strcmp(char(colonna5(c)),'-') == 0 % Esiste almeno un valore di lunghezza
|
||||
C5 = 1;
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if C5 == 1
|
||||
tab = FormalTable([colonna1,colonna2,colonna2bis,colonna3,colonna4,colonna5,colonna6_short,colonna7]);
|
||||
else
|
||||
tab = FormalTable([colonna1,colonna2,colonna2bis,colonna3,colonna4,colonna6,colonna7]);
|
||||
end
|
||||
|
||||
% formattazione tabella
|
||||
if Font_Loc == 1
|
||||
tab.TableEntriesStyle = {HAlign('center'),VAlign('middle'),FontSize(Font_table_Loc),InnerMargin('0.5mm')};
|
||||
else
|
||||
tab.TableEntriesStyle = {HAlign('center'),VAlign('middle'),FontSize(Font_table),InnerMargin('0.5mm')};
|
||||
end
|
||||
tab.Style = {ResizeToFitContents(true),Width("100%"),RowSep('solid','black','1px'),...
|
||||
ColSep('solid','black','1px'),Hyphenation(false),BackgroundColor('#E0F1FF')};
|
||||
tab.Border = 'single';
|
||||
tabCaption = Paragraph('Tab. 1 - Instrumentation typologies and features');
|
||||
tabCaption.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
bodyFirstRow = tab.Body.Children(1);
|
||||
bodyFirstRow.Style = [bodyFirstRow.Style {Bold()}];
|
||||
if C5 == 0
|
||||
grps(1) = TableColSpecGroup;
|
||||
grps(1).Span = 7;
|
||||
specs(1) = TableColSpec;
|
||||
specs(1).Span = 1;
|
||||
specs(1).Style = {Width("7.5%")};
|
||||
specs(2) = TableColSpec;
|
||||
specs(2).Span = 3;
|
||||
specs(2).Style = {Width("15%")};
|
||||
specs(3) = TableColSpec;
|
||||
specs(3).Span = 1;
|
||||
specs(3).Style = {Width("10%")};
|
||||
specs(4) = TableColSpec;
|
||||
specs(4).Span = 1;
|
||||
specs(5) = TableColSpec;
|
||||
specs(5).Span = 1;
|
||||
specs(5).Style = {Width("12%")};
|
||||
grps(1).ColSpecs = specs;
|
||||
tab.ColSpecGroups = grps;
|
||||
end
|
||||
|
||||
% Installazione
|
||||
testo3 = Paragraph(['The first available reading date, reported in Tab. 1, '...
|
||||
'refers to the beginning of the monitoring activity. '...
|
||||
'It should be taken into account that the very first monitoring data '...
|
||||
'are usually influenced by stabilization phenomena, which are a '...
|
||||
'natural consequence of the tool installation on-site. For this reason, '...
|
||||
'a reference reading date is defined, representing a time reference '...
|
||||
'where the device can be considered fully operational since no more '...
|
||||
'stabilization movements are observed from sampled data '...
|
||||
'(we suggest to refer to the International Standard EN ISO 18674-1:2015 '...
|
||||
'documentation for further information on this matter).']);
|
||||
testo3.HAlign = 'justify';
|
||||
|
||||
add(geoloc_ENG,testo);
|
||||
add(geoloc_ENG,testo2);
|
||||
add(geoloc_ENG,testo3);
|
||||
add(geoloc_ENG,tabCaption);
|
||||
add(geoloc_ENG,tab);
|
||||
add(geoloc_ENG,br);
|
||||
add(geoloc_ENG,geo);
|
||||
add(geoloc_ENG,geo_cap);
|
||||
add(geoloc_ENG,sito);
|
||||
add(geoloc_ENG,sito_cap);
|
||||
add(rpt_ENG,geoloc_ENG);
|
||||
template(rpt_ENG);
|
||||
end
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'Site information defined';
|
||||
fprintf(fileID,fmt,text);
|
||||
fileID = fopen(FileName,'a');
|
||||
fclose(fileID);
|
||||
|
||||
%% Capitolo 3 - Centraline
|
||||
% --- Analisi centraline e catene ---
|
||||
|
||||
datalogger = Chapter;
|
||||
app = Heading1('Risultati - Dati delle centraline');
|
||||
app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
|
||||
datalogger.Title = app;
|
||||
|
||||
datalogger_ENG = Chapter;
|
||||
if activeEN == 1
|
||||
app_ENG = Heading1('Results - Control units');
|
||||
app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
|
||||
datalogger_ENG.Title = app_ENG;
|
||||
end
|
||||
|
||||
[FIG,FIG_ENG,datarif,contunit,IDscaduta] = report_CU(unitID,chainID,adesso,datainvio,numgiorni,...
|
||||
datasample,tipoarray,firstdata_num,siteID,datalogger,datalogger_ENG,FIG,FIG_ENG,rpt,rpt_ENG,...
|
||||
Font_caption,Font_section,activeEN,conn,FileName);
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'Control units information defined';
|
||||
fprintf(fileID,fmt,text);
|
||||
fileID = fopen(FileName,'a');
|
||||
fclose(fileID);
|
||||
|
||||
%% Capitolo 4 - Catene
|
||||
|
||||
MUMS = Chapter;
|
||||
app = Heading1('Risultati - Dati della strumentazione installata');
|
||||
app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter)};
|
||||
MUMS.Title = app;
|
||||
|
||||
if activeEN == 1
|
||||
MUMS_ENG = Chapter;
|
||||
app_ENG = Heading1('Results - Monitoring tools');
|
||||
app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter)};
|
||||
MUMS_ENG.Title = app_ENG;
|
||||
else
|
||||
MUMS_ENG = [];
|
||||
end
|
||||
|
||||
[PL_A,PL_D,FIG,FIG_ENG] = report_AR(chainID,unitID,tipoarray,contunit,...
|
||||
siteID,FIG,FIG_ENG,rpt,rpt_ENG,Font_caption,Font_Chapter,Font_section,...
|
||||
Font_tools,datarif,yesKLHR3D,rTL,rTLHR,rTLH,rTLHRH,rPL,rBL,rLL,rRL,rKL,...
|
||||
rKLHR,rThL,rPT100,rIPL,rIPLHR,rTuL,rRaL,rPCL,rPCLHR,rPrL,rEL,r3DEL,rWEL,rMPBEL,...
|
||||
rCrL,r2DCrL,r3DCrL,rBML,rHL,rLuxL,rCO2,rRSN,rRSNHR,rTrL,rPE,rWL,rGF,rGS,...
|
||||
NodoTiltLink,NodoTiltLinkH,NodoPiezoLink,NodoBaroLink,NodoLoadLink,...
|
||||
NodoRainLink,NodoKlinoLink,NodoKlinoLinkHR,NodoThermLink,NodoPT100Link,...
|
||||
NodoInPlaceLink,NodoInPlaceLinkHR,NodoTunnelLink,NodoRadialLink,NodoPreConvLink,...
|
||||
NodoPressureLink,NodoExtensometerLink,Nodo3DExtensometerLink,...
|
||||
NodoWireExtensometerLink,NodoMultiPointExtensometerLink,NodoCrackLink,...
|
||||
Nodo2DCrackLink,Nodo3DCrackLink,NodoBaroMusaLink,NodoHumidityLink,NodoLuxLink,...
|
||||
NodoCO2Link,NodoRSNLink,NodoRSNHRLink,NodoTriggerLink,NodoStressMeter,NodoWeirLink,...
|
||||
NodoPendulum,MUMS,MUMS_ENG,colonna2,colonna2bis,colonna4,firstdata_num,activeEN,IDscaduta,...
|
||||
status,br,conn,FileName);
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'Arrays information defined';
|
||||
fprintf(fileID,fmt,text);
|
||||
fileID = fopen(FileName,'a');
|
||||
fclose(fileID);
|
||||
|
||||
%% Capitolo 5 - Control Tools
|
||||
if cA > 1 % Significa che ci sono CT
|
||||
CT = Chapter;
|
||||
app = Heading1('Risultati - Attivazioni dei Control Tools');
|
||||
app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter)};
|
||||
CT.Title = app;
|
||||
|
||||
if activeEN == 1
|
||||
CT_ENG = Chapter;
|
||||
app_ENG = Heading1('Results - Control Tools activations');
|
||||
app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter)};
|
||||
CT_ENG.Title = app_ENG;
|
||||
else
|
||||
CT_ENG = [];
|
||||
end
|
||||
|
||||
[FIG,FIG_ENG] = report_CT(c1trigger,c6trigger,alarms,nCT,rpt,Font_caption,...
|
||||
Font_table,Font_section,datarif,CT,CT_ENG,FIG,FIG_ENG,activeEN,conn,FileName);
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'Control tools information defined';
|
||||
fprintf(fileID,fmt,text);
|
||||
fileID = fopen(FileName,'a');
|
||||
fclose(fileID);
|
||||
end
|
||||
|
||||
%% Appendice
|
||||
[dim,~]= size(colonna6);
|
||||
appendice = Chapter;
|
||||
app = Heading1('Appendice');
|
||||
app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
|
||||
appendice.Title = app;
|
||||
|
||||
if activeEN == 1
|
||||
appendice_ENG = Chapter;
|
||||
app_ENG = Heading1('Appendix');
|
||||
app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
|
||||
appendice_ENG.Title = app_ENG;
|
||||
else
|
||||
appendice_ENG = [];
|
||||
end
|
||||
|
||||
report_appendix(yesTL,yesIPL,yesIPLHR,yesTLH,yesPCL,yesTLHR,yesTLHRH,yesPCLHR,...
|
||||
yesPL,yesBL,yesTuL,yesRaL,yesThL,yesKL,yesKLHR,yesRL,yesLL,yesPrL,yesPT100,...
|
||||
yesCrL,yes3DCrL,yesEL,yes3DEL,yesWEL,yesMPBEL,yesTrL,nCAM,yesWL,yesPE,PL_A,PL_D,...
|
||||
Font_section,Font_caption,Font_tools,FIG,FIG_ENG,dim,appendice,appendice_ENG,...
|
||||
colonna4,colonna6,rpt,rpt_ENG,activeEN,FileName)
|
||||
|
||||
% Chiudi report
|
||||
close(rpt);
|
||||
close(rpt_ENG);
|
||||
|
||||
%% ---Email---
|
||||
[rU,cU] = size(Users_Report);
|
||||
sendReportmail(NomeSito,Coordinate,meseadesso,NomeReport,NomeReport_ENG,...
|
||||
Users_Report,recipients_ASE,Mail,Mail_ASE,activeEN,rU,cU,FileName);
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
datainvio = meseadesso+1;
|
||||
if datainvio > 12
|
||||
datainvio = datainvio-12;
|
||||
end
|
||||
end
|
||||
%% --- Modifica file di testo --- %%%
|
||||
if numgiorni == 30
|
||||
if datainvio == 12
|
||||
nuovofile = 1;
|
||||
elseif datainvio == 13
|
||||
nuovofile = 13;
|
||||
else
|
||||
nuovofile = adesso+1;
|
||||
end
|
||||
else
|
||||
nuovofile = datainvio + numgiorni;
|
||||
end
|
||||
attivaReport = 0;
|
||||
outdat = fopen(NomeFile,'wt+');
|
||||
fopen(NomeFile,'wt');
|
||||
fmt = '%d \r';
|
||||
fileID = fopen(NomeFile,'a');
|
||||
fprintf(fileID,fmt,nuovofile);
|
||||
fprintf(fileID,fmt,attivaReport);
|
||||
fclose(fileID);
|
||||
|
||||
catch err
|
||||
FileErr = ['ErrorFile-' IDcentralina '-' datestr(today) '-' datestr(now,'hhMMss') '.txt'];
|
||||
fid = fopen(FileErr,'a+');
|
||||
fprintf(fid, '%s', err.getReport('extended','hyperlinks','off'));
|
||||
fclose(fid);
|
||||
|
||||
% Scarico la frequenza del report
|
||||
comando = ['select freq_report from sites where id like ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Freq = cell2mat(curs.Data);
|
||||
numgiorni = Freq;
|
||||
|
||||
NomeFile = strcat('Report',siteID,'.txt');
|
||||
|
||||
if isfile(NomeFile) == 1 % Esiste
|
||||
Filetesto = importdata(NomeFile);
|
||||
datainvio = Filetesto(1,1); % mese di invio OPPURE data di ultimo invio
|
||||
else
|
||||
datainvio = meseadesso+1;
|
||||
if datainvio > 12
|
||||
datainvio = datainvio-12;
|
||||
end
|
||||
end
|
||||
|
||||
attivaReport = 0;
|
||||
outdat = fopen(NomeFile,'wt+');
|
||||
fopen(NomeFile,'wt');
|
||||
fmt = '%d \r';
|
||||
fileID = fopen(NomeFile,'a');
|
||||
if numgiorni == 30
|
||||
if datainvio == 12
|
||||
nuovofile = 12;
|
||||
elseif datainvio == 13
|
||||
nuovofile = 13;
|
||||
else
|
||||
nuovofile = adesso;
|
||||
end
|
||||
else
|
||||
nuovofile = datainvio;
|
||||
end
|
||||
fprintf(fileID,fmt,nuovofile);
|
||||
fprintf(fileID,fmt,attivaReport);
|
||||
fclose(fileID);
|
||||
|
||||
%% Email
|
||||
setpref('Internet','E_mail','aseparma@gmail.com');
|
||||
setpref('Internet','SMTP_Server','smtp.gmail.com');
|
||||
setpref('Internet','SMTP_Username','aseparma@gmail.com');
|
||||
setpref('Internet','SMTP_Password','Mums@2016');
|
||||
props=java.lang.System.getProperties;
|
||||
pp=props.setProperty('mail.smtp.auth','true'); %#ok
|
||||
pp=props.setProperty('mail.smtp.socketFactory.class','javax.net.ssl.SSLSocketFactory'); %#ok
|
||||
pp=props.setProperty('mail.smtp.socketFactory.port','465'); %#ok
|
||||
|
||||
subject_ITA = (['CRASH del Report Automatico - ' NomeSito '']);
|
||||
testo = cellstr('Ciao Andrea e Alessandro,');
|
||||
testobis = cellstr('');
|
||||
testo2 = cellstr(['Nella funzione del report avete scritto qualche minchiata per cui crasha. Vi prego di correggermi '...
|
||||
'o continuer' char(243) ' a crashare e ad assillarvi con questa mail. Troverete l''errore in allegato.']);
|
||||
message_ITA = [testo; testobis; testo2];
|
||||
message = cellstr('Tanti Bip e Bop a te, ');
|
||||
message2 = cellstr('Software Tilt');
|
||||
message_ITA = [message_ITA; message; message2];
|
||||
|
||||
recipients_ASE{1,1} = 'alessandro.valletta@aseltd.eu';
|
||||
recipients_ASE{2,1} = 'andrea.carri@aseltd.eu';
|
||||
|
||||
allegato = FileErr;
|
||||
|
||||
sendmail(recipients_ASE, subject_ITA, message_ITA, allegato)
|
||||
|
||||
end
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'report_ASE function executed correctly';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
114
Tilt/SMS.m
Executable file
114
Tilt/SMS.m
Executable file
@@ -0,0 +1,114 @@
|
||||
function SMS(IDcentralina,DTcatena,Sito,Users_SMS,Criterio,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
|
||||
[rU,cU] = size(Users_SMS);
|
||||
NumTel = cell(1);
|
||||
Language = cell(1);
|
||||
j = 1;
|
||||
if cU > 1
|
||||
for i = 1:rU
|
||||
if isempty(Users_SMS{i,6}) == 0 % l'utente ha un numero di telefono
|
||||
NumTel(j,1) = Users_SMS(i,6);
|
||||
Language(j,1) = Users_SMS(i,4);
|
||||
j = j+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
%% ------ INVIO SMS TRAMITE MAIL-TO-SMS SKEBBY -------
|
||||
|
||||
% Settaggio Email mittente
|
||||
setpref('Internet','E_mail','aseparma@gmail.com');
|
||||
setpref('Internet','SMTP_Server','smtp.gmail.com');
|
||||
setpref('Internet','SMTP_Username','aseparma@gmail.com');
|
||||
setpref('Internet','SMTP_Password','Mums@2016');
|
||||
props=java.lang.System.getProperties;
|
||||
pp=props.setProperty('mail.smtp.auth','true'); %#ok
|
||||
pp=props.setProperty('mail.smtp.socketFactory.class','javax.net.ssl.SSLSocketFactory'); %#ok
|
||||
pp=props.setProperty('mail.smtp.socketFactory.port','465'); %#ok
|
||||
|
||||
if strcmp(Criterio,'Fukuzono')
|
||||
sms = 1;
|
||||
elseif strcmp(Criterio,'FIFA')
|
||||
sms = 2;
|
||||
end
|
||||
|
||||
% --- Invio sms di allertamento utenti ---
|
||||
[r,~]=size(NumTel);
|
||||
Condizione = cell2mat(NumTel);
|
||||
|
||||
if isempty(Condizione) == 0 % almeno un utente da avvisare
|
||||
for k=1:r
|
||||
check = char(NumTel(k,1));
|
||||
[~,cC] = size(check);
|
||||
if cC >= 1
|
||||
if Language{k,1} == 2 %ITA
|
||||
if sms == 1
|
||||
testosms = (['ALLARME - Criterio Inverso della Velocità attivato per la Centralina ' IDcentralina...
|
||||
', Catena ' DTcatena ' nel sito di ' Sito '. Controllare l''email per maggiori dettagli.']); %testo sms
|
||||
elseif sms == 2
|
||||
testosms = (['ALLARME - Criterio FIFA attivato per la Centralina ' IDcentralina...
|
||||
', Catena ' DTcatena ' nel sito di ' Sito '. Controllare l''email per maggiori dettagli.']); %testo sms
|
||||
end
|
||||
else %ENG
|
||||
if sms == 1
|
||||
testosms = (['ALARM - Inverse of Velocity Criterion Activated for Datalogger ' IDcentralina ', Array ' DTcatena ', Site: ' Sito...
|
||||
'. Check the email for further details. ''']); %testo sms
|
||||
elseif sms == 2
|
||||
testosms = (['ALARM - FIFA Criterion Activated for Datalogger ' IDcentralina ', Array ' DTcatena ', Site: ' Sito...
|
||||
'. Check the email for further details. ''']); %testo sms
|
||||
end
|
||||
end
|
||||
NUMERO_TEL = num2str(cell2mat(NumTel(k,1))); % numero telefono
|
||||
soggetto = 'ASE: Allarme Fukuzono!';
|
||||
utente = [NUMERO_TEL '@classic.skebby.com'];
|
||||
sendmail(utente,soggetto,testosms)
|
||||
if sms == 1
|
||||
text = ['Alert of Level #5 SMS sent to ' NUMERO_TEL '!'];
|
||||
elseif sms == 2
|
||||
text = ['Alert of Red Code SMS sent to ' NUMERO_TEL '!'];
|
||||
end
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
end
|
||||
% scrivo invio sms a utenti autorizzati nel logfile
|
||||
text = 'Alarm activated, email-to-sms process completed - Alert sent to authorized users!';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
% --- Invio sms a destinatari ASE ---
|
||||
recipients_ITA{1,1} = '+393482453680'; % Alessandro Valletta
|
||||
recipients_ITA{2,1} = '+393493048545'; % Andrea Carri
|
||||
recipients_ITA{3,1} = '+393406654863'; % Roberto Savi
|
||||
recipients_ITA{4,1} = '+393485113211'; % Andrea Segalini
|
||||
[rASE,~]=size(recipients_ITA);
|
||||
|
||||
for z = 1:rASE
|
||||
if sms == 1
|
||||
smsASE = (['ALLARME di livello massimo - Criterio di Fukuzono Attivato per la Centralina' IDcentralina...
|
||||
', Catena ' DTcatena ' nel sito di ' Sito '. Controllare l''email per maggiori dettagli.']);
|
||||
soggettoASE = 'ASE: Allarme Fukuzono!';
|
||||
elseif sms == 2
|
||||
smsASE = (['ALLARME - Criterio FIFA Attivato per la Centralina' IDcentralina...
|
||||
', Catena ' DTcatena ' nel sito di ' Sito '. Controllare l''email per maggiori dettagli.']);
|
||||
soggettoASE = 'ASE: Allarme FIFA!';
|
||||
end
|
||||
Num_ASE = num2str(cell2mat(recipients_ITA(z,1))); % numero telefono ASE
|
||||
utenteASE = [Num_ASE '@classic.skebby.com'];
|
||||
sendmail(utenteASE,soggettoASE,smsASE)
|
||||
% scrivo invio sms a utenti autorizzati nel logfile
|
||||
if sms == 1
|
||||
text = ['Alert of Level #5 SMS sent to ' Num_ASE '!'];
|
||||
elseif sms == 2
|
||||
text = ['Alert of Red Code SMS sent to ' Num_ASE '!'];
|
||||
end
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
text = 'Alarm activated, email-to-sms process completed - Alert sent to ASE users!';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
286
Tilt/SWSearch.m
Executable file
286
Tilt/SWSearch.m
Executable file
@@ -0,0 +1,286 @@
|
||||
% Funzione che ricostruisce la tipologia di nodi presenti
|
||||
% NodoTiltLink ad esempio contiene numero del nodo e profondità per tutti i
|
||||
% nodi di questo tipo
|
||||
% idTool rappresenta l'identificativo con cui sono definite le
|
||||
% installazioni su DB, serve più avanti nell'elaborazione
|
||||
% idNode scrive gli identificativi dei nodi del DB. E' un output di
|
||||
% controllo
|
||||
|
||||
function [yesATD,yesRSN,yesMusa] = SWSearch(idTool,conn,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'SWSearch function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
yesATD = 0;
|
||||
yesRSN = 0;
|
||||
yesMusa = 0;
|
||||
|
||||
%% Tunnel Link
|
||||
% carico le informazioni relative al numero e alla posizione (rispetto all'ancora
|
||||
% considerando la circonferenza come una retta verticale) per Tunnel LINK
|
||||
comando = ['select num, depth from nodes where tool_id = ''' idTool ''' and nodetype_id = 17 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = 'Tunnel Links identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Radial Link
|
||||
% carico le informazioni relative al numero e alla posizione (rispetto all'ancora
|
||||
% considerando la circonferenza come una retta verticale) per Radial LINK
|
||||
comando = ['select num, depth from nodes where tool_id = ''' idTool ''' and nodetype_id = 18 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = 'Radial Links identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% PreConv Link
|
||||
% carico le informazioni relative al numero e alla lunghezza per PreConv
|
||||
% Link (nodo per la misura di PRE-Convergenza)
|
||||
comando = ['select num, depth from nodes where tool_id = ''' idTool ''' and nodetype_id = 23 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = 'PreConv Links identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% PreConv Link HR
|
||||
% carico le informazioni relative al numero e alla lunghezza per TILT LINK
|
||||
% HR H (ampolla orizzontale)
|
||||
comando = ['select num, depth from nodes where tool_id = ''' idTool ''' and nodetype_id = 24 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = 'PreConv Links HR identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Pressure Link
|
||||
% carico le informazioni relative al numero per Pressure LINK
|
||||
comando = ['select num, depth, channels, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 21 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = 'Pressure Links identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Load Link
|
||||
% carico le informazioni relative al numero per LOAD LINK
|
||||
comando = ['select num, depth, channels, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 15 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = 'Load Links identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Extensometer Link
|
||||
% carico le informazioni relative al numero per EXTENSOMETER LINK
|
||||
comando = ['select num, depth, channels, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 16 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = 'Extensometer Links identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% 3D Extensometer Link
|
||||
% carico le informazioni relative al numero per 3D EXTENSOMETER LINK
|
||||
comando = ['select num, depth, channels, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 19 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = '3D Extensometer Links identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Wire Extensometer Link
|
||||
% carico le informazioni relative al numero per Wire EXTENSOMETER LINK
|
||||
comando = ['select num, depth, channels, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 22 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = 'Wire Extensometer Links identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Multi Point Borehole Rod Extensometer
|
||||
% carico le informazioni relative al numero per Multi Point Borehole Rod Extensometer
|
||||
comando = ['select num, depth, channels, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 25 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = 'Multi-Point Rod Extensometers identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Crack Link
|
||||
comando = ['select num, depth, channels, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 36 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = 'Cracks Links identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% 2D Crack Link
|
||||
comando = ['select num, depth, channels, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 51 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = '2D Cracks Links identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% 3D Crack Link
|
||||
comando = ['select num, depth, channels, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 37 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = '3D Cracks Links identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Stress Meter
|
||||
comando = ['select num, depth, channels, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 47 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesATD = 1;
|
||||
text = 'Stress Meters identified, ATD relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Baro Musa Link
|
||||
comando = ['select num, depth from nodes where tool_id = ''' idTool ''' and nodetype_id = 41 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesMusa = 1;
|
||||
text = 'Baro Musa Links identified, Musa relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Humidity link
|
||||
comando = ['select num, depth from nodes where tool_id = ''' idTool ''' and nodetype_id = 35 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesMusa = 1;
|
||||
text = 'Humidity Links identified, Musa relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% CO2 Link
|
||||
comando = ['select num, depth from nodes where tool_id = ''' idTool ''' and nodetype_id = 33 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesMusa = 1;
|
||||
text = 'CO2 Links identified, Musa relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Lux Link
|
||||
comando = ['select num, depth from nodes where tool_id = ''' idTool ''' and nodetype_id = 34 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesMusa = 1;
|
||||
text = 'Lux Links identified, Musa relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% RSN Link
|
||||
comando = ['select num, depth from nodes where tool_id = ''' idTool ''' and nodetype_id = 38 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesRSN = 1;
|
||||
text = 'RSN Links identified, RSN relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% RSN Link HR
|
||||
comando = ['select num, depth from nodes where tool_id = ''' idTool ''' and nodetype_id = 39 order by num'];
|
||||
Leggo = fetch(conn,comando);
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesRSN = 1;
|
||||
text = 'RSN Links HR identified, RSN relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Trigger Link
|
||||
comando = ['select num, depth, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 40 order by num'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Leggo = curs.Data;
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesRSN = 1;
|
||||
text = 'Trigger Links identified, RSN relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% G-Flow Link
|
||||
comando = ['select num, depth, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 48 order by num'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Leggo = curs.Data;
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesRSN = 1;
|
||||
text = 'G-Flow Links identified, RSN relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% G-Shock Link
|
||||
comando = ['select num, depth, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 50 order by num'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Leggo = curs.Data;
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesRSN = 1;
|
||||
text = 'G-Shock Links identified, RSN relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
%% Debris Link
|
||||
comando = ['select num, depth, measurment from nodes where tool_id = ''' idTool ''' and nodetype_id = 49 order by num'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Leggo = curs.Data;
|
||||
[~,cL] = size(Leggo);
|
||||
if cL > 1
|
||||
yesRSN = 1;
|
||||
text = 'Debris Links identified, RSN relaunch activated';
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
|
||||
text = 'SWSearch function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
219
Tilt/Siren.m
Executable file
219
Tilt/Siren.m
Executable file
@@ -0,0 +1,219 @@
|
||||
function Siren(alarms,yesKL,yesKLHR,yesTL,yesIPL,datainiKL,tempoiniKL,datainiKLHR,tempoiniKLHR,...
|
||||
datainiTL,tempoiniTL,datainiIPL,tempoiniIPL,ARRAYdateKL,ARRAYdateKLHR,ARRAYdateTL,ARRAYdateIPL,...
|
||||
conn,date,time,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
|
||||
text = 'Siren function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
[rA,cA] = size(alarms);
|
||||
|
||||
sirena = 0;
|
||||
if rA > 0 && cA > 1
|
||||
for aa = 1:rA
|
||||
if cell2mat(alarms(aa,3)) == 1
|
||||
sirena = 1;
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if cA ~= 1 && sirena == 1
|
||||
if yesKL == 1
|
||||
ARRAYdateAL = ARRAYdateKL;
|
||||
elseif yesKLHR == 1
|
||||
ARRAYdateAL = ARRAYdateKLHR;
|
||||
elseif yesTL == 1
|
||||
ARRAYdateAL = ARRAYdateTL;
|
||||
end
|
||||
[ListaDate,~] = size(ARRAYdateAL);
|
||||
val_AL = zeros(ListaDate,rA);
|
||||
StoricoAllarmi = zeros(ListaDate,rA);
|
||||
% Attivazione della Sirena al superamento di una determinata soglia
|
||||
|
||||
if yesKL == 1
|
||||
dataini = datainiKL;
|
||||
tempoini = tempoiniKL;
|
||||
elseif yesKLHR == 1
|
||||
dataini = datainiKLHR;
|
||||
tempoini = tempoiniKLHR;
|
||||
elseif yesTL == 1
|
||||
dataini = datainiTL;
|
||||
tempoini = tempoiniTL;
|
||||
end
|
||||
dateCheck = [date ' ' time];
|
||||
if dataini < datenum(dateCheck)
|
||||
dataini = date;
|
||||
tempoini = time;
|
||||
else
|
||||
dataini = datestr(dataini,'yyyy-mm-dd HH:MM:SS');
|
||||
end
|
||||
|
||||
%% QUI ANDRA' INSERITO IL CRITERIO DI ATTIVAZIONE DELL'ALLARME
|
||||
|
||||
% Criterio di attivazione dell'allarme
|
||||
%-------------------------------------
|
||||
|
||||
% Criterio di attivazione dell'SMS
|
||||
AL = 1;
|
||||
DATAinsert = cell(1,5);
|
||||
Data = datestr(ARRAYdateAL(end,1),'yyyy-mm-dd HH:MM:SS');
|
||||
for ii = 1:rA % numero di allarmi
|
||||
if val_AL(end,ii) == 1 && ARRAYdateAL(end,1) > alarms(ii,end)
|
||||
desc = strjoin(alarms(ii,5),alarms(ii,6),'ON');
|
||||
DATAinsert{AL,1} = 6; % Sirena e lampeggiante
|
||||
DATAinsert{AL,2} = alarms(ii,2); % ID del CT
|
||||
DATAinsert{AL,3} = Data; % Data & ora
|
||||
DATAinsert{AL,4} = 1; % SMS
|
||||
DATAinsert{AL,5} = desc; % Codice da inviare
|
||||
allarme = 1;
|
||||
AL = AL+1;
|
||||
end
|
||||
end
|
||||
|
||||
if allarme == 1
|
||||
AL = AL-1; % Numero totale di allarmi
|
||||
for a = 1:AL
|
||||
% Cerco se il dato è già presente
|
||||
Data = DATAinsert{a,3};
|
||||
type = num2str(DATAinsert{a,1}); % tipologia
|
||||
IDtool = num2str(DATAinsert{a,2}); % ID del CT
|
||||
desc = DATAinsert{a,5}; % Descrizione
|
||||
comando = ['select id from alarms where tool_name = ''' IDtool ''' and date_time = ''' ...
|
||||
Data ''' and type_id = ''' type ''' and description like ''' desc ''' order by date_time'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
idDate = curs.Data;
|
||||
if cell2mat(idDate) == 0
|
||||
idElabData = 0; % 0 indica che il dato non è presente su DB
|
||||
else
|
||||
idElabData = cell2mat(idDate);
|
||||
end
|
||||
tablename = 'alarms';
|
||||
colnames = {'type_id','tool_name','date_time','send_sms','description'};
|
||||
data = [DATAinsert(a,1),DATAinsert(a,2),DATAinsert(a,3),DATAinsert(a,4),DATAinsert(a,5)];
|
||||
if idElabData == 0 % Scrivo
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
text = ['ALERT was written in the DB by Siren function for date: ''' Data ''' '];
|
||||
else % Aggiorno
|
||||
whereclause = ['WHERE tool_name = ''' DATAinsert{a,2} ''' and date_time = ''' DATAinsert{a,3} ...
|
||||
''' and type_id = ''' type ''' and description like ''' desc ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
text = ['ALERT was updated in the DB by Siren function for date: ''' Data ''' '];
|
||||
end
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
end
|
||||
|
||||
Control = 1;
|
||||
while Control == 1
|
||||
for nn = 1:rA
|
||||
% Scarico i dati storici di attivazione dell'allarme
|
||||
comando = ['select EventDate, EventTime, X from ELABDATACTRL where EventDate = ''' ...
|
||||
dataini ''' and EventTime >= ''' tempoini ''' and CtrlToolName = '''...
|
||||
char(alarms(nn,2)) ''' and NodeNum = 1 '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
AlarmTot_1 = curs.Data; % numero cumulato di attivazioni prima della lettura in elaborazione
|
||||
|
||||
comando = ['select EventDate, EventTime, X from ELABDATACTRL where EventDate > ''' ...
|
||||
dataini ''' and CtrlToolName = ''' char(alarms(nn,2)) ''' and NodeNum = 1 '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
AlarmTot_2 = curs.Data; % numero cumulato di attivazioni prima della lettura in elaborazione
|
||||
|
||||
[r1,c1] = size(AlarmTot_1);
|
||||
[r2,c2] = size(AlarmTot_2);
|
||||
if r1 == 1 && c1 == 1
|
||||
if r2 == 1 && c2 == 1
|
||||
if dataini < datenum(dateCheck)
|
||||
AlarmTot(1,1) = cellstr(date);
|
||||
AlarmTot(1,2) = cellstr(time);
|
||||
AlarmTot(1,3) = cell;
|
||||
Control = 0;
|
||||
else
|
||||
dataini = dataini-1;
|
||||
break
|
||||
end
|
||||
else
|
||||
AlarmTot = AlarmTot_2;
|
||||
Control = 0;
|
||||
end
|
||||
else
|
||||
Control = 0;
|
||||
if r2 == 1 && c2 == 1
|
||||
AlarmTot = AlarmTot_1;
|
||||
else
|
||||
AlarmTot = [AlarmTot_1; AlarmTot_2];
|
||||
end
|
||||
end
|
||||
[rA,~] = size(AlarmTot);
|
||||
Data = [cell2mat(AlarmTot(:,1)) repmat(' ', [rA,1]) cell2mat(AlarmTot(:,2))];
|
||||
Data = datenum(Data);
|
||||
Var = find(Data < datenum(ARRAYdateAL(1,1)));
|
||||
if isempty(Var) == 1
|
||||
StoricoAllarmi(:,nn) = cumsum(val_AL);
|
||||
else
|
||||
StoricoAllarmi(:,nn) = cumsum(val_AL)+cell2mat(AlarmTot(Var(end),3));
|
||||
end
|
||||
|
||||
DATAinsert = cell(ListaDate,6);
|
||||
% Creo i dati da scrivere
|
||||
for ii=1:ListaDate
|
||||
DATAinsert{ii,1} = alarms(nn,2);
|
||||
DATAinsert{ii,2} = datestr(ARRAYdateAL(ii),'yyyy-mm-dd');
|
||||
DATAinsert{ii,3} = datestr(ARRAYdateAL(ii),'HH:MM:SS');
|
||||
DATAinsert{ii,4} = val_AL(ii,nn);
|
||||
DATAinsert{ii,5} = StoricoAllarmi(ii,nn);
|
||||
DATAinsert{ii,6} = 1;
|
||||
end
|
||||
idElabData = zeros(ListaDate,1); % Contiene gli id delle date delle quali ho già dati
|
||||
cc = 1; % contatore
|
||||
% Cerco su DB se i dati sono da aggiornare o scrivere
|
||||
for ii = 1:ListaDate
|
||||
dString = datestr(ARRAYdateAL(ii),'yyyy-mm-dd');
|
||||
tString = datestr(ARRAYdateAL(ii),'HH:MM:SS');
|
||||
|
||||
comando = ['select idElabDataCtrl from ELABDATACTRL where CtrlToolName = '''...
|
||||
char(alarms(nn,2)) ''' and NodeNum = 1 and EventDate = ''' ...
|
||||
dString ''' and EventTime = ''' tString ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
idDate = curs.Data;
|
||||
if strcmp(idDate,'No Data')
|
||||
idElabData(cc,1) = 0; % 0 indica che il dato non è presente su DB
|
||||
else
|
||||
idElabData(cc,1) = cell2mat(idDate);
|
||||
end
|
||||
cc = cc+1;
|
||||
% Scrivo o Aggiorno i dati
|
||||
idData = idElabData(ii,1);
|
||||
tablename = 'ELABDATACTRL';
|
||||
if idData == 0 % Se la data non è su DB (=0), scrivo i dati
|
||||
colnames = {'CtrlToolName','EventDate','EventTime','XShift','X','NodeNum',};
|
||||
data = [DATAinsert(ii,1),DATAinsert(ii,2),DATAinsert(ii,3),...
|
||||
DATAinsert(ii,4),DATAinsert(ii,5),DATAinsert(ii,6)];
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
else % altrimenti li aggiorno
|
||||
colnames = {'XShift','X'};
|
||||
data = [DATAinsert(ii,4),DATAinsert(ii,5)];
|
||||
whereclause = ['WHERE CtrlToolName = ''' char(alarms(nn,2)) ...
|
||||
''' and NodeNum = 1 and EventDate = ''' cell2mat(DATAinsert(ii,2))...
|
||||
''' and EventTime = ''' cell2mat(DATAinsert(ii,3)) ''' '];
|
||||
update(conn,tablename,colnames,data,whereclause)
|
||||
end
|
||||
end
|
||||
text = ['Data of Control Tools ' char(alarms(nn,2)) ' uploaded in the DB correctly'];
|
||||
fprintf(fileID,fmt,text);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
text = 'Siren function executed correctly';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
|
||||
|
||||
60
Tilt/Site_Info.m
Executable file
60
Tilt/Site_Info.m
Executable file
@@ -0,0 +1,60 @@
|
||||
function [unitID,chainID,Chain_Scheme,num_nodi,alarms] = Site_Info(siteID,conn,FileName)
|
||||
|
||||
text = 'Site_Info function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
% Scarico tutte le centraline presenti in sito
|
||||
comando = ['select id, name from units where site_id = ''' siteID ''' order by name']; % il rapporto centralina sito è di 1 a 1
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
unitID = curs.Data;
|
||||
|
||||
col = size(unitID);
|
||||
chainID = cell(1,4);
|
||||
ini = 1;
|
||||
for c = 1:col(1,1)
|
||||
% dalle centraline presenti, risalgo alle catene disponibili
|
||||
comando = ['select id, name from tools where unit_id = ''' num2str(cell2mat(unitID(c,1))) ''' order by name'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
chainID_down = curs.Data; % id tool, nome tool
|
||||
[fin,~] = size(chainID_down);
|
||||
fin = fin+ini-1;
|
||||
chainID(ini:fin,3:4) = chainID_down;
|
||||
for j = ini:fin
|
||||
chainID(j,1:2) = unitID(c,1:2); % Id centralina, nome centralina, id tool, nome tool
|
||||
end
|
||||
ini = fin+1;
|
||||
end
|
||||
|
||||
% Scarico gli schemi delle catene
|
||||
[col,~] = size(chainID); % Numero di Array
|
||||
Chain_Scheme = cell(1,3);
|
||||
num_nodi = zeros(col,1);
|
||||
ini = 1;
|
||||
cont = 1;
|
||||
for c = 1:col(1,1)
|
||||
comando = ['select nodetype_id, depth, num from nodes where tool_id = ''' num2str(cell2mat(chainID(c,3))) ''' order by num'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
scheme_down = curs.Data; % id nodo, profondità, numero
|
||||
[fin,~] = size(scheme_down);
|
||||
num_nodi(cont) = fin;
|
||||
Chain_Scheme(1:fin,ini:ini+2) = scheme_down;
|
||||
ini = ini+3;
|
||||
cont = cont+1;
|
||||
end
|
||||
|
||||
% Scarico l'allarme relativo al sito
|
||||
comando = ['select id, name, ctrltype_id, alarm_phone, conn_usr, conn_pwd, duedate from ctrltools where site_id = ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
alarms = curs.Data;
|
||||
|
||||
text = 'Site_Info function worked correctly';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
135
Tilt/Therm.m
Executable file
135
Tilt/Therm.m
Executable file
@@ -0,0 +1,135 @@
|
||||
function [Dati_ThL,ARRAYdateThL,ErrThermLink] = Therm(Dati_ThL,ARRAYdateThL,...
|
||||
NuovoZeroThL,ErrThermLink,NdatiMedia,margine,Tmax,Tmin,datainiThL,...
|
||||
IDcentralina,DTcatena,FileName)
|
||||
|
||||
text = 'Therm function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
if NuovoZeroThL == 1
|
||||
ini = round(NdatiMedia/2);
|
||||
if rem(NdatiMedia,2) == 0
|
||||
ini = ini+1;
|
||||
end
|
||||
ini = ini + margine;
|
||||
if ini < 6
|
||||
ini = 6;
|
||||
end
|
||||
ErrThermLink = ErrThermLink(ini:end,:)';
|
||||
Dati_ThL = Dati_ThL(ini:end,:);
|
||||
ARRAYdateThL = ARRAYdateThL(ini:end,1);
|
||||
else
|
||||
ErrThermLink = ErrThermLink';
|
||||
end
|
||||
|
||||
[r,c] = size(Dati_ThL);
|
||||
FileTemperature = ['' IDcentralina '-' DTcatena '-ThL-Therm.csv'];
|
||||
if isfile(FileTemperature) == 1
|
||||
DatiRaw = csvread(FileTemperature);
|
||||
[rDR,cDR] = size(DatiRaw);
|
||||
DatiRaw(:,1) = DatiRaw(:,1) + 730000;
|
||||
else
|
||||
rDR = 1;
|
||||
cDR = 1;
|
||||
end
|
||||
cont2 = 1;
|
||||
textT = '0 correction executed for Therm Link - Temperature filter';
|
||||
for a = 1:r % Data
|
||||
for b = 1:c % Nodo
|
||||
% NON considero i dati al di sopra dei 80 °C o al di sotto dei -30 °C!
|
||||
if Dati_ThL(a,b) > Tmax || Dati_ThL(a,b) < Tmin
|
||||
cont2 = cont2+1;
|
||||
if a == 1
|
||||
if isfile(FileTemperature) == 1
|
||||
RawDate = find(DatiRaw(:,1)<=datenum(datainiThL));
|
||||
if isempty(RawDate) == 1
|
||||
cc = 2;
|
||||
while cc <= c
|
||||
if Dati_ThL(cc,b) > Tmax || Dati_ThL(cc,b) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
Dati_ThL(a,b) = Dati_ThL(cc,b);
|
||||
else
|
||||
if isnan(DatiRaw(RawDate(end),b+1)) == 0
|
||||
Dati_ThL(a,b) = DatiRaw(RawDate(end),b+1);
|
||||
ErrThermLink(b,a) = 1;
|
||||
wardat = 'Temperature data of Therm Link nodes corrected using Raw Data of reference Csv file.';
|
||||
fprintf(fileID,fmt,wardat);
|
||||
else
|
||||
cc = 2;
|
||||
while cc <= c
|
||||
if Dati_ThL(cc,b) > Tmax || Dati_ThL(cc,b) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
Dati_ThL(a,b) = Dati_ThL(cc,b);
|
||||
end
|
||||
end
|
||||
else
|
||||
cc = 2;
|
||||
while cc <= c
|
||||
if Dati_ThL(cc,b) > Tmax || Dati_ThL(cc,b) < Tmin
|
||||
cc = cc+1;
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
Dati_ThL(a,b) = Dati_ThL(cc,b);
|
||||
end
|
||||
else
|
||||
Dati_ThL(a,b) = Dati_ThL(a-1,b);
|
||||
ErrThermLink(b,a) = 1;
|
||||
end
|
||||
textT = ['' num2str(cont2) ' correction executed for Therm Link - Temperature filter!'];
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if rDR~=1 && cDR~=1 && isempty(DatiRaw) == 0
|
||||
RawDate1 = find(DatiRaw(:,1)<=ARRAYdateThL(1));
|
||||
if isempty(RawDate1) == 1
|
||||
RawDate2 = 1;
|
||||
elseif RawDate1(end) == rDR
|
||||
RawDate2 = find(ARRAYdateThL(:,1)>DatiRaw(end,1));
|
||||
else
|
||||
RawDate2 = find(ARRAYdateThL(:,1)>DatiRaw(RawDate1(end)+1,1));
|
||||
end
|
||||
else
|
||||
RawDate1 = [];
|
||||
RawDate2 = 1;
|
||||
end
|
||||
if isempty(RawDate1) == 0 && isempty(RawDate2) == 0
|
||||
Dati = [DatiRaw(1:RawDate1(end),:); ARRAYdateThL(RawDate2(1):end) Dati_ThL(RawDate2(1):end,:)];
|
||||
elseif isempty(RawDate1) == 1 && isempty(RawDate2) == 0
|
||||
Dati = [ARRAYdateThL Dati_ThL];
|
||||
else
|
||||
Dati = DatiRaw;
|
||||
end
|
||||
% Elimino appoggio più vecchio di un mese
|
||||
RawDate3 = find(Dati(:,1)<now-30);
|
||||
if isempty(RawDate3) == 0
|
||||
[rDati,~] = size(Dati);
|
||||
if RawDate3(end) == rDati
|
||||
else
|
||||
Dati = Dati(RawDate3(end)+1:end,:);
|
||||
end
|
||||
end
|
||||
if isfile(FileTemperature) == 1
|
||||
delete(FileTemperature);
|
||||
end
|
||||
Dati(:,1) = Dati(:,1) - 730000;
|
||||
csvwrite(FileTemperature,Dati);
|
||||
|
||||
fprintf(fileID,fmt,textT);
|
||||
|
||||
text = 'Therm Link elaborated correctly. Therm function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
1327
Tilt/Tilt.m
Executable file
1327
Tilt/Tilt.m
Executable file
File diff suppressed because it is too large
Load Diff
1040
Tilt/Tilt_bck.m
Executable file
1040
Tilt/Tilt_bck.m
Executable file
File diff suppressed because it is too large
Load Diff
1572
Tilt/Time_Of_Failure.m
Executable file
1572
Tilt/Time_Of_Failure.m
Executable file
File diff suppressed because it is too large
Load Diff
30
Tilt/Untitled.m
Executable file
30
Tilt/Untitled.m
Executable file
@@ -0,0 +1,30 @@
|
||||
dsX(1,17237:17670) = 0;
|
||||
dsY(1,17237:17670) = 0;
|
||||
dsZ(1,17237:17670) = 0;
|
||||
dsX(1,18200:end) = 0;
|
||||
dsY(1,18200:end) = 0;
|
||||
dsZ(1,18200:end) = 0;
|
||||
dsX(15,11720:11760) = 0;
|
||||
dsY(15,11720:11760) = 0;
|
||||
dsZ(15,11720:11760) = 0;
|
||||
dsX(15,13550:13670) = 0;
|
||||
dsY(15,13550:13670) = 0;
|
||||
dsZ(15,13550:13670) = 0;
|
||||
dsX(17,11600:15000) = 0;
|
||||
dsY(17,11600:15000) = 0;
|
||||
dsZ(17,11600:15000) = 0;
|
||||
dsX(18,11700:11800) = 0;
|
||||
dsY(18,11700:11800) = 0;
|
||||
dsZ(18,11700:11800) = 0;
|
||||
dsX(18,13600:13800) = 0;
|
||||
dsY(18,13600:13800) = 0;
|
||||
dsZ(18,13600:13800) = 0;
|
||||
dsX(19,11700:11800) = 0;
|
||||
dsY(19,11700:11800) = 0;
|
||||
dsZ(19,11700:11800) = 0;
|
||||
dsX(19,13600:13800) = 0;
|
||||
dsY(19,13600:13800) = 0;
|
||||
dsZ(19,13600:13800) = 0;
|
||||
dsX(20,7000:18000) = 0;
|
||||
dsY(20,7000:18000) = 0;
|
||||
dsZ(20,7000:18000) = 0;
|
||||
14
Tilt/Untitled2.m
Executable file
14
Tilt/Untitled2.m
Executable file
@@ -0,0 +1,14 @@
|
||||
datainiTL = date;
|
||||
datainiTLHR = date;
|
||||
datainiPL = date;
|
||||
datainiBL = date;
|
||||
tempoiniTL = time;
|
||||
tempoiniTLHR = time;
|
||||
tempoiniPL = time;
|
||||
tempoiniBL = time;
|
||||
NuovoZeroTL = 0;
|
||||
NuovoZeroTLHR = 0;
|
||||
NuovoZeroBL = 0;
|
||||
NuovoZeroPL = 0;
|
||||
DatiElabTiltLink = [];
|
||||
DatiElabTiltLinkHR = [];
|
||||
45
Tilt/Untitled3.m
Executable file
45
Tilt/Untitled3.m
Executable file
@@ -0,0 +1,45 @@
|
||||
ini = 2249;
|
||||
fin = 2669;
|
||||
|
||||
accTL(ini:fin,58)= accTL(ini:fin,1);
|
||||
accTL(ini:fin,59)= accTL(ini:fin,2);
|
||||
accTL(ini:fin,60)= accTL(ini:fin,3);
|
||||
accTL(ini:fin,1)= accTL(ini-1,1);
|
||||
accTL(ini:fin,2)= accTL(ini-1,2);
|
||||
accTL(ini:fin,3)= accTL(ini-1,3);
|
||||
magTL(ini:fin,59)= magTL(ini:fin,2);
|
||||
magTL(ini:fin,60)= magTL(ini:fin,3);
|
||||
magTL(ini:fin,58)= magTL(ini:fin,1);
|
||||
magTL(ini:fin,1)= magTL(ini-1,1);
|
||||
magTL(ini:fin,2)= magTL(ini-1,2);
|
||||
magTL(ini:fin,3)= magTL(ini-1,3);
|
||||
tempTL(ini:fin,20)= tempTL(ini:fin,1);
|
||||
tempTL(ini:fin,1)= tempTL(ini-1,1);
|
||||
|
||||
accTL(18229:end,58)= accTL(18229:end,1);
|
||||
accTL(18229:end,59)= accTL(18229:end,2);
|
||||
accTL(18229:end,60)= accTL(18229:end,3);
|
||||
accTL(18229:end,1)= accTL(18228,1);
|
||||
accTL(18229:end,2)= accTL(18228,2);
|
||||
accTL(18229:end,3)= accTL(18228,3);
|
||||
magTL(18229:end,59)= magTL(18229:end,2);
|
||||
magTL(18229:end,60)= magTL(18229:end,3);
|
||||
magTL(18229:end,58)= magTL(18229:end,1);
|
||||
magTL(18229:end,1)= magTL(18228,1);
|
||||
magTL(18229:end,2)= magTL(18228,2);
|
||||
magTL(18229:end,3)= magTL(18228,3);
|
||||
tempTL(18229:end,20)= tempTL(18229:end,1);
|
||||
tempTL(18229:end,1)= tempTL(18228,1);
|
||||
|
||||
angTLHR(ini:fin,39)= angTLHR(ini:fin,1);
|
||||
angTLHR(ini:fin,40)= angTLHR(ini:fin,2);
|
||||
angTLHR(ini:fin,1)= angTLHR(ini-1,1);
|
||||
angTLHR(ini:fin,2)= angTLHR(ini-1,2);
|
||||
angTLHR(18229:end,39)= angTLHR(18229:end,1);
|
||||
angTLHR(18229:end,40)= angTLHR(18229:end,2);
|
||||
angTLHR(18229:end,1)= angTLHR(18228,1);
|
||||
angTLHR(18229:end,2)= angTLHR(18228,2);
|
||||
tempTLHR(ini:fin,20)= tempTLHR(ini:fin,1);
|
||||
tempTLHR(ini:fin,1)= tempTLHR(ini-1,1);
|
||||
tempTLHR(18229:end,20)= tempTLHR(18229:end,1);
|
||||
tempTLHR(18229:end,1)= tempTLHR(18228,1);
|
||||
46
Tilt/Untitled3bis.m
Executable file
46
Tilt/Untitled3bis.m
Executable file
@@ -0,0 +1,46 @@
|
||||
ini = 2249;
|
||||
fin = 2669;
|
||||
ini2 = 3241;
|
||||
|
||||
accTL(ini:fin,58)= accTL(ini:fin,1);
|
||||
accTL(ini:fin,59)= accTL(ini:fin,2);
|
||||
accTL(ini:fin,60)= accTL(ini:fin,3);
|
||||
accTL(ini:fin,1)= accTL(ini-1,1);
|
||||
accTL(ini:fin,2)= accTL(ini-1,2);
|
||||
accTL(ini:fin,3)= accTL(ini-1,3);
|
||||
magTL(ini:fin,59)= magTL(ini:fin,2);
|
||||
magTL(ini:fin,60)= magTL(ini:fin,3);
|
||||
magTL(ini:fin,58)= magTL(ini:fin,1);
|
||||
magTL(ini:fin,1)= magTL(ini-1,1);
|
||||
magTL(ini:fin,2)= magTL(ini-1,2);
|
||||
magTL(ini:fin,3)= magTL(ini-1,3);
|
||||
tempTL(ini:fin,20)= tempTL(ini:fin,1);
|
||||
tempTL(ini:fin,1)= tempTL(ini-1,1);
|
||||
|
||||
accTL(ini2:end,58)= accTL(ini2:end,1);
|
||||
accTL(ini2:end,59)= accTL(ini2:end,2);
|
||||
accTL(ini2:end,60)= accTL(ini2:end,3);
|
||||
accTL(ini2:end,1)= accTL(ini2-1,1);
|
||||
accTL(ini2:end,2)= accTL(ini2-1,2);
|
||||
accTL(ini2:end,3)= accTL(ini2-1,3);
|
||||
magTL(ini2:end,59)= magTL(ini2:end,2);
|
||||
magTL(ini2:end,60)= magTL(ini2:end,3);
|
||||
magTL(ini2:end,58)= magTL(ini2:end,1);
|
||||
magTL(ini2:end,1)= magTL(ini2-1,1);
|
||||
magTL(ini2:end,2)= magTL(ini2-1,2);
|
||||
magTL(ini2:end,3)= magTL(ini2-1,3);
|
||||
tempTL(ini2:end,20)= tempTL(ini2:end,1);
|
||||
tempTL(ini2:end,1)= tempTL(ini2-1,1);
|
||||
|
||||
angTLHR(ini:fin,39)= angTLHR(ini:fin,1);
|
||||
angTLHR(ini:fin,40)= angTLHR(ini:fin,2);
|
||||
angTLHR(ini:fin,1)= angTLHR(ini-1,1);
|
||||
angTLHR(ini:fin,2)= angTLHR(ini-1,2);
|
||||
angTLHR(ini2:end,39)= angTLHR(ini2:end,1);
|
||||
angTLHR(ini2:end,40)= angTLHR(ini2:end,2);
|
||||
angTLHR(ini2:end,1)= angTLHR(ini2-1,1);
|
||||
angTLHR(ini2:end,2)= angTLHR(ini2-1,2);
|
||||
tempTLHR(ini:fin,20)= tempTLHR(ini:fin,1);
|
||||
tempTLHR(ini:fin,1)= tempTLHR(ini-1,1);
|
||||
tempTLHR(ini2:end,20)= tempTLHR(ini2:end,1);
|
||||
tempTLHR(ini2:end,1)= tempTLHR(ini2-1,1);
|
||||
54
Tilt/Untitled_2.m
Executable file
54
Tilt/Untitled_2.m
Executable file
@@ -0,0 +1,54 @@
|
||||
ini =1;
|
||||
N = 2250;
|
||||
%15000
|
||||
|
||||
X = X(:,ini:N);
|
||||
Y = Y(:,ini:N);
|
||||
Z = Z(:,ini:N);
|
||||
Xlocal = Xlocal(:,ini:N);
|
||||
Ylocal = Ylocal(:,ini:N);
|
||||
Zlocal = Zlocal(:,ini:N);
|
||||
HShift = HShift(:,ini:N);
|
||||
HShift_local = HShift_local(:,ini:N);
|
||||
Acceleration = Acceleration(:,ini:N);
|
||||
Acceleration_local = Acceleration_local(:,ini:N);
|
||||
Speed = Speed(:,ini:N);
|
||||
Speed_local = Speed_local(:,ini:N);
|
||||
AlfaX = AlfaX(:,ini:N);
|
||||
AlfaY = AlfaY(:,ini:N);
|
||||
ARRAYdateTL = ARRAYdateTL(ini:N);
|
||||
Azimuth = Azimuth(:,ini:N);
|
||||
ErrTiltLink = ErrTiltLink(:,ini:N);
|
||||
TempDef_TL = TempDef_TL(ini:N,:);
|
||||
|
||||
X_HR = X_HR(:,ini:N);
|
||||
Y_HR = Y_HR(:,ini:N);
|
||||
Z_HR = Z_HR(:,ini:N);
|
||||
Xlocal_HR = Xlocal_HR(:,ini:N);
|
||||
Ylocal_HR = Ylocal_HR(:,ini:N);
|
||||
Zlocal_HR = Zlocal_HR(:,ini:N);
|
||||
HShift_HR = HShift_HR(:,ini:N);
|
||||
HShift_local_HR = HShift_local_HR(:,ini:N);
|
||||
Acceleration_HR = Acceleration_HR(:,ini:N);
|
||||
Acceleration_local_HR = Acceleration_local_HR(:,ini:N);
|
||||
Speed_HR = Speed_HR(:,ini:N);
|
||||
Speed_local_HR = Speed_local_HR(:,ini:N);
|
||||
AlfaX_HR = AlfaX_HR(:,ini:N);
|
||||
AlfaY_HR = AlfaY_HR(:,ini:N);
|
||||
ARRAYdateTLHR = ARRAYdateTLHR(ini:N);
|
||||
Azimuth_HR = Azimuth_HR(:,ini:N);
|
||||
ErrTiltLinkHR = ErrTiltLinkHR(:,ini:N);
|
||||
TempDef_TLHR = TempDef_TLHR(ini:N,:);
|
||||
|
||||
ARRAYdateBL = ARRAYdateBL(ini:N);
|
||||
BaroDef = BaroDef(ini:N);
|
||||
BaroDefT = BaroDefT(ini:N);
|
||||
ErrBaroLink = ErrBaroLink(:,ini:N);
|
||||
|
||||
ARRAYdatePL = ARRAYdatePL(ini:N);
|
||||
ErrPiezoLink = ErrPiezoLink(:,ini:N);
|
||||
Livello = Livello(ini:N,:);
|
||||
PiezDef = PiezDef(ini:N);
|
||||
PiezDefT = PiezDefT(ini:N);
|
||||
|
||||
|
||||
118
Tilt/Users_Def.m
Executable file
118
Tilt/Users_Def.m
Executable file
@@ -0,0 +1,118 @@
|
||||
function [Mail,Users_Report,activeEN,siteID,NomeSito] = Users_Def(IDcentralina,conn,FileName)
|
||||
|
||||
text = 'Users function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
% A partire dalla centralina, risalgo al site ID
|
||||
comando = ['select site_id from units where name like ''' IDcentralina ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
siteID = num2str(cell2mat(curs.Data));
|
||||
|
||||
% --- Cerco gli utenti ---
|
||||
|
||||
% - Definisco gli Users
|
||||
% A partire dal site ID, risalgo al company ID
|
||||
comando = ['select company_id, name, lat, lon, alarm_email from sites where id like ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Site = curs.Data;
|
||||
Company_id = num2str(cell2mat(Site(1,1)));
|
||||
NomeSito = Site(1,2);
|
||||
|
||||
% A partire dal company ID, mi scarico le info relative a Send Email Alarm
|
||||
comando = ['select send_alarm from companies where id like ''' Company_id ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Mail = cell2mat(curs.Data);
|
||||
|
||||
% A partire dal company ID, risalgo agli utenti e alla loro mail di
|
||||
% quella company che sono admin
|
||||
comando = ['select fname, lname, email, language_id, report from users where '...
|
||||
'company_id like ''' Company_id ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Users = curs.Data;
|
||||
|
||||
% Elimino gli utenti che non devono ricevere il report
|
||||
[rU,cU] = size(Users);
|
||||
Users_Report = cell(1,1);
|
||||
rpt = 1;
|
||||
if cU > 1
|
||||
for u = 1:rU
|
||||
if cell2mat(Users(u,5)) == 1
|
||||
[rUA,cUA] = size(Users_Report);
|
||||
if rUA == 1 && cUA == 1
|
||||
clear Users_Report
|
||||
end
|
||||
Users_Report(rpt,:) = Users(u,1:4);
|
||||
rpt = rpt+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
ini_CoV = rpt;
|
||||
|
||||
% Cone of vision
|
||||
% A partire dal site ID, risalgo al USER ID degli utenti nel
|
||||
% cone-of-vision per quel sito
|
||||
comando = ['select user_id from coneofvisions where site_id like ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
CoV = cell2mat(curs.Data);
|
||||
|
||||
comando = ['select report_cov from coneofvisions where site_id like ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Auth_CoV = cell2mat(curs.Data);
|
||||
|
||||
% A partire dal USER ID, risalgo agli utenti e alla loro email se sono company manager
|
||||
[rC, ~] = size(CoV);
|
||||
n = 1;
|
||||
if strcmp(char(CoV(1,:)),'No Data') % almeno un utente da cercare nel database
|
||||
else
|
||||
for i=1:rC
|
||||
if Auth_CoV(i) == 1
|
||||
Utente = num2str(CoV(i,1));
|
||||
comando = ['select fname, lname, email, language_id '...
|
||||
'from users where id = ''' Utente ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
COV = curs.Data;
|
||||
Users_CoV(n,:) = COV;
|
||||
n = n+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
if n>1 % Esistono utenti CoV per il report
|
||||
[~,cU] = size(Users_Report);
|
||||
if cU == 1
|
||||
Users_Report = Users_CoV;
|
||||
else
|
||||
Users_Report(rpt:rpt+n-2,:) = Users_CoV;
|
||||
end
|
||||
end
|
||||
[rU,cU] = size(Users_Report);
|
||||
if rU == 0
|
||||
Mail = 0;
|
||||
end
|
||||
|
||||
% A chi mando la mail
|
||||
activeEN = 0;
|
||||
if cU >1 % sono presenti utenti a cui inviare la mail
|
||||
for i = 1:rU
|
||||
if Users_Report{i,4} == 2
|
||||
activeIT = 1;
|
||||
else
|
||||
activeEN = 1;
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
text = 'Users function worked correctly';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
322
Tilt/Users_Def_old.m
Executable file
322
Tilt/Users_Def_old.m
Executable file
@@ -0,0 +1,322 @@
|
||||
function [Mail,Users_Alert,Users_SMS,Users_Report,activeIT,activeEN,...
|
||||
sms,siteID,NomeSito,ini_CoV] = Users_Def(IDcentralina,conn,FileName)
|
||||
|
||||
text = 'Users function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
% A partire dalla centralina, risalgo al site ID
|
||||
comando = ['select site_id from units where name like ''' IDcentralina ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
siteID = num2str(cell2mat(curs.Data));
|
||||
|
||||
% --- Cerco gli utenti ---
|
||||
|
||||
% - Definisco gli Users
|
||||
% A partire dal site ID, risalgo al company ID
|
||||
comando = ['select company_id, name, lat, lon, alarm_email from sites where id like ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Site = curs.Data;
|
||||
Company_id = num2str(cell2mat(Site(1,1)));
|
||||
Email_Alarm_Site = Site(1,5);
|
||||
NomeSito = Site(1,2);
|
||||
|
||||
% A partire dal company ID, mi scarico le info relative a Send Email Alarm
|
||||
comando = ['select send_alarm from companies where id like ''' Company_id ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Mail = cell2mat(curs.Data);
|
||||
|
||||
if Mail == 1 % Significa che invio Mail alla Company del Sito
|
||||
% La Mail la mando SOLO alla mail indicata nel campo del Sito (per quanto riguarda la company cliente)
|
||||
if isempty(cell2mat(Email_Alarm_Site)) == 0
|
||||
if strcmp(char(Email_Alarm_Site),'null') == 0
|
||||
US = Email_Alarm_Site;
|
||||
check = cell2mat(strfind(US,','));
|
||||
if isempty(check)==1
|
||||
% A partire dal company ID, risalgo agli utenti e alla loro mail di
|
||||
% quella company che sono admin
|
||||
comando = ['select fname, lname, language_id, info, phone, sms_alarm, report, report_cov, '...
|
||||
'allertamento from users where email like '''...
|
||||
char(US) ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Info = curs.Data; % Cerco la lingua dell'unico destinatario
|
||||
[~,cC] = size(Info);
|
||||
if cC > 1
|
||||
Users = Info(1:2);
|
||||
Users(3) = US;
|
||||
Users(4:5) = Info(3:4);
|
||||
Users(6) = Info(5);
|
||||
Users(7:10) = Info(6:9);
|
||||
else
|
||||
Users = [];
|
||||
end
|
||||
else
|
||||
[~,cC] = size(check);
|
||||
Users = cell(cC+1,6);
|
||||
u = 1;
|
||||
ini = 1;
|
||||
for i=1:cC+1
|
||||
utente = char(US);
|
||||
% A partire dal company ID, risalgo agli utenti e alla loro mail di
|
||||
% quella company che sono admin
|
||||
if i == cC+1
|
||||
comando = ['select fname, lname, language_id, info, phone, sms_alarm, report, report_cov, '...
|
||||
'allertamento, email from users where email like ''' utente(ini:end) ''' '];
|
||||
else
|
||||
comando = ['select fname, lname, language_id, info, phone, sms_alarm, report, report_cov, '...
|
||||
'allertamento, email from users where email like ''' utente(ini:check(i)-1) ''' '];
|
||||
end
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Info = curs.Data; % Cerco la lingua dell'unico destinatario
|
||||
[~,cI] = size(Info);
|
||||
if cI ~= 1
|
||||
Users(u,1:2) = Info(1:2);
|
||||
Users(u,3) = Info(10);
|
||||
Users(u,4:5) = Info(3:4);
|
||||
Users(u,6) = Info(5);
|
||||
Users(u,7:10) = Info(6:9);
|
||||
u = u+1;
|
||||
end
|
||||
if i ~= cC+1
|
||||
ini = check(i)+1;
|
||||
end
|
||||
end
|
||||
Users = Users(1:u-1,:);
|
||||
end
|
||||
else
|
||||
% Company Manager
|
||||
Role = ' 2 ';
|
||||
% A partire dal company ID, risalgo agli utenti e alla loro mail di
|
||||
% quella company che sono admin
|
||||
comando = ['select fname, lname, email, language_id, info, phone, sms_alarm, report, report_cov, '...
|
||||
'allertamento from users where company_id like ''' Company_id ''' and role_id = ''' Role ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Users = curs.Data;
|
||||
end
|
||||
else
|
||||
% Company Manager
|
||||
Role = ' 2 ';
|
||||
% A partire dal company ID, risalgo agli utenti e alla loro mail di
|
||||
% quella company che sono admin
|
||||
comando = ['select fname, lname, email, language_id, info, phone, sms_alarm, report, report_cov, '...
|
||||
'allertamento from users where company_id like ''' Company_id ''' and role_id = ''' Role ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Users = curs.Data;
|
||||
end
|
||||
else
|
||||
Users = [];
|
||||
end
|
||||
|
||||
% Elimino gli utenti che non possono essere allertati
|
||||
[rU,cU] = size(Users);
|
||||
al = 1;
|
||||
sms = 1;
|
||||
rpt = 1;
|
||||
Users_Alert = cell(1,1);
|
||||
Users_SMS = cell(1,1);
|
||||
Users_Report = cell(1,1);
|
||||
if cU > 1
|
||||
for u = 1:rU
|
||||
if cell2mat(Users(u,10)) == 1
|
||||
[rUA,cUA] = size(Users_Alert);
|
||||
if rUA == 1 && cUA == 1
|
||||
clear Users_Alert
|
||||
end
|
||||
Users_Alert(al,:) = Users(u,:);
|
||||
al = al+1;
|
||||
if cell2mat(Users(u,7)) == 1
|
||||
[rUA,cUA] = size(Users_SMS);
|
||||
if rUA == 1 && cUA == 1
|
||||
clear Users_SMS
|
||||
end
|
||||
Users_SMS(sms,:) = Users(u,:);
|
||||
sms = sms+1;
|
||||
end
|
||||
end
|
||||
if cell2mat(Users(u,8)) == 1
|
||||
[rUA,cUA] = size(Users_Report);
|
||||
if rUA == 1 && cUA == 1
|
||||
clear Users_Report
|
||||
end
|
||||
Users_Report(rpt,:) = Users(u,:);
|
||||
rpt = rpt+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
ini_CoV = al;
|
||||
|
||||
% Cerco se allertare o meno i Cone of Visions
|
||||
comando = ['select conn_path from units where name like ''' IDcentralina ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Auth = curs.Data; % Se pari a 1 autorizzo i Cone of Visions, altrimenti no
|
||||
|
||||
if strcmp(char(Auth),'Yes')
|
||||
Mail = 1;
|
||||
% Cone of vision
|
||||
% A partire dal site ID, risalgo al USER ID degli utenti nel
|
||||
% cone-of-vision per quel sito
|
||||
comando = ['select user_id from coneofvisions where site_id like ''' siteID ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
CoV = cell2mat(curs.Data);
|
||||
|
||||
% A partire dal USER ID, risalgo agli utenti e alla loro email se sono company manager
|
||||
[rC, ~] = size(CoV);
|
||||
if strcmp(char(CoV(1,:)),'No Data') % almeno un utente da cercare nel database
|
||||
Users_CoV = [];
|
||||
else
|
||||
ii = 1;
|
||||
for i=1:rC
|
||||
Utente = num2str(CoV(i,1));
|
||||
Role = ' 2 '; % Company Manager
|
||||
comando = ['select fname, lname, email, language_id, info, phone, sms_alarm, report, report_cov, '...
|
||||
'allertamento from users where id = ''' Utente ''' and role_id = ''' Role ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
UC = curs.Data;
|
||||
[~,cUC] = size(UC);
|
||||
Role = ' 5 '; % Super Company Manager
|
||||
comando = ['select fname, lname, email, language_id, info, phone, sms_alarm, report, report_cov, '...
|
||||
'allertamento from users where id = ''' Utente ''' and role_id = ''' Role ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
UC2 = curs.Data;
|
||||
[~,cUC2] = size(UC2);
|
||||
if cUC ~= 1
|
||||
Users_CoV(ii,:) = UC;
|
||||
ii = ii+1;
|
||||
elseif cUC2 ~= 1
|
||||
Users_CoV(ii,:) = UC2;
|
||||
ii = ii+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
[rUC,cUC] = size(Users_CoV);
|
||||
[rUA,cUA] = size(Users_Alert);
|
||||
if cUC > 1
|
||||
for u = 1:rUC
|
||||
if cell2mat(Users_CoV(u,10)) == 1 && cell2mat(Users_CoV(u,9)) == 1
|
||||
salta = 0;
|
||||
for cov = 1:rUA
|
||||
if cUA > 1
|
||||
A = strfind(char(Users_CoV(u,3)),char(Users_Alert(cov,3)));
|
||||
if A == 1
|
||||
salta = 1;
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if salta == 0
|
||||
if cUA > 1
|
||||
Users_Alert(al,:) = Users_CoV(u,:);
|
||||
else
|
||||
Users_Alert = Users_CoV(u,:);
|
||||
end
|
||||
al = al+1;
|
||||
if cell2mat(Users_CoV(u,7)) == 1
|
||||
[rSMS,cSMS] = size(Users_SMS);
|
||||
if rSMS == 1 && cSMS == 1
|
||||
clear Users_SMS
|
||||
end
|
||||
Users_SMS(sms,:) = Users_CoV(u,:);
|
||||
sms = sms+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
if cell2mat(Users_CoV(u,9)) == 1
|
||||
salta = 0;
|
||||
for cov = 1:rUA
|
||||
if cUA > 1
|
||||
A = strfind(char(Users_CoV(u,3)),char(Users_Alert(cov,3)));
|
||||
if A == 1
|
||||
salta = 1;
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if salta == 0
|
||||
[rUA,cUA] = size(Users_Report);
|
||||
if rUA == 1 && cUA == 1
|
||||
clear Users_Report
|
||||
end
|
||||
Users_Report(rpt,:) = Users_CoV(u,:);
|
||||
rpt = rpt+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
Users_CoV = [];
|
||||
end
|
||||
|
||||
[rU,cU] = size(Users);
|
||||
[rC,cC] = size(Users_CoV);
|
||||
if cC > 1 && rC > 0 && cU > 1 % comando ha trovato informazioni e le ha scritte in Users
|
||||
Users(rU+1:rU+rC,1:10) = Users_CoV;
|
||||
elseif cC > 1 && rC > 0 && cU == 0
|
||||
Users = Users_CoV;
|
||||
end
|
||||
|
||||
[rU,~] = size(Users);
|
||||
if rU == 0
|
||||
Mail = 0;
|
||||
end
|
||||
% Controllo che la centralina non sia scaduta
|
||||
comando = ['select duedate from units where name = ''' IDcentralina ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Date = curs.Data;
|
||||
Check = cell2mat(Date);
|
||||
if strcmp(Check,'null') || strcmp(Check,'No Data')
|
||||
% La data di scadenza centralina non è impostata
|
||||
sms = 1;
|
||||
else
|
||||
if datenum(Date) < now % Centralina scaduta
|
||||
sms = 0;
|
||||
Users_Alert = [];
|
||||
Users_SMS = [];
|
||||
Users_Report = [];
|
||||
else
|
||||
sms = 1;
|
||||
end
|
||||
end
|
||||
|
||||
% A chi mando la mail
|
||||
activeIT = 0;
|
||||
activeEN = 0;
|
||||
[~,c1] = size(Users_Alert);
|
||||
[~,c2] = size(Users_Report);
|
||||
if c1 == 1 && c2 == 1
|
||||
Users_Lang = [];
|
||||
elseif c1 == 1
|
||||
Users_Lang = Users_Report;
|
||||
elseif c2 == 1
|
||||
Users_Lang = Users_Alert;
|
||||
else
|
||||
Users_Lang = [Users_Alert; Users_Report];
|
||||
end
|
||||
[rU,cU] = size(Users_Lang);
|
||||
if cU >1 % sono presenti utenti a cui inviare la mail
|
||||
for i = 1:rU
|
||||
if Users_Lang{i,4} == 2
|
||||
activeIT = 1;
|
||||
else
|
||||
activeEN = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
text = 'Users function worked correctly';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
223
Tilt/YesNo.m
Executable file
223
Tilt/YesNo.m
Executable file
@@ -0,0 +1,223 @@
|
||||
%% funzione che attiva/disattiva l'elaborazione per una determinata tipologia di nodo
|
||||
% Ad esempio se la matrice Tilt Link è vuota i Tilt Link non sono presenti
|
||||
% e si scrive yesTL = 0, altrimenti se ci sono dei dati, yesTL = 1 e ne
|
||||
% viene attivata l'elaborazione nelle fasi successive
|
||||
|
||||
function [yesTL,yesTLHR,yesTLHR3D,yesTLH,yesTLHRH,yesTLHR3DH,yesPL,yesBL,...
|
||||
yesThL,yesAL,yesLL,yesKL,yesKLHR,yesRL,yesPT100,yesIPL,yesIPLHR,yesIPLHR3D,...
|
||||
yesWL,yesPE,NodoPiezoLink,yesWI,yesHD,yesHDVR,yesSPP,yesSL] = YesNo(NodoTiltLink,NodoTiltLinkHR,...
|
||||
NodoTiltLinkHR3D,NodoTiltLinkH,NodoTiltLinkHRH,NodoTiltLinkHR3DH,NodoPiezoLink,...
|
||||
NodoBaroLink,NodoThermLink,NodoAnalogLink,NodoLoadLink,NodoKlinoLink,NodoKlinoLinkHR,...
|
||||
NodoRainLink,NodoPT100Link,NodoInPlaceLink,NodoInPlaceLinkHR,NodoInPlaceLinkHR3D,...
|
||||
NodoWeirLink,NodoPendulum,NodoWind,NodoTiltLinkHD,NodoTiltLinkHDVR,NodoSPPLink,NodoSnowLink,FileName)
|
||||
|
||||
text = 'YesNo function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
%% Tilt Link V
|
||||
[rTL,cTL] = size(NodoTiltLink);
|
||||
if rTL==0 && cTL==0
|
||||
yesTL = 0; % Non elaboro i Tilt Link
|
||||
else
|
||||
yesTL = 1; % attiva l'elaborazione dei Tilt Link
|
||||
end
|
||||
|
||||
%% Tilt Link HR V
|
||||
[rTLHR,cTLHR] = size(NodoTiltLinkHR);
|
||||
if rTLHR==0 && cTLHR==0
|
||||
yesTLHR = 0; % Non elaboro i Tilt Link HR
|
||||
else
|
||||
yesTLHR = 1; % attiva l'elaborazione dei Tilt Link HR
|
||||
end
|
||||
|
||||
%% Tilt Link H
|
||||
[rTLH,cTLH] = size(NodoTiltLinkH);
|
||||
if rTLH==0 && cTLH==0
|
||||
yesTLH = 0; % Non elaboro i Tilt Link H
|
||||
else
|
||||
yesTLH = 1; % attiva l'elaborazione dei Tilt Link H
|
||||
end
|
||||
|
||||
%% Tilt Link HR H
|
||||
[rTLHRH,cTLHRH] = size(NodoTiltLinkHRH);
|
||||
if rTLHRH==0 && cTLHRH==0
|
||||
yesTLHRH = 0; % Non elaboro i Tilt Link HR H
|
||||
else
|
||||
yesTLHRH = 1; % attiva l'elaborazione dei Tilt Link HR H
|
||||
end
|
||||
|
||||
%% Piezo Link
|
||||
[rPL,cPL] = size(NodoPiezoLink);
|
||||
if rPL==0 && cPL==0
|
||||
yesPL = 0; % Non elaboro i Piezo Link
|
||||
NodoPiezoLink = zeros(1,4);
|
||||
else
|
||||
yesPL = 1; % attiva l'elaborazione dei Piezo Link
|
||||
end
|
||||
|
||||
%% Baro Link
|
||||
[rBL,cBL] = size(NodoBaroLink);
|
||||
if rBL==0 && cBL==0
|
||||
yesBL = 0; % Non elaboro i Baro Link
|
||||
else
|
||||
yesBL = 1; % attiva l'elaborazione dei Baro Link
|
||||
end
|
||||
|
||||
%% Analog Link
|
||||
[rAL,cAL] = size(NodoAnalogLink);
|
||||
if rAL==0 && cAL==0
|
||||
yesAL = 0; % Non elaboro gli Analog Link
|
||||
else
|
||||
yesAL = 1; % attiva l'elaborazione degli Analog Link
|
||||
end
|
||||
|
||||
%% Therm Link
|
||||
[rThL,cThL] = size(NodoThermLink);
|
||||
if rThL==0 && cThL==0
|
||||
yesThL = 0; % Non elaboro i Settle Link
|
||||
else
|
||||
yesThL = 1; % attiva l'elaborazione dei Settle Link
|
||||
end
|
||||
|
||||
%% Load Link
|
||||
[rLL,cLL] = size(NodoLoadLink);
|
||||
if rLL==0 && cLL==0
|
||||
yesLL = 0; % Non elaboro i Load Link
|
||||
else
|
||||
yesLL = 1; % attiva l'elaborazione dei Load Link
|
||||
end
|
||||
|
||||
%% Tilt Link HR3D
|
||||
[rTLHR3D,cTLHR3D] = size(NodoTiltLinkHR3D);
|
||||
if rTLHR3D==0 && cTLHR3D==0
|
||||
yesTLHR3D = 0; % Non elaboro i Tilt Link HR
|
||||
else
|
||||
yesTLHR3D = 1; % attiva l'elaborazione dei Tilt Link HR
|
||||
end
|
||||
|
||||
%% Tilt Link HR3D H
|
||||
[rTLHR3DH,cTLHR3DH] = size(NodoTiltLinkHR3DH);
|
||||
if rTLHR3DH==0 && cTLHR3DH==0
|
||||
yesTLHR3DH = 0; % Non elaboro i Tilt Link HR H
|
||||
else
|
||||
yesTLHR3DH = 1; % attiva l'elaborazione dei Tilt Link HR H
|
||||
end
|
||||
|
||||
%% Klino Link
|
||||
[rKL,cKL] = size(NodoKlinoLink);
|
||||
if rKL==0 && cKL==0
|
||||
yesKL = 0; % Non elaboro i Klino Link
|
||||
else
|
||||
yesKL = 1; % attiva l'elaborazione dei Klino Link
|
||||
end
|
||||
|
||||
%% Klino Link HR
|
||||
[rKLHR,cKLHR] = size(NodoKlinoLinkHR);
|
||||
if rKLHR==0 && cKLHR==0
|
||||
yesKLHR = 0; % Non elaboro i Klino Link HR
|
||||
else
|
||||
yesKLHR = 1; % attiva l'elaborazione dei Klino Link HR
|
||||
end
|
||||
|
||||
%% Rain Link
|
||||
[rRL,cRL] = size(NodoRainLink);
|
||||
if rRL==0 && cRL==0
|
||||
yesRL = 0; % Non elaboro i Rain Link
|
||||
else
|
||||
yesRL = 1; % attiva l'elaborazione dei Rain Link
|
||||
end
|
||||
|
||||
%% PT100 Link
|
||||
[rPT100,cPT100] = size(NodoPT100Link);
|
||||
if rPT100==0 && cPT100==0
|
||||
yesPT100 = 0; % Non elaboro i PT100 Link
|
||||
else
|
||||
yesPT100 = 1; % attiva l'elaborazione dei PT100 Link
|
||||
end
|
||||
|
||||
%% In Place Link
|
||||
[rIPL,cIPL] = size(NodoInPlaceLink);
|
||||
if rIPL==0 && cIPL==0
|
||||
yesIPL = 0; % Non elaboro In Place Link
|
||||
else
|
||||
yesIPL = 1; % attiva l'elaborazione dei In Place Link
|
||||
end
|
||||
|
||||
%% In Place Link HR
|
||||
[rIPLHR,cIPLHR] = size(NodoInPlaceLinkHR);
|
||||
if rIPLHR==0 && cIPLHR==0
|
||||
yesIPLHR = 0; % Non elaboro In Place Link HR
|
||||
else
|
||||
yesIPLHR = 1; % attiva l'elaborazione dei In Place Link HR
|
||||
end
|
||||
|
||||
%% In Place Link HR 3D
|
||||
[rIPLHR3D,cIPLHR3D] = size(NodoInPlaceLinkHR3D);
|
||||
if rIPLHR3D==0 && cIPLHR3D==0
|
||||
yesIPLHR3D = 0; % Non elaboro In Place Link HR
|
||||
else
|
||||
yesIPLHR3D = 1; % attiva l'elaborazione dei In Place Link HR
|
||||
end
|
||||
|
||||
%% Weir Link
|
||||
[rWL,cWL] = size(NodoWeirLink);
|
||||
if rWL==0 && cWL==0
|
||||
yesWL = 0; % Non elaboro Weir Link
|
||||
else
|
||||
yesWL = 1; % attiva l'elaborazione dei Weir Link
|
||||
end
|
||||
|
||||
%% Pendulum
|
||||
[rPE,cPE] = size(NodoPendulum);
|
||||
if rPE==0 && cPE==0
|
||||
yesPE = 0; % Non elaboro Pendulum
|
||||
else
|
||||
yesPE = 1; % attiva l'elaborazione dei Pendulum
|
||||
end
|
||||
|
||||
%% Wind Link
|
||||
[rWI,cWI] = size(NodoWind);
|
||||
if rWI==0 && cWI==0
|
||||
yesWI = 0; % Non elaboro Wind Link
|
||||
else
|
||||
yesWI = 1; % attiva l'elaborazione
|
||||
end
|
||||
|
||||
%% Tilt Link HD
|
||||
[rHD,cHD] = size(NodoTiltLinkHD);
|
||||
if rHD==0 && cHD==0
|
||||
yesHD = 0; % Non elaboro
|
||||
else
|
||||
yesHD = 1; % attiva l'elaborazione
|
||||
end
|
||||
|
||||
%% Tilt Link HD VR
|
||||
[rHDVR,cHDVR] = size(NodoTiltLinkHDVR);
|
||||
if rHDVR==0 && cHDVR==0
|
||||
yesHDVR = 0; % Non elaboro
|
||||
else
|
||||
yesHDVR = 1; % attiva l'elaborazione
|
||||
end
|
||||
|
||||
%% SPP Link
|
||||
[rSP,cSP] = size(NodoSPPLink);
|
||||
if rSP==0 && cSP==0
|
||||
yesSPP = 0; % Non elaboro gli SPP Link
|
||||
else
|
||||
yesSPP = 1; % attiva l'elaborazione degli SPP Link
|
||||
end
|
||||
|
||||
%% Snow Link
|
||||
[rSL,cSL] = size(NodoSnowLink);
|
||||
if rSL==0 && cSL==0
|
||||
yesSL = 0; % Non elaboro
|
||||
else
|
||||
yesSL = 1; % attiva l'elaborazione
|
||||
end
|
||||
|
||||
text = 'Activation parameters for the elaboration defined correctly. YesNo function ended';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
end
|
||||
476
Tilt/alert_Levels.m
Executable file
476
Tilt/alert_Levels.m
Executable file
@@ -0,0 +1,476 @@
|
||||
function alert_Levels(ARRAYdateRL,IDcentralina,DTcatena,conn,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'alert_Levels function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
alarm1h = 0;
|
||||
alarm24h = 0;
|
||||
alert1h = 0;
|
||||
alert24h = 0;
|
||||
alarm = 0;
|
||||
alert = 0;
|
||||
if strcmp(IDcentralina,'ID0102') && strcmp(DTcatena,'LOC0102') == 1 || strcmp(IDcentralina,'ID0153') && strcmp(DTcatena,'DT0050') == 1 % Pluviometri A27 Cave Est e Fadalto
|
||||
DataScarico = ARRAYdateRL(1)-1.1;
|
||||
% Scarico di dati di pioggia
|
||||
NodeType = 'Rain Link';
|
||||
comando = ['select EventDate, EventTime, Z, calcerr from ElabDataView where EventDate = ''' ...
|
||||
datestr(DataScarico,'yyyy-mm-dd') ''' and EventTime >= ''' datestr(DataScarico,'HH:MM:SS') ''' and UnitName = ''' ...
|
||||
IDcentralina ''' and ToolNameID = ''' DTcatena ''' and NodeType = ''' NodeType ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoRLd = curs.Data;
|
||||
% Scarico di dati di pioggia
|
||||
comando = ['select EventDate, EventTime, Z, calcerr from ElabDataView where EventDate > ''' ...
|
||||
datestr(DataScarico,'yyyy-mm-dd') ''' and UnitName = ''' IDcentralina ''' and ToolNameID = ''' ...
|
||||
DTcatena ''' and NodeType = ''' NodeType ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DATnodoRL = curs.Data;
|
||||
[~,c1] = size(DATnodoRL);
|
||||
[~,c2] = size(DATnodoRLd);
|
||||
if c1 == c2
|
||||
DATnodoRL = [DATnodoRLd; DATnodoRL];
|
||||
elseif c1 < c2 % solo giorno di riferimento
|
||||
DATnodoRL = DATnodoRLd;
|
||||
end
|
||||
% Modifico il formato di data e ora in DATini.
|
||||
[rD,cD] = size(DATnodoRL);
|
||||
if rD ~=1 && cD ~=1
|
||||
T = [cell2mat(DATnodoRL(:,1)) repmat(' ', [rD,1]) cell2mat(DATnodoRL(:,2))];
|
||||
T = datenum(T);
|
||||
% Converto da Cell Array a Matrice.
|
||||
ARRAYdateRL = T;
|
||||
end
|
||||
RainCum = cell2mat(DATnodoRL(:,3));
|
||||
ErrRainLink = cell2mat(DATnodoRL(:,4));
|
||||
|
||||
[numDate,~] = size(ARRAYdateRL);
|
||||
% 24H
|
||||
d = 1;
|
||||
p = 1;
|
||||
diffDate = 0;
|
||||
n = 1;
|
||||
period = 1; % calcolo giornaliero
|
||||
ContSUP = [];
|
||||
Pioggia24h = zeros(numDate,1);
|
||||
for dd = 1:numDate
|
||||
while diffDate < period
|
||||
d = d+1;
|
||||
if d > numDate % Se d supera le date disponibili, esco dal ciclo while
|
||||
break
|
||||
end
|
||||
diffDate = ARRAYdateRL(d) - ARRAYdateRL(p);
|
||||
end
|
||||
if d >numDate
|
||||
break
|
||||
end
|
||||
ContSUP(n,1) = d; %#ok<*AGROW> % Creo matrice indici dell'estremo superiore della differenza
|
||||
ContINF(n,1) = p; % Creo matrice indici dell'estremo inferiore della differenza
|
||||
p = p+1; % passo alla data di partenza successiva
|
||||
d = p; % resetto il conto di d
|
||||
n = n+1;
|
||||
diffDate = 0;
|
||||
end
|
||||
check = isempty(ContSUP);
|
||||
if check == 0
|
||||
[nDate,~] = size(ContSUP);
|
||||
for dd = 1:nDate
|
||||
Pioggia24h(ContSUP(dd,1),1) = RainCum(ContSUP(dd,1))-RainCum(ContINF(dd,1));
|
||||
end
|
||||
end
|
||||
% 1H
|
||||
d = 1;
|
||||
p = 1;
|
||||
diffDate = 0;
|
||||
n = 1;
|
||||
period = 1/24; % calcolo orario
|
||||
ContSUP = [];
|
||||
Pioggia1h = zeros(numDate,1);
|
||||
for dd = 1:numDate
|
||||
while diffDate < period
|
||||
d = d+1;
|
||||
if d > numDate % Se d supera le date disponibili, esco dal ciclo while
|
||||
break
|
||||
end
|
||||
diffDate = ARRAYdateRL(d) - ARRAYdateRL(p);
|
||||
end
|
||||
if d >numDate
|
||||
break
|
||||
end
|
||||
ContSUP(n,1) = d; %#ok<*AGROW> % Creo matrice indici dell'estremo superiore della differenza
|
||||
ContINF(n,1) = p; % Creo matrice indici dell'estremo inferiore della differenza
|
||||
p = p+1; % passo alla data di partenza successiva
|
||||
d = p; % resetto il conto di d
|
||||
n = n+1;
|
||||
diffDate = 0;
|
||||
end
|
||||
check = isempty(ContSUP);
|
||||
if check == 0
|
||||
[nDate,~] = size(ContSUP);
|
||||
for dd = 1:nDate
|
||||
Pioggia1h(ContSUP(dd,1),1) = RainCum(ContSUP(dd,1))-RainCum(ContINF(dd,1));
|
||||
end
|
||||
end
|
||||
% Allerta
|
||||
indexALE1h = zeros(1,2);
|
||||
indexALE24h = zeros(1,2);
|
||||
indexALA1h = zeros(1,2);
|
||||
indexALA24h = zeros(1,2);
|
||||
c1h_ALE = 1;
|
||||
c24h_ALE = 1;
|
||||
c1h_ALA = 1;
|
||||
c24h_ALA = 1;
|
||||
|
||||
% ---SOGLIE---
|
||||
if strcmp(IDcentralina,'ID0102') && strcmp(DTcatena,'LOC0102') == 1
|
||||
soglia1h_ALE = 25; % mm
|
||||
soglia24h_ALE = 90; % mm
|
||||
soglia1h_ALA = 40; % mm
|
||||
soglia24h_ALA = 120; % mm
|
||||
Search_ALE = 1;
|
||||
Search_ALA = 1;
|
||||
elseif strcmp(IDcentralina,'ID0153') && strcmp(DTcatena,'DT0050')
|
||||
soglia1h_ALE = 20; % mm
|
||||
soglia24h_ALE = 80; % mm
|
||||
soglia1h_ALA = 30; % mm
|
||||
soglia24h_ALA = 110; % mm
|
||||
Search_ALE = 1;
|
||||
Search_ALA = 1;
|
||||
end
|
||||
|
||||
for n = 1:numDate
|
||||
%% ALLARMI
|
||||
if Search_ALA == 1
|
||||
if Pioggia1h(n,1) > soglia1h_ALA % mm
|
||||
if ErrRainLink(n,1) == 0 || ErrRainLink(n,1) == 0.5 % Il nodo non è in errore
|
||||
alarm1h = 1;
|
||||
alarm = 1;
|
||||
indexALA1h(c1h_ALA,1) = n; % Data
|
||||
indexALA1h(c1h_ALA,2) = Pioggia1h(n,1); % valore
|
||||
c1h_ALA = c1h_ALA+1;
|
||||
end
|
||||
end
|
||||
if Pioggia24h(n,1) > soglia24h_ALA % mm
|
||||
if ErrRainLink(n,1) == 0 || ErrRainLink(n,1) == 0.5 % Il nodo non è in errore
|
||||
alarm24h = 1;
|
||||
alarm = 1;
|
||||
indexALA24h(c24h_ALA,1) = n; % Data
|
||||
indexALA24h(c24h_ALA,2) = Pioggia24h(n,1); % valore
|
||||
c24h_ALA = c24h_ALA+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
%% ALLERTE
|
||||
if Search_ALE == 1
|
||||
% Oraria
|
||||
if Search_ALA == 1
|
||||
if Pioggia1h(n,1) > soglia1h_ALE && Pioggia1h(n,1) <= soglia1h_ALA % mm
|
||||
continua = 1;
|
||||
else
|
||||
continua = 0;
|
||||
end
|
||||
else
|
||||
if Pioggia1h(n,1) > soglia1h_ALE % mm
|
||||
continua = 1;
|
||||
else
|
||||
continua = 0;
|
||||
end
|
||||
end
|
||||
if continua == 1
|
||||
if ErrRainLink(n,1) == 0 || ErrRainLink(n,1) == 0.5 % Il nodo non è in errore
|
||||
alert1h = 1;
|
||||
alert = 1;
|
||||
indexALE1h(c1h_ALE,1) = n; % Data
|
||||
indexALE1h(c1h_ALE,2) = Pioggia1h(n,1); % valore
|
||||
c1h_ALE = c1h_ALE+1;
|
||||
end
|
||||
end
|
||||
|
||||
% Giornaliera
|
||||
if Search_ALA == 1
|
||||
if Pioggia24h(n,1) > soglia24h_ALE && Pioggia24h(n,1) <= soglia24h_ALA % mm
|
||||
continua = 1;
|
||||
else
|
||||
continua = 0;
|
||||
end
|
||||
else
|
||||
if Pioggia24h(n,1) > soglia24h_ALE % mm
|
||||
continua = 1;
|
||||
else
|
||||
continua = 0;
|
||||
end
|
||||
end
|
||||
if continua == 1
|
||||
if ErrRainLink(n,1) == 0 || ErrRainLink(n,1) == 0.5 % Il nodo non è in errore
|
||||
alert24h = 1;
|
||||
alert = 1;
|
||||
indexALE24h(c24h_ALE,1) = n; % Data
|
||||
indexALE24h(c24h_ALE,2) = Pioggia24h(n,1); % valore
|
||||
c24h_ALE = c24h_ALE+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if alarm == 1 || alert == 1
|
||||
|
||||
%% Controllo la data
|
||||
if strcmp(IDcentralina,'ID0102') == 1 && strcmp(DTcatena,'LOC0102') == 1 || ...
|
||||
strcmp(IDcentralina,'ID0153') == 1 && strcmp(DTcatena,'DT0050') == 1 % Pluviometri A27 Cave Est e Fadalto
|
||||
if alarm1h == 1 && alert1h == 1
|
||||
date1h_ALA = ARRAYdateRL(indexALA1h(:,1));
|
||||
date1h_ALE = ARRAYdateRL(indexALE1h(:,1));
|
||||
elseif alarm1h == 1
|
||||
date1h_ALE = 0;
|
||||
date1h_ALA = ARRAYdateRL(indexALA1h(:,1));
|
||||
elseif alert1h == 1
|
||||
date1h_ALE = ARRAYdateRL(indexALE1h(:,1));
|
||||
date1h_ALA = 0;
|
||||
else
|
||||
date1h_ALA = 0;
|
||||
date1h_ALE = 0;
|
||||
end
|
||||
if alarm24h == 1 && alert24h == 1
|
||||
date24h_ALA = ARRAYdateRL(indexALA24h(:,1));
|
||||
date24h_ALE = ARRAYdateRL(indexALE24h(:,1));
|
||||
elseif alarm24h == 1
|
||||
date24h_ALA = ARRAYdateRL(indexALA24h(:,1));
|
||||
date24h_ALE = 0;
|
||||
elseif alert24h == 1
|
||||
date24h_ALA = 0;
|
||||
date24h_ALE = ARRAYdateRL(indexALE24h(:,1));
|
||||
else
|
||||
date24h_ALA = 0;
|
||||
date24h_ALE = 0;
|
||||
end
|
||||
end
|
||||
DataALE = max(date1h_ALE(end),date24h_ALE(end));
|
||||
DataALA = max(date1h_ALA(end),date24h_ALA(end));
|
||||
|
||||
FileNameALA = ['' IDcentralina '-' DTcatena '-Alarm.txt'];
|
||||
if isfile(FileNameALA) == 1
|
||||
A = importdata(FileNameALA);
|
||||
[rA,~] = size(A);
|
||||
if rA == 0
|
||||
DataRif_ALE = 0;
|
||||
DataRif_ALA = 0;
|
||||
elseif rA == 1
|
||||
DataRif_ALE = A(1,1);
|
||||
DataRif_ALA = 0;
|
||||
else
|
||||
DataRif_ALE = A(1,1);
|
||||
DataRif_ALA = A(2,1);
|
||||
end
|
||||
else
|
||||
DataRif_ALE = 0;
|
||||
DataRif_ALA = 0;
|
||||
end
|
||||
|
||||
if alert == 1 || alarm == 1
|
||||
if alert == 1 && alarm == 1
|
||||
DATA = max(DataALA,DataALE);
|
||||
DataWrite_ALA = DataALA;
|
||||
DataWrite_ALE = DataALE;
|
||||
elseif alert == 1
|
||||
DATA = DataALE;
|
||||
DataWrite_ALE = DataALE;
|
||||
DataWrite_ALA = DataRif_ALA;
|
||||
elseif alarm == 1
|
||||
DATA = DataALA;
|
||||
DataWrite_ALE = DataRif_ALE;
|
||||
DataWrite_ALA = DataALA;
|
||||
end
|
||||
|
||||
% Allerta
|
||||
if alert == 1
|
||||
if date1h_ALE(end) > DataRif_ALE+1
|
||||
mail1h_ALE = 1;
|
||||
else
|
||||
mail1h_ALE = 0;
|
||||
end
|
||||
if date24h_ALE(end) > DataRif_ALE+1
|
||||
mail24h_ALE = 1;
|
||||
else
|
||||
mail24h_ALE = 0;
|
||||
end
|
||||
else
|
||||
mail1h_ALE = 0;
|
||||
mail24h_ALE = 0;
|
||||
end
|
||||
% Allarme
|
||||
if alarm == 1
|
||||
if date1h_ALA(end) > DataRif_ALA+1
|
||||
mail1h_ALA = 1;
|
||||
else
|
||||
mail1h_ALA = 0;
|
||||
end
|
||||
if date24h_ALA(end) > DataRif_ALA+1
|
||||
mail24h_ALA = 1;
|
||||
else
|
||||
mail24h_ALA = 0;
|
||||
end
|
||||
else
|
||||
mail1h_ALA = 0;
|
||||
mail24h_ALA = 0;
|
||||
end
|
||||
else
|
||||
DataWrite_ALE = DataRif_ALE;
|
||||
DataWrite_ALA = DataRif_ALA;
|
||||
fileID = fopen(FileNameALA,'a');
|
||||
outdat = fopen(FileNameALA,'wt+');
|
||||
fmt = '%.10f \r';
|
||||
fprintf(fileID,fmt,DataWrite_ALE);
|
||||
fmt = '%.10f \r';
|
||||
fprintf(fileID,fmt,DataWrite_ALA);
|
||||
fclose(fileID);
|
||||
end
|
||||
|
||||
if mail24h_ALA == 1 || mail24h_ALE == 1 || mail1h_ALA == 1 || mail1h_ALE == 1
|
||||
allarme = 0;
|
||||
allerta = 0;
|
||||
AL = 1;
|
||||
DATAinsert = cell(1,9);
|
||||
if strcmp(IDcentralina,'ID0102') && strcmp(DTcatena,'LOC0102') % Pluviometro A27
|
||||
sms = 1;
|
||||
NodeNum = 2;
|
||||
elseif strcmp(IDcentralina,'ID0153') && strcmp(DTcatena,'DT0050') == 1
|
||||
NodeNum = 1;
|
||||
sms = 1;
|
||||
end
|
||||
%% ALLARMI
|
||||
for ii = 1:c1h_ALA-1 % numero di allarmi orari
|
||||
if mail1h_ALA == 1 && ARRAYdateRL(indexALA1h(ii,1)) > DataRif_ALA+1
|
||||
Level = 3;
|
||||
sms = 1;
|
||||
desc = 'Soglia oraria';
|
||||
Data = datestr(ARRAYdateRL(indexALA1h(ii,1),1),'yyyy-mm-dd HH:MM:SS');
|
||||
Valore = Pioggia1h(indexALA1h(ii,1));
|
||||
DATAinsert{AL,1} = 3; % Allarme tipologia Soglie tradizionali
|
||||
DATAinsert{AL,2} = IDcentralina;
|
||||
DATAinsert{AL,3} = DTcatena;
|
||||
DATAinsert{AL,4} = NodeNum;
|
||||
DATAinsert{AL,5} = Data;
|
||||
DATAinsert{AL,6} = Valore;
|
||||
DATAinsert{AL,7} = Level;
|
||||
DATAinsert{AL,8} = sms;
|
||||
DATAinsert{AL,9} = desc;
|
||||
allarme = 1;
|
||||
AL = AL+1;
|
||||
end
|
||||
end
|
||||
for ii = 1:c24h_ALA-1 % numero di allarmi giornalieri
|
||||
if mail24h_ALA == 1 && ARRAYdateRL(indexALA24h(ii,1)) > DataRif_ALA+1
|
||||
Level = 4;
|
||||
sms = 1;
|
||||
desc = 'Soglia giornaliera';
|
||||
Data = datestr(ARRAYdateRL(indexALA24h(ii,1),1),'yyyy-mm-dd HH:MM:SS');
|
||||
Valore = Pioggia24h(indexALA24h(ii,1));
|
||||
DATAinsert{AL,1} = 3; % Allarme tipologia Soglie tradizionali
|
||||
DATAinsert{AL,2} = IDcentralina;
|
||||
DATAinsert{AL,3} = DTcatena;
|
||||
DATAinsert{AL,4} = NodeNum;
|
||||
DATAinsert{AL,5} = Data;
|
||||
DATAinsert{AL,6} = Valore;
|
||||
DATAinsert{AL,7} = Level;
|
||||
DATAinsert{AL,8} = sms;
|
||||
DATAinsert{AL,9} = desc;
|
||||
allarme = 1;
|
||||
AL = AL+1;
|
||||
end
|
||||
end
|
||||
%% Allerte
|
||||
for ii = 1:c1h_ALE-1 % numero di allerte orarie
|
||||
if mail1h_ALE == 1 && ARRAYdateRL(indexALE1h(ii,1)) > DataRif_ALE+1
|
||||
Level = 1;
|
||||
desc = 'Soglia oraria';
|
||||
Data = datestr(ARRAYdateRL(indexALE1h(ii,1),1),'yyyy-mm-dd HH:MM:SS');
|
||||
Valore = Pioggia1h(indexALE1h(ii,1));
|
||||
DATAinsert{AL,1} = 3; % Allarme tipologia Soglie tradizionali
|
||||
DATAinsert{AL,2} = IDcentralina;
|
||||
DATAinsert{AL,3} = DTcatena;
|
||||
DATAinsert{AL,4} = NodeNum;
|
||||
DATAinsert{AL,5} = Data;
|
||||
DATAinsert{AL,6} = Valore;
|
||||
DATAinsert{AL,7} = Level;
|
||||
DATAinsert{AL,8} = sms;
|
||||
DATAinsert{AL,9} = desc;
|
||||
allerta = 1;
|
||||
AL = AL+1;
|
||||
end
|
||||
end
|
||||
for ii = 1:c24h_ALE-1 % numero di alerte giornaliere
|
||||
if mail24h_ALE == 1 && ARRAYdateRL(indexALE24h(ii,1)) > DataRif_ALE+1
|
||||
Level = 2;
|
||||
desc = 'Soglia giornaliera';
|
||||
Data = datestr(ARRAYdateRL(indexALE24h(ii,1),1),'yyyy-mm-dd HH:MM:SS');
|
||||
Valore = Pioggia24h(indexALE24h(ii,1));
|
||||
DATAinsert{AL,1} = 3; % Allarme tipologia Soglie tradizionali
|
||||
DATAinsert{AL,2} = IDcentralina;
|
||||
DATAinsert{AL,3} = DTcatena;
|
||||
DATAinsert{AL,4} = NodeNum;
|
||||
DATAinsert{AL,5} = Data;
|
||||
DATAinsert{AL,6} = Valore;
|
||||
DATAinsert{AL,7} = Level;
|
||||
DATAinsert{AL,8} = sms;
|
||||
DATAinsert{AL,9} = desc;
|
||||
allerta = 1;
|
||||
AL = AL+1;
|
||||
end
|
||||
end
|
||||
|
||||
if allarme == 1 || allerta == 1
|
||||
AL = AL-1; % Numero totale di allarmi
|
||||
for a = 1:AL
|
||||
% Cerco se il dato è già presente
|
||||
Data = DATAinsert{a,5};
|
||||
nNodo = num2str(DATAinsert{a,4}); % Numero nodo
|
||||
type = num2str(DATAinsert{a,1}); % tipologia
|
||||
level = num2str(DATAinsert{a,7}); % livello allarme
|
||||
value = num2str(DATAinsert{a,6}); % Valore
|
||||
desc = DATAinsert{a,9}; % Descrizione
|
||||
comando = ['select id, type_id, date_time from alarms where unit_name = ''' ...
|
||||
IDcentralina ''' and tool_name = ''' DTcatena ''' and node_num = ''' ...
|
||||
nNodo ''' and date_time = ''' Data ''' and type_id = ''' type ...
|
||||
''' and alarm_level = ''' level ''' and registered_value = ''' value ...
|
||||
''' and description like ''' desc ''' order by date_time'];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
idDate = curs.Data;
|
||||
[~,cI] = size(idDate);
|
||||
if cI == 1
|
||||
idElabData = 0; % 0 indica che il dato non è presente su DB
|
||||
else
|
||||
idElabData = cell2mat(idDate(:,1));
|
||||
end
|
||||
tablename = 'alarms';
|
||||
colnames = {'type_id','unit_name','tool_name','node_num','date_time',...
|
||||
'registered_value','alarm_level','send_sms','description'};
|
||||
data = [DATAinsert(a,1),DATAinsert(a,2),DATAinsert(a,3),DATAinsert(a,4),...
|
||||
DATAinsert(a,5),DATAinsert(a,6),DATAinsert(a,7),DATAinsert(a,8),DATAinsert(a,9)];
|
||||
if idElabData == 0 % Scrivo
|
||||
fastinsert(conn,tablename,colnames,data);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
fileID = fopen(FileNameALA,'a');
|
||||
outdat = fopen(FileNameALA,'wt+');
|
||||
fmt = '%.10f \r';
|
||||
fprintf(fileID,fmt,DataWrite_ALE);
|
||||
fmt = '%.10f \r';
|
||||
fprintf(fileID,fmt,DataWrite_ALA);
|
||||
fclose(fileID);
|
||||
end
|
||||
end
|
||||
|
||||
text = ('alert_Levels function worked correctly');
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
73
Tilt/approx.m
Executable file
73
Tilt/approx.m
Executable file
@@ -0,0 +1,73 @@
|
||||
% Funzione che approssima il dato alla quarta cifra decimale (decimi di
|
||||
% millimetri)
|
||||
function [X,Y,Z,Xlocal,Ylocal,Zlocal,HShift,HShift_local,Azimuth,Speed,...
|
||||
Speed_local,Acceleration,Acceleration_local,TempDef_TL] = approx(X,Y,Z,...
|
||||
Xlocal,Ylocal,Zlocal,HShift,HShift_local,Azimuth,Speed,Speed_local,...
|
||||
Acceleration,Acceleration_local,TempDef_TL,FileName)
|
||||
|
||||
text = 'approx function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
conv = X*10000;
|
||||
conv = round(conv);
|
||||
X = conv/10000;
|
||||
|
||||
conv = Y*10000;
|
||||
conv = round(conv);
|
||||
Y = conv/10000;
|
||||
|
||||
conv = Z*10000;
|
||||
conv = round(conv);
|
||||
Z = conv/10000;
|
||||
|
||||
conv = Xlocal*10000;
|
||||
conv = round(conv);
|
||||
Xlocal = conv/10000;
|
||||
|
||||
conv = Ylocal*10000;
|
||||
conv = round(conv);
|
||||
Ylocal = conv/10000;
|
||||
|
||||
conv = Zlocal*1000000;
|
||||
conv = round(conv);
|
||||
Zlocal = conv/1000000;
|
||||
|
||||
conv = HShift*10000;
|
||||
conv = round(conv);
|
||||
HShift = conv/10000;
|
||||
|
||||
conv = HShift_local*10000;
|
||||
conv = round(conv);
|
||||
HShift_local = conv/10000;
|
||||
|
||||
conv = Azimuth*10;
|
||||
conv = round(conv);
|
||||
Azimuth = conv/10;
|
||||
|
||||
conv = Acceleration_local*10000;
|
||||
conv = round(conv);
|
||||
Acceleration_local = conv/10000;
|
||||
|
||||
conv = Speed*10000;
|
||||
conv = round(conv);
|
||||
Speed = conv/10000;
|
||||
|
||||
conv = Speed_local*10000;
|
||||
conv = round(conv);
|
||||
Speed_local = conv/10000;
|
||||
|
||||
conv = Acceleration*10000;
|
||||
conv = round(conv);
|
||||
Acceleration = conv/10000;
|
||||
|
||||
conv = TempDef_TL*10;
|
||||
conv = round(conv);
|
||||
TempDef_TL = conv/10;
|
||||
|
||||
text = 'approx function executed correctly';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
73
Tilt/approx_HD.m
Executable file
73
Tilt/approx_HD.m
Executable file
@@ -0,0 +1,73 @@
|
||||
% Funzione che approssima il dato alla quarta cifra decimale (decimi di
|
||||
% millimetri)
|
||||
function [X_HD,Y_HD,Z_HD,Xlocal_HD,Ylocal_HD,Zlocal_HD,HShift_HD,HShift_local_HD,Azimuth_HD,Speed_HD,...
|
||||
Speed_local_HD,Acceleration_HD,Acceleration_local_HD,TempDef_HD] = approx_HD(X_HD,Y_HD,Z_HD,...
|
||||
Xlocal_HD,Ylocal_HD,Zlocal_HD,HShift_HD,HShift_local_HD,Azimuth_HD,Speed_HD,Speed_local_HD,...
|
||||
Acceleration_HD,Acceleration_local_HD,TempDef_HD,FileName)
|
||||
|
||||
text = 'approx function started';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
conv = X_HD*100000;
|
||||
conv = round(conv);
|
||||
X_HD = conv/100000;
|
||||
|
||||
conv = Y_HD*100000;
|
||||
conv = round(conv);
|
||||
Y_HD = conv/100000;
|
||||
|
||||
conv = Z_HD*100000;
|
||||
conv = round(conv);
|
||||
Z_HD = conv/100000;
|
||||
|
||||
conv = Xlocal_HD*100000;
|
||||
conv = round(conv);
|
||||
Xlocal_HD = conv/100000;
|
||||
|
||||
conv = Ylocal_HD*100000;
|
||||
conv = round(conv);
|
||||
Ylocal_HD = conv/100000;
|
||||
|
||||
conv = Zlocal_HD*10000000;
|
||||
conv = round(conv);
|
||||
Zlocal_HD = conv/10000000;
|
||||
|
||||
conv = HShift_HD*100000;
|
||||
conv = round(conv);
|
||||
HShift_HD = conv/100000;
|
||||
|
||||
conv = HShift_local_HD*100000;
|
||||
conv = round(conv);
|
||||
HShift_local_HD = conv/100000;
|
||||
|
||||
conv = Azimuth_HD*10;
|
||||
conv = round(conv);
|
||||
Azimuth_HD = conv/10;
|
||||
|
||||
conv = Acceleration_local_HD*10000;
|
||||
conv = round(conv);
|
||||
Acceleration_local_HD = conv/10000;
|
||||
|
||||
conv = Speed_HD*10000;
|
||||
conv = round(conv);
|
||||
Speed_HD = conv/10000;
|
||||
|
||||
conv = Speed_local_HD*10000;
|
||||
conv = round(conv);
|
||||
Speed_local_HD = conv/10000;
|
||||
|
||||
conv = Acceleration_HD*10000;
|
||||
conv = round(conv);
|
||||
Acceleration_HD = conv/10000;
|
||||
|
||||
conv = TempDef_HD*10;
|
||||
conv = round(conv);
|
||||
TempDef_HD = conv/10;
|
||||
|
||||
text = 'approx function executed correctly';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
71
Tilt/approx_IPLHR.m
Executable file
71
Tilt/approx_IPLHR.m
Executable file
@@ -0,0 +1,71 @@
|
||||
% Funzione che approssima il dato alla quarta cifra decimale (decimi di
|
||||
% millimetri)
|
||||
function [X_IPLHR,Y_IPLHR,Z_IPLHR,Xlocal_IPLHR,Ylocal_IPLHR,Zlocal_IPLHR,HShift_IPLHR,...
|
||||
HShift_local_IPLHR,Azimuth_IPLHR,Speed_IPLHR,Speed_local_IPLHR,Acceleration_IPLHR,...
|
||||
Acceleration_local_IPLHR,TempDef_IPLHR] = approx_IPLHR(X_IPLHR,Y_IPLHR,Z_IPLHR,...
|
||||
Xlocal_IPLHR,Ylocal_IPLHR,Zlocal_IPLHR,HShift_IPLHR,HShift_local_IPLHR,Azimuth_IPLHR,...
|
||||
Speed_IPLHR,Speed_local_IPLHR,Acceleration_IPLHR,Acceleration_local_IPLHR,TempDef_IPLHR,FileName)
|
||||
|
||||
conv = X_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
X_IPLHR = conv/1000000;
|
||||
|
||||
conv = Y_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
Y_IPLHR = conv/1000000;
|
||||
|
||||
conv = Z_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
Z_IPLHR = conv/1000000;
|
||||
|
||||
conv = Xlocal_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
Xlocal_IPLHR = conv/1000000;
|
||||
|
||||
conv = Ylocal_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
Ylocal_IPLHR = conv/1000000;
|
||||
|
||||
conv = Zlocal_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
Zlocal_IPLHR = conv/1000000;
|
||||
|
||||
conv = HShift_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
HShift_IPLHR = conv/1000000;
|
||||
|
||||
conv = HShift_local_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
HShift_local_IPLHR = conv/1000000;
|
||||
|
||||
conv = Azimuth_IPLHR*10;
|
||||
conv = round(conv);
|
||||
Azimuth_IPLHR = conv/10;
|
||||
|
||||
conv = Acceleration_local_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
Acceleration_local_IPLHR = conv/1000000;
|
||||
|
||||
conv = Speed_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
Speed_IPLHR = conv/1000000;
|
||||
|
||||
conv = Speed_local_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
Speed_local_IPLHR = conv/1000000;
|
||||
|
||||
conv = Acceleration_IPLHR*1000000;
|
||||
conv = round(conv);
|
||||
Acceleration_IPLHR = conv/1000000;
|
||||
|
||||
conv = TempDef_IPLHR*10;
|
||||
conv = round(conv);
|
||||
TempDef_IPLHR = conv/10;
|
||||
|
||||
text = 'approx_TLHR function executed correctly';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
59
Tilt/approx_TLH.m
Executable file
59
Tilt/approx_TLH.m
Executable file
@@ -0,0 +1,59 @@
|
||||
% Funzione che approssima il dato alla quarta cifra decimale (decimi di
|
||||
% millimetri)
|
||||
function [Y_TLH,Z_TLH,Ylocal_TLH,Zlocal_TLH,speed_TLH,speed_local_TLH,...
|
||||
acceleration_TLH,acceleration_local_TLH,TempDef_TLH] = approx_TLH(...
|
||||
Y_TLH,Z_TLH,Ylocal_TLH,Zlocal_TLH,speed_TLH,speed_local_TLH,...
|
||||
acceleration_TLH,acceleration_local_TLH,TempDef_TLH,FileName)
|
||||
|
||||
% Y
|
||||
conv = Y_TLH*100000;
|
||||
conv = round(conv);
|
||||
Y_TLH = conv/100000;
|
||||
|
||||
% Y local
|
||||
conv = Ylocal_TLH*100000;
|
||||
conv = round(conv);
|
||||
Ylocal_TLH = conv/100000;
|
||||
|
||||
% Z
|
||||
conv = Z_TLH*100000;
|
||||
conv = round(conv);
|
||||
Z_TLH = conv/100000;
|
||||
|
||||
% Z local
|
||||
conv = Zlocal_TLH*100000;
|
||||
conv = round(conv);
|
||||
Zlocal_TLH = conv/100000;
|
||||
|
||||
% Velocità
|
||||
conv = speed_TLH*100000;
|
||||
conv = round(conv);
|
||||
speed_TLH = conv/100000;
|
||||
|
||||
% Velocità locale
|
||||
conv = speed_local_TLH*100000;
|
||||
conv = round(conv);
|
||||
speed_local_TLH = conv/100000;
|
||||
|
||||
% Accelerazione
|
||||
conv = acceleration_TLH*100000;
|
||||
conv = round(conv);
|
||||
acceleration_TLH = conv/100000;
|
||||
|
||||
% Accelerazione locale
|
||||
conv = acceleration_local_TLH*100000;
|
||||
conv = round(conv);
|
||||
acceleration_local_TLH = conv/100000;
|
||||
|
||||
% TempDef
|
||||
conv = TempDef_TLH*10;
|
||||
conv = round(conv);
|
||||
TempDef_TLH = conv/10;
|
||||
|
||||
text = 'approx_TLH function executed correctly';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
71
Tilt/approx_TLHR.m
Executable file
71
Tilt/approx_TLHR.m
Executable file
@@ -0,0 +1,71 @@
|
||||
% Funzione che approssima il dato alla quarta cifra decimale (decimi di
|
||||
% millimetri)
|
||||
function [X_HR,Y_HR,Z_HR,Xlocal_HR,Ylocal_HR,Zlocal_HR,HShift_HR,...
|
||||
HShift_local_HR,Azimuth_HR,Speed_HR,Speed_local_HR,Acceleration_HR,...
|
||||
Acceleration_local_HR,TempDef_TLHR] = approx_TLHR(X_HR,Y_HR,Z_HR,...
|
||||
Xlocal_HR,Ylocal_HR,Zlocal_HR,HShift_HR,HShift_local_HR,Azimuth_HR,...
|
||||
Speed_HR,Speed_local_HR,Acceleration_HR,Acceleration_local_HR,TempDef_TLHR,FileName)
|
||||
|
||||
conv = X_HR*1000000;
|
||||
conv = round(conv);
|
||||
X_HR = conv/1000000;
|
||||
|
||||
conv = Y_HR*1000000;
|
||||
conv = round(conv);
|
||||
Y_HR = conv/1000000;
|
||||
|
||||
conv = Z_HR*1000000;
|
||||
conv = round(conv);
|
||||
Z_HR = conv/1000000;
|
||||
|
||||
conv = Xlocal_HR*1000000;
|
||||
conv = round(conv);
|
||||
Xlocal_HR = conv/1000000;
|
||||
|
||||
conv = Ylocal_HR*1000000;
|
||||
conv = round(conv);
|
||||
Ylocal_HR = conv/1000000;
|
||||
|
||||
conv = Zlocal_HR*1000000;
|
||||
conv = round(conv);
|
||||
Zlocal_HR = conv/1000000;
|
||||
|
||||
conv = HShift_HR*1000000;
|
||||
conv = round(conv);
|
||||
HShift_HR = conv/1000000;
|
||||
|
||||
conv = HShift_local_HR*1000000;
|
||||
conv = round(conv);
|
||||
HShift_local_HR = conv/1000000;
|
||||
|
||||
conv = Azimuth_HR*10;
|
||||
conv = round(conv);
|
||||
Azimuth_HR = conv/10;
|
||||
|
||||
conv = Acceleration_local_HR*1000000;
|
||||
conv = round(conv);
|
||||
Acceleration_local_HR = conv/1000000;
|
||||
|
||||
conv = Speed_HR*1000000;
|
||||
conv = round(conv);
|
||||
Speed_HR = conv/1000000;
|
||||
|
||||
conv = Speed_local_HR*1000000;
|
||||
conv = round(conv);
|
||||
Speed_local_HR = conv/1000000;
|
||||
|
||||
conv = Acceleration_HR*1000000;
|
||||
conv = round(conv);
|
||||
Acceleration_HR = conv/1000000;
|
||||
|
||||
conv = TempDef_TLHR*10;
|
||||
conv = round(conv);
|
||||
TempDef_TLHR = conv/10;
|
||||
|
||||
text = 'approx_TLHR function executed correctly';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
59
Tilt/approx_TLHRH.m
Executable file
59
Tilt/approx_TLHRH.m
Executable file
@@ -0,0 +1,59 @@
|
||||
% Funzione che approssima il dato alla quarta cifra decimale (decimi di
|
||||
% millimetri)
|
||||
function [Y_TLHRH,Z_TLHRH,Ylocal_TLHRH,Zlocal_TLHRH,speed_TLHRH,speed_local_TLHRH,...
|
||||
acceleration_TLHRH,acceleration_local_TLHRH,TempDef_TLHRH] = approx_TLHRH(...
|
||||
Y_TLHRH,Z_TLHRH,Ylocal_TLHRH,Zlocal_TLHRH,speed_TLHRH,speed_local_TLHRH,...
|
||||
acceleration_TLHRH,acceleration_local_TLHRH,TempDef_TLHRH,FileName)
|
||||
|
||||
% Y
|
||||
conv = Y_TLHRH*10000;
|
||||
conv = round(conv);
|
||||
Y_TLHRH = conv/10000;
|
||||
|
||||
% Y local
|
||||
conv = Ylocal_TLHRH*10000;
|
||||
conv = round(conv);
|
||||
Ylocal_TLHRH = conv/10000;
|
||||
|
||||
% Z
|
||||
conv = Z_TLHRH*10000;
|
||||
conv = round(conv);
|
||||
Z_TLHRH = conv/10000;
|
||||
|
||||
% Z local
|
||||
conv = Zlocal_TLHRH*10000;
|
||||
conv = round(conv);
|
||||
Zlocal_TLHRH = conv/10000;
|
||||
|
||||
% Velocità
|
||||
conv = speed_TLHRH*10000;
|
||||
conv = round(conv);
|
||||
speed_TLHRH = conv/10000;
|
||||
|
||||
% Velocità locale
|
||||
conv = speed_local_TLHRH*10000;
|
||||
conv = round(conv);
|
||||
speed_local_TLHRH = conv/10000;
|
||||
|
||||
% Accelerazione
|
||||
conv = acceleration_TLHRH*10000;
|
||||
conv = round(conv);
|
||||
acceleration_TLHRH = conv/10000;
|
||||
|
||||
% Accelerazione locale
|
||||
conv = acceleration_local_TLHRH*10000;
|
||||
conv = round(conv);
|
||||
acceleration_local_TLHRH = conv/10000;
|
||||
|
||||
% TempDef
|
||||
conv = TempDef_TLHRH*10;
|
||||
conv = round(conv);
|
||||
TempDef_TLHRH = conv/10;
|
||||
|
||||
text = 'approx_TLHRH function executed correctly';
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
13
Tilt/arot.m
Executable file
13
Tilt/arot.m
Executable file
@@ -0,0 +1,13 @@
|
||||
function angle = arot(mx,my,j,i) %Unit vectors
|
||||
|
||||
if my(i,j)>0
|
||||
angle = 90-(atan(mx(i,j)/my(i,j)))*180/pi;
|
||||
elseif my(i,j)<0
|
||||
angle = 270-(atan(mx(i,j)/my(i,j)))*180/pi;
|
||||
elseif (my(i,j)==0)&&(mx(i,j)<0)
|
||||
angle = 180.0;
|
||||
elseif (my(i,j)==0)&&(mx(i,j)>0)
|
||||
angle = 0.0;
|
||||
end
|
||||
|
||||
end
|
||||
15
Tilt/arotHR.m
Executable file
15
Tilt/arotHR.m
Executable file
@@ -0,0 +1,15 @@
|
||||
function angle = arotHR(mx,my,j) %Unit vectors
|
||||
|
||||
i = 1;
|
||||
% j è la data
|
||||
if my(i,j)>0
|
||||
angle = 90-(atan(mx(i,j)/my(i,j)))*180/pi;
|
||||
elseif my(i,j)<0
|
||||
angle = 270-(atan(mx(i,j)/my(i,j)))*180/pi;
|
||||
elseif (my(i,j)==0)&&(mx(i,j)<0)
|
||||
angle = 180.0;
|
||||
elseif (my(i,j)==0)&&(mx(i,j)>0)
|
||||
angle = 0.0;
|
||||
end
|
||||
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user