0001 function [MachineName, SubMachineName, LinkFlag, MMLROOT] = setpathmml(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 LinkFlag = '';
0021 for i = length(varargin):-1:1
0022 if ~ischar(varargin{i})
0023
0024 elseif strcmpi(varargin{i},'LabCA')
0025 LinkFlag = 'LabCA';
0026 varargin(i) = [];
0027 elseif strcmpi(varargin{i},'MCA')
0028 LinkFlag = 'MCA';
0029 varargin(i) = [];
0030 elseif strcmpi(varargin{i},'SCA')
0031 LinkFlag = 'SCA';
0032 varargin(i) = [];
0033 elseif strcmpi(varargin{i},'OPC')
0034 LinkFlag = 'OPC';
0035 varargin(i) = [];
0036 elseif strcmpi(varargin{i},'SLC')
0037 LinkFlag = 'SLC';
0038 varargin(i) = [];
0039 elseif strcmpi(varargin{i},'Tango')
0040 LinkFlag = 'Tango';
0041 varargin(i) = [];
0042 elseif strcmpi(varargin{i},'UCODE')
0043 LinkFlag = 'UCODE';
0044 varargin(i) = [];
0045 end
0046 end
0047
0048
0049
0050 if length(varargin) >= 1
0051 MachineName = varargin{1};
0052 else
0053 MachineName = '';
0054 end
0055
0056 if isempty(MachineName)
0057 [MachineListCell, SubMachineListCell] = getmachinelist;
0058 [i, iok] = listdlg('Name','SETPATHMML', 'ListString',MachineListCell, 'Name','MML Init', 'PromptString',{'Select a facility:'}, 'SelectionMode','Single');
0059
0060 drawnow;
0061 if iok
0062 MachineName = MachineListCell{i};
0063 else
0064 fprintf(' No path change.\n');
0065 MachineName=''; SubMachineName=''; LinkFlag=''; MMLROOT='';
0066 return;
0067 end
0068 else
0069 SubMachineListCell = {};
0070 end
0071
0072
0073
0074 if length(varargin) >= 2
0075 SubMachineName = varargin{2};
0076 else
0077 SubMachineName = '';
0078 end
0079 if isempty(SubMachineName)
0080 if isempty(SubMachineListCell)
0081 [MachineListCell, SubMachineListCell] = getmachinelist;
0082 end
0083 i = strmatch(MachineName, MachineListCell, 'exact');
0084 SubMachineListCell = SubMachineListCell{i}(:);
0085
0086 if length(SubMachineListCell) == 1
0087 SubMachineName = SubMachineListCell{1};
0088 else
0089 [i, iok] = listdlg('Name','SETPATHMML', 'ListString',SubMachineListCell, 'Name','MML Init', 'PromptString',{'Select an accelerator:'}, 'SelectionMode','Single');
0090 drawnow;
0091 if iok
0092 SubMachineName = SubMachineListCell{i};
0093 else
0094 fprintf(' No path change.\n');
0095 MachineName=''; SubMachineName=''; LinkFlag=''; MMLROOT='';
0096 return;
0097 end
0098 end
0099 end
0100
0101
0102
0103 if length(varargin) >= 3
0104 MachineType = varargin{3};
0105 else
0106 MachineType = '';
0107 end
0108 if isempty(MachineType)
0109 switch upper(SubMachineName)
0110 case {'LTB', 'LB', 'BTS', 'BS', 'LT1', 'LT2', 'INJECTOR', 'LINAC', 'GUN'}
0111 MachineType = 'Transport';
0112 case {'BOOSTER', 'BOOSTER RING', 'BR'}
0113 MachineType = 'Booster';
0114 case {'SR', 'STORAGERING', 'STORAGE RING', 'HER', 'LER', '800MEV'}
0115 MachineType = 'StorageRing';
0116 otherwise
0117 MachineType = 'StorageRing';
0118 end
0119 end
0120
0121
0122
0123
0124
0125
0126 MatlabVersion = ver('Matlab');
0127 MatlabVersion = str2num(MatlabVersion.Version);
0128
0129
0130 if isempty(LinkFlag)
0131 switch upper(MachineName)
0132 case 'ALS'
0133 if strncmp(computer,'PC',2)
0134 LinkFlag = 'LABCA';
0135
0136 elseif isunix
0137 if strncmp(computer,'GLNX',4) || MatlabVersion >= 7.4
0138 LinkFlag = 'LABCA';
0139
0140 else
0141
0142 LinkFlag = 'SCA';
0143 end
0144 else
0145 LinkFlag = 'LABCA';
0146 end
0147 case {'ASP'}
0148 LinkFlag = 'LABCA';
0149 case {'NSRRC','PLS','SPEAR','SPEAR3','SSRF'}
0150 LinkFlag = 'MCA';
0151 case 'BFACTORY'
0152 LinkFlag = 'SLC';
0153 case 'LCLS'
0154 LinkFlag = 'LABCA';
0155 case {'NSRC','SPS'}
0156 LinkFlag = 'OPC';
0157 case {'VUV','XRAY'}
0158 LinkFlag = 'UCODE';
0159 case {'ALBA','SOLEIL'}
0160 LinkFlag = 'Tango';
0161 otherwise
0162
0163 if strncmp(computer,'PC',2)
0164 LinkFlag = 'LABCA';
0165
0166 elseif isunix
0167 LinkFlag = 'LABCA';
0168 else
0169 LinkFlag = 'LABCA';
0170
0171 end
0172 end
0173 end
0174
0175
0176
0177 if length(varargin) >= 4
0178 MMLROOT = varargin{4};
0179 else
0180 MMLROOT = '';
0181 end
0182 if isempty(MMLROOT)
0183 MMLROOT = getmmlroot;
0184 end
0185
0186
0187
0188 if ~isdeployed_local
0189
0190
0191 if any(strcmpi(MachineName,{'Spear3','cls','diamond','asp','alba','camd'}))
0192
0193 addpath(fullfile(MMLROOT, 'applications', 'orbit', 'lib'), '-begin');
0194 addpath(fullfile(MMLROOT, 'applications', 'orbit', lower(MachineName)), '-begin');
0195 end
0196
0197
0198 Directory = fullfile(MMLROOT, 'applications', 'naff');
0199 if exist(Directory, 'dir')
0200 addpath(fullfile(MMLROOT, 'applications', 'naff'), '-begin');
0201 end
0202
0203
0204 addpath(fullfile(MMLROOT, 'applications', 'm2html'), '-begin');
0205
0206
0207
0208 addpath(fullfile(MMLROOT, 'applications', 'database', 'mym'), '-begin');
0209
0210
0211 addpath(fullfile(MMLROOT, 'applications', 'xml', 'geodise'), '-begin');
0212
0213
0214
0215 setpathat(fullfile(MMLROOT,'at'));
0216
0217
0218 addpath(fullfile(MMLROOT, 'mml', 'at'),'-begin');
0219
0220
0221 addpath(fullfile(MMLROOT, 'applications', 'loco'),'-begin');
0222
0223
0224 switch upper(LinkFlag)
0225 case 'MCA'
0226
0227
0228
0229
0230
0231
0232 fprintf(' Appending MATLAB path control using MCA (Australian)\n');
0233 addpath(fullfile(MMLROOT, 'links', 'mca_asp'),'-begin');
0234 addpath(fullfile(MMLROOT, 'mml', 'links', 'mca_asp'),'-begin');
0235
0236 case 'LABCA'
0237 fprintf(' Appending MATLAB path control using LabCA \n');
0238 switch computer
0239 case 'PCWIN'
0240 addpath(fullfile(MMLROOT,'links','labca', 'bin','win32-x86','labca'),'-begin');
0241
0242 case 'SOL2'
0243 addpath(fullfile(MMLROOT,'links','labca', 'bin','solaris-sparc','labca'),'-begin');
0244 case 'SOL64'
0245 addpath(fullfile(MMLROOT,'links','labca', 'bin','solaris-sparc64','labca'),'-begin');
0246 case 'GLNX86'
0247 addpath(fullfile(MMLROOT,'links','labca', 'bin','linux-x86','labca'),'-begin');
0248 case 'GLNXA64'
0249 addpath(fullfile(MMLROOT,'links','labca', 'bin','linux-x86_64','labca'),'-begin');
0250 otherwise
0251 fprintf('Computer not recognized for LabCA path.\n');
0252 end
0253
0254 addpath(fullfile(MMLROOT,'mml', 'links', 'labca'),'-begin');
0255
0256 case 'SCA'
0257 fprintf(' Appending MATLAB path control using Simple-CA Version 3\n');
0258 switch computer
0259 case 'PCWIN'
0260 fprintf('\n WARNING: SCAIII is not working with PC''s yet\n\n');
0261 addpath(fullfile(MMLROOT,'links','sca', 'bin','win32-x86','sca'),'-begin');
0262 case 'SOL2'
0263 addpath(fullfile(MMLROOT,'links','sca', 'bin','solaris-sparc','sca'),'-begin');
0264 case 'SOL64'
0265 addpath(fullfile(MMLROOT,'links','sca', 'bin','solaris-sparc64','sca'),'-begin');
0266 case 'GLNX86'
0267 addpath(fullfile(MMLROOT,'links','sca', 'bin','linux-x86','sca'),'-begin');
0268 case 'GLNXA64'
0269 addpath(fullfile(MMLROOT,'links','sca', 'bin','linux-x86_64','sca'),'-begin');
0270 otherwise
0271 fprintf('Computer not recognized for SCA path.\n');
0272 end
0273 addpath(fullfile(MMLROOT, 'mml', 'links', 'sca'),'-begin');
0274
0275 case 'TANGO'
0276
0277 fprintf(' Appending MATLAB path control using Tango\n');
0278 addpath(fullfile(MMLROOT,'links','tango'),'-begin');
0279 addpath(fullfile(MMLROOT, 'mml', 'links', 'tango'),'-begin');
0280
0281 case 'UCODE'
0282 fprintf(' Appending MATLAB path control using UCODE \n');
0283
0284 addpath(fullfile(MMLROOT,'mml','links','ucode'),'-begin');
0285
0286 case 'SLC'
0287 fprintf(' Appending MATLAB path for SLC control \n');
0288 addpath(fullfile(MMLROOT,'links','slc'),'-begin');
0289 addpath(fullfile(MMLROOT,'mml', 'links', 'slc'),'-begin');
0290
0291 case 'OPC'
0292 fprintf(' Appending MATLAB path for OPC control \n');
0293 addpath(fullfile(MMLROOT,'links','opc'),'-begin');
0294 addpath(fullfile(MMLROOT,'mml', 'links', 'opc'),'-begin');
0295
0296 otherwise
0297 fprintf(' Unknown type for the Online connection method. Only simulator mode will work.\n');
0298 end
0299
0300
0301
0302 addpath(fullfile(MMLROOT, 'applications', 'common'),'-begin');
0303
0304
0305 addpath(fullfile(MMLROOT, 'mml'),'-begin');
0306
0307
0308 if ~isempty(MachineName) && ~isempty(SubMachineName)
0309
0310 Directory = fullfile(MMLROOT, 'machine', MachineName, 'common');
0311 if exist(Directory, 'dir')
0312 addpath(Directory,'-begin');
0313 end
0314 Directory = fullfile(MMLROOT, 'machine', MachineName, 'Common');
0315 if exist(Directory, 'dir')
0316 addpath(Directory,'-begin');
0317 end
0318
0319
0320 addpath(fullfile(MMLROOT, 'machine', MachineName, SubMachineName),'-begin');
0321 end
0322 end
0323
0324
0325
0326 setad([]);
0327 AD.Machine = MachineName;
0328 AD.SubMachine = SubMachineName;
0329 AD.MachineType = MachineType;
0330 AD.OperationalMode = '';
0331 setad(AD);
0332
0333
0334
0335 aoinit(SubMachineName);
0336
0337
0338 function RunTimeFlag = isdeployed_local
0339
0340 V = version;
0341 if str2num(V(1,1)) < 7
0342 RunTimeFlag = 0;
0343 else
0344 RunTimeFlag = isdeployed;
0345 end