283 lines
12 KiB
Matlab
Executable File
283 lines
12 KiB
Matlab
Executable File
function [ATTIVA,FIG,FIG_ENG] = report_KLHR(rKLHR,m,NodoKlinoLinkHR,toolrif,unitrif,...
|
|
datarif,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,ATTIVA,...
|
|
activeEN,conn,FileName)
|
|
|
|
fileID = fopen(FileName,'a');
|
|
fmt = '%s \r';
|
|
text = 'report_KLHR function started';
|
|
fprintf(fileID,fmt,text);
|
|
|
|
import mlreportgen.dom.*
|
|
import mlreportgen.report.*
|
|
|
|
% Make sure DOM is compilable
|
|
makeDOMCompilable()
|
|
|
|
if status(m,1) == 1
|
|
if ATTIVA == 1
|
|
ATTIVA = 0;
|
|
testo = Paragraph('Catena non ancora installata o inattiva.');
|
|
add(DT,testo);
|
|
if activeEN == 1
|
|
testo = Paragraph('Array not installed or inactive.');
|
|
add(DT_ENG,testo);
|
|
end
|
|
end
|
|
elseif status(m,1) == 3
|
|
if ATTIVA == 1
|
|
ATTIVA = 0;
|
|
testo = Paragraph(['Monitoraggio completato. Invitiamo a visitare la '...
|
|
'piattaforma web per la visione dei dati storici.']);
|
|
add(DT,testo);
|
|
if activeEN == 1
|
|
testo = Paragraph(['Monitoring completed. Please log into the web-based platform '...
|
|
'to access the complete dataset.']);
|
|
add(DT_ENG,testo);
|
|
end
|
|
end
|
|
else
|
|
KL = Section();
|
|
if activeEN == 1
|
|
KL_EN = Section();
|
|
end
|
|
titolo = 1;
|
|
|
|
for k = 1:rKLHR(m,1)
|
|
NodeNum = num2str(NodoKlinoLinkHR(k,m));
|
|
comando = ['select EventDate, EventTime, XShift, YShift, T_node from ElabDataView where EventDate >= ''' ...
|
|
datarif ''' and ToolNameID = ''' char(toolrif) ''' and UnitName = ''' char(unitrif) ...
|
|
''' and NodeNum = ''' NodeNum ''' '];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
Dati = curs.Data;
|
|
% Modifico il formato di data e ora
|
|
[rD,rC] = size(Dati);
|
|
if rC ~= 1
|
|
T = [cell2mat(Dati(:,1)) repmat(' ', [rD,1]) cell2mat(Dati(:,2))];
|
|
Date = datenum(T); % Data
|
|
TiltX = cell2mat(Dati(:,3)); % asse x
|
|
TiltY = cell2mat(Dati(:,4)); % asse y
|
|
TempKLHR = cell2mat(Dati(:,5)); % temperatura
|
|
|
|
% grafico inclinazione-tempo asse X,Y NELL'ULTIMO MESE
|
|
figure(1)
|
|
subplot(2,1,1); % (righe colonne posizione)
|
|
pbaspect([3 1 1]);
|
|
yyaxis left
|
|
InclX = plot(Date,TiltX);
|
|
if isnan(TempKLHR) == 0
|
|
yyaxis right
|
|
TempKLHR_X = plot(Date,TempKLHR,':','LineWidth',1.1);
|
|
yyaxis right
|
|
ylabel(['Temperatura [' char(176) 'C]']);
|
|
set(gca,'YColor','k');
|
|
end
|
|
title(['Inclinazione clinometro ' NodeNum ' - asse X']);
|
|
xlabel('Data [gg/mm/aaaa]');
|
|
yyaxis left
|
|
ylabel(['Inclinazione [' char(176) ']']);
|
|
set(gca,'YColor','k');
|
|
|
|
h = gca;
|
|
h.XAxis.MinorTick = 'on';
|
|
datetick('x','dd/mm/yyyy','keepticks','keeplimits');
|
|
xtickangle(12);
|
|
grid on
|
|
grid minor
|
|
|
|
hold off
|
|
subplot(2,1,2)
|
|
pbaspect([3 1 1]);
|
|
yyaxis left
|
|
InclY = plot(Date,TiltY);
|
|
if isnan(TempKLHR) == 0
|
|
yyaxis right
|
|
TempKLHR_Y = plot(Date,TempKLHR,':','LineWidth',1.1);
|
|
yyaxis right
|
|
ylabel(['Temperatura [' char(176) 'C]']);
|
|
set(gca,'YColor','k');
|
|
end
|
|
title(['Inclinazione clinometro ' NodeNum ' - asse Y']);
|
|
xlabel('Data [gg/mm/aaaa]');
|
|
yyaxis left
|
|
ylabel(['Inclinazione [' char(176) ']']);
|
|
set(gca,'YColor','k');
|
|
h = gca;
|
|
h.XAxis.MinorTick = 'on';
|
|
datetick('x','dd/mm/yyyy','keepticks','keeplimits');
|
|
xtickangle(12);
|
|
grid on
|
|
grid minor
|
|
|
|
legendaKL = Image(('legendaKL.png'));
|
|
legendaKL.Style = {Height('0.7cm'),HAlign('center')};
|
|
|
|
TempName = char(strcat('Report',siteID,'-', char(toolrif),'-KlinoHR', NodeNum, '.png'));
|
|
saveas(InclY,TempName);
|
|
ChartKLHR = Image(TempName);
|
|
ChartKLHR.Style = {ScaleToFit};
|
|
ChartKLHR_cap = Paragraph(['Fig. ' num2str(FIG) ' - Inclinazione in direzione strumentale X e Y '...
|
|
'registrata dal sensore elettrolitico durante il periodo temporale di riferimento']);
|
|
FIG = FIG+1;
|
|
ChartKLHR_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
|
if titolo == 1
|
|
sezKlinoHR = Heading3('Klino Link HR');
|
|
sezKlinoHR.Style = {OuterMargin('0in','0in','0.15in','0in'),FontSize(Font_tools),Bold(1),Italic(1)};
|
|
KL.Title = sezKlinoHR;
|
|
add(DT,sezKlinoHR);
|
|
if activeEN == 0
|
|
titolo = 0;
|
|
end
|
|
end
|
|
|
|
testo = Paragraph(['I grafici seguenti riportano i valori di inclinazione assoluta misurati dal Nodo ' NodeNum ...
|
|
' lungo gli assi strumentali X e Y del sensore elettrolitico nell''ultimo mese di monitoraggio. ']);
|
|
testo2 = Paragraph(['In questo periodo di tempo, il sensore ha rilevato un''inclinazione massima lungo l''asse X '...
|
|
'pari a ' num2str(round(max(TiltX),2), '%0.2f') '' char(176) ' ed un valore minimo pari a '...
|
|
num2str(round(min(TiltX),2), '%0.2f') '' char(176) ', per una variazione massima uguale a '...
|
|
num2str(round(max(TiltX)-min(TiltX),2), '%0.2f')...
|
|
char(176) '. Per quanto riguarda l''asse Y, i valori massimi e minimi sono rispettivamente '...
|
|
' pari a ' num2str(round(max(TiltY),2), '%0.2f') '' char(176) ' e ' num2str(round(min(TiltY),2), '%0.2f')...
|
|
char(176) ', con una variazione massima di ' num2str(round(max(TiltY)-min(TiltY),2), '%0.2f')...
|
|
char(176) ' di inclinazione.']);
|
|
testo.HAlign = 'justify';
|
|
testo2.HAlign = 'justify';
|
|
if titolo == 1
|
|
sezKlinoHR = Heading3('Klino Link HR');
|
|
sezKlinoHR.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
|
|
KL = Section();
|
|
KL.Title = sezKlinoHR;
|
|
add(DT,sezKlinoHR);
|
|
titolo = 0;
|
|
end
|
|
add(DT,testo);
|
|
add(DT,testo2);
|
|
add(DT,ChartKLHR);
|
|
add(DT,legendaKL);
|
|
add(DT,ChartKLHR_cap);
|
|
add(DT,br);
|
|
close(figure(1));
|
|
|
|
if activeEN == 1
|
|
% grafico inclinazione-tempo asse X,Y NELL'ULTIMO MESE
|
|
figure(1)
|
|
subplot(2,1,1); % (righe colonne posizione)
|
|
pbaspect([3 1 1]);
|
|
yyaxis left
|
|
InclX = plot(Date,TiltX);
|
|
if isnan(TempKLHR) == 0
|
|
yyaxis right
|
|
TempKLHR_X = plot(Date,TempKLHR,':','LineWidth',1.1);
|
|
yyaxis right
|
|
ylabel(['Temperature [' char(176) 'C]']);
|
|
set(gca,'YColor','k');
|
|
end
|
|
title(['Tilt ' NodeNum ' - X axis']);
|
|
xlabel('Date [dd/mm/yyyy]');
|
|
yyaxis left
|
|
ylabel(['Tilt [' char(176) ']']);
|
|
set(gca,'YColor','k');
|
|
|
|
h = gca;
|
|
h.XAxis.MinorTick = 'on';
|
|
datetick('x','dd/mm/yyyy','keepticks','keeplimits');
|
|
xtickangle(12);
|
|
grid on
|
|
grid minor
|
|
|
|
hold off
|
|
subplot(2,1,2)
|
|
pbaspect([3 1 1]);
|
|
yyaxis left
|
|
InclY = plot(Date,TiltY);
|
|
if isnan(TempKLHR) == 0
|
|
yyaxis right
|
|
TempKLHR_Y = plot(Date,TempKLHR,':','LineWidth',1.1);
|
|
yyaxis right
|
|
ylabel(['Temperature [' char(176) 'C]']);
|
|
set(gca,'YColor','k');
|
|
end
|
|
title(['Tilt ' NodeNum ' - Y axis']);
|
|
xlabel('Date [dd/mm/yyyy]');
|
|
yyaxis left
|
|
ylabel(['Tilt [' char(176) ']']);
|
|
set(gca,'YColor','k');
|
|
h = gca;
|
|
h.XAxis.MinorTick = 'on';
|
|
datetick('x','dd/mm/yyyy','keepticks','keeplimits');
|
|
xtickangle(12);
|
|
grid on
|
|
grid minor
|
|
|
|
TempName = char(strcat('Report',siteID,'-', char(toolrif),'-KlinoHR', NodeNum, '_ENG.png'));
|
|
saveas(InclY,TempName);
|
|
ChartKLHR = Image(TempName);
|
|
ChartKLHR.Style = {ScaleToFit};
|
|
ChartKLHR_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Tilt recorded by electrolytic tilt sensor '...
|
|
'during the reference monitoring period along X and Y instrumental axes of node '...
|
|
NodeNum '']);
|
|
FIG_ENG = FIG_ENG+1;
|
|
ChartKLHR_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
|
|
|
if titolo == 1
|
|
if activeEN == 0
|
|
KL_EN.Title = sezKlinoHR;
|
|
add(DT_ENG,sezKlinoHR);
|
|
titolo = 0;
|
|
end
|
|
end
|
|
|
|
testo = Paragraph(['The following graphs show the absolute tilt angles recorded along X and Y '...
|
|
'instrumental axes during the reference monitoring period.']);
|
|
testo2 = Paragraph(['Node number ' NodeNum ' highlighted a maximum and a minimum tilt of '...
|
|
num2str(round(max(TiltX),2), '%0.2f') '' char(176) ' and '...
|
|
num2str(round(min(TiltX),2), '%0.2f') '' char(176) ' along the X axis. The angle variation equals '...
|
|
num2str(round(max(TiltX)-min(TiltX),2), '%0.2f')...
|
|
char(176) '. Y axis showed maximum and minimum values equal to '...
|
|
num2str(round(max(TiltY),2), '%0.2f') '' char(176) ' and ' num2str(round(min(TiltY),2), '%0.2f')...
|
|
char(176) ', while the variation is ' num2str(round(max(TiltY)-min(TiltY),2), '%0.2f')...
|
|
char(176) '.']);
|
|
testo.HAlign = 'justify';
|
|
testo2.HAlign = 'justify';
|
|
if titolo == 1
|
|
sezKlinoHR = Heading3('Klino Link HR');
|
|
sezKlinoHR.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
|
|
KL = Section();
|
|
KL.Title = sezKlinoHR;
|
|
add(DT_ENG,sezKlinoHR);
|
|
titolo = 0;
|
|
end
|
|
add(DT_ENG,testo);
|
|
add(DT_ENG,testo2);
|
|
add(DT_ENG,ChartKLHR);
|
|
add(DT_ENG,legendaKL);
|
|
add(DT_ENG,ChartKLHR_cap);
|
|
add(DT_ENG,br);
|
|
close(figure(1));
|
|
end
|
|
|
|
%pulisco variabili da riutilizzare per catena successiva
|
|
clear TiltX;
|
|
clear TiltY;
|
|
else
|
|
if ATTIVA == 1
|
|
testo = Paragraph('Non sono presenti dati relativi al periodo temporale considerato.');
|
|
ATTIVA = 0;
|
|
add(DT,testo);
|
|
if activeEN == 1
|
|
testo = Paragraph('No data available for the reference time period.');
|
|
add(DT_ENG,testo);
|
|
if m == 1
|
|
add(DT_ENG,br);
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
text = 'report_KLHR function executed correctly';
|
|
fprintf(fileID,fmt,text);
|
|
fclose(fileID);
|
|
|
|
end |