Files
matlab-python/ATD/report_KLHR_ENG.m

149 lines
6.1 KiB
Matlab
Executable File

function [ATTIVA,FIG] = report_KLHR_ENG(rKLHR,m,NodoKlinoLinkHR,toolrif,unitrif,...
datarif,Font_caption,Font_tools,siteID,DT,FIG,br,status,ATTIVA,conn,FileName)
import mlreportgen.dom.*
import mlreportgen.report.*
% Make sure DOM is compilable
makeDOMCompilable()
if status(m,1) == 1
if ATTIVA == 1
ATTIVA = 0;
testo = Paragraph('Array not installed or inactive.');
add(DT,testo);
end
elseif status(m,1) == 3
if ATTIVA == 1
ATTIVA = 0;
testo = Paragraph(['Monitoring completed. Please log into the web-based platoform '...
'to access the complete dataset.']);
add(DT,testo);
end
else
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(['Temperature [' char(186) 'C]']);
set(gca,'YColor','k');
end
title(['Clinometer ' NodeNum ' - X axis tilt']);
xlabel('Date [dd/mm/yyyy]');
yyaxis left
ylabel(['Tilt [' char(186) ']']);
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(186) 'C]']);
set(gca,'YColor','k');
end
title(['Clinometer ' NodeNum ' - Y axis tilt']);
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
legendaKL = Image(('legendaKL_ENG.png'));
legendaKL.Style = {Height('0.7cm'),HAlign('center')};
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) ' - Tilt '...
'recorded during thte reference time period by the electrolytic tilt sensor along X and Y instrumental axes']);
FIG = FIG+1;
ChartKLHR_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
testo = Paragraph(['Following graphs report the absolute tilt values measured during the reference time interval '...
'by the electrolytic tilt sensor installed in the node ' NodeNum ' along the two instrumental axes X and Y.']);
testo2 = Paragraph(['In the time period considered for this report, the sensor recorded a maximum tilt value along '...
'the X axis equal to ' num2str(round(max(TiltX),2), '%0.2f') '' char(186) ' and a minimum value of '...
num2str(round(min(TiltX),2), '%0.2f') '' char(186) ', with '...
num2str(round(max(TiltX),2)-round(min(TiltX),2), '%0.2f')...
char(186) ' of maximum variation. For what concern the Y axis, maximum and minimum values are respectively equal to'...
num2str(round(max(TiltY),2), '%0.2f') '' char(186) ' and ' num2str(round(min(TiltY),2), '%0.2f')...
char(186) ', displaying a maximum variation of ' num2str(round(max(TiltY),2)-round(min(TiltY),2), '%0.2f')...
char(186) '.']);
testo.HAlign = 'justify';
testo2.HAlign = 'justify';
if titolo == 1
sezKlino = Heading3('Klino Link HR');
sezKlino.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
KL = Section();
KL.Title = sezKlino;
add(DT,sezKlino);
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));
%pulisco variabili da riutilizzare per catena successiva
clear TiltX;
clear TiltY;
else
if ATTIVA == 1
testo = Paragraph('No data available for the reference time period.');
ATTIVA = 0;
add(DT,testo);
end
end
end
end
fileID = fopen(FileName,'a');
fmt = '%s \r';
text = 'report_KLHR_ENG function executed correctly';
fprintf(fileID,fmt,text);
fclose(fileID);
end