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

/ATF2/FlightSim/watchdogApps/componentAvailability/componentAvailabilityGui.m

http://atf2flightsim.googlecode.com/
MATLAB | 469 lines | 225 code | 81 blank | 163 comment | 29 complexity | b700331c39c193a15a488784a41a5f56 MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.0, IPL-1.0, BSD-3-Clause
  1. function varargout = componentAvailabilityGui(varargin)
  2. % COMPONENTAVAILABILITYGUI M-file for componentAvailabilityGui.fig
  3. % COMPONENTAVAILABILITYGUI, by itself, creates a new COMPONENTAVAILABILITYGUI or raises the existing
  4. % singleton*.
  5. %
  6. % H = COMPONENTAVAILABILITYGUI returns the handle to a new COMPONENTAVAILABILITYGUI or the handle to
  7. % the existing singleton*.
  8. %
  9. % COMPONENTAVAILABILITYGUI('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in COMPONENTAVAILABILITYGUI.M with the given input arguments.
  11. %
  12. % COMPONENTAVAILABILITYGUI('Property','Value',...) creates a new COMPONENTAVAILABILITYGUI or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before componentAvailabilityGui_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to componentAvailabilityGui_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 componentAvailabilityGui
  23. % Last Modified by GUIDE v2.5 20-Nov-2009 15:46:37
  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', @componentAvailabilityGui_OpeningFcn, ...
  29. 'gui_OutputFcn', @componentAvailabilityGui_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 componentAvailabilityGui is made visible.
  42. function componentAvailabilityGui_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 componentAvailabilityGui (see VARARGIN)
  48. % Choose default command line output for componentAvailabilityGui
  49. handles.output = handles;
  50. % Update handles structure
  51. guidata(hObject, handles);
  52. % UIWAIT makes componentAvailabilityGui wait for user response (see UIRESUME)
  53. % uiwait(handles.figure1);
  54. % Restore any settings from last time
  55. restoreList={'radiobutton1','Value',0; 'radiobutton2','Value',0;'radiobutton3','Value',0;
  56. 'radiobutton4','Value',0; 'radiobutton5','Value',0;'radiobutton6','Value',0;'radiobutton7','Value',0;
  57. 'radiobutton12','Value',0; 'radiobutton13','Value',0;'radiobutton14','Value',0};
  58. guiRestoreFn('compareAvailabilityGui',handles,restoreList);
  59. % Update lisbox display
  60. pushbutton4_Callback(handles.pushbutton4,[],handles);
  61. % --- Outputs from this function are returned to the command line.
  62. function varargout = componentAvailabilityGui_OutputFcn(hObject, eventdata, handles)
  63. % varargout cell array for returning output args (see VARARGOUT);
  64. % hObject handle to figure
  65. % eventdata reserved - to be defined in a future version of MATLAB
  66. % handles structure with handles and user data (see GUIDATA)
  67. % Get default command line output from handles structure
  68. varargout{1} = handles.output;
  69. % --- Executes on selection change in listbox1.
  70. function listbox1_Callback(hObject, eventdata, handles)
  71. % hObject handle to listbox1 (see GCBO)
  72. % eventdata reserved - to be defined in a future version of MATLAB
  73. % handles structure with handles and user data (see GUIDATA)
  74. % Hints: contents = get(hObject,'String') returns listbox1 contents as cell array
  75. % contents{get(hObject,'Value')} returns selected item from listbox1
  76. % --- Executes during object creation, after setting all properties.
  77. function listbox1_CreateFcn(hObject, eventdata, handles)
  78. % hObject handle to listbox1 (see GCBO)
  79. % eventdata reserved - to be defined in a future version of MATLAB
  80. % handles empty - handles not created until after all CreateFcns called
  81. % Hint: listbox controls usually have a white background on Windows.
  82. % See ISPC and COMPUTER.
  83. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  84. set(hObject,'BackgroundColor','white');
  85. end
  86. % --- EXIT
  87. function pushbutton1_Callback(hObject, eventdata, handles)
  88. % hObject handle to pushbutton1 (see GCBO)
  89. % eventdata reserved - to be defined in a future version of MATLAB
  90. % handles structure with handles and user data (see GUIDATA)
  91. componentAvailability('Save');
  92. guiCloseFn('componentAvailabilityGui',handles);
  93. % --- Toggle HW require
  94. function pushbutton2_Callback(hObject, eventdata, handles)
  95. % hObject handle to pushbutton2 (see GCBO)
  96. % eventdata reserved - to be defined in a future version of MATLAB
  97. % handles structure with handles and user data (see GUIDATA)
  98. [stat pars]=componentAvailability('GetPars');
  99. if stat{1}~=1
  100. errordlg(stat{2},'GetPars failed')
  101. return
  102. end
  103. listSel=get(handles.listbox1,'Value');
  104. listStr=get(handles.listbox1,'String');
  105. types={'GIRDER' 'INSTR' 'PS'}; typeSel='GIP';
  106. for i_ind=listSel
  107. indList=str2double(regexp(listStr{i_ind},'\d+','match','once'));
  108. t=regexp(listStr{i_ind},'\((\w)','tokens','once');
  109. typeList=types{ismember(typeSel,t{1})};
  110. toggleInd=ismember(pars.ind,indList)&ismember(pars.types,typeList);
  111. pars.requireHW(toggleInd)=~pars.requireHW(toggleInd);
  112. end
  113. newpars.requireHW=pars.requireHW;
  114. componentAvailability('SetPars',newpars);
  115. % Update display list
  116. pushbutton4_Callback(handles.pushbutton4,[],handles);
  117. % --- Toggle Tol Require
  118. function pushbutton3_Callback(hObject, eventdata, handles)
  119. % hObject handle to pushbutton3 (see GCBO)
  120. % eventdata reserved - to be defined in a future version of MATLAB
  121. % handles structure with handles and user data (see GUIDATA)
  122. [stat pars]=componentAvailability('GetPars');
  123. if stat{1}~=1
  124. errordlg(stat{2},'GetPars failed')
  125. return
  126. end
  127. listSel=get(handles.listbox1,'Value');
  128. listStr=get(handles.listbox1,'String');
  129. types={'GIRDER' 'INSTR' 'PS'}; typeSel='GIP';
  130. for i_ind=listSel
  131. indList=str2double(regexp(listStr{i_ind},'\d+','match','once'));
  132. t=regexp(listStr{i_ind},'\((\w)','tokens','once');
  133. typeList=types{ismember(typeSel,t{1})};
  134. toggleInd=ismember(pars.ind,indList)&ismember(pars.types,typeList);
  135. pars.requireTol(toggleInd)=~pars.requireTol(toggleInd);
  136. end
  137. newpars.requireTol=pars.requireTol;
  138. componentAvailability('SetPars',newpars);
  139. % Update display list
  140. pushbutton4_Callback(handles.pushbutton4,[],handles);
  141. % --- Display only alaram states
  142. function radiobutton4_Callback(hObject, eventdata, handles)
  143. % hObject handle to radiobutton4 (see GCBO)
  144. % eventdata reserved - to be defined in a future version of MATLAB
  145. % handles structure with handles and user data (see GUIDATA)
  146. Update(hObject, eventdata, handles)
  147. % Update display
  148. function Update(hObject, eventdata, handles)
  149. pushbutton4_Callback(handles.pushbutton4,[],handles);
  150. % --- Executes on button press in radiobutton5.
  151. function radiobutton5_Callback(hObject, eventdata, handles)
  152. % hObject handle to radiobutton5 (see GCBO)
  153. % eventdata reserved - to be defined in a future version of MATLAB
  154. % handles structure with handles and user data (see GUIDATA)
  155. % Hint: get(hObject,'Value') returns toggle state of radiobutton5
  156. % --- Executes on button press in radiobutton6.
  157. function radiobutton6_Callback(hObject, eventdata, handles)
  158. % hObject handle to radiobutton6 (see GCBO)
  159. % eventdata reserved - to be defined in a future version of MATLAB
  160. % handles structure with handles and user data (see GUIDATA)
  161. % Hint: get(hObject,'Value') returns toggle state of radiobutton6
  162. % --- Executes on button press in radiobutton7.
  163. function radiobutton7_Callback(hObject, eventdata, handles)
  164. % hObject handle to radiobutton7 (see GCBO)
  165. % eventdata reserved - to be defined in a future version of MATLAB
  166. % handles structure with handles and user data (see GUIDATA)
  167. % Hint: get(hObject,'Value') returns toggle state of radiobutton7
  168. % --- Display PS select
  169. function radiobutton1_Callback(hObject, eventdata, handles)
  170. % hObject handle to radiobutton1 (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. % Can't unselect all
  174. if ~any([get(handles.radiobutton1,'Value') get(handles.radiobutton2,'Value') get(handles.radiobutton3,'Value')])
  175. set(hObject,'Value',1)
  176. end
  177. % Update display
  178. pushbutton4_Callback(handles.pushbutton4,[],handles);
  179. % --- Display GIRDER select
  180. function radiobutton2_Callback(hObject, eventdata, handles)
  181. % hObject handle to radiobutton2 (see GCBO)
  182. % eventdata reserved - to be defined in a future version of MATLAB
  183. % handles structure with handles and user data (see GUIDATA)
  184. % Can't unselect all
  185. if ~any([get(handles.radiobutton1,'Value') get(handles.radiobutton2,'Value') get(handles.radiobutton3,'Value')])
  186. set(hObject,'Value',1)
  187. end
  188. % Update display
  189. pushbutton4_Callback(handles.pushbutton4,[],handles);
  190. % --- Display INSTR select
  191. function radiobutton3_Callback(hObject, eventdata, handles) %#ok<*INUSD,*DEFNU>
  192. % hObject handle to radiobutton3 (see GCBO)
  193. % eventdata reserved - to be defined in a future version of MATLAB
  194. % handles structure with handles and user data (see GUIDATA)
  195. % Can't unselect all
  196. if ~any([get(handles.radiobutton1,'Value') get(handles.radiobutton2,'Value') get(handles.radiobutton3,'Value')])
  197. set(hObject,'Value',1)
  198. end
  199. % Update display
  200. pushbutton4_Callback(handles.pushbutton4,[],handles);
  201. % --- Update button
  202. function pushbutton4_Callback(hObject, eventdata, handles) %#ok<*INUSL>
  203. % hObject handle to pushbutton4 (see GCBO)
  204. % eventdata reserved - to be defined in a future version of MATLAB
  205. % handles structure with handles and user data (see GUIDATA)
  206. global FL
  207. % Get options
  208. dopt={};
  209. if get(handles.radiobutton1,'Value'); dopt{end+1}=get(handles.radiobutton1,'String'); end;
  210. if get(handles.radiobutton2,'Value'); dopt{end+1}=get(handles.radiobutton2,'String'); end;
  211. if get(handles.radiobutton3,'Value'); dopt{end+1}=get(handles.radiobutton3,'String'); end;
  212. if get(handles.radiobutton4,'Value')
  213. alarmopt=true;
  214. else
  215. alarmopt=false;
  216. end
  217. sortopt=get(handles.popupmenu1,'Value');
  218. % Get new data from function an pars
  219. [stat data]=componentAvailability('Update');
  220. if stat{1}~=1
  221. errordlg(stat{2},'Update failed')
  222. return
  223. end
  224. [stat pars]=componentAvailability('GetPars');
  225. if stat{1}~=1
  226. errordlg(stat{2},'GetPars failed')
  227. return
  228. end
  229. % Set general alarm state
  230. if data.alarm
  231. set(handles.text3,'BackgroundColor','red')
  232. else
  233. set(handles.text3,'BackgroundColor','green')
  234. end
  235. % Display update rate
  236. set(handles.edit1,'String',num2str(pars.updateRate))
  237. % Display requested elemets
  238. if alarmopt
  239. ele=ismember(pars.types,dopt) & (data.alarmHW | any(data.alarmTol));
  240. else
  241. ele=ismember(pars.types,dopt);
  242. end
  243. if sortopt==1
  244. eleSort=1:sum(ele);
  245. elseif sortopt==2
  246. [~, eleSort]=sort(pars.types(ele));
  247. elseif sortopt==3
  248. [~, eleSort]=sort(data.HW(ele));
  249. elseif sortopt==4
  250. [~, eleSort]=sort(base2dec(num2str(data.Tol(ele)'),3));
  251. elseif sortopt==5
  252. [~, eleSort]=sort(pars.requireHW(ele));
  253. elseif sortopt==6
  254. [~, eleSort]=sort(pars.requireTol(ele));
  255. else
  256. errordlg('Unknown sort option','Update failed')
  257. return
  258. end
  259. displayStr={}; yesno={'No' 'Yes'};
  260. ele=find(ele);
  261. for iele=ele(eleSort)
  262. % if alarmopt && (data.alarmHW(iele) || any(data.alarmTol(iele))); continue; end;
  263. if pars.ind(iele)>=FL.Region.DR.ind(1) && pars.ind(iele)<=FL.Region.DR.ind(2) && ~get(handles.radiobutton12,'Value')
  264. continue
  265. end
  266. if pars.ind(iele)>=FL.Region.EXT.ind(1) && pars.ind(iele)<=FL.Region.EXT.ind(2) && ~get(handles.radiobutton13,'Value')
  267. continue
  268. end
  269. if pars.ind(iele)>=FL.Region.FFS.ind(1) && pars.ind(iele)<=FL.Region.FFS.ind(2) && ~get(handles.radiobutton14,'Value')
  270. continue
  271. end
  272. if data.HW(iele)
  273. hwavail='No';
  274. else
  275. hwavail='Yes';
  276. end
  277. hwtol='000';
  278. hwtol(data.Tol(:,iele)==1)='L';
  279. hwtol(data.Tol(:,iele)==2)='H';
  280. displayStr{end+1}=sprintf('%4d %20s (%c%4d) | %3s | %3s | %3s | %3s',...
  281. pars.ind(iele),pars.names{iele}(1:min(length(pars.names{iele}),20)),pars.types{iele}(1),pars.typeInd(iele),hwavail,hwtol,...
  282. yesno{pars.requireHW(iele)+1},yesno{pars.requireTol(iele)+1}); %#ok<AGROW>
  283. end
  284. origDispSel=get(handles.listbox1,'Value');
  285. origDispStr=get(handles.listbox1,'String');
  286. set(handles.listbox1,'ListboxTop',1);
  287. set(handles.listbox1,'String',displayStr)
  288. newDispStr=get(handles.listbox1,'String');
  289. if ~isempty(origDispStr) && ~isempty(newDispStr) && ~isempty(origDispSel)
  290. set(handles.listbox1,'Value',find(ismember(newDispStr,origDispStr{origDispSel(1)})))
  291. else
  292. set(handles.listbox1,'Value',1)
  293. end
  294. % Update rate
  295. function edit1_Callback(hObject, eventdata, handles)
  296. % hObject handle to edit1 (see GCBO)
  297. % eventdata reserved - to be defined in a future version of MATLAB
  298. % handles structure with handles and user data (see GUIDATA)
  299. if ~isnan(str2double(get(hObject,'String')))
  300. pars.updateRate=str2double(get(hObject,'String'));
  301. end
  302. componentAvailability('SetPars',pars);
  303. % --- Executes during object creation, after setting all properties.
  304. function edit1_CreateFcn(hObject, eventdata, handles)
  305. % hObject handle to edit1 (see GCBO)
  306. % eventdata reserved - to be defined in a future version of MATLAB
  307. % handles empty - handles not created until after all CreateFcns called
  308. % Hint: edit controls usually have a white background on Windows.
  309. % See ISPC and COMPUTER.
  310. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  311. set(hObject,'BackgroundColor','white');
  312. end
  313. % --- Launch details gui
  314. function pushbutton5_Callback(hObject, eventdata, handles)
  315. % hObject handle to pushbutton5 (see GCBO)
  316. % eventdata reserved - to be defined in a future version of MATLAB
  317. % handles structure with handles and user data (see GUIDATA)
  318. global FL
  319. listStr=get(handles.listbox1,'String');
  320. listSel=get(handles.listbox1,'Value');
  321. FL.Gui.detailsGui=detailsGui('UserData',listStr(listSel));
  322. % --- Display sort select
  323. function popupmenu1_Callback(hObject, eventdata, handles)
  324. % hObject handle to popupmenu1 (see GCBO)
  325. % eventdata reserved - to be defined in a future version of MATLAB
  326. % handles structure with handles and user data (see GUIDATA)
  327. % Update display
  328. pushbutton4_Callback(handles.pushbutton4,[],handles);
  329. % --- Executes during object creation, after setting all properties.
  330. function popupmenu1_CreateFcn(hObject, eventdata, handles)
  331. % hObject handle to popupmenu1 (see GCBO)
  332. % eventdata reserved - to be defined in a future version of MATLAB
  333. % handles empty - handles not created until after all CreateFcns called
  334. % Hint: popupmenu controls usually have a white background on Windows.
  335. % See ISPC and COMPUTER.
  336. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  337. set(hObject,'BackgroundColor','white');
  338. end
  339. % --- Executes when user attempts to close figure1.
  340. function figure1_CloseRequestFcn(hObject, eventdata, handles)
  341. % hObject handle to figure1 (see GCBO)
  342. % eventdata reserved - to be defined in a future version of MATLAB
  343. % handles structure with handles and user data (see GUIDATA)
  344. componentAvailability('Save');
  345. guiCloseFn('componentAvailabilityGui',handles);
  346. % --- Select DR
  347. function radiobutton12_Callback(hObject, eventdata, handles)
  348. % hObject handle to radiobutton12 (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. % Update display
  352. pushbutton4_Callback(handles.pushbutton4,[],handles);
  353. % --- Select EXT
  354. function radiobutton13_Callback(hObject, eventdata, handles)
  355. % hObject handle to radiobutton13 (see GCBO)
  356. % eventdata reserved - to be defined in a future version of MATLAB
  357. % handles structure with handles and user data (see GUIDATA)
  358. % Update display
  359. pushbutton4_Callback(handles.pushbutton4,[],handles);
  360. % --- Select FFS
  361. function radiobutton14_Callback(hObject, eventdata, handles)
  362. % hObject handle to radiobutton14 (see GCBO)
  363. % eventdata reserved - to be defined in a future version of MATLAB
  364. % handles structure with handles and user data (see GUIDATA)
  365. % Update display
  366. pushbutton4_Callback(handles.pushbutton4,[],handles);
  367. % --- Executes on button press in pushbutton6.
  368. function pushbutton6_Callback(hObject, eventdata, handles)
  369. % hObject handle to pushbutton6 (see GCBO)
  370. % eventdata reserved - to be defined in a future version of MATLAB
  371. % handles structure with handles and user data (see GUIDATA)
  372. global BEAMLINE INSTR
  373. listSel=get(handles.listbox1,'Value');
  374. listStr=get(handles.listbox1,'String');
  375. types={'GIRDER' 'INSTR' 'PS'}; typeSel='GIP';
  376. for i_ind=listSel
  377. indList=str2double(regexp(listStr{i_ind},'\d+','match','once'));
  378. t=regexp(listStr{i_ind},'\((\w)','tokens','once');
  379. typeList=types{ismember(typeSel,t{1})};
  380. if strcmp(typeList,'GIRDER')
  381. FlCA('restore','GIRDER',BEAMLINE{indList}.Girder);
  382. elseif strcmp(typeList,'PS')
  383. FlCA('restore','PS',BEAMLINE{indList}.PS);
  384. else
  385. FlCA('restore','INSTR',findcells(INSTR,'Index',indList));
  386. end
  387. end
  388. pushbutton4_Callback(handles.pushbutton4,[],handles);