📄 inca_matlab_api_demo.m
字号:
function varargout = INCA_MATLAB_API_demo(varargin)
% INCA_MATLAB_API_DEMO M-file for INCA_MATLAB_API_demo.fig
% INCA_MATLAB_API_DEMO, by itself, creates a new INCA_MATLAB_API_DEMO or raises the existing
% singleton*.
%
% H = INCA_MATLAB_API_DEMO returns the handle to a new INCA_MATLAB_API_DEMO or the handle to
% the existing singleton*.
%
% INCA_MATLAB_API_DEMO('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in INCA_MATLAB_API_DEMO.M with the given input arguments.
%
% INCA_MATLAB_API_DEMO('Property','Value',...) creates a new INCA_MATLAB_API_DEMO or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before INCA_MATLAB_API_demo_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to INCA_MATLAB_API_demo_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help INCA_MATLAB_API_demo
% Last Modified by GUIDE v2.5 27-Oct-2005 22:04:55
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @INCA_MATLAB_API_demo_OpeningFcn, ...
'gui_OutputFcn', @INCA_MATLAB_API_demo_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before INCA_MATLAB_API_demo is made visible.
function INCA_MATLAB_API_demo_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to INCA_MATLAB_API_demo (see VARARGIN)
% Choose default command line output for INCA_MATLAB_API_demo
handles.output = hObject;
handles.pref = getpref('INCA');
if isempty(handles.pref)
addpref('INCA','databaseDir', '')
addpref('INCA','experiment', '')
addpref('INCA','device','')
addpref('INCA','calElements','')
addpref('INCA','measElementsGroup','')
addpref('INCA','measElementsSignal','')
handles.pref = getpref('INCA');
end
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes INCA_MATLAB_API_demo wait for user response (see UIRESUME)
% uiwait(handles.figure1);
xlabel('Time')
ylabel('Measured Units')
% --- Outputs from this function are returned to the command line.
function varargout = INCA_MATLAB_API_demo_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function databaseOpen_Callback(hObject, eventdata, handles)
% hObject handle to databaseOpen (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
try
dname = uigetdir( handles.pref.databaseDir, 'Choose the directory containing your database.')
catch
dname = uigetdir(' ','Choose the directory containing your database.')
end
if isstr(dname)
IncaOpenDatabase(dname)
setpref('INCA','databaseDir',dname)
set(handles.pathDatabase,'string',dname)
end
% --------------------------------------------------------------------
function experOpen_Callback(hObject, eventdata, handles)
% hObject handle to experOpen (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
prompts = {'Input the name of the experiment folder:'...
'Input the name of the experiment:'...
'Input the name of the INCA workspace folder:'...
'Input the name of the INCA workspace:'};
dlg_title = 'Experiment Configuration';
num_lines = 1;
defAns = getpref('INCA','experiment');
if isempty(defAns)
defAns = {'', '.vk', '', '.ws'};
end
answer = inputdlg(prompts,dlg_title,num_lines,defAns);
if ~isempty(answer)
button = questdlg('Would you like to close all INCA measure and calibration windows?',...
'Close All Views','Yes');
end
switch button
case 'Yes'
IncaOpenExperiment(answer{1},answer{2},answer{3},answer{4},1);
setpref('INCA','experiment',answer)
case 'No'
IncaOpenExperiment(answer{1},answer{2},answer{3},answer{4},0);
setpref('INCA','experiment',answer)
otherwise
setpref('INCA','experiment',answer)
end
% --------------------------------------------------------------------
function monitor_Callback(hObject, eventdata, handles)
% hObject handle to monitor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
checked = get(hObject, 'checked');
if strcmp(checked, 'on')
IncaShowMessages(0) % ETAS mex function to disable command line messages
set(hObject,'checked', 'off')
else
IncaShowMessages(1) % ETAS mex function to enable command line messages
set(hObject,'checked', 'on')
end
% --------------------------------------------------------------------
function resetExper_Callback(hObject, eventdata, handles)
% hObject handle to resetExper (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
IncaResetExperiment
% --------------------------------------------------------------------
function INCAversion_Callback(hObject, eventdata, handles)
% hObject handle to INCAversion (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
version = IncaGetVersion;
helpdlg(sprintf('You are running INCA version: %s',version),...
sprintf('INCA %s',version))
% --------------------------------------------------------------------
function startMeas_Callback(hObject, eventdata, handles)
% hObject handle to startMeas (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if strcmp(get(hObject,'checked'),'off')
IncaStartMeasurement
set(hObject,'checked','on')
set(handles.stopMeas,'checked','off')
end
% --------------------------------------------------------------------
function stopMeas_Callback(hObject, eventdata, handles)
% hObject handle to stopMeas (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if strcmp(get(hObject,'checked'),'off')
if strcmp(get(handles.startRecord,'checked'),'on')
file = get(handles.MDFfile,'string');
IncaStopMeasurement(file)
set(handles.startRecord,'checked','off')
set(handles.stopRecord,'checked','on')
else
IncaStopMeasurement
end
set(hObject,'checked','on')
set(handles.startMeas,'checked','off')
end
set(handles.readDataToggle,'backgroundcolor',[1 0 0])
a = timerfind;
stop(a);delete(a)
% --------------------------------------------------------------------
function startRecord_Callback(hObject, eventdata, handles)
% hObject handle to startRecord (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if strcmp(get(hObject,'checked'),'off')
IncaStartRecording
set(hObject,'checked','on')
set(handles.stopRecord,'checked','off')
end
% --------------------------------------------------------------------
function stopRecord_Callback(hObject, eventdata, handles)
% hObject handle to stopRecord (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
file = get(handles.MDFfile,'string');
if strcmp(get(hObject,'checked'),'off')
IncaStopRecording(file)
set(hObject,'checked','on')
set(handles.startRecord,'checked','off')
end
% --------------------------------------------------------------------
function readMode_Callback(hObject, eventdata, handles)
% hObject handle to readMode (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if strcmp(get(hObject,'checked'),'on')
IncaSetMeasureReadMode(1)
set(hObject,'checked','off')
else
IncaSetMeasureReadMode(0)
set(hObject,'checked','on')
end
% --------------------------------------------------------------------
function bufferReset_Callback(hObject, eventdata, handles)
% hObject handle to bufferReset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
IncaResetRecords
% --------------------------------------------------------------------
function addMeas_Callback(hObject, eventdata, handles)
% hObject handle to addMeas (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
try
defAns = {getpref('INCA','device'),...
getpref('INCA','measElementGroup'),...
getpref('INCA','measElementSignal'),''};
answer = inputdlg({'Device Name:','Group Name:', 'Signal Name:', 'Display Mode: (1 on / 0 off)'},...
'Add a Measurement Element to a Signal Group',1,defAns);
catch
answer = inputdlg({'Device Name:','Group Name:', 'Signal Name:', 'Display Mode: (1 on / 0 off)'},...
'Add a Measurement Element to a Signal Group');
end
if ~isempty(answer)
setpref('INCA','device',answer{1})
setpref('INCA','measElementGroup',answer{2})
setpref('INCA','measElementSignal',answer{3})
if isempty(answer{4})
IncaAddMeasureElement(answer{1}, answer{2}, answer{3});
else
IncaAddMeasureElement(answer{1}, answer{2}, answer{3}, str2num(answer{4}));
end
end
% --------------------------------------------------------------------
function start_Callback(hObject, eventdata, handles)
% hObject handle to start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% If INCA has been opened by MATLAB and then closed, some classes may not
% be cleared enabling the application to be opened.
warning off;
clear classes;
warning on;
% ETAS mex-function to open INCA
IncaOpen
% --- Executes during object creation, after setting all properties.
function pathDatabase_CreateFcn(hObject, eventdata, handles)
% hObject handle to pathDatabase (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
try
set(hObject,'string',getpref('INCA','databaseDir'));
catch
set(hObject,'string',' ');
end
% --------------------------------------------------------------------
function recordFile_Callback(hObject, eventdata, handles)
% hObject handle to recordFile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uiputfile( ...
{'*.dat';'*.mdf';'*.*'}, ...
'Save MDF File as');
if isstr(pathname)
setpref('INCA','MDFfile',{pathname,filename})
set(handles.MDFfile,'string',[pathname,filename])
end
% --- Executes during object creation, after setting all properties.
function MDFfile_CreateFcn(hObject, eventdata, handles)
% hObject handle to MDFfile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
try
file = getpref('INCA','MDFfile');
set(hObject,'string',[file{1},file{2}]);
catch
set(hObject,'string',' ');
end
% --------------------------------------------------------------------
function incrementFile_Callback(hObject, eventdata, handles)
% hObject handle to incrementFile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function calAdd_Callback(hObject, eventdata, handles)
% hObject handle to calAdd (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -