function [GI_MaxDispMESE,GI_DateTL,GI_MaxDispProf,ATTIVA,FIG,FIG_ENG] = report_TL(... rTL,rTLHR,m,NodoTiltLink,toolrif,unitrif,datarif,firstdata_num,... Font_caption,Font_tools,siteID,toolrifID,DT,DT_ENG,FIG,FIG_ENG,br,... colonna2,colonna2bis,status,ATTIVA,activeEN,conn,FileName) fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'report_TL function started'; fprintf(fileID,fmt,text); import mlreportgen.dom.* import mlreportgen.report.* % Make sure DOM is compilable makeDOMCompilable() NODATA(m,1) = 0; GI_MaxDispMESE = []; GI_DateTL = []; GI_MaxDispProf = []; check = 0; while check == 0 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 check = 1; 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 check = 1; else for n = 1:rTL(m,1) NodeNum = num2str(NodoTiltLink(n,m)); comando = ['select EventDate, EventTime, HShift_local, HShift, NodeDepth, XShift, YShift, X, Y, HShiftDir 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 n == 1 % Il primo lo scrivo e creo la variabile di controllo else [rS,~] = size(Spost_local); if rD ~= rS NODATA(m,1) = 2; check = 0; break else check = 1; end end % dall'inizio Spost_local(:,n) = cell2mat((Dati(:,3)))*1000; % Loc 2D Spost(:,n) = (cell2mat(Dati(:,4)))*1000; % Cum 2D Prof(:,n) = -(cell2mat(Dati(1,5))); % Profondità % Locali ultimo mese Spost_Local_MeseX(:,n) = cell2mat(Dati(:,6)); % Loc X ultimo mese Spost_Local_MeseY(:,n) = cell2mat(Dati(:,7)); % Loc Y ultimo mese diffMeseX_Local(1,n) = Spost_Local_MeseX(end,n)-Spost_Local_MeseX(1,n); diffMeseY_Local(1,n) = Spost_Local_MeseY(end,n)-Spost_Local_MeseY(1,n); DispMese_Local(1,n) = sqrt(diffMeseX_Local(1,n)^2 + diffMeseY_Local(1,n)^2)*1000; % Cumulati ultimo mese Spost_MeseX(:,n) = cell2mat(Dati(:,8)); % Cum X ultimo mese Spost_MeseY(:,n) = cell2mat(Dati(:,9)); % Cum Y ultimo mese diffMeseX(1,n) = Spost_MeseX(end,n)-Spost_MeseX(1,n); diffMeseY(1,n) = Spost_MeseY(end,n)-Spost_MeseY(1,n); DispMese(1,n) = sqrt(diffMeseX(1,n)^2 + diffMeseY(1,n)^2)*1000; Azim(:,n) = cell2mat(Dati(:,10)); % Azimuth totale else NODATA(m,1) = 1; check = 1; end end if NODATA(m,1) == 0 if strcmp(colonna2bis(m+1,1),colonna2(m+1,1)) == 0 % data zero diversa data riferimento clear Spost; clear Spost_local; clear Azimuth; datarifNEW = datestr(firstdata_num{m+1,1},'yyyy-mm-dd'); % data riferimento definita sul sito for nw = 1:rTL(m,1) NodeNum = num2str(NodoTiltLink(nw,m)); comando = ['select EventDate, EventTime, HShift_local, HShift, NodeDepth, XShift, YShift, X, Y, HShiftDir '... 'from ElabDataView where EventDate = ''' datarifNEW ''' and ToolNameID = ''' char(toolrif) ... ''' and UnitName = ''' char(unitrif) ''' and NodeNum = ''' NodeNum ''' ']; curs = exec(conn,comando); curs = fetch(curs); DatiNEW = curs.Data; % dati registrati alla data di riferimento [~,rC] = size(DatiNEW); if rC ~= 1 % dalla data di riferimento Spost_Local_X_RIF(:,nw) = cell2mat(DatiNEW(:,6)); %Loc X data rif Spost_Local_Y_RIF(:,nw) = cell2mat(DatiNEW(:,7)); %Loc Y data rif diffX_Local_RIF(1,nw) = Spost_Local_MeseX(end,nw)-Spost_Local_X_RIF(1,nw); diffY_Local_RIF(1,nw) = Spost_Local_MeseY(end,nw)-Spost_Local_Y_RIF(1,nw); Spost_local(1,nw) = sqrt(diffX_Local_RIF(1,nw)^2 + diffY_Local_RIF(1,nw)^2)*1000; Spost_X_RIF(:,nw) =cell2mat(DatiNEW(:,8)); % Cum X data rif Spost_Y_RIF(:,nw) =cell2mat(DatiNEW(:,9)); % Cum Y data rif diffX_RIF(1,nw) = Spost_MeseX(end,nw)-Spost_X_RIF(1,nw); diffY_RIF(1,nw) = Spost_MeseY(end,nw)-Spost_Y_RIF(1,nw); Spost(1,nw) = sqrt(diffX_RIF(1,nw)^2 + diffY_RIF(1,nw)^2)*1000; azim(1,nw) = (acos(abs(diffX_RIF(1,nw)*1000)/Spost(1,nw)))*180/pi(); % Angolo Teta in gradi 0° - 90° segnoNS = sign(diffX_RIF(1,nw)); segnoEO = sign(diffY_RIF(1,nw)); % L'azimuth si calcola con NS = 0, positivo in senso orario % (90° = Est) if segnoNS == 1 && segnoEO == 1 % quadrante 1 Azimuth(1,nw) = azim(1,nw); % Teta lo tengo come è (1 quadrante) elseif segnoNS == -1 && segnoEO == 1 % quadrante 2 Azimuth(1,nw) = 180 - azim(1,nw); % 180-teta elseif segnoNS == -1 && segnoEO == -1 % quadrante 3 Azimuth(1,nw) = 180 + azim(1,nw); % 180+teta elseif segnoNS == 1 && segnoEO == -1 % quadrante 4 Azimuth(1,nw) = 360 - azim(1,nw); % 360-teta elseif segnoNS == 0 && segnoEO == -1 % 270° Azimuth(1,nw) = 270; elseif segnoNS == -1 && segnoEO == 0 % 180° Azimuth(1,nw) = 180; elseif segnoNS == 0 && segnoEO == 1 % 90° Azimuth(1,nw) = 90; elseif segnoNS == 1 && segnoEO == 0 % 0° Azimuth(1,nw) = 0; else % non c'è nessuno spostamento da nessuna parte if nw == 1 Azimuth(1,nw) = 0; else Azimuth(1,nw) = Azimuth(1,nw-1); end end Azimuth(1,nw) = real(Azimuth(1,nw)); else NODATA(m,1) = 1; end end % Approssimo gli spostamenti al decimo di millimetro conv = Spost*10; conv = round(conv); Spost = conv/10; end MaxDisp = max(Spost_local(end,:)); Index = find(Spost_local(end,:) == MaxDisp); MaxDispProf = Prof(1,Index(1)); MaxDispMESE = max(DispMese_Local(end,:)); IndexMESE = find(DispMese_Local(end,:) == MaxDispMESE); MaxDispProfMESE = Prof(1,IndexMESE(1)); % aggiungo ancora comando = ['select nodetype_id, depth, num from nodes where tool_id = ''' num2str(cell2mat(toolrifID)) ... ''' and nodetype_id = 9 order by num']; Anc = fetch(conn,comando); ProfAnc = -(cell2mat((Anc(:,2)))); Prof = [ProfAnc Prof]; [rt,~] = size(Spost_local); ancoraTL = zeros(rt,1); Spost_local = [ancoraTL Spost_local]; Spost = [ancoraTL Spost]; DispMese_Local = [0 DispMese_Local]; DispMese = [0 DispMese]; % per grafici integrati GI_MaxDispMESE_x = Spost_Local_MeseX(:,IndexMESE(1)); % x del nodo a maggior spostamento GI_diff_x = GI_MaxDispMESE_x(:,:)- GI_MaxDispMESE_x(1,1); % differenza GI_MaxDispMESE_y = Spost_Local_MeseY(:,IndexMESE(1));% y del nodo a maggior spostamento GI_diff_y = GI_MaxDispMESE_y(:,:)- GI_MaxDispMESE_y(1,1); % differenza GI_MaxDispMESE = sqrt((GI_diff_x).^2 + (GI_diff_y).^2)*1000; % risultante GI_DateTL = Date; GI_MaxDispProf = MaxDispProfMESE; % Grafico Locali figure(1) subplot(1,2,1); plot(DispMese_Local,Prof); hold on plot(Spost_local(end,:),Prof); title('Spostamenti Locali 2D'); xlabel('Spostamento [mm]'); ylabel(['Profondit' char(224) ' [m]']); h = gca; h.XAxis.MinorTick = 'on'; if MaxDisp < 10 % mm xlim([-inf 10]); end grid on grid minor % Grafico Cumulati subplot(1,2,2); plot(DispMese,Prof); hold on DispCum = plot(Spost(end,:),Prof); title('Spostamenti Cumulati 2D'); xlabel('Spostamento [mm]'); ylabel(['Profondit' char(224) ' [m]']); h = gca; h.XAxis.MinorTick = 'on'; if max(Spost(end,:)) < 10 xlim([-inf 10]); end grid on grid minor lgd = legend('Ultimo periodo','Intero periodo','Location','southeast'); lgd.FontSize = 6; TempName = char(strcat('Report',siteID,'-', char(toolrif),'Disp.png')); saveas(DispCum,TempName); Chart = Image(TempName); if m > 1 for C = 1:m-1 if status(C,1) == 3 || status(C,1) == 1 Chart.Style = {Height('10cm'),HAlign('center')}; break else Chart.Style = {ScaleToFit}; end end else Chart.Style = {ScaleToFit}; end Chart_capM = Paragraph(['Fig. ' num2str(FIG) ' - Spostamenti differenziali locali e cumulati in '... 'direzione di massima pendenza registrati dalla catena '... 'durante il periodo temporale di riferimento e a partire '... 'dalla data di riferimento riportata in Tabella 1']); FIG = FIG+1; Chart_capM.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; close(figure(1)) if activeEN == 1 figure(1) subplot(1,2,1); plot(DispMese_Local,Prof); hold on plot(Spost_local(end,:),Prof); title('2D Local Displacements'); xlabel('Displacement [mm]'); ylabel('Depth [m]'); h = gca; h.XAxis.MinorTick = 'on'; if MaxDisp < 10 % mm xlim([-inf 10]); end grid on grid minor subplot(1,2,2); plot(DispMese,Prof); hold on DispCum = plot(Spost(end,:),Prof); title('2D Cumulative Displacements'); xlabel('Displacements [mm]'); ylabel('Depth [m]'); h = gca; h.XAxis.MinorTick = 'on'; if max(Spost(end,:)) < 10 xlim([-inf 10]); end grid on grid minor lgd = legend('Last period','Entire period','Location','southeast'); lgd.FontSize = 6; TempName = char(strcat('Report',siteID,'-', char(toolrif),'Disp_ENG.png')); saveas(DispCum,TempName); Chart = Image(TempName); if m > 1 for C = 1:m-1 if status(C,1) == 3 || status(C,1) == 1 Chart.Style = {Height('10cm'),HAlign('center')}; break else Chart.Style = {ScaleToFit}; end end else Chart.Style = {ScaleToFit}; end Chart.Style = {ScaleToFit}; Chart_capM = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Local and cumulative '... 'differential displacements along maximum grade direction, '... 'recorded during the monitoring reference period and starting from the '... 'reported in Tab. 1']); FIG_ENG = FIG_ENG+1; Chart_capM.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; close(figure(1)) end % grafico azimuth DALL'INIZIO Azim_grafico = deg2rad(Azim(end,:)); Azim_grafico = [0 Azim_grafico]; %aggiungo ancora figure(2) azimuth = polarscatter(Azim_grafico,flip(abs(Prof)),'filled'); title('Azimut'); h = gca; h.ThetaDir = 'clockwise'; h.ThetaZeroLocation = 'top'; angles = 0:45:360; h.ThetaTick = angles; labels = {'N','NE','E','SE','S','SO','O','NO'}; h.ThetaTickLabel = labels; grid on Testa = Azim(end,end); if Testa > 11.25 && Testa <= 33.75 DirAzim = 'Nord-Nord-Est'; elseif Testa > 33.75 && Testa <= 56.25 DirAzim = 'Nord-Est'; elseif Testa > 56.25 && Testa <= 78.75 DirAzim = 'Est-Nord-Est'; elseif Testa > 78.75 && Testa <= 101.25 DirAzim = 'Est'; elseif Testa > 101.25 && Testa <= 123.75 DirAzim = 'Est-Sud-Est'; elseif Testa > 123.75 && Testa <= 146.25 DirAzim = 'Sud-Est'; elseif Testa > 146.25 && Testa <= 168.75 DirAzim = 'Sud-Sud-Est'; elseif Testa > 168.75 && Testa <= 191.25 DirAzim = 'Sud'; elseif Testa > 191.25 && Testa <= 213.75 DirAzim = 'Sud-Sud-Ovest'; elseif Testa > 213.75 && Testa <= 236.25 DirAzim = 'Sud-Ovest'; elseif Testa > 236.25 && Testa <= 258.75 DirAzim = 'Ovest-Sud-Ovest'; elseif Testa > 258.75 && Testa <= 281.25 DirAzim = 'Ovest'; elseif Testa > 281.25 && Testa <= 303.75 DirAzim = 'Ovest-Nord-Ovest'; elseif Testa > 303.75 && Testa <= 326.25 DirAzim = 'Nord-Ovest'; elseif Testa > 326.25 && Testa <= 348.75 DirAzim = 'Nord-Nord-Ovest'; else DirAzim = 'Nord'; end TempName = char(strcat('Report',siteID,'-', char(toolrif),'Azimuth.png')); saveas(azimuth,TempName); ChartAZ = Image(TempName); ChartAZ.Style = {ScaleToFit}; ChartAZ_cap = Paragraph(['Fig. ' num2str(FIG) ' - Azimut degli spostamenti '... 'differenziali cumulati secondo la profondit' char(224) ', registrato a partire dalla lettura di riferimento']); FIG = FIG+1; ChartAZ_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; SE = Section(); if rTLHR(m,1) > 0 sezTilt = Heading3('Tilt Link HR 3D V'); else sezTilt = Heading3('Tilt Link V'); end sezTilt.Style = {OuterMargin('0in','0in','0.15in','0in'),FontSize(Font_tools),Bold(1),Italic(1)}; SE.Title = sezTilt; close(figure(2)) if activeEN == 1 Azim_grafico = deg2rad(Azim(end,:)); Azim_grafico = [0 Azim_grafico]; %aggiungo ancora figure(2) azimuth = polarscatter(Azim_grafico,flip(abs(Prof)),'filled'); title('Azimuth'); h = gca; h.ThetaDir = 'clockwise'; h.ThetaZeroLocation = 'top'; angles = 0:45:360; h.ThetaTick = angles; labels = {'N','NE','E','SE','S','SW','W','NW'}; h.ThetaTickLabel = labels; grid on Testa = Azim(end,end); if Testa > 11.25 && Testa <= 33.75 DirAzim = 'North-North-East'; elseif Testa > 33.75 && Testa <= 56.25 DirAzim = 'North-East'; elseif Testa > 56.25 && Testa <= 78.75 DirAzim = 'East-North-East'; elseif Testa > 78.75 && Testa <= 101.25 DirAzim = 'East'; elseif Testa > 101.25 && Testa <= 123.75 DirAzim = 'East-South-East'; elseif Testa > 123.75 && Testa <= 146.25 DirAzim = 'South-East'; elseif Testa > 146.25 && Testa <= 168.75 DirAzim = 'South-South-East'; elseif Testa > 168.75 && Testa <= 191.25 DirAzim = 'South'; elseif Testa > 191.25 && Testa <= 213.75 DirAzim = 'South-South-West'; elseif Testa > 213.75 && Testa <= 236.25 DirAzim = 'South-West'; elseif Testa > 236.25 && Testa <= 258.75 DirAzim = 'West-South-West'; elseif Testa > 258.75 && Testa <= 281.25 DirAzim = 'West'; elseif Testa > 281.25 && Testa <= 303.75 DirAzim = 'West-North-West'; elseif Testa > 303.75 && Testa <= 326.25 DirAzim = 'North-West'; elseif Testa > 326.25 && Testa <= 348.75 DirAzim = 'North-North-West'; else DirAzim = 'North'; end TempName = char(strcat('Report',siteID,'-', char(toolrif),'Azimuth_ENG.png')); saveas(azimuth,TempName); ChartAZ = Image(TempName); ChartAZ.Style = {ScaleToFit}; ChartAZ_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Azimuth of cumulative differential '... 'displacements vs depth, recorded starting from the monitoring reference date']); FIG_ENG = FIG_ENG+1; ChartAZ_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; SE_ENG = Section(); SE_ENG.Title = sezTilt; close(figure(2)) end testo = Paragraph(['I grafici seguenti riportano i valori di spostamento differenziale locale e cumulato '... 'misurati dal sensore MEMS 3D lungo la direzione di massima pendenza, '... 'registrati durante il periodo temporale di riferimento e calcolati a partire dalla lettura di '... 'riferimento riportata in Tabella 1. In particolare, il massimo spostamento differenziale locale '... 'registrato durante il periodo temporale di riferimento ' char(232) ' pari a ' num2str((MaxDispMESE), ... '%0.1f') ' mm alla profondit' char(224) ' di ' num2str(abs(MaxDispProfMESE)) ' m. '... 'Lo spostamento cumulato in testa risulta pari a ' num2str(DispMese(end,end),'%0.1f') ' mm.']); testo2 = Paragraph(['Gli stessi dati relativi all''intero periodo di monitoraggio rilevano un massimo spostamento '... 'differenziale locale pari a ' num2str((MaxDisp), '%0.1f') ' mm, in corrispondenza di una profondit' char(224) ... ' di ' num2str(abs(MaxDispProf)) ' metri. Lo spostamento cumulato in testa risulta pari a ' num2str(Spost(end,end)) ' mm.']); testo3 = Paragraph(['Il grafico seguente mostra l''andamento dell''azimut ottenuto a partire dai dati cumulati '... 'al variare della profondit' char(224) ', calcolati a partire dalla lettura di riferimento. Attualmente, il valore ' ... 'rilevato in testa allo strumento indica uno spostamento in direzione ' DirAzim '.']); testo4 = Paragraph(['Si ricorda che l''azimut ' char(232) ' una rappresentazione della direzione '... 'di movimento del singolo sensore, calcolato a partire dai dati cumulati. '... 'Il parametro viene calcolato indipendentemente dall''ordine di grandezza '... 'dello spostamento misurato: ad esempio, uno spostamento sub-millimetrico '... 'e uno centimetrico nella stessa direzione saranno caratterizzati dallo stesso '... 'valore di azimut. Per questo motivo, ' char(232) ' opportuno considerare tale '... 'grandezza come significativa solo nel caso di spostamenti di entit' char(224) ... ' rilevante.']); testo.HAlign = 'justify'; testo2.HAlign = 'justify'; testo3.HAlign = 'justify'; testo4.HAlign = 'justify'; add(DT,sezTilt); add(DT,testo); add(DT,testo2); add(DT,Chart); add(DT,Chart_capM); add(DT,testo3); add(DT,testo4); add(DT,ChartAZ); add(DT,ChartAZ_cap); add(DT,br); if activeEN == 1 testo = Paragraph(['The following graphs shows the local and differential cumulative displacements '... 'recorded by 3D MEMS sensor along the maximum grade direction during the reference monitoring period '... 'and starting from the reference date reported in Tab. 1. The maximum local differential displacement '... 'recorded during the reference time period equals ' num2str((MaxDispMESE),'%0.1f') ' mm at a depth of '... num2str(abs(MaxDispProfMESE)) ' m. The cumulative displacements at the ground level is '... num2str(DispMese(end,end),'%0.1f') ' mm.']); testo2 = Paragraph(['The same analysis related to the whole monitoring period highlights a maximum local '... 'differential displacement of ' num2str((MaxDisp), '%0.1f') ' mm, at a depth of ' num2str(abs(MaxDispProf)) ... ' m. The cumulative displacement equals ' num2str(Spost(end,end)) ' mm.']); testo3 = Paragraph(['The following graph shows the azimuth obtained through cumulative displacements, '... 'starting from the reference date. The direction identified is ' DirAzim '.']); testo4 = Paragraph(['It is necessary to underline that the azimuth represents the movement direction '... 'of every single sensor, calculated starting from differential cumulative displacements. '... 'The parameter is always processed, regardless of the displacement measured: a sub-millimeters '... 'or a centimeters movements in the same direction will show the same azimuth. '... 'For this reason, it is appropriate to consider the result as significant only for relevant '... 'displacements.']); testo.HAlign = 'justify'; testo2.HAlign = 'justify'; testo3.HAlign = 'justify'; testo4.HAlign = 'justify'; add(DT_ENG,sezTilt); add(DT_ENG,testo); add(DT_ENG,testo2); add(DT_ENG,Chart); add(DT_ENG,Chart_capM); add(DT_ENG,testo3); add(DT_ENG,testo4); add(DT_ENG,ChartAZ); add(DT_ENG,ChartAZ_cap); add(DT_ENG,br); end %pulisco variabili da riutilizzare per catena successiva clear Spost; clear Spost_local; clear Spost_mese; clear Spost_local_mese; clear Prof; clear Azim; clear DirAzim; clear Spost_Local_MeseX; clear Spost_Local_MeseY; clear diffMeseX_Local; clear diffMeseY_Local; clear DispMese_Local; clear Spost_MeseX; clear Spost_MeseY; clear diffMeseX; clear diffMeseY; clear DispMese; clear GI_MaxDispMESE_x; clear GI_diff_x; clear GI_MaxDispMESE_y; clear GI_diff_y; else if ATTIVA == 1 testo = Paragraph('Non sono presenti dati relativi al periodo temporale considerato.'); ATTIVA = 0; add(DT,testo); check = 1; if m == 1 add(DT,br); end 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_TL function executed correctly'; fprintf(fileID,fmt,text); fclose(fileID); end