source: MML/trunk/machine/SOLEIL/StorageRing/loco/LOCOsymgui.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 9.3 KB
Line 
1function varargout = LOCOsymgui(varargin)
2% LOCOSYMGUI M-file for LOCOsymgui.fig
3%      LOCOSYMGUI, by itself, creates a new LOCOSYMGUI or raises the existing
4%      singleton*.
5%
6%      H = LOCOSYMGUI returns the handle to a new LOCOSYMGUI or the handle to
7%      the existing singleton*.
8%
9%      LOCOSYMGUI('CALLBACK',hObject,eventData,handles,...) calls the local
10%      function named CALLBACK in LOCOSYMGUI.M with the given input arguments.
11%
12%      LOCOSYMGUI('Property','Value',...) creates a new LOCOSYMGUI or raises the
13%      existing singleton*.  Starting from the left, property value pairs are
14%      applied to the GUI before LOCOsymgui_OpeningFunction gets called.  An
15%      unrecognized property name or invalid value makes property application
16%      stop.  All inputs are passed to LOCOsymgui_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
23% Edit the above text to modify the response to help LOCOsymgui
24
25% Last Modified by GUIDE v2.5 21-Jul-2009 20:40:07
26
27% Begin initialization code - DO NOT EDIT
28
29fprintf('Appli HS en optique 163 quadrupoles\n')
30return;
31
32gui_Singleton = 1;
33gui_State = struct('gui_Name',       mfilename, ...
34                   'gui_Singleton',  gui_Singleton, ...
35                   'gui_OpeningFcn', @LOCOsymgui_OpeningFcn, ...
36                   'gui_OutputFcn',  @LOCOsymgui_OutputFcn, ...
37                   'gui_LayoutFcn',  [] , ...
38                   'gui_Callback',   []);
39if nargin && ischar(varargin{1})
40    gui_State.gui_Callback = str2func(varargin{1});
41end
42
43if nargout
44    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
45else
46    gui_mainfcn(gui_State, varargin{:});
47end
48% End initialization code - DO NOT EDIT
49
50
51% --- Executes just before LOCOsymgui is made visible.
52function LOCOsymgui_OpeningFcn(hObject, eventdata, handles, varargin)
53% This function has no output args, see OutputFcn.
54% hObject    handle to figure
55% eventdata  reserved - to be defined in a future version of MATLAB
56% handles    structure with handles and user data (see GUIDATA)
57% varargin   command line arguments to LOCOsymgui (see VARARGIN)
58
59% Choose default command line output for LOCOsymgui
60handles.output = hObject;
61
62% Update handles structure
63guidata(hObject, handles);
64
65% UIWAIT makes LOCOsymgui wait for user response (see UIRESUME)
66% uiwait(handles.figure1);
67
68handles.DK = NaN;
69handles.Mode = 'Online';
70
71handles.K1i_before = NaN;
72handles.K2i_before = NaN;
73handles.K3i_before = NaN;
74handles.K4i_before = NaN;
75handles.K5i_before = NaN;
76handles.K6i_before = NaN;
77handles.K7i_before = NaN;
78handles.K8i_before = NaN;
79handles.K9i_before = NaN;
80handles.K10i_before = NaN;
81handles.QT_before = NaN;
82handles.tune_before = NaN;
83
84% Update handles structure
85guidata(hObject, handles);
86
87% --- Outputs from this function are returned to the command line.
88function varargout = LOCOsymgui_OutputFcn(hObject, eventdata, handles)
89% varargout  cell array for returning output args (see VARARGOUT);
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
94% Get default command line output from handles structure
95varargout{1} = handles.output;
96
97% --- Executes on button press in pushbutton_storedata.
98function pushbutton_storedata_Callback(hObject, eventdata, handles)
99% hObject    handle to pushbutton_storedata (see GCBO)
100% eventdata  reserved - to be defined in a future version of MATLAB
101% handles    structure with handles and user data (see GUIDATA)
102
103
104Mode = 'Online';
105
106fprintf('Reading Quad values \n');
107
108try
109    handles.K1i_before=getsp('Q1',handles.Mode,'Physics');
110    handles.K2i_before=getsp('Q2',handles.Mode,'Physics');
111    handles.K3i_before=getsp('Q3',handles.Mode,'Physics');
112    handles.K4i_before=getsp('Q4',handles.Mode,'Physics');
113    handles.K5i_before=getsp('Q5',handles.Mode,'Physics');
114    handles.K6i_before=getsp('Q6',handles.Mode,'Physics');
115    handles.K7i_before=getsp('Q7',handles.Mode,'Physics');
116    handles.K8i_before=getsp('Q8',handles.Mode,'Physics');
117    handles.K9i_before=getsp('Q9',handles.Mode,'Physics');
118    handles.K10i_before=getsp('Q10',handles.Mode,'Physics');
119
120    handles.QT_before = getsp('QT', handles.Mode, 'Physics');
121
122    handles.tune_before = gettune;
123
124    fprintf('Nux = %f Nuz = %f\n', handles.tune_before);
125
126    set(handles.pushbutton_Symmetry,'Enable', 'On')
127    set(handles.pushbutton_Coupling,'Enable', 'On')
128
129catch
130    fprintf('Error \n')
131end
132
133% Update handles structure
134guidata(hObject, handles);
135
136
137% --- Executes on button press in pushbutton_Symmetry.
138function pushbutton_Symmetry_Callback(hObject, eventdata, handles)
139% hObject    handle to pushbutton_Symmetry (see GCBO)
140% eventdata  reserved - to be defined in a future version of MATLAB
141% handles    structure with handles and user data (see GUIDATA)
142
143
144%% 160 quad % -1 full correctionvehandles.DK
145k = -1;
146setsp('Q1',k* handles.DK(1:8) + handles.K1i_before, handles.Mode,'Physics');
147setsp('Q2',k* handles.DK(9:16) + handles.K2i_before, handles.Mode,'Physics');
148setsp('Q3',k* handles.DK(17:24) + handles.K3i_before, handles.Mode,'Physics');
149setsp('Q4',k* handles.DK(25:40) + handles.K4i_before, handles.Mode,'Physics');
150setsp('Q5',k* handles.DK(41:56) + handles.K5i_before, handles.Mode,'Physics');
151setsp('Q6',k* handles.DK(57:80) + handles.K6i_before, handles.Mode,'Physics');
152setsp('Q7',k* handles.DK(81:104) + handles.K7i_before, handles.Mode,'Physics');
153setsp('Q8',k* handles.DK(105:128) + handles.K8i_before, handles.Mode,'Physics');
154setsp('Q9',k* handles.DK(129:144) + handles.K9i_before, handles.Mode,'Physics');
155setsp('Q10',k* handles.DK(145:160) + handles.K10i_before, handles.Mode,'Physics');
156pause(5);
157tune = gettune;
158fprintf('Tunes variations for iter0 is Dnux = %f Dnuz =%f\n', tune-handles.tune_before);
159
160set(handles.pushbutton_CancelDK, 'Enable', 'on');
161
162% --- Executes on button press in pushbutton_Coupling.
163function pushbutton_Coupling_Callback(hObject, eventdata, handles)
164% hObject    handle to pushbutton_Coupling (see GCBO)
165% eventdata  reserved - to be defined in a future version of MATLAB
166% handles    structure with handles and user data (see GUIDATA)
167
168%% skew quad -1 for full correction
169k =-1;
170setsp('QT',k* handles.DK(161:192) + handles.QT_before, handles.Mode,'Physics');
171
172fprintf('Correction applied on QTs \n');
173
174set(handles.pushbutton_CancelDK, 'Enable', 'on');
175
176% --- Executes on button press in pushbutton_LOCODATA.
177function pushbutton_LOCODATA_Callback(hObject, eventdata, handles)
178% hObject    handle to pushbutton_LOCODATA (see GCBO)
179% eventdata  reserved - to be defined in a future version of MATLAB
180% handles    structure with handles and user data (see GUIDATA)
181
182temp = evalin('base', 'LOCOstruct');
183
184handles.DK = temp.DK;
185
186% Update handles structure
187guidata(hObject, handles);
188
189set(handles.pushbutton_LOCODATA, 'BackgroundColor', [0 1 0]);
190set(handles.pushbutton_PlotDK, 'Enable', 'on');
191
192
193
194% --- Executes on button press in pushbutton_PlotDK.
195function pushbutton_PlotDK_Callback(hObject, eventdata, handles)
196% hObject    handle to pushbutton_PlotDK (see GCBO)
197% eventdata  reserved - to be defined in a future version of MATLAB
198% handles    structure with handles and user data (see GUIDATA)
199
200analoco('160quad');
201
202
203% --- Executes on button press in pushbutton_CancelDK.
204function pushbutton_CancelDK_Callback(hObject, eventdata, handles)
205% hObject    handle to pushbutton_CancelDK (see GCBO)
206% eventdata  reserved - to be defined in a future version of MATLAB
207% handles    structure with handles and user data (see GUIDATA)
208
209%% 160 quad % -1 full correctionvehandles.DK
210k = 0;
211QuadFlag = 0;
212QTFlag = 1;
213
214if QuadFlag
215    setsp('Q1',k* handles.DK(1:8) + handles.K1i_before, handles.Mode,'Physics');
216    setsp('Q2',k* handles.DK(9:16) + handles.K2i_before, handles.Mode,'Physics');
217    setsp('Q3',k* handles.DK(17:24) + handles.K3i_before, handles.Mode,'Physics');
218    setsp('Q4',k* handles.DK(25:40) + handles.K4i_before, handles.Mode,'Physics');
219    setsp('Q5',k* handles.DK(41:56) + handles.K5i_before, handles.Mode,'Physics');
220    setsp('Q6',k* handles.DK(57:80) + handles.K6i_before, handles.Mode,'Physics');
221    setsp('Q7',k* handles.DK(81:104) + handles.K7i_before, handles.Mode,'Physics');
222    setsp('Q8',k* handles.DK(105:128) + handles.K8i_before, handles.Mode,'Physics');
223    setsp('Q9',k* handles.DK(129:144) + handles.K9i_before, handles.Mode,'Physics');
224    setsp('Q10',k* handles.DK(145:160) + handles.K10i_before, handles.Mode,'Physics');
225end
226
227if QTFlag
228    setsp('QT',k* handles.DK(161:192) + handles.QT_before, handles.Mode,'Physics');
229end   
230
231pause(5);
232tune = gettune;
233fprintf('Tunes variations for iter0 is Dnux = %f Dnuz =%f\n', tune-handles.tune_before);
234
235set(handles.pushbutton_CancelDK, 'Enable', 'off');
236
237
238% --- Executes on button press in checkbox_Quad.
239function checkbox_Quad_Callback(hObject, eventdata, handles)
240% hObject    handle to checkbox_Quad (see GCBO)
241% eventdata  reserved - to be defined in a future version of MATLAB
242% handles    structure with handles and user data (see GUIDATA)
243
244% Hint: get(hObject,'Value') returns toggle state of checkbox_Quad
245
246
247% --- Executes on button press in checkbox_QT.
248function checkbox_QT_Callback(hObject, eventdata, handles)
249% hObject    handle to checkbox_QT (see GCBO)
250% eventdata  reserved - to be defined in a future version of MATLAB
251% handles    structure with handles and user data (see GUIDATA)
252
253% Hint: get(hObject,'Value') returns toggle state of checkbox_QT
254
255
Note: See TracBrowser for help on using the repository browser.