Sync from remote server: 2025-10-12 18:56:41
This commit is contained in:
206
ATD/report_WEL_ENG.m
Executable file
206
ATD/report_WEL_ENG.m
Executable file
@@ -0,0 +1,206 @@
|
||||
function [FIG,battANALOG,ATTIVA] = report_WEL_ENG(rWEL,m,NodoWireExtensometerLink,toolrif,...
|
||||
unitrif,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()
|
||||
|
||||
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
|
||||
WE = Section();
|
||||
sezWEL = Heading3('Wire Extensometer Link');
|
||||
sezWEL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
|
||||
WE.Title = sezWEL;
|
||||
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. Temperature data are displayed below.']);
|
||||
testoB1.HAlign = 'justify';
|
||||
testoB2.HAlign = 'justify';
|
||||
|
||||
% grafico batteria
|
||||
figure(19)
|
||||
plot(Date,Batteria);
|
||||
hold on
|
||||
title('Battery Level');
|
||||
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')};
|
||||
sezBATT = Paragraph('GMUX - Battery level and temperature');
|
||||
sezBATT.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
|
||||
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,sezWEL);
|
||||
for w = 1:rWEL(m,1)
|
||||
NodeNum = num2str(NodoWireExtensometerLink(w,m));
|
||||
comando = ['select EventDate, EventTime, 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
|
||||
allungamento = cell2mat(Dati(:,3)); % allungamento filo
|
||||
var_X = allungamento - allungamento(1,:);
|
||||
|
||||
% grafico allungamento NELL'ULTIMO MESE
|
||||
figure(10);
|
||||
wire = plot(Date,var_X);
|
||||
title(['Wire length variation - sensor ' NodeNum]);
|
||||
xlabel('Date [dd/mm/yyyy]');
|
||||
ylabel('Wire lengthening(+)/shortening(-) [mm]');
|
||||
h = gca;
|
||||
h.XAxis.MinorTick = 'on';
|
||||
datetick('x','dd/mm/yyyy','keepticks','keeplimits');
|
||||
xtickangle(20);
|
||||
grid on
|
||||
grid minor
|
||||
control = max(abs(var_X));
|
||||
if control < 1 % mm
|
||||
ylim([-1 1]);
|
||||
end
|
||||
|
||||
TempName = char(strcat('Report',siteID,'-', char(toolrif),'-WireExt', NodeNum, '_ENG.png'));
|
||||
saveas(wire,TempName);
|
||||
ChartWEL = Image(TempName);
|
||||
ChartWEL.Style = {Height('7.3cm'),HAlign('center')};
|
||||
ChartWEL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Length variation of the wire connected to the extensometer ' NodeNum...
|
||||
' recorded during the reference time period']);
|
||||
FIG = FIG+1;
|
||||
ChartWEL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
|
||||
testo = Paragraph(['The following graph displays the wire length variation recorded by the wire extensometer ' NodeNum ...
|
||||
'. Specifically, positive values indicate a lengthening of the wire, while'...
|
||||
'a shortening of the wire is represented by negative values.']);
|
||||
testo2 = Paragraph(['DurantDuring the reference time period, '...
|
||||
'node ' NodeNum ' recorded a maximum value of wire length equal to'...
|
||||
num2str(round(max(var_X),2), '%0.2f') ' mm and a minimum value of ' num2str(round(min(var_X),2), '%0.2f')...
|
||||
' mm, resulting in a variation of '...
|
||||
num2str(round(max(var_X),2)-round(min(var_X),2),'%0.2f') ' mm.' ]);
|
||||
testo.HAlign = 'justify';
|
||||
testo2.HAlign = 'justify';
|
||||
if w == 1
|
||||
add(DT,testo);
|
||||
end
|
||||
add(DT,testo2);
|
||||
add(DT,ChartWEL);
|
||||
add(DT,ChartWEL_cap);
|
||||
if w == rWEL(m,1)
|
||||
add(DT,br);
|
||||
end
|
||||
close(figure(10));
|
||||
% pulisco variabili da riutilizzare per catena successiva
|
||||
clear deform;
|
||||
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_WEL_ENG function executed correctly';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user