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

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

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