function Report_ASE_LOC(IDcentralina,siteID,unitID,chainID,Chain_Scheme,num_nodi,... alarms,Mail,Users_Report,activeEN,time,conn,FileName) % Software per la generazione automatica di report sull'attivitą di % monitoraggio ASE try fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'report_ASE function started'; fprintf(fileID,fmt,text); fclose(fileID); RPT_ON = 0; % parametro che regola la creazione o meno del report NomeFile = strcat('Report',siteID,'.txt'); meseadesso = str2double(datestr(today,'mm')); if isfile(NomeFile) == 1 % Esiste Filetesto = importdata(NomeFile); datainvio = Filetesto(1,1); % mese di invio OPPURE data di ultimo invio attivaReport = Filetesto(2,1); % Scarico la frequenza del report comando = ['select freq_report from sites where id like ''' siteID ''' ']; curs = exec(conn,comando); curs = fetch(curs); Freq = cell2mat(curs.Data); numgiorni = Freq; fileID = fopen(FileName,'a'); fmt = '%s \r'; text = ['Report frequency:' num2str(numgiorni) ' days']; fprintf(fileID,fmt,text); fclose(fileID); if numgiorni == 30 adesso = str2double(datestr(today,'mm')); if datainvio == adesso RPT_ON = 1; end else adesso = now; if adesso >= datainvio + numgiorni RPT_ON = 1; end end if RPT_ON == 1 fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'Report creation started'; fprintf(fileID,fmt,text); fclose(fileID); if attivaReport == 0 attivaReport = 1; outdat = fopen(NomeFile,'wt+'); fopen(NomeFile,'wt'); fmt = '%d \r'; fileID = fopen(NomeFile,'a'); fprintf(fileID,fmt,meseadesso); fprintf(fileID,fmt,attivaReport); fclose(fileID); recipients_ASE{1,1} = 'alessandro.valletta@aseltd.eu'; recipients_ASE{2,1} = 'andrea.carri@aseltd.eu'; recipients_ASE{3,1} = 'roberto.savi@aseltd.eu'; Mail_ASE = 1; if Mail_ASE == 1 || Mail == 1 % Importo librerie Matlab Report Generator e creo report import mlreportgen.dom.* import mlreportgen.report.* FIG = 1; % Contatore Figure FIG_ENG = 1; NomeReport = (['Report_ASE_' siteID]); rpt = Report(NomeReport, 'pdf'); % Crea report NomeReport_ENG = (['Report_ASE_' siteID '_ENG']); rpt_ENG = Report(NomeReport_ENG, 'pdf'); % Crea report Section.number(rpt,false); % elimina numerazione capitoli Section.number(rpt_ENG,false); % elimina numerazione capitoli Font_caption = '8.5pt'; Font_table = '9pt'; Font_table_Loc = '8pt'; Font_section = '14pt'; Font_tools = '12pt'; Font_Chapter = '16pt'; %% Ricavo info sul sito % Uso il siteID per identificare il nome del sito comando = ['select name from sites where id like ''' siteID ''' ']; curs = exec(conn,comando); curs = fetch(curs); NomeSito = num2str(cell2mat(curs.Data)); [arraysito,arraysitoENG,controlsito,yesTL,yesTLHR,yesTLH,yesTLHRH,yesPL,yesBL,yesLL,... yesRL,yesKL,yesKLHR,yesThL,yesPT100,yesIPL,yesIPLHR,yesTuL,yesRaL,yesPCL,yesPCLHR,... yesPrL,yesEL,yes3DEL,yesWEL,yesMPBEL,yesCrL,yes3DCrL,yesBML,yesHL,... yesLuxL,yesCO2,yesRSN,yesRSNHR,yesTrL,yesSM,yes2DCrL,yesPE,yesWL,yesGF,yesGS,... rTL,rTLHR,rTLH,rTLHRH,rPL,rBL,rLL,rRL,rKL,rKLHR,rThL,rPT100,rIPL,rIPLHR,rTuL,rRaL,... rPCL,rPCLHR,rPrL,rEL,r3DEL,rWEL,rMPBEL,rCrL,r3DCrL,rBML,rHL,rLuxL,rCO2,rRSN,rRSNHR,... rTrL,rSM,r2DCrL,rPE,rWL,rGF,rGS,nCT,... NodoTiltLink,NodoTiltLinkHR,NodoTiltLinkH,NodoTiltLinkHRH,NodoPiezoLink,NodoBaroLink,... NodoLoadLink,NodoRainLink,NodoKlinoLink,NodoKlinoLinkHR,NodoThermLink,NodoPT100Link,... NodoInPlaceLink,NodoInPlaceLinkHR,NodoTunnelLink,NodoRadialLink,NodoPreConvLink,... NodoPreConvLinkHR,NodoPressureLink,NodoExtensometerLink,Nodo3DExtensometerLink,... NodoWireExtensometerLink,NodoMultiPointExtensometerLink,NodoCrackLink,Nodo3DCrackLink,... NodoBaroMusaLink,NodoHumidityLink,NodoLuxLink,NodoCO2Link,NodoRSNLink,NodoRSNHRLink,... NodoTriggerLink,NodoStressMeter,Nodo2DCrackLink,NodoPendulum,NodoWeirLink,NodoGflowLink,... NodoGshockLink,tipoarray,tipoalarms,nVMS,nTL,nCAM,nAL] = info_Sito(chainID,alarms,... Chain_Scheme,conn,num_nodi,FileName); info_sito = [chainID(:,2) chainID(:,4)]; %% Pagina titolo ITA template_cover(rpt); tp = TitlePage; Titolo = Paragraph(['Report di monitoraggio del sito: ' NomeSito]); Titolo.Style = {HAlign('center'),Bold(1), FontSize('32pt'),OuterMargin('0in','0in','3in','0.2in')}; tp.Title = (Titolo); sottotitolo = Paragraph('Report automatico - Versione Beta Test'); sottotitolo.Style = {FontSize('12pt'),Bold(1),HAlign('center')}; tp.Subtitle = sottotitolo; tp.Author = ' '; datapub = Paragraph(datestr(today,'dd-mm-yyyy')); datapub.Style = {FontSize('12pt'),HAlign('center')}; tp.PubDate = datapub; add(rpt,tp); if activeEN == 1 %% Pagina titolo ENG template_cover(rpt_ENG); tp_ENG = TitlePage; Titolo = Paragraph('Monitoring activity report '); Titolo.Style = {HAlign('center'),Bold(1), FontSize('32pt'),OuterMargin('0in','0in','3in','0in')}; tp_ENG.Title = (Titolo); sottotitolo = Paragraph(NomeSito); sottotitolo.Style = {HAlign('center'),Bold(1), FontSize('32pt'),OuterMargin('0in','0in','0in','0.2in')}; tp_ENG.Subtitle = sottotitolo; report = Paragraph('Automatic report - Alpha test version'); report.Style = {FontSize('12pt'),Bold(1),HAlign('center'),OuterMargin('0in','0in','0.4in','0.2in')}; tp_ENG.Author = report; datapub = Paragraph(datestr(today,'dd-mm-yyyy')); datapub.Style = {FontSize('12pt'),HAlign('center')}; tp_ENG.PubDate = datapub; add(rpt_ENG,tp_ENG); end fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'Title page created'; fprintf(fileID,fmt,text); %% Pagina sommario % Add a default table of contents object to the report template(rpt); TOC = TableOfContents(); TOC.Layout.PageNumberFormat = 'I'; add(rpt,TOC); if activeEN == 1 template(rpt_ENG); TOC_ENG = TableOfContents(); TOC_ENG.Layout.PageNumberFormat = 'I'; add(rpt_ENG,TOC_ENG); end text = 'Summary page created'; fprintf(fileID,fmt,text); %% Disclaimer iniziale disclaimer = Chapter; dis = Heading1('Disclaimer'); dis.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')}; disclaimer.Title = dis; text = Paragraph(['Il presente report ' char(232) ' un documento generato automaticamente '... 'dal software proprietario sviluppato da ASE S.r.l. Il suo obiettivo ' char(232) ' quello '... 'di riassumere i principali risultati ottenuti dalla strumentazione installata '... 'in un determinato sito del cliente, nel corso di un periodo temporale di riferimento. '... 'Il report riporta le principali informazioni relative al sito monitorato: queste includono '... 'numero e tipologia degli Array presenti, data di installazione, data di riferimento '... 'per i calcoli successivi, principali caratteristiche dei sensori utilizzati, etc. ']); text2 = Paragraph(['Il report viene creato automaticamente il primo giorno di ogni mese e '... 'contiene i dati di monitoraggio elaborati a partire dal mese precedente (o dal mese '... 'della redazione dell''ultimo report, nel caso di Array inattivo), fornendo una panoramica generale '... 'del livello di attivit' char(224) ' del sito durante il periodo temporale di riferimento. '... 'Inoltre, nel caso in cui gli strumenti lo consentano, sono riportati grafici che '... 'integrano i dati raccolti da diverse tipologie di sensori, con l''obiettivo di '... 'evidenziare eventuali correlazioni tra le grandezze monitorate.']); Link = Paragraph(ExternalLink('https://www2.aseltd.eu','cliccando qui.')); text3 = Paragraph(['Si vuole sottolineare che questo documento ' char(232) ' generato completamente in automatico '... 'e non contiene pertanto alcuna valutazione o validazione di carattere tecnico '... 'relativamente ai risultati ottenuti dalla strumentazione installata. '... 'Si ricorda inoltre che quanto riportato nel report ' char(232) ' inteso come un riassunto dei risultati '... 'dell''attivit' char(224) ' di monitoraggio. Per la consultazione completa di tutti i dati '... 'relativi al sito in esame, ' char(232) ' possibile accedere con le proprie credenziali '... 'alla piattaforma interattiva web-based']); text4 = Paragraph('ASE - Advanced Slope Engineering S.r.l.'); text5 = Paragraph('Via Robert Koch 53/A, 43123 Fraz. Pilastrello, Parma - Italy'); text6 = Paragraph('Tel: +39 0521 1404292'); text7 = Paragraph('REA n. 258983 - Cod Fis. e P.IVA 02687890349'); text8 = Paragraph('info@aseltd.eu - www.aseltd.eu'); text.HAlign = 'justify'; text2.HAlign = 'justify'; text3.HAlign = 'justify'; text4.Style = {Bold(1),HAlign('left')}; text5.Style = {HAlign('left'),OuterMargin('0in','0in','0in','0in'),FontSize('8pt')}; text6.Style = {HAlign('left'),OuterMargin('0in','0in','0in','0in'),FontSize('8pt')}; text7.Style = {HAlign('left'),OuterMargin('0in','0in','0in','0in'),FontSize('8pt')}; text8.Style = {HAlign('left'),OuterMargin('0in','0in','0in','0in'),FontSize('8pt')}; logo = Image('aselogo.jpeg'); logo.Style = {Height('9cm'),HAlign('left')}; add(disclaimer,text); add(disclaimer,text2); add(disclaimer,text3); Link.Style = {OuterMargin('0in','0in','0in','0in')}; add(disclaimer,Link); add(disclaimer,logo); add(disclaimer,text4); add(disclaimer,text5); add(disclaimer,text6); add(disclaimer,text7); add(disclaimer,text8); br = PageBreak(); add(disclaimer,br); add(rpt,disclaimer); if activeEN == 1 disclaimer_ENG = Chapter; dis_ENG = Heading1('Disclaimer'); dis_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')}; disclaimer_ENG.Title = dis_ENG; % Disclaimer ENG text = Paragraph(['This report consists of a document automatically generated by ASE proprietary software. Its objective is '... 'to summarize the main monitoring results recorded during a specific time interval by the instrumentation installed on-site. Moreover, '... 'this document presents all the key information concerning the monitored site, including Arrays number and typology, installation date, '... 'reference date, installed sensors features, etc. The report is generated automatically on the first day of each month, and it contains '... 'monitoring data elaborated from the beginning of the previous month, in order to provide a general overview of the site activity '... 'during the reference time period. For specific typologies of sensors, the report also includes graphs composed of different physical quantities, '... 'in order to highlight any correlation between data sampled by these sensors.']); Link = Paragraph(ExternalLink('https://www2.aseltd.eu','this link.')); text2 = Paragraph(['We would like to remind that the report generation is completely automated, therefore it does not contain '... 'any technical evaluation or validation concerning the results obtained by the instrumentation installed on-site. '... 'Moreover, the report is intended as a resume of the main outcomes resulting from the monitoring activity. The user can access complete datasets '... 'and information concerning the monitored site by logging into the interactive web-based platform developed by ASE S.r.l., available at']); text7 = Paragraph('REA n. 258983 - VAT ID 02687890349'); text.HAlign = 'justify'; text2.HAlign = 'justify'; text7.Style = {HAlign('left'),OuterMargin('0in','0in','0in','0in'),FontSize('8pt')}; add(disclaimer_ENG,text); add(disclaimer_ENG,text2); Link.Style = {OuterMargin('0in','0in','0in','0in')}; add(disclaimer_ENG,Link); add(disclaimer_ENG,logo); add(disclaimer_ENG,text4); add(disclaimer_ENG,text5); add(disclaimer_ENG,text6); add(disclaimer_ENG,text7); add(disclaimer_ENG,text8); br = PageBreak(); add(disclaimer_ENG,br); add(rpt_ENG,disclaimer_ENG); end text = 'Disclaimer page created'; fprintf(fileID,fmt,text); fileID = fopen(FileName,'a'); %% Capitolo 1 - sistema MUMS sys = Chapter; app = Heading1('Sistema MUMS'); app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')}; sys.Title = app; testo = Paragraph(['Il monitoraggio ' char(232) ' svolto mediante sistema MUMS '... '(Modular Underground Monitoring System), progettato per il controllo multiparametrico dei movimenti '... 'orizzontali o verticali del terreno, delle deformazioni di strutture civili '... 'e/o geotecniche, di barriere paramassi o debris flow. In ogni nodo possono essere collocati sensori per monitorare '... 'grandezze fisiche di varia natura come spostamenti, inclinazioni, pressione interstiziale, temperatura, etc.']); testo2 = Paragraph(['In particolare, il sito ' char(232) ' caratterizzato dalla presenza di ' arraysito ' e relativo sistema'... ' di acquisizione automatico, completato da batteria tampone ed adeguato sistema di ricarica.']); if controlsito ~= 0 [rTA,~] = size(tipoalarms); aVMS = 0; aCAM = 0; aAL = 0; aTL = 0; for mm = 1:rTA if strcmp(char(tipoalarms(mm)),'Variable Message System') aVMS = 1; elseif strcmp(char(tipoalarms(mm)),'Traffic Lights') aCAM = 1; elseif strcmp(char(tipoalarms(mm)),'Alarms') aAL = 1; elseif strcmp(char(tipoalarms(mm)),'Camera') aCAM = 1; end end testo2prep = []; spazio = ''; if aAL > 0 if nAL == 1 testo2prep = [num2str(nAL) ' allarme acustico-visivo']; else testo2prep = [num2str(nAL) ' allarmi acustico-visivi']; end spazio = ', '; end if aTL > 0 if nTL == 1 testo2prep = [testo2prep spazio num2str(nTL) ' impianto semaforico']; else testo2prep = [testo2prep spazio num2str(nTL) ' impianti semaforici']; end spazio = ', '; end if aVMS > 0 if nVMS == 1 testo2prep = [testo2prep spazio num2str(nVMS) ' pannello a messaggio variabile']; else testo2prep = [testo2prep spazio num2str(nVMS) ' pannelli a messaggio variabile']; end spazio = ', '; end if aCAM > 0 if nCAM == 1 testo2prep = [testo2prep spazio num2str(nCAM) ' videocamera']; else testo2prep = [testo2prep spazio num2str(nCAM) ' videocamere']; end end testo2bis = Paragraph(['Il sistema inoltre include un dispositivo di allertamento composto da ' testo2prep '.']); else testo2bis = []; end testo3 = Paragraph(['I dati grezzi (punti elettrici) sono salvati su apposito supporto' ... ' di memoria locale (scheda SD) ed inviati al centro di elaborazione secondo la frequenza impostata. '... 'Una volta ricevute le informazioni, il dato viene salvato su un Database con backup giornaliero automatico, '... 'elaborato mediante software con algoritmi proprietari e reso disponibile su piattaforma web ad accesso '... 'controllato in pochi secondi.']); testo4 = Paragraph(['Il funzionamento completo del sisema MUMS ' char(232) ' schematizzato nella figura seguente.']); ionh = Image(('ionh.png')); testo.HAlign = 'justify'; testo2.HAlign = 'justify'; testo3.HAlign = 'justify'; testo4.HAlign = 'justify'; testo.HAlign = 'justify'; testo2.HAlign = 'justify'; testo3.HAlign = 'justify'; testo4.HAlign = 'justify'; ionhcaption = Paragraph(['Fig. ' num2str(FIG) ' - Struttura del sistema di monitoraggio']); FIG = FIG + 1; ionhcaption.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; ionh.Style = {Height('8cm'),HAlign('center')}; add(sys,testo); add(sys,testo2); if controlsito ~= 0 add(sys,testo2bis); end add(sys,testo3); add(sys,testo4); add(sys,ionh); add(sys,ionhcaption); add(rpt,sys); template(rpt); if activeEN == 1 sys_ENG = Chapter; app_ENG = Heading1('MUMS System'); app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')}; sys_ENG.Title = app_ENG; testo = Paragraph(['The monitoring activity is performed with MUMS '... '(Modular Underground Monitoring System) technology, specifically developed for the '... 'multi-parametric monitoring of slopes, civil and/or geotechnical structures, rockfall and '... 'debris flow barriers. Each node of the Array can equip sensors able to measure different '... 'physical quantities like displacements, tilts, pressure, temperatures, etc.']); testo2 = Paragraph(['In particular, the monitoring system installed on-site includes ' arraysitoENG... ', the automatic data acquisition '... 'system and a battery, with dedicated recharge apparatus.']); if controlsito ~= 0 testo2prep = []; spazio = ''; if aAL > 0 if aAL == 1 testo2prep = [num2str(nAL) ' visual-acoustic alarm']; else testo2prep = [num2str(nAL) ' visual-acoustic alarms']; end spazio = ', '; end if aTL > 0 if aTL == 1 testo2prep = [testo2prep spazio num2str(nTL) ' traffic light']; else testo2prep = [testo2prep spazio num2str(nTL) ' traffic lights']; end spazio = ', '; end if aVMS > 0 if aVMS == 1 testo2prep = [testo2prep spazio num2str(nVMS) ' variable message panel (VMP)']; else testo2prep = [testo2prep spazio num2str(nVMS) ' variable message panels (VMPs)']; end spazio = ', '; end if aCAM > 0 if aCAM == 1 testo2prep = [testo2prep spazio num2str(nCAM) ' camera']; else testo2prep = [testo2prep spazio num2str(nCAM) ' cameras']; end end testo2bis = Paragraph(['Moreover, the following devices are included for early warning purposes: ' testo2prep '.']); end testo3 = Paragraph(['The datalogger saves raw data (electrical signals) on a volatile memory (SD card) and then transmits them '... 'to the elaboration centre, according to a predefined frequency. Upon arrival on central server, a proprietary '... 'software routine automatically elaborates raw data and converts them into physical units. '... 'Results are stored in a "parallel" database from which they can be accessed and analysed '... 'thanks to a dedicated web-based platform with private access.']); testo4 = Paragraph('The following image describes the structure of the MUMS-based system.'); testo.HAlign = 'justify'; testo2.HAlign = 'justify'; testo3.HAlign = 'justify'; testo4.HAlign = 'justify'; ionhcaption = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Structure of the monitoring system']); FIG_ENG = FIG_ENG + 1; ionhcaption.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; ionh.Style = {Height('9cm'),HAlign('center')}; add(sys_ENG,testo); add(sys_ENG,testo2); if controlsito ~= 0 add(sys_ENG,testo2bis); end add(sys_ENG,testo3); add(sys_ENG,testo4); add(sys_ENG,ionh); add(sys_ENG,ionhcaption); add(rpt_ENG,sys_ENG); template(rpt_ENG); end text = 'MUMS system defined'; fprintf(fileID,fmt,text); fileID = fopen(FileName,'a'); fclose(fileID); %% Capitolo 2 - Geografia e composizione geoloc = Chapter; app = Heading1('Caratteristiche del sito'); app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')}; geoloc.Title = app; testo = Paragraph(['Le principali caratteristiche della strumentazione installata nel sito '... 'in esame sono riportate nella seguente tabella. Le figure sottostanti presentano la localizzazione '... 'geografica degli Array e del relativo sistema di acquisizione (immagini '... 'tratte da Mappe di Bing).']); comando = ['select lat, lon from sites where id like ''' siteID ''' ']; curs = exec(conn,comando); curs = fetch(curs); Coordinate = (cell2mat(curs.Data))'; latNS = 'N'; lonEO = 'E'; if Coordinate(1) < 0 latNS = 'S'; end if Coordinate(2) < 0 lonEO = 'O'; end testo.HAlign = 'justify'; testo2 = Paragraph(['In particolare, il sito in esame si trova '... 'alle seguenti coordinate geografiche: Latitudine ' num2str(abs(Coordinate(1))) ... ' ' latNS ', Longitudine ' num2str(abs(Coordinate(2,:))) ' ' lonEO '.']); testo2.HAlign = 'justify'; %--- IMMAGINI GEOGRAFICHE ---% mapsito = ['sito' siteID '.png']; geo = Image((mapsito)); geo.Style = [geo.Style {ScaleToFit}]; geo_cap = Paragraph(['Fig. ' num2str(FIG) ' - Localizzazione geografica della strumentazione installata e del sistema di acquisizione dati']); FIG = FIG+1; geo_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; mapcatene = ['sito' siteID 'det.png']; sito = Image((mapcatene)); sito.Style = [sito.Style {ScaleToFit}]; sito_cap = Paragraph(['Fig. ' num2str(FIG) ' - Posizione in sito delle centraline e degli strumenti installati']); FIG = FIG+1; sito_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; %--- TABELLA SITO MONITORATO ---% Font_Loc = 0; [Font_Loc,status,firstdata_num,datasample,colonna1,colonna2,colonna2bis,colonna3,... colonna4,colonna5,colonna6,colonna6_short,colonna7,yesKLHR3D,c1trigger,c6trigger,cA] = ... report_table(Font_Loc,info_sito,controlsito,tipoarray,tipoalarms,alarms,chainID,Chain_Scheme,... yesTL,yesTLHR,yesTLH,yesTLHRH,yesPL,yesBL,yesLL,yesRL,yesKL,yesKLHR,yesThL,... yesPT100,yesIPL,yesIPLHR,yesTuL,yesRaL,yesPCL,yesPCLHR,yesPrL,yesEL,yes3DEL,... yesWEL,yesMPBEL,yesCrL,yes3DCrL,yesBML,yesHL,yesLuxL,yesCO2,yesRSN,yesRSNHR,yesTrL,... yesPE,yesWL,yes2DCrL,yesGF,yesGS,rTL,rTLHR,rTLH,rTLHRH,rKL,rKLHR,rIPL,rIPLHR,nCT,... num_nodi,time,conn,FileName) ; % Controllo che Colonna 5 (lunghezza Array) abbia dei dati, % altrimenti la elimino [rC5,~] = size(colonna5); C5 = 0; for c = 2:rC5 if strcmp(char(colonna5(c)),'-') == 0 % Esiste almeno un valore di lunghezza C5 = 1; break end end if C5 == 1 tab = FormalTable([colonna1,colonna2,colonna2bis,colonna3,colonna4,colonna5,colonna6_short,colonna7]); else tab = FormalTable([colonna1,colonna2,colonna2bis,colonna3,colonna4,colonna6,colonna7]); end % formattazione tabella if Font_Loc == 1 tab.TableEntriesStyle = {HAlign('center'),VAlign('middle'),FontSize(Font_table_Loc),InnerMargin('0.5mm')}; else tab.TableEntriesStyle = {HAlign('center'),VAlign('middle'),FontSize(Font_table),InnerMargin('0.5mm')}; end tab.Style = {ResizeToFitContents(true),Width("100%"),RowSep('solid','black','1px'),... ColSep('solid','black','1px'),Hyphenation(false),BackgroundColor('#E0F1FF')}; tab.Border = 'single'; tabCaption = Paragraph('Tab. 1 - Tipologia e caratteristiche della strumentazione installata in sito'); tabCaption.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; bodyFirstRow = tab.Body.Children(1); bodyFirstRow.Style = [bodyFirstRow.Style {Bold()}]; if C5 == 0 grps(1) = TableColSpecGroup; grps(1).Span = 7; specs(1) = TableColSpec; specs(1).Span = 1; specs(1).Style = {Width("7.5%")}; specs(2) = TableColSpec; specs(2).Span = 3; specs(2).Style = {Width("15%")}; specs(3) = TableColSpec; specs(3).Span = 1; specs(3).Style = {Width("10%")}; specs(4) = TableColSpec; specs(4).Span = 1; specs(5) = TableColSpec; specs(5).Span = 1; specs(5).Style = {Width("12%")}; grps(1).ColSpecs = specs; tab.ColSpecGroups = grps; end % Installazione testo3 = Paragraph(['La prima lettura disponibile, riportata in Tab. 1, si riferisce '... 'alla data di inizio monitoraggio. Va sottolineato come i primissimi dati '... 'rilevati da uno strumento possano essere influenzati dagli assestamenti occorsi in '... 'seguito all''installazione o dall''adattamento del sensore in sito. Per questo motivo '... 'viene definita la lettura di riferimento come data in cui i dati raccolti non mostrano '... 'pi' char(249) ' i caratteri tipici dell''adattamento strumentale in sito (per maggiori informazioni '... 'consigliamo di fare riferimento agli standard ISO 18674-1:2015).']); testo3.HAlign = 'justify'; add(geoloc,testo); add(geoloc,testo2); add(geoloc,testo3); add(geoloc,tabCaption); add(geoloc,tab); add(geoloc,br); add(geoloc,geo); add(geoloc,geo_cap); add(geoloc,sito); add(geoloc,sito_cap); add(rpt,geoloc); template(rpt); if activeEN == 1 geoloc_ENG = Chapter; app_ENG = Heading1('Site features'); app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')}; geoloc_ENG.Title = app_ENG; testo = Paragraph(['The table reported below summarizes the main characteristics of the instrumentation installed on-site. '... 'Moreover, following images display the geographical position of the monitoring system, including the location of Arrays '... 'and acquisition devices (source: Bing Maps).']); if Coordinate(2) < 0 lonEO = 'W'; end testo.HAlign = 'justify'; testo2 = Paragraph(['Geographical coordinates of the monitored site are: '... 'Latitude ' num2str(abs(Coordinate(1))) ... ' ' latNS ', Longitude ' num2str(abs(Coordinate(2,:))) ' ' lonEO '.']); testo2.HAlign = 'justify'; %--- IMMAGINI GEOGRAFICHE ---% geo_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Geographical position of the monitored site']); FIG_ENG = FIG_ENG+1; geo_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; sito_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - On-site location of monitoring devices']); FIG_ENG = FIG_ENG+1; sito_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; %--- TABELLA SITO MONITORATO ---% [status,firstdata_num,datasample,colonna1,colonna2,colonna2bis,colonna3,... colonna4,colonna5,colonna6,colonna6_short,colonna7,yesKLHR3D,c1trigger,c6trigger,cA]... = report_table_ENG(info_sito,controlsito,tipoarray,tipoalarms,alarms,chainID,Chain_Scheme,... yesTL,yesTLHR,yesTLH,yesTLHRH,yesPL,yesBL,yesLL,yesRL,yesKL,yesKLHR,yesThL,... yesPT100,yesIPL,yesIPLHR,yesTuL,yesRaL,yesPCL,yesPCLHR,yesPrL,yesEL,yes3DEL,... yesWEL,yesMPBEL,yesCrL,yes3DCrL,yesBML,yesHL,yesLuxL,yesCO2,yesRSN,yesRSNHR,yesTrL,... yesPE,yesWL,yes2DCrL,yesGF,yesGS,rTL,rTLHR,rTLH,rTLHRH,rKL,rKLHR,rIPL,rIPLHR,nCT,... num_nodi,time,conn,FileName); % Controllo che Colonna 5 (lunghezza Array) abbia dei dati, % altrimenti la elimino [rC5,~] = size(colonna5); C5 = 0; for c = 2:rC5 if strcmp(char(colonna5(c)),'-') == 0 % Esiste almeno un valore di lunghezza C5 = 1; break end end if C5 == 1 tab = FormalTable([colonna1,colonna2,colonna2bis,colonna3,colonna4,colonna5,colonna6_short,colonna7]); else tab = FormalTable([colonna1,colonna2,colonna2bis,colonna3,colonna4,colonna6,colonna7]); end % formattazione tabella if Font_Loc == 1 tab.TableEntriesStyle = {HAlign('center'),VAlign('middle'),FontSize(Font_table_Loc),InnerMargin('0.5mm')}; else tab.TableEntriesStyle = {HAlign('center'),VAlign('middle'),FontSize(Font_table),InnerMargin('0.5mm')}; end tab.Style = {ResizeToFitContents(true),Width("100%"),RowSep('solid','black','1px'),... ColSep('solid','black','1px'),Hyphenation(false),BackgroundColor('#E0F1FF')}; tab.Border = 'single'; tabCaption = Paragraph('Tab. 1 - Instrumentation typologies and features'); tabCaption.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; bodyFirstRow = tab.Body.Children(1); bodyFirstRow.Style = [bodyFirstRow.Style {Bold()}]; if C5 == 0 grps(1) = TableColSpecGroup; grps(1).Span = 7; specs(1) = TableColSpec; specs(1).Span = 1; specs(1).Style = {Width("7.5%")}; specs(2) = TableColSpec; specs(2).Span = 3; specs(2).Style = {Width("15%")}; specs(3) = TableColSpec; specs(3).Span = 1; specs(3).Style = {Width("10%")}; specs(4) = TableColSpec; specs(4).Span = 1; specs(5) = TableColSpec; specs(5).Span = 1; specs(5).Style = {Width("12%")}; grps(1).ColSpecs = specs; tab.ColSpecGroups = grps; end % Installazione testo3 = Paragraph(['The first available reading date, reported in Tab. 1, '... 'refers to the beginning of the monitoring activity. '... 'It should be taken into account that the very first monitoring data '... 'are usually influenced by stabilization phenomena, which are a '... 'natural consequence of the tool installation on-site. For this reason, '... 'a reference reading date is defined, representing a time reference '... 'where the device can be considered fully operational since no more '... 'stabilization movements are observed from sampled data '... '(we suggest to refer to the International Standard EN ISO 18674-1:2015 '... 'documentation for further information on this matter).']); testo3.HAlign = 'justify'; add(geoloc_ENG,testo); add(geoloc_ENG,testo2); add(geoloc_ENG,testo3); add(geoloc_ENG,tabCaption); add(geoloc_ENG,tab); add(geoloc_ENG,br); add(geoloc_ENG,geo); add(geoloc_ENG,geo_cap); add(geoloc_ENG,sito); add(geoloc_ENG,sito_cap); add(rpt_ENG,geoloc_ENG); template(rpt_ENG); end fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'Site information defined'; fprintf(fileID,fmt,text); fileID = fopen(FileName,'a'); fclose(fileID); %% Capitolo 3 - Centraline % --- Analisi centraline e catene --- datalogger = Chapter; app = Heading1('Risultati - Dati delle centraline'); app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')}; datalogger.Title = app; datalogger_ENG = Chapter; if activeEN == 1 app_ENG = Heading1('Results - Control units'); app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')}; datalogger_ENG.Title = app_ENG; end [FIG,FIG_ENG,datarif,contunit,IDscaduta] = report_CU(unitID,chainID,adesso,datainvio,numgiorni,... datasample,tipoarray,firstdata_num,siteID,datalogger,datalogger_ENG,FIG,FIG_ENG,rpt,rpt_ENG,... Font_caption,Font_section,activeEN,conn,FileName); fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'Control units information defined'; fprintf(fileID,fmt,text); fileID = fopen(FileName,'a'); fclose(fileID); %% Capitolo 4 - Catene MUMS = Chapter; app = Heading1('Risultati - Dati della strumentazione installata'); app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter)}; MUMS.Title = app; if activeEN == 1 MUMS_ENG = Chapter; app_ENG = Heading1('Results - Monitoring tools'); app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter)}; MUMS_ENG.Title = app_ENG; else MUMS_ENG = []; end [PL_A,PL_D,FIG,FIG_ENG] = report_AR(chainID,unitID,tipoarray,contunit,... siteID,FIG,FIG_ENG,rpt,rpt_ENG,Font_caption,Font_Chapter,Font_section,... Font_tools,datarif,yesKLHR3D,rTL,rTLHR,rTLH,rTLHRH,rPL,rBL,rLL,rRL,rKL,... rKLHR,rThL,rPT100,rIPL,rIPLHR,rTuL,rRaL,rPCL,rPCLHR,rPrL,rEL,r3DEL,rWEL,rMPBEL,... rCrL,r2DCrL,r3DCrL,rBML,rHL,rLuxL,rCO2,rRSN,rRSNHR,rTrL,rPE,rWL,rGF,rGS,... NodoTiltLink,NodoTiltLinkH,NodoPiezoLink,NodoBaroLink,NodoLoadLink,... NodoRainLink,NodoKlinoLink,NodoKlinoLinkHR,NodoThermLink,NodoPT100Link,... NodoInPlaceLink,NodoInPlaceLinkHR,NodoTunnelLink,NodoRadialLink,NodoPreConvLink,... NodoPressureLink,NodoExtensometerLink,Nodo3DExtensometerLink,... NodoWireExtensometerLink,NodoMultiPointExtensometerLink,NodoCrackLink,... Nodo2DCrackLink,Nodo3DCrackLink,NodoBaroMusaLink,NodoHumidityLink,NodoLuxLink,... NodoCO2Link,NodoRSNLink,NodoRSNHRLink,NodoTriggerLink,NodoStressMeter,NodoWeirLink,... NodoPendulum,MUMS,MUMS_ENG,colonna2,colonna2bis,colonna4,firstdata_num,activeEN,IDscaduta,... status,br,conn,FileName); fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'Arrays information defined'; fprintf(fileID,fmt,text); fileID = fopen(FileName,'a'); fclose(fileID); %% Capitolo 5 - Control Tools if cA > 1 % Significa che ci sono CT CT = Chapter; app = Heading1('Risultati - Attivazioni dei Control Tools'); app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter)}; CT.Title = app; if activeEN == 1 CT_ENG = Chapter; app_ENG = Heading1('Results - Control Tools activations'); app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter)}; CT_ENG.Title = app_ENG; else CT_ENG = []; end [FIG,FIG_ENG] = report_CT(c1trigger,c6trigger,alarms,nCT,rpt,Font_caption,... Font_table,Font_section,datarif,CT,CT_ENG,FIG,FIG_ENG,activeEN,conn,FileName); fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'Control tools information defined'; fprintf(fileID,fmt,text); fileID = fopen(FileName,'a'); fclose(fileID); end %% Appendice [dim,~]= size(colonna6); appendice = Chapter; app = Heading1('Appendice'); app.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')}; appendice.Title = app; if activeEN == 1 appendice_ENG = Chapter; app_ENG = Heading1('Appendix'); app_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')}; appendice_ENG.Title = app_ENG; else appendice_ENG = []; end report_appendix(yesTL,yesIPL,yesIPLHR,yesTLH,yesPCL,yesTLHR,yesTLHRH,yesPCLHR,... yesPL,yesBL,yesTuL,yesRaL,yesThL,yesKL,yesKLHR,yesRL,yesLL,yesPrL,yesPT100,... yesCrL,yes3DCrL,yesEL,yes3DEL,yesWEL,yesMPBEL,yesTrL,nCAM,yesWL,yesPE,PL_A,PL_D,... Font_section,Font_caption,Font_tools,FIG,FIG_ENG,dim,appendice,appendice_ENG,... colonna4,colonna6,rpt,rpt_ENG,activeEN,FileName) % Chiudi report close(rpt); close(rpt_ENG); %% ---Email--- [rU,cU] = size(Users_Report); sendReportmail(NomeSito,Coordinate,meseadesso,NomeReport,NomeReport_ENG,... Users_Report,recipients_ASE,Mail,Mail_ASE,activeEN,rU,cU,FileName); end end end else datainvio = meseadesso+1; if datainvio > 12 datainvio = datainvio-12; end end %% --- Modifica file di testo --- %%% if numgiorni == 30 if datainvio == 12 nuovofile = 1; elseif datainvio == 13 nuovofile = 13; else nuovofile = adesso+1; end else nuovofile = datainvio + numgiorni; end attivaReport = 0; outdat = fopen(NomeFile,'wt+'); fopen(NomeFile,'wt'); fmt = '%d \r'; fileID = fopen(NomeFile,'a'); fprintf(fileID,fmt,nuovofile); fprintf(fileID,fmt,attivaReport); fclose(fileID); catch err FileErr = ['ErrorFile-' IDcentralina '-' datestr(today) '-' datestr(now,'hhMMss') '.txt']; fid = fopen(FileErr,'a+'); fprintf(fid, '%s', err.getReport('extended','hyperlinks','off')); fclose(fid); % Scarico la frequenza del report comando = ['select freq_report from sites where id like ''' siteID ''' ']; curs = exec(conn,comando); curs = fetch(curs); Freq = cell2mat(curs.Data); numgiorni = Freq; NomeFile = strcat('Report',siteID,'.txt'); if isfile(NomeFile) == 1 % Esiste Filetesto = importdata(NomeFile); datainvio = Filetesto(1,1); % mese di invio OPPURE data di ultimo invio else datainvio = meseadesso+1; if datainvio > 12 datainvio = datainvio-12; end end attivaReport = 0; outdat = fopen(NomeFile,'wt+'); fopen(NomeFile,'wt'); fmt = '%d \r'; fileID = fopen(NomeFile,'a'); if numgiorni == 30 if datainvio == 12 nuovofile = 12; elseif datainvio == 13 nuovofile = 13; else nuovofile = adesso; end else nuovofile = datainvio; end fprintf(fileID,fmt,nuovofile); fprintf(fileID,fmt,attivaReport); fclose(fileID); %% Email setpref('Internet','E_mail','aseparma@gmail.com'); setpref('Internet','SMTP_Server','smtp.gmail.com'); setpref('Internet','SMTP_Username','aseparma@gmail.com'); setpref('Internet','SMTP_Password','Mums@2016'); props=java.lang.System.getProperties; pp=props.setProperty('mail.smtp.auth','true'); %#ok pp=props.setProperty('mail.smtp.socketFactory.class','javax.net.ssl.SSLSocketFactory'); %#ok pp=props.setProperty('mail.smtp.socketFactory.port','465'); %#ok subject_ITA = (['CRASH del Report Automatico - ' NomeSito '']); testo = cellstr('Ciao Andrea e Alessandro,'); testobis = cellstr(''); testo2 = cellstr(['Nella funzione del report avete scritto qualche minchiata per cui crasha. Vi prego di correggermi '... 'o continuer' char(243) ' a crashare e ad assillarvi con questa mail. Troverete l''errore in allegato.']); message_ITA = [testo; testobis; testo2]; message = cellstr('Tanti Bip e Bop a te, '); message2 = cellstr('Software Tilt'); message_ITA = [message_ITA; message; message2]; recipients_ASE{1,1} = 'alessandro.valletta@aseltd.eu'; recipients_ASE{2,1} = 'andrea.carri@aseltd.eu'; allegato = FileErr; sendmail(recipients_ASE, subject_ITA, message_ITA, allegato) end fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'report_ASE function executed correctly'; fprintf(fileID,fmt,text); fclose(fileID); end