1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| function appareil
clear all
close all
clc
%% CREATION FIGURE
fig = figure ('units','pixels',...
'position',[200 200 800 400],...
'name','Appareil',...
'toolbar','figure',...
'tag','fig');
%% CREATION AXES
handles.axes = axes('units','pixels',...
'position',[280 40 480 320],'tag','axes1');
grid on
handles.courbe = plot(NaN,NaN);
%% TIMER POUR AFFICHAGE SPECTRE
handles.timer = timer(...
'ExecutionMode','fixedRate',...
'Period',1,...
'TimerFcn', @updateMAYA,...
'tag','timapp');
%% BOUTON START
handles.start = uicontrol ('style','pushbutton',...
'units','pixels','position',[10 160 60 30],...
'string','START','BackgroundColor','g',...
'callback',@startapp);
%% BOUTON STOP
handles.stop = uicontrol ('style','pushbutton',...
'units','pixels','position',[100 160 60 30],...
'string','STOP','background','r',...
'callback',@stopapp);
handles.appareil = [];
guidata(fig,handles);
function startapp(obj,event)
fig = findobj('Type','Figure','Tag','fig');
handles = guidata(fig);
handles.appareil = icdevice('Driver_de_l'appareil')
connect(handles.appareil);
if isvalid(handles.timer)
start(handles.timer);
end
guidata (fig,handles);
function stopapp(obj,event)
fig = findobj('Type','Figure','Tag','fig');
handles = guidata(fig);
if isvalid(handles.timer)
stop(handles.timer);
end
guidata (fig,handles);
function updateMAYA (obj,event)
fig = findobj('Type','Figure','Tag','fig');
handles = guidata(fig);
spectrometerIndex = 0; % Indice de l'appareil à utiliser (le premier par défaut)
channelIndex = 0; % Indice du canal à utiliser (le premier par défaut)
abs = invoke(handles.appareil, 'getWavelengths', spectrometerIndex, channelIndex);
ord = invoke(handles.appareil, 'getSpectrum', spectrometerIndex);
x = get(handles.courbe, 'XData');
y = get(handles.courbe, 'YData');
set(handles.courbe, 'XData', [x abs], 'YData', [y ord]);
drawnow;
function closefig(obj,event)
h = timerfind('tag','timeapp');
if isvalid(h)
stop(h);
delete(h);
end
closereq; |