?? advfigure.m
字號:
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in button4.
global g_ADVMXAHandle
if handles.menuNumber == 0
%*---------------------------------------------------*
% Start/Stop button was pressed in the main menu.
%*---------------------------------------------------*
if strcmpi( get( handles.button3, 'String' ), 'Start' )
% Initialize the timer object
t = timer( 'TimerFcn', @timer_Callback, ...
'StartDelay', 0.0, ...
'Period', 0.01, ...
'ExecutionMode', 'fixedRate' );
% Update the GUI data to include the timer handle
handles.timer = t;
guidata( handles.advFigure, handles );
set( t, 'UserData', handles );
% Change start button to stop
set( handles.button3, 'String', 'Stop' );
drawnow
% Start the timer
start( t );
else
% Stop the timer
stop( handles.timer );
delete( handles.timer );
% Change button text back to start
set( handles.button3, 'String', 'Start' );
% Update the GUI data
handles.timer = 0;
guidata( handles.advFigure, handles );
end
elseif handles.menuNumber == 1
%*---------------------------------------------------*
% Analog plus button was pressed in the display
% mode selection menu.
%*---------------------------------------------------*
% Change mode to analog plus
handles.displayMode = 1;
ADV_SetDisplayMode( g_ADVMXAHandle, 1, handles );
guidata( handles.advFigure, handles );
% Update timer user data
if handles.timer ~= 0
set( handles.timer, 'UserData', handles );
end
% Switch to the main menu
ShowMainMenu( handles );
end
function button4_Callback(hObject, eventdata, handles)
% hObject handle to button4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global g_ADVMXAHandle
if handles.menuNumber == 0
% Restart
ADV_Reset( g_ADVMXAHandle );
elseif handles.menuNumber == 1
% Change mode to waterfall
handles.displayMode = 2;
ADV_SetDisplayMode( g_ADVMXAHandle, 2, handles );
guidata( handles.advFigure, handles );
% Update timer user data
if handles.timer ~= 0
set( handles.timer, 'UserData', handles );
end
% Switch to the main menu
ShowMainMenu( handles );
end
% --- Executes on button press in button5.
function button5_Callback(hObject, eventdata, handles)
% hObject handle to button5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global g_ADVMXAHandle
if handles.menuNumber == 1
% Change mode to waterfall
handles.displayMode = 3;
ADV_SetDisplayMode( g_ADVMXAHandle, 3, handles );
guidata( handles.advFigure, handles );
% Update timer user data
if handles.timer ~= 0
set( handles.timer, 'UserData', handles );
end
% Switch to the main menu
ShowMainMenu( handles );
end
% --- Executes on button press in button6.
function button6_Callback(hObject, eventdata, handles)
% hObject handle to button6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in button7.
function button7_Callback(hObject, eventdata, handles)
% hObject handle to button7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global g_ADVClosing
if handles.menuNumber == 0
% Stop the timer, if it is executing
if handles.timer ~= 0
stop( handles.timer );
delete( handles.timer );
g_ADVClosing = 1;
else
% Execute termination code
ADV_Close;
% Close the figure
close( handles.advFigure );
end
elseif handles.menuNumber == 1
% Return to main menu
ShowMainMenu( handles );
end
%*******************************************************************
% ShowMainMenu
%
% Configures the buttons to display the main menu.
%*******************************************************************
function ShowMainMenu( handles )
% Determine mode button name
switch handles.displayMode
case 0
modeName = 'Analog Adv';
case 1
modeName = 'Analog Plus';
case 2
modeName = 'Waterfall';
case 3
modeName = 'Spectrogram';
end
% Change button names
set( handles.button1, 'Visible', 'off' );
set( handles.button2, 'String', modeName, 'FontWeight', 'normal' );
if handles.timer ~= 0
if strcmpi( get( handles.timer, 'Running' ), 'off' ) == 1
startText = 'Start';
else
startText = 'Stop';
end
else
startText = 'Start';
end
set( handles.button3, 'Visible', 'on' );
set( handles.button3, 'String', startText, 'FontWeight', 'normal' );
set( handles.button4, 'Visible', 'on' );
set( handles.button4, 'String', 'Restart' );
set( handles.button5, 'Visible', 'off' );
set( handles.button6, 'Visible', 'off' );
set( handles.button7, 'String', 'Exit' );
% Update the menu number
handles.menuNumber = 0;
guidata( handles.advFigure, handles );
drawnow;
%*******************************************************************
% Timer Callback
%
% Executes the code that is required for each iteration of the
% timer loop. This callback is used to acquire the data from the
% MXA and perform the post processing and display functions.
%*******************************************************************
function timer_Callback( hObject, eventdata )
global g_ADVTraceFIFO
global g_ADVXAxis
global g_ADVYAxis
global g_ADVPersistBuffer
global g_ADVMXAHandle
global g_ADVClosing
% Retrieve the figure handles structure
handles = get( hObject, 'UserData' );
% Acquire data from the MXA
data = MXA_AcquireData( g_ADVMXAHandle );
ADV_DataToBuffer( g_ADVMXAHandle, data );
% Make sure the timer is still running
if isvalid( handles.timer ) == 0
return;
end
% Update the display
figure( handles.advFigure );
uicontrol( handles.button7 );
if handles.displayMode == 0
% Analog advanced
image( g_ADVXAxis, g_ADVYAxis, g_ADVPersistBuffer );
set( handles.mainAxes, 'YDir', 'normal' );
elseif handles.displayMode == 1
% Analog plus
image( g_ADVXAxis, g_ADVYAxis, g_ADVPersistBuffer );
set( handles.mainAxes, 'YDir', 'normal' );
elseif handles.displayMode == 2
% Waterfall
mesh( handles.mainAxes, g_ADVYAxis, g_ADVXAxis, g_ADVTraceFIFO, 'MeshStyle', 'Column' );
set( handles.mainAxes, 'View', [95, 30] );
elseif handles.displayMode == 3
% Spectrogram
mesh( handles.mainAxes, g_ADVYAxis, g_ADVXAxis, g_ADVTraceFIFO );
set( handles.mainAxes, 'View', [90, 90] );
end
if g_ADVClosing == 1
% Terminate ADV
ADV_Close;
% Close figure
close( handles.advFigure );
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -