function [GI_MPB_RL,GI_MPB,GI_Base,GI_Date,FIG,battANALOG,ATTIVA] = report_MPBEL_ENG(DTcatena,... rMPBEL,m,NodoMultiPointExtensometerLink,toolrif,unitrif,contunit,datarif,... Font_caption,Font_tools,battANALOG,ATTIVA,siteID,DT,FIG,br,status,conn,FileName) import mlreportgen.dom.* import mlreportgen.report.* % Make sure DOM is compilable makeDOMCompilable() GI_Date = []; GI_MPB = []; GI_Base = []; GI_MPB_RL = []; if status(m,1) == 1 if ATTIVA == 1 ATTIVA = 0; testo = Paragraph('GMUX 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 MPBE = Section(); sezMPBELExtensometer = Heading3('MultiPoint Borehole Extensometer'); sezMPBELExtensometer.Style = {OuterMargin('0in','0in','0.15in','0in'),FontSize(Font_tools),Bold(1),Italic(1)}; MPBE.Title = sezMPBELExtensometer; if battANALOG == 0 comando = ['select Date, Time, UnitName, ToolNameID, BatLevel, Temperature from RawDataView where Date >= ''' ... datarif ''' and UnitName = ''' char(unitrif) ''' and ToolNameID = '''... char(toolrif) ''' and NodeNum = 1 ']; curs = exec(conn,comando); curs = fetch(curs); BatTemp = curs.Data; [~,cc] = size(BatTemp); if cc ~= 1 %ci sono dati riferiti all'ultimo mese/periodo di interesse DataPlot = [BatTemp(:,1) BatTemp(:,2)]; % sistemo date, batteria e temperatura [rD,~] = size(DataPlot); T = [cell2mat(DataPlot(:,1)) repmat(' ', [rD,1]) cell2mat(DataPlot(:,2))]; Date = datenum(T); Batteria = cell2mat(BatTemp(:,5)); Temperatura = cell2mat(BatTemp(:,6)); % testo introduttivo testoB1 = Paragraph(['The following chart reports the battery level trend recorded during the reference time period. '... 'The correct functioning of the GMUX module is guaranteed for a minimum level of 12 V. The last '... 'available data is equal to ' num2str(Batteria(end,1)) ' V.']); testoB2 = Paragraph(['The GMUX module equips also a thermometer that allows the monitoring of the working '... 'temperature and the identification of eventual malfunctioning. The following chart reports temperature '... 'data recorded by the GMUX module.']); testoB1.HAlign = 'justify'; testoB2.HAlign = 'justify'; % grafico batteria figure(19) plot(Date,Batteria); hold on title('Battery level and GMUX temperature'); xlabel('Date [dd/mm/yyyy]'); ylabel('Level [V]'); ylim([floor(min(Batteria(:,1))) ceil(max(Batteria(:,1)))]); yyaxis right GMUX = plot(Date,Temperatura,':','LineWidth',1.1); ylim([floor(min(Temperatura(:,1))) ceil(max(Temperatura(:,1)))]); ylabel(['Temperature [' char(176) 'C]']); set(gca,'YColor','k'); str(1,1) = cellstr('Battery'); str(2,1) = cellstr('Temperature'); legend(str,'Location','northwest'); h = gca; h.XAxis.MinorTick = 'on'; datetick('x','dd/mm/yyyy','keepticks','keeplimits'); xtickangle(20); grid on grid minor xlim([Date(1)-1 Date(end)+1]); TempName = char(strcat('Report',siteID,'-', contunit,'-GMUX_ENG.png')); saveas(GMUX,TempName); ChartGMUX = Image(TempName); ChartGMUX.Style = {Height('8cm'),HAlign('center')}; if Batteria(end,1) >= 13 TempName = char(strcat('B_13.jpg')); elseif Batteria(end,1) >= 12 TempName = char(strcat('B_12.jpg')); elseif Batteria(end,1) >= 11 TempName = char(strcat('B_11.jpg')); else TempName = char(strcat('B_10.jpg')); end Batt = Image(TempName); Batt.Style = {Height('4cm'),HAlign('center')}; lot = Table({ChartGMUX, Batt}); lot.TableEntriesStyle = {HAlign('center'),VAlign('middle')}; lot.Style = {ResizeToFitContents(false),Width("100%")}; 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; lot.ColSpecGroups = grps; lot_cap = Paragraph(['Fig. ' num2str(FIG) ' - Battery level and GMUX temperature recorded '... 'during the reference time period']); FIG = FIG+1; lot_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; FIG = FIG+1; Chart_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; Batt = Section(); sezBATT = Heading3('GMUX - Battery level and temperature'); sezBATT.Style = {FontSize(Font_tools),Bold(1),Italic(1)}; Batt.Title = sezBATT; add(DT,sezBATT); add(DT,testoB1); add(DT,testoB2); add(DT,lot); add(DT,lot_cap); add(DT,br); close(figure(19)); battANALOG = 1; end end add(DT,sezMPBELExtensometer); for mp = 1:rMPBEL(m,1) NodeNum = num2str(NodoMultiPointExtensometerLink(mp,m)); comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z 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 if isnan(cell2mat(Dati(:,3))) == 0 d1(:,mp) = cell2mat(Dati(:,3)); % deformazioni base 1 else d1(:,mp) = 999999; end if isnan(cell2mat(Dati(:,4))) == 0 d2(:,mp) = cell2mat(Dati(:,4)); % deformazioni base 2 else d2(:,mp) = 999999; end if isnan(cell2mat(Dati(:,5))) == 0 d3(:,mp) = cell2mat(Dati(:,5)); % deformazioni base 3 else d3(:,mp) = 999999; end if isnan(cell2mat(Dati(:,6))) == 0 d4(:,mp) = cell2mat(Dati(:,6)); % deformazioni base 4 else d4(:,mp) = 999999; end if isnan(cell2mat(Dati(:,7))) == 0 d5(:,mp) = cell2mat(Dati(:,7)); % deformazioni base 5 else d5(:,mp) = 999999; end if isnan(cell2mat(Dati(:,8))) == 0 d6(:,mp) = cell2mat(Dati(:,8)); % deformazioni base 6 else d6(:,mp) = 999999; end % grafico deformazioni NELL'ULTIMO MESE figure(5); title(['Deformation measured by node ' NodeNum]); d1g(:,mp) = d1(:,mp)-d1(1,mp); MX(1) = max(d1g(:,mp)); MN(1) = min(d1g(:,mp)); MPB = plot(Date,d1g(:,mp)); M = max(abs(d1g(:,mp))); S = find(abs(d1g(:,mp))==M(1)); D = d1g(S(1),mp); basi = 1; if d2(1,mp) < 999999 hold on d2g(:,mp) = d2(:,mp)-d2(1,mp); MX(2) = max(d2g(:,mp)); MN(2) = min(d2g(:,mp)); MPB = plot(Date,d2g(:,mp)); M(2) = max(abs(d2g(:,mp))); S = find(abs(d2g(:,mp))==M(2)); D(2) = d2g(S(1),mp); basi = 2; end if d3(1,mp) < 999999 hold on d3g(:,mp) = d3(:,mp)-d3(1,mp); MX(3) = max(d3g(:,mp)); MN(3) = min(d3g(:,mp)); MPB = plot(Date,d3g(:,mp)); M(3) = max(abs(d3g(:,mp))); S = find(abs(d3g(:,mp))==M(3)); D(3) = d3g(S(1),mp); basi = 3; end if d4(1,mp) < 999999 hold on d4g(:,mp) = d4(:,mp)-d4(1,mp); MX(4) = max(d4g(:,mp)); MN(4) = min(d4g(:,mp)); MPB = plot(Date,d4g(:,mp)); M(4) = max(abs(d4g(:,mp))); S = find(abs(d4g(:,mp))==M(4)); D(4) = d4g(S(1),mp); basi = 4; end if d5(1,mp) < 999999 hold on d5g(:,mp) = d5(:,mp)-d5(1,mp); MX(5) = max(d5g(:,mp)); MN(5) = min(d5g(:,mp)); MPB = plot(Date,d5g(:,mp)); M(5) = max(abs(d5g(:,mp))); S = find(abs(d5g(:,mp))==M(5)); D(5) = d5g(S(1),mp); basi = 5; end if d6(1,mp) < 999999 hold on d6g(:,mp) = d6(:,mp)-d6(1,mp); MX(6) = max(d6g(:,mp)); MN(6) = min(d6g(:,mp)); plot(Date,d6g(:,mp)); M(6) = max(abs(d6g(:,mp))); S = find(abs(d6g(:,mp))==M(6)); D(6) = d6g(S(1),mp); basi = 6; end title(['Deformations - node ' NodeNum]); ylabel('Deformation [mm]'); xlabel('Date [dd/mm/yyyy]'); set(gca,'YColor','k'); str(1,1) = cellstr('Rod 1'); if basi > 1 str(2,1) = cellstr('Rod 2'); end if basi > 2 str(3,1) = cellstr('Rod 3'); end if basi > 3 str(4,1) = cellstr('Rod 4'); end if basi > 4 str(5,1) = cellstr('Rod 5'); end if basi > 5 str(6,1) = cellstr('Rod 6'); end VAR(1) = max(MX); VAR(2) = min(MN); MAX = max(abs(VAR)); IN = find(abs(VAR)==MAX); if IN == 1 % Legenda sotto legend(str,'Location','southwest'); else legend(str,'Location','northwest'); end legend(str,'Location','northwest'); xlim([Date(1)-1 Date(end)+1]); h = gca; h.XAxis.MinorTick = 'on'; datetick('x','dd/mm/yyyy','keepticks','keeplimits'); xtickangle(20); grid on grid minor TempName = char(strcat('Report',siteID,'-', char(toolrif),'-MPBEL', NodeNum, '_ENG.png')); saveas(MPB,TempName); ChartMPBEL = Image(TempName); ChartMPBEL.Style = {Height('7.3cm'),HAlign('center')}; ChartMPBEL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Deformations '... 'measured by the MultiPoint Borehole Extensometer ' NodeNum... ', during the reference time period']); FIG = FIG+1; ChartMPBEL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; MAX = max(M); IN = find(MAX==M); % Base che ha misurato tale variazione Massimo = D(IN); % Valore massimo (positivo o negativo) di deformazione misurata % Cerco eventuali correlazioni con Rad Array NomeFile = strcat('Report',siteID,'-RLvsMPBEL.txt'); Filetesto = importdata(NomeFile); [rF,~] = size(Filetesto); AAA = 1; Nodo = 999; iNodo = 1; while AAA <= rF % Cerco la coppia di sensori Rad - Multibase da correlare check1 = Filetesto(AAA,1); if check1 == 99999 % Non ci sono multibase o non ci sono Rad AAA = 2; else check2 = Filetesto(AAA+1,1); if check1 == str2num(DTcatena(end-2:end)) % Il Multibase è da prendere in considerazione ed è riportato nella prima riga del file Nodo(iNodo) = Filetesto(AAA+2,1); iNodo = iNodo+1; elseif check2 == str2num(DTcatena(end-2:end)) % Il Multibase è da prendere in considerazione ed è riportato nella seconda riga del file Nodo(iNodo) = Filetesto(AAA+3,1); iNodo = iNodo+1; end AAA = AAA+4; end end [~,cd] = size(d1g); if IN == 1 if Nodo(mp) <= cd GI_MPB_RL(:,mp) = d1g(:,Nodo(mp)); end GI_MPB(:,mp) = d1g(:,mp); elseif IN == 2 if Nodo(mp) <= cd GI_MPB_RL(:,mp) = d2g(:,Nodo(mp)); end GI_MPB(:,mp) = d2g(:,mp); elseif IN == 3 if Nodo(mp) <= cd GI_MPB_RL(:,mp) = d3g(:,Nodo(mp)); end GI_MPB(:,mp) = d3g(:,mp); elseif IN == 4 if Nodo(mp) <= cd GI_MPB_RL(:,mp) = d4g(:,Nodo(mp)); end GI_MPB(:,mp) = d4g(:,mp); elseif IN == 5 if Nodo(mp) <= cd GI_MPB_RL(:,mp) = d5g(:,Nodo(mp)); end GI_MPB(:,mp) = d5g(:,mp); elseif IN == 2 if Nodo(mp) <= cd GI_MPB_RL(:,mp) = d6g(:,Nodo(mp)); end GI_MPB(:,mp) = d6g(:,mp); else end GI_Base(:,mp) = IN; GI_Date(:,mp) = Date; testo = Paragraph(['The following graph reports deformation data recorded by MultiPoint Borehole '... 'Extensometers connected to the Analog Array. ']); testo2 = Paragraph(['During the reference time period, node ' NodeNum... ' measured a maximum differential deformation value of '... num2str(round(Massimo,2), '%0.2f') ' mm, referred to Rod ' num2str(IN) '. ']); testo.HAlign = 'justify'; testo2.HAlign = 'justify'; if mp == 1 add(DT,testo); end add(DT,testo2); add(DT,ChartMPBEL); add(DT,ChartMPBEL_cap); if mp == rMPBEL(m,1) add(DT,br); end close(figure(5)); %pulisco variabili da riutilizzare per catena successiva else if ATTIVA == 1 ATTIVA = 0; testo = Paragraph('No data available for the reference time period.'); add(DT,testo); add(DT,br); end end end end fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'report_MPBEL_ENG function executed correctly'; fprintf(fileID,fmt,text); fclose(fileID); end