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

/ATF2/FlightSim/testApps/EXT_Bump/EXT_Bump.m

http://atf2flightsim.googlecode.com/
MATLAB | 593 lines | 348 code | 80 blank | 165 comment | 14 complexity | b2589f8098cbdf8ff1bac11aac532674 MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.0, IPL-1.0, BSD-3-Clause
  1. function varargout = EXT_Bump(varargin)
  2. % EXT_BUMP M-file for EXT_Bump.fig
  3. % EXT_BUMP, by itself, creates a new EXT_BUMP or raises the existing
  4. % singleton*.
  5. %
  6. % H = EXT_BUMP returns the handle to a new EXT_BUMP or the handle to
  7. % the existing singleton*.
  8. %
  9. % EXT_BUMP('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in EXT_BUMP.M with the given input arguments.
  11. %
  12. % EXT_BUMP('Property','Value',...) creates a new EXT_BUMP or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before EXT_Bump_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to EXT_Bump_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 EXT_Bump
  23. % Last Modified by GUIDE v2.5 01-Dec-2009 10:13:27
  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', @EXT_Bump_OpeningFcn, ...
  29. 'gui_OutputFcn', @EXT_Bump_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 EXT_Bump is made visible.
  42. function EXT_Bump_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 EXT_Bump (see VARARGIN)
  48. % Choose default command line output for EXT_Bump
  49. handles.output = hObject;
  50. % Update handles structure
  51. guidata(hObject, handles);
  52. % UIWAIT makes EXT_Bump wait for user response (see UIRESUME)
  53. % uiwait(handles.figure1);
  54. global BEAMLINE INSTR
  55. ZV9Rind = findcells(BEAMLINE,'Name','ZV9R'); %% 1249
  56. ZV2xind = findcells(BEAMLINE,'Name','ZV2X'); %% 1309
  57. ZV11Rind = findcells(BEAMLINE,'Name','ZV11R'); %% 77
  58. ringext = findcells(BEAMLINE,'Name','IEX');
  59. tt = cellfun(@(x) x.Index, INSTR, 'UniformOutput',false);
  60. FlHwUpdate;
  61. xx = cellfun(@(x) x.Data(1),INSTR);
  62. yy = cellfun(@(x) x.Data(2),INSTR);
  63. %% FlHwUpdate('wait',20)
  64. %% [stat,output] = FlHwUpdate('bpmave',20);
  65. %% xx = output{1}(1,:);
  66. %% yy = output{1}(2,:);
  67. instr_ind = cat(1,tt{1:end}); %% notice it's {} not ()
  68. [mm, ia, ib] = intersect(instr_ind, [ZV9Rind:ZV2xind]);
  69. [mm1, ia1, ib1] = intersect(instr_ind, [ZV9Rind:ringext]);
  70. [mm2, ia2, ib2] = intersect(instr_ind, [1:ZV11Rind]);
  71. handles.mm = mm;
  72. handles.ia = ia;
  73. handles.mmd = [mm1, mm2];
  74. handles.iad = [ia1, ia2];
  75. instr_ss = zeros(length(handles.ia),1);
  76. instr_ssd = zeros(length(handles.iad),1);
  77. for ii = 1:length(handles.ia)
  78. instr_ss(ii) = BEAMLINE{handles.mm(ii)}.S;
  79. end
  80. for ii = 1:length(ia1)
  81. instr_ssd(ii) = BEAMLINE{handles.mmd(ii)}.S;
  82. end
  83. for ii = length(ia1)+1:length(ia2)+length(ia1)
  84. instr_ssd(ii) = BEAMLINE{handles.mmd(ii)}.S+BEAMLINE{ringext}.S;
  85. end
  86. handles.instr_ss = instr_ss;
  87. handles.instr_ssd = instr_ssd;
  88. handles.xxd0 = xx(handles.iad);
  89. handles.xx0 = xx(handles.ia);
  90. handles.yyd0 = yy(handles.iad);
  91. handles.yy0 = yy(handles.ia);
  92. ZH9Rind = findcells(BEAMLINE,'Name','ZH9R'); %% 1253 %% 1251
  93. ZH100Rind = findcells(BEAMLINE,'Name','ZH100R'); %% 11
  94. ZH100Rxind = findcells(BEAMLINE,'Name','ZH100RX'); %% 1268 %% 1266
  95. ZH10Rind = findcells(BEAMLINE,'Name','ZH10R'); %% 59
  96. ZH11Rind = findcells(BEAMLINE,'Name','ZH11R'); %% 70
  97. ZH1xind = findcells(BEAMLINE,'Name','ZH1X'); %%1323 %% 1321
  98. ZH2xind = findcells(BEAMLINE,'Name','ZH2X'); %%1334 %% 1332
  99. hcor_ind = [ZH9Rind, ZH100Rind, ZH10Rind, ZH11Rind, ZH100Rxind, ZH1xind, ZH2xind];
  100. psh = [BEAMLINE{ZH9Rind}.PS, BEAMLINE{ZH100Rind}.PS, BEAMLINE{ZH10Rind}.PS, BEAMLINE{ZH11Rind}.PS, BEAMLINE{ZH1xind}.PS, BEAMLINE{ZH2xind}.PS];
  101. request={[] psh []};
  102. [stat resph] = AccessRequest(request);
  103. if(stat{1}==-1)
  104. display(sprintf('AccessRequest returned error :%s',stat{2}));
  105. else
  106. display(sprintf('Access granted, ID of request : %s',resph));
  107. end
  108. [cor_h0, hfig ] = ExtBump('QM7RX', 'h', [0 0]*1e-3, hcor_ind, psh );
  109. t1 = get(hfig(1),'Children');
  110. t2 = get(hfig(2),'Children');
  111. handles.DRsh = get(t1(1),'XData');
  112. handles.DRx = get(t1(2),'YData'); %% reverse order for the data sequence
  113. handles.DRxp = get(t1(1),'YData');
  114. axes(handles.axes3)
  115. plot(handles.DRsh, handles.DRx*1e3)
  116. hold on
  117. plot(handles.DRsh, handles.DRxp*1e3, 'r');
  118. plot(handles.instr_ssd,xx(handles.iad)*1e3,'g d')
  119. hold off
  120. set(gca,'XLim',[min(handles.DRsh), max(handles.DRsh)])
  121. set(gca,'XTick',[]);
  122. ylabel('x x'' (mm , mrad)')
  123. % legend('x', 'x''', 'BPM')
  124. title('Damping ring bump')
  125. axes(handles.axes5)
  126. handles.EXTsh = get(t2(1),'XData');
  127. handles.EXTx = get(t2(2),'YData');
  128. handles.EXTxp = get(t2(1),'YData');
  129. plot( handles.EXTsh, handles.EXTx*1e3)
  130. hold on
  131. plot( handles.EXTsh, handles.EXTxp*1e3, 'r');
  132. plot(handles.instr_ss, xx(handles.ia)*1e3,'g d')
  133. hold off
  134. set(gca,'XLim',[min(handles.EXTsh), max(handles.EXTsh)]);
  135. set(gca,'XTick',[]);
  136. title('Extraction line bump')
  137. ylabel('x x'' (mm , mrad)')
  138. % legend('x', 'x''', 'BPM')
  139. axes(handles.axes7)
  140. bar(cor_h0, 0.8)
  141. ylabel('HC ps')
  142. %% set(gca,'XTickLabel',{'ZH9R', 'ZH100R(x)','ZH10R', 'ZH11R', 'ZH1X', 'ZH2X'});
  143. set(gca,'xlim',[0 7])
  144. ZV100Rind = findcells(BEAMLINE,'Name','ZV100R'); %% 19
  145. ZV100Rxind = findcells(BEAMLINE,'Name','ZV100RX'); %% 1272 %% 1270
  146. ZV10Rind = findcells(BEAMLINE,'Name','ZV10R'); %% 61
  147. %% ZV11Rind = findcells(BEAMLINE,'Name','ZV11R'); %% 77
  148. ZV1xind = findcells(BEAMLINE,'Name','ZV1X'); %% 1295 %% 1293
  149. vcor_ind = [ZV9Rind, ZV100Rind, ZV10Rind, ZV11Rind, ZV100Rxind, ZV1xind, ZV2xind];
  150. psv = [BEAMLINE{ZV9Rind}.PS, BEAMLINE{ZV100Rind}.PS, BEAMLINE{ZV10Rind}.PS, BEAMLINE{ZV11Rind}.PS, BEAMLINE{ZV1xind}.PS, BEAMLINE{ZV2xind}.PS];
  151. request={[] psv []};
  152. [stat respv] = AccessRequest(request);
  153. if(stat{1}==-1)
  154. disp(sprintf('AccessRequest returned error :%s',stat{2}));
  155. else
  156. disp(sprintf('Access granted, ID of request : %s',respv));
  157. end
  158. [cor_v0, hfig ] = ExtBump('QM7RX', 'v', [0 0]*1e-3, vcor_ind, psv );
  159. t1 = get(hfig(1),'Children');
  160. t2 = get(hfig(2),'Children');
  161. handles.DRsv = get(t1(1),'XData');
  162. handles.DRy = get(t1(2),'YData');
  163. handles.DRyp = get(t1(1),'YData');
  164. axes(handles.axes4)
  165. plot( handles.DRsv, handles.DRy*1e3)
  166. hold on
  167. plot( handles.DRsv, handles.DRyp*1e3, 'r');
  168. plot(handles.instr_ssd,yy(handles.iad)*1e3,'g d')
  169. hold off
  170. set(gca,'XLim',[min(handles.DRsh), max(handles.DRsh)])
  171. xlabel('position (s)')
  172. ylabel('y y'' (mm , mrad)')
  173. % legend('y', 'y''', 'BPM')
  174. axes(handles.axes6)
  175. handles.EXTsv = get(t2(1),'XData');
  176. handles.EXTy = get(t2(2),'YData');
  177. handles.EXTyp = get(t2(1),'YData');
  178. plot( handles.EXTsv, handles.EXTy*1e3)
  179. hold on
  180. plot( handles.EXTsv, handles.EXTyp*1e3, 'r');
  181. plot(handles.instr_ss,yy(handles.ia)*1e3,'g d')
  182. hold off
  183. set(gca,'XLim',[min(handles.EXTsh), max(handles.EXTsh)])
  184. xlabel('position (s)')
  185. ylabel('y y'' (mm , mrad)')
  186. % legend('y', 'y''', 'BPM')
  187. axes(handles.axes8)
  188. bar(cor_v0, 0.8)
  189. ylabel('VC ps')
  190. set(gca,'xlim',[0 7])
  191. handles.resph = resph;
  192. handles.respv = respv;
  193. handles.hcor_ind = hcor_ind;
  194. handles.vcor_ind = vcor_ind;
  195. handles.psh = psh;
  196. handles.psv = psv;
  197. handles.cor_h0 = cor_h0;
  198. handles.cor_v0 = cor_v0;
  199. handles.corh_newv = cor_h0;
  200. handles.corv_newv = cor_v0;
  201. guidata(hObject,handles);
  202. % --- Outputs from this function are returned to the command line.
  203. function varargout = EXT_Bump_OutputFcn(hObject, eventdata, handles)
  204. % varargout cell array for returning output args (see VARARGOUT);
  205. % hObject handle to figure
  206. % eventdata reserved - to be defined in a future version of MATLAB
  207. % handles structure with handles and user data (see GUIDATA)
  208. % Get default command line output from handles structure
  209. varargout{1} = handles.output;
  210. % --- Executes on button press in pushbutton1.
  211. function pushbutton1_Callback(hObject, eventdata, handles)
  212. % hObject handle to pushbutton1 (see GCBO)
  213. % eventdata reserved - to be defined in a future version of MATLAB
  214. % handles structure with handles and user data (see GUIDATA)
  215. global INSTR
  216. uu = eval(['[',get(handles.edit1,'String'),']']);
  217. str = get(handles.popupmenu1, 'String');
  218. val = get(handles.popupmenu1,'Value');
  219. handles.plane = get(handles.popupmenu2,'Value');
  220. guidata(hObject,handles);
  221. % Create frequency plot
  222. if handles.plane == 1
  223. plane = 'h';
  224. [corh_newv, hfig ] = ExtBump(str{val}, plane, uu*1e-3, handles.hcor_ind, handles.psh );
  225. handles.corh_newv = corh_newv;
  226. FlHwUpdate;
  227. xx = cellfun(@(x) x.Data(1),INSTR);
  228. yy = cellfun(@(x) x.Data(2),INSTR);
  229. %% FlHwUpdate('wait',20)
  230. %% [stat,output] = FlHwUpdate('bpmave',20)
  231. %% xx = output{1}(1,:);
  232. %% yy = output{1}(2,:);
  233. t1 = get(hfig(1),'Children');
  234. t2 = get(hfig(2),'Children');
  235. handles.DRx = handles.DRx + get(t1(2),'YData');
  236. handles.DRxp = handles.DRxp + get(t1(1),'YData');
  237. axes(handles.axes3)
  238. plot(handles.DRsh, handles.DRx*1e3)
  239. hold on
  240. plot(handles.DRsh, handles.DRxp*1e3, 'r');
  241. plot(handles.instr_ssd, (xx(handles.iad)-handles.xxd0)*1e3,'g d')
  242. hold off
  243. set(gca,'XLim',[min(handles.DRsv), max(handles.DRsv)])
  244. set(gca,'XTick',[]);
  245. ylabel('x x'' (mm , mrad)');
  246. % legend('x', 'x''', 'BPM')
  247. title('Damping ring bump');
  248. %% subplot(4,1,2)
  249. axes(handles.axes5)
  250. handles.EXTx = handles.EXTx + get(t2(2),'YData');
  251. handles.EXTxp = handles.EXTxp + get(t2(1),'YData');
  252. plot( handles.EXTsh, handles.EXTx*1e3)
  253. hold on
  254. plot( handles.EXTsh, handles.EXTxp*1e3, 'r');
  255. plot(handles.instr_ss, (xx(handles.ia)-handles.xx0)*1e3,'g d')
  256. hold off
  257. set(gca,'XLim',[min(handles.EXTsh), max(handles.EXTsh)]);
  258. set(gca,'XTick',[]);
  259. title('Extraction line bump')
  260. ylabel('x x'' (mm , mrad)')
  261. % legend('y', 'y''', 'BPM')
  262. axes(handles.axes7)
  263. bar(handles.corh_newv-handles.cor_h0, 0.8)
  264. ylabel('HC ps')
  265. set(gca,'xlim',[0 7])
  266. guidata(hObject,handles);
  267. else
  268. plane = 'v';
  269. [corv_newv, hfig ] = ExtBump(str{val}, plane, uu*1e-3, handles.vcor_ind, handles.psv );
  270. handles.corv_newv = corv_newv;
  271. guidata(hObject,handles);
  272. FlHwUpdate;
  273. xx = cellfun(@(x) x.Data(1),INSTR);
  274. yy = cellfun(@(x) x.Data(2),INSTR);
  275. %% FlHwUpdate('wait',20)
  276. %% [stat,output] = FlHwUpdate('bpmave',20)
  277. %% xx = output{1}(1,:);
  278. %% yy = output{1}(2,:);
  279. t1 = get(hfig(1),'Children');
  280. t2 = get(hfig(2),'Children');
  281. %% subplot(4,1,3)
  282. axes(handles.axes4)
  283. handles.DRy = handles.DRy + get(t1(2),'YData');
  284. handles.DRyp = handles.DRyp + get(t1(1),'YData');
  285. plot( handles.DRsv, handles.DRy*1e3)
  286. hold on
  287. plot( handles.DRsv, handles.DRyp*1e3, 'r');
  288. plot(handles.instr_ssd, (yy(handles.iad)-handles.yyd0)*1e3,'g d')
  289. hold off
  290. set(gca,'XLim',[min(handles.DRsv), max(handles.DRsv)])
  291. xlabel('position (s)')
  292. ylabel('y y'' (mm , mrad)')
  293. % legend('y', 'y''', 'BPM')
  294. %% subplot(4,1,4)
  295. axes(handles.axes6)
  296. handles.EXTy = handles.EXTy + get(t2(2),'YData');
  297. handles.EXTyp = handles.EXTyp + get(t2(1),'YData');
  298. plot( handles.EXTsv, handles.EXTy*1e3)
  299. hold on
  300. plot( handles.EXTsv, handles.EXTyp*1e3, 'r');
  301. plot(handles.instr_ss, (yy(handles.ia)-handles.yy0)*1e3,'g d')
  302. hold off
  303. set(gca,'XLim',[min(handles.EXTsh), max(handles.EXTsh)])
  304. xlabel('position (s)')
  305. ylabel('y y'' (mm , mrad)')
  306. % legend('y', 'y''', 'BPM')
  307. axes(handles.axes8)
  308. bar(handles.corv_newv-handles.cor_v0, 0.8)
  309. ylabel('VC ps')
  310. set(gca,'xlim',[0 7])
  311. guidata(hObject,handles);
  312. end
  313. % Create time plot
  314. %% axes(handles.time_axes)
  315. %% plot(t,x)
  316. %% set(handles.time_axes,'XMinorTick','on')
  317. %% grid on
  318. % --- Executes on selection change in popupmenu1.
  319. function popupmenu1_Callback(hObject, eventdata, handles)
  320. % hObject handle to popupmenu1 (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. % Get user input from GUI
  324. % Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
  325. % contents{get(hObject,'Value')} returns selected item from popupmenu1
  326. % --- Executes during object creation, after setting all properties.
  327. function popupmenu1_CreateFcn(hObject, eventdata, handles)
  328. % hObject handle to popupmenu1 (see GCBO)
  329. % eventdata reserved - to be defined in a future version of MATLAB
  330. % handles empty - handles not created until after all CreateFcns called
  331. % Hint: popupmenu controls usually have a white background on Windows.
  332. % See ISPC and COMPUTER.
  333. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  334. set(hObject,'BackgroundColor','white');
  335. end
  336. % --- Executes on selection change in popupmenu2.
  337. function popupmenu2_Callback(hObject, eventdata, handles)
  338. % hObject handle to popupmenu2 (see GCBO)
  339. % eventdata reserved - to be defined in a future version of MATLAB
  340. % handles structure with handles and user data (see GUIDATA)
  341. %% multiKnobsFn('save');
  342. %% handles=guiCloseFn('Ext_Bump',handles);
  343. % Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
  344. % contents{get(hObject,'Value')} returns selected item from popupmenu2
  345. % --- Executes during object creation, after setting all properties.
  346. function popupmenu2_CreateFcn(hObject, eventdata, handles)
  347. % hObject handle to popupmenu2 (see GCBO)
  348. % eventdata reserved - to be defined in a future version of MATLAB
  349. % handles empty - handles not created until after all CreateFcns called
  350. % Hint: popupmenu controls usually have a white background on Windows.
  351. % See ISPC and COMPUTER.
  352. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  353. set(hObject,'BackgroundColor','white');
  354. end
  355. function edit1_Callback(hObject, eventdata, handles)
  356. % hObject handle to edit1 (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. % Hints: get(hObject,'String') returns contents of edit1 as text
  360. % str2double(get(hObject,'String')) returns contents of edit1 as a double
  361. % --- Executes during object creation, after setting all properties.
  362. function edit1_CreateFcn(hObject, eventdata, handles)
  363. % hObject handle to edit1 (see GCBO)
  364. % eventdata reserved - to be defined in a future version of MATLAB
  365. % handles empty - handles not created until after all CreateFcns called
  366. % Hint: edit controls usually have a white background on Windows.
  367. % See ISPC and COMPUTER.
  368. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  369. set(hObject,'BackgroundColor','white');
  370. end
  371. % --- Executes on button press in pushbutton2.
  372. function pushbutton2_Callback(hObject, eventdata, handles)
  373. % hObject handle to pushbutton2 (see GCBO)
  374. % eventdata reserved - to be defined in a future version of MATLAB
  375. % handles structure with handles and user data (see GUIDATA)
  376. resp=questdlg('Are you sure?','Exit Request','Yes','No','No');
  377. if ~strcmp(resp,'Yes'); return; end;
  378. try
  379. guiCloseFn('EXT_Bump',handles);
  380. [stat resp] = AccessRequest('release',handles.resph);
  381. [stat resp] = AccessRequest('release',handles.respv);
  382. catch
  383. %% exit
  384. end
  385. %% delete(Ext_Bump1);
  386. %% guiCloseFn(Ext_Bump,handles)
  387. % --- Executes on button press in pushbutton3.
  388. function pushbutton3_Callback(hObject, eventdata, handles)
  389. % hObject handle to pushbutton3 (see GCBO)
  390. % eventdata reserved - to be defined in a future version of MATLAB
  391. % handles structure with handles and user data (see GUIDATA)
  392. global INSTR
  393. handles.plane = get(handles.popupmenu2,'Value');
  394. if handles.plane == 1
  395. [handles.corh_newv] = set_ps(handles.psh,handles.cor_h0);
  396. FlHwUpdate;
  397. xx = cellfun(@(x) x.Data(1),INSTR);
  398. yy = cellfun(@(x) x.Data(2),INSTR);
  399. %% FlHwUpdate('wait',20)
  400. %% [stat,output] = FlHwUpdate('bpmave',20)
  401. %% xx = output{1}(1,:);
  402. %% yy = output{1}(2,:);
  403. axes(handles.axes3);
  404. handles.DRx = zeros(1,length(handles.DRx));
  405. handles.DRxp = zeros(1,length(handles.DRxp));
  406. axes(handles.axes3)
  407. plot(handles.DRsh, handles.DRx*1e3)
  408. hold on
  409. plot(handles.DRsh, handles.DRxp*1e3, 'r');
  410. plot(handles.instr_ssd, xx(handles.iad)*1e3,'g d')
  411. hold off
  412. set(gca,'XLim',[min(handles.DRsv), max(handles.DRsv)])
  413. set(gca,'XTick',[]);
  414. ylabel('x x'' (mm , mrad)');
  415. % legend('x', 'x''', 'BPM')
  416. title('Damping ring bump');
  417. axes(handles.axes5)
  418. handles.EXTx = zeros(1,length(handles.EXTx));
  419. handles.EXTxp = zeros(1,length(handles.EXTxp));
  420. plot( handles.EXTsh, handles.EXTx*1e3)
  421. hold on
  422. plot( handles.EXTsh, handles.EXTxp*1e3, 'r');
  423. plot(handles.instr_ss, xx(handles.ia)*1e3,'g d')
  424. hold off
  425. set(gca,'XLim',[min(handles.EXTsh), max(handles.EXTsh)]);
  426. set(gca,'XTick',[]);
  427. title('Extraction line bump')
  428. ylabel('x x'' (mm , mrad)')
  429. % legend('x', 'x''', 'BPM')
  430. axes(handles.axes7)
  431. bar(handles.corh_newv, 0.8)
  432. ylabel('HC ps')
  433. %% set(gca,'XTickLabel',{'ZH9R', 'ZH100R(x)','ZH10R', 'ZH11R', 'ZH1X', 'ZH2X'});
  434. set(gca,'xlim',[0 7])
  435. guidata(hObject,handles);
  436. else
  437. [handles.corv_newv] = set_ps(handles.psv,handles.cor_v0);
  438. axes(handles.axes4);
  439. handles.DRy = zeros(1,length(handles.DRy));
  440. handles.DRyp = zeros(1,length(handles.DRyp));
  441. FlHwUpdate;
  442. xx = cellfun(@(x) x.Data(1),INSTR);
  443. yy = cellfun(@(x) x.Data(2),INSTR);
  444. %% FlHwUpdate('wait',20)
  445. %% [stat,output] = FlHwUpdate('bpmave',20)
  446. %% xx = output{1}(1,:);
  447. %% yy = output{1}(2,:);
  448. plot( handles.DRsv, handles.DRy*1e3)
  449. hold on
  450. plot( handles.DRsv, handles.DRyp*1e3, 'r');
  451. plot(handles.instr_ssd, yy(handles.iad)*1e3,'g d')
  452. hold off
  453. set(gca,'XLim',[min(handles.DRsv), max(handles.DRsv)])
  454. xlabel('position (s)')
  455. ylabel('y y'' (mm , mrad)')
  456. % legend('y', 'y''', 'BPM')
  457. %% subplot(4,1,4)
  458. axes(handles.axes6)
  459. handles.EXTy = zeros(1,length(handles.EXTy));
  460. handles.EXTyp = zeros(1,length(handles.EXTyp));
  461. plot( handles.EXTsv, handles.EXTy*1e3)
  462. hold on
  463. plot( handles.EXTsv, handles.EXTyp*1e3, 'r');
  464. plot(handles.instr_ss, yy(handles.ia)*1e3,'g d')
  465. hold off
  466. set(gca,'XLim',[min(handles.EXTsh), max(handles.EXTsh)])
  467. xlabel('position (s)')
  468. ylabel('y y'' (mm , mrad)')
  469. %% legend('y', 'y''', 'BPM')
  470. axes(handles.axes8)
  471. bar(handles.corv_newv, 0.8)
  472. ylabel('VC ps')
  473. set(gca,'xlim',[0 7])
  474. guidata(hObject,handles);
  475. end
  476. function edit2_Callback(hObject, eventdata, handles)
  477. % hObject handle to edit2 (see GCBO)
  478. % eventdata reserved - to be defined in a future version of MATLAB
  479. % handles structure with handles and user data (see GUIDATA)
  480. % Hints: get(hObject,'String') returns contents of edit2 as text
  481. % str2double(get(hObject,'String')) returns contents of edit2 as a double
  482. % --- Executes during object creation, after setting all properties.
  483. function edit2_CreateFcn(hObject, eventdata, handles)
  484. % hObject handle to edit2 (see GCBO)
  485. % eventdata reserved - to be defined in a future version of MATLAB
  486. % handles empty - handles not created until after all CreateFcns called
  487. % Hint: edit controls usually have a white background on Windows.
  488. % See ISPC and COMPUTER.
  489. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  490. set(hObject,'BackgroundColor','white');
  491. end
  492. function edit3_Callback(hObject, eventdata, handles)
  493. % hObject handle to edit3 (see GCBO)
  494. % eventdata reserved - to be defined in a future version of MATLAB
  495. % handles structure with handles and user data (see GUIDATA)
  496. % Hints: get(hObject,'String') returns contents of edit3 as text
  497. % str2double(get(hObject,'String')) returns contents of edit3 as a double
  498. % --- Executes during object creation, after setting all properties.
  499. function edit3_CreateFcn(hObject, eventdata, handles)
  500. % hObject handle to edit3 (see GCBO)
  501. % eventdata reserved - to be defined in a future version of MATLAB
  502. % handles empty - handles not created until after all CreateFcns called
  503. % Hint: edit controls usually have a white background on Windows.
  504. % See ISPC and COMPUTER.
  505. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  506. set(hObject,'BackgroundColor','white');
  507. end
  508. % --- If Enable == 'on', executes on mouse press in 5 pixel border.
  509. % --- Otherwise, executes on mouse press in 5 pixel border or over popupmenu2.
  510. function popupmenu2_ButtonDownFcn(hObject, eventdata, handles)
  511. % hObject handle to popupmenu2 (see GCBO)
  512. % eventdata reserved - to be defined in a future version of MATLAB
  513. % handles structure with handles and user data (see GUIDATA)