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

/ATF2/FlightSim/watchdogApps/componentAvailability/detailsGui.m

http://atf2flightsim.googlecode.com/
MATLAB | 437 lines | 258 code | 49 blank | 130 comment | 54 complexity | 426e5f421bcb1b4b6f4ec8f59c73383d MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.0, IPL-1.0, BSD-3-Clause
  1. function varargout = detailsGui(varargin)
  2. % DETAILSGUI M-file for detailsGui.fig
  3. % DETAILSGUI, by itself, creates a new DETAILSGUI or raises the existing
  4. % singleton*.
  5. %
  6. % H = DETAILSGUI returns the handle to a new DETAILSGUI or the handle to
  7. % the existing singleton*.
  8. %
  9. % DETAILSGUI('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in DETAILSGUI.M with the given input arguments.
  11. %
  12. % DETAILSGUI('Property','Value',...) creates a new DETAILSGUI or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before detailsGui_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to detailsGui_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 detailsGui
  23. % Last Modified by GUIDE v2.5 31-Aug-2009 16:05:03
  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', @detailsGui_OpeningFcn, ...
  29. 'gui_OutputFcn', @detailsGui_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 detailsGui is made visible.
  42. function detailsGui_OpeningFcn(hObject, eventdata, handles, varargin) %#ok<*INUSL>
  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 detailsGui (see VARARGIN)
  48. global PS GIRDER INSTR FL
  49. % Choose default command line output for detailsGui
  50. handles.output = handles;
  51. % Update handles structure
  52. guidata(hObject, handles);
  53. % UIWAIT makes detailsGui wait for user response (see UIRESUME)
  54. % uiwait(handles.figure1);
  55. % Get pars from function
  56. [stat pars]=componentAvailability('GetPars');
  57. % Take passed data and display
  58. dataIn=get(handles.figure1,'UserData');
  59. t=regexp(dataIn,'\d+\s*(\S+)','tokens','once');
  60. for it=1:length(t)
  61. eleStr{it}=t{it}{1};
  62. end
  63. ele=regexp(dataIn,'\d+','match','once');
  64. t=regexp(dataIn,'\((\S\s*\d+\))','tokens','once');
  65. typeIn=t{1}{1};
  66. dispStr={};
  67. for istr=1:length(eleStr)
  68. ind_all=ismember(pars.ind,str2double(ele{istr}));
  69. for ind=find(ind_all)
  70. switch pars.types{ind}
  71. case 'PS'
  72. if t{istr}{1}~='P'; continue; end;
  73. val=PS(pars.typeInd(ind)).Ampl;
  74. if isfield(FL.HwInfo.PS(pars.typeInd(ind)),'ref')
  75. ref=FL.HwInfo.PS(pars.typeInd(ind)).ref;
  76. else
  77. % ref=pars.defRef(1,pars.typeInd(ind));
  78. % JLN 091208 really want ind here because we're in pars not Fl.Hw...
  79. ref=pars.defRef(1,ind);
  80. end
  81. dof={'Ampl'};
  82. case 'INSTR'
  83. if t{istr}{1}~='I'; continue; end;
  84. val=INSTR{pars.typeInd(ind)}.Data;
  85. ref=INSTR{pars.typeInd(ind)}.ref;
  86. dof={'X' 'Y' 'TMIT'};
  87. case 'GIRDER'
  88. if t{istr}{1}~='G'; continue; end;
  89. val=GIRDER{pars.typeInd(ind)}.MoverPos;
  90. % 091208 JLN I think this should be
  91. % ref=GIRDER(pars.typeInd(ind)).MoverSetPt
  92. if isfield(FL.HwInfo.GIRDER(pars.typeInd(ind)),'ref')
  93. ref=FL.HwInfo.GIRDER(pars.typeInd(ind)).ref;
  94. else
  95. % jln 091208 see PS above
  96. ref=pars.defRef(:,ind);
  97. end
  98. dof={'X' 'Y' 'TILT'};
  99. otherwise
  100. continue
  101. end
  102. for idof=1:length(dof)
  103. tol=[pars.tolLow(idof,ind) pars.tolHigh(idof,ind)];
  104. dispStr{end+1}=sprintf('%4s(%s %20s (%4s) | %9.3g | %9.3g | [%9.2g,%9.2g]',ele{istr},t{istr}{1},eleStr{istr},dof{idof},val(idof),ref(idof),tol(1),tol(2));
  105. end
  106. end
  107. end
  108. set(handles.listbox1,'String',dispStr)
  109. set(handles.listbox1,'Value',1)
  110. % --- Outputs from this function are returned to the command line.
  111. function varargout = detailsGui_OutputFcn(hObject, eventdata, handles)
  112. % varargout cell array for returning output args (see VARARGOUT);
  113. % hObject handle to figure
  114. % eventdata reserved - to be defined in a future version of MATLAB
  115. % handles structure with handles and user data (see GUIDATA)
  116. % Get default command line output from handles structure
  117. varargout{1} = handles.output;
  118. % --- Executes on selection change in listbox1.
  119. function listbox1_Callback(hObject, eventdata, handles) %#ok<*INUSD,*DEFNU>
  120. % hObject handle to listbox1 (see GCBO)
  121. % eventdata reserved - to be defined in a future version of MATLAB
  122. % handles structure with handles and user data (see GUIDATA)
  123. listStr=get(hObject,'String');
  124. listSel=get(hObject,'Value');
  125. if length(listSel)==1
  126. t=regexp(listStr{listSel},'\|\s*\S+\s*\|\s*+(\S+)\s*\|\s*\[\s*(\S+),\s*(\S+)\s*\]','tokens','once');
  127. set(handles.edit1,'String',t{1})
  128. tol=[str2num(t{2}) str2num(t{3})];
  129. set(handles.edit2,'String',num2str(tol(1),6))
  130. set(handles.edit3,'String',num2str(tol(2),6))
  131. else
  132. set(handles.edit1,'String',[])
  133. set(handles.edit2,'String',[])
  134. set(handles.edit3,'String',[])
  135. end
  136. % --- Executes during object creation, after setting all properties.
  137. function listbox1_CreateFcn(hObject, eventdata, handles)
  138. % hObject handle to listbox1 (see GCBO)
  139. % eventdata reserved - to be defined in a future version of MATLAB
  140. % handles empty - handles not created until after all CreateFcns called
  141. % Hint: listbox controls usually have a white background on Windows.
  142. % See ISPC and COMPUTER.
  143. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  144. set(hObject,'BackgroundColor','white');
  145. end
  146. % --- EXIT
  147. function pushbutton1_Callback(hObject, eventdata, handles)
  148. % hObject handle to pushbutton1 (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. guiCloseFn('detailsGui',handles);
  152. % --- Update
  153. function pushbutton2_Callback(hObject, eventdata, handles)
  154. % hObject handle to pushbutton2 (see GCBO)
  155. % eventdata reserved - to be defined in a future version of MATLAB
  156. % handles structure with handles and user data (see GUIDATA)
  157. detailsGui_OpeningFcn(handles.figure1, [], handles, []);
  158. % --- Set to Ref value
  159. function pushbutton7_Callback(hObject, eventdata, handles)
  160. % hObject handle to pushbutton7 (see GCBO)
  161. % eventdata reserved - to be defined in a future version of MATLAB
  162. % handles structure with handles and user data (see GUIDATA)
  163. global PS GIRDER FL
  164. if ~strcmp(questdlg('Set this (these) components to their reference values? (Directly write to hardware)','Set to ref'),'Yes')
  165. return
  166. end
  167. [stat pars]=componentAvailability('GetPars');
  168. listStr=get(handles.listbox1,'String');
  169. listSel=get(handles.listbox1,'Value');
  170. for isel=1:length(listSel)
  171. thisStr=listStr{listSel(isel)};
  172. t=regexp(thisStr,'\(\s*(\S+))','tokens');
  173. dofStr=t{1}{1};
  174. if ismember(dofStr,{'X' 'Ampl'})
  175. dof=1;
  176. elseif strcmp(dofStr,'Y')
  177. dof=2;
  178. else
  179. dof=3;
  180. end
  181. allind=ismember(pars.ind,str2double(regexp(thisStr,'\d+','match','once')));
  182. t=regexp(thisStr,'\((\w)','tokens','once');
  183. for ind=find(allind)
  184. switch pars.types{ind}
  185. case 'PS'
  186. if ~t{1}=='P'; continue; end;
  187. if isfield(FL.HwInfo.PS(pars.typeInd(ind)),'ref')
  188. PS(pars.typeInd(ind)).SetPt=FL.HwInfo.PS(pars.typeInd(ind)).ref(1);
  189. else
  190. PS(pars.typeInd(ind)).SetPt=pars.defRef(1,ind);
  191. end
  192. stat=PSTrim(pars.typeInd(ind),1);
  193. if stat{1}~=1
  194. errordlg(stat{2},'Error setting PS')
  195. return
  196. end
  197. case 'INSTR'
  198. continue
  199. case 'GIRDER'
  200. if ~t{1}=='G'; continue; end;
  201. if isfield(FL.HwInfo.GIRDER(pars.typeInd(ind)),'ref')
  202. GIRDER{pars.typeInd(ind)}.MoverSetPt(dof)=FL.HwInfo.GIRDER(pars.typeInd(ind)).ref(dof);
  203. else
  204. GIRDER{pars.typeInd(ind)}.MoverSetPt(dof)=pars.defRef(dof,ind);
  205. end
  206. stat=MoverTrim(pars.typeInd(ind),1);
  207. if stat{1}~=1
  208. errordlg(stat{2},'Error setting Mover')
  209. return
  210. end
  211. end
  212. end
  213. end
  214. pushbutton2_Callback(handles.pushbutton2,[],handles);
  215. function edit1_Callback(hObject, eventdata, handles)
  216. % hObject handle to edit1 (see GCBO)
  217. % eventdata reserved - to be defined in a future version of MATLAB
  218. % handles structure with handles and user data (see GUIDATA)
  219. % Hints: get(hObject,'String') returns contents of edit1 as text
  220. % str2double(get(hObject,'String')) returns contents of edit1 as a double
  221. % --- Executes during object creation, after setting all properties.
  222. function edit1_CreateFcn(hObject, eventdata, handles)
  223. % hObject handle to edit1 (see GCBO)
  224. % eventdata reserved - to be defined in a future version of MATLAB
  225. % handles empty - handles not created until after all CreateFcns called
  226. % Hint: edit controls usually have a white background on Windows.
  227. % See ISPC and COMPUTER.
  228. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  229. set(hObject,'BackgroundColor','white');
  230. end
  231. function edit2_Callback(hObject, eventdata, handles)
  232. % hObject handle to edit2 (see GCBO)
  233. % eventdata reserved - to be defined in a future version of MATLAB
  234. % handles structure with handles and user data (see GUIDATA)
  235. % Hints: get(hObject,'String') returns contents of edit2 as text
  236. % str2double(get(hObject,'String')) returns contents of edit2 as a double
  237. % --- Executes during object creation, after setting all properties.
  238. function edit2_CreateFcn(hObject, eventdata, handles)
  239. % hObject handle to edit2 (see GCBO)
  240. % eventdata reserved - to be defined in a future version of MATLAB
  241. % handles empty - handles not created until after all CreateFcns called
  242. % Hint: edit controls usually have a white background on Windows.
  243. % See ISPC and COMPUTER.
  244. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  245. set(hObject,'BackgroundColor','white');
  246. end
  247. function edit3_Callback(hObject, eventdata, handles)
  248. % hObject handle to edit3 (see GCBO)
  249. % eventdata reserved - to be defined in a future version of MATLAB
  250. % handles structure with handles and user data (see GUIDATA)
  251. % Hints: get(hObject,'String') returns contents of edit3 as text
  252. % str2double(get(hObject,'String')) returns contents of edit3 as a double
  253. % --- Executes during object creation, after setting all properties.
  254. function edit3_CreateFcn(hObject, eventdata, handles)
  255. % hObject handle to edit3 (see GCBO)
  256. % eventdata reserved - to be defined in a future version of MATLAB
  257. % handles empty - handles not created until after all CreateFcns called
  258. % Hint: edit controls usually have a white background on Windows.
  259. % See ISPC and COMPUTER.
  260. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  261. set(hObject,'BackgroundColor','white');
  262. end
  263. % --- set reference values / Tols for this line item
  264. function pushbutton5_Callback(hObject, eventdata, handles)
  265. % hObject handle to pushbutton5 (see GCBO)
  266. % eventdata reserved - to be defined in a future version of MATLAB
  267. % handles structure with handles and user data (see GUIDATA)
  268. global PS GIRDER INSTR FL %#ok<NUSED>
  269. if ~isequal(get(hObject,'UserData'),'OverideCheck')
  270. if ~strcmp(questdlg('Apply new Reference and tolerance settings?','Reference and Tol Set'),'Yes')
  271. return
  272. end
  273. end
  274. [stat pars]=componentAvailability('GetPars');
  275. newpars.tolLow=pars.tolLow;
  276. newpars.tolHigh=pars.tolHigh;
  277. dispStr=get(handles.listbox1,'String');
  278. selStr={dispStr{get(handles.listbox1,'Value')}};
  279. for istr=1:length(selStr)
  280. thisStr=selStr{istr};
  281. % refVal set by other applications
  282. %refVal=str2double(get(handles.edit1,'String'));
  283. lowTolVal=str2double(get(handles.edit2,'String'));
  284. highTolVal=str2double(get(handles.edit3,'String'));
  285. t=regexp(thisStr,'\(\s*(\S+))','tokens');
  286. dofStr=t{1}{1};
  287. if ismember(dofStr,{'X' 'Ampl'})
  288. dof=1;
  289. elseif strcmp(dofStr,'Y')
  290. dof=2;
  291. else
  292. dof=3;
  293. end
  294. allind=ismember(pars.ind,str2double(regexp(thisStr,'\d+','match','once')));
  295. for ind=find(allind)
  296. t=regexp(thisStr,'\((\w)','tokens','once');
  297. if t{1}~=pars.types{ind}(1); continue; end;
  298. if ~isnan(lowTolVal)
  299. newpars.tolLow(dof,ind)=lowTolVal;
  300. end
  301. if ~isnan(highTolVal)
  302. newpars.tolHigh(dof,ind)=highTolVal;
  303. end
  304. componentAvailability('SetPars',newpars);
  305. % switch pars.types{ind}
  306. % case {'PS','GIRDER'}
  307. % if ~isnan(refVal)
  308. % FL.HwInfo.(pars.types{ind})(pars.typeInd(ind)).ref(dof)=refVal;
  309. % end
  310. % case 'INSTR'
  311. % if ~isnan(refVal)
  312. % INSTR{pars.typeInd(ind)}.ref(dof)=refVal;
  313. % end
  314. % end
  315. end
  316. end
  317. pushbutton2_Callback(handles.pushbutton2,[],handles);
  318. % --- Set default ref setting
  319. function pushbutton6_Callback(hObject, eventdata, handles)
  320. % hObject handle to pushbutton6 (see GCBO)
  321. % eventdata reserved - to be defined in a future version of MATLAB
  322. % handles structure with handles and user data (see GUIDATA)
  323. if ~strcmp(questdlg('Apply default Reference settings?','Set Default Ref'),'Yes')
  324. return
  325. end
  326. [stat pars]=componentAvailability('GetPars');
  327. listStr=get(handles.listbox1,'String');
  328. listSel=get(handles.listbox1,'Value');
  329. t=regexp(listStr{listSel},'\(\s*(\S+))','tokens');
  330. dofStr=t{1}{1};
  331. if ismember(dofStr,{'X' 'Ampl'})
  332. dof=1;
  333. elseif strcmp(dofStr,'Y')
  334. dof=2;
  335. else
  336. dof=3;
  337. end
  338. for isel=1:length(listSel)
  339. thisStr=listStr{isel};
  340. allind=ismember(pars.ind,str2double(regexp(thisStr,'\d+','match','once')));
  341. for ind=find(allind)
  342. t=regexp(thisStr,'\((\w)','tokens','once');
  343. if t{1}~=pars.types{ind}(1); continue; end;
  344. set(handles.edit1,'String',pars.defRef(dof,ind))
  345. set(handles.pushbutton5,'UserData','OverideCheck')
  346. pushbutton5_Callback(handles.pushbutton5,[],handles);
  347. set(handles.pushbutton5,'UserData',[])
  348. end
  349. end
  350. % --- Executes when user attempts to close figure1.
  351. function figure1_CloseRequestFcn(hObject, eventdata, handles)
  352. % hObject handle to figure1 (see GCBO)
  353. % eventdata reserved - to be defined in a future version of MATLAB
  354. % handles structure with handles and user data (see GUIDATA)
  355. guiCloseFn('componentAvailabilityGui',handles);
  356. % --- Set default Tol settings
  357. function pushbutton8_Callback(hObject, eventdata, handles)
  358. % hObject handle to pushbutton8 (see GCBO)
  359. % eventdata reserved - to be defined in a future version of MATLAB
  360. % handles structure with handles and user data (see GUIDATA)
  361. if ~strcmp(questdlg('Apply default Tolerance settings?','Set Default Tol'),'Yes')
  362. return
  363. end
  364. [stat pars]=componentAvailability('GetPars');
  365. listStr=get(handles.listbox1,'String');
  366. listSel=get(handles.listbox1,'Value');
  367. t=regexp(listStr{listSel},'\(\s*(\S+))','tokens');
  368. dofStr=t{1}{1};
  369. if ismember(dofStr,{'X' 'Ampl'})
  370. dof=1;
  371. elseif strcmp(dofStr,'Y')
  372. dof=2;
  373. else
  374. dof=3;
  375. end
  376. for isel=1:length(listSel)
  377. thisStr=listStr{isel};
  378. allind=ismember(pars.ind,str2double(regexp(thisStr,'\d+','match','once')));
  379. for ind=find(allind)
  380. t=regexp(thisStr,'\((\w)','tokens','once');
  381. if t{1}~=pars.types{ind}(1); continue; end;
  382. set(handles.edit2,'String',pars.defTolLow(dof,ind))
  383. set(handles.edit3,'String',pars.defTolHigh(dof,ind))
  384. set(handles.pushbutton5,'UserData','OverideCheck')
  385. pushbutton5_Callback(handles.pushbutton5,[],handles);
  386. set(handles.pushbutton5,'UserData',[])
  387. end
  388. end