📄 inca_matlab_api_demo.m
字号:
% handles structure with handles and user data (see GUIDATA)
try
defAns = {getpref('INCA','device'),...
getpref('INCA','calElements'),''};
answer = inputdlg({'Device Name:', 'Calibration Element:(Scalar / Curve / Map)',...
'Display Mode: (2 for displayed and updated, 1 for just displayed, and 0 for no display)'},...
'Add Calibration Element to Signal Group',1,defAns);
catch
answer = inputdlg({'Device Name:', 'Calibration Element:(Scalar / Curve / Map)',...
'Display Mode: (2 for displayed and updated, 1 for just displayed, and 0 for no display)'},...
'Add Calibration Element to Signal Group');
end
if ~isempty(answer)
setpref('INCA','device',answer{1})
setpref('INCA','calElements',answer{2})
if isempty(answer{3})
IncaAddCalibrationElement(answer{1},answer{2})
else
IncaAddCalibrationElement(answer{1},answer{2},str2num(answer{3}))
end
end
% --------------------------------------------------------------------
function calRead_Callback(hObject, eventdata, handles)
% hObject handle to calRead (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','calElements')};
answer = inputdlg({'Device Name:', 'Calibration Element Name'},...
'Read a Calibration Element from a Signal Group',1,defAns);
catch
answer = inputdlg({'Device Name:', 'Calibration Element Name'},...
'Read a Calibration Element from a Signal Group');
end
value = '';
xbreak = '';
ybreak = '';
if ~isempty(answer)
setpref('INCA','device',answer{1})
setpref('INCA','calElements',answer{2})
value = IncaGetCalibrationValue(answer{1},answer{2});
set(handles.textV,'string',num2str(value(1,1)))
set(handles.textV,'userdata',value)
try
xbreak = IncaGetCalibrationValue(answer{1},answer{2},'x');
set(handles.calEditX,'string',num2str(xbreak),...
'value',1)
catch
set(handles.calEditX,'string','-------------',...
'value',1)
end
try
ybreak = IncaGetCalibrationValue(answer{1},answer{2},'y');
set(handles.calEditY1,'string',num2str(ybreak),...
'value',1)
catch
set(handles.calEditY1,'string','-------------',...
'value',1)
end
end
assignin('base','INCAcalDataValue',value)
assignin('base','INCAcalDataXbreak',xbreak)
assignin('base','INCAcalDataYbreak',ybreak)
%--------------------------------------------------------------------
function calSet_Callback(hObject, eventdata, handles)
% hObject handle to calSet (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','calElements'),'0','v'};
answer = inputdlg({'Device Name:', 'Calibration Element:(Scalar / Curve / Map)'...
'Calibration Value:','Calibration Value Type:(v / x / y)'},...
'Set Calibration Element in a Signal Group',1,defAns);
catch
answer = inputdlg({'Device Name:', 'Calibration Element:(Scalar / Curve / Map)'...
'Calibration Value:','Calibration Value Type:(v / x / y)'},...
'Set Calibration Element in a Signal Group');
end
if ~isempty(answer)
setpref('INCA','device',answer{1})
setpref('INCA','calElements',answer{2})
if isempty(answer{4})
IncaSetCalibrationValue(answer{1}, answer{2}, str2num(answer{3}));
else
IncaSetCalibrationValue(answer{1}, answer{2}, str2num(answer{3}), answer{4});
end
end
% --------------------------------------------------------------------
function memActivate_Callback(hObject, eventdata, handles)
% hObject handle to memActivate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
answer = inputdlg({'Device Name:', 'Page Name:(WP / RP)'},'Activate Memory Page',1,{getpref('INCA','device'),'WP'});
if ~isempty(answer)
IncaSwitchPage(answer{1},answer{2})
end
% --------------------------------------------------------------------
function checkWrite_Callback(hObject, eventdata, handles)
% hObject handle to checkWrite (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
answer = inputdlg({'Device Name:', 'Page Name:(WP / RP)'},'Activate Memory Page',1,{getpref('INCA','device'),'WP'});
if ~isempty(answer)
iswrite = IncaIsPageWriteProtected(answer{1},answer{2})
if iswrite
msgbox('Memory page is write-protected',...
'Memory Page Write-Protection','help')
else
msgbox('Memory page is NOT write-protected',...
'Memory Page Write-Protection','help')
end
end
% --------------------------------------------------------------------
function memDownload_Callback(hObject, eventdata, handles)
% hObject handle to memDownload (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'),'WP'};
answer = inputdlg({'Device Name:', 'Page Name:(WP / RP)'},'Download Selected Memory Page',1,defAns);
catch
defAns = {'','WP'};
answer = inputdlg({'Device Name:', 'Page Name:(WP / RP)'},'Download Selected Memory Page',1,defAns);
end
if ~isempty(answer)
IncaSwitchPage(answer{1},answer{2})
end
% --------------------------------------------------------------------
function memCopy_Callback(hObject, eventdata, handles)
% hObject handle to memCopy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
answer = inputdlg({'Device Name:', 'Source Page Name:(WP / RP)', 'Destination Page Name:(WP / RP)'},...
'Copy Memory Page',1,{getpref('INCA','device'),'RP','WP'});
if ~isempty(answer)
IncaCopyPageFromTo(answer{1},answer{2},answer{3})
end
% --------------------------------------------------------------------
function memDiff_Callback(hObject, eventdata, handles)
% hObject handle to memDiff (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
answer = inputdlg({'Device Name:'},...
'Loads The Differences Between The Memory Pages',1,{getpref('INCA','device')});
if ~isempty(answer)
IncaDownloadDifferences(answer{1})
end
% --------------------------------------------------------------------
function getRecord_Callback(hObject, eventdata, handles)
% hObject handle to getRecord (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','measElementsGroup'),'1000'};
answer = inputdlg({'Device Name:','Group Name:', 'Maximum number of records to be transfered:'},...
'Get Current Records',1,defAns);
catch
answer = inputdlg({'Device Name:','Group Name:', 'Maximum number of records to be transfered:'},...
'Get Current Records');
end
if ~isempty(answer)
[time, data] = IncaGetRecords(answer{1},answer{2},str2num(answer{3}));
assignin('base','time',time)
assignin('base','data',data)
setpref('INCA','device',answer{1})
setpref('INCA','measElementsGroup',answer{2})
end
plot(time,data)
xlabel
% --------------------------------------------------------------------
function demoDummy_Callback(hObject, eventdata, handles)
% hObject handle to demoDummy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
notebook('INCADummyDeviceDemo.doc')
% --------------------------------------------------------------------
function demoEtkDummy_Callback(hObject, eventdata, handles)
% hObject handle to demoEtkDummy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
notebook('INCAetkDummyDeviceDemo.doc')
% --- Executes on button press in readDataToggle.
function readDataToggle_Callback(hObject, eventdata, handles)
% hObject handle to readDataToggle (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of readDataToggle
val = get(hObject,'value');
if val
set(hObject,'backgroundcolor',[0 1 0])
try
defAns = {getpref('INCA','device'), getpref('INCA','measElementsGroup'),'1000'};
answer = inputdlg({'Device Name:','Group Name:', 'Maximum number of records to be transfered:'},...
'Get Current Records',1,defAns);
catch
answer = inputdlg({'Device Name:','Group Name:', 'Maximum number of records to be transfered:'},...
'Get Current Records');
end
if ~isempty(answer)
device = answer{1};
group = answer{2};
sample = str2num(answer{3});
fcn = sprintf('readfunction(%s,%s,%d)',device,group,sample);
t = timer( 'Period', .2,'ExecutionMode','fixedRate');
set(t,'timerfcn',{'readfunction', device, group, sample,gca})
start(t)
setpref('INCA','device',device)
setpref('INCA','measElementsGroup',group)
end
else
set(hObject,'backgroundcolor',[1 0 0])
a = timerfind;
stop(a);delete(a)
set(handles.axes1,'userdata','')
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function calEditV_Callback(hObject, eventdata, handles)
% hObject handle to calEditV (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of calEditV as text
% str2double(get(hObject,'String')) returns contents of calEditV as a double
v = get(handles.calEditV,'value');
v2 = get(handles.calEditV2,'value');
data = get(handles.textV,'userdata');
if ~isempty(data)
set(handles.textV,'string',data(v,v2))
else
set(handles.textV,'string','----------------')
end
function calEditX_Callback(hObject, eventdata, handles)
% hObject handle to calEditX (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of calEditX as text
% str2double(get(hObject,'String')) returns contents of calEditX as a double
y = get(handles.calEditY1,'value');
x = get(handles.calEditX,'value');
if ~isempty(str2num(get(handles.calEditX,'string')))
data = get(handles.textV,'userdata');
if ~isempty(data)
set(handles.textV,'string',data(x,y))
else
set(handles.textV,'string','----------------')
end
end
function calEditY1_Callback(hObject, eventdata, handles)
% hObject handle to calEditY1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of calEditY1 as text
% str2double(get(hObject,'String')) returns contents of calEditY1 as a double
y = get(handles.calEditY1,'value');
x = get(handles.calEditX,'value');
if ~isempty(str2num(get(handles.calEditY1,'string')))
data = get(handles.textV,'userdata');
if ~isempty(data)
set(handles.textV,'string',data(x,y))
else
set(handles.textV,'string','----------------')
end
end
% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes1
% --- Executes on button press in gridbutton.
function gridbutton_Callback(hObject, eventdata, handles)
% hObject handle to gridbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of gridbutton
val = get(hObject,'Value');
if val
grid on
else
grid off
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes1,'userdata','')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -