function ATTIVA = report_TrL(NodoTriggerLink,rTrL,m,Font_tools,br,datarif,toolrif,... unitrif,DT,DT_ENG,activeEN,status,ATTIVA,conn,FileName) fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'report_TrL function started'; fprintf(fileID,fmt,text); import mlreportgen.dom.* import mlreportgen.report.* % Make sure DOM is compilable makeDOMCompilable() if status(m,1) == 1 if ATTIVA == 1 ATTIVA = 0; testo = Paragraph('Trigger non ancora installato o inattivo.'); add(DT,testo); if activeEN == 1 testo = Paragraph('Trigger not installed or inactive.'); add(DT_ENG,testo); end end elseif status(m,1) == 3 if ATTIVA == 1 ATTIVA = 0; testo = Paragraph(['Monitoraggio completato. Invitiamo a visitare la '... 'piattaforma web per la visione dei dati storici.']); 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 for t = 1:rTrL(m,1) NodeNum = num2str(NodoTriggerLink(t,m)); comando = ['select EventDate, EventTime, X, XShift 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 Att_Tot = cell2mat(Dati(:,3)); % attivazioni totali da inizio monitoraggio Att = cell2mat(Dati(:,4)); % attivazioni nel periodo di riferimento Att_Rif = cumsum(Att); sezTrig = Paragraph('Trigger Link'); sezTrig.Style = {FontSize(Font_tools),Bold(1),Italic(1)}; TR = Section(); TR.Title = sezTrig; add(DT,sezTrig); if activeEN == 1 sezTrig_ENG = Paragraph('Trigger Link'); sezTrig_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)}; TR_ENG = Section(); TR_ENG.Title = sezTrig_ENG; add(DT_ENG,sezTrig_ENG); end testo = Paragraph(['Durante il periodo temporale di riferimento, '... 'sono state registrate ' num2str(Att_Rif(end)) ' attivazioni del sensore Trigger. '... 'Il numero di attivazioni totali dalla data di inizio monitoraggio ' char(232) ' pari '... 'a ' num2str(Att_Tot(end)) '.' ]); testo.HAlign = 'justify'; add(DT,testo); if Att_Rif > 0 % ci sono attivazioni nel periodo di riferimento testo2 = Paragraph(['Di seguito sono riportate le date, relative al periodo temporale di riferimento, '... 'nelle quali ' char(232) ' stata identificata un''attivazione del Trigger Link: ']); testo2.HAlign = 'justify'; add(DT,testo2); nd = size(Date); for dt = 1:nd if Att(dt) == 1 text = ['- ' datestr(Date(dt),'dd/mm/yyyy HH:MM:SS')]; testodata = Paragraph(text); add(DT,testodata); end end end add(DT,br); % -- ENG -- if activeEN == 1 testo = Paragraph(['During the reference time period, '... 'the Trigger sensor activated ' num2str(Att_Rif(end)) ' times. '... 'The total amount of activations since the beginning of the monitoring activity is '... 'equal to ' num2str(Att_Tot(end)) '.' ]); testo.HAlign = 'justify'; add(DT_ENG,testo); if Att_rif > 0 % ci sono attivazioni nel periodo di riferimento testo2 = Paragraph(['The activation dates for what concern the reference time period '... 'are reported below: ']); testo2.HAlign = 'justify'; add(DT_ENG,testo2); nd = size(Date); for dt = 1:nd if Att(dt) == 1 textENG = ['- ' datestr(Date(dt),'dd/mm/yyyy HH:MM:SS')]; testodataENG = Paragraph(textENG); add(DT_ENG,testodataENG); end end end add(DT_ENG,br); end % pulisco variabili da riutilizzare per catena successiva clear Att_Tot clear Att clear Att_Rif 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 fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'report_TrL function executed correctly. report_TrL function closed'; fprintf(fileID,fmt,text); fclose(fileID); end