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

/ATF2/FlightSim/testApps/OCEXT/OCEXT.m

http://atf2flightsim.googlecode.com/
MATLAB | 539 lines | 391 code | 46 blank | 102 comment | 40 complexity | 6a8b2d085c32dc861a3fc7afaa645113 MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.0, IPL-1.0, BSD-3-Clause
  1. function varargout = OCEXT(varargin)
  2. % OCEXT M-file for OCEXT.fig
  3. % OCEXT, by itself, creates a new OCEXT or raises the existing
  4. % singleton*.
  5. %
  6. % H = OCEXT returns the handle to a new OCEXT or the handle to
  7. % the existing singleton*.
  8. %
  9. % OCEXT('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in OCEXT.M with the given input arguments.
  11. %
  12. % OCEXT('Property','Value',...) creates a new OCEXT or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before OCEXT_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to OCEXT_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 OCEXT
  23. % Last Modified by GUIDE v2.5 15-Apr-2009 14:13:43
  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', @OCEXT_OpeningFcn, ...
  29. 'gui_OutputFcn', @OCEXT_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 OCEXT is made visible.
  42. function OCEXT_OpeningFcn(hObject, eventdata, handles, varargin)
  43. global FL BEAMLINE PS
  44. FlHwUpdate();
  45. iexlist=findcells(BEAMLINE,'Name','IEX');
  46. extstart=findcells(BEAMLINE,'Name','QF1X');
  47. fflist=findcells(BEAMLINE,'Name','QM16FF');
  48. zv1xpos=findcells(BEAMLINE,'Name','ZV1X')-1;
  49. bpmno=length(findcells({BEAMLINE{zv1xpos(end):fflist(1)}},'Class','MONI'));
  50. list = findcells(BEAMLINE,'Class','XCOR');
  51. xcorpos=list(find(list>zv1xpos(end),1):length(list)-1);
  52. xcorlist=zeros(1, length(xcorpos));
  53. for R=1:length(xcorpos)
  54. xcorlist(R)=BEAMLINE{xcorpos(R)}.PS;
  55. end
  56. list = findcells(BEAMLINE,'Class','YCOR');
  57. ycorpos=list(find(list>zv1xpos(end),1):length(list)-1);
  58. ycorlist=zeros(1, length(ycorpos));
  59. for R=1:length(ycorpos)
  60. ycorlist(R)=BEAMLINE{ycorpos(R)}.PS;
  61. end
  62. fullcorlist=[xcorlist,ycorlist];
  63. FL.OCEXT.corrreset=[PS(fullcorlist).Ampl];
  64. FL.OCEXT.savefilename='testApps/OCEXT/EXTresults.txt';
  65. FL.OCEXT.overwrite=1;
  66. FL.OCEXT.bpmweights=ones(bpmno,2);
  67. FL.OCEXT.bpmtarget=zeros(bpmno,2);
  68. FL.OCEXT.hcorrweights=ones(length(xcorpos),2);
  69. FL.OCEXT.vcorrweights=ones(length(ycorpos),2);
  70. FL.OCEXT.maxiter=10;
  71. FL.OCEXT.tabledatafile='testApps/OCEXT/defaults.mat';
  72. % This function has no output args, see OutputFcn.
  73. % hObject handle to figure
  74. % eventdata reserved - to be defined in a future version of MATLAB
  75. % handles structure with handles and user data (see GUIDATA)
  76. % varargin command line arguments to OCEXT (see VARARGIN)
  77. % Choose default command line output for OCEXT
  78. handles.output = hObject;
  79. % Update handles structure
  80. guidata(hObject, handles);
  81. % UIWAIT makes OCEXT wait for user response (see UIRESUME)
  82. % uiwait(handles.figure1);
  83. % --- Outputs from this function are returned to the command line.
  84. function varargout = OCEXT_OutputFcn(hObject, eventdata, handles)
  85. % varargout cell array for returning output args (see VARARGOUT);
  86. % hObject handle to figure
  87. % eventdata reserved - to be defined in a future version of MATLAB
  88. % handles structure with handles and user data (see GUIDATA)
  89. % Get default command line output from handles structure
  90. varargout{1} = handles.output;
  91. % --- Executes on button press in pushbutton1.
  92. function pushbutton1_Callback(hObject, eventdata, handles)
  93. bpmtargetEXT
  94. % hObject handle to pushbutton1 (see GCBO)
  95. % eventdata reserved - to be defined in a future version of MATLAB
  96. % handles structure with handles and user data (see GUIDATA)
  97. % --- Executes on button press in pushbutton2.
  98. function pushbutton2_Callback(hObject, eventdata, handles)
  99. bpmweightsEXT
  100. % hObject handle to pushbutton2 (see GCBO)
  101. % eventdata reserved - to be defined in a future version of MATLAB
  102. % handles structure with handles and user data (see GUIDATA)
  103. % --- Executes on button press in pushbutton3.
  104. function pushbutton3_Callback(hObject, eventdata, handles)
  105. correctorweightsEXT
  106. % hObject handle to pushbutton3 (see GCBO)
  107. % eventdata reserved - to be defined in a future version of MATLAB
  108. % handles structure with handles and user data (see GUIDATA)
  109. % --- Executes on button press in pushbutton4.
  110. function pushbutton4_Callback(hObject, eventdata, handles)
  111. global FL PS BEAMLINE
  112. set(handles.text5, 'String', 'Auto-run')
  113. if FL.OCEXT.overwrite==1
  114. delete(FL.OCEXT.savefilename)
  115. end
  116. FlHwUpdate();
  117. openfile=open('thermatsEXT.mat');
  118. FL.OCEXT.xmat=openfile.xmat;
  119. FL.OCEXT.ymat=openfile.ymat;
  120. for R2=1:length(FL.OCEXT.bpmweights(:,1))
  121. FL.OCEXT.xmat(:,R2)=FL.OCEXT.xmat(:,R2)*FL.OCEXT.bpmweights(R2,1);
  122. end
  123. for R2=1:length(FL.OCEXT.hcorrweights(:,1))
  124. FL.OCEXT.xmat(R2,:)=FL.OCEXT.xmat(R2,:)*FL.OCEXT.hcorrweights(R2,1);
  125. end
  126. for R2=1:length(FL.OCEXT.bpmweights(:,2))
  127. FL.OCEXT.ymat(:,R2)=FL.OCEXT.ymat(:,R2)*FL.OCEXT.bpmweights(R2,2);
  128. end
  129. for R2=1:length(FL.OCEXT.vcorrweights(:,1))
  130. FL.OCEXT.ymat(R2,:)=FL.OCEXT.ymat(R2,:)*FL.OCEXT.vcorrweights(R2,1);
  131. end
  132. FL.OCEXT.iexlist=findcells(BEAMLINE,'Name','IEX');
  133. FL.OCEXT.extstart=findcells(BEAMLINE,'Name','QF1X');
  134. FL.OCEXT.fflist=findcells(BEAMLINE,'Name','QM16FF');
  135. zv1xpos=findcells(BEAMLINE,'Name','ZV1X')-1;
  136. FL.OCEXT.bpmno=length(findcells({BEAMLINE{zv1xpos(end):FL.OCEXT.fflist(1)}},'Class','MONI'));
  137. list = findcells(BEAMLINE,'Class','XCOR');
  138. FL.OCEXT.xcorpos=list(find(list>zv1xpos(end),1):length(list)-1);
  139. FL.OCEXT.xcorlist=zeros(1, length(FL.OCEXT.xcorpos));
  140. for R=1:length(FL.OCEXT.xcorpos)
  141. FL.OCEXT.xcorlist(R)=BEAMLINE{FL.OCEXT.xcorpos(R)}.PS;
  142. end
  143. list = findcells(BEAMLINE,'Class','YCOR');
  144. FL.OCEXT.ycorpos=list(find(list>zv1xpos(end),1):length(list)-1);
  145. FL.OCEXT.ycorlist=zeros(1, length(FL.OCEXT.ycorpos));
  146. for R=1:length(FL.OCEXT.ycorpos)
  147. FL.OCEXT.ycorlist(R)=BEAMLINE{FL.OCEXT.ycorpos(R)}.PS;
  148. end
  149. FL.OCEXT.fullcorlist=[FL.OCEXT.xcorlist,FL.OCEXT.ycorlist];
  150. FL.OCEXT.iternum=0;
  151. request{1}=[];
  152. request{2}=FL.OCEXT.fullcorlist;
  153. request{3}=[];
  154. [stat FL.OCEXT.resp] = AccessRequest(request);
  155. FL.OCEXT.stop=0;
  156. while FL.OCEXT.stop==0
  157. pause on
  158. pause(1);
  159. pause off
  160. FlHwUpdate();
  161. stat=FlHwUpdate('wait',10);
  162. [stat,output]=FlHwUpdate('bpmave',10);
  163. [stat instdata] = FlTrackThru(FL.OCEXT.iexlist(end),FL.OCEXT.fflist(end),output);
  164. FL.OCEXT.bpmxavg=zeros(FL.OCEXT.bpmno,1);
  165. FL.OCEXT.bpmyavg=zeros(FL.OCEXT.bpmno,1);
  166. for R2=1:FL.OCEXT.bpmno
  167. if isnan(instdata{1}(R2).x) == 1
  168. FL.OCEXT.bpmxavg(R2,1)=FL.OCEXT.bpmtarget(R2,1);
  169. else
  170. FL.OCEXT.bpmxavg(R2,1)=instdata{1}(R2).x;
  171. end
  172. if isnan(instdata{1}(R2).y) == 1
  173. FL.OCEXT.bpmyavg(R2,1)=FL.OCEXT.bpmtarget(R2,2);
  174. else
  175. FL.OCEXT.bpmyavg(R2,1)=instdata{1}(R2).y;
  176. end
  177. end
  178. FL.OCEXT.corrundo=[PS(FL.OCEXT.fullcorlist).Ampl];
  179. FL.OCEXT.iternum=FL.OCEXT.iternum+1;
  180. zv1xpos=findcells(BEAMLINE,'Name','ZV1X')-1;
  181. list=findcells({BEAMLINE{zv1xpos(end):FL.OCEXT.fflist(1)}},'Class','MONI')+FL.OCEXT.iexlist(end)-1;
  182. bpmslist=[];
  183. for r=1:length(list)
  184. bpmslist=[bpmslist,BEAMLINE{list(r)}.S];
  185. end
  186. plot(bpmslist,FL.OCEXT.bpmxavg*10^6,'Color','blue')
  187. hold on
  188. plot(bpmslist,FL.OCEXT.bpmyavg*10^6,'Color','red')
  189. hold off
  190. xlabel('S (m)')
  191. ylabel('BPM Reading (microns)')
  192. title('Current Extraction Line Orbit')
  193. h = legend('Horizontal','Vertical',1);
  194. set(h,'Interpreter','none')
  195. dlmwrite(FL.OCEXT.savefilename,'====================== new track ==================','delimiter', ' ','roffset', 2,'-append');
  196. dlmwrite(FL.OCEXT.savefilename,'iternum','delimiter', ' ','roffset', 2,'-append');
  197. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.iternum,'delimiter', ' ','roffset', 2,'-append');
  198. dlmwrite(FL.OCEXT.savefilename,'xrms','delimiter', ' ','roffset', 2,'-append');
  199. dlmwrite(FL.OCEXT.savefilename,sqrt(mean(FL.OCEXT.bpmxavg.^2)),'delimiter', ' ','roffset', 2,'-append');
  200. dlmwrite(FL.OCEXT.savefilename,'yrms','delimiter', ' ','roffset', 2,'-append');
  201. dlmwrite(FL.OCEXT.savefilename,sqrt(mean(FL.OCEXT.bpmyavg.^2)),'delimiter', ' ','roffset', 2,'-append')
  202. dlmwrite(FL.OCEXT.savefilename,'hor','delimiter', ' ','roffset', 2,'-append');
  203. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.bpmxavg,'delimiter', ' ','roffset', 2,'-append');
  204. dlmwrite(FL.OCEXT.savefilename,'vert','delimiter', ' ','roffset', 2,'-append');
  205. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.bpmyavg,'delimiter', ' ','roffset', 2,'-append');
  206. dlmwrite(FL.OCEXT.savefilename,'---------------------------','delimiter', ' ','roffset', 2,'-append')
  207. FL.OCEXT.horcorr=transpose(pinv(FL.OCEXT.xmat))*(FL.OCEXT.bpmxavg-FL.OCEXT.bpmtarget(:,1))*10^-5;
  208. FL.OCEXT.vertcorr=transpose(pinv(FL.OCEXT.ymat))*(FL.OCEXT.bpmyavg-FL.OCEXT.bpmtarget(:,2))*10^-5;
  209. FL.OCEXT.midhorcorr=transpose(pinv(FL.OCEXT.xmat))*((FL.OCEXT.bpmxavg-FL.OCEXT.bpmtarget(:,1))/2)*10^-5;
  210. FL.OCEXT.midvertcorr=transpose(pinv(FL.OCEXT.ymat))*((FL.OCEXT.bpmyavg-FL.OCEXT.bpmtarget(:,2))/2)*10^-5;
  211. dlmwrite(FL.OCEXT.savefilename,'horcorr','delimiter', ' ','roffset', 2,'-append');
  212. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.horcorr,'delimiter', ' ','roffset', 2,'-append');
  213. dlmwrite(FL.OCEXT.savefilename,'vertcorr','delimiter', ' ','roffset', 2,'-append');
  214. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.vertcorr,'delimiter', ' ','roffset', 2,'-append');
  215. dlmwrite(FL.OCEXT.savefilename,'mid-point horcorr','delimiter', ' ','roffset', 2,'-append');
  216. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.midhorcorr,'delimiter', ' ','roffset', 2,'-append');
  217. dlmwrite(FL.OCEXT.savefilename,'mid-point vertcorr','delimiter', ' ','roffset', 2,'-append');
  218. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.midvertcorr,'delimiter', ' ','roffset', 2,'-append');
  219. for R1=1:length(FL.OCEXT.xcorlist)
  220. PS(FL.OCEXT.xcorlist(R1)).SetPt=PS(FL.OCEXT.xcorlist(R1)).Ampl+FL.OCEXT.horcorr(R1);
  221. end
  222. for R1=1:length(FL.OCEXT.ycorlist)
  223. PS(FL.OCEXT.ycorlist(R1)).SetPt=PS(FL.OCEXT.ycorlist(R1)).Ampl+FL.OCEXT.vertcorr(R1);
  224. end
  225. dlmwrite(FL.OCEXT.savefilename,'full correction','delimiter', ' ','roffset', 2,'-append');
  226. dlmwrite(FL.OCEXT.savefilename,'horsetpt','delimiter', ' ','roffset', 2,'-append');
  227. dlmwrite(FL.OCEXT.savefilename,[PS(FL.OCEXT.xcorlist).SetPt],'delimiter', ' ','roffset', 2,'-append');
  228. dlmwrite(FL.OCEXT.savefilename,'vertsetpt','delimiter', ' ','roffset', 2,'-append');
  229. dlmwrite(FL.OCEXT.savefilename,[PS(FL.OCEXT.ycorlist).SetPt],'delimiter', ' ','roffset', 2,'-append');
  230. PSTrim(FL.OCEXT.fullcorlist, 1);
  231. pause on
  232. pause(1);
  233. pause off
  234. FlHwUpdate();
  235. FL.OCEXT.bpmxavgprev=FL.OCEXT.bpmxavg;
  236. FL.OCEXT.bpmyavgprev=FL.OCEXT.bpmyavg;
  237. FlHwUpdate('wait',10);
  238. [stat,output]=FlHwUpdate('bpmave',10);
  239. [stat instdata] = FlTrackThru(FL.OCEXT.iexlist(end),FL.OCEXT.fflist(end),output);
  240. FL.OCEXT.bpmxavg=zeros(FL.OCEXT.bpmno,1);
  241. FL.OCEXT.bpmyavg=zeros(FL.OCEXT.bpmno,1);
  242. for R2=1:FL.OCEXT.bpmno
  243. if isnan(instdata{1}(R2).x) == 1
  244. FL.OCEXT.bpmxavg(R2,1)=FL.OCEXT.bpmtarget(R2,1);
  245. else
  246. FL.OCEXT.bpmxavg(R2,1)=instdata{1}(R2).x;
  247. end
  248. if isnan(instdata{1}(R2).y) == 1
  249. FL.OCEXT.bpmyavg(R2,1)=FL.OCEXT.bpmtarget(R2,2);
  250. else
  251. FL.OCEXT.bpmyavg(R2,1)=instdata{1}(R2).y;
  252. end
  253. end
  254. FL.OCEXT.iternum=FL.OCEXT.iternum+1;
  255. list=findcells({BEAMLINE{FL.OCEXT.iexlist(end):FL.OCEXT.fflist(1)}},'Class','MONI')+FL.OCEXT.iexlist(end)-1;
  256. bpmslist=[];
  257. for r=1:length(list)
  258. bpmslist=[bpmslist,BEAMLINE{list(r)}.S];
  259. end
  260. plot(bpmslist,FL.OCEXT.bpmxavg*10^6,'Color','blue')
  261. hold on
  262. plot(bpmslist,FL.OCEXT.bpmyavg*10^6,'Color','red')
  263. hold off
  264. xlabel('S (m)')
  265. ylabel('BPM Reading (microns)')
  266. title('Current Extraction Line Orbit')
  267. h = legend('Horizontal','Vertical',1);
  268. set(h,'Interpreter','none')
  269. dlmwrite(FL.OCEXT.savefilename,'iternum','delimiter', ' ','roffset', 2,'-append');
  270. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.iternum,'delimiter', ' ','roffset', 2,'-append');
  271. dlmwrite(FL.OCEXT.savefilename,'xrms','delimiter', ' ','roffset', 2,'-append');
  272. dlmwrite(FL.OCEXT.savefilename,sqrt(mean(FL.OCEXT.bpmxavg.^2)),'delimiter', ' ','roffset', 2,'-append');
  273. dlmwrite(FL.OCEXT.savefilename,'yrms','delimiter', ' ','roffset', 2,'-append');
  274. dlmwrite(FL.OCEXT.savefilename,sqrt(mean(FL.OCEXT.bpmyavg.^2)),'delimiter', ' ','roffset', 2,'-append')
  275. dlmwrite(FL.OCEXT.savefilename,'hor','delimiter', ' ','roffset', 2,'-append');
  276. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.bpmxavg,'delimiter', ' ','roffset', 2,'-append');
  277. dlmwrite(FL.OCEXT.savefilename,'vert','delimiter', ' ','roffset', 2,'-append');
  278. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.bpmyavg,'delimiter', ' ','roffset', 2,'-append');
  279. dlmwrite(FL.OCEXT.savefilename,'---------------------------','delimiter', ' ','roffset', 2,'-append')
  280. if sqrt(mean(FL.OCEXT.bpmxavg.^2))/sqrt(mean(FL.OCEXT.bpmxavgprev.^2))>=1
  281. if sqrt(mean(FL.OCEXT.bpmyavg.^2))/sqrt(mean(FL.OCEXT.bpmyavgprev.^2))>=1
  282. FL.OCEXT.stop=1;
  283. end
  284. end
  285. if FL.OCEXT.iternum>=FL.OCEXT.maxiter
  286. FL.OCEXT.stop=1;
  287. end
  288. end
  289. for R1=1:length(FL.OCEXT.xcorlist)
  290. PS(FL.OCEXT.xcorlist(R1)).SetPt=PS(FL.OCEXT.xcorlist(R1)).Ampl-FL.OCEXT.horcorr(R1);
  291. end
  292. for R1=1:length(FL.OCEXT.ycorlist)
  293. PS(FL.OCEXT.ycorlist(R1)).SetPt=PS(FL.OCEXT.ycorlist(R1)).Ampl-FL.OCEXT.vertcorr(R1);
  294. end
  295. dlmwrite(FL.OCEXT.savefilename,'full correction','delimiter', ' ','roffset', 2,'-append');
  296. dlmwrite(FL.OCEXT.savefilename,'horsetpt','delimiter', ' ','roffset', 2,'-append');
  297. dlmwrite(FL.OCEXT.savefilename,[PS(FL.OCEXT.xcorlist).SetPt],'delimiter', ' ','roffset', 2,'-append');
  298. dlmwrite(FL.OCEXT.savefilename,'vertsetpt','delimiter', ' ','roffset', 2,'-append');
  299. dlmwrite(FL.OCEXT.savefilename,[PS(FL.OCEXT.ycorlist).SetPt],'delimiter', ' ','roffset', 2,'-append');
  300. PSTrim(FL.OCEXT.fullcorlist, 1);
  301. pause on
  302. pause(1);
  303. pause off
  304. FlHwUpdate();
  305. FL.OCEXT.bpmxavgprev=FL.OCEXT.bpmxavg;
  306. FL.OCEXT.bpmyavgprev=FL.OCEXT.bpmyavg;
  307. FlHwUpdate('wait',10);
  308. [stat,output]=FlHwUpdate('bpmave',10);
  309. [stat instdata] = FlTrackThru(FL.OCEXT.iexlist(end),FL.OCEXT.fflist(end),output);
  310. FL.OCEXT.bpmxavg=zeros(FL.OCEXT.bpmno,1);
  311. FL.OCEXT.bpmyavg=zeros(FL.OCEXT.bpmno,1);
  312. for R2=1:FL.OCEXT.bpmno
  313. if isnan(instdata{1}(R2).x) == 1
  314. FL.OCEXT.bpmxavg(R2,1)=FL.OCEXT.bpmtarget(R2,1);
  315. else
  316. FL.OCEXT.bpmxavg(R2,1)=instdata{1}(R2).x;
  317. end
  318. if isnan(instdata{1}(R2).y) == 1
  319. FL.OCEXT.bpmyavg(R2,1)=FL.OCEXT.bpmtarget(R2,2);
  320. else
  321. FL.OCEXT.bpmyavg(R2,1)=instdata{1}(R2).y;
  322. end
  323. end
  324. FL.OCEXT.iternum=FL.OCEXT.iternum+1;
  325. list=findcells({BEAMLINE{FL.OCEXT.iexlist(end):FL.OCEXT.fflist(1)}},'Class','MONI')+FL.OCEXT.iexlist(end)-1;
  326. bpmslist=[];
  327. for r=1:length(list)
  328. bpmslist=[bpmslist,BEAMLINE{list(r)}.S];
  329. end
  330. plot(bpmslist,FL.OCEXT.bpmxavg*10^6,'Color','blue')
  331. hold on
  332. plot(bpmslist,FL.OCEXT.bpmyavg*10^6,'Color','red')
  333. hold off
  334. xlabel('S (m)')
  335. ylabel('BPM Reading (microns)')
  336. title('Current Extraction Line Orbit')
  337. h = legend('Horizontal','Vertical',1);
  338. set(h,'Interpreter','none')
  339. dlmwrite(FL.OCEXT.savefilename,'iternum','delimiter', ' ','roffset', 2,'-append');
  340. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.iternum,'delimiter', ' ','roffset', 2,'-append');
  341. dlmwrite(FL.OCEXT.savefilename,'xrms','delimiter', ' ','roffset', 2,'-append');
  342. dlmwrite(FL.OCEXT.savefilename,sqrt(mean(FL.OCEXT.bpmxavg.^2)),'delimiter', ' ','roffset', 2,'-append');
  343. dlmwrite(FL.OCEXT.savefilename,'yrms','delimiter', ' ','roffset', 2,'-append');
  344. dlmwrite(FL.OCEXT.savefilename,sqrt(mean(FL.OCEXT.bpmyavg.^2)),'delimiter', ' ','roffset', 2,'-append')
  345. dlmwrite(FL.OCEXT.savefilename,'hor','delimiter', ' ','roffset', 2,'-append');
  346. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.bpmxavg,'delimiter', ' ','roffset', 2,'-append');
  347. dlmwrite(FL.OCEXT.savefilename,'vert','delimiter', ' ','roffset', 2,'-append');
  348. dlmwrite(FL.OCEXT.savefilename,FL.OCEXT.bpmyavg,'delimiter', ' ','roffset', 2,'-append');
  349. dlmwrite(FL.OCEXT.savefilename,'---------------------------','delimiter', ' ','roffset', 2,'-append')
  350. AccessRequest('release',FL.OCEXT.resp);
  351. if FL.OCEXT.stop==2
  352. set(handles.text5, 'String', 'Aborted')
  353. else
  354. set(handles.text5, 'String', 'Ready')
  355. end
  356. % hObject handle to pushbutton4 (see GCBO)
  357. % eventdata reserved - to be defined in a future version of MATLAB
  358. % handles structure with handles and user data (see GUIDATA)
  359. % --- Executes on button press in pushbutton5.
  360. function pushbutton5_Callback(hObject, eventdata, handles)
  361. FL.OCEXT.stop=2;
  362. % hObject handle to pushbutton5 (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. % --- Executes on button press in pushbutton6.
  366. function pushbutton6_Callback(hObject, eventdata, handles)
  367. manualEXT
  368. % hObject handle to pushbutton6 (see GCBO)
  369. % eventdata reserved - to be defined in a future version of MATLAB
  370. % handles structure with handles and user data (see GUIDATA)
  371. % --- Executes on button press in pushbutton7.
  372. function pushbutton7_Callback(hObject, eventdata, handles)
  373. global FL BEAMLINE PS
  374. set(handles.text5, 'String', 'Busy')
  375. iexlist=findcells(BEAMLINE,'Name','IEX');
  376. extstart=findcells(BEAMLINE,'Name','QF1X');
  377. fflist=findcells(BEAMLINE,'Name','QM16FF');
  378. zv1xpos=findcells(BEAMLINE,'Name','ZV1X')-1;
  379. bpmno=length(findcells({BEAMLINE{zv1xpos(end):fflist(1)}},'Class','MONI'));
  380. list = findcells(BEAMLINE,'Class','XCOR');
  381. xcorpos=list(find(list>zv1xpos(end),1):length(list)-1);
  382. xcorlist=zeros(1, length(xcorpos));
  383. for R=1:length(xcorpos)
  384. xcorlist(R)=BEAMLINE{xcorpos(R)}.PS;
  385. end
  386. list = findcells(BEAMLINE,'Class','YCOR');
  387. ycorpos=list(find(list>zv1xpos(end),1):length(list)-1);
  388. ycorlist=zeros(1, length(ycorpos));
  389. for R=1:length(ycorpos)
  390. ycorlist(R)=BEAMLINE{ycorpos(R)}.PS;
  391. end
  392. fullcorlist=[xcorlist,ycorlist];
  393. request{1}=[];
  394. request{2}=fullcorlist;
  395. request{3}=[];
  396. [stat resp] = AccessRequest(request);
  397. for R1=1:length(fullcorlist)
  398. PS(fullcorlist(R1)).SetPt=FL.OCEXT.corrreset(R1);
  399. end
  400. PSTrim(fullcorlist, 1);
  401. pause on
  402. pause(1);
  403. pause off
  404. FlHwUpdate();
  405. AccessRequest('release',resp);
  406. set(handles.text5, 'String', 'Ready')
  407. % hObject handle to pushbutton7 (see GCBO)
  408. % eventdata reserved - to be defined in a future version of MATLAB
  409. % handles structure with handles and user data (see GUIDATA)
  410. % --- Executes on button press in pushbutton8.
  411. function pushbutton8_Callback(hObject, eventdata, handles)
  412. global FL BEAMLINE PS
  413. set(handles.text5, 'String', 'Busy')
  414. pause on
  415. pause(1)
  416. pause off
  417. FlHwUpdate();
  418. iexlist=findcells(BEAMLINE,'Name','IEX');
  419. extstart=findcells(BEAMLINE,'Name','QF1X');
  420. fflist=findcells(BEAMLINE,'Name','QM16FF');
  421. zv1xpos=findcells(BEAMLINE,'Name','ZV1X')-1;
  422. bpmno=length(findcells({BEAMLINE{zv1xpos(end):fflist(1)}},'Class','MONI'));
  423. list = findcells(BEAMLINE,'Class','XCOR');
  424. xcorpos=list(find(list>zv1xpos(end),1):length(list)-1);
  425. xcorlist=zeros(1, length(xcorpos));
  426. for R=1:length(xcorpos)
  427. xcorlist(R)=BEAMLINE{xcorpos(R)}.PS;
  428. end
  429. list = findcells(BEAMLINE,'Class','YCOR');
  430. ycorpos=list(find(list>zv1xpos(end),1):length(list)-1);
  431. ycorlist=zeros(1, length(ycorpos));
  432. for R=1:length(ycorpos)
  433. ycorlist(R)=BEAMLINE{ycorpos(R)}.PS;
  434. end
  435. fullcorlist=[xcorlist,ycorlist];
  436. FL.OCEXT.corrreset=[PS(fullcorlist).Ampl];
  437. set(handles.text5, 'String', 'Ready')
  438. % hObject handle to pushbutton8 (see GCBO)
  439. % eventdata reserved - to be defined in a future version of MATLAB
  440. % handles structure with handles and user data (see GUIDATA)
  441. % --- Executes on button press in pushbutton9.
  442. function pushbutton9_Callback(hObject, eventdata, handles)
  443. close(handles.figure1);
  444. % hObject handle to pushbutton9 (see GCBO)
  445. % eventdata reserved - to be defined in a future version of MATLAB
  446. % handles structure with handles and user data (see GUIDATA)
  447. % --- Executes on button press in pushbutton10.
  448. function pushbutton10_Callback(hObject, eventdata, handles)
  449. outputfileEXT
  450. % hObject handle to pushbutton10 (see GCBO)
  451. % eventdata reserved - to be defined in a future version of MATLAB
  452. % handles structure with handles and user data (see GUIDATA)
  453. % --- Executes on slider movement.
  454. function slider1_Callback(hObject, eventdata, handles)
  455. % hObject handle to slider1 (see GCBO)
  456. % eventdata reserved - to be defined in a future version of MATLAB
  457. % handles structure with handles and user data (see GUIDATA)
  458. % Hints: get(hObject,'Value') returns position of slider
  459. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  460. % --- Executes during object creation, after setting all properties.
  461. function slider1_CreateFcn(hObject, eventdata, handles)
  462. % hObject handle to slider1 (see GCBO)
  463. % eventdata reserved - to be defined in a future version of MATLAB
  464. % handles empty - handles not created until after all CreateFcns called
  465. % Hint: slider controls usually have a light gray background.
  466. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  467. set(hObject,'BackgroundColor',[.9 .9 .9]);
  468. end
  469. function edit3_Callback(hObject, eventdata, handles)
  470. global FL
  471. user_entry = str2double(get(hObject,'string'));
  472. if isnan(user_entry)
  473. errordlg('You must enter a numeric value','Bad Input','modal')
  474. uicontrol(hObject)
  475. return
  476. else
  477. FL.OCEXT.maxiter=user_entry;
  478. end
  479. % hObject handle to edit3 (see GCBO)
  480. % eventdata reserved - to be defined in a future version of MATLAB
  481. % handles structure with handles and user data (see GUIDATA)
  482. % Hints: get(hObject,'String') returns contents of edit3 as text
  483. % str2double(get(hObject,'String')) returns contents of edit3 as a double
  484. % --- Executes during object creation, after setting all properties.
  485. function edit3_CreateFcn(hObject, eventdata, handles)
  486. % hObject handle to edit3 (see GCBO)
  487. % eventdata reserved - to be defined in a future version of MATLAB
  488. % handles empty - handles not created until after all CreateFcns called
  489. % Hint: edit controls usually have a white background on Windows.
  490. % See ISPC and COMPUTER.
  491. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  492. set(hObject,'BackgroundColor','white');
  493. end