OPTICS_LT1_LT2 - M-file for optics_LT1_LT2.fig OPTICS_LT1_LT2, by itself, creates a new OPTICS_LT1_LT2 or raises the existing singleton*. H = OPTICS_LT1_LT2 returns the handle to a new OPTICS_LT1_LT2 or the handle to the existing singleton*. OPTICS_LT1_LT2('CALLBACK',hObject,eventData,handles,...) calls the local function named CALLBACK in OPTICS_LT1_LT2.M with the given input arguments. OPTICS_LT1_LT2('Property','Value',...) creates a new OPTICS_LT1_LT2 or raises the existing singleton*. Starting from the left, property value pairs are applied to the GUI before optics_LT1_LT2_OpeningFunction gets called. An unrecognized property name or invalid value makes property application stop. All inputs are passed to optics_LT1_LT2_OpeningFcn via varargin. *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one instance to run (singleton)". See also: GUIDE, GUIDATA, GUIHANDLES
0001 function varargout = optics_LT1_LT2(varargin) 0002 %OPTICS_LT1_LT2 - M-file for optics_LT1_LT2.fig 0003 % OPTICS_LT1_LT2, by itself, creates a new OPTICS_LT1_LT2 or raises the existing 0004 % singleton*. 0005 % 0006 % H = OPTICS_LT1_LT2 returns the handle to a new OPTICS_LT1_LT2 or the handle to 0007 % the existing singleton*. 0008 % 0009 % OPTICS_LT1_LT2('CALLBACK',hObject,eventData,handles,...) calls the local 0010 % function named CALLBACK in OPTICS_LT1_LT2.M with the given input arguments. 0011 % 0012 % OPTICS_LT1_LT2('Property','Value',...) creates a new OPTICS_LT1_LT2 or raises the 0013 % existing singleton*. Starting from the left, property value pairs are 0014 % applied to the GUI before optics_LT1_LT2_OpeningFunction gets called. An 0015 % unrecognized property name or invalid value makes property application 0016 % stop. All inputs are passed to optics_LT1_LT2_OpeningFcn via varargin. 0017 % 0018 % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 0019 % instance to run (singleton)". 0020 % 0021 % See also: GUIDE, GUIDATA, GUIHANDLES 0022 0023 % Edit the above text to modify the response to help optics_LT1_LT2 0024 0025 % Last Modified by GUIDE v2.5 09-Mar-2005 10:49:46 0026 0027 % Begin initialization code - DO NOT EDIT 0028 gui_Singleton = 1; 0029 gui_State = struct('gui_Name', mfilename, ... 0030 'gui_Singleton', gui_Singleton, ... 0031 'gui_OpeningFcn', @optics_LT1_LT2_OpeningFcn, ... 0032 'gui_OutputFcn', @optics_LT1_LT2_OutputFcn, ... 0033 'gui_LayoutFcn', [] , ... 0034 'gui_Callback', []); 0035 if nargin && ischar(varargin{1}) 0036 gui_State.gui_Callback = str2func(varargin{1}); 0037 end 0038 0039 if nargout 0040 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 0041 else 0042 gui_mainfcn(gui_State, varargin{:}); 0043 end 0044 % End initialization code - DO NOT EDIT 0045 0046 % --- Executes just before optics_LT1_LT2 is made visible. 0047 function optics_LT1_LT2_OpeningFcn(hObject, eventdata, handles, varargin) 0048 % This function has no output args, see OutputFcn. 0049 % hObject handle to figure 0050 % eventdata reserved - to be defined in a future version of MATLAB 0051 % handles structure with handles and user data (see GUIDATA) 0052 % varargin command line arguments to optics_LT1_LT2 (see VARARGIN) 0053 0054 % Choose default command line output for optics_LT1_LT2 0055 handles.output = hObject; 0056 0057 %mat: utilite ??? 0058 setappdata(handles.figure1, 'twissdatain',struct([])); 0059 0060 % construct initial twiss parameters 0061 0062 Machine = getfamilydata('SubMachine'); 0063 0064 switch Machine 0065 case {'LT1'} 0066 0067 twissdatain.ElemIndex = 1; 0068 twissdatain.SPos = 0; 0069 twissdatain.ClosedOrbit= [1e-3 0 2e-3 0]'*0; 0070 twissdatain.M44 = eye(4); 0071 twissdatain.beta = [8.1 8.1]; 0072 twissdatain.alpha = [0 0]; 0073 twissdatain.mu = [0 0]; 0074 twissdatain.Dispersion = [0 0 0 0]'; 0075 set(handles.figure1,'Name', 'LT1 Optical functions'); 0076 0077 case {'LT2'} 0078 0079 twissdatain.ElemIndex = 1; 0080 twissdatain.SPos = 0; 0081 twissdatain.ClosedOrbit= [1e-3 0 2e-3 0]'*0; 0082 twissdatain.M44 = eye(4); 0083 twissdatain.beta = [6.0 6.0]; 0084 twissdatain.alpha = [-1.8 1.5]; 0085 twissdatain.mu = [0 0]; 0086 twissdatain.Dispersion = [0 0 0 0]'; 0087 set(handles.figure1,'Name', 'LT2 Optical functions'); 0088 0089 otherwise 0090 error('No Machine loaded') 0091 end 0092 0093 setappdata(handles.figure1, 'twissdatain0',twissdatain); 0094 handles.restart = 1; 0095 0096 %% Initialize structure for handling LT1 and LT2 magnets 0097 handles = init_handles(handles); 0098 0099 % Update handles structure 0100 guidata(hObject, handles); 0101 0102 AO = getao; 0103 % setappdata(handles.figure1,'AOmagnet', AO); 0104 0105 %set(handles.(name),'Max',9, 'Min', -9) 0106 0107 % min et max des sliders (figé à l'ouverture puis modifiable par SETBAR) 0108 val_max = getmaxsp('QP'); 0109 val_min = getminsp('QP'); 0110 0111 %% Number of sliders 0112 handles.sliderNumber = 7; 0113 0114 for k = 1:handles.sliderNumber, 0115 name = strcat('sliderQP',num2str(k)) 0116 set(handles.(name),'Max',val_max(k),'Min',val_min(k)); 0117 end 0118 0119 0120 %% liste de aimants a controler (menu deroulant) 0121 list = [AO.QP.CommonNames;... 0122 AO.CH.CommonNames; ... 0123 AO.CV.CommonNames 0124 ]; 0125 0126 %% Automatic configuration for sliders 0127 for k = 1:handles.sliderNumber 0128 name = ['popupmenu_bar' num2str(k)]; 0129 set(handles.(name),'String',list); 0130 set(handles.(name),'Value',k); 0131 end 0132 0133 %% graphe par defaut 0134 axes(handles.axes1); 0135 handles.xtype = 'spos'; 0136 handles.ytype = 'beta'; 0137 0138 %% initialisation AT et IHM 0139 handles = restart(handles); 0140 0141 %% Read Tango values 0142 %read_tango(handles); 0143 0144 % UIWAIT makes optics_LT1_LT2 wait for user response (see UIRESUME) 0145 % uiwait(handles.figure1); 0146 set(0,'DefaultAxesXgrid','on','DefaultAxesYgrid','on'); 0147 0148 %% graphe symboles 0149 axes(handles.axes2); 0150 drawlattice(0,0.8); 0151 set(handles.axes2,'Xlim',[handles.spos(1) handles.spos(end)], ... 0152 'XTick',[],'YTick',[]); 0153 0154 0155 % Update handles structure 0156 guidata(hObject, handles); 0157 0158 %% ------------------------------------- 0159 function handles = computeTwiss(handles) 0160 % update ATmodel 0161 % compute new twiss parameters 0162 % 0163 global THERING; 0164 0165 %%% parameters at the entrance of the line 0166 % twissdatain.ElemIndex=1; 0167 % twissdatain.SPos=0; 0168 % twissdatain.ClosedOrbit=[1e-3 0 2e-3 0]'*0; 0169 % twissdatain.M44=eye(4); 0170 % 0171 % if isequal(isfield(twissdatain,'beta'),0) 0172 0173 if handles.restart == 1 0174 twissdatain = getappdata(handles.figure1,'twissdatain0'); 0175 handles.restart = 0; 0176 else 0177 twissdatain = getappdata(handles.figure1,'twissdatain'); 0178 end 0179 % twissdatain.beta= [8.1 8.1]; 0180 % twissdatain.alpha= [0 0]; 0181 % else 0182 % twissdatain = getappdata(handles.figure1,'twissdatain') 0183 % end 0184 0185 % twissdatain.mu= [0 0]; 0186 % twissdatain.Dispersion= [0 0 0 0]'; 0187 0188 %%% get twiss paramaters 0189 TD = twissline(THERING,0.0,twissdatain,1:length(THERING),'chroma'); 0190 0191 handles.twissdatain = twissdatain; 0192 handles.beta = cat(1,TD.beta); 0193 handles.cod = cat(2,TD.ClosedOrbit)'; 0194 handles.eta = cat(2,TD.Dispersion)'; 0195 handles.spos = cat(1,TD.SPos); 0196 handles.phase = cat(1,TD.mu); 0197 0198 setappdata(handles.figure1,'twissdatain',twissdatain); 0199 0200 % --- Outputs from this function are returned to the command line. 0201 function varargout = optics_LT1_LT2_OutputFcn(hObject, eventdata, handles) 0202 % varargout cell array for returning output args (see VARARGOUT); 0203 % hObject handle to figure 0204 % eventdata reserved - to be defined in a future version of MATLAB 0205 % handles structure with handles and user data (see GUIDATA) 0206 0207 % Get default command line output from handles structure 0208 varargout{1} = handles.output; 0209 0210 % --- Executes during object creation, after setting all properties. 0211 function sliderQP1_CreateFcn(hObject, eventdata, handles) 0212 % hObject handle to sliderQP1 (see GCBO) 0213 % eventdata reserved - to be defined in a future version of MATLAB 0214 % handles empty - handles not created until after all CreateFcns called 0215 0216 % Hint: slider controls usually have a light gray background, change 0217 % 'usewhitebg' to 0 to use default. See ISPC and COMPUTER. 0218 usewhitebg = 1; 0219 if usewhitebg 0220 set(hObject,'BackgroundColor',[.9 .9 .9]); 0221 else 0222 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0223 end 0224 0225 % --- Executes on slider movement. 0226 function sliderQP1_Callback(hObject, eventdata, handles) 0227 % hObject handle to sliderQP1 (see GCBO) 0228 % eventdata reserved - to be defined in a future version of MATLAB 0229 % handles structure with handles and user data (see GUIDATA) 0230 0231 % Hints: get(hObject,'Value') returns position of slider 0232 % get(hObject,'Min') and get(hObject,'Max') to determine range of slider 0233 0234 handles = setslider(hObject,handles); 0235 guidata(hObject, handles); 0236 0237 % --- Executes during object creation, after setting all properties. 0238 function editQP1_CreateFcn(hObject, eventdata, handles) 0239 % hObject handle to editQP1 (see GCBO) 0240 % eventdata reserved - to be defined in a future version of MATLAB 0241 % handles empty - handles not created until after all CreateFcns called 0242 0243 % Hint: edit controls usually have a white background on Windows. 0244 % See ISPC and COMPUTER. 0245 if ispc 0246 set(hObject,'BackgroundColor','green'); 0247 else 0248 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0249 end 0250 0251 % --- Executes on slider movement. 0252 function editQP1_Callback(hObject, eventdata, handles) 0253 % hObject handle to editQP1 (see GCBO) 0254 % eventdata reserved - to be defined in a future version of MATLAB 0255 % handles structure with handles and user data (see GUIDATA) 0256 0257 % Hints: get(hObject,'String') returns contents of editQP1 as text 0258 % str2double(get(hObject,'String')) returns contents of editQP1 as a double 0259 handles = setedit(handles); 0260 guidata(hObject, handles); 0261 0262 % --- Executes during object creation, after setting all properties. 0263 function sliderQP2_CreateFcn(hObject, eventdata, handles) 0264 % hObject handle to sliderQP2 (see GCBO) 0265 % eventdata reserved - to be defined in a future version of MATLAB 0266 % handles empty - handles not created until after all CreateFcns called 0267 0268 % Hint: slider controls usually have a light gray background, change 0269 % 'usewhitebg' to 0 to use default. See ISPC and COMPUTER. 0270 usewhitebg = 1; 0271 if usewhitebg 0272 set(hObject,'BackgroundColor',[.9 .9 .9]); 0273 else 0274 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0275 end 0276 0277 % --- Executes on slider movement. 0278 function sliderQP2_Callback(hObject, eventdata, handles) 0279 % hObject handle to sliderQP2 (see GCBO) 0280 % eventdata reserved - to be defined in a future version of MATLAB 0281 % handles structure with handles and user data (see GUIDATA) 0282 0283 % Hints: get(hObject,'Value') returns position of slider 0284 % get(hObject,'Min') and get(hObject,'Max') to determine range of slider 0285 handles = setslider(hObject,handles); 0286 guidata(hObject, handles); 0287 0288 % --- Executes during object creation, after setting all properties. 0289 function editQP2_CreateFcn(hObject, eventdata, handles) 0290 % hObject handle to editQP2 (see GCBO) 0291 % eventdata reserved - to be defined in a future version of MATLAB 0292 % handles empty - handles not created until after all CreateFcns called 0293 0294 % Hint: edit controls usually have a white background on Windows. 0295 % See ISPC and COMPUTER. 0296 if ispc 0297 set(hObject,'BackgroundColor','white'); 0298 else 0299 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0300 end 0301 0302 function editQP2_Callback(hObject, eventdata, handles) 0303 % hObject handle to editQP2 (see GCBO) 0304 % eventdata reserved - to be defined in a future version of MATLAB 0305 % handles structure with handles and user data (see GUIDATA) 0306 0307 % Hints: get(hObject,'String') returns contents of editQP2 as text 0308 % str2double(get(hObject,'String')) returns contents of editQP2 as a double 0309 handles = setedit(handles); 0310 guidata(hObject, handles); 0311 0312 % --- Executes during object creation, after setting all properties. 0313 function sliderQP3_CreateFcn(hObject, eventdata, handles) 0314 % hObject handle to sliderQP3 (see GCBO) 0315 % eventdata reserved - to be defined in a future version of MATLAB 0316 % handles empty - handles not created until after all CreateFcns called 0317 0318 % Hint: slider controls usually have a light gray background, change 0319 % 'usewhitebg' to 0 to use default. See ISPC and COMPUTER. 0320 usewhitebg = 1; 0321 if usewhitebg 0322 set(hObject,'BackgroundColor',[.9 .9 .9]); 0323 else 0324 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0325 end 0326 0327 % --- Executes on slider movement. 0328 function sliderQP3_Callback(hObject, eventdata, handles) 0329 % hObject handle to sliderQP3 (see GCBO) 0330 % eventdata reserved - to be defined in a future version of MATLAB 0331 % handles structure with handles and user data (see GUIDATA) 0332 0333 % Hints: get(hObject,'Value') returns position of slider 0334 % get(hObject,'Min') and get(hObject,'Max') to determine range of slider 0335 handles = setslider(hObject,handles); 0336 guidata(hObject, handles); 0337 0338 0339 % --- Executes during object creation, after setting all properties. 0340 function editQP3_CreateFcn(hObject, eventdata, handles) 0341 % hObject handle to editQP3 (see GCBO) 0342 % eventdata reserved - to be defined in a future version of MATLAB 0343 % handles empty - handles not created until after all CreateFcns called 0344 0345 % Hint: edit controls usually have a white background on Windows. 0346 % See ISPC and COMPUTER. 0347 if ispc 0348 set(hObject,'BackgroundColor','white'); 0349 else 0350 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0351 end 0352 0353 function editQP3_Callback(hObject, eventdata, handles) 0354 % hObject handle to editQP3 (see GCBO) 0355 % eventdata reserved - to be defined in a future version of MATLAB 0356 % handles structure with handles and user data (see GUIDATA) 0357 0358 % Hints: get(hObject,'String') returns contents of editQP3 as text 0359 % str2double(get(hObject,'String')) returns contents of editQP3 as a double 0360 handles = setedit(handles); 0361 guidata(hObject, handles); 0362 0363 % --- Executes during object creation, after setting all properties. 0364 function editQP4_CreateFcn(hObject, eventdata, handles) 0365 % hObject handle to editQP4 (see GCBO) 0366 % eventdata reserved - to be defined in a future version of MATLAB 0367 % handles empty - handles not created until after all CreateFcns called 0368 0369 % Hint: edit controls usually have a white background on Windows. 0370 % See ISPC and COMPUTER. 0371 if ispc 0372 set(hObject,'BackgroundColor','white'); 0373 else 0374 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0375 end 0376 0377 function editQP4_Callback(hObject, eventdata, handles) 0378 % hObject handle to editQP4 (see GCBO) 0379 % eventdata reserved - to be defined in a future version of MATLAB 0380 % handles structure with handles and user data (see GUIDATA) 0381 0382 % Hints: get(hObject,'String') returns contents of editQP4 as text 0383 % str2double(get(hObject,'String')) returns contents of editQP4 as a double 0384 handles = setedit(handles); 0385 0386 0387 % --- Executes during object creation, after setting all properties. 0388 function sliderQP4_CreateFcn(hObject, eventdata, handles) 0389 % hObject handle to sliderQP4 (see GCBO) 0390 % eventdata reserved - to be defined in a future version of MATLAB 0391 % handles empty - handles not created until after all CreateFcns called 0392 0393 % Hint: slider controls usually have a light gray background, change 0394 % 'usewhitebg' to 0 to use default. See ISPC and COMPUTER. 0395 usewhitebg = 1; 0396 if usewhitebg 0397 set(hObject,'BackgroundColor',[.9 .9 .9]); 0398 else 0399 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0400 end 0401 0402 0403 % --- Executes on slider movement. 0404 function sliderQP4_Callback(hObject, eventdata, handles) 0405 % hObject handle to sliderQP4 (see GCBO) 0406 % eventdata reserved - to be defined in a future version of MATLAB 0407 % handles structure with handles and user data (see GUIDATA) 0408 0409 % Hints: get(hObject,'Value') returns position of slider 0410 % get(hObject,'Min') and get(hObject,'Max') to determine range of slider 0411 handles = setslider(hObject,handles); 0412 guidata(hObject, handles); 0413 0414 % --- Executes during object creation, after setting all properties. 0415 function editQP5_CreateFcn(hObject, eventdata, handles) 0416 % hObject handle to editQP5 (see GCBO) 0417 % eventdata reserved - to be defined in a future version of MATLAB 0418 % handles empty - handles not created until after all CreateFcns called 0419 0420 % Hint: edit controls usually have a white background on Windows. 0421 % See ISPC and COMPUTER. 0422 if ispc 0423 set(hObject,'BackgroundColor','white'); 0424 else 0425 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0426 end 0427 0428 0429 function editQP5_Callback(hObject, eventdata, handles) 0430 % hObject handle to editQP5 (see GCBO) 0431 % eventdata reserved - to be defined in a future version of MATLAB 0432 % handles structure with handles and user data (see GUIDATA) 0433 0434 % Hints: get(hObject,'String') returns contents of editQP5 as text 0435 % str2double(get(hObject,'String')) returns contents of editQP5 as a double 0436 handles = setedit(handles); 0437 guidata(hObject, handles); 0438 0439 % --- Executes during object creation, after setting all properties. 0440 function sliderQP5_CreateFcn(hObject, eventdata, handles) 0441 % hObject handle to sliderQP5 (see GCBO) 0442 % eventdata reserved - to be defined in a future version of MATLAB 0443 % handles empty - handles not created until after all CreateFcns called 0444 0445 % Hint: slider controls usually have a light gray background, change 0446 % 'usewhitebg' to 0 to use default. See ISPC and COMPUTER. 0447 usewhitebg = 1; 0448 if usewhitebg 0449 set(hObject,'BackgroundColor',[.9 .9 .9]); 0450 else 0451 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0452 end 0453 0454 % --- Executes on slider movement. 0455 function sliderQP5_Callback(hObject, eventdata, handles) 0456 % hObject handle to sliderQP5 (see GCBO) 0457 % eventdata reserved - to be defined in a future version of MATLAB 0458 % handles structure with handles and user data (see GUIDATA) 0459 0460 % Hints: get(hObject,'Value') returns position of slider 0461 % get(hObject,'Min') and get(hObject,'Max') to determine range of slider 0462 handles = setslider(hObject,handles); 0463 guidata(hObject, handles); 0464 0465 % --- Executes during object creation, after setting all properties. 0466 function sliderQP6_CreateFcn(hObject, eventdata, handles) 0467 % hObject handle to sliderQP6 (see GCBO) 0468 % eventdata reserved - to be defined in a future version of MATLAB 0469 % handles empty - handles not created until after all CreateFcns called 0470 0471 % Hint: slider controls usually have a light gray background, change 0472 % 'usewhitebg' to 0 to use default. See ISPC and COMPUTER. 0473 usewhitebg = 1; 0474 if usewhitebg 0475 set(hObject,'BackgroundColor',[.9 .9 .9]); 0476 else 0477 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0478 end 0479 0480 % --- Executes on slider movement. 0481 function sliderQP6_Callback(hObject, eventdata, handles) 0482 % hObject handle to sliderQP6 (see GCBO) 0483 % eventdata reserved - to be defined in a future version of MATLAB 0484 % handles structure with handles and user data (see GUIDATA) 0485 0486 % Hints: get(hObject,'Value') returns position of slider 0487 % get(hObject,'Min') and get(hObject,'Max') to determine range of slider 0488 handles = setslider(hObject,handles); 0489 guidata(hObject, handles); 0490 0491 % --- Executes during object creation, after setting all properties. 0492 function editQP6_CreateFcn(hObject, eventdata, handles) 0493 % hObject handle to editQP6 (see GCBO) 0494 % eventdata reserved - to be defined in a future version of MATLAB 0495 % handles empty - handles not created until after all CreateFcns called 0496 0497 % Hint: edit controls usually have a white background on Windows. 0498 % See ISPC and COMPUTER. 0499 if ispc 0500 set(hObject,'BackgroundColor','white'); 0501 else 0502 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0503 end 0504 0505 function editQP6_Callback(hObject, eventdata, handles) 0506 % hObject handle to editQP6 (see GCBO) 0507 % eventdata reserved - to be defined in a future version of MATLAB 0508 % handles structure with handles and user data (see GUIDATA) 0509 0510 % Hints: get(hObject,'String') returns contents of editQP6 as text 0511 % str2double(get(hObject,'String')) returns contents of editQP6 as a double 0512 handles = setedit(handles); 0513 guidata(hObject, handles); 0514 0515 % --- Executes during object creation, after setting all properties. 0516 function editQP7_CreateFcn(hObject, eventdata, handles) 0517 % hObject handle to editQP7 (see GCBO) 0518 % eventdata reserved - to be defined in a future version of MATLAB 0519 % handles empty - handles not created until after all CreateFcns called 0520 0521 % Hint: edit controls usually have a white background on Windows. 0522 % See ISPC and COMPUTER. 0523 if ispc 0524 set(hObject,'BackgroundColor','white'); 0525 else 0526 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0527 end 0528 0529 function editQP7_Callback(hObject, eventdata, handles) 0530 % hObject handle to editQP7 (see GCBO) 0531 % eventdata reserved - to be defined in a future version of MATLAB 0532 % handles structure with handles and user data (see GUIDATA) 0533 0534 % Hints: get(hObject,'String') returns contents of editQP7 as text 0535 % str2double(get(hObject,'String')) returns contents of editQP7 as a double 0536 handles = setedit(handles); 0537 0538 0539 % --- Executes during object creation, after setting all properties. 0540 function sliderQP7_CreateFcn(hObject, eventdata, handles) 0541 % hObject handle to sliderQP7 (see GCBO) 0542 % eventdata reserved - to be defined in a future version of MATLAB 0543 % handles empty - handles not created until after all CreateFcns called 0544 0545 % Hint: slider controls usually have a light gray background, change 0546 % 'usewhitebg' to 0 to use default. See ISPC and COMPUTER. 0547 usewhitebg = 1; 0548 if usewhitebg 0549 set(hObject,'BackgroundColor',[.9 .9 .9]); 0550 else 0551 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0552 end 0553 0554 % --- Executes on slider movement. 0555 function sliderQP7_Callback(hObject, eventdata, handles) 0556 % hObject handle to sliderQP7 (see GCBO) 0557 % eventdata reserved - to be defined in a future version of MATLAB 0558 % handles structure with handles and user data (see GUIDATA) 0559 0560 % Hints: get(hObject,'Value') returns position of slider 0561 % get(hObject,'Min') and get(hObject,'Max') to determine range of slider 0562 handles = setslider(hObject,handles); 0563 guidata(hObject, handles); 0564 0565 %----------------------------------------------------------------------- 0566 function plot_axes(handles,quoi) 0567 %%% fonction generique 0568 0569 axes(handles.axes1); cla; hold on; 0570 0571 switch handles.xtype 0572 case 'spos' 0573 x=handles.(handles.xtype); 0574 case 'phase' 0575 x=handles.(handles.xtype); x = x(:,1); 0576 end 0577 0578 switch quoi 0579 case 'beta' 0580 plot(x,handles.beta(:,1),'r.-'); 0581 plot(x,handles.beta(:,2),'b.-'); 0582 ylabel('\beta (m)'); 0583 %mat 0584 %ylim([0 130]); 0585 0586 case 'eta' 0587 plot(x,handles.eta(:,1),'r.-'); 0588 plot(x,handles.eta(:,3),'b.-'); 0589 ylabel('\eta (m)'); 0590 case 'cod' 0591 plot(x,handles.cod(:,1)*1e3,'r.-'); 0592 plot(x,handles.cod(:,3)*1e3,'b.-'); 0593 ylabel('cod (mm)'); 0594 case 'phase' 0595 plot(x,handles.phase(:,1),'r.-'); 0596 plot(x,handles.phase(:,2),'b.-'); 0597 ylabel('phase '); 0598 end 0599 axis([x(1) x(end) -inf inf]); 0600 datalabel on 0601 0602 %-------------------------------------------------------------------------- 0603 function handles = setslider(hObject, handles) 0604 %%% fonction generique pour un slider de type aimant 0605 0606 AOmagnet = getappdata(handles.figure1,'AOmagnet'); %% get LT1 structure 0607 %% extrait le numero 0608 tagstring = get(hObject,'Tag'); 0609 num = tagstring(regexp(tagstring,'\d')); 0610 magnet0 = ['QP' num2str(num)]; 0611 val = get(hObject,'Value'); 0612 str = num2str(val); 0613 set(handles.(['edit' magnet0]),'string',str); 0614 0615 %% Cherche le nom de l'aimant 0616 h = handles.(['popupmenu_bar' num]); 0617 contents = get(h,'String'); 0618 magnet = contents{get(h,'Value')}; 0619 handles = setATmagnet(handles,magnet,val); 0620 0621 AOmagnet.(magnet(1:2)).ModelVal(str2double(magnet(end))) = val; 0622 0623 % save data 0624 setappdata(handles.figure1,'AOmagnet',AOmagnet) 0625 0626 %-------------------------------------------------------------------------- 0627 function handles = setATmagnet(handles,magnet,val) 0628 % function handles = setATmagnet(handles,magnet,val) 0629 % set val as new setvalue of element 'magnet' 0630 % Replot current graph 0631 0632 AOmagnet= getappdata(handles.figure1,'AOmagnet'); % get magnet AO 0633 0634 % set value to AT model 0635 setsp(common2family(magnet), val, common2dev(magnet),'Model'); 0636 0637 % Recompute twiss parameters 0638 handles = computeTwiss(handles); 0639 % Replot everything 0640 plot_axes(handles,handles.ytype); 0641 %mat 0642 %ylim([0 130]); 0643 0644 %-------------------------------------------------------------------------- 0645 function handles = setedit(handles) 0646 % function setedit(handles) 0647 % generic callback for an edit box 0648 0649 AOmagnet= getappdata(handles.figure1,'AOmagnet'); % get magnet AO 0650 0651 %% construction automatique du nom du slider 0652 val = str2double(get(gcbo,'String')); 0653 tagstring = get(gcbo,'Tag'); 0654 num = tagstring(regexp(tagstring,'\d')); 0655 magnet0=['QP' num2str(num)]; 0656 name = handles.(['slider' magnet0]); 0657 %% Cherche le nom de l'aimant 0658 h = handles.(['popupmenu_bar' num]); 0659 contents = get(h,'String'); 0660 magnet = contents{get(h,'Value')}; 0661 0662 %%% Test si dans les limites 0663 if val<get(name,'Max') && val> get(name,'Min') 0664 set(name,'Value',val); 0665 handles = setATmagnet(handles,magnet,val); 0666 AOmagnet.(magnet(1:2)).ModelVal(str2double(magnet(end))) = val; 0667 else % message d'erreur 0668 warndlg('Wrong value for K','Edit Box','Modal') 0669 set(hObject,'String',num2str(get(name,'Value'))); 0670 end 0671 0672 % Save data 0673 setappdata(handles.figure1,'AOmagnet',AOmagnet); 0674 0675 %--------------------------------- 0676 function mutual_exclude(off) 0677 % function mutual_exclude(off) 0678 % fonction pour faire des radioboutons 0679 set(off,'Value',0); 0680 0681 % --- Executes during object creation, after setting all properties. 0682 function popupmenu_y_CreateFcn(hObject, eventdata, handles) 0683 % hObject handle to popupmenu_y (see GCBO) 0684 % eventdata reserved - to be defined in a future version of MATLAB 0685 % handles empty - handles not created until after all CreateFcns called 0686 0687 % Hint: popupmenu controls usually have a white background on Windows. 0688 % See ISPC and COMPUTER. 0689 if ispc 0690 set(hObject,'BackgroundColor','white'); 0691 else 0692 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0693 end 0694 0695 0696 % --- Executes on selection change in popupmenu_y. 0697 function popupmenu_y_Callback(hObject, eventdata, handles) 0698 % hObject handle to popupmenu_y (see GCBO) 0699 % eventdata reserved - to be defined in a future version of MATLAB 0700 % handles structure with handles and user data (see GUIDATA) 0701 0702 % Hints: contents = get(hObject,'String') returns popupmenu_y contents as cell array 0703 % contents{get(hObject,'Value')} returns selected item from popupmenu_y 0704 contents = get(hObject,'String'); 0705 plot_axes(handles, contents{get(hObject,'Value')}); 0706 %mat 0707 %ylim([0 130]); 0708 handles.ytype = contents{get(hObject,'Value')}; 0709 guidata(hObject, handles); 0710 0711 % --- Executes during object creation, after setting all properties. 0712 function popupmenu_x_CreateFcn(hObject, eventdata, handles) 0713 % hObject handle to popupmenu_x (see GCBO) 0714 % eventdata reserved - to be defined in a future version of MATLAB 0715 % handles empty - handles not created until after all CreateFcns called 0716 0717 % Hint: popupmenu controls usually have a white background on Windows. 0718 % See ISPC and COMPUTER. 0719 if ispc 0720 set(hObject,'BackgroundColor','white'); 0721 else 0722 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0723 end 0724 0725 % --- Executes on selection change in popupmenu_x. 0726 function popupmenu_x_Callback(hObject, eventdata, handles) 0727 % hObject handle to popupmenu_x (see GCBO) 0728 % eventdata reserved - to be defined in a future version of MATLAB 0729 % handles structure with handles and user data (see GUIDATA) 0730 0731 % Hints: contents = get(hObject,'String') returns popupmenu_x contents as cell array 0732 % contents{get(hObject,'Value')} returns selected item from popupmenu_x 0733 contents = get(hObject,'String'); 0734 handles.xtype = contents{get(hObject,'Value')}; 0735 guidata(hObject, handles); 0736 plot_axes(handles, handles.ytype); 0737 %mat 0738 %ylim([0 130]); 0739 0740 % --- Executes during object creation, after setting all properties. 0741 function popupmenu_plane_CreateFcn(hObject, eventdata, handles) 0742 % hObject handle to popupmenu_plane (see GCBO) 0743 % eventdata reserved - to be defined in a future version of MATLAB 0744 % handles empty - handles not created until after all CreateFcns called 0745 0746 % Hint: popupmenu controls usually have a white background on Windows. 0747 % See ISPC and COMPUTER. 0748 if ispc 0749 set(hObject,'BackgroundColor','white'); 0750 else 0751 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0752 end 0753 0754 0755 % --- Executes on selection change in popupmenu_plane. 0756 function popupmenu_plane_Callback(hObject, eventdata, handles) 0757 % hObject handle to popupmenu_plane (see GCBO) 0758 % eventdata reserved - to be defined in a future version of MATLAB 0759 % handles structure with handles and user data (see GUIDATA) 0760 0761 % Hints: contents = get(hObject,'String') returns popupmenu_plane contents as cell array 0762 % contents{get(hObject,'Value')} returns selected item from popupmenu_plane 0763 0764 0765 % --- Executes on button press in pushbutton_reload. 0766 function pushbutton_reload_Callback(hObject, eventdata, handles) 0767 % hObject handle to pushbutton_reload (see GCBO) 0768 % eventdata reserved - to be defined in a future version of MATLAB 0769 % handles structure with handles and user data (see GUIDATA) 0770 0771 handles = restart(handles); 0772 guidata(hObject,handles); 0773 0774 %-------------------------------------------------------- 0775 function handles = restart(handles) 0776 % function handles = restart(handles) 0777 % Reinitialise la maille et l'IHM 0778 0779 AD = getad; 0780 run(AD.ATModel); %% Load lattice 0781 global THERING 0782 % MAT ET LAURENT : TEMPORAIRE 0783 %warning('66 MeV'); 0784 %setenergymodel(0.066); 0785 0786 % 0787 setappdata(handles.figure1, 'LT1', THERING); 0788 0789 handles.restart = 1; 0790 handles = computeTwiss(handles); 0791 0792 plot_axes(handles,handles.ytype); 0793 %mat 0794 0795 %ylim([0 130]); 0796 0797 handles.modelMagnetVal = {'chModelVal', 'cvModelVal', ... 0798 'quadrupoleModelVal', 'dipoleModelVal'}; 0799 0800 store_model_values(handles); 0801 0802 % Relaod Accelerator Object 0803 AO = getao; 0804 0805 %% Initialise les sliders et editboxes 0806 for k = 1:handles.sliderNumber 0807 name = ['popupmenu_bar' num2str(k)]; 0808 contents = get(handles.(name),'String'); 0809 magnet = contents{get(handles.(name),'Value')}; 0810 0811 Qname = ['QP' num2str(k)]; 0812 0813 % Read AT values 0814 val = getam(common2family(magnet),common2dev(magnet),'Model'); 0815 0816 set(handles.(['slider' Qname]),'Value', val); 0817 set(handles.(['edit' Qname]),'string', num2str(val)); 0818 end 0819 0820 0821 % --- Executes during object creation, after setting all properties. 0822 function popupmenu_bar1_CreateFcn(hObject, eventdata, handles) 0823 % hObject handle to popupmenu_bar1 (see GCBO) 0824 % eventdata reserved - to be defined in a future version of MATLAB 0825 % handles empty - handles not created until after all CreateFcns called 0826 0827 % Hint: popupmenu controls usually have a white background on Windows. 0828 % See ISPC and COMPUTER. 0829 if ispc 0830 set(hObject,'BackgroundColor','white'); 0831 else 0832 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0833 end 0834 0835 0836 % --- Executes on selection change in popupmenu_bar1. 0837 function popupmenu_bar1_Callback(hObject, eventdata, handles) 0838 % hObject handle to popupmenu_bar1 (see GCBO) 0839 % eventdata reserved - to be defined in a future version of MATLAB 0840 % handles structure with handles and user data (see GUIDATA) 0841 0842 % Hints: contents = get(hObject,'String') returns popupmenu_bar1 contents as cell array 0843 % contents{get(hObject,'Value')} returns selected item from popupmenu_bar1 0844 0845 setbar(handles); 0846 0847 %---------------------------------------------------------- 0848 function setbar(handles) 0849 %% aimant selectionne 0850 contents = get(gcbo,'String'); 0851 magnet = contents{get(gcbo,'Value')} 0852 0853 %% mets a jour l'IHM pour cet aimant 0854 tagstring = get(gcbo,'Tag'); 0855 num = tagstring(regexp(tagstring,'\d')); 0856 slidername = ['sliderQP' num]; 0857 editboxname = ['editQP' num]; 0858 0859 AOmagnet = getappdata(handles.figure1,'AOmagnet'); 0860 0861 switch magnet 0862 case AOmagnet.CH.CommonNames 0863 val_max = getmaxsp('CH'); 0864 for k = 1:7 0865 name = strcat('sliderQP',num2str(k)) 0866 set(handles.(name),'Max',val_max); 0867 end 0868 val = AOmagnet.CH.ModelVal(str2double(magnet(end))); 0869 case AOmagnet.CV.CommonNames 0870 val = AOmagnet.CV.ModelVal(str2double(magnet(end))); 0871 case AOmagnet.QP.CommonNames 0872 val = AOmagnet.QP.ModelVal(str2double(magnet(end))); 0873 end 0874 0875 str = num2str(val); 0876 set(handles.(slidername),'Value',val); % writes slider 0877 set(handles.(editboxname),'String',str); % writes editbox 0878 0879 % --- Executes during object creation, after setting all properties. 0880 function popupmenu_bar2_CreateFcn(hObject, eventdata, handles) 0881 % hObject handle to popupmenu_bar2 (see GCBO) 0882 % eventdata reserved - to be defined in a future version of MATLAB 0883 % handles empty - handles not created until after all CreateFcns called 0884 0885 % Hint: popupmenu controls usually have a white background on Windows. 0886 % See ISPC and COMPUTER. 0887 if ispc 0888 set(hObject,'BackgroundColor','white'); 0889 else 0890 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0891 end 0892 0893 % --- Executes on selection change in popupmenu_bar2. 0894 function popupmenu_bar2_Callback(hObject, eventdata, handles) 0895 % hObject handle to popupmenu_bar2 (see GCBO) 0896 % eventdata reserved - to be defined in a future version of MATLAB 0897 % handles structure with handles and user data (see GUIDATA) 0898 0899 % Hints: contents = get(hObject,'String') returns popupmenu_bar2 contents as cell array 0900 % contents{get(hObject,'Value')} returns selected item from popupmenu_bar2 0901 setbar(handles); 0902 0903 % --- Executes during object creation, after setting all properties. 0904 function popupmenu_bar3_CreateFcn(hObject, eventdata, handles) 0905 % hObject handle to popupmenu_bar3 (see GCBO) 0906 % eventdata reserved - to be defined in a future version of MATLAB 0907 % handles empty - handles not created until after all CreateFcns called 0908 0909 % Hint: popupmenu controls usually have a white background on Windows. 0910 % See ISPC and COMPUTER. 0911 if ispc 0912 set(hObject,'BackgroundColor','white'); 0913 else 0914 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0915 end 0916 0917 % --- Executes on selection change in popupmenu_bar3. 0918 function popupmenu_bar3_Callback(hObject, eventdata, handles) 0919 % hObject handle to popupmenu_bar3 (see GCBO) 0920 % eventdata reserved - to be defined in a future version of MATLAB 0921 % handles structure with handles and user data (see GUIDATA) 0922 0923 % Hints: contents = get(hObject,'String') returns popupmenu_bar3 contents as cell array 0924 % contents{get(hObject,'Value')} returns selected item from popupmenu_bar3 0925 setbar(handles); 0926 0927 % --- Executes during object creation, after setting all properties. 0928 function popupmenu_bar4_CreateFcn(hObject, eventdata, handles) 0929 % hObject handle to popupmenu_bar4 (see GCBO) 0930 % eventdata reserved - to be defined in a future version of MATLAB 0931 % handles empty - handles not created until after all CreateFcns called 0932 0933 % Hint: popupmenu controls usually have a white background on Windows. 0934 % See ISPC and COMPUTER. 0935 if ispc 0936 set(hObject,'BackgroundColor','white'); 0937 else 0938 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0939 end 0940 0941 % --- Executes on selection change in popupmenu_bar4. 0942 function popupmenu_bar4_Callback(hObject, eventdata, handles) 0943 % hObject handle to popupmenu_bar4 (see GCBO) 0944 % eventdata reserved - to be defined in a future version of MATLAB 0945 % handles structure with handles and user data (see GUIDATA) 0946 0947 % Hints: contents = get(hObject,'String') returns popupmenu_bar4 contents as cell array 0948 % contents{get(hObject,'Value')} returns selected item from popupmenu_bar4 0949 setbar(handles); 0950 0951 % --- Executes during object creation, after setting all properties. 0952 function popupmenu_bar5_CreateFcn(hObject, eventdata, handles) 0953 % hObject handle to popupmenu_bar5 (see GCBO) 0954 % eventdata reserved - to be defined in a future version of MATLAB 0955 % handles empty - handles not created until after all CreateFcns called 0956 0957 % Hint: popupmenu controls usually have a white background on Windows. 0958 % See ISPC and COMPUTER. 0959 if ispc 0960 set(hObject,'BackgroundColor','white'); 0961 else 0962 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0963 end 0964 0965 % --- Executes on selection change in popupmenu_bar5. 0966 function popupmenu_bar5_Callback(hObject, eventdata, handles) 0967 % hObject handle to popupmenu_bar5 (see GCBO) 0968 % eventdata reserved - to be defined in a future version of MATLAB 0969 % handles structure with handles and user data (see GUIDATA) 0970 0971 % Hints: contents = get(hObject,'String') returns popupmenu_bar5 contents as cell array 0972 % contents{get(hObject,'Value')} returns selected item from popupmenu_bar5 0973 setbar(handles); 0974 0975 % --- Executes during object creation, after setting all properties. 0976 function popupmenu_bar6_CreateFcn(hObject, eventdata, handles) 0977 % hObject handle to popupmenu_bar6 (see GCBO) 0978 % eventdata reserved - to be defined in a future version of MATLAB 0979 % handles empty - handles not created until after all CreateFcns called 0980 0981 % Hint: popupmenu controls usually have a white background on Windows. 0982 % See ISPC and COMPUTER. 0983 if ispc 0984 set(hObject,'BackgroundColor','white'); 0985 else 0986 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0987 end 0988 0989 0990 % --- Executes on selection change in popupmenu_bar6. 0991 function popupmenu_bar6_Callback(hObject, eventdata, handles) 0992 % hObject handle to popupmenu_bar6 (see GCBO) 0993 % eventdata reserved - to be defined in a future version of MATLAB 0994 % handles structure with handles and user data (see GUIDATA) 0995 0996 % Hints: contents = get(hObject,'String') returns popupmenu_bar6 contents as cell array 0997 % contents{get(hObject,'Value')} returns selected item from popupmenu_bar6 0998 setbar(handles); 0999 1000 % --- Executes during object creation, after setting all properties. 1001 function popupmenu_bar7_CreateFcn(hObject, eventdata, handles) 1002 % hObject handle to popupmenu_bar7 (see GCBO) 1003 % eventdata reserved - to be defined in a future version of MATLAB 1004 % handles empty - handles not created until after all CreateFcns called 1005 1006 % Hint: popupmenu controls usually have a white background on Windows. 1007 % See ISPC and COMPUTER. 1008 if ispc 1009 set(hObject,'BackgroundColor','white'); 1010 else 1011 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 1012 end 1013 1014 % --- Executes on selection change in popupmenu_bar7. 1015 function popupmenu_bar7_Callback(hObject, eventdata, handles) 1016 % hObject handle to popupmenu_bar7 (see GCBO) 1017 % eventdata reserved - to be defined in a future version of MATLAB 1018 % handles structure with handles and user data (see GUIDATA) 1019 1020 % Hints: contents = get(hObject,'String') returns popupmenu_bar7 contents as cell array 1021 % contents{get(hObject,'Value')} returns selected item from popupmenu_bar7 1022 setbar(handles); 1023 1024 1025 % --- Executes on button press in pushbutton_refresh. 1026 function pushbutton_refresh_Callback(hObject, eventdata, handles) 1027 % hObject handle to pushbutton_refresh (see GCBO) 1028 % eventdata reserved - to be defined in a future version of MATLAB 1029 % handles structure with handles and user data (see GUIDATA) 1030 1031 %-------------------------------------------------------------------------- 1032 function read_tango(handles) 1033 % Reads Tango values for LT1. 1034 1035 % Get magnet AO 1036 AOmagnet = getappdata(handles.figure1,'AOmagnet'); 1037 FamilyName = fieldnames(AOmagnet); 1038 1039 for k1 = 1:length(FamilyName) 1040 % get attribute readback value 1041 magnet = AOmagnet.(FamilyName{k1}); 1042 AOmagnet.(FamilyName{k1}).TangoVal = ... 1043 getam(FamilyName{k1},'Online'); 1044 end 1045 1046 % save data 1047 setappdata(handles.figure1,'AOmagnet',AOmagnet) 1048 1049 %-------------------------------------------------------------------------- 1050 function write_tango(handles); 1051 %-- Writes Tango values 1052 %% Ecriture courant aimant sur les devices serveurs 1053 1054 % Get magnet AO 1055 AOmagnet = getappdata(handles.figure1,'AOmagnet'); 1056 1057 FamilyName = fieldnames(AOmagnet); 1058 for k1 = 1:length(FamilyName) 1059 magnet = AOmagnet.(FamilyName{k1}); 1060 setsp(magnet, magnet.ModelVal,'Online'); 1061 end 1062 1063 %-------------------------------------------------------------------------- 1064 function devicelist = get_device_name(machine,property,magnet) 1065 % get device list from mapping read in tango database 1066 1067 map = tango_get_db_property(machine,property); 1068 sep = cell2mat(regexpi(map,'::','once'))-1; 1069 devicelist = regexprep(map,[magnet '\d*::'],'')'; 1070 1071 % --- Executes during object creation, after setting all properties. 1072 function pushbutton_reload_CreateFcn(hObject, eventdata, handles) 1073 % hObject handle to pushbutton_reload (see GCBO) 1074 % eventdata reserved - to be defined in a future version of MATLAB 1075 % handles empty - handles not created until after all CreateFcns called 1076 1077 % --- Executes on button press in pushbutton_model2online. 1078 function pushbutton_model2online_Callback(hObject, eventdata, handles) 1079 % hObject handle to pushbutton_model2online (see GCBO) 1080 % eventdata reserved - to be defined in a future version of MATLAB 1081 % handles structure with handles and user data (see GUIDATA) 1082 1083 AOmagnet = getappdata(handles.figure1,'AOmagnet'); %% get LT1 structure 1084 1085 user_response = questdlg('Do you want to write setvalues to LT1?'); 1086 switch user_response 1087 case{'No','Cancel'} 1088 return; 1089 case{'Yes'} 1090 FamilyName = fieldnames(AOmagnet); 1091 for k1 = 1:length(FamilyName) 1092 AOmagnet.(FamilyName{k1}).TangoVal = ... 1093 AOmagnet.(FamilyName{k1}).ModelVal; 1094 end 1095 write_tango(handles); 1096 end 1097 1098 % save data 1099 setappdata(handles.figure1,'AOmagnet',AOmagnet) 1100 1101 % --- Executes on button press in pushbutton_online2model. 1102 function pushbutton_online2model_Callback(hObject, eventdata, handles) 1103 % hObject handle to pushbutton_online2model (see GCBO) 1104 % eventdata reserved - to be defined in a future version of MATLAB 1105 % handles structure with handles and user data (see GUIDATA) 1106 1107 % Online values stored in model values except dipoles 1108 user_response = questdlg('Do you want to read TANGO setvalues from LT1?'); 1109 switch user_response 1110 case{'No','Cancel'} 1111 return; 1112 case{'Yes'} 1113 read_tango(handles); 1114 end 1115 1116 AOmagnet = getappdata(handles.figure1,'AOmagnet'); %% get LT1 structure 1117 1118 FamilyName = fieldnames(AOmagnet); 1119 for k1 = 1:length(FamilyName) 1120 AOmagnet.(FamilyName{k1}).ModelVal = AOmagnet.(FamilyName{k1}).TangoVal; 1121 end 1122 1123 %% Initialise les sliders et editboxes 1124 for k = 1:handles.sliderNumber 1125 name = ['popupmenu_bar' num2str(k)]; 1126 contents = get(handles.(name),'String'); 1127 magnet = contents{get(handles.(name),'Value')}; 1128 1129 Qname = ['QP' num2str(k)]; 1130 1131 switch magnet 1132 case AOmagnet.QP.CommonNames 1133 val = AOmagnet.QP.TangoVal(str2double(magnet(end))); 1134 case AOmagnet.CH.CommonNames 1135 val = AOmagnet.CH.TangoVal(str2double(magnet(end))); 1136 case AOmagnet.CV.CommonNames 1137 val = AOmagnet.CV.TangoVal(str2double(magnet(end))); 1138 end 1139 1140 set(handles.(['slider' Qname]),'Value', val); 1141 set(handles.(['edit' Qname]),'string', num2str(val)); 1142 end 1143 1144 set_model_values(handles); 1145 1146 handles = computeTwiss(handles); 1147 plot_axes(handles,handles.ytype); 1148 %mat 1149 %ylim([0 130]); 1150 % Update handles structure 1151 guidata(hObject, handles); 1152 1153 %% Update date 1154 set(handles.text_date,'String',datestr(now,0)); 1155 1156 %save data 1157 setappdata(handles.figure1,'AOmagnet',AOmagnet); 1158 1159 %-------------------------------------------------------------------------- 1160 function handles = init_handles(handles) 1161 %% Inits structure storing all the magnet data 1162 1163 %% AT model used 1164 % global THERING; 1165 1166 A1 = getao; % Load AO for the first time 1167 AOmagnet = []; 1168 list = findmemberof('Magnet'); 1169 for k = 1:length(list) 1170 AOmagnet.(list{k}) = A1.(list{k}); 1171 end 1172 clear A1; 1173 1174 %save data 1175 setappdata(handles.figure1,'AOmagnet',AOmagnet); 1176 1177 store_model_values(handles); 1178 1179 %% Update time 1180 set(handles.text_date,'String',datestr(now,0)); 1181 1182 %-------------------------------------------------------------------------- 1183 function store_model_values(handles) 1184 %% Stores model values in AOmagnet 1185 1186 AOmagnet = getappdata(handles.figure1,'AOmagnet'); % get AOmagnet structure 1187 1188 % Loop over magnet types 1189 FamilyName = fieldnames(AOmagnet); 1190 1191 for k1 = 1:length(FamilyName) 1192 AOmagnet.(FamilyName{k1}).ModelVal = getam(FamilyName{k1},'Model'); 1193 end 1194 1195 setappdata(handles.figure1,'AOmagnet',AOmagnet); 1196 1197 %-------------------------------------------------------------------------- 1198 function set_model_values(handles) 1199 % Set Modelvalue into LT1 AT model 1200 1201 AOmagnet = getappdata(handles.figure1,'AOmagnet'); % get AOmagnet structure 1202 1203 %% Set model values to AT 1204 FamilyName = fieldnames(AOmagnet); 1205 1206 for k1 = 1:length(FamilyName) 1207 magnet = AOmagnet.(FamilyName{k1}); 1208 setsp(FamilyName{k1}, magnet.ModelVal,'Model'); 1209 end 1210 1211 1212 %-------------------------------------------------------------------------- 1213 function submenu_print_setpoint_Callback(hObject, eventdata, handles) 1214 % hObject handle to submenu_print_setpoint (see GCBO) 1215 % eventdata reserved - to be defined in a future version of MATLAB 1216 % handles structure with handles and user data (see GUIDATA) 1217 1218 1219 %-------------------------------------------------------------------------- 1220 function submenu_print_model_Callback(hObject, eventdata, handles) 1221 % hObject handle to submenu_print_model (see GCBO) 1222 % eventdata reserved - to be defined in a future version of MATLAB 1223 % handles structure with handles and user data (see GUIDATA) 1224 1225 1226 % ------------------------------------------------------------------------- 1227 function submenu_save_setpoint_Callback(hObject, eventdata, handles) 1228 % hObject handle to submenu_save_setpoint (see GCBO) 1229 % eventdata reserved - to be defined in a future version of MATLAB 1230 % handles structure with handles and user data (see GUIDATA) 1231 1232 1233 % ------------------------------------------------------------------------- 1234 function submenu_save_model_Callback(hObject, eventdata, handles) 1235 % hObject handle to submenu_save_model (see GCBO) 1236 % eventdata reserved - to be defined in a future version of MATLAB 1237 % handles structure with handles and user data (see GUIDATA) 1238 1239 1240 % ------------------------------------------------------------------------- 1241 function submenu_load_setpoint_Callback(hObject, eventdata, handles) 1242 % hObject handle to submenu_load_setpoint (see GCBO) 1243 % eventdata reserved - to be defined in a future version of MATLAB 1244 % handles structure with handles and user data (see GUIDATA) 1245 1246 1247 %-------------------------------------------------------------------------- 1248 function submenu_load_model_Callback(hObject, eventdata, handles) 1249 % hObject handle to submenu_load_model (see GCBO) 1250 % eventdata reserved - to be defined in a future version of MATLAB 1251 % handles structure with handles and user data (see GUIDATA) 1252 1253 1254 %-------------------------------------------------------------------------- 1255 function Untitled_1_Callback(hObject, eventdata, handles) 1256 % hObject handle to Untitled_1 (see GCBO) 1257 % eventdata reserved - to be defined in a future version of MATLAB 1258 % handles structure with handles and user data (see GUIDATA) 1259 1260 1261 %-------------------------------------------------------------------------- 1262 function Untitled_4_Callback(hObject, eventdata, handles) 1263 % hObject handle to Untitled_4 (see GCBO) 1264 % eventdata reserved - to be defined in a future version of MATLAB 1265 % handles structure with handles and user data (see GUIDATA) 1266 1267 1268 %-------------------------------------------------------------------------- 1269 function Untitled_7_Callback(hObject, eventdata, handles) 1270 % hObject handle to Untitled_7 (see GCBO) 1271 % eventdata reserved - to be defined in a future version of MATLAB 1272 % handles structure with handles and user data (see GUIDATA) 1273 1274 1275 % -------------------------------------------------------------------- 1276 function submenu_dump_model_Callback(hObject, eventdata, handles) 1277 % hObject handle to submenu_dump_model (see GCBO) 1278 % eventdata reserved - to be defined in a future version of MATLAB 1279 % handles structure with handles and user data (see GUIDATA) 1280 1281 % Get magnet AO 1282 AOmagnet = getappdata(handles.figure1,'AOmagnet'); 1283 1284 fprintf(' DeviceName Model s(m) phasex betax(m) etax(m) xcod(mm) phasez betaz(m) etaz(m) zcod(mm)\n') 1285 1286 FamilyName = fieldnames(AOmagnet); 1287 for k1 = 1:length(FamilyName) 1288 alias = AOmagnet.(FamilyName{k1}); 1289 for k2 = 1 : length(AOmagnet.(FamilyName{k1}).CommonNames) 1290 fprintf('%15s %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f \n', ... 1291 alias.DeviceName{k2}, alias.ModelVal(k2), ... 1292 handles.spos(alias.AT.ATIndex(k2),1), handles.phase(alias.AT.ATIndex(k2),1), ... 1293 handles.beta(alias.AT.ATIndex(k2),1), handles.eta(alias.AT.ATIndex(k2),1), ... 1294 handles.cod(alias.AT.ATIndex(k2),1), ... 1295 handles.phase(alias.AT.ATIndex(k2),2), ... 1296 handles.beta(alias.AT.ATIndex(k2),2), handles.eta(alias.AT.ATIndex(k2),2), ... 1297 handles.cod(alias.AT.ATIndex(k2),2)); 1298 end 1299 end 1300 1301 1302 %-------------------------------------------------------------------------- 1303 function submenu_dump_setpoint_Callback(hObject, eventdata, handles) 1304 % hObject handle to submenu_dump_setpoint (see GCBO) 1305 % eventdata reserved - to be defined in a future version of MATLAB 1306 % handles structure with handles and user data (see GUIDATA) 1307 1308 % Get magnet AO 1309 AOmagnet = getappdata(handles.figure1,'AOmagnet'); 1310 1311 fprintf('\n\n DeviceName TANGO\n') 1312 1313 FamilyName = fieldnames(AOmagnet); 1314 for k1 = 1:length(FamilyName) 1315 for k2 = 1 : length(AOmagnet.(FamilyName{k1}).CommonNames) 1316 alias = AOmagnet.(FamilyName{k1}); 1317 fprintf('%15s %6.2f \n', alias.DeviceName{k2}, ... 1318 alias.TangoVal(k2)); 1319 end 1320 end 1321 1322 1323 %-------------------------------------------------------------------------- 1324 function submenu_dump_soleil_setpoint_Callback(hObject, eventdata, handles) 1325 % hObject handle to submenu_dump_soleil_setpoint (see GCBO) 1326 % eventdata reserved - to be defined in a future version of MATLAB 1327 % handles structure with handles and user data (see GUIDATA) 1328 1329 fprintf('\n\n DeviceName Model TANGO\n') 1330 1331 % Get magnet AO 1332 AOmagnet = getappdata(handles.figure1,'AOmagnet'); 1333 1334 FamilyName = fieldnames(AOmagnet); 1335 for k1 = 1:length(FamilyName) 1336 for k2 = 1 : length(AOmagnet.(FamilyName{k1}).CommonNames) 1337 alias = AOmagnet.(FamilyName{k1}); 1338 fprintf('%15s %6.2f %6.2f\n', alias.DeviceName{k2}, ... 1339 alias.ModelVal(k2), alias.TangoVal(k2)); 1340 end 1341 end 1342 1343 1344 % -------------------------------------------------------------------- 1345 function twiss_parameters_Callback(hObject, eventdata, handles) 1346 % hObject handle to twiss_parameters (see GCBO) 1347 % eventdata reserved - to be defined in a future version of MATLAB 1348 % handles structure with handles and user data (see GUIDATA) 1349 1350 1351 % -------------------------------------------------------------------- 1352 function submenu_twissparameters_entry_Callback(hObject, eventdata, handles) 1353 % hObject handle to submenu_twissparameters_entry (see GCBO) 1354 % eventdata reserved - to be defined in a future version of MATLAB 1355 % handles structure with handles and user data (see GUIDATA) 1356 1357 twiss_parameters_entry(handles) 1358 1359 1360