Files
matlab-python/ATD/report_BL_ENG.m

96 lines
3.5 KiB
Matlab
Executable File

function [ATTIVA,FIG] = report_BL_ENG(rBL,m,NodoBaroLink,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
testo = Paragraph('Array not installed or inactive.');
ATTIVA = 0;
add(DT,testo);
end
elseif status(m,1) == 3
if ATTIVA == 1
testo = Paragraph(['Monitoring completed. Please log into the web-based platoform '...
'to access the complete dataset.']);
ATTIVA = 0;
add(DT,testo);
end
else
SE = Section();
titolo = 1;
for b = 1:rBL(m,1)
NodeNum = num2str(NodoBaroLink(b,m));
comando = ['select EventDate, EventTime, pressure 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
pressatm = cell2mat(Dati(:,3)); % pressione atmosferica
% grafico pressione atmosferica NELL'ULTIMO MESE
figure(4)
atm = plot(Date,pressatm);
title('Atmospheric pressure');
xlabel('Date [dd/mm/yyyy]');
ylabel('Pressure [Pa]');
h = gca;
h.XAxis.MinorTick = 'on';
datetick('x','dd/mm/yyyy','keepticks','keeplimits');
xtickangle(15);
grid on
grid minor
hold off
TempName = char(strcat('Report',siteID,'-', char(toolrif),'-Baro_ENG.png'));
saveas(atm,TempName);
ChartBL = Image(TempName);
ChartBL.Style = {Height('8cm'),HAlign('center')};
ChartBL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Atmospheric pressure recorded by the barometer during the reference time period']);
FIG = FIG+1;
ChartBL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
testo = Paragraph(['The following graph represents atmospheric pressure values recorded during the reference time period '...
'by the barometer installed on-site.']);
testo.HAlign = 'justify';
if titolo == 1
sezBaro = Heading3('Baro Link');
sezBaro.Style = {OuterMargin('0in','0in','0.15in','0in'),FontSize(Font_tools),Bold(1),Italic(1)};
SE.Title = sezBaro;
add(DT,sezBaro);
titolo = 0;
end
add(DT,testo);
add(DT,ChartBL);
add(DT,ChartBL_cap);
add(DT,br);
close(figure(4));
%pulisco variabili da riutilizzare per catena successiva
clear pressatm;
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_BL_ENG function executed correctly';
fprintf(fileID,fmt,text);
fclose(fileID);
end