0001 function varargout = Ringcycling(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 gui_Singleton = 1;
0029 gui_State = struct('gui_Name', mfilename, ...
0030 'gui_Singleton', gui_Singleton, ...
0031 'gui_OpeningFcn', @Ringcycling_OpeningFcn, ...
0032 'gui_OutputFcn', @Ringcycling_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
0045
0046
0047
0048 function Ringcycling_OpeningFcn(hObject, eventdata, handles, varargin)
0049
0050
0051
0052
0053
0054
0055
0056 handles.output = hObject;
0057
0058
0059
0060 set(handles.checkbox_HCOR,'Value',0);
0061 set(handles.checkbox_VCOR,'Value',0);
0062 set(handles.checkbox_all,'Value',0);
0063 set([handles.checkbox_all,handles.checkbox_HCOR,handles.checkbox_VCOR],...
0064 'Enable','off');
0065
0066
0067 set(handles.popupmenu_type,'Value',2);
0068
0069
0070 h = uibuttongroup('visible','off','Position',[0.70 0.46 .20 .10],...
0071 'Title','','TitlePosition','centertop',...
0072 'BackgroundColor',[0.696 1.0 0.924]);
0073 u1 = uicontrol('Style','Radio','String','premier élément','Tag','radiobutton1',...
0074 'pos',[10 25 120 25],'parent',h,'HandleVisibility','off',...
0075 'BackgroundColor',[0.696 1.0 0.924]);
0076 u2 = uicontrol('Style','Radio','String','toute la famille','Tag','radiobutton2',...
0077 'pos',[10 0.95 120 25],'parent',h,'HandleVisibility','off',...
0078 'BackgroundColor',[0.696 1.0 0.924]);
0079
0080 set(h,'SelectionChangeFcn',...
0081 {@uibuttongroup_SelectionChangeFcn,handles});
0082
0083 set(h,'SelectedObject',u1);
0084 set(h,'Visible','on');
0085
0086
0087 handles.mode = '1element';
0088
0089
0090 guidata(hObject, handles);
0091
0092
0093
0094 list = {'Present', 'Golden', 'UserSelect'};
0095 set(handles.popupmenu_file,'String',list);
0096
0097 list = {'Simple', 'Full', 'startup'};
0098 set(handles.popupmenu_type,'String',list);
0099
0100 list = {'Load cycling curve','Start', 'Stop', 'Init', 'Pause', 'Resume'};
0101 set(handles.popupmenu_command,'String',list);
0102
0103
0104 function varargout = Ringcycling_OutputFcn(hObject, eventdata, handles)
0105
0106
0107
0108
0109
0110
0111 varargout{1} = handles.output;
0112
0113
0114
0115 function checkbox_none_Callback(hObject, eventdata, handles)
0116
0117
0118
0119
0120
0121 val = get(hObject,'Value');
0122
0123 if val
0124 set(handles.checkbox_BEND,'Value',0);
0125 set(handles.checkbox_Q1,'Value',0);
0126 set(handles.checkbox_HCOR,'Value',0);
0127 set(handles.checkbox_VCOR,'Value',0);
0128 set(handles.checkbox_all,'Value',0);
0129 end
0130
0131
0132 function checkbox_all_Callback(hObject, eventdata, handles)
0133
0134
0135
0136
0137
0138 val = get(hObject,'Value');
0139
0140 if val
0141 set(handles.checkbox_BEND,'Value',1);
0142
0143
0144
0145 for k =1:length(length(findmemberof('QUAD')))
0146 Name = strcat('Q',num2str(k));
0147 set(handles.(['checkbox_',Name]),'Value',1)
0148 end
0149
0150
0151 set(handles.checkbox_S1,'Value',1);
0152 set(handles.checkbox_S2,'Value',1);
0153 set(handles.checkbox_S3,'Value',1);
0154 set(handles.checkbox_S4,'Value',1);
0155 set(handles.checkbox_S5,'Value',1);
0156 set(handles.checkbox_S6,'Value',1);
0157 set(handles.checkbox_S7,'Value',1);
0158 set(handles.checkbox_S8,'Value',1);
0159 set(handles.checkbox_S9,'Value',1);
0160 set(handles.checkbox_S10,'Value',1);
0161
0162 set(handles.checkbox_HCOR,'Value',1);
0163 set(handles.checkbox_VCOR,'Value',1);
0164
0165 set(handles.checkbox_none,'Value',0);
0166 end
0167
0168
0169
0170 function checkbox_BEND_Callback(hObject, eventdata, handles)
0171
0172
0173
0174
0175
0176
0177 set(handles.checkbox_all,'Value',0);
0178 set(handles.checkbox_none,'Value',0);
0179 val = get(handles.checkbox_BEND,'Value');
0180 valQ1 = get(handles.checkbox_Q1,'Value');valQ2 = get(handles.checkbox_Q2,'Value');
0181 valQ3 = get(handles.checkbox_Q3,'Value');valQ4 = get(handles.checkbox_Q4,'Value');
0182 valQ5 = get(handles.checkbox_Q5,'Value');valQ6 = get(handles.checkbox_Q6,'Value');
0183 valQ7 = get(handles.checkbox_Q7,'Value');valQ8 = get(handles.checkbox_Q8,'Value');
0184 valQ9 = get(handles.checkbox_Q9,'Value');valQ10 = get(handles.checkbox_Q10,'Value');
0185 valQtous = get(handles.checkbox_AllQuad,'Value');
0186 valeurs = [valQ1 valQ2 valQ3 valQ4 valQ5 valQ6 valQ7 valQ8 valQ9 valQ10 valQtous];
0187 test = ones(11,1)'*0;
0188
0189 if val
0190
0191 if ~isequal(valeurs,test)
0192 errordlg('conflit entre Quad et Dipole !','Erreur');
0193 set(handles.checkbox_BEND,'Value',0);
0194 return
0195 end
0196
0197
0198 for k = 1:length(findmemberof('QUAD'))
0199 Name = strcat('Q',num2str(k));
0200 set(handles.(['checkbox_',Name]),'Enable','off')
0201 end
0202 set(handles.checkbox_AllQuad,'Enable','off');
0203
0204 set(handles.checkbox_AllSextu,'Enable','off')
0205 for k = 1:length(findmemberof('SEXT'))
0206 Name = strcat('S',num2str(k));
0207 set(handles.(['checkbox_',Name]),'Enable','off')
0208 end
0209
0210
0211 else
0212 val2 = get(handles.checkbox_AllQuad,'Value');
0213 if val2==0
0214
0215
0216 for k = 1:length(findmemberof('QUAD'))
0217 Name = strcat('Q',num2str(k));
0218 set(handles.(['checkbox_',Name]),'Enable','on')
0219 end
0220 set(handles.checkbox_AllQuad,'Enable','on');
0221
0222 set(handles.checkbox_AllSextu,'Enable','on')
0223 for k = 1:length(findmemberof('SEXT'))
0224 Name = strcat('S',num2str(k));
0225 set(handles.(['checkbox_',Name]),'Enable','on')
0226 end
0227
0228 end
0229 end
0230
0231
0232
0233
0234 function checkbox_Q1_Callback(hObject, eventdata, handles)
0235
0236
0237
0238
0239
0240
0241 set(handles.checkbox_all,'Value',0);
0242 set(handles.checkbox_none,'Value',0);
0243
0244
0245 function checkbox_HCOR_Callback(hObject, eventdata, handles)
0246
0247
0248
0249
0250
0251
0252 set(handles.checkbox_all,'Value',0);
0253 set(handles.checkbox_none,'Value',0);
0254
0255
0256 function checkbox_VCOR_Callback(hObject, eventdata, handles)
0257
0258
0259
0260
0261
0262
0263 set(handles.checkbox_all,'Value',0);
0264 set(handles.checkbox_none,'Value',0);
0265
0266
0267 function pushbutton_apply_Callback(hObject, eventdata, handles)
0268
0269
0270
0271
0272 contents = get(handles.popupmenu_command,'String');
0273 command = contents{get(handles.popupmenu_command,'Value')};
0274
0275 switch command
0276 case {'Load cycling curve','Start','Stop','Init','Pause','Resume'}
0277 cyclemagnet_local(command,handles);
0278 otherwise
0279 error('Unknown ommand name: %s ', command);
0280 end
0281
0282 function cyclemagnet_local(command,handles)
0283
0284
0285
0286
0287
0288 Family={'QC13','BEND',...
0289 'Q1','Q2','Q3','Q4','Q5',...
0290 'Q6','Q7','Q8','Q9','Q10',...
0291 'S1','S2','S3','S4','S5',...
0292 'S6','S7','S8','S9','S10',...
0293 'HCOR','VCOR'};
0294
0295 Families = {};
0296 for k =1:length(Family)
0297 if get(handles.(['checkbox_',Family{k}]),'Value')
0298 Families = {Families{:}, Family{k}};
0299 end
0300 end
0301
0302 switch command
0303 case {'Start'}
0304
0305 contents = get(handles.popupmenu_file,'String');
0306 file = contents{get(handles.popupmenu_file,'Value')};
0307
0308
0309 contents = get(handles.popupmenu_type,'String');
0310 type = contents{get(handles.popupmenu_type,'Value')};
0311
0312 magnetcycle(type,file,Families,'NoDisplay','NoConfig');
0313
0314 case {'Load cycling curve'}
0315
0316 contents = get(handles.popupmenu_file,'String');
0317 file = contents{get(handles.popupmenu_file,'Value')};
0318
0319
0320 contents = get(handles.popupmenu_type,'String');
0321 type = contents{get(handles.popupmenu_type,'Value')};
0322
0323 magnetcycle(type,file,Families,'NoDisplay','NoConfig','NoApply');
0324
0325
0326 case {'Stop','Init','Pause','Resume'}
0327 for k =1:length(Families)
0328 CycleFamily = ['Cycle' Families{k}];
0329 cyclingcommand(CycleFamily,command);
0330 end
0331 end
0332
0333
0334 function popupmenu_command_Callback(hObject, eventdata, handles)
0335
0336
0337
0338
0339
0340
0341
0342
0343 function popupmenu_command_CreateFcn(hObject, eventdata, handles)
0344
0345
0346
0347
0348
0349
0350 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0351 set(hObject,'BackgroundColor','white');
0352 end
0353
0354
0355
0356 function popupmenu_type_Callback(hObject, eventdata, handles)
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366 function popupmenu_type_CreateFcn(hObject, eventdata, handles)
0367
0368
0369
0370
0371
0372
0373 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0374 set(hObject,'BackgroundColor','white');
0375 end
0376
0377
0378
0379 function popupmenu_file_Callback(hObject, eventdata, handles)
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389 function popupmenu_file_CreateFcn(hObject, eventdata, handles)
0390
0391
0392
0393
0394
0395
0396 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0397 set(hObject,'BackgroundColor','white');
0398 end
0399
0400
0401
0402
0403
0404 function checkbox_Q2_Callback(hObject, eventdata, handles)
0405
0406
0407
0408
0409
0410
0411 set(handles.checkbox_all,'Value',0);
0412 set(handles.checkbox_none,'Value',0);
0413
0414
0415 function checkbox_Q3_Callback(hObject, eventdata, handles)
0416
0417
0418
0419
0420
0421
0422 set(handles.checkbox_all,'Value',0);
0423 set(handles.checkbox_none,'Value',0);
0424
0425
0426 function checkbox_Q4_Callback(hObject, eventdata, handles)
0427
0428
0429
0430
0431
0432
0433 set(handles.checkbox_all,'Value',0);
0434 set(handles.checkbox_none,'Value',0);
0435
0436
0437 function checkbox_Q5_Callback(hObject, eventdata, handles)
0438
0439
0440
0441
0442
0443
0444 set(handles.checkbox_all,'Value',0);
0445 set(handles.checkbox_none,'Value',0);
0446
0447
0448 function checkbox_Q6_Callback(hObject, eventdata, handles)
0449
0450
0451
0452
0453
0454
0455 set(handles.checkbox_all,'Value',0);
0456 set(handles.checkbox_none,'Value',0);
0457
0458
0459 function checkbox_Q7_Callback(hObject, eventdata, handles)
0460
0461
0462
0463
0464
0465
0466 set(handles.checkbox_all,'Value',0);
0467 set(handles.checkbox_none,'Value',0);
0468
0469
0470 function checkbox_Q8_Callback(hObject, eventdata, handles)
0471
0472
0473
0474
0475
0476
0477 set(handles.checkbox_all,'Value',0);
0478 set(handles.checkbox_none,'Value',0);
0479
0480
0481 function checkbox_Q9_Callback(hObject, eventdata, handles)
0482
0483
0484
0485
0486
0487
0488 set(handles.checkbox_all,'Value',0);
0489 set(handles.checkbox_none,'Value',0);
0490
0491
0492 function checkbox_Q10_Callback(hObject, eventdata, handles)
0493
0494
0495
0496
0497
0498
0499 set(handles.checkbox_all,'Value',0);
0500 set(handles.checkbox_none,'Value',0);
0501
0502
0503 function checkbox_S1_Callback(hObject, eventdata, handles)
0504
0505
0506
0507
0508
0509
0510 set(handles.checkbox_all,'Value',0);
0511 set(handles.checkbox_none,'Value',0);
0512
0513
0514 function checkbox_S2_Callback(hObject, eventdata, handles)
0515
0516
0517
0518
0519
0520
0521 set(handles.checkbox_all,'Value',0);
0522 set(handles.checkbox_none,'Value',0);
0523
0524
0525 function checkbox_S3_Callback(hObject, eventdata, handles)
0526
0527
0528
0529
0530
0531
0532
0533
0534 function checkbox_S4_Callback(hObject, eventdata, handles)
0535
0536
0537
0538
0539
0540
0541 set(handles.checkbox_all,'Value',0);
0542 set(handles.checkbox_none,'Value',0);
0543
0544
0545 function checkbox_S5_Callback(hObject, eventdata, handles)
0546
0547
0548
0549
0550
0551
0552 set(handles.checkbox_all,'Value',0);
0553 set(handles.checkbox_none,'Value',0);
0554
0555
0556 function checkbox_S6_Callback(hObject, eventdata, handles)
0557
0558
0559
0560
0561
0562
0563 set(handles.checkbox_all,'Value',0);
0564 set(handles.checkbox_none,'Value',0);
0565
0566
0567 function checkbox_S7_Callback(hObject, eventdata, handles)
0568
0569
0570
0571
0572
0573
0574 set(handles.checkbox_all,'Value',0);
0575 set(handles.checkbox_none,'Value',0);
0576
0577
0578 function checkbox_S8_Callback(hObject, eventdata, handles)
0579
0580
0581
0582
0583
0584
0585 set(handles.checkbox_all,'Value',0);
0586 set(handles.checkbox_none,'Value',0);
0587
0588
0589 function checkbox_S9_Callback(hObject, eventdata, handles)
0590
0591
0592
0593
0594
0595
0596 set(handles.checkbox_all,'Value',0);
0597 set(handles.checkbox_none,'Value',0);
0598
0599
0600 function checkbox_S10_Callback(hObject, eventdata, handles)
0601
0602
0603
0604
0605
0606
0607 set(handles.checkbox_all,'Value',0);
0608 set(handles.checkbox_none,'Value',0);
0609
0610
0611 function checkbox_AllQuad_Callback(hObject, eventdata, handles)
0612
0613
0614
0615
0616
0617
0618 set(handles.checkbox_all,'Value',0);
0619 set(handles.checkbox_none,'Value',0);
0620 val = get(handles.checkbox_AllQuad,'Value');
0621
0622 if val
0623 set(handles.checkbox_noneQuad,'Value',0);
0624 for k = 1:length(findmemberof('QUAD'))
0625 Name = strcat('Q',num2str(k));
0626 set(handles.(['checkbox_',Name]),'Enable','off')
0627 set(handles.(['checkbox_',Name]),'Value',1)
0628 end
0629
0630
0631 for k = 1:length(findmemberof('SEXT'))
0632 Name = strcat('S',num2str(k));
0633 set(handles.(['checkbox_',Name]),'Enable','off')
0634 end
0635 set(handles.checkbox_AllSextu,'Enable','off');
0636 set(handles.checkbox_BEND,'Enable','off');
0637 end
0638
0639
0640 function checkbox_AllSextu_Callback(hObject, eventdata, handles)
0641
0642
0643
0644
0645
0646
0647 set(handles.checkbox_all,'Value',0);
0648 set(handles.checkbox_none,'Value',0);
0649 val = get(handles.checkbox_AllSextu,'Value');
0650
0651 if val
0652 set(handles.checkbox_NoneSextu,'Value',0);
0653
0654 for k = 1:length(findmemberof('SEXT'))
0655 Name = strcat('S',num2str(k));
0656 set(handles.(['checkbox_',Name]),'Enable','off');
0657 set(handles.(['checkbox_',Name]),'Value',1)
0658 end
0659
0660 for k = 1:length(findmemberof('QUAD'))
0661 Name = strcat('Q',num2str(k));
0662 set(handles.(['checkbox_',Name]),'Enable','off')
0663 end
0664 set(handles.checkbox_AllQuad,'Enable','off');
0665 set(handles.checkbox_BEND,'Enable','off');
0666
0667 else
0668
0669 for k = 1:length(findmemberof('SEXT'))
0670 Name = strcat('S',num2str(k));
0671 set(handles.(['checkbox_',Name]),'Enable','on')
0672 end
0673
0674 for k = 1:length(findmemberof('QUAD'))
0675 Name = strcat('Q',num2str(k));
0676 set(handles.(['checkbox_',Name]),'Enable','on')
0677 end
0678 set(handles.checkbox_AllQuad,'Enable','on');
0679 set(handles.checkbox_BEND,'Enable','on');
0680 end
0681
0682
0683
0684
0685 function courbe_pushbutton_Callback(hObject, eventdata, handles)
0686
0687
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710 name=['axes' num2str(1)];
0711 axes(handles.(name));
0712
0713 Family={'BEND',...
0714 'Q1','Q2','Q3','Q4','Q5',...
0715 'Q6','Q7','Q8','Q9','Q10',...
0716 'S1','S2','S3','S4','S5',...
0717 'S6','S7','S8','S9','S10',...
0718 'HCOR','VCOR'};
0719
0720 for k =1:length(Family)
0721 if get(handles.(['checkbox_',Family{k}]),'Value')
0722 Name = strcat('Cycle',Family{k});
0723
0724
0725 vect = getfamilydata(Name,'DeviceName');
0726 if strcmp(handles.mode,'1element')
0727 jend = 1;
0728 elseif strcmp(handles.mode,'lafamille')
0729 jend = length(vect);
0730 end
0731
0732
0733
0734 for j = 1:jend
0735 curve = getcyclecurve(vect{j});
0736
0737 if iscell(curve)
0738 for k=1:length(curve),
0739 n = size(curve{k}.Data,1);
0740
0741 cums = cumsum(curve{k}.Data(:,2))';
0742 x = [cums; cums];
0743 x = reshape(x,1,2*n);
0744 x = [0 x(1:end-1)];
0745
0746
0747 y = [curve{k}.Data(:,1),curve{k}.Data(:,1)]';
0748 y = reshape(y,1,2*n);
0749
0750
0751 plot(x,y,'b.-');
0752 xlabel('Temps (s)');
0753 ylabel('Courant [A]');
0754 ylim([min(y) max(y)*1.05]);
0755 title(['Cycling curve for ' curve{k}.DeviceName]);
0756 grid on
0757 end
0758 else
0759 n = size(curve,1);
0760
0761 cums = cumsum(curve(:,2))';
0762 x = [cums; cums];
0763 x = reshape(x,1,2*n);
0764 x = [0 x(1:end-1)];
0765
0766
0767 y = [curve(:,1),curve(:,1)]';
0768 y = reshape(y,1,2*n);
0769
0770
0771 plot(x,y,'b.-');
0772 xlabel('Temps (s)');
0773 ylabel('Courant [A]');
0774 ylim([min(y)*1.1 max(y)*1.1]);
0775 title('courbe de cyclage');
0776
0777 grid on
0778
0779 end
0780
0781
0782 hold on
0783 end
0784 hold on
0785 end
0786 end
0787
0788
0789
0790
0791 function checkbox_QC13_Callback(hObject, eventdata, handles)
0792
0793
0794
0795
0796
0797
0798 set(handles.checkbox_all,'Value',0);
0799 set(handles.checkbox_none,'Value',0);
0800 val = get(handles.checkbox_QC13,'Value');
0801
0802
0803 function edit1_Callback(hObject, eventdata, handles)
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813 function edit1_CreateFcn(hObject, eventdata, handles)
0814
0815
0816
0817
0818
0819
0820 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0821 set(hObject,'BackgroundColor','white');
0822 end
0823
0824
0825
0826 function pushbutton_singledevice_Callback(hObject, eventdata, handles)
0827
0828
0829
0830
0831
0832 function uibuttongroup_SelectionChangeFcn(hObject,eventdata,handles)
0833
0834
0835
0836
0837 switch get(get(hObject,'SelectedObject'),'Tag')
0838 case 'radiobutton1'
0839
0840
0841 handles.mode = '1element';
0842
0843 case 'radiobutton2'
0844
0845
0846 handles.mode = 'lafamille';
0847 end
0848
0849 guidata(hObject, handles);
0850
0851
0852
0853 function checkbox_noneQuad_Callback(hObject, eventdata, handles)
0854
0855
0856
0857
0858
0859
0860 set(handles.checkbox_all,'Value',0);
0861 set(handles.checkbox_none,'Value',0);
0862 val = get(handles.checkbox_noneQuad,'Value');
0863
0864 if val
0865 set(handles.checkbox_AllQuad,'Value',0);
0866 for k = 1:length(findmemberof('QUAD'))
0867 Name = strcat('Q',num2str(k));
0868 set(handles.(['checkbox_',Name]),'Enable','on')
0869 set(handles.(['checkbox_',Name]),'Value',0)
0870 end
0871
0872
0873 for k = 1:length(findmemberof('SEXT'))
0874 Name = strcat('S',num2str(k));
0875 set(handles.(['checkbox_',Name]),'Enable','on')
0876 end
0877 set(handles.checkbox_AllSextu,'Enable','on');
0878 set(handles.checkbox_BEND,'Enable','on');
0879 end
0880
0881
0882
0883 function checkbox_NoneSextu_Callback(hObject, eventdata, handles)
0884
0885
0886
0887
0888
0889
0890 set(handles.checkbox_all,'Value',0);
0891 set(handles.checkbox_none,'Value',0);
0892 val = get(handles.checkbox_NoneSextu,'Value');
0893
0894 if val
0895 set(handles.checkbox_AllSextu,'Value',0);
0896 for k = 1:length(findmemberof('SEXT'))
0897 Name = strcat('S',num2str(k));
0898 set(handles.(['checkbox_',Name]),'Enable','on')
0899 set(handles.(['checkbox_',Name]),'Value',0)
0900 end
0901
0902
0903 for k = 1:length(findmemberof('QUAD'))
0904 Name = strcat('Q',num2str(k));
0905 set(handles.(['checkbox_',Name]),'Enable','on')
0906 end
0907 set(handles.checkbox_AllQuad,'Enable','on');
0908 set(handles.checkbox_BEND,'Enable','on');
0909 end