PageRenderTime 27ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/ATF2/FlightSim/coreApps/SimSettings_staticErr.m

http://atf2flightsim.googlecode.com/
MATLAB | 371 lines | 146 code | 83 blank | 142 comment | 28 complexity | 231a9920c546e1079b9e6e9ea3c0092c MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.0, IPL-1.0, BSD-3-Clause
  1. function varargout = SimSettings_staticErr(varargin)
  2. % SIMSETTINGS_STATICERR M-file for SimSettings_staticErr.fig
  3. % SIMSETTINGS_STATICERR, by itself, creates a new SIMSETTINGS_STATICERR or raises the existing
  4. % singleton*.
  5. %
  6. % H = SIMSETTINGS_STATICERR returns the handle to a new SIMSETTINGS_STATICERR or the handle to
  7. % the existing singleton*.
  8. %
  9. % SIMSETTINGS_STATICERR('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in SIMSETTINGS_STATICERR.M with the given input arguments.
  11. %
  12. % SIMSETTINGS_STATICERR('Property','Value',...) creates a new SIMSETTINGS_STATICERR or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before SimSettings_staticErr_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to SimSettings_staticErr_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 SimSettings_staticErr
  23. % Last Modified by GUIDE v2.5 05-May-2008 10:45:52
  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', @SimSettings_staticErr_OpeningFcn, ...
  29. 'gui_OutputFcn', @SimSettings_staticErr_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 SimSettings_staticErr is made visible.
  42. function SimSettings_staticErr_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 SimSettings_staticErr (see VARARGIN)
  48. global FL
  49. % Choose default command line output for SimSettings_staticErr
  50. handles.output = handles;
  51. % Update handles structure
  52. guidata(hObject, handles);
  53. % Update error fields from Model structure
  54. set(handles.edit1,'String',num2str(FL.SimModel.align.x*1e6));
  55. set(handles.edit2,'String',num2str(FL.SimModel.align.y*1e6));
  56. set(handles.edit3,'String',num2str(FL.SimModel.align.rot*1e6));
  57. set(handles.edit6,'String',num2str(FL.SimModel.align.z*1e6));
  58. set(handles.edit7,'String',num2str(FL.SimModel.align.magbpm_x*1e6));
  59. set(handles.edit8,'String',num2str(FL.SimModel.align.magbpm_y*1e6));
  60. set(handles.edit4,'String',num2str(FL.SimModel.align.dB*1e5));
  61. set(handles.edit5,'String',num2str(FL.SimModel.align.dB_syst*1e5));
  62. udat{1}=figState(handles);
  63. set(handles.figure1,'UserData',udat);
  64. % --- Outputs from this function are returned to the command line.
  65. function varargout = SimSettings_staticErr_OutputFcn(hObject, eventdata, handles)
  66. % varargout cell array for returning output args (see VARARGOUT);
  67. % hObject handle to figure
  68. % eventdata reserved - to be defined in a future version of MATLAB
  69. % handles structure with handles and user data (see GUIDATA)
  70. % Get default command line output from handles structure
  71. varargout{1} = handles.output;
  72. function edit7_Callback(hObject, eventdata, handles)
  73. % hObject handle to edit7 (see GCBO)
  74. % eventdata reserved - to be defined in a future version of MATLAB
  75. % handles structure with handles and user data (see GUIDATA)
  76. % Hints: get(hObject,'String') returns contents of edit7 as text
  77. % str2double(get(hObject,'String')) returns contents of edit7 as a double
  78. % --- Executes during object creation, after setting all properties.
  79. function edit7_CreateFcn(hObject, eventdata, handles)
  80. % hObject handle to edit7 (see GCBO)
  81. % eventdata reserved - to be defined in a future version of MATLAB
  82. % handles empty - handles not created until after all CreateFcns called
  83. % Hint: edit controls usually have a white background on Windows.
  84. % See ISPC and COMPUTER.
  85. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  86. set(hObject,'BackgroundColor','white');
  87. end
  88. function edit4_Callback(hObject, eventdata, handles)
  89. % hObject handle to edit4 (see GCBO)
  90. % eventdata reserved - to be defined in a future version of MATLAB
  91. % handles structure with handles and user data (see GUIDATA)
  92. % Hints: get(hObject,'String') returns contents of edit4 as text
  93. % str2double(get(hObject,'String')) returns contents of edit4 as a double
  94. % --- Executes during object creation, after setting all properties.
  95. function edit4_CreateFcn(hObject, eventdata, handles)
  96. % hObject handle to edit4 (see GCBO)
  97. % eventdata reserved - to be defined in a future version of MATLAB
  98. % handles empty - handles not created until after all CreateFcns called
  99. % Hint: edit controls usually have a white background on Windows.
  100. % See ISPC and COMPUTER.
  101. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  102. set(hObject,'BackgroundColor','white');
  103. end
  104. function edit5_Callback(hObject, eventdata, handles)
  105. % hObject handle to edit5 (see GCBO)
  106. % eventdata reserved - to be defined in a future version of MATLAB
  107. % handles structure with handles and user data (see GUIDATA)
  108. % Hints: get(hObject,'String') returns contents of edit5 as text
  109. % str2double(get(hObject,'String')) returns contents of edit5 as a double
  110. % --- Executes during object creation, after setting all properties.
  111. function edit5_CreateFcn(hObject, eventdata, handles)
  112. % hObject handle to edit5 (see GCBO)
  113. % eventdata reserved - to be defined in a future version of MATLAB
  114. % handles empty - handles not created until after all CreateFcns called
  115. % Hint: edit controls usually have a white background on Windows.
  116. % See ISPC and COMPUTER.
  117. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  118. set(hObject,'BackgroundColor','white');
  119. end
  120. function edit1_Callback(hObject, eventdata, handles)
  121. % hObject handle to edit1 (see GCBO)
  122. % eventdata reserved - to be defined in a future version of MATLAB
  123. % handles structure with handles and user data (see GUIDATA)
  124. % Hints: get(hObject,'String') returns contents of edit1 as text
  125. % str2double(get(hObject,'String')) returns contents of edit1 as a double
  126. % --- Executes during object creation, after setting all properties.
  127. function edit1_CreateFcn(hObject, eventdata, handles)
  128. % hObject handle to edit1 (see GCBO)
  129. % eventdata reserved - to be defined in a future version of MATLAB
  130. % handles empty - handles not created until after all CreateFcns called
  131. % Hint: edit controls usually have a white background on Windows.
  132. % See ISPC and COMPUTER.
  133. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  134. set(hObject,'BackgroundColor','white');
  135. end
  136. function edit2_Callback(hObject, eventdata, handles)
  137. % hObject handle to edit2 (see GCBO)
  138. % eventdata reserved - to be defined in a future version of MATLAB
  139. % handles structure with handles and user data (see GUIDATA)
  140. % Hints: get(hObject,'String') returns contents of edit2 as text
  141. % str2double(get(hObject,'String')) returns contents of edit2 as a double
  142. % --- Executes during object creation, after setting all properties.
  143. function edit2_CreateFcn(hObject, eventdata, handles)
  144. % hObject handle to edit2 (see GCBO)
  145. % eventdata reserved - to be defined in a future version of MATLAB
  146. % handles empty - handles not created until after all CreateFcns called
  147. % Hint: edit controls usually have a white background on Windows.
  148. % See ISPC and COMPUTER.
  149. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  150. set(hObject,'BackgroundColor','white');
  151. end
  152. function edit3_Callback(hObject, eventdata, handles)
  153. % hObject handle to edit3 (see GCBO)
  154. % eventdata reserved - to be defined in a future version of MATLAB
  155. % handles structure with handles and user data (see GUIDATA)
  156. % Hints: get(hObject,'String') returns contents of edit3 as text
  157. % str2double(get(hObject,'String')) returns contents of edit3 as a double
  158. % --- Executes during object creation, after setting all properties.
  159. function edit3_CreateFcn(hObject, eventdata, handles)
  160. % hObject handle to edit3 (see GCBO)
  161. % eventdata reserved - to be defined in a future version of MATLAB
  162. % handles empty - handles not created until after all CreateFcns called
  163. % Hint: edit controls usually have a white background on Windows.
  164. % See ISPC and COMPUTER.
  165. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  166. set(hObject,'BackgroundColor','white');
  167. end
  168. function edit6_Callback(hObject, eventdata, handles)
  169. % hObject handle to edit6 (see GCBO)
  170. % eventdata reserved - to be defined in a future version of MATLAB
  171. % handles structure with handles and user data (see GUIDATA)
  172. % Hints: get(hObject,'String') returns contents of edit6 as text
  173. % str2double(get(hObject,'String')) returns contents of edit6 as a double
  174. % --- Executes during object creation, after setting all properties.
  175. function edit6_CreateFcn(hObject, eventdata, handles)
  176. % hObject handle to edit6 (see GCBO)
  177. % eventdata reserved - to be defined in a future version of MATLAB
  178. % handles empty - handles not created until after all CreateFcns called
  179. % Hint: edit controls usually have a white background on Windows.
  180. % See ISPC and COMPUTER.
  181. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  182. set(hObject,'BackgroundColor','white');
  183. end
  184. function edit8_Callback(hObject, eventdata, handles)
  185. % hObject handle to edit8 (see GCBO)
  186. % eventdata reserved - to be defined in a future version of MATLAB
  187. % handles structure with handles and user data (see GUIDATA)
  188. % Hints: get(hObject,'String') returns contents of edit8 as text
  189. % str2double(get(hObject,'String')) returns contents of edit8 as a double
  190. % --- Executes during object creation, after setting all properties.
  191. function edit8_CreateFcn(hObject, eventdata, handles)
  192. % hObject handle to edit8 (see GCBO)
  193. % eventdata reserved - to be defined in a future version of MATLAB
  194. % handles empty - handles not created until after all CreateFcns called
  195. % Hint: edit controls usually have a white background on Windows.
  196. % See ISPC and COMPUTER.
  197. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  198. set(hObject,'BackgroundColor','white');
  199. end
  200. % --- Executes on button press in pushbutton1.
  201. function pushbutton1_Callback(hObject, eventdata, handles)
  202. % hObject handle to pushbutton1 (see GCBO)
  203. % eventdata reserved - to be defined in a future version of MATLAB
  204. % handles structure with handles and user data (see GUIDATA)
  205. udat=get(handles.figure1,'UserData');
  206. if ~isequal(figState(handles),udat{1})
  207. resp=questdlg('Settings have been changed but not saved','Settings Changed',...
  208. 'Quit anyway','Save before quiting','Cancel','Cancel');
  209. switch resp
  210. case 'Quit anyway'
  211. guiCloseFn('SimSettings_dynamicErr',handles);
  212. case 'Save before quiting'
  213. stat=saveErrData(handles);
  214. if stat{1}~=1
  215. errordlg(stat{2},'Static Error Save Error');
  216. else
  217. guiCloseFn('SimSettings_dynamicErr',handles);
  218. end % if err
  219. end % switch resp
  220. else
  221. guiCloseFn('SimSettings_dynamicErr',handles);
  222. end % if settings changed
  223. % --- Executes on button press in pushbutton2.
  224. function pushbutton2_Callback(hObject, eventdata, handles)
  225. % hObject handle to pushbutton2 (see GCBO)
  226. % eventdata reserved - to be defined in a future version of MATLAB
  227. % handles structure with handles and user data (see GUIDATA)
  228. stat=saveErrData(handles);
  229. if stat{1}~=1; errordlg(stat{2},'Static Error Save Error'); end;
  230. function stat=saveErrData(handles)
  231. global FL
  232. % Change sim model parameters with field values
  233. x=str2double(get(handles.edit1,'String'))/1e6;
  234. stat=valCheck(x,'Horizontal Magnet Alignment'); if stat{1}~=1; return; end;
  235. FL.SimModel.align.x=x;
  236. x=str2double(get(handles.edit2,'String'))/1e6;
  237. stat=valCheck(x,'Vertical Magnet Alignment'); if stat{1}~=1; return; end;
  238. FL.SimModel.align.y=x;
  239. x=str2double(get(handles.edit3,'String'))/1e6;
  240. stat=valCheck(x,'Roll Magnet Alignment'); if stat{1}~=1; return; end;
  241. FL.SimModel.align.rot=x;
  242. x=str2double(get(handles.edit6,'String'))/1e6;
  243. stat=valCheck(x,'Longitudinal Magnet Alignment'); if stat{1}~=1; return; end;
  244. FL.SimModel.align.z=x;
  245. x=str2double(get(handles.edit7,'String'))/1e6;
  246. stat=valCheck(x,'Horizontal BPM-MAG alignment'); if stat{1}~=1; return; end;
  247. FL.SimModel.align.magbpm_x=x;
  248. x=str2double(get(handles.edit8,'String'))/1e6;
  249. stat=valCheck(x,'Vertical BPM-MAG alignment'); if stat{1}~=1; return; end;
  250. FL.SimModel.align.magbpm_y=x;
  251. x=str2double(get(handles.edit4,'String'))/1e5;
  252. stat=valCheck(x,'dB/B RMS'); if stat{1}~=1; return; end;
  253. FL.SimModel.align.dB=x;
  254. x=str2double(get(handles.edit5,'String'))/1e5;
  255. stat=valCheck(x,'dB/B systematic'); if stat{1}~=1; return; end;
  256. FL.SimModel.align.dB_syst=x;
  257. % Store save state
  258. udat=get(handles.figure1,'UserData');
  259. udat{1}=figState(handles);
  260. set(handles.figure1,'UserData',udat);
  261. function stat=valCheck(x,str)
  262. if isnan(x) || x<0
  263. stat{1}=-1; stat{2}=[str,' must be numeric and >0'];
  264. else
  265. stat{1}=1;
  266. end % x xcheck
  267. % --- Executes when user attempts to close figure1.
  268. function figure1_CloseRequestFcn(hObject, eventdata, handles)
  269. % hObject handle to figure1 (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. guiCloseFn('SimSettings_staticErr',handles);
  273. % Get array of Value and String properties for this figure
  274. function array = figState(handles)
  275. hans=fieldnames(handles);
  276. array=[];
  277. for ihan=1:length(hans)
  278. if ~isequal(hans{ihan},'pushbutton1') && ~isequal(hans{ihan},'pushbutton2')
  279. try
  280. array=[array double(get(handles.(hans{ihan}),'String'))];
  281. catch
  282. end % try/catch
  283. try
  284. array=[array get(handles.(hans{ihan}),'Value')];
  285. catch
  286. end % try/catch
  287. end % if not pushbutton1 or 2 (exit or save button)
  288. end % for ihan