171 lines
6.9 KiB
Matlab
Executable File
171 lines
6.9 KiB
Matlab
Executable File
function [ATTIVA,FIG,FIG_ENG] = report_BL(rBL,m,NodoBaroLink,tipoCU,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_BL function started';
|
|
fprintf(fileID,fmt,text);
|
|
|
|
import mlreportgen.dom.*
|
|
import mlreportgen.report.*
|
|
|
|
% Make sure DOM is compilable
|
|
makeDOMCompilable()
|
|
titolo = 1;
|
|
if status(m,1) == 1
|
|
if ATTIVA == 1
|
|
testo = Paragraph('Catena non ancora installata o inattiva.');
|
|
ATTIVA = 0;
|
|
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
|
|
testo = Paragraph(['Monitoraggio completato. Invitiamo a visitare la '...
|
|
'piattaforma web per la visione dei dati storici.']);
|
|
ATTIVA = 0;
|
|
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
|
|
SE = Section();
|
|
if activeEN == 1
|
|
SE_ENG = Section();
|
|
end
|
|
for b = 1:rBL(m,1)
|
|
NodeNum = num2str(NodoBaroLink(b,m));
|
|
if tipoCU == 9 % Nesa Evo
|
|
comando = ['select EventTimestamp, JSON_VALUE(dataJSON,"$.pressureAvg") from elabdatanesaview where EventTimestamp >= ''' ...
|
|
datarif ''' and ToolNameID = ''' char(toolrif) ''' and UnitName = ''' char(unitrif) ...
|
|
''' and NodeNum = ''' NodeNum ''' '];
|
|
curs = exec(conn,comando);
|
|
curs = fetch(curs);
|
|
Dati = curs.Data;
|
|
else
|
|
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;
|
|
end
|
|
% Modifico il formato di data e ora
|
|
[rD,rC] = size(Dati);
|
|
if rC ~= 1
|
|
if rC == 2 % Nesa Evo
|
|
Date = datenum(Dati(:,1));
|
|
pressatm = str2num(char(Dati(:,2))); % altezza di pioggia locale
|
|
else
|
|
T = [cell2mat(Dati(:,1)) repmat(' ', [rD,1]) cell2mat(Dati(:,2))];
|
|
Date = datenum(T); % Data
|
|
pressatm = cell2mat(Dati(:,3)); % pressione atmosferica
|
|
end
|
|
|
|
% grafico pressione atmosferica NELL'ULTIMO MESE
|
|
figure(4)
|
|
atm = plot(Date,pressatm);
|
|
title('Pressione atmosferica');
|
|
xlabel('Data [gg/mm/aaaa]');
|
|
ylabel('Pressione [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.png'));
|
|
saveas(atm,TempName);
|
|
ChartBL = Image(TempName);
|
|
ChartBL.Style = {Height('8cm'),HAlign('center')};
|
|
ChartBL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Andamento della '...
|
|
'pressione atmosferica misurata dal barometro nel periodo temporale di riferimento']);
|
|
FIG = FIG+1;
|
|
ChartBL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
|
|
|
testo = Paragraph('Il grafico seguente riporta i valori relativi alla pressione atmosferica misurati dal sensore barometrico nel periodo temporale di riferimento.');
|
|
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);
|
|
if activeEN == 0
|
|
titolo = 0;
|
|
end
|
|
end
|
|
add(DT,testo);
|
|
add(DT,ChartBL);
|
|
add(DT,ChartBL_cap);
|
|
add(DT,br);
|
|
close(figure(4));
|
|
|
|
if activeEN == 1
|
|
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_ENG) ' - Atmospheric pressure recorded during '...
|
|
'the reference time period']);
|
|
FIG_ENG = FIG_ENG+1;
|
|
ChartBL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
|
|
|
testo = Paragraph(['The following graph shows the atmospheric pressure recorded by the '...
|
|
'Barometer sensor during the reference monitoring period.']);
|
|
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_ENG.Title = sezBaro;
|
|
add(DT_ENG,sezBaro);
|
|
titolo = 0;
|
|
end
|
|
add(DT_ENG,testo);
|
|
add(DT_ENG,ChartBL);
|
|
add(DT_ENG,ChartBL_cap);
|
|
add(DT_ENG,br);
|
|
close(figure(4));
|
|
end
|
|
%pulisco variabili da riutilizzare per catena successiva
|
|
clear pressatm;
|
|
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);
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
text = 'report_BL function executed correctly';
|
|
fprintf(fileID,fmt,text);
|
|
fclose(fileID);
|
|
|
|
end |