PageRenderTime 33ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/ATF2/FlightSim/testApps/multiKnobs/multiKnobs.m

http://atf2flightsim.googlecode.com/
MATLAB | 623 lines | 329 code | 88 blank | 206 comment | 46 complexity | 1d428cd1e641b44324e4384bfa33feb0 MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.0, IPL-1.0, BSD-3-Clause
  1. function varargout = multiKnobs(varargin)
  2. % MULTIKNOBS M-file for multiKnobs.fig
  3. % MULTIKNOBS, by itself, creates a new MULTIKNOBS or raises the existing
  4. % singleton*.
  5. %
  6. % H = MULTIKNOBS returns the handle to a new MULTIKNOBS or the handle to
  7. % the existing singleton*.
  8. %
  9. % MULTIKNOBS('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in MULTIKNOBS.M with the given input arguments.
  11. %
  12. % MULTIKNOBS('Property','Value',...) creates a new MULTIKNOBS or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before multiKnobs_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to multiKnobs_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22. % Edit the above text to modify the response to help multiKnobs
  23. % Last Modified by GUIDE v2.5 19-Jan-2012 00:50:07
  24. % Begin initialization code - DO NOT EDIT
  25. gui_Singleton = 1;
  26. gui_State = struct('gui_Name', mfilename, ...
  27. 'gui_Singleton', gui_Singleton, ...
  28. 'gui_OpeningFcn', @multiKnobs_OpeningFcn, ...
  29. 'gui_OutputFcn', @multiKnobs_OutputFcn, ...
  30. 'gui_LayoutFcn', [] , ...
  31. 'gui_Callback', []);
  32. if nargin && ischar(varargin{1})
  33. gui_State.gui_Callback = str2func(varargin{1});
  34. end
  35. if nargout
  36. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  37. else
  38. gui_mainfcn(gui_State, varargin{:});
  39. end
  40. % End initialization code - DO NOT EDIT
  41. % --- Executes just before multiKnobs is made visible.
  42. function multiKnobs_OpeningFcn(hObject, eventdata, handles, varargin)
  43. % This function has no output args, see OutputFcn.
  44. % hObject handle to figure
  45. % eventdata reserved - to be defined in a future version of MATLAB
  46. % handles structure with handles and user data (see GUIDATA)
  47. % varargin command line arguments to multiKnobs (see VARARGIN)
  48. global FL
  49. % Choose default command line output for multiKnobs
  50. handles.output = handles;
  51. % Restore options
  52. restoreList={'edit2','String',0};
  53. guiRestoreFn('multiKnobs',handles,restoreList);
  54. % Get Knobs
  55. [stat pars]=multiKnobsFn('GetPars');
  56. set(handles.popupmenu1,'String',pars.knobNames)
  57. if ismember(pars.lastKnob,pars.knobNames)
  58. set(handles.popupmenu1,'Value',find(ismember(pars.knobNames,pars.lastKnob)))
  59. else
  60. set(handles.popupmenu1,'Value',1)
  61. end
  62. popupmenu1_Callback(handles.popupmenu1,[],handles);
  63. % Create and Start readback value monitoring process
  64. if ~isfield(FL,'t_multiKnobs') || ~strcmp(FL.t_multiKnobs,'on')
  65. FL.t_multiKnobs=timer('TimerFcn','multiKnobs(''timerFcn'')','Period',3,'StopFcn','multiKnobs(''timerStopFcn'')',...
  66. 'TasksToExecute',15e10,'ExecutionMode','fixedSpacing','StartDelay',3);
  67. start(FL.t_multiKnobs)
  68. end
  69. % Update handles structure
  70. guidata(hObject, handles);
  71. % Timer function
  72. function timerFcn
  73. global FL
  74. try
  75. stat=sreq; if stat{1}~=1; error('server proccess busy'); end;
  76. sreq('multiKnobsTimer');
  77. if isfield(FL.Gui,'multiKnobs') && ishandle(FL.Gui.multiKnobs.figure1)
  78. knames=get(FL.Gui.multiKnobs.popupmenu1,'String');
  79. [stat readback]=multiKnobsFn('GetReadback',knames{get(FL.Gui.multiKnobs.popupmenu1,'Value')});
  80. if stat{1}~=1 || any(isnan(readback))
  81. if isequal(stat{2},'No Cal Data')
  82. set(FL.Gui.multiKnobs.text4,'String','---')
  83. end
  84. set(FL.Gui.multiKnobs.text2,'BackgroundColor','red');
  85. set(FL.Gui.multiKnobs.text3,'BackgroundColor','red');
  86. set(FL.Gui.multiKnobs.text6,'BackgroundColor','red');
  87. else
  88. set(FL.Gui.multiKnobs.text2,'BackgroundColor','white');
  89. set(FL.Gui.multiKnobs.text3,'BackgroundColor','white');
  90. set(FL.Gui.multiKnobs.text6,'BackgroundColor','white');
  91. units=get(FL.Gui.multiKnobs.popupmenu2,'String');
  92. thisUnits=str2double(units{get(FL.Gui.multiKnobs.popupmenu2,'Value')});
  93. set(FL.Gui.multiKnobs.text2,'String',num2str(readback(1)/thisUnits))
  94. set(FL.Gui.multiKnobs.text3,'String',num2str(readback(2)/thisUnits))
  95. if length(readback)>=4
  96. set(FL.Gui.multiKnobs.text6,'String',[num2str(readback(3)/thisUnits,2) ' : ' num2str(readback(4)/thisUnits,2)]);
  97. else
  98. set(FL.Gui.multiKnobs.text6,'String','---')
  99. end
  100. end
  101. end
  102. sreq('multiKnobsTimer');
  103. uiresume(FL.Gui.multiKnobs.figure1)
  104. catch
  105. % warning(lasterr)
  106. stat=sreq;
  107. if stat{1}~=1 && any(strcmp(stat{2},'multiKnobsTimer'))
  108. sreq('multiKnobsTimer');
  109. end
  110. timerStopFcn
  111. uiresume(FL.Gui.multiKnobs.figure1)
  112. end
  113. % check access status
  114. if isempty(strfind(FL.mode,'trusted'))
  115. [stat data]=multiKnobsFn('GetData');
  116. knames=get(FL.Gui.multiKnobs.popupmenu1,'String');
  117. kname=knames{get(FL.Gui.multiKnobs.popupmenu1,'Value')};
  118. if isfield(data,kname) && isfield(data.(kname),'access') && isempty(data.(kname).access)
  119. pushbutton9_Callback(FL.Gui.multiKnobs.pushbutton9,[],FL.Gui.multiKnobs);
  120. end
  121. end
  122. % Function to run in case of timer error
  123. function timerStopFcn
  124. global FL
  125. if isfield(FL.Gui,'multiKnobs') && ishandle(FL.Gui.multiKnobs.figure1)
  126. set(FL.Gui.multiKnobs.text2,'BackgroundColor','black');
  127. set(FL.Gui.multiKnobs.text3,'BackgroundColor','black');
  128. end
  129. % --- Outputs from this function are returned to the command line.
  130. function varargout = multiKnobs_OutputFcn(hObject, eventdata, handles)
  131. % varargout cell array for returning output args (see VARARGOUT);
  132. % hObject handle to figure
  133. % eventdata reserved - to be defined in a future version of MATLAB
  134. % handles structure with handles and user data (see GUIDATA)
  135. % Get default command line output from handles structure
  136. varargout{1} = handles.output;
  137. % --- EXIT button
  138. function pushbutton1_Callback(hObject, eventdata, handles)
  139. % hObject handle to pushbutton1 (see GCBO)
  140. % eventdata reserved - to be defined in a future version of MATLAB
  141. % handles structure with handles and user data (see GUIDATA)
  142. global FL
  143. stop(FL.t_multiKnobs);
  144. multiKnobsFn('save');
  145. guiCloseFn('multiKnobs',handles);
  146. % --- Make new multiKnob
  147. function pushbutton8_Callback(hObject, eventdata, handles)
  148. % hObject handle to pushbutton8 (see GCBO)
  149. % eventdata reserved - to be defined in a future version of MATLAB
  150. % handles structure with handles and user data (see GUIDATA)
  151. global FL
  152. FL.Gui.multiKnobs_edit=multiKnobs_edit;
  153. % --- Edit selected multiKnbob
  154. function pushbutton7_Callback(hObject, eventdata, handles)
  155. % hObject handle to pushbutton7 (see GCBO)
  156. % eventdata reserved - to be defined in a future version of MATLAB
  157. % handles structure with handles and user data (see GUIDATA)
  158. global FL
  159. knobNames=get(handles.popupmenu1,'String');
  160. thisKnobName=knobNames{get(handles.popupmenu1,'Value')};
  161. if exist(['userMK_',thisKnobName,'.m'],'file')
  162. edit(fullfile('testApps','multiKnobs',['userMK_',thisKnobName,'.m']))
  163. else
  164. FL.Gui.multiKnobs_edit=multiKnobs_edit;
  165. set(FL.Gui.multiKnobs_edit.edit4,'String',thisKnobName)
  166. multiKnobs_edit('pushbutton11_Callback',FL.Gui.multiKnobs_edit.pushbutton11,[],FL.Gui.multiKnobs_edit)
  167. end
  168. % --- Select Knob
  169. function popupmenu1_Callback(hObject, eventdata, handles)
  170. % hObject handle to popupmenu1 (see GCBO)
  171. % eventdata reserved - to be defined in a future version of MATLAB
  172. % handles structure with handles and user data (see GUIDATA)
  173. % Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
  174. % contents{get(hObject,'Value')} returns selected item from popupmenu1
  175. knobNames=get(hObject,'String');
  176. thisKnobName=knobNames{get(hObject,'Value')};
  177. [stat knobData]=multiKnobsFn('GetData',thisKnobName);
  178. if isfield(knobData,'guiUnits')
  179. storedUnits=knobData.guiUnits;
  180. unitsel=find(strcmp(get(handles.popupmenu2,'String'),storedUnits));
  181. if ~isempty(unitsel)
  182. set(handles.popupmenu2,'Value',unitsel)
  183. end
  184. end
  185. units=get(handles.popupmenu2,'String');
  186. thisUnits=str2double(units{get(handles.popupmenu2,'Value')});
  187. if stat{1}~=1
  188. errordlg(stat{2},'Get Data Error')
  189. return
  190. end
  191. set(handles.edit1,'String',num2str(knobData.val/thisUnits))
  192. set(handles.edit2,'String',num2str(knobData.stepVal/thisUnits))
  193. set(handles.edit3,'String',num2str(knobData.storedVal/thisUnits))
  194. % Reset knob readback
  195. pushbutton10_Callback(handles.pushbutton10,[],handles);
  196. % Get access permissions
  197. % pushbutton9_Callback(handles.pushbutton9,[],handles);
  198. % Get controls reference info and display
  199. [stat refVals reftime]=multiKnobsFn('GetControlsRef',thisKnobName);
  200. if stat{1}==1
  201. set(handles.text7,'String',datestr(reftime))
  202. end
  203. % Get info about any calibration performed
  204. if isfield(knobData,'caldata') && ~isempty(knobData.caldata)
  205. set(handles.text4,'String',knobData.caldata)
  206. end
  207. if isfield(knobData,'caltype') && any(strcmp(knobData.caltype,get(handles.popupmenu3,'String')))
  208. set(handles.popupmenu3,'Value',find(strcmp(knobData.caltype,get(handles.popupmenu3,'String'))))
  209. end
  210. % Display any user comments
  211. [stat comments]=multiKnobsFn('GetComment',thisKnobName);
  212. if stat{1}==1
  213. set(handles.edit4,'String',comments)
  214. else
  215. set(handles.edit4,'String',['Error Getting any comments for this knob: ',stat{1,2}])
  216. end
  217. % Set des value to zero
  218. set(handles.edit1,'String','0.0')
  219. % --- Executes during object creation, after setting all properties.
  220. function popupmenu1_CreateFcn(hObject, eventdata, handles)
  221. % hObject handle to popupmenu1 (see GCBO)
  222. % eventdata reserved - to be defined in a future version of MATLAB
  223. % handles empty - handles not created until after all CreateFcns called
  224. % Hint: popupmenu controls usually have a white background on Windows.
  225. % See ISPC and COMPUTER.
  226. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  227. set(hObject,'BackgroundColor','white');
  228. end
  229. function edit3_Callback(hObject, eventdata, handles)
  230. % hObject handle to edit3 (see GCBO)
  231. % eventdata reserved - to be defined in a future version of MATLAB
  232. % handles structure with handles and user data (see GUIDATA)
  233. knobNames=get(handles.popupmenu1,'String'); thisKnobName=knobNames{get(handles.popupmenu1,'Value')};
  234. if isnan(str2double(get(hObject,'String')))
  235. errordlg('Bad entry','MultiKnob Value Error')
  236. [stat knobData]=multiKnobsFn('GetData',thisKnobName);
  237. set(hObject,'String',num2str(knobData.storedVal))
  238. else
  239. multiKnobsFn('SetStoredVal',thisKnobName,str2double(get(hObject,'String')));
  240. end
  241. % --- Executes during object creation, after setting all properties.
  242. function edit3_CreateFcn(hObject, eventdata, handles)
  243. % hObject handle to edit3 (see GCBO)
  244. % eventdata reserved - to be defined in a future version of MATLAB
  245. % handles empty - handles not created until after all CreateFcns called
  246. % Hint: edit controls usually have a white background on Windows.
  247. % See ISPC and COMPUTER.
  248. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  249. set(hObject,'BackgroundColor','white');
  250. end
  251. % --- Go to stored value
  252. function pushbutton6_Callback(hObject, eventdata, handles)
  253. % hObject handle to pushbutton6 (see GCBO)
  254. % eventdata reserved - to be defined in a future version of MATLAB
  255. % handles structure with handles and user data (see GUIDATA)
  256. knobNames=get(handles.popupmenu1,'String');
  257. thisKnobName=knobNames{get(handles.popupmenu1,'Value')};
  258. units=get(handles.popupmenu2,'String');
  259. thisUnits=str2double(units{get(handles.popupmenu2,'Value')});
  260. multiKnobsFn('GetControlsRefTemp',thisKnobName);
  261. stat=multiKnobsFn('SetStoredVal',thisKnobName,str2double(get(handles.edit3,'String'))*thisUnits);
  262. if stat{1}~=1
  263. errordlg(stat{2},'MultiKnob Error')
  264. return
  265. end
  266. set(handles.edit1,'String',get(handles.edit3,'String'))
  267. pushbutton2_Callback(handles.pushbutton2,[],handles);
  268. function edit2_Callback(hObject, eventdata, handles)
  269. % hObject handle to edit2 (see GCBO)
  270. % eventdata reserved - to be defined in a future version of MATLAB
  271. % handles structure with handles and user data (see GUIDATA)
  272. % Hints: get(hObject,'String') returns contents of edit2 as text
  273. % str2double(get(hObject,'String')) returns contents of edit2 as a double
  274. if isnan(str2double(get(hObject,'String')))
  275. errordlg('Bad entry','MultiKnob Value Error')
  276. knobNames=get(handles.popupmenu1,'String'); thisKnobName=knobNames{get(handles.popupmenu1,'Value')};
  277. [stat knobData]=multiKnobsFn('GetData',thisKnobName);
  278. set(hObject,'String',num2str(knobData.stepVal))
  279. end
  280. % --- Executes during object creation, after setting all properties.
  281. function edit2_CreateFcn(hObject, eventdata, handles)
  282. % hObject handle to edit2 (see GCBO)
  283. % eventdata reserved - to be defined in a future version of MATLAB
  284. % handles empty - handles not created until after all CreateFcns called
  285. % Hint: edit controls usually have a white background on Windows.
  286. % See ISPC and COMPUTER.
  287. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  288. set(hObject,'BackgroundColor','white');
  289. end
  290. % --- Step Down
  291. function pushbutton4_Callback(hObject, eventdata, handles)
  292. % hObject handle to pushbutton4 (see GCBO)
  293. % eventdata reserved - to be defined in a future version of MATLAB
  294. % handles structure with handles and user data (see GUIDATA)
  295. set(handles.edit1,'String',num2str(str2double(get(handles.edit1,'String'))-str2double(get(handles.edit2,'String'))))
  296. pushbutton2_Callback(handles.pushbutton2,[],handles)
  297. % --- Step Up
  298. function pushbutton5_Callback(hObject, eventdata, handles)
  299. % hObject handle to pushbutton5 (see GCBO)
  300. % eventdata reserved - to be defined in a future version of MATLAB
  301. % handles structure with handles and user data (see GUIDATA)
  302. set(handles.edit1,'String',num2str(str2double(get(handles.edit1,'String'))+str2double(get(handles.edit2,'String'))))
  303. pushbutton2_Callback(handles.pushbutton2,[],handles)
  304. function edit1_Callback(hObject, eventdata, handles)
  305. % hObject handle to edit1 (see GCBO)
  306. % eventdata reserved - to be defined in a future version of MATLAB
  307. % handles structure with handles and user data (see GUIDATA)
  308. % Hints: get(hObject,'String') returns contents of edit1 as text
  309. % str2double(get(hObject,'String')) returns contents of edit1 as a double
  310. if isnan(str2double(get(hObject,'String')))
  311. errordlg('Bad entry','MultiKnob Value Error')
  312. knobNames=get(handles.popupmenu1,'String'); thisKnobName=knobNames{get(handles.popupmenu1,'Value')};
  313. [stat knobData]=multiKnobsFn('GetData',thisKnobName);
  314. set(hObject,'String',num2str(knobData.val))
  315. end
  316. % --- Executes during object creation, after setting all properties.
  317. function edit1_CreateFcn(hObject, eventdata, handles) %#ok<*INUSD>
  318. % hObject handle to edit1 (see GCBO)
  319. % eventdata reserved - to be defined in a future version of MATLAB
  320. % handles empty - handles not created until after all CreateFcns called
  321. % Hint: edit controls usually have a white background on Windows.
  322. % See ISPC and COMPUTER.
  323. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  324. set(hObject,'BackgroundColor','white');
  325. end
  326. % --- Set Val
  327. function pushbutton2_Callback(hObject, eventdata, handles) %#ok<*INUSL>
  328. % hObject handle to pushbutton2 (see GCBO)
  329. % eventdata reserved - to be defined in a future version of MATLAB
  330. % handles structure with handles and user data (see GUIDATA)
  331. sreq_wait;
  332. knobNames=get(handles.popupmenu1,'String');
  333. units=get(handles.popupmenu2,'String');
  334. thisUnits=str2double(units{get(handles.popupmenu2,'Value')});
  335. thisKnobName=knobNames{get(handles.popupmenu1,'Value')};
  336. % First store current control value settings in temp storage for undo
  337. % option
  338. multiKnobsFn('GetControlsRefTemp',thisKnobName);
  339. stat=multiKnobsFn('SetVal',thisKnobName,str2double(get(handles.edit1,'String'))*thisUnits);
  340. if stat{1}~=1
  341. errordlg(stat{2},'MultiKnob SetVal Error')
  342. return
  343. end
  344. sreq_wait('restart');
  345. drawnow('expose')
  346. % --- Executes when user attempts to close figure1.
  347. function figure1_CloseRequestFcn(hObject, eventdata, handles) %#ok<*DEFNU>
  348. % hObject handle to figure1 (see GCBO)
  349. % eventdata reserved - to be defined in a future version of MATLAB
  350. % handles structure with handles and user data (see GUIDATA)
  351. global FL
  352. stop(FL.t_multiKnobs);
  353. multiKnobsFn('save');
  354. guiCloseFn('multiKnobs',handles);
  355. % --- Access Request Button
  356. function pushbutton9_Callback(hObject, eventdata, handles)
  357. % hObject handle to pushbutton9 (see GCBO)
  358. % eventdata reserved - to be defined in a future version of MATLAB
  359. % handles structure with handles and user data (see GUIDATA)
  360. sreq_wait;
  361. knames=get(handles.popupmenu1,'String');
  362. knobName=knames{get(handles.popupmenu1,'Value')};
  363. [stat resp]=multiKnobsFn('AccessRequest',knobName,1);
  364. if stat{1}~=1; resp=false; end;
  365. if resp
  366. set(hObject,'BackgroundColor','green')
  367. set(hObject,'String','Granted')
  368. else
  369. set(hObject,'BackgroundColor','red')
  370. set(hObject,'String','Denied')
  371. end
  372. sreq_wait('restart');
  373. % --- Access Permissions button create function
  374. function pushbutton9_CreateFcn(hObject, eventdata, handles)
  375. % hObject handle to pushbutton9 (see GCBO)
  376. % eventdata reserved - to be defined in a future version of MATLAB
  377. % handles empty - handles not created until after all CreateFcns called
  378. global FL
  379. if isfield(FL,'mode') && strcmp(FL.mode,'trusted')
  380. set(hObject,'BackgroundColor','green')
  381. set(hObject,'String','Granted')
  382. end
  383. % --- Set knob offset
  384. function pushbutton10_Callback(hObject, eventdata, handles)
  385. % hObject handle to pushbutton10 (see GCBO)
  386. % eventdata reserved - to be defined in a future version of MATLAB
  387. % handles structure with handles and user data (see GUIDATA)
  388. try
  389. knames=get(handles.popupmenu1,'String');
  390. stat=multiKnobsFn('SetOffset',knames{get(handles.popupmenu1,'Value')});
  391. if stat{1}~=1
  392. errordlg(stat{2},'Zero Set Error')
  393. end
  394. catch
  395. end
  396. % --- restart reader timer
  397. function pushbutton11_Callback(hObject, eventdata, handles)
  398. % hObject handle to pushbutton11 (see GCBO)
  399. % eventdata reserved - to be defined in a future version of MATLAB
  400. % handles structure with handles and user data (see GUIDATA)
  401. global FL
  402. stop(FL.t_multiKnobs)
  403. pause(FL.t_multiKnobs.Period)
  404. sreq('clear');
  405. start(FL.t_multiKnobs)
  406. drawnow('expose')
  407. % --- Unit selection
  408. function popupmenu2_Callback(hObject, eventdata, handles)
  409. % hObject handle to popupmenu2 (see GCBO)
  410. % eventdata reserved - to be defined in a future version of MATLAB
  411. % handles structure with handles and user data (see GUIDATA)
  412. knames=get(handles.popupmenu1,'String');
  413. kname=knames{get(handles.popupmenu1,'Value')};
  414. units=get(hObject,'String');
  415. multiKnobsFn('SetGuiUnits',kname,units{get(hObject,'Value')});
  416. popupmenu1_Callback(handles.popupmenu1,[],handles);
  417. % --- Executes during object creation, after setting all properties.
  418. function popupmenu2_CreateFcn(hObject, eventdata, handles)
  419. % hObject handle to popupmenu2 (see GCBO)
  420. % eventdata reserved - to be defined in a future version of MATLAB
  421. % handles empty - handles not created until after all CreateFcns called
  422. % Hint: popupmenu controls usually have a white background on Windows.
  423. % See ISPC and COMPUTER.
  424. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  425. set(hObject,'BackgroundColor','white');
  426. end
  427. % --- Get Calibration data
  428. function pushbutton12_Callback(hObject, eventdata, handles)
  429. % hObject handle to pushbutton12 (see GCBO)
  430. % eventdata reserved - to be defined in a future version of MATLAB
  431. % handles structure with handles and user data (see GUIDATA)
  432. if ~strcmp(questdlg('Start Calibration procedure?','Cal Procedure'),'Yes'); return; end;
  433. mhan=msgbox('Calibration procedure running...');
  434. sreq_wait;
  435. knames=get(handles.popupmenu1,'String');
  436. ipnames=get(handles.popupmenu3,'String');
  437. [stat caldata]=multiKnobsFn('Calibrate',knames{get(handles.popupmenu1,'Value')},ipnames{get(handles.popupmenu3,'Value')},get(handles.checkbox1,'Value'));
  438. if stat{1}~=1
  439. errordlg(stat{2},'Calibration Error')
  440. return
  441. end
  442. set(handles.text4,'String',caldata)
  443. sreq_wait('restart');
  444. if ishandle(mhan); delete(mhan); end;
  445. % --- Executes on selection change in popupmenu3.
  446. function popupmenu3_Callback(hObject, eventdata, handles)
  447. % hObject handle to popupmenu3 (see GCBO)
  448. % eventdata reserved - to be defined in a future version of MATLAB
  449. % handles structure with handles and user data (see GUIDATA)
  450. % Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array
  451. % contents{get(hObject,'Value')} returns selected item from popupmenu3
  452. % --- Executes during object creation, after setting all properties.
  453. function popupmenu3_CreateFcn(hObject, eventdata, handles)
  454. % hObject handle to popupmenu3 (see GCBO)
  455. % eventdata reserved - to be defined in a future version of MATLAB
  456. % handles empty - handles not created until after all CreateFcns called
  457. % Hint: popupmenu controls usually have a white background on Windows.
  458. % See ISPC and COMPUTER.
  459. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  460. set(hObject,'BackgroundColor','white');
  461. end
  462. % --- Executes on button press in checkbox1.
  463. function checkbox1_Callback(hObject, eventdata, handles)
  464. % hObject handle to checkbox1 (see GCBO)
  465. % eventdata reserved - to be defined in a future version of MATLAB
  466. % handles structure with handles and user data (see GUIDATA)
  467. % Hint: get(hObject,'Value') returns toggle state of checkbox1
  468. % --- Set controls ref
  469. function pushbutton13_Callback(hObject, eventdata, handles)
  470. % hObject handle to pushbutton13 (see GCBO)
  471. % eventdata reserved - to be defined in a future version of MATLAB
  472. % handles structure with handles and user data (see GUIDATA)
  473. sreq_wait;
  474. knames=get(handles.popupmenu1,'String');
  475. stat=multiKnobsFn('SetControlsRef',knames{get(handles.popupmenu1,'Value')});
  476. if stat{1}~=1
  477. errordlg(stat{2},'SetControlsRef Error')
  478. end
  479. sreq_wait('restart');
  480. % --- Executes on button press in pushbutton14.
  481. function pushbutton14_Callback(hObject, eventdata, handles)
  482. % hObject handle to pushbutton14 (see GCBO)
  483. % eventdata reserved - to be defined in a future version of MATLAB
  484. % handles structure with handles and user data (see GUIDATA)
  485. % --- Take new controls ref
  486. function pushbutton15_Callback(hObject, eventdata, handles)
  487. % hObject handle to pushbutton15 (see GCBO)
  488. % eventdata reserved - to be defined in a future version of MATLAB
  489. % handles structure with handles and user data (see GUIDATA)
  490. knames=get(handles.popupmenu1,'String');
  491. [stat refVals reftime]=multiKnobsFn('GetControlsRef',knames{get(handles.popupmenu1,'Value')});
  492. if stat{1}~=1
  493. errordlg(stat{2},'GetControlsRef Error')
  494. else
  495. set(handles.text7,'String',datestr(reftime))
  496. end
  497. % --- Executes on button press in pushbutton16.
  498. function pushbutton16_Callback(hObject, eventdata, handles)
  499. % hObject handle to pushbutton16 (see GCBO)
  500. % eventdata reserved - to be defined in a future version of MATLAB
  501. % handles structure with handles and user data (see GUIDATA)
  502. knames=get(handles.popupmenu1,'String');
  503. stat=multiKnobsFn('ResetOffset',knames{get(handles.popupmenu1,'Value')});
  504. if stat{1}~=1
  505. errordlg(stat{2},'Reset Offset Error')
  506. end
  507. % User comment field
  508. function edit4_Callback(hObject, eventdata, handles)
  509. % hObject handle to edit4 (see GCBO)
  510. % eventdata reserved - to be defined in a future version of MATLAB
  511. % handles structure with handles and user data (see GUIDATA)
  512. knobNames=get(handles.popupmenu1,'String');
  513. multiKnobsFn('SetComment',knobNames{get(handles.popupmenu1,'Value')},get(hObject,'String'));
  514. % --- Executes during object creation, after setting all properties.
  515. function edit4_CreateFcn(hObject, eventdata, handles)
  516. % hObject handle to edit4 (see GCBO)
  517. % eventdata reserved - to be defined in a future version of MATLAB
  518. % handles empty - handles not created until after all CreateFcns called
  519. % Hint: edit controls usually have a white background on Windows.
  520. % See ISPC and COMPUTER.
  521. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  522. set(hObject,'BackgroundColor','white');
  523. end
  524. % --- Executes on button press in pushbutton18.
  525. function pushbutton18_Callback(hObject, eventdata, handles)
  526. % hObject handle to pushbutton18 (see GCBO)
  527. % eventdata reserved - to be defined in a future version of MATLAB
  528. % handles structure with handles and user data (see GUIDATA)
  529. sreq_wait;
  530. knames=get(handles.popupmenu1,'String');
  531. stat=multiKnobsFn('SetControlsRefTemp',knames{get(handles.popupmenu1,'Value')});
  532. if stat{1}~=1
  533. errordlg(stat{2},'SetControlsRef Error')
  534. end
  535. sreq_wait('restart');