88 lines
3.1 KiB
Matlab
Executable File
88 lines
3.1 KiB
Matlab
Executable File
function report_CT_ENG(c1trigger,c6trigger,alarms,rA,rpt,Font_caption,...
|
|
Font_table,datarif,CT,conn,FileName)
|
|
|
|
import mlreportgen.dom.*
|
|
import mlreportgen.report.*
|
|
|
|
% Make sure DOM is compilable
|
|
makeDOMCompilable()
|
|
|
|
CT_Att = zeros(1,rA);
|
|
att = cell(1,rA);
|
|
for A = 1:rA
|
|
array = char(alarms(A,2));
|
|
comando = ['select EventDate, EventTime, XShift, X from ELABDATACTRL where EventDate > ''' ...
|
|
datestr(datenum(datarif),'yyyy-mm-dd') ''' and CtrlToolName = ''' ...
|
|
array ''' '];
|
|
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_Loc = cell2mat(Dati(:,3)); % Attivazioni Locali
|
|
Att_Cum = cell2mat(Dati(:,4)); % Attivazioni Cumulate
|
|
Att_Loc_Tot = cumsum(Att_Loc);
|
|
testo = Paragraph(['During the reference time period, '...
|
|
'the control tool was activated ' num2str(Att_Loc_Tot(end)) ' times.' ]);
|
|
testo2 = Paragraph(['The same device has been activated a total of '...
|
|
num2str(Att_Cum(end)) ' times since the beginning of the monitoring activity.' ]);
|
|
if Att_Loc_Tot(end) > 1
|
|
CT_Att(1,A) = A;
|
|
end
|
|
testo.HAlign = 'justify';
|
|
testo2.HAlign = 'justify';
|
|
add(CT,testo);
|
|
add(CT,testo2);
|
|
att_temp = find(Att_Loc);
|
|
if isempty(att_temp) == 0
|
|
att{1,A} = splitlines(strjoin(cellstr(Date(att_temp)), '\n'));
|
|
end
|
|
else
|
|
testo = Paragraph('No data available for the reference time period.');
|
|
add(CT,testo);
|
|
end
|
|
end
|
|
clear A
|
|
A = find(CT_Att); % Cerco eventuali attivazioni nei singoli dispositivi CT
|
|
if isempty(A) == 0
|
|
colonna1(1,1) = {'ID'};
|
|
colonna2(1,1) = {'Control tool typology'};
|
|
colonna3(1,1) = {'Activations [dd-mm-yyyy hh:MM:ss]'};
|
|
disp = c1trigger(A);
|
|
type = c6trigger(A);
|
|
[num,~] = size(disp);
|
|
for n = 1:num
|
|
colonna1(n+1,1) = {disp};
|
|
colonna2(n+1,1) = {type};
|
|
colonna3(n+1,1) = {att};
|
|
end
|
|
tab = FormalTable([colonna1,colonna2,colonna3]);
|
|
% formattazione tabella
|
|
tab.TableEntriesStyle = {HAlign('center'),VAlign('middle'),FontSize(Font_table),InnerMargin('0.5mm')};
|
|
tab.Style = {ResizeToFitContents(true),Width("100%"),RowSep('solid','black','1px'),...
|
|
ColSep('solid','black','1px'),Hyphenation(false),BackgroundColor('#E0F1FF')};
|
|
tab.Border = 'single';
|
|
tabCaption = Paragraph('Tab. 2 - Control tools typology and activations number during the reference time period');
|
|
tabCaption.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
|
bodyFirstRow = tab.Body.Children(1);
|
|
bodyFirstRow.Style = [bodyFirstRow.Style {Bold()}];
|
|
|
|
add(CT,tabCaption);
|
|
add(CT,tab);
|
|
end
|
|
br = PageBreak();
|
|
add(CT,br);
|
|
add(rpt,CT);
|
|
template(rpt);
|
|
|
|
fileID = fopen(FileName,'a');
|
|
fmt = '%s \r';
|
|
text = 'report_CT_ENG function executed correctly';
|
|
fprintf(fileID,fmt,text);
|
|
fclose(fileID);
|
|
|
|
end |