1 | function varargout = LT1cycling(varargin) |
---|
2 | % LT1CYCLING M-file for LT1cycling.fig |
---|
3 | % LT1CYCLING, by itself, creates a new LT1CYCLING or raises the existing |
---|
4 | % singleton*. |
---|
5 | % |
---|
6 | % H = LT1CYCLING returns the handle to a new LT1CYCLING or the handle to |
---|
7 | % the existing singleton*. |
---|
8 | % |
---|
9 | % LT1CYCLING('CALLBACK',hObject,eventData,handles,...) calls the local |
---|
10 | % function named CALLBACK in LT1CYCLING.M with the given input arguments. |
---|
11 | % |
---|
12 | % LT1CYCLING('Property','Value',...) creates a new LT1CYCLING or raises the |
---|
13 | % existing singleton*. Starting from the left, property value pairs are |
---|
14 | % applied to the GUI before LT1cycling_OpeningFunction gets called. An |
---|
15 | % unrecognized property name or invalid value makes property application |
---|
16 | % stop. All inputs are passed to LT1cycling_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 LT1cycling |
---|
24 | |
---|
25 | % Last Modified by GUIDE v2.5 04-Apr-2005 17:56:04 |
---|
26 | |
---|
27 | % Begin initialization code - DO NOT EDIT |
---|
28 | gui_Singleton = 1; |
---|
29 | gui_State = struct('gui_Name', mfilename, ... |
---|
30 | 'gui_Singleton', gui_Singleton, ... |
---|
31 | 'gui_OpeningFcn', @LT1cycling_OpeningFcn, ... |
---|
32 | 'gui_OutputFcn', @LT1cycling_OutputFcn, ... |
---|
33 | 'gui_LayoutFcn', [] , ... |
---|
34 | 'gui_Callback', []); |
---|
35 | if nargin && ischar(varargin{1}) |
---|
36 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
37 | end |
---|
38 | |
---|
39 | if nargout |
---|
40 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
41 | else |
---|
42 | gui_mainfcn(gui_State, varargin{:}); |
---|
43 | end |
---|
44 | % End initialization code - DO NOT EDIT |
---|
45 | |
---|
46 | |
---|
47 | % --- Executes just before LT1cycling is made visible. |
---|
48 | function LT1cycling_OpeningFcn(hObject, eventdata, handles, varargin) |
---|
49 | % This function has no output args, see OutputFcn. |
---|
50 | % hObject handle to figure |
---|
51 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
52 | % handles structure with handles and user data (see GUIDATA) |
---|
53 | % varargin command line arguments to LT1cycling (see VARARGIN) |
---|
54 | |
---|
55 | % Choose default command line output for LT1cycling |
---|
56 | handles.output = hObject; |
---|
57 | |
---|
58 | % Update handles structure |
---|
59 | guidata(hObject, handles); |
---|
60 | |
---|
61 | % UIWAIT makes LT1cycling wait for user response (see UIRESUME) |
---|
62 | % uiwait(handles.figure1); |
---|
63 | list = {'Present', 'Golden', 'UserSelect'}; |
---|
64 | set(handles.popupmenu_file,'String',list); |
---|
65 | set(handles.popupmenu_file,'Value',2); |
---|
66 | |
---|
67 | list = {'Simple', 'Full', 'startup'}; |
---|
68 | set(handles.popupmenu_type,'String',list); |
---|
69 | set(handles.popupmenu_type,'Value',2); |
---|
70 | |
---|
71 | list = {'Load cycling curve','Start', 'Stop', 'Pause', 'Resume', 'Init'}; |
---|
72 | set(handles.popupmenu_command,'String',list); |
---|
73 | |
---|
74 | Machine = getfamilydata('SubMachine'); |
---|
75 | |
---|
76 | if isempty(Machine) |
---|
77 | error('Exiting .. first load a machine!'); |
---|
78 | return; |
---|
79 | else |
---|
80 | switch Machine |
---|
81 | case {'LT1','LT2'} |
---|
82 | set(handles.figure1,'Name', [Machine 'cycling']); |
---|
83 | otherwise |
---|
84 | error('Exiting .. first load LT1 or LT2!'); |
---|
85 | return; |
---|
86 | end |
---|
87 | end |
---|
88 | |
---|
89 | % --- Outputs from this function are returned to the command line. |
---|
90 | function varargout = LT1cycling_OutputFcn(hObject, eventdata, handles) |
---|
91 | % varargout cell array for returning output args (see VARARGOUT); |
---|
92 | % hObject handle to figure |
---|
93 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
94 | % handles structure with handles and user data (see GUIDATA) |
---|
95 | |
---|
96 | % Get default command line output from handles structure |
---|
97 | varargout{1} = handles.output; |
---|
98 | |
---|
99 | |
---|
100 | % --- Executes on button press in checkbox_none. |
---|
101 | function checkbox_none_Callback(hObject, eventdata, handles) |
---|
102 | % hObject handle to checkbox_none (see GCBO) |
---|
103 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
104 | % handles structure with handles and user data (see GUIDATA) |
---|
105 | |
---|
106 | % Hint: get(hObject,'Value') returns toggle state of checkbox_none |
---|
107 | val = get(hObject,'Value'); |
---|
108 | |
---|
109 | if val |
---|
110 | set(handles.checkbox_BEND,'Value',0); |
---|
111 | set(handles.checkbox_QP,'Value',0); |
---|
112 | set(handles.checkbox_CH,'Value',0); |
---|
113 | set(handles.checkbox_CV,'Value',0); |
---|
114 | set(handles.checkbox_all,'Value',0); |
---|
115 | end |
---|
116 | |
---|
117 | % --- Executes on button press in checkbox_all. |
---|
118 | function checkbox_all_Callback(hObject, eventdata, handles) |
---|
119 | % hObject handle to checkbox_all (see GCBO) |
---|
120 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
121 | % handles structure with handles and user data (see GUIDATA) |
---|
122 | |
---|
123 | % Hint: get(hObject,'Value') returns toggle state of checkbox_all |
---|
124 | val = get(hObject,'Value'); |
---|
125 | |
---|
126 | if val |
---|
127 | set(handles.checkbox_BEND,'Value',1); |
---|
128 | set(handles.checkbox_QP,'Value',1); |
---|
129 | set(handles.checkbox_CH,'Value',1); |
---|
130 | set(handles.checkbox_CV,'Value',1); |
---|
131 | set(handles.checkbox_none,'Value',0); |
---|
132 | end |
---|
133 | |
---|
134 | |
---|
135 | % --- Executes on button press in checkbox_BEND. |
---|
136 | function checkbox_BEND_Callback(hObject, eventdata, handles) |
---|
137 | % hObject handle to checkbox_BEND (see GCBO) |
---|
138 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
139 | % handles structure with handles and user data (see GUIDATA) |
---|
140 | |
---|
141 | % Hint: get(hObject,'Value') returns toggle state of checkbox_BEND |
---|
142 | |
---|
143 | set(handles.checkbox_all,'Value',0); |
---|
144 | set(handles.checkbox_none,'Value',0); |
---|
145 | |
---|
146 | % --- Executes on button press in checkbox_QP. |
---|
147 | function checkbox_QP_Callback(hObject, eventdata, handles) |
---|
148 | % hObject handle to checkbox_QP (see GCBO) |
---|
149 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
150 | % handles structure with handles and user data (see GUIDATA) |
---|
151 | |
---|
152 | % Hint: get(hObject,'Value') returns toggle state of checkbox_QP |
---|
153 | |
---|
154 | set(handles.checkbox_all,'Value',0); |
---|
155 | set(handles.checkbox_none,'Value',0); |
---|
156 | |
---|
157 | % --- Executes on button press in checkbox_CH. |
---|
158 | function checkbox_CH_Callback(hObject, eventdata, handles) |
---|
159 | % hObject handle to checkbox_CH (see GCBO) |
---|
160 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
161 | % handles structure with handles and user data (see GUIDATA) |
---|
162 | |
---|
163 | % Hint: get(hObject,'Value') returns toggle state of checkbox_CH |
---|
164 | |
---|
165 | set(handles.checkbox_all,'Value',0); |
---|
166 | set(handles.checkbox_none,'Value',0); |
---|
167 | |
---|
168 | % --- Executes on button press in checkbox_CV. |
---|
169 | function checkbox_CV_Callback(hObject, eventdata, handles) |
---|
170 | % hObject handle to checkbox_CV (see GCBO) |
---|
171 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
172 | % handles structure with handles and user data (see GUIDATA) |
---|
173 | |
---|
174 | % Hint: get(hObject,'Value') returns toggle state of checkbox_CV |
---|
175 | |
---|
176 | set(handles.checkbox_all,'Value',0); |
---|
177 | set(handles.checkbox_none,'Value',0); |
---|
178 | |
---|
179 | % --- Executes on button press in pushbutton_apply. |
---|
180 | function pushbutton_apply_Callback(hObject, eventdata, handles) |
---|
181 | % hObject handle to pushbutton_apply (see GCBO) |
---|
182 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
183 | % handles structure with handles and user data (see GUIDATA) |
---|
184 | |
---|
185 | contents = get(handles.popupmenu_command,'String'); |
---|
186 | command = contents{get(handles.popupmenu_command,'Value')}; |
---|
187 | |
---|
188 | switch command |
---|
189 | case {'Start','Stop','Init','Pause','Resume', 'Load cycling curve'} |
---|
190 | cyclemagnet_local(command,handles); |
---|
191 | otherwise |
---|
192 | error('Unknown ommand name: %s ', command); |
---|
193 | end |
---|
194 | |
---|
195 | function cyclemagnet_local(command,handles) |
---|
196 | |
---|
197 | % [CycleIndex, CycleAO] = isfamily(CycleFamily); |
---|
198 | % |
---|
199 | % rep = tango_group_command_inout2(CycleAO.GroupId,'State',1,0); |
---|
200 | |
---|
201 | Family = {'BEND','QP','CH','CV'}; |
---|
202 | |
---|
203 | Families = {}; |
---|
204 | for k = 1:length(Family), |
---|
205 | if get(handles.(['checkbox_',Family{k}]),'Value') |
---|
206 | Families = {Families{:}, Family{k}}; |
---|
207 | end |
---|
208 | end |
---|
209 | |
---|
210 | switch command |
---|
211 | case {'Start'} |
---|
212 | % get cycling file |
---|
213 | contents = get(handles.popupmenu_file,'String'); |
---|
214 | file = contents{get(handles.popupmenu_file,'Value')}; |
---|
215 | |
---|
216 | % get cycling file |
---|
217 | contents = get(handles.popupmenu_type,'String'); |
---|
218 | type = contents{get(handles.popupmenu_type,'Value')}; |
---|
219 | |
---|
220 | magnetcycle(type,file,Families,'NoDisplay','NoConfig'); |
---|
221 | |
---|
222 | case {'Load cycling curve'} |
---|
223 | % get cycling file |
---|
224 | contents = get(handles.popupmenu_file,'String'); |
---|
225 | file = contents{get(handles.popupmenu_file,'Value')}; |
---|
226 | |
---|
227 | % get cycling file |
---|
228 | contents = get(handles.popupmenu_type,'String'); |
---|
229 | type = contents{get(handles.popupmenu_type,'Value')}; |
---|
230 | |
---|
231 | magnetcycle(type,file,Families,'NoDisplay','Config', 'NoApply'); |
---|
232 | |
---|
233 | case {'Stop','Init','Pause','Resume'} |
---|
234 | for k =1:length(Families) |
---|
235 | CycleFamily = ['Cycle' Families{k}]; |
---|
236 | cyclingcommand(CycleFamily,command); |
---|
237 | end |
---|
238 | end |
---|
239 | |
---|
240 | % --- Executes on selection change in popupmenu_command. |
---|
241 | function popupmenu_command_Callback(hObject, eventdata, handles) |
---|
242 | % hObject handle to popupmenu_command (see GCBO) |
---|
243 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
244 | % handles structure with handles and user data (see GUIDATA) |
---|
245 | |
---|
246 | % Hints: contents = get(hObject,'String') returns popupmenu_command contents as cell array |
---|
247 | % contents{get(hObject,'Value')} returns selected item from popupmenu_command |
---|
248 | |
---|
249 | % --- Executes during object creation, after setting all properties. |
---|
250 | function popupmenu_command_CreateFcn(hObject, eventdata, handles) |
---|
251 | % hObject handle to popupmenu_command (see GCBO) |
---|
252 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
253 | % handles empty - handles not created until after all CreateFcns called |
---|
254 | |
---|
255 | % Hint: popupmenu controls usually have a white background on Windows. |
---|
256 | % See ISPC and COMPUTER. |
---|
257 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
258 | set(hObject,'BackgroundColor','white'); |
---|
259 | end |
---|
260 | |
---|
261 | |
---|
262 | % --- Executes on selection change in popupmenu_type. |
---|
263 | function popupmenu_type_Callback(hObject, eventdata, handles) |
---|
264 | % hObject handle to popupmenu_type (see GCBO) |
---|
265 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
266 | % handles structure with handles and user data (see GUIDATA) |
---|
267 | |
---|
268 | % Hints: contents = get(hObject,'String') returns popupmenu_type contents as cell array |
---|
269 | % contents{get(hObject,'Value')} returns selected item from popupmenu_type |
---|
270 | |
---|
271 | |
---|
272 | % --- Executes during object creation, after setting all properties. |
---|
273 | function popupmenu_type_CreateFcn(hObject, eventdata, handles) |
---|
274 | % hObject handle to popupmenu_type (see GCBO) |
---|
275 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
276 | % handles empty - handles not created until after all CreateFcns called |
---|
277 | |
---|
278 | % Hint: popupmenu controls usually have a white background on Windows. |
---|
279 | % See ISPC and COMPUTER. |
---|
280 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
281 | set(hObject,'BackgroundColor','white'); |
---|
282 | end |
---|
283 | |
---|
284 | |
---|
285 | % --- Executes on selection change in popupmenu_file. |
---|
286 | function popupmenu_file_Callback(hObject, eventdata, handles) |
---|
287 | % hObject handle to popupmenu_file (see GCBO) |
---|
288 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
289 | % handles structure with handles and user data (see GUIDATA) |
---|
290 | |
---|
291 | % Hints: contents = get(hObject,'String') returns popupmenu_file contents as cell array |
---|
292 | % contents{get(hObject,'Value')} returns selected item from popupmenu_file |
---|
293 | |
---|
294 | |
---|
295 | % --- Executes during object creation, after setting all properties. |
---|
296 | function popupmenu_file_CreateFcn(hObject, eventdata, handles) |
---|
297 | % hObject handle to popupmenu_file (see GCBO) |
---|
298 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
299 | % handles empty - handles not created until after all CreateFcns called |
---|
300 | |
---|
301 | % Hint: popupmenu controls usually have a white background on Windows. |
---|
302 | % See ISPC and COMPUTER. |
---|
303 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) |
---|
304 | set(hObject,'BackgroundColor','white'); |
---|
305 | end |
---|
306 | |
---|
307 | |
---|