diff --git a/machine/ASP/StorageRing/amp2k.m b/machine/ASP/StorageRing/amp2k.m
index 39ab0a8c..5e305e7c 100644
--- a/machine/ASP/StorageRing/amp2k.m
+++ b/machine/ASP/StorageRing/amp2k.m
@@ -1,90 +1,90 @@
-function k = amp2k(Family, Field, Amps, DeviceList, Energy, C, K2AmpScaleFactor)
-%AMP2K - Converts amperes to simulator values
-% k = amp2k(Family, Field, Amps, DeviceList, Energy, Coefficients, K2AmpScaleFactor)
-% or
-% k = amp2k(Family, Field, Amps, DeviceList, Energy, MagnetCoreType, K2AmpScaleFactor)
-%
-% Calculates the "K-value" from the coefficients (or MagnetCoreType),
-% current [amps], energy, and linear scale factor
-%
-% For dipole: k = B / Brho
-% For quadrupole: k = B'/ Brho
-% For sextupole: k = B"/ Brho / 2 (to be compatible with AT)
-%
-% A curve vector or a MagnetCoreType string (current curves found from
-% magnetcoefficents.m) can be used. Amps and Coefficients must have equal
-% number of rows or one must only have one row.
-%
-% Energy can be anything getenergy accepts, like 'Model' or 'Online'.
-%
-% The K2AmpScaleFactor linearly scales the input current: Amps = Amps ./ K2AmpScaleFactor
-% This can be used to account for linear calibration errors of the power supply and magnet
-%
-% NOTES
-% 1. If energy is not an input or empty, then the energy is obtained from getenergy.
-% 2. Family and Field inputs are not used but there automatically part of the hw2physics call.
-%
-% Original structure set up using polynomials by M. Yoon 4/8/03
-% Modified for ASP by E. Tan 31/05/2006
-
-if nargin < 4
- error('At least 4 inputs required');
-end
-
-if nargin < 6
- C = [];
-end
-if isempty(C)
- %[C, Leff, MagnetName] = magnetcoefficients(Family);
- temp = getfamilydata(Family, Field, 'HW2PhysicsParams', DeviceList);
- C = temp{1};
-end
-
-if nargin < 5
- Energy = [];
-end
-if isempty(Energy)
- Energy = getenergy;
-elseif ischar(Energy)
- Energy = getenergy(Energy);
-end
-
-
-% If Amps is a row vector make it a column vector
-Amps = Amps(:);
-
-brho = getbrho(Energy);
-
-% Scale solution if required
-if nargin >= 7
- Amps = Amps ./ K2AmpScaleFactor;
-end
-
-
-
-if isstr(C)
- [C, Leff, MagnetName] = magnetcoefficients(C);
-end
-
-if any(size(C,1) ~= length(Amps))
- if length(Amps) == 1
- Amps = ones(size(C,1),1) * Amps;
- elseif size(C,1) == 1
- %C = ones(size(Amps,1),1) * C;
- else
- error('Amps and Coefficients must have equal number of rows or one must only have one row');
- end
-end
-
-% B, B', or B" scaled by energy. Applies to all other magnets other than
-% the dipoles. The curve C is arranged such that the first half of the row
-% vector contains the current data and the second half contains the B, B'
-% and/or B" as a function of the current data.
-splitind = size(C,2)/2;
-for i = 1:length(Amps)
- if size(C,1) == 1
- k(i,1) = interp1(C(1,1:splitind),C(1,splitind+1:end),Amps(i),'linear','extrap') / brho;
- else
- k(i,1) = interp1(C(i,1:splitind),C(i,splitind+1:end),Amps(i),'linear','extrap') / brho;
- end
-end
+function k = amp2k(Family, Field, Amps, DeviceList, Energy, C, K2AmpScaleFactor)
+%AMP2K - Converts amperes to simulator values
+% k = amp2k(Family, Field, Amps, DeviceList, Energy, Coefficients, K2AmpScaleFactor)
+% or
+% k = amp2k(Family, Field, Amps, DeviceList, Energy, MagnetCoreType, K2AmpScaleFactor)
+%
+% Calculates the "K-value" from the coefficients (or MagnetCoreType),
+% current [amps], energy, and linear scale factor
+%
+% For dipole: k = B / Brho
+% For quadrupole: k = B'/ Brho
+% For sextupole: k = B"/ Brho / 2 (to be compatible with AT)
+%
+% A curve vector or a MagnetCoreType string (current curves found from
+% magnetcoefficents.m) can be used. Amps and Coefficients must have equal
+% number of rows or one must only have one row.
+%
+% Energy can be anything getenergy accepts, like 'Model' or 'Online'.
+%
+% The K2AmpScaleFactor linearly scales the input current: Amps = Amps ./ K2AmpScaleFactor
+% This can be used to account for linear calibration errors of the power supply and magnet
+%
+% NOTES
+% 1. If energy is not an input or empty, then the energy is obtained from getenergy.
+% 2. Family and Field inputs are not used but there automatically part of the hw2physics call.
+%
+% Original structure set up using polynomials by M. Yoon 4/8/03
+% Modified for ASP by E. Tan 31/05/2006
+
+if nargin < 4
+ error('At least 4 inputs required');
+end
+
+if nargin < 6
+ C = [];
+end
+if isempty(C)
+ %[C, Leff, MagnetName] = magnetcoefficients(Family);
+ temp = getfamilydata(Family, Field, 'HW2PhysicsParams', DeviceList);
+ C = temp{1};
+end
+
+if nargin < 5
+ Energy = [];
+end
+if isempty(Energy)
+ Energy = getenergy;
+elseif ischar(Energy)
+ Energy = getenergy(Energy);
+end
+
+
+% If Amps is a row vector make it a column vector
+Amps = Amps(:);
+
+brho = getbrho(Energy);
+
+% Scale solution if required
+if nargin >= 7
+ Amps = Amps ./ K2AmpScaleFactor;
+end
+
+
+
+if isstr(C)
+ [C, Leff, MagnetName] = magnetcoefficients(C);
+end
+
+if any(size(C,1) ~= length(Amps))
+ if length(Amps) == 1
+ Amps = ones(size(C,1),1) * Amps;
+ elseif size(C,1) == 1
+ %C = ones(size(Amps,1),1) * C;
+ else
+ error('Amps and Coefficients must have equal number of rows or one must only have one row');
+ end
+end
+
+% B, B', or B" scaled by energy. Applies to all other magnets other than
+% the dipoles. The curve C is arranged such that the first half of the row
+% vector contains the current data and the second half contains the B, B'
+% and/or B" as a function of the current data.
+splitind = size(C,2)/2;
+for i = 1:length(Amps)
+ if size(C,1) == 1
+ k(i,1) = interp1(C(1,1:splitind),C(1,splitind+1:end),Amps(i),'linear','extrap') / brho;
+ else
+ k(i,1) = interp1(C(i,1:splitind),C(i,splitind+1:end),Amps(i),'linear','extrap') / brho;
+ end
+end
diff --git a/machine/ASP/StorageRing/aoinit.m b/machine/ASP/StorageRing/aoinit.m
index 774d5255..08c6b224 100644
--- a/machine/ASP/StorageRing/aoinit.m
+++ b/machine/ASP/StorageRing/aoinit.m
@@ -2,7 +2,10 @@ function aoinit(SubMachineName)
%AOINIT - Initialization function for the Matlab Middle Layer (MML)
-% The path does not needs to be set in Standalone mode
+% The path does not needs to be set in Standalone mode. Standalone
+% applications must not call addpath. If it needs to call external
+% functions/libraries that may not be directly called within the files it
+% needs to be "linked" when compiling.
if ~isdeployed_local
MMLROOT = getmmlroot;
@@ -15,15 +18,15 @@ function aoinit(SubMachineName)
%end
% mca (since some people use mca directly)
- %addpath(fullfile(MMLROOT, 'links', 'mca_asp'));
+ addpath(fullfile(MMLROOT, 'online', 'mca', 'mca_asp'));
% orbit
- addpath(fullfile(MMLROOT, 'applications', 'orbit'), '-begin');
- addpath(fullfile(MMLROOT, 'applications', 'orbit', 'asp'), '-begin');
- addpath(fullfile(MMLROOT, 'applications', 'orbit', 'lib'), '-begin');
+% addpath(fullfile(MMLROOT, 'applications', 'orbit'), '-begin');
+% addpath(fullfile(MMLROOT, 'applications', 'orbit', 'asp'), '-begin');
+% addpath(fullfile(MMLROOT, 'applications', 'orbit', 'lib'), '-begin');
% SOFB
- %addpath(fullfile(MMLROOT, 'applications', 'SOFB'), '-begin');
+% addpath(fullfile(MMLROOT, 'applications', 'SOFB'), '-begin');
% Add magnet_calibration_curves
addpath(fullfile(MMLROOT, 'machine', 'ASP', 'StorageRing', 'magnet_calibration_curves'),'-begin');
@@ -32,32 +35,27 @@ function aoinit(SubMachineName)
addpath(fullfile(MMLROOT, 'machine', 'ASP', 'StorageRing', 'magnetcycling'),'-begin');
% BPM scripts
- %addpath(fullfile(MMLROOT, 'machine', 'ASP', 'StorageRing', 'bpm_scripts'),'-begin');
+ addpath(fullfile(MMLROOT, 'machine', 'ASP', 'StorageRing', 'bpm_scripts'),'-begin');
% Add measurements directory
- %dirs = {'beamsize','betas','emittance','iccd','ltb','screens','stability','streakcamera','tunes'};
- %for i=1:length(dirs)
- % addpath(fullfile([filesep 'asp'],'usr','measurements',dirs{i}),'-begin');
- %end
+% dirs = {'beamsize','betas','emittance','iccd','ltb','screens','stability','streakcamera','tunes'};
+% for i=1:length(dirs)
+% addpath(fullfile([filesep 'asp'],'usr','measurements',dirs{i}),'-begin');
+% end
% Make ASP first on the path
addpath(fullfile(MMLROOT, 'machine', 'ASP', 'StorageRing'),'-begin');
end
-
% Initialize
aspinit;
-
-
-
-
-function RunTimeFlag = isdeployed_local
-% isdeployed is not in matlab 6.5
-V = version;
-if str2num(V(1,1)) < 7
- RunTimeFlag = 0;
-else
- RunTimeFlag = isdeployed;
-end
+ function RunTimeFlag = isdeployed_local
+ % isdeployed is not in matlab 6.5
+ V = version;
+ if str2num(V(1,1)) < 7
+ RunTimeFlag = 0;
+ else
+ RunTimeFlag = isdeployed;
+ end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/aspinfo.m b/machine/ASP/StorageRing/aspinfo.m
index 093ec6cd..084f8116 100644
--- a/machine/ASP/StorageRing/aspinfo.m
+++ b/machine/ASP/StorageRing/aspinfo.m
@@ -1,38 +1,38 @@
-function alsinfo
-%ASPINFO - Prints hypertext for useful websites and commands to the command window
-%
-% Written by Greg Portmann
-
-fprintf('\n Useful Documents\n');
-
-fprintf(' Matlab Middle Layer (MML) Manual ', [getmmlroot, 'mml',filesep,'docs',filesep,'MatlabMiddleLayerManual.htm']);
-fprintf(' Matlab Middle Layer (MML) Quick Reference\n', [getmmlroot, 'mml',filesep,'docs',filesep,'MiddleLayerQuickReference.htm']);
-
-fprintf(' Matlab Middle Layer (MML) Objects ', [getmmlroot, 'mml',filesep,'docs',filesep,'MiddleLayerObjects.htm']);
-fprintf(' Matlab Middle Layer (MML) HTML Help\n', [getmmlroot, 'mml',filesep,'doc_html',filesep]);
-fprintf(' Accelerator Toolbox (AT) HTML Help\n', [getmmlroot, 'at', filesep,'doc_html',filesep]);
-
-%fprintf('\n Useful Websites\n');
-%fprintf(' ASP Homepage ');
-
-
-%fprintf(' ALS Week Performance Data');
-%fprintf(' ALS Data Access Facilities\n');
-
-fprintf('\n Useful Commands\n');
-fprintf(' setpathmml - Sets the Matlab path for an accelerator (like ALS or Spear3)\n');
-
-fprintf(' Possible ASP Middle Layers: Storage Ring, Booster, BTS, or , LTB\n' ');
-
-fprintf(' setoperationalmode - Change the operational mode (like 1.5 GeV or 1.9 GeV).\n');
-fprintf(' plotfamily - General purpose plotting and application launcher program\n');
-fprintf(' mmlviewer - View the MML setup variables as well as lattice files\n');
-fprintf(' setorbitgui - General SVD orbit correction application \n');
-fprintf(' setorbitbumpgui - Orbit bump application\n');
-fprintf(' Plot the Orbit w.r.t. the Golden Orbit Plot the Golden Orbit\n');
-fprintf(' Plot the Orbit w.r.t. the Offset Orbit Plot the Offset Orbit\n');
-fprintf(' Plot the BPM Response Matrix Plot the BPM Standard Deviations\n');
-fprintf(' Plot the Correctors Plot the Measured Dispersion Function\n');
-fprintf(' Online Mode Simulation Mode\n');
-fprintf(' Use All BPMs Bergoz Only BPMs\n');
-fprintf(' New Figure Window Close All Figure Windows\n');
+function alsinfo
+%ASPINFO - Prints hypertext for useful websites and commands to the command window
+%
+% Written by Greg Portmann
+
+fprintf('\n Useful Documents\n');
+
+fprintf(' Matlab Middle Layer (MML) Manual ', [getmmlroot, 'mml',filesep,'docs',filesep,'MatlabMiddleLayerManual.htm']);
+fprintf(' Matlab Middle Layer (MML) Quick Reference\n', [getmmlroot, 'mml',filesep,'docs',filesep,'MiddleLayerQuickReference.htm']);
+
+fprintf(' Matlab Middle Layer (MML) Objects ', [getmmlroot, 'mml',filesep,'docs',filesep,'MiddleLayerObjects.htm']);
+fprintf(' Matlab Middle Layer (MML) HTML Help\n', [getmmlroot, 'mml',filesep,'doc_html',filesep]);
+fprintf(' Accelerator Toolbox (AT) HTML Help\n', [getmmlroot, 'at', filesep,'doc_html',filesep]);
+
+%fprintf('\n Useful Websites\n');
+%fprintf(' ASP Homepage ');
+
+
+%fprintf(' ALS Week Performance Data');
+%fprintf(' ALS Data Access Facilities\n');
+
+fprintf('\n Useful Commands\n');
+fprintf(' setpathmml - Sets the Matlab path for an accelerator (like ALS or Spear3)\n');
+
+fprintf(' Possible ASP Middle Layers: Storage Ring, Booster, BTS, or , LTB\n' ');
+
+fprintf(' setoperationalmode - Change the operational mode (like 1.5 GeV or 1.9 GeV).\n');
+fprintf(' plotfamily - General purpose plotting and application launcher program\n');
+fprintf(' mmlviewer - View the MML setup variables as well as lattice files\n');
+fprintf(' setorbitgui - General SVD orbit correction application \n');
+fprintf(' setorbitbumpgui - Orbit bump application\n');
+fprintf(' Plot the Orbit w.r.t. the Golden Orbit Plot the Golden Orbit\n');
+fprintf(' Plot the Orbit w.r.t. the Offset Orbit Plot the Offset Orbit\n');
+fprintf(' Plot the BPM Response Matrix Plot the BPM Standard Deviations\n');
+fprintf(' Plot the Correctors Plot the Measured Dispersion Function\n');
+fprintf(' Online Mode Simulation Mode\n');
+fprintf(' Use All BPMs Bergoz Only BPMs\n');
+fprintf(' New Figure Window Close All Figure Windows\n');
diff --git a/machine/ASP/StorageRing/aspinit.m b/machine/ASP/StorageRing/aspinit.m
index c9a6935b..2997cb4e 100644
--- a/machine/ASP/StorageRing/aspinit.m
+++ b/machine/ASP/StorageRing/aspinit.m
@@ -1,1582 +1,1739 @@
-function aspinit(OperationalMode)
-% aspinit(OperationalMode)
-%
-% Initialize parameters for ASP control in MATLAB
-%
-%==========================
-% Accelerator Family Fields
-%==========================
-% FamilyName BPMx, HCM, etc
-% CommonNames Shortcut name for each element (optional)
-% DeviceList [Sector, Number]
-% ElementList number in list
-% Position m, magnet center
-%
-% MONITOR FIELDS
-% Mode online/manual/special/simulator
-% ChannelNames PV for monitor
-% Units Physics or HW
-% HW2PhysicsFcn function handle used to convert from hardware to physics units ==> inline will not compile, see below
-% HW2PhysicsParams parameters used for conversion function
-% Physics2HWFcn function handle used to convert from physics to hardware units
-% Physics2HWParams parameters used for conversion function
-% HWUnits units for Hardware 'ampere';
-% PhysicsUnits units for physics 'Rad';
-%
-% SETPOINT FIELDS
-% Mode online/manual/special/simulator
-% ChannelNames PV for monitor
-% Units hardware or physics
-% HW2PhysicsFcn function handle used to convert from hardware to physics units
-% HW2PhysicsParams parameters used for conversion function
-% Physics2HWFcn function handle used to convert from physics to hardware units
-% Physics2HWParams parameters used for conversion function
-% HWUnits units for Hardware 'ampere';
-% PhysicsUnits units for physics 'Rad';
-% Range minsetpoint, maxsetpoint;
-% Tolerance setpoint-monitor
-%
-%=============================================
-% Accelerator Toolbox Simulation Fields
-%=============================================
-% ATType Quad, Sext, etc
-% ATIndex index in THERING
-% ATParameterGroup parameter group
-%
-%============
-% Family List
-%============
-% BPMx BPMy - beam position monitors
-% HCM VCM - corrector magnets wound into sextupoles
-% BEND - gradient dipoles
-% QFA QDA QFB - quadrupole magnets
-% SFA SDA SDB SFB - sextupole magnets
-% SQK - skew quads wound into SDA magnets
-% KICK - injection kickers (DELTA type)
-% RF - 4 cavities (KEK type?)
-% DCCT
-% Septum (Not in model yet)
-%
-% Normal cell: d1 bpm s1 hcor d2 q1 d3 s2 d4 bpm dip bpm d4 hcor s3 d5 q2 d6 q3 d2 bpm s4
-% d2 q3 d6 q2 d5 s3 hcor d4 bpm dip bpm d4 s2 d3 q1 d2 hcor s1 bpm d1
-
-% === Change Log ===
-% Mark Boland 2004-02-12
-% Eugene Tan 2004-02-23
-% Eugene Tan 2004-12-13
-% Eugene Tan 2005-09-27 ver 4
-% Updated naming convention of the process variables, use version 4 of
-% the lattice "assr4.m" where the correctors have been merged into the
-% sextupoles. Made the necessary changes to updateatindex. Added skew
-% quadrupoles and updated generate_init.
-% Mark Boland 2006-05-27
-% Changed the BPM PVs to ...:SA_X_MONITOR and ...:SA_Y_MONITOR
-%
-% Mark Boland 2006-08-29
-% Changed range on HCM and VCM from - to + since the polarity of the
-% correctors was physically changed in the last weeks.
-%
-% === Still to do ===
-% - kicker delays
-% - BPM names and other possible PVs of interest eg. Q factor etc.
-% - clean up and configure the amp2k and k2amp conversion. Control system
-% designed to calculate the strengths and amp values using calc records,
-% therefore we should only need to change the PV name to access for
-% readback at setpoints. Only problem will be in simulation/offline mode
-% where those value are not available online. How do you keep the offline
-% conversion factors up to date with online vals?
-%
-% === Generated from ===
-% aspinit_v5skeleton.m
-
-
-
-% When using the compiler add a line like, "%#function " for
-% for special functions that hidden in strings.
-
-
-% Default operational mode
-if nargin < 1
- OperationalMode = 1;
-end
-
-
-%=============================================
-% START DEFINITION OF ACCELERATOR OBJECTS
-%=============================================
-fprintf(' Defining the Accelerator Objects. Objects being defined:\n')
-
-
-% Clear previous AcceleratorObjects
-setao([]);
-
-
-Mode = 'Online'; % This gets reset in setoperationalmode
-
-%=============================================
-%BPM data: status field designates if BPM in use
-%=============================================
-ntbpm=98;
-AO.BPMx.FamilyName = 'BPMx'; dispobject(AO,AO.BPMx.FamilyName);
-AO.BPMx.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'; 'BPMx'; 'Horizontal';};
-AO.BPMx.Monitor.Mode = Mode;
-AO.BPMx.Monitor.DataType = 'Scalar';
-AO.BPMx.Monitor.Units = 'Hardware';
-AO.BPMx.Monitor.HWUnits = 'mm';
-AO.BPMx.Monitor.PhysicsUnits = 'meter';
-
-AO.BPMy.FamilyName = 'BPMy'; dispobject(AO,AO.BPMy.FamilyName);
-AO.BPMy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'; 'BPMy'; 'Vertical';};
-AO.BPMy.Monitor.Mode = Mode;
-AO.BPMy.Monitor.DataType = 'Scalar';
-AO.BPMy.Monitor.Units = 'Hardware';
-AO.BPMy.Monitor.HWUnits = 'mm';
-AO.BPMy.Monitor.PhysicsUnits = 'meter';
-
-% x-name x-chname xstat y-name y-chname ystat DevList Elem
-bpm={
-'1BPMx1 ' 'SR01BPM01:SA_X_MONITOR' 1 '1BPMy1 ' 'SR01BPM01:SA_Y_MONITOR' 1 [1,1] 1 ; ...
-'1BPMx2 ' 'SR01BPM02:SA_X_MONITOR' 1 '1BPMy2 ' 'SR01BPM02:SA_Y_MONITOR' 1 [1,2] 2 ; ...
-'1BPMx3 ' 'SR01BPM03:SA_X_MONITOR' 1 '1BPMy3 ' 'SR01BPM03:SA_Y_MONITOR' 1 [1,3] 3 ; ...
-'1BPMx4 ' 'SR01BPM04:SA_X_MONITOR' 1 '1BPMy4 ' 'SR01BPM04:SA_Y_MONITOR' 1 [1,4] 4 ; ...
-'1BPMx5 ' 'SR01BPM05:SA_X_MONITOR' 1 '1BPMy5 ' 'SR01BPM05:SA_Y_MONITOR' 1 [1,5] 5 ; ...
-'1BPMx6 ' 'SR01BPM06:SA_X_MONITOR' 1 '1BPMy6 ' 'SR01BPM06:SA_Y_MONITOR' 1 [1,6] 6 ; ...
-'1BPMx7 ' 'SR01BPM07:SA_X_MONITOR' 1 '1BPMy7 ' 'SR01BPM07:SA_Y_MONITOR' 1 [1,7] 7 ; ...
-'2BPMx1 ' 'SR02BPM01:SA_X_MONITOR' 1 '2BPMy1 ' 'SR02BPM01:SA_Y_MONITOR' 1 [2,1] 8 ; ...
-'2BPMx2 ' 'SR02BPM02:SA_X_MONITOR' 1 '2BPMy2 ' 'SR02BPM02:SA_Y_MONITOR' 1 [2,2] 9 ; ...
-'2BPMx3 ' 'SR02BPM03:SA_X_MONITOR' 1 '2BPMy3 ' 'SR02BPM03:SA_Y_MONITOR' 1 [2,3] 10 ; ...
-'2BPMx4 ' 'SR02BPM04:SA_X_MONITOR' 1 '2BPMy4 ' 'SR02BPM04:SA_Y_MONITOR' 1 [2,4] 11 ; ...
-'2BPMx5 ' 'SR02BPM05:SA_X_MONITOR' 1 '2BPMy5 ' 'SR02BPM05:SA_Y_MONITOR' 1 [2,5] 12 ; ...
-'2BPMx6 ' 'SR02BPM06:SA_X_MONITOR' 1 '2BPMy6 ' 'SR02BPM06:SA_Y_MONITOR' 1 [2,6] 13 ; ...
-'2BPMx7 ' 'SR02BPM07:SA_X_MONITOR' 1 '2BPMy7 ' 'SR02BPM07:SA_Y_MONITOR' 1 [2,7] 14 ; ...
-'3BPMx1 ' 'SR03BPM01:SA_X_MONITOR' 0 '3BPMy1 ' 'SR03BPM01:SA_Y_MONITOR' 0 [3,1] 15 ; ...
-'3BPMx2 ' 'SR03BPM02:SA_X_MONITOR' 1 '3BPMy2 ' 'SR03BPM02:SA_Y_MONITOR' 1 [3,2] 16 ; ...
-'3BPMx3 ' 'SR03BPM03:SA_X_MONITOR' 1 '3BPMy3 ' 'SR03BPM03:SA_Y_MONITOR' 1 [3,3] 17 ; ...
-'3BPMx4 ' 'SR03BPM04:SA_X_MONITOR' 1 '3BPMy4 ' 'SR03BPM04:SA_Y_MONITOR' 1 [3,4] 18 ; ...
-'3BPMx5 ' 'SR03BPM05:SA_X_MONITOR' 1 '3BPMy5 ' 'SR03BPM05:SA_Y_MONITOR' 1 [3,5] 19 ; ...
-'3BPMx6 ' 'SR03BPM06:SA_X_MONITOR' 1 '3BPMy6 ' 'SR03BPM06:SA_Y_MONITOR' 1 [3,6] 20 ; ...
-'3BPMx7 ' 'SR03BPM07:SA_X_MONITOR' 1 '3BPMy7 ' 'SR03BPM07:SA_Y_MONITOR' 1 [3,7] 21 ; ...
-'4BPMx1 ' 'SR04BPM01:SA_X_MONITOR' 1 '4BPMy1 ' 'SR04BPM01:SA_Y_MONITOR' 1 [4,1] 22 ; ...
-'4BPMx2 ' 'SR04BPM02:SA_X_MONITOR' 1 '4BPMy2 ' 'SR04BPM02:SA_Y_MONITOR' 1 [4,2] 23 ; ...
-'4BPMx3 ' 'SR04BPM03:SA_X_MONITOR' 0 '4BPMy3 ' 'SR04BPM03:SA_Y_MONITOR' 0 [4,3] 24 ; ...
-'4BPMx4 ' 'SR04BPM04:SA_X_MONITOR' 1 '4BPMy4 ' 'SR04BPM04:SA_Y_MONITOR' 1 [4,4] 25 ; ...
-'4BPMx5 ' 'SR04BPM05:SA_X_MONITOR' 1 '4BPMy5 ' 'SR04BPM05:SA_Y_MONITOR' 1 [4,5] 26 ; ...
-'4BPMx6 ' 'SR04BPM06:SA_X_MONITOR' 1 '4BPMy6 ' 'SR04BPM06:SA_Y_MONITOR' 1 [4,6] 27 ; ...
-'4BPMx7 ' 'SR04BPM07:SA_X_MONITOR' 1 '4BPMy7 ' 'SR04BPM07:SA_Y_MONITOR' 1 [4,7] 28 ; ...
-'5BPMx1 ' 'SR05BPM01:SA_X_MONITOR' 1 '5BPMy1 ' 'SR05BPM01:SA_Y_MONITOR' 1 [5,1] 29 ; ...
-'5BPMx2 ' 'SR05BPM02:SA_X_MONITOR' 1 '5BPMy2 ' 'SR05BPM02:SA_Y_MONITOR' 1 [5,2] 30 ; ...
-'5BPMx3 ' 'SR05BPM03:SA_X_MONITOR' 1 '5BPMy3 ' 'SR05BPM03:SA_Y_MONITOR' 1 [5,3] 31 ; ...
-'5BPMx4 ' 'SR05BPM04:SA_X_MONITOR' 1 '5BPMy4 ' 'SR05BPM04:SA_Y_MONITOR' 1 [5,4] 32 ; ...
-'5BPMx5 ' 'SR05BPM05:SA_X_MONITOR' 1 '5BPMy5 ' 'SR05BPM05:SA_Y_MONITOR' 1 [5,5] 33 ; ...
-'5BPMx6 ' 'SR05BPM06:SA_X_MONITOR' 1 '5BPMy6 ' 'SR05BPM06:SA_Y_MONITOR' 1 [5,6] 34 ; ...
-'5BPMx7 ' 'SR05BPM07:SA_X_MONITOR' 1 '5BPMy7 ' 'SR05BPM07:SA_Y_MONITOR' 1 [5,7] 35 ; ...
-'6BPMx1 ' 'SR06BPM01:SA_X_MONITOR' 1 '6BPMy1 ' 'SR06BPM01:SA_Y_MONITOR' 1 [6,1] 36 ; ...
-'6BPMx2 ' 'SR06BPM02:SA_X_MONITOR' 1 '6BPMy2 ' 'SR06BPM02:SA_Y_MONITOR' 1 [6,2] 37 ; ...
-'6BPMx3 ' 'SR06BPM03:SA_X_MONITOR' 1 '6BPMy3 ' 'SR06BPM03:SA_Y_MONITOR' 1 [6,3] 38 ; ...
-'6BPMx4 ' 'SR06BPM04:SA_X_MONITOR' 1 '6BPMy4 ' 'SR06BPM04:SA_Y_MONITOR' 1 [6,4] 39 ; ...
-'6BPMx5 ' 'SR06BPM05:SA_X_MONITOR' 1 '6BPMy5 ' 'SR06BPM05:SA_Y_MONITOR' 1 [6,5] 40 ; ...
-'6BPMx6 ' 'SR06BPM06:SA_X_MONITOR' 1 '6BPMy6 ' 'SR06BPM06:SA_Y_MONITOR' 1 [6,6] 41 ; ...
-'6BPMx7 ' 'SR06BPM07:SA_X_MONITOR' 1 '6BPMy7 ' 'SR06BPM07:SA_Y_MONITOR' 1 [6,7] 42 ; ...
-'7BPMx1 ' 'SR07BPM01:SA_X_MONITOR' 1 '7BPMy1 ' 'SR07BPM01:SA_Y_MONITOR' 1 [7,1] 43 ; ...
-'7BPMx2 ' 'SR07BPM02:SA_X_MONITOR' 1 '7BPMy2 ' 'SR07BPM02:SA_Y_MONITOR' 1 [7,2] 44 ; ...
-'7BPMx3 ' 'SR07BPM03:SA_X_MONITOR' 1 '7BPMy3 ' 'SR07BPM03:SA_Y_MONITOR' 1 [7,3] 45 ; ...
-'7BPMx4 ' 'SR07BPM04:SA_X_MONITOR' 1 '7BPMy4 ' 'SR07BPM04:SA_Y_MONITOR' 1 [7,4] 46 ; ...
-'7BPMx5 ' 'SR07BPM05:SA_X_MONITOR' 1 '7BPMy5 ' 'SR07BPM05:SA_Y_MONITOR' 1 [7,5] 47 ; ...
-'7BPMx6 ' 'SR07BPM06:SA_X_MONITOR' 1 '7BPMy6 ' 'SR07BPM06:SA_Y_MONITOR' 1 [7,6] 48 ; ...
-'7BPMx7 ' 'SR07BPM07:SA_X_MONITOR' 1 '7BPMy7 ' 'SR07BPM07:SA_Y_MONITOR' 1 [7,7] 49 ; ...
-'8BPMx1 ' 'SR08BPM01:SA_X_MONITOR' 1 '8BPMy1 ' 'SR08BPM01:SA_Y_MONITOR' 1 [8,1] 50 ; ...
-'8BPMx2 ' 'SR08BPM02:SA_X_MONITOR' 1 '8BPMy2 ' 'SR08BPM02:SA_Y_MONITOR' 1 [8,2] 51 ; ...
-'8BPMx3 ' 'SR08BPM03:SA_X_MONITOR' 1 '8BPMy3 ' 'SR08BPM03:SA_Y_MONITOR' 1 [8,3] 52 ; ...
-'8BPMx4 ' 'SR08BPM04:SA_X_MONITOR' 1 '8BPMy4 ' 'SR08BPM04:SA_Y_MONITOR' 1 [8,4] 53 ; ...
-'8BPMx5 ' 'SR08BPM05:SA_X_MONITOR' 1 '8BPMy5 ' 'SR08BPM05:SA_Y_MONITOR' 1 [8,5] 54 ; ...
-'8BPMx6 ' 'SR08BPM06:SA_X_MONITOR' 1 '8BPMy6 ' 'SR08BPM06:SA_Y_MONITOR' 1 [8,6] 55 ; ...
-'8BPMx7 ' 'SR08BPM07:SA_X_MONITOR' 1 '8BPMy7 ' 'SR08BPM07:SA_Y_MONITOR' 1 [8,7] 56 ; ...
-'9BPMx1 ' 'SR09BPM01:SA_X_MONITOR' 1 '9BPMy1 ' 'SR09BPM01:SA_Y_MONITOR' 1 [9,1] 57 ; ...
-'9BPMx2 ' 'SR09BPM02:SA_X_MONITOR' 1 '9BPMy2 ' 'SR09BPM02:SA_Y_MONITOR' 1 [9,2] 58 ; ...
-'9BPMx3 ' 'SR09BPM03:SA_X_MONITOR' 1 '9BPMy3 ' 'SR09BPM03:SA_Y_MONITOR' 1 [9,3] 59 ; ...
-'9BPMx4 ' 'SR09BPM04:SA_X_MONITOR' 1 '9BPMy4 ' 'SR09BPM04:SA_Y_MONITOR' 1 [9,4] 60 ; ...
-'9BPMx5 ' 'SR09BPM05:SA_X_MONITOR' 1 '9BPMy5 ' 'SR09BPM05:SA_Y_MONITOR' 1 [9,5] 61 ; ...
-'9BPMx6 ' 'SR09BPM06:SA_X_MONITOR' 1 '9BPMy6 ' 'SR09BPM06:SA_Y_MONITOR' 1 [9,6] 62 ; ...
-'9BPMx7 ' 'SR09BPM07:SA_X_MONITOR' 1 '9BPMy7 ' 'SR09BPM07:SA_Y_MONITOR' 1 [9,7] 63 ; ...
-'10BPMx1 ' 'SR10BPM01:SA_X_MONITOR' 1 '10BPMy1 ' 'SR10BPM01:SA_Y_MONITOR' 1 [10,1] 64 ; ...
-'10BPMx2 ' 'SR10BPM02:SA_X_MONITOR' 1 '10BPMy2 ' 'SR10BPM02:SA_Y_MONITOR' 1 [10,2] 65 ; ...
-'10BPMx3 ' 'SR10BPM03:SA_X_MONITOR' 1 '10BPMy3 ' 'SR10BPM03:SA_Y_MONITOR' 1 [10,3] 66 ; ...
-'10BPMx4 ' 'SR10BPM04:SA_X_MONITOR' 1 '10BPMy4 ' 'SR10BPM04:SA_Y_MONITOR' 1 [10,4] 67 ; ...
-'10BPMx5 ' 'SR10BPM05:SA_X_MONITOR' 1 '10BPMy5 ' 'SR10BPM05:SA_Y_MONITOR' 1 [10,5] 68 ; ...
-'10BPMx6 ' 'SR10BPM06:SA_X_MONITOR' 1 '10BPMy6 ' 'SR10BPM06:SA_Y_MONITOR' 1 [10,6] 69 ; ...
-'10BPMx7 ' 'SR10BPM07:SA_X_MONITOR' 1 '10BPMy7 ' 'SR10BPM07:SA_Y_MONITOR' 1 [10,7] 70 ; ...
-'11BPMx1 ' 'SR11BPM01:SA_X_MONITOR' 1 '11BPMy1 ' 'SR11BPM01:SA_Y_MONITOR' 1 [11,1] 71 ; ...
-'11BPMx2 ' 'SR11BPM02:SA_X_MONITOR' 1 '11BPMy2 ' 'SR11BPM02:SA_Y_MONITOR' 1 [11,2] 72 ; ...
-'11BPMx3 ' 'SR11BPM03:SA_X_MONITOR' 1 '11BPMy3 ' 'SR11BPM03:SA_Y_MONITOR' 1 [11,3] 73 ; ...
-'11BPMx4 ' 'SR11BPM04:SA_X_MONITOR' 1 '11BPMy4 ' 'SR11BPM04:SA_Y_MONITOR' 1 [11,4] 74 ; ...
-'11BPMx5 ' 'SR11BPM05:SA_X_MONITOR' 1 '11BPMy5 ' 'SR11BPM05:SA_Y_MONITOR' 1 [11,5] 75 ; ...
-'11BPMx6 ' 'SR11BPM06:SA_X_MONITOR' 1 '11BPMy6 ' 'SR11BPM06:SA_Y_MONITOR' 1 [11,6] 76 ; ...
-'11BPMx7 ' 'SR11BPM07:SA_X_MONITOR' 1 '11BPMy7 ' 'SR11BPM07:SA_Y_MONITOR' 1 [11,7] 77 ; ...
-'12BPMx1 ' 'SR12BPM01:SA_X_MONITOR' 1 '12BPMy1 ' 'SR12BPM01:SA_Y_MONITOR' 1 [12,1] 78 ; ...
-'12BPMx2 ' 'SR12BPM02:SA_X_MONITOR' 1 '12BPMy2 ' 'SR12BPM02:SA_Y_MONITOR' 1 [12,2] 79 ; ...
-'12BPMx3 ' 'SR12BPM03:SA_X_MONITOR' 1 '12BPMy3 ' 'SR12BPM03:SA_Y_MONITOR' 1 [12,3] 80 ; ...
-'12BPMx4 ' 'SR12BPM04:SA_X_MONITOR' 1 '12BPMy4 ' 'SR12BPM04:SA_Y_MONITOR' 1 [12,4] 81 ; ...
-'12BPMx5 ' 'SR12BPM05:SA_X_MONITOR' 1 '12BPMy5 ' 'SR12BPM05:SA_Y_MONITOR' 1 [12,5] 82 ; ...
-'12BPMx6 ' 'SR12BPM06:SA_X_MONITOR' 1 '12BPMy6 ' 'SR12BPM06:SA_Y_MONITOR' 1 [12,6] 83 ; ...
-'12BPMx7 ' 'SR12BPM07:SA_X_MONITOR' 1 '12BPMy7 ' 'SR12BPM07:SA_Y_MONITOR' 1 [12,7] 84 ; ...
-'13BPMx1 ' 'SR13BPM01:SA_X_MONITOR' 1 '13BPMy1 ' 'SR13BPM01:SA_Y_MONITOR' 1 [13,1] 85 ; ...
-'13BPMx2 ' 'SR13BPM02:SA_X_MONITOR' 1 '13BPMy2 ' 'SR13BPM02:SA_Y_MONITOR' 1 [13,2] 86 ; ...
-'13BPMx3 ' 'SR13BPM03:SA_X_MONITOR' 1 '13BPMy3 ' 'SR13BPM03:SA_Y_MONITOR' 1 [13,3] 87 ; ...
-'13BPMx4 ' 'SR13BPM04:SA_X_MONITOR' 1 '13BPMy4 ' 'SR13BPM04:SA_Y_MONITOR' 1 [13,4] 88 ; ...
-'13BPMx5 ' 'SR13BPM05:SA_X_MONITOR' 1 '13BPMy5 ' 'SR13BPM05:SA_Y_MONITOR' 1 [13,5] 89 ; ...
-'13BPMx6 ' 'SR13BPM06:SA_X_MONITOR' 1 '13BPMy6 ' 'SR13BPM06:SA_Y_MONITOR' 1 [13,6] 90 ; ...
-'13BPMx7 ' 'SR13BPM07:SA_X_MONITOR' 1 '13BPMy7 ' 'SR13BPM07:SA_Y_MONITOR' 1 [13,7] 91 ; ...
-'14BPMx1 ' 'SR14BPM01:SA_X_MONITOR' 1 '14BPMy1 ' 'SR14BPM01:SA_Y_MONITOR' 1 [14,1] 92 ; ...
-'14BPMx2 ' 'SR14BPM02:SA_X_MONITOR' 1 '14BPMy2 ' 'SR14BPM02:SA_Y_MONITOR' 1 [14,2] 93 ; ...
-'14BPMx3 ' 'SR14BPM03:SA_X_MONITOR' 1 '14BPMy3 ' 'SR14BPM03:SA_Y_MONITOR' 1 [14,3] 94 ; ...
-'14BPMx4 ' 'SR14BPM04:SA_X_MONITOR' 1 '14BPMy4 ' 'SR14BPM04:SA_Y_MONITOR' 1 [14,4] 95 ; ...
-'14BPMx5 ' 'SR14BPM05:SA_X_MONITOR' 1 '14BPMy5 ' 'SR14BPM05:SA_Y_MONITOR' 1 [14,5] 96 ; ...
-'14BPMx6 ' 'SR14BPM06:SA_X_MONITOR' 1 '14BPMy6 ' 'SR14BPM06:SA_Y_MONITOR' 1 [14,6] 97 ; ...
-'14BPMx7 ' 'SR14BPM07:SA_X_MONITOR' 1 '14BPMy7 ' 'SR14BPM07:SA_Y_MONITOR' 1 [14,7] 98 ; ...
-};
-
-%Load fields from data block
-for ii=1:size(bpm,1)
-name=bpm{ii,1}; AO.BPMx.CommonNames(ii,:) = name;
-name=bpm{ii,2}; AO.BPMx.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,3}; AO.BPMx.Status(ii,:) = val;
-name=bpm{ii,4}; AO.BPMy.CommonNames(ii,:) = name;
-name=bpm{ii,5}; AO.BPMy.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,6}; AO.BPMy.Status(ii,:) = val;
-val =bpm{ii,7}; AO.BPMx.DeviceList(ii,:) = val;
- AO.BPMy.DeviceList(ii,:) = val;
-val =bpm{ii,8}; AO.BPMx.ElementList(ii,:) = val;
- AO.BPMy.ElementList(ii,:) = val;
- AO.BPMx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.BPMx.Monitor.Physics2HWParams(ii,:) = 1e+3;
- AO.BPMy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.BPMy.Monitor.Physics2HWParams(ii,:) = 1e+3;
-end
-
-
-% % Get sum value from button. Don't need handles and PV namelist as
-% % parameters are the same as the 'monitor' subcategory.
-% AO.BPMx.Sum.Monitor = AO.BPMx.Monitor;
-% AO.BPMx.Sum.SpecialFunction = 'getbpmsumspear';
-% AO.BPMx.Sum.HWUnits = 'ADC Counts';
-% AO.BPMx.Sum.PhysicsUnits = 'ADC Counts';
-% AO.BPMx.Sum.HW2PhysicsParams = 1;
-% AO.BPMx.Sum.Physics2HWParams = 1;
-% % Get q value from BPMs. Don't need handles and PV namelist.
-% AO.BPMx.Q = AO.BPMx.Monitor;
-% AO.BPMx.Q.SpecialFunction = 'getbpmqspear';
-% AO.BPMx.Q.HWUnits = 'mm';
-% AO.BPMx.Q.PhysicsUnits = 'meter';
-% AO.BPMx.Q.HW2PhysicsParams = 1e-3;
-% AO.BPMx.Q.Physics2HWParams = 1000;
-%
-% % Definition above for horiz0ontal. Replicate for vertical.
-% AO.BPMy.Sum = AO.BPMx.Sum;
-% AO.BPMy.Q = AO.BPMx.Q;
-
-%===========================================================
-% Corrector data: status field designates if corrector in use
-% ASP corrector coils wound into sextupoles. Not dynamic correctors.
-%===========================================================
-
-AO.HCM.FamilyName = 'HCM'; dispobject(AO,AO.HCM.FamilyName);
-AO.HCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'HCM'; 'Magnet'; 'Horizontal'};
-
-AO.HCM.Monitor.Mode = Mode;
-AO.HCM.Monitor.DataType = 'Scalar';
-AO.HCM.Monitor.Units = 'Hardware';
-AO.HCM.Monitor.HWUnits = 'ampere';
-AO.HCM.Monitor.PhysicsUnits = 'radian';
-AO.HCM.Monitor.HW2PhysicsFcn = @amp2k;
-AO.HCM.Monitor.Physics2HWFcn = @k2amp;
-
-AO.HCM.Setpoint.Mode = Mode;
-AO.HCM.Setpoint.DataType = 'Scalar';
-AO.HCM.Setpoint.Units = 'Hardware';
-AO.HCM.Setpoint.HWUnits = 'ampere';
-AO.HCM.Setpoint.PhysicsUnits = 'radian';
-AO.HCM.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.HCM.Setpoint.Physics2HWFcn = @k2amp;
-
-% HW in ampere, Physics in radian. Respmat settings below AO definitions.
-% x-common x-monitor x-setpoint stat devlist elem tol
-cor={
-'1HCM1 ' 'SR01CPS01:CURRENT_MONITOR' 'SR01CPS01:CURRENT_SP ' 1 [1,1] 1 0.2 ; ...
-'1HCM2 ' 'SR01CPS05:CURRENT_MONITOR' 'SR01CPS05:CURRENT_SP ' 1 [1,2] 2 0.2 ; ...
-'1HCM3 ' 'SR01CPS09:CURRENT_MONITOR' 'SR01CPS09:CURRENT_SP ' 1 [1,3] 3 0.2 ; ...
-'2HCM1 ' 'SR02CPS01:CURRENT_MONITOR' 'SR02CPS01:CURRENT_SP ' 1 [2,1] 4 0.2 ; ...
-'2HCM2 ' 'SR02CPS05:CURRENT_MONITOR' 'SR02CPS05:CURRENT_SP ' 1 [2,2] 5 0.2 ; ...
-'2HCM3 ' 'SR02CPS09:CURRENT_MONITOR' 'SR02CPS09:CURRENT_SP ' 1 [2,3] 6 0.2 ; ...
-'3HCM1 ' 'SR03CPS01:CURRENT_MONITOR' 'SR03CPS01:CURRENT_SP ' 1 [3,1] 7 0.2 ; ...
-'3HCM2 ' 'SR03CPS05:CURRENT_MONITOR' 'SR03CPS05:CURRENT_SP ' 1 [3,2] 8 0.2 ; ...
-'3HCM3 ' 'SR03CPS09:CURRENT_MONITOR' 'SR03CPS09:CURRENT_SP ' 1 [3,3] 9 0.2 ; ...
-'4HCM1 ' 'SR04CPS01:CURRENT_MONITOR' 'SR04CPS01:CURRENT_SP ' 1 [4,1] 10 0.2 ; ...
-'4HCM2 ' 'SR04CPS05:CURRENT_MONITOR' 'SR04CPS05:CURRENT_SP ' 1 [4,2] 11 0.2 ; ...
-'4HCM3 ' 'SR04CPS09:CURRENT_MONITOR' 'SR04CPS09:CURRENT_SP ' 1 [4,3] 12 0.2 ; ...
-'5HCM1 ' 'SR05CPS01:CURRENT_MONITOR' 'SR05CPS01:CURRENT_SP ' 1 [5,1] 13 0.2 ; ...
-'5HCM2 ' 'SR05CPS05:CURRENT_MONITOR' 'SR05CPS05:CURRENT_SP ' 1 [5,2] 14 0.2 ; ...
-'5HCM3 ' 'SR05CPS09:CURRENT_MONITOR' 'SR05CPS09:CURRENT_SP ' 1 [5,3] 15 0.2 ; ...
-'6HCM1 ' 'SR06CPS01:CURRENT_MONITOR' 'SR06CPS01:CURRENT_SP ' 1 [6,1] 16 0.2 ; ...
-'6HCM2 ' 'SR06CPS05:CURRENT_MONITOR' 'SR06CPS05:CURRENT_SP ' 1 [6,2] 17 0.2 ; ...
-'6HCM3 ' 'SR06CPS09:CURRENT_MONITOR' 'SR06CPS09:CURRENT_SP ' 1 [6,3] 18 0.2 ; ...
-'7HCM1 ' 'SR07CPS01:CURRENT_MONITOR' 'SR07CPS01:CURRENT_SP ' 1 [7,1] 19 0.2 ; ...
-'7HCM2 ' 'SR07CPS05:CURRENT_MONITOR' 'SR07CPS05:CURRENT_SP ' 1 [7,2] 20 0.2 ; ...
-'7HCM3 ' 'SR07CPS09:CURRENT_MONITOR' 'SR07CPS09:CURRENT_SP ' 1 [7,3] 21 0.2 ; ...
-'8HCM1 ' 'SR08CPS01:CURRENT_MONITOR' 'SR08CPS01:CURRENT_SP ' 1 [8,1] 22 0.2 ; ...
-'8HCM2 ' 'SR08CPS05:CURRENT_MONITOR' 'SR08CPS05:CURRENT_SP ' 1 [8,2] 23 0.2 ; ...
-'8HCM3 ' 'SR08CPS09:CURRENT_MONITOR' 'SR08CPS09:CURRENT_SP ' 1 [8,3] 24 0.2 ; ...
-'9HCM1 ' 'SR09CPS01:CURRENT_MONITOR' 'SR09CPS01:CURRENT_SP ' 1 [9,1] 25 0.2 ; ...
-'9HCM2 ' 'SR09CPS05:CURRENT_MONITOR' 'SR09CPS05:CURRENT_SP ' 1 [9,2] 26 0.2 ; ...
-'9HCM3 ' 'SR09CPS09:CURRENT_MONITOR' 'SR09CPS09:CURRENT_SP ' 1 [9,3] 27 0.2 ; ...
-'10HCM1 ' 'SR10CPS01:CURRENT_MONITOR' 'SR10CPS01:CURRENT_SP ' 1 [10,1] 28 0.2 ; ...
-'10HCM2 ' 'SR10CPS05:CURRENT_MONITOR' 'SR10CPS05:CURRENT_SP ' 1 [10,2] 29 0.2 ; ...
-'10HCM3 ' 'SR10CPS09:CURRENT_MONITOR' 'SR10CPS09:CURRENT_SP ' 1 [10,3] 30 0.2 ; ...
-'11HCM1 ' 'SR11CPS01:CURRENT_MONITOR' 'SR11CPS01:CURRENT_SP ' 1 [11,1] 31 0.2 ; ...
-'11HCM2 ' 'SR11CPS05:CURRENT_MONITOR' 'SR11CPS05:CURRENT_SP ' 1 [11,2] 32 0.2 ; ...
-'11HCM3 ' 'SR11CPS09:CURRENT_MONITOR' 'SR11CPS09:CURRENT_SP ' 1 [11,3] 33 0.2 ; ...
-'12HCM1 ' 'SR12CPS01:CURRENT_MONITOR' 'SR12CPS01:CURRENT_SP ' 1 [12,1] 34 0.2 ; ...
-'12HCM2 ' 'SR12CPS05:CURRENT_MONITOR' 'SR12CPS05:CURRENT_SP ' 1 [12,2] 35 0.2 ; ...
-'12HCM3 ' 'SR12CPS09:CURRENT_MONITOR' 'SR12CPS09:CURRENT_SP ' 1 [12,3] 36 0.2 ; ...
-'13HCM1 ' 'SR13CPS01:CURRENT_MONITOR' 'SR13CPS01:CURRENT_SP ' 1 [13,1] 37 0.2 ; ...
-'13HCM2 ' 'SR13CPS05:CURRENT_MONITOR' 'SR13CPS05:CURRENT_SP ' 1 [13,2] 38 0.2 ; ...
-'13HCM3 ' 'SR13CPS09:CURRENT_MONITOR' 'SR13CPS09:CURRENT_SP ' 1 [13,3] 39 0.2 ; ...
-'14HCM1 ' 'SR14CPS01:CURRENT_MONITOR' 'SR14CPS01:CURRENT_SP ' 1 [14,1] 40 0.2 ; ...
-'14HCM2 ' 'SR14CPS05:CURRENT_MONITOR' 'SR14CPS05:CURRENT_SP ' 1 [14,2] 41 0.2 ; ...
-'14HCM3 ' 'SR14CPS09:CURRENT_MONITOR' 'SR14CPS09:CURRENT_SP ' 1 [14,3] 42 0.2 ; ...
-};
-
-[C, Leff, MagnetType] = magnetcoefficients('HCM');
-
-for ii=1:size(cor,1)
-name=cor{ii,1}; AO.HCM.CommonNames(ii,:) = name;
-name=cor{ii,2}; AO.HCM.Monitor.ChannelNames(ii,:) = name;
-name=cor{ii,3}; AO.HCM.Setpoint.ChannelNames(ii,:) = name;
-val =cor{ii,4}; AO.HCM.Status(ii,1) = val;
-val =cor{ii,5}; AO.HCM.DeviceList(ii,:) = val;
-val =cor{ii,6}; AO.HCM.ElementList(ii,1) = val;
-val =cor{ii,7}; AO.HCM.Setpoint.Tolerance(ii,1) = val;
-
-AO.HCM.Setpoint.Range(ii,:) = [-90 +90];
-AO.HCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
-AO.HCM.Monitor.Physics2HWParams{1}(ii,:) = C;
-AO.HCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
-AO.HCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
-end
-
-
-AO.VCM.FamilyName = 'VCM'; dispobject(AO,AO.VCM.FamilyName);
-AO.VCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'VCM'; 'Magnet'; 'Vertical'};
-
-AO.VCM.Monitor.Mode = Mode;
-AO.VCM.Monitor.DataType = 'Scalar';
-AO.VCM.Monitor.Units = 'Hardware';
-AO.VCM.Monitor.HWUnits = 'ampere';
-AO.VCM.Monitor.PhysicsUnits = 'radian';
-AO.VCM.Monitor.HW2PhysicsFcn = @amp2k;
-AO.VCM.Monitor.Physics2HWFcn = @k2amp;
-
-AO.VCM.Setpoint.Mode = Mode;
-AO.VCM.Setpoint.DataType = 'Scalar';
-AO.VCM.Setpoint.Units = 'Hardware';
-AO.VCM.Setpoint.HWUnits = 'ampere';
-AO.VCM.Setpoint.PhysicsUnits = 'radian';
-AO.VCM.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.VCM.Setpoint.Physics2HWFcn = @k2amp;
-
-% HW in ampere, Physics in radian ** radian units converted to ampere below ***
-% y-common y-monitor y-setpoint stat devlist elem
-cor={
-'1VCM1 ' 'SR01CPS02:CURRENT_MONITOR' 'SR01CPS02:CURRENT_SP ' 1 [1,1] 1 0.2 ; ...
-'1VCM2 ' 'SR01CPS04:CURRENT_MONITOR' 'SR01CPS04:CURRENT_SP ' 1 [1,2] 2 0.2 ; ...
-'1VCM3 ' 'SR01CPS06:CURRENT_MONITOR' 'SR01CPS06:CURRENT_SP ' 1 [1,3] 3 0.2 ; ...
-'1VCM4 ' 'SR01CPS07:CURRENT_MONITOR' 'SR01CPS07:CURRENT_SP ' 1 [1,4] 4 0.2 ; ...
-'2VCM1 ' 'SR02CPS02:CURRENT_MONITOR' 'SR02CPS02:CURRENT_SP ' 1 [2,1] 5 0.2 ; ...
-'2VCM2 ' 'SR02CPS04:CURRENT_MONITOR' 'SR02CPS04:CURRENT_SP ' 1 [2,2] 6 0.2 ; ...
-'2VCM3 ' 'SR02CPS06:CURRENT_MONITOR' 'SR02CPS06:CURRENT_SP ' 1 [2,3] 7 0.2 ; ...
-'2VCM4 ' 'SR02CPS07:CURRENT_MONITOR' 'SR02CPS07:CURRENT_SP ' 1 [2,4] 8 0.2 ; ...
-'3VCM1 ' 'SR03CPS02:CURRENT_MONITOR' 'SR03CPS02:CURRENT_SP ' 1 [3,1] 9 0.2 ; ...
-'3VCM2 ' 'SR03CPS04:CURRENT_MONITOR' 'SR03CPS04:CURRENT_SP ' 1 [3,2] 10 0.2 ; ...
-'3VCM3 ' 'SR03CPS06:CURRENT_MONITOR' 'SR03CPS06:CURRENT_SP ' 1 [3,3] 11 0.2 ; ...
-'3VCM4 ' 'SR03CPS07:CURRENT_MONITOR' 'SR03CPS07:CURRENT_SP ' 1 [3,4] 12 0.2 ; ...
-'4VCM1 ' 'SR04CPS02:CURRENT_MONITOR' 'SR04CPS02:CURRENT_SP ' 1 [4,1] 13 0.2 ; ...
-'4VCM2 ' 'SR04CPS04:CURRENT_MONITOR' 'SR04CPS04:CURRENT_SP ' 1 [4,2] 14 0.2 ; ...
-'4VCM3 ' 'SR04CPS06:CURRENT_MONITOR' 'SR04CPS06:CURRENT_SP ' 1 [4,3] 15 0.2 ; ...
-'4VCM4 ' 'SR04CPS07:CURRENT_MONITOR' 'SR04CPS07:CURRENT_SP ' 1 [4,4] 16 0.2 ; ...
-'5VCM1 ' 'SR05CPS02:CURRENT_MONITOR' 'SR05CPS02:CURRENT_SP ' 1 [5,1] 17 0.2 ; ...
-'5VCM2 ' 'SR05CPS04:CURRENT_MONITOR' 'SR05CPS04:CURRENT_SP ' 1 [5,2] 18 0.2 ; ...
-'5VCM3 ' 'SR05CPS06:CURRENT_MONITOR' 'SR05CPS06:CURRENT_SP ' 1 [5,3] 19 0.2 ; ...
-'5VCM4 ' 'SR05CPS07:CURRENT_MONITOR' 'SR05CPS07:CURRENT_SP ' 1 [5,4] 20 0.2 ; ...
-'6VCM1 ' 'SR06CPS02:CURRENT_MONITOR' 'SR06CPS02:CURRENT_SP ' 1 [6,1] 21 0.2 ; ...
-'6VCM2 ' 'SR06CPS04:CURRENT_MONITOR' 'SR06CPS04:CURRENT_SP ' 1 [6,2] 22 0.2 ; ...
-'6VCM3 ' 'SR06CPS06:CURRENT_MONITOR' 'SR06CPS06:CURRENT_SP ' 1 [6,3] 23 0.2 ; ...
-'6VCM4 ' 'SR06CPS07:CURRENT_MONITOR' 'SR06CPS07:CURRENT_SP ' 1 [6,4] 24 0.2 ; ...
-'7VCM1 ' 'SR07CPS02:CURRENT_MONITOR' 'SR07CPS02:CURRENT_SP ' 1 [7,1] 25 0.2 ; ...
-'7VCM2 ' 'SR07CPS04:CURRENT_MONITOR' 'SR07CPS04:CURRENT_SP ' 1 [7,2] 26 0.2 ; ...
-'7VCM3 ' 'SR07CPS06:CURRENT_MONITOR' 'SR07CPS06:CURRENT_SP ' 1 [7,3] 27 0.2 ; ...
-'7VCM4 ' 'SR07CPS07:CURRENT_MONITOR' 'SR07CPS07:CURRENT_SP ' 1 [7,4] 28 0.2 ; ...
-'8VCM1 ' 'SR08CPS02:CURRENT_MONITOR' 'SR08CPS02:CURRENT_SP ' 1 [8,1] 29 0.2 ; ...
-'8VCM2 ' 'SR08CPS04:CURRENT_MONITOR' 'SR08CPS04:CURRENT_SP ' 1 [8,2] 30 0.2 ; ...
-'8VCM3 ' 'SR08CPS06:CURRENT_MONITOR' 'SR08CPS06:CURRENT_SP ' 1 [8,3] 31 0.2 ; ...
-'8VCM4 ' 'SR08CPS07:CURRENT_MONITOR' 'SR08CPS07:CURRENT_SP ' 1 [8,4] 32 0.2 ; ...
-'9VCM1 ' 'SR09CPS02:CURRENT_MONITOR' 'SR09CPS02:CURRENT_SP ' 1 [9,1] 33 0.2 ; ...
-'9VCM2 ' 'SR09CPS04:CURRENT_MONITOR' 'SR09CPS04:CURRENT_SP ' 1 [9,2] 34 0.2 ; ...
-'9VCM3 ' 'SR09CPS06:CURRENT_MONITOR' 'SR09CPS06:CURRENT_SP ' 1 [9,3] 35 0.2 ; ...
-'9VCM4 ' 'SR09CPS07:CURRENT_MONITOR' 'SR09CPS07:CURRENT_SP ' 1 [9,4] 36 0.2 ; ...
-'10VCM1 ' 'SR10CPS02:CURRENT_MONITOR' 'SR10CPS02:CURRENT_SP ' 1 [10,1] 37 0.2 ; ...
-'10VCM2 ' 'SR10CPS04:CURRENT_MONITOR' 'SR10CPS04:CURRENT_SP ' 1 [10,2] 38 0.2 ; ...
-'10VCM3 ' 'SR10CPS06:CURRENT_MONITOR' 'SR10CPS06:CURRENT_SP ' 1 [10,3] 39 0.2 ; ...
-'10VCM4 ' 'SR10CPS07:CURRENT_MONITOR' 'SR10CPS07:CURRENT_SP ' 1 [10,4] 40 0.2 ; ...
-'11VCM1 ' 'SR11CPS02:CURRENT_MONITOR' 'SR11CPS02:CURRENT_SP ' 1 [11,1] 41 0.2 ; ...
-'11VCM2 ' 'SR11CPS04:CURRENT_MONITOR' 'SR11CPS04:CURRENT_SP ' 1 [11,2] 42 0.2 ; ...
-'11VCM3 ' 'SR11CPS06:CURRENT_MONITOR' 'SR11CPS06:CURRENT_SP ' 1 [11,3] 43 0.2 ; ...
-'11VCM4 ' 'SR11CPS07:CURRENT_MONITOR' 'SR11CPS07:CURRENT_SP ' 1 [11,4] 44 0.2 ; ...
-'12VCM1 ' 'SR12CPS02:CURRENT_MONITOR' 'SR12CPS02:CURRENT_SP ' 1 [12,1] 45 0.2 ; ...
-'12VCM2 ' 'SR12CPS04:CURRENT_MONITOR' 'SR12CPS04:CURRENT_SP ' 1 [12,2] 46 0.2 ; ...
-'12VCM3 ' 'SR12CPS06:CURRENT_MONITOR' 'SR12CPS06:CURRENT_SP ' 1 [12,3] 47 0.2 ; ...
-'12VCM4 ' 'SR12CPS07:CURRENT_MONITOR' 'SR12CPS07:CURRENT_SP ' 1 [12,4] 48 0.2 ; ...
-'13VCM1 ' 'SR13CPS02:CURRENT_MONITOR' 'SR13CPS02:CURRENT_SP ' 1 [13,1] 49 0.2 ; ...
-'13VCM2 ' 'SR13CPS04:CURRENT_MONITOR' 'SR13CPS04:CURRENT_SP ' 1 [13,2] 50 0.2 ; ...
-'13VCM3 ' 'SR13CPS06:CURRENT_MONITOR' 'SR13CPS06:CURRENT_SP ' 1 [13,3] 51 0.2 ; ...
-'13VCM4 ' 'SR13CPS07:CURRENT_MONITOR' 'SR13CPS07:CURRENT_SP ' 1 [13,4] 52 0.2 ; ...
-'14VCM1 ' 'SR14CPS02:CURRENT_MONITOR' 'SR14CPS02:CURRENT_SP ' 1 [14,1] 53 0.2 ; ...
-'14VCM2 ' 'SR14CPS04:CURRENT_MONITOR' 'SR14CPS04:CURRENT_SP ' 1 [14,2] 54 0.2 ; ...
-'14VCM3 ' 'SR14CPS06:CURRENT_MONITOR' 'SR14CPS06:CURRENT_SP ' 1 [14,3] 55 0.2 ; ...
-'14VCM4 ' 'SR14CPS07:CURRENT_MONITOR' 'SR14CPS07:CURRENT_SP ' 1 [14,4] 56 0.3 ; ...
-};
-
-[C, Leff, MagnetType] = magnetcoefficients('VCM');
-
-for ii=1:size(cor,1)
-name=cor{ii,1}; AO.VCM.CommonNames(ii,:) = name;
-name=cor{ii,2}; AO.VCM.Monitor.ChannelNames(ii,:) = name;
-name=cor{ii,3}; AO.VCM.Setpoint.ChannelNames(ii,:) = name;
-val =cor{ii,4}; AO.VCM.Status(ii,1) = val;
-val =cor{ii,5}; AO.VCM.DeviceList(ii,:) = val;
-val =cor{ii,6}; AO.VCM.ElementList(ii,1) = val;
-val =cor{ii,7}; AO.VCM.Setpoint.Tolerance(ii,1) = val;
-
-AO.VCM.Setpoint.Range(ii,:) = [-125 +125];
-AO.VCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
-AO.VCM.Monitor.Physics2HWParams{1}(ii,:) = C;
-AO.VCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
-AO.VCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
-end
-
-
-%=============================
-% MAIN MAGNETS
-%=============================
-
-%===========
-%Dipole data
-%===========
-
-% *** BEND ***
-AO.BEND.FamilyName = 'BEND'; dispobject(AO,AO.BEND.FamilyName);
-AO.BEND.MemberOf = {'PlotFamily'; 'MachineConfig'; 'BEND'; 'Magnet';};
-HW2PhysicsParams = magnetcoefficients('BEND');
-Physics2HWParams = magnetcoefficients('BEND');
-
-AO.BEND.Monitor.Mode = Mode;
-AO.BEND.Monitor.DataType = 'Scalar';
-AO.BEND.Monitor.Units = 'Hardware';
-AO.BEND.Monitor.HW2PhysicsFcn = @bend2gev; % @bend2gev ???
-AO.BEND.Monitor.Physics2HWFcn = @gev2bend;
-AO.BEND.Monitor.HWUnits = 'ampere';
-AO.BEND.Monitor.PhysicsUnits = 'energy';
-
-AO.BEND.Setpoint.Mode = Mode;
-AO.BEND.Setpoint.DataType = 'Scalar';
-AO.BEND.Setpoint.Units = 'Hardware';
-AO.BEND.Setpoint.HW2PhysicsFcn = @bend2gev;
-AO.BEND.Setpoint.Physics2HWFcn = @gev2bend;
-AO.BEND.Setpoint.HWUnits = 'ampere';
-AO.BEND.Setpoint.PhysicsUnits = 'energy';
-
-% common monitor setpoint stat devlist elem scale tol
-bend={
-'1BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
-'1BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
-'2BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
-'2BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
-'3BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
-'3BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
-'4BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
-'4BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
-'5BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
-'5BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
-'6BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
-'6BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
-'7BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
-'7BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
-'8BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
-'8BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
-'9BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
-'9BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
-'10BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
-'10BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
-'11BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
-'11BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
-'12BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
-'12BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
-'13BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
-'13BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
-'14BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
-'14BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
-};
-
-for ii=1:size(bend,1)
-name=bend{ii,1}; AO.BEND.CommonNames(ii,:) = name;
-name=bend{ii,2}; AO.BEND.Monitor.ChannelNames(ii,:) = name;
-name=bend{ii,3}; AO.BEND.Setpoint.ChannelNames(ii,:) = name;
-val =bend{ii,4}; AO.BEND.Status(ii,1) = val;
-val =bend{ii,5}; AO.BEND.DeviceList(ii,:) = val;
-val =bend{ii,6}; AO.BEND.ElementList(ii,1) = val;
-val =bend{ii,7}; % This is the scale factor
-AO.BEND.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.BEND.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.BEND.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.BEND.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.BEND.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.BEND.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.BEND.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.BEND.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =bend{ii,8}; AO.BEND.Setpoint.Tolerance(ii,1) = val;
-
-AO.BEND.Setpoint.Range(ii,:) = [50 695];
-end
-
-%===============
-%Quadrupole data
-%===============
-
-% *** QFA ***
-AO.QFA.FamilyName = 'QFA'; dispobject(AO,AO.QFA.FamilyName);
-AO.QFA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
-HW2PhysicsParams = magnetcoefficients('QFA');
-Physics2HWParams = magnetcoefficients('QFA');
-
-AO.QFA.Monitor.Mode = Mode;
-AO.QFA.Monitor.DataType = 'Scalar';
-AO.QFA.Monitor.Units = 'Hardware';
-AO.QFA.Monitor.HWUnits = 'ampere';
-AO.QFA.Monitor.PhysicsUnits = 'meter^-2';
-AO.QFA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QFA.Monitor.Physics2HWFcn = @k2amp;
-
-AO.QFA.Setpoint.Mode = Mode;
-AO.QFA.Setpoint.DataType = 'Scalar';
-AO.QFA.Setpoint.Units = 'Hardware';
-AO.QFA.Setpoint.HWUnits = 'ampere';
-AO.QFA.Setpoint.PhysicsUnits = 'meter^-2';
-AO.QFA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QFA.Setpoint.Physics2HWFcn = @k2amp;
-
-% common monitor setpoint stat devlist elem scale tol
-qfa={
-'1QFA1 ' 'SR01QPS01:CURRENT_MONITOR' 'SR01QPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
-'1QFA2 ' 'SR01QPS06:CURRENT_MONITOR' 'SR01QPS06:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
-'2QFA1 ' 'SR02QPS01:CURRENT_MONITOR' 'SR02QPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
-'2QFA2 ' 'SR02QPS06:CURRENT_MONITOR' 'SR02QPS06:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
-'3QFA1 ' 'SR03QPS01:CURRENT_MONITOR' 'SR03QPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
-'3QFA2 ' 'SR03QPS06:CURRENT_MONITOR' 'SR03QPS06:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
-'4QFA1 ' 'SR04QPS01:CURRENT_MONITOR' 'SR04QPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
-'4QFA2 ' 'SR04QPS06:CURRENT_MONITOR' 'SR04QPS06:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
-'5QFA1 ' 'SR05QPS01:CURRENT_MONITOR' 'SR05QPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
-'5QFA2 ' 'SR05QPS06:CURRENT_MONITOR' 'SR05QPS06:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
-'6QFA1 ' 'SR06QPS01:CURRENT_MONITOR' 'SR06QPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
-'6QFA2 ' 'SR06QPS06:CURRENT_MONITOR' 'SR06QPS06:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
-'7QFA1 ' 'SR07QPS01:CURRENT_MONITOR' 'SR07QPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
-'7QFA2 ' 'SR07QPS06:CURRENT_MONITOR' 'SR07QPS06:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
-'8QFA1 ' 'SR08QPS01:CURRENT_MONITOR' 'SR08QPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
-'8QFA2 ' 'SR08QPS06:CURRENT_MONITOR' 'SR08QPS06:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
-'9QFA1 ' 'SR09QPS01:CURRENT_MONITOR' 'SR09QPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
-'9QFA2 ' 'SR09QPS06:CURRENT_MONITOR' 'SR09QPS06:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
-'10QFA1 ' 'SR10QPS01:CURRENT_MONITOR' 'SR10QPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
-'10QFA2 ' 'SR10QPS06:CURRENT_MONITOR' 'SR10QPS06:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
-'11QFA1 ' 'SR11QPS01:CURRENT_MONITOR' 'SR11QPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
-'11QFA2 ' 'SR11QPS06:CURRENT_MONITOR' 'SR11QPS06:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
-'12QFA1 ' 'SR12QPS01:CURRENT_MONITOR' 'SR12QPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
-'12QFA2 ' 'SR12QPS06:CURRENT_MONITOR' 'SR12QPS06:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
-'13QFA1 ' 'SR13QPS01:CURRENT_MONITOR' 'SR13QPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
-'13QFA2 ' 'SR13QPS06:CURRENT_MONITOR' 'SR13QPS06:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
-'14QFA1 ' 'SR14QPS01:CURRENT_MONITOR' 'SR14QPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
-'14QFA2 ' 'SR14QPS06:CURRENT_MONITOR' 'SR14QPS06:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
-};
-
-for ii=1:size(qfa,1)
-name=qfa{ii,1}; AO.QFA.CommonNames(ii,:) = name;
-name=qfa{ii,2}; AO.QFA.Monitor.ChannelNames(ii,:) = name;
-name=qfa{ii,3}; AO.QFA.Setpoint.ChannelNames(ii,:) = name;
-val =qfa{ii,4}; AO.QFA.Status(ii,1) = val;
-val =qfa{ii,5}; AO.QFA.DeviceList(ii,:) = val;
-val =qfa{ii,6}; AO.QFA.ElementList(ii,1) = val;
-val =qfa{ii,7}; % This is the scale factor
-AO.QFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qfa{ii,8}; AO.QFA.Setpoint.Tolerance(ii,1) = val;
-
-% Important! This determines the cycling range
-AO.QFA.Setpoint.Range(ii,:) = [0 160];
-end
-
-
-% *** QDA ***
-AO.QDA.FamilyName = 'QDA'; dispobject(AO,AO.QDA.FamilyName);
-AO.QDA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QD';};
-HW2PhysicsParams = magnetcoefficients('QDA');
-Physics2HWParams = magnetcoefficients('QDA');
-
-AO.QDA.Monitor.Mode = Mode;
-AO.QDA.Monitor.DataType = 'Scalar';
-AO.QDA.Monitor.Units = 'Hardware';
-AO.QDA.Monitor.HWUnits = 'ampere';
-AO.QDA.Monitor.PhysicsUnits = 'meter^-2';
-AO.QDA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QDA.Monitor.Physics2HWFcn = @k2amp;
-
-AO.QDA.Setpoint.Mode = Mode;
-AO.QDA.Setpoint.DataType = 'Scalar';
-AO.QDA.Setpoint.Units = 'Hardware';
-AO.QDA.Setpoint.HWUnits = 'ampere';
-AO.QDA.Setpoint.PhysicsUnits = 'meter^-2';
-AO.QDA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QDA.Setpoint.Physics2HWFcn = @k2amp;
-
-% common monitor setpoint stat devlist elem scale tol
-qda={
-'1QDA1 ' 'SR01QPS02:CURRENT_MONITOR' 'SR01QPS02:CURRENT_SP ' 1 [1,1] 1 1.0 0.15 ; ...
-'1QDA2 ' 'SR01QPS05:CURRENT_MONITOR' 'SR01QPS05:CURRENT_SP ' 1 [1,2] 2 1.0 0.15 ; ...
-'2QDA1 ' 'SR02QPS02:CURRENT_MONITOR' 'SR02QPS02:CURRENT_SP ' 1 [2,1] 3 1.0 0.15 ; ...
-'2QDA2 ' 'SR02QPS05:CURRENT_MONITOR' 'SR02QPS05:CURRENT_SP ' 1 [2,2] 4 1.0 0.15 ; ...
-'3QDA1 ' 'SR03QPS02:CURRENT_MONITOR' 'SR03QPS02:CURRENT_SP ' 1 [3,1] 5 1.0 0.15 ; ...
-'3QDA2 ' 'SR03QPS05:CURRENT_MONITOR' 'SR03QPS05:CURRENT_SP ' 1 [3,2] 6 1.0 0.15 ; ...
-'4QDA1 ' 'SR04QPS02:CURRENT_MONITOR' 'SR04QPS02:CURRENT_SP ' 1 [4,1] 7 1.0 0.15 ; ...
-'4QDA2 ' 'SR04QPS05:CURRENT_MONITOR' 'SR04QPS05:CURRENT_SP ' 1 [4,2] 8 1.0 0.15 ; ...
-'5QDA1 ' 'SR05QPS02:CURRENT_MONITOR' 'SR05QPS02:CURRENT_SP ' 1 [5,1] 9 1.0 0.15 ; ...
-'5QDA2 ' 'SR05QPS05:CURRENT_MONITOR' 'SR05QPS05:CURRENT_SP ' 1 [5,2] 10 1.0 0.15 ; ...
-'6QDA1 ' 'SR06QPS02:CURRENT_MONITOR' 'SR06QPS02:CURRENT_SP ' 1 [6,1] 11 1.0 0.15 ; ...
-'6QDA2 ' 'SR06QPS05:CURRENT_MONITOR' 'SR06QPS05:CURRENT_SP ' 1 [6,2] 12 1.0 1.00 ; ...
-'7QDA1 ' 'SR07QPS02:CURRENT_MONITOR' 'SR07QPS02:CURRENT_SP ' 1 [7,1] 13 1.0 0.15 ; ...
-'7QDA2 ' 'SR07QPS05:CURRENT_MONITOR' 'SR07QPS05:CURRENT_SP ' 1 [7,2] 14 1.0 0.15 ; ...
-'8QDA1 ' 'SR08QPS02:CURRENT_MONITOR' 'SR08QPS02:CURRENT_SP ' 1 [8,1] 15 1.0 0.15 ; ...
-'8QDA2 ' 'SR08QPS05:CURRENT_MONITOR' 'SR08QPS05:CURRENT_SP ' 1 [8,2] 16 1.0 0.15 ; ...
-'9QDA1 ' 'SR09QPS02:CURRENT_MONITOR' 'SR09QPS02:CURRENT_SP ' 1 [9,1] 17 1.0 0.15 ; ...
-'9QDA2 ' 'SR09QPS05:CURRENT_MONITOR' 'SR09QPS05:CURRENT_SP ' 1 [9,2] 18 1.0 0.15 ; ...
-'10QDA1 ' 'SR10QPS02:CURRENT_MONITOR' 'SR10QPS02:CURRENT_SP ' 1 [10,1] 19 1.0 0.15 ; ...
-'10QDA2 ' 'SR10QPS05:CURRENT_MONITOR' 'SR10QPS05:CURRENT_SP ' 1 [10,2] 20 1.0 0.15 ; ...
-'11QDA1 ' 'SR11QPS02:CURRENT_MONITOR' 'SR11QPS02:CURRENT_SP ' 1 [11,1] 21 1.0 0.15 ; ...
-'11QDA2 ' 'SR11QPS05:CURRENT_MONITOR' 'SR11QPS05:CURRENT_SP ' 1 [11,2] 22 1.0 0.15 ; ...
-'12QDA1 ' 'SR12QPS02:CURRENT_MONITOR' 'SR12QPS02:CURRENT_SP ' 1 [12,1] 23 1.0 0.15 ; ...
-'12QDA2 ' 'SR12QPS05:CURRENT_MONITOR' 'SR12QPS05:CURRENT_SP ' 1 [12,2] 24 1.0 0.15 ; ...
-'13QDA1 ' 'SR13QPS02:CURRENT_MONITOR' 'SR13QPS02:CURRENT_SP ' 1 [13,1] 25 1.0 0.15 ; ...
-'13QDA2 ' 'SR13QPS05:CURRENT_MONITOR' 'SR13QPS05:CURRENT_SP ' 1 [13,2] 26 1.0 0.15 ; ...
-'14QDA1 ' 'SR14QPS02:CURRENT_MONITOR' 'SR14QPS02:CURRENT_SP ' 1 [14,1] 27 1.0 0.15 ; ...
-'14QDA2 ' 'SR14QPS05:CURRENT_MONITOR' 'SR14QPS05:CURRENT_SP ' 1 [14,2] 28 1.0 0.15 ; ...
-};
-
-for ii=1:size(qda,1)
-name=qda{ii,1}; AO.QDA.CommonNames(ii,:) = name;
-name=qda{ii,2}; AO.QDA.Monitor.ChannelNames(ii,:) = name;
-name=qda{ii,3}; AO.QDA.Setpoint.ChannelNames(ii,:) = name;
-val =qda{ii,4}; AO.QDA.Status(ii,1) = val;
-val =qda{ii,5}; AO.QDA.DeviceList(ii,:) = val;
-val =qda{ii,6}; AO.QDA.ElementList(ii,1) = val;
-val =qda{ii,7}; % This is the scale factor
-AO.QDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QDA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qda{ii,8}; AO.QDA.Setpoint.Tolerance(ii,1) = val;
-
-% Important! This determines the cycling range
-AO.QDA.Setpoint.Range(ii,:) = [0 90];
-end
-
-
-
-% *** QFB ***
-AO.QFB.FamilyName = 'QFB'; dispobject(AO,AO.QFB.FamilyName);
-AO.QFB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
-HW2PhysicsParams = magnetcoefficients('QFB');
-Physics2HWParams = magnetcoefficients('QFB');
-
-AO.QFB.Monitor.Mode = Mode;
-AO.QFB.Monitor.DataType = 'Scalar';
-AO.QFB.Monitor.Units = 'Hardware';
-AO.QFB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QFB.Monitor.Physics2HWFcn = @k2amp;
-AO.QFB.Monitor.HWUnits = 'ampere';
-AO.QFB.Monitor.PhysicsUnits = 'meter^-2';
-
-AO.QFB.Setpoint.Mode = Mode;
-AO.QFB.Setpoint.DataType = 'Scalar';
-AO.QFB.Setpoint.Units = 'Hardware';
-AO.QFB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QFB.Setpoint.Physics2HWFcn = @k2amp;
-AO.QFB.Setpoint.HWUnits = 'ampere';
-AO.QFB.Setpoint.PhysicsUnits = 'meter^-2';
-
-% common monitor setpoint stat devlist elem scale tol
-qfb={
-'1QFB1 ' 'SR01QPS03:CURRENT_MONITOR' 'SR01QPS03:CURRENT_SP ' 1 [1,1] 1 1.0 0.25 ; ...
-'1QFB2 ' 'SR01QPS04:CURRENT_MONITOR' 'SR01QPS04:CURRENT_SP ' 1 [1,2] 2 1.0 0.25 ; ...
-'2QFB1 ' 'SR02QPS03:CURRENT_MONITOR' 'SR02QPS03:CURRENT_SP ' 1 [2,1] 3 1.0 0.25 ; ...
-'2QFB2 ' 'SR02QPS04:CURRENT_MONITOR' 'SR02QPS04:CURRENT_SP ' 1 [2,2] 4 1.0 0.25 ; ...
-'3QFB1 ' 'SR03QPS03:CURRENT_MONITOR' 'SR03QPS03:CURRENT_SP ' 1 [3,1] 5 1.0 0.25 ; ...
-'3QFB2 ' 'SR03QPS04:CURRENT_MONITOR' 'SR03QPS04:CURRENT_SP ' 1 [3,2] 6 1.0 0.25 ; ...
-'4QFB1 ' 'SR04QPS03:CURRENT_MONITOR' 'SR04QPS03:CURRENT_SP ' 1 [4,1] 7 1.0 0.25 ; ...
-'4QFB2 ' 'SR04QPS04:CURRENT_MONITOR' 'SR04QPS04:CURRENT_SP ' 1 [4,2] 8 1.0 0.25 ; ...
-'5QFB1 ' 'SR05QPS03:CURRENT_MONITOR' 'SR05QPS03:CURRENT_SP ' 1 [5,1] 9 1.0 0.25 ; ...
-'5QFB2 ' 'SR05QPS04:CURRENT_MONITOR' 'SR05QPS04:CURRENT_SP ' 1 [5,2] 10 1.0 0.25 ; ...
-'6QFB1 ' 'SR06QPS03:CURRENT_MONITOR' 'SR06QPS03:CURRENT_SP ' 1 [6,1] 11 1.0 0.25 ; ...
-'6QFB2 ' 'SR06QPS04:CURRENT_MONITOR' 'SR06QPS04:CURRENT_SP ' 1 [6,2] 12 1.0 0.25 ; ...
-'7QFB1 ' 'SR07QPS03:CURRENT_MONITOR' 'SR07QPS03:CURRENT_SP ' 1 [7,1] 13 1.0 0.25 ; ...
-'7QFB2 ' 'SR07QPS04:CURRENT_MONITOR' 'SR07QPS04:CURRENT_SP ' 1 [7,2] 14 1.0 0.25 ; ...
-'8QFB1 ' 'SR08QPS03:CURRENT_MONITOR' 'SR08QPS03:CURRENT_SP ' 1 [8,1] 15 1.0 0.25 ; ...
-'8QFB2 ' 'SR08QPS04:CURRENT_MONITOR' 'SR08QPS04:CURRENT_SP ' 1 [8,2] 16 1.0 0.25 ; ...
-'9QFB1 ' 'SR09QPS03:CURRENT_MONITOR' 'SR09QPS03:CURRENT_SP ' 1 [9,1] 17 1.0 0.25 ; ...
-'9QFB2 ' 'SR09QPS04:CURRENT_MONITOR' 'SR09QPS04:CURRENT_SP ' 1 [9,2] 18 1.0 0.25 ; ...
-'10QFB1 ' 'SR10QPS03:CURRENT_MONITOR' 'SR10QPS03:CURRENT_SP ' 1 [10,1] 19 1.0 0.25 ; ...
-'10QFB2 ' 'SR10QPS04:CURRENT_MONITOR' 'SR10QPS04:CURRENT_SP ' 1 [10,2] 20 1.0 0.25 ; ...
-'11QFB1 ' 'SR11QPS03:CURRENT_MONITOR' 'SR11QPS03:CURRENT_SP ' 1 [11,1] 21 1.0 0.25 ; ...
-'11QFB2 ' 'SR11QPS04:CURRENT_MONITOR' 'SR11QPS04:CURRENT_SP ' 1 [11,2] 22 1.0 0.25 ; ...
-'12QFB1 ' 'SR12QPS03:CURRENT_MONITOR' 'SR12QPS03:CURRENT_SP ' 1 [12,1] 23 1.0 0.25 ; ...
-'12QFB2 ' 'SR12QPS04:CURRENT_MONITOR' 'SR12QPS04:CURRENT_SP ' 1 [12,2] 24 1.0 0.25 ; ...
-'13QFB1 ' 'SR13QPS03:CURRENT_MONITOR' 'SR13QPS03:CURRENT_SP ' 1 [13,1] 25 1.0 0.25 ; ...
-'13QFB2 ' 'SR13QPS04:CURRENT_MONITOR' 'SR13QPS04:CURRENT_SP ' 1 [13,2] 26 1.0 0.25 ; ...
-'14QFB1 ' 'SR14QPS03:CURRENT_MONITOR' 'SR14QPS03:CURRENT_SP ' 1 [14,1] 27 1.0 0.25 ; ...
-'14QFB2 ' 'SR14QPS04:CURRENT_MONITOR' 'SR14QPS04:CURRENT_SP ' 1 [14,2] 28 1.0 0.25 ; ...
-};
-
-for ii=1:size(qfb,1)
-name=qfb{ii,1}; AO.QFB.CommonNames(ii,:) = name;
-name=qfb{ii,2}; AO.QFB.Monitor.ChannelNames(ii,:) = name;
-name=qfb{ii,3}; AO.QFB.Setpoint.ChannelNames(ii,:) = name;
-val =qfb{ii,4}; AO.QFB.Status(ii,1) = val;
-val =qfb{ii,5}; AO.QFB.DeviceList(ii,:) = val;
-val =qfb{ii,6}; AO.QFB.ElementList(ii,1) = val;
-val =qfb{ii,7}; % This is the scale factor
-AO.QFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qfb{ii,8}; AO.QFB.Setpoint.Tolerance(ii,1) = val;
-
-% Important! This determines the cycling range
-AO.QFB.Setpoint.Range(ii,:) = [0 160];
-end
-
-
-%===============
-%Sextupole data
-%===============
-% *** SFA ***
-AO.SFA.FamilyName = 'SFA'; dispobject(AO,AO.SFA.FamilyName);
-AO.SFA.MemberOf = {'PlotFamily'; 'SF'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SFA');
-Physics2HWParams = magnetcoefficients('SFA');
-
-AO.SFA.Monitor.Mode = Mode;
-AO.SFA.Monitor.DataType = 'Scalar';
-AO.SFA.Monitor.Units = 'Hardware';
-AO.SFA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SFA.Monitor.Physics2HWFcn = @k2amp;
-AO.SFA.Monitor.HWUnits = 'ampere';
-AO.SFA.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SFA.Setpoint.Mode = Mode;
-AO.SFA.Setpoint.DataType = 'Scalar';
-AO.SFA.Setpoint.Units = 'Hardware';
-AO.SFA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SFA.Setpoint.Physics2HWFcn = @k2amp;
-AO.SFA.Setpoint.HWUnits = 'ampere';
-AO.SFA.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sfa={
-'1SFA1 ' 'SR01SPS01:CURRENT_MONITOR' 'SR01SPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.15 ; ...
-'1SFA2 ' 'SR01SPS07:CURRENT_MONITOR' 'SR01SPS07:CURRENT_SP ' 1 [1,2] 2 1.0 0.15 ; ...
-'2SFA1 ' 'SR02SPS01:CURRENT_MONITOR' 'SR02SPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.15 ; ...
-'2SFA2 ' 'SR02SPS07:CURRENT_MONITOR' 'SR02SPS07:CURRENT_SP ' 1 [2,2] 4 1.0 0.15 ; ...
-'3SFA1 ' 'SR03SPS01:CURRENT_MONITOR' 'SR03SPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.15 ; ...
-'3SFA2 ' 'SR03SPS07:CURRENT_MONITOR' 'SR03SPS07:CURRENT_SP ' 1 [3,2] 6 1.0 0.15 ; ...
-'4SFA1 ' 'SR04SPS01:CURRENT_MONITOR' 'SR04SPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.15 ; ...
-'4SFA2 ' 'SR04SPS07:CURRENT_MONITOR' 'SR04SPS07:CURRENT_SP ' 1 [4,2] 8 1.0 0.15 ; ...
-'5SFA1 ' 'SR05SPS01:CURRENT_MONITOR' 'SR05SPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.15 ; ...
-'5SFA2 ' 'SR05SPS07:CURRENT_MONITOR' 'SR05SPS07:CURRENT_SP ' 1 [5,2] 10 1.0 0.15 ; ...
-'6SFA1 ' 'SR06SPS01:CURRENT_MONITOR' 'SR06SPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.15 ; ...
-'6SFA2 ' 'SR06SPS07:CURRENT_MONITOR' 'SR06SPS07:CURRENT_SP ' 1 [6,2] 12 1.0 0.15 ; ...
-'7SFA1 ' 'SR07SPS01:CURRENT_MONITOR' 'SR07SPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.15 ; ...
-'7SFA2 ' 'SR07SPS07:CURRENT_MONITOR' 'SR07SPS07:CURRENT_SP ' 1 [7,2] 14 1.0 0.15 ; ...
-'8SFA1 ' 'SR08SPS01:CURRENT_MONITOR' 'SR08SPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.15 ; ...
-'8SFA2 ' 'SR08SPS07:CURRENT_MONITOR' 'SR08SPS07:CURRENT_SP ' 1 [8,2] 16 1.0 0.15 ; ...
-'9SFA1 ' 'SR09SPS01:CURRENT_MONITOR' 'SR09SPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.15 ; ...
-'9SFA2 ' 'SR09SPS07:CURRENT_MONITOR' 'SR09SPS07:CURRENT_SP ' 1 [9,2] 18 1.0 0.15 ; ...
-'10SFA1 ' 'SR10SPS01:CURRENT_MONITOR' 'SR10SPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.15 ; ...
-'10SFA2 ' 'SR10SPS07:CURRENT_MONITOR' 'SR10SPS07:CURRENT_SP ' 1 [10,2] 20 1.0 0.15 ; ...
-'11SFA1 ' 'SR11SPS01:CURRENT_MONITOR' 'SR11SPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.15 ; ...
-'11SFA2 ' 'SR11SPS07:CURRENT_MONITOR' 'SR11SPS07:CURRENT_SP ' 1 [11,2] 22 1.0 0.15 ; ...
-'12SFA1 ' 'SR12SPS01:CURRENT_MONITOR' 'SR12SPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.15 ; ...
-'12SFA2 ' 'SR12SPS07:CURRENT_MONITOR' 'SR12SPS07:CURRENT_SP ' 1 [12,2] 24 1.0 0.15 ; ...
-'13SFA1 ' 'SR13SPS01:CURRENT_MONITOR' 'SR13SPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.15 ; ...
-'13SFA2 ' 'SR13SPS07:CURRENT_MONITOR' 'SR13SPS07:CURRENT_SP ' 1 [13,2] 26 1.0 0.15 ; ...
-'14SFA1 ' 'SR14SPS01:CURRENT_MONITOR' 'SR14SPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.15 ; ...
-'14SFA2 ' 'SR14SPS07:CURRENT_MONITOR' 'SR14SPS07:CURRENT_SP ' 1 [14,2] 28 1.0 0.15 ; ...
-};
-
-for ii=1:size(sfa,1)
-name=sfa{ii,1}; AO.SFA.CommonNames(ii,:) = name;
-name=sfa{ii,2}; AO.SFA.Monitor.ChannelNames(ii,:) = name;
-name=sfa{ii,3}; AO.SFA.Setpoint.ChannelNames(ii,:) = name;
-val =sfa{ii,4}; AO.SFA.Status(ii,1) = val;
-val =sfa{ii,5}; AO.SFA.DeviceList(ii,:) = val;
-val =sfa{ii,6}; AO.SFA.ElementList(ii,1) = val;
-val =sfa{ii,7}; % This is the scale factor
-AO.SFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sfa{ii,8}; AO.SFA.Setpoint.Tolerance(ii,1) = val;
-
-AO.SFA.Setpoint.Range(ii,:) = [0 90];
-end
-
-
-
-% *** SDA ***
-AO.SDA.FamilyName = 'SDA'; dispobject(AO,AO.SDA.FamilyName);
-AO.SDA.MemberOf = {'PlotFamily'; 'SD'; 'SEXT'; 'MachineConfig'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SDA');
-Physics2HWParams = magnetcoefficients('SDA');
-AO.SDA.Monitor.Mode = Mode;
-AO.SDA.Monitor.DataType = 'Scalar';
-AO.SDA.Monitor.Units = 'Hardware';
-AO.SDA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SDA.Monitor.Physics2HWFcn = @k2amp;
-AO.SDA.Monitor.HWUnits = 'ampere';
-AO.SDA.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SDA.Setpoint.Mode = Mode;
-AO.SDA.Setpoint.DataType = 'Scalar';
-AO.SDA.Setpoint.Units = 'Hardware';
-AO.SDA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SDA.Setpoint.Physics2HWFcn = @k2amp;
-AO.SDA.Setpoint.HWUnits = 'ampere';
-AO.SDA.Setpoint.PhysicsUnits = 'meter^-3';
-
-
-% common monitor setpoint stat devlist elem scale tol
-sda={
-'1SDA1 ' 'SR01SPS02:CURRENT_MONITOR' 'SR01SPS02:CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
-'1SDA2 ' 'SR01SPS06:CURRENT_MONITOR' 'SR01SPS06:CURRENT_SP ' 1 [1,2] 2 1.0 0.2 ; ...
-'2SDA1 ' 'SR02SPS02:CURRENT_MONITOR' 'SR02SPS02:CURRENT_SP ' 1 [2,1] 3 1.0 0.2 ; ...
-'2SDA2 ' 'SR02SPS06:CURRENT_MONITOR' 'SR02SPS06:CURRENT_SP ' 1 [2,2] 4 1.0 0.2 ; ...
-'3SDA1 ' 'SR03SPS02:CURRENT_MONITOR' 'SR03SPS02:CURRENT_SP ' 1 [3,1] 5 1.0 0.2 ; ...
-'3SDA2 ' 'SR03SPS06:CURRENT_MONITOR' 'SR03SPS06:CURRENT_SP ' 1 [3,2] 6 1.0 0.2 ; ...
-'4SDA1 ' 'SR04SPS02:CURRENT_MONITOR' 'SR04SPS02:CURRENT_SP ' 1 [4,1] 7 1.0 0.2 ; ...
-'4SDA2 ' 'SR04SPS06:CURRENT_MONITOR' 'SR04SPS06:CURRENT_SP ' 1 [4,2] 8 1.0 0.2 ; ...
-'5SDA1 ' 'SR05SPS02:CURRENT_MONITOR' 'SR05SPS02:CURRENT_SP ' 1 [5,1] 9 1.0 0.2 ; ...
-'5SDA2 ' 'SR05SPS06:CURRENT_MONITOR' 'SR05SPS06:CURRENT_SP ' 1 [5,2] 10 1.0 0.2 ; ...
-'6SDA1 ' 'SR06SPS02:CURRENT_MONITOR' 'SR06SPS02:CURRENT_SP ' 1 [6,1] 11 1.0 0.2 ; ...
-'6SDA2 ' 'SR06SPS06:CURRENT_MONITOR' 'SR06SPS06:CURRENT_SP ' 1 [6,2] 12 1.0 0.2 ; ...
-'7SDA1 ' 'SR07SPS02:CURRENT_MONITOR' 'SR07SPS02:CURRENT_SP ' 1 [7,1] 13 1.0 0.2 ; ...
-'7SDA2 ' 'SR07SPS06:CURRENT_MONITOR' 'SR07SPS06:CURRENT_SP ' 1 [7,2] 14 1.0 0.2 ; ...
-'8SDA1 ' 'SR08SPS02:CURRENT_MONITOR' 'SR08SPS02:CURRENT_SP ' 1 [8,1] 15 1.0 0.2 ; ...
-'8SDA2 ' 'SR08SPS06:CURRENT_MONITOR' 'SR08SPS06:CURRENT_SP ' 1 [8,2] 16 1.0 0.2 ; ...
-'9SDA1 ' 'SR09SPS02:CURRENT_MONITOR' 'SR09SPS02:CURRENT_SP ' 1 [9,1] 17 1.0 0.2 ; ...
-'9SDA2 ' 'SR09SPS06:CURRENT_MONITOR' 'SR09SPS06:CURRENT_SP ' 1 [9,2] 18 1.0 0.2 ; ...
-'10SDA1 ' 'SR10SPS02:CURRENT_MONITOR' 'SR10SPS02:CURRENT_SP ' 1 [10,1] 19 1.0 0.2 ; ...
-'10SDA2 ' 'SR10SPS06:CURRENT_MONITOR' 'SR10SPS06:CURRENT_SP ' 1 [10,2] 20 1.0 0.2 ; ...
-'11SDA1 ' 'SR11SPS02:CURRENT_MONITOR' 'SR11SPS02:CURRENT_SP ' 1 [11,1] 21 1.0 0.2 ; ...
-'11SDA2 ' 'SR11SPS06:CURRENT_MONITOR' 'SR11SPS06:CURRENT_SP ' 1 [11,2] 22 1.0 0.2 ; ...
-'12SDA1 ' 'SR12SPS02:CURRENT_MONITOR' 'SR12SPS02:CURRENT_SP ' 1 [12,1] 23 1.0 0.2 ; ...
-'12SDA2 ' 'SR12SPS06:CURRENT_MONITOR' 'SR12SPS06:CURRENT_SP ' 1 [12,2] 24 1.0 0.2 ; ...
-'13SDA1 ' 'SR13SPS02:CURRENT_MONITOR' 'SR13SPS02:CURRENT_SP ' 1 [13,1] 25 1.0 0.2 ; ...
-'13SDA2 ' 'SR13SPS06:CURRENT_MONITOR' 'SR13SPS06:CURRENT_SP ' 1 [13,2] 26 1.0 0.2 ; ...
-'14SDA1 ' 'SR14SPS02:CURRENT_MONITOR' 'SR14SPS02:CURRENT_SP ' 1 [14,1] 27 1.0 0.2 ; ...
-'14SDA2 ' 'SR14SPS06:CURRENT_MONITOR' 'SR14SPS06:CURRENT_SP ' 1 [14,2] 28 1.0 0.2 ; ...
-};
-
-for ii=1:size(sda,1)
-name=sda{ii,1}; AO.SDA.CommonNames(ii,:) = name;
-name=sda{ii,2}; AO.SDA.Monitor.ChannelNames(ii,:) = name;
-name=sda{ii,3}; AO.SDA.Setpoint.ChannelNames(ii,:) = name;
-val =sda{ii,4}; AO.SDA.Status(ii,1) = val;
-val =sda{ii,5}; AO.SDA.DeviceList(ii,:) = val;
-val =sda{ii,6}; AO.SDA.ElementList(ii,1) = val;
-val =sda{ii,7}; % This is the scale factor
-AO.SDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sda{ii,8}; AO.SDA.Setpoint.Tolerance(ii,1) = val;
-
-AO.SDA.Setpoint.Range(ii,:) = [0 90];
-end
-
-
-% *** SDB ***
-AO.SDB.FamilyName = 'SDB'; dispobject(AO,AO.SDB.FamilyName);
-AO.SDB.MemberOf = {'PlotFamily'; 'SD'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SDB');
-Physics2HWParams = magnetcoefficients('SDB');
-AO.SDB.Monitor.Mode = Mode;
-AO.SDB.Monitor.DataType = 'Scalar';
-AO.SDB.Monitor.Units = 'Hardware';
-AO.SDB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SDB.Monitor.Physics2HWFcn = @k2amp;
-AO.SDB.Monitor.HWUnits = 'ampere';
-AO.SDB.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SDB.Setpoint.Mode = Mode;
-AO.SDB.Setpoint.DataType = 'Scalar';
-AO.SDB.Setpoint.Units = 'Hardware';
-AO.SDB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SDB.Setpoint.Physics2HWFcn = @k2amp;
-AO.SDB.Setpoint.HWUnits = 'ampere';
-AO.SDB.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sdb={
-'1SDB1 ' 'SR01SPS03:CURRENT_MONITOR' 'SR01SPS03:CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
-'1SDB2 ' 'SR01SPS05:CURRENT_MONITOR' 'SR01SPS05:CURRENT_SP ' 1 [1,2] 2 1.0 0.2 ; ...
-'2SDB1 ' 'SR02SPS03:CURRENT_MONITOR' 'SR02SPS03:CURRENT_SP ' 1 [2,1] 3 1.0 0.2 ; ...
-'2SDB2 ' 'SR02SPS05:CURRENT_MONITOR' 'SR02SPS05:CURRENT_SP ' 1 [2,2] 4 1.0 0.2 ; ...
-'3SDB1 ' 'SR03SPS03:CURRENT_MONITOR' 'SR03SPS03:CURRENT_SP ' 1 [3,1] 5 1.0 0.2 ; ...
-'3SDB2 ' 'SR03SPS05:CURRENT_MONITOR' 'SR03SPS05:CURRENT_SP ' 1 [3,2] 6 1.0 0.2 ; ...
-'4SDB1 ' 'SR04SPS03:CURRENT_MONITOR' 'SR04SPS03:CURRENT_SP ' 1 [4,1] 7 1.0 0.2 ; ...
-'4SDB2 ' 'SR04SPS05:CURRENT_MONITOR' 'SR04SPS05:CURRENT_SP ' 1 [4,2] 8 1.0 0.2 ; ...
-'5SDB1 ' 'SR05SPS03:CURRENT_MONITOR' 'SR05SPS03:CURRENT_SP ' 1 [5,1] 9 1.0 0.2 ; ...
-'5SDB2 ' 'SR05SPS05:CURRENT_MONITOR' 'SR05SPS05:CURRENT_SP ' 1 [5,2] 10 1.0 0.2 ; ...
-'6SDB1 ' 'SR06SPS03:CURRENT_MONITOR' 'SR06SPS03:CURRENT_SP ' 1 [6,1] 11 1.0 0.2 ; ...
-'6SDB2 ' 'SR06SPS05:CURRENT_MONITOR' 'SR06SPS05:CURRENT_SP ' 1 [6,2] 12 1.0 0.2 ; ...
-'7SDB1 ' 'SR07SPS03:CURRENT_MONITOR' 'SR07SPS03:CURRENT_SP ' 1 [7,1] 13 1.0 0.2 ; ...
-'7SDB2 ' 'SR07SPS05:CURRENT_MONITOR' 'SR07SPS05:CURRENT_SP ' 1 [7,2] 14 1.0 0.2 ; ...
-'8SDB1 ' 'SR08SPS03:CURRENT_MONITOR' 'SR08SPS03:CURRENT_SP ' 1 [8,1] 15 1.0 0.2 ; ...
-'8SDB2 ' 'SR08SPS05:CURRENT_MONITOR' 'SR08SPS05:CURRENT_SP ' 1 [8,2] 16 1.0 0.2 ; ...
-'9SDB1 ' 'SR09SPS03:CURRENT_MONITOR' 'SR09SPS03:CURRENT_SP ' 1 [9,1] 17 1.0 0.2 ; ...
-'9SDB2 ' 'SR09SPS05:CURRENT_MONITOR' 'SR09SPS05:CURRENT_SP ' 1 [9,2] 18 1.0 0.2 ; ...
-'10SDB1 ' 'SR10SPS03:CURRENT_MONITOR' 'SR10SPS03:CURRENT_SP ' 1 [10,1] 19 1.0 0.2 ; ...
-'10SDB2 ' 'SR10SPS05:CURRENT_MONITOR' 'SR10SPS05:CURRENT_SP ' 1 [10,2] 20 1.0 0.2 ; ...
-'11SDB1 ' 'SR11SPS03:CURRENT_MONITOR' 'SR11SPS03:CURRENT_SP ' 1 [11,1] 21 1.0 0.2 ; ...
-'11SDB2 ' 'SR11SPS05:CURRENT_MONITOR' 'SR11SPS05:CURRENT_SP ' 1 [11,2] 22 1.0 0.2 ; ...
-'12SDB1 ' 'SR12SPS03:CURRENT_MONITOR' 'SR12SPS03:CURRENT_SP ' 1 [12,1] 23 1.0 0.2 ; ...
-'12SDB2 ' 'SR12SPS05:CURRENT_MONITOR' 'SR12SPS05:CURRENT_SP ' 1 [12,2] 24 1.0 0.2 ; ...
-'13SDB1 ' 'SR13SPS03:CURRENT_MONITOR' 'SR13SPS03:CURRENT_SP ' 1 [13,1] 25 1.0 0.2 ; ...
-'13SDB2 ' 'SR13SPS05:CURRENT_MONITOR' 'SR13SPS05:CURRENT_SP ' 1 [13,2] 26 1.0 0.2 ; ...
-'14SDB1 ' 'SR14SPS03:CURRENT_MONITOR' 'SR14SPS03:CURRENT_SP ' 1 [14,1] 27 1.0 0.2 ; ...
-'14SDB2 ' 'SR14SPS05:CURRENT_MONITOR' 'SR14SPS05:CURRENT_SP ' 1 [14,2] 28 1.0 0.2 ; ...
-};
-
-for ii=1:size(sdb,1)
-name=sdb{ii,1}; AO.SDB.CommonNames(ii,:) = name;
-name=sdb{ii,2}; AO.SDB.Monitor.ChannelNames(ii,:) = name;
-name=sdb{ii,3}; AO.SDB.Setpoint.ChannelNames(ii,:)= name;
-val =sdb{ii,4}; AO.SDB.Status(ii,1) = val;
-val =sdb{ii,5}; AO.SDB.DeviceList(ii,:) = val;
-val =sdb{ii,6}; AO.SDB.ElementList(ii,1) = val;
-val =sdb{ii,7}; % This is the scale factor
-AO.SDB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SDB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sdb{ii,8}; AO.SDB.Setpoint.Tolerance(ii,1) = val;
-
-AO.SDB.Setpoint.Range(ii,:) = [0 80];
-end
-
-
-
-% *** SFB ***
-AO.SFB.FamilyName = 'SFB'; dispobject(AO,AO.SFB.FamilyName);
-AO.SFB.MemberOf = {'PlotFamily'; 'SF'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SFB');
-Physics2HWParams = magnetcoefficients('SFB');
-
-AO.SFB.Monitor.Mode = Mode;
-AO.SFB.Monitor.DataType = 'Scalar';
-AO.SFB.Monitor.Units = 'Hardware';
-AO.SFB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SFB.Monitor.Physics2HWFcn = @k2amp;
-AO.SFB.Monitor.HWUnits = 'ampere';
-AO.SFB.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SFB.Setpoint.Mode = Mode;
-AO.SFB.Setpoint.DataType = 'Scalar';
-AO.SFB.Setpoint.Units = 'Hardware';
-AO.SFB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SFB.Setpoint.Physics2HWFcn = @k2amp;
-AO.SFB.Setpoint.HWUnits = 'ampere';
-AO.SFB.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sfb={
-'1SFB1 ' 'SR01SPS04:CURRENT_MONITOR' 'SR01SPS04:CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
-'2SFB1 ' 'SR02SPS04:CURRENT_MONITOR' 'SR02SPS04:CURRENT_SP ' 1 [2,1] 2 1.0 0.2 ; ...
-'3SFB1 ' 'SR03SPS04:CURRENT_MONITOR' 'SR03SPS04:CURRENT_SP ' 1 [3,1] 3 1.0 0.2 ; ...
-'4SFB1 ' 'SR04SPS04:CURRENT_MONITOR' 'SR04SPS04:CURRENT_SP ' 1 [4,1] 4 1.0 0.2 ; ...
-'5SFB1 ' 'SR05SPS04:CURRENT_MONITOR' 'SR05SPS04:CURRENT_SP ' 1 [5,1] 5 1.0 0.2 ; ...
-'6SFB1 ' 'SR06SPS04:CURRENT_MONITOR' 'SR06SPS04:CURRENT_SP ' 1 [6,1] 6 1.0 0.2 ; ...
-'7SFB1 ' 'SR07SPS04:CURRENT_MONITOR' 'SR07SPS04:CURRENT_SP ' 1 [7,1] 7 1.0 0.2 ; ...
-'8SFB1 ' 'SR08SPS04:CURRENT_MONITOR' 'SR08SPS04:CURRENT_SP ' 1 [8,1] 8 1.0 0.2 ; ...
-'9SFB1 ' 'SR09SPS04:CURRENT_MONITOR' 'SR09SPS04:CURRENT_SP ' 1 [9,1] 9 1.0 0.2 ; ...
-'10SFB1 ' 'SR10SPS04:CURRENT_MONITOR' 'SR10SPS04:CURRENT_SP ' 1 [10,1] 10 1.0 0.2 ; ...
-'11SFB1 ' 'SR11SPS04:CURRENT_MONITOR' 'SR11SPS04:CURRENT_SP ' 1 [11,1] 11 1.0 0.2 ; ...
-'12SFB1 ' 'SR12SPS04:CURRENT_MONITOR' 'SR12SPS04:CURRENT_SP ' 1 [12,1] 12 1.0 0.2 ; ...
-'13SFB1 ' 'SR13SPS04:CURRENT_MONITOR' 'SR13SPS04:CURRENT_SP ' 1 [13,1] 13 1.0 0.2 ; ...
-'14SFB1 ' 'SR14SPS04:CURRENT_MONITOR' 'SR14SPS04:CURRENT_SP ' 1 [14,1] 14 1.0 0.2 ; ...
-};
-
-for ii=1:size(sfb,1)
-name=sfb{ii,1}; AO.SFB.CommonNames(ii,:) = name;
-name=sfb{ii,2}; AO.SFB.Monitor.ChannelNames(ii,:) = name;
-name=sfb{ii,3}; AO.SFB.Setpoint.ChannelNames(ii,:)= name;
-val =sfb{ii,4}; AO.SFB.Status(ii,1) = val;
-val =sfb{ii,5}; AO.SFB.DeviceList(ii,:) = val;
-val =sfb{ii,6}; AO.SFB.ElementLsist(ii,1) = val;
-val =sfb{ii,7}; % This is the scale factor
-AO.SFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sfb{ii,8}; AO.SFB.Setpoint.Tolerance(ii,1) = val;
-
-AO.SFB.Setpoint.Range(ii,:) = [0 60];
-end
-
-%===============
-%Skew Quad data
-%===============
-% *** Skew quadrupoles *** 2005/09/27 Eugene
-AO.SKQ.FamilyName = 'SKQ'; dispobject(AO,AO.SKQ.FamilyName);
-AO.SKQ.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SkewQuad'; 'Magnet';};
-HW2PhysicsParams = magnetcoefficients('SKQ');
-Physics2HWParams = magnetcoefficients('SKQ');
-
-AO.SKQ.Monitor.Mode = Mode;
-AO.SKQ.Monitor.DataType = 'Scalar';
-AO.SKQ.Monitor.Units = 'Hardware';
-AO.SKQ.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SKQ.Monitor.Physics2HWFcn = @k2amp;
-AO.SKQ.Monitor.HWUnits = 'ampere';
-AO.SKQ.Monitor.PhysicsUnits = 'meter^-2';
-
-AO.SKQ.Setpoint.Mode = Mode;
-AO.SKQ.Setpoint.DataType = 'Scalar';
-AO.SKQ.Setpoint.Units = 'Hardware';
-AO.SKQ.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SKQ.Setpoint.Physics2HWFcn = @k2amp;
-AO.SKQ.Setpoint.HWUnits = 'ampere';
-AO.SKQ.Setpoint.PhysicsUnits = 'meter^-2';
-
-% common monitor setpoint stat devlist elem scale tol
-sq={
-'1SKQ1 ' 'SR01CPS03:CURRENT_MONITOR' 'SR01CPS03:CURRENT_SP ' 1 [1,1] 1 0.2 ; ...
-'1SKQ2 ' 'SR01CPS08:CURRENT_MONITOR' 'SR01CPS08:CURRENT_SP ' 1 [1,2] 2 0.2 ; ...
-'2SKQ1 ' 'SR02CPS03:CURRENT_MONITOR' 'SR02CPS03:CURRENT_SP ' 1 [2,1] 3 0.2 ; ...
-'2SKQ2 ' 'SR02CPS08:CURRENT_MONITOR' 'SR02CPS08:CURRENT_SP ' 1 [2,2] 4 0.2 ; ...
-'3SKQ1 ' 'SR03CPS03:CURRENT_MONITOR' 'SR03CPS03:CURRENT_SP ' 1 [3,1] 5 0.2 ; ...
-'3SKQ2 ' 'SR03CPS08:CURRENT_MONITOR' 'SR03CPS08:CURRENT_SP ' 1 [3,2] 6 0.2 ; ...
-'4SKQ1 ' 'SR04CPS03:CURRENT_MONITOR' 'SR04CPS03:CURRENT_SP ' 1 [4,1] 7 0.2 ; ...
-'4SKQ2 ' 'SR04CPS08:CURRENT_MONITOR' 'SR04CPS08:CURRENT_SP ' 1 [4,2] 8 0.2 ; ...
-'5SKQ1 ' 'SR05CPS03:CURRENT_MONITOR' 'SR05CPS03:CURRENT_SP ' 1 [5,1] 9 0.2 ; ...
-'5SKQ2 ' 'SR05CPS08:CURRENT_MONITOR' 'SR05CPS08:CURRENT_SP ' 1 [5,2] 10 0.2 ; ...
-'6SKQ1 ' 'SR06CPS03:CURRENT_MONITOR' 'SR06CPS03:CURRENT_SP ' 1 [6,1] 11 0.2 ; ...
-'6SKQ2 ' 'SR06CPS08:CURRENT_MONITOR' 'SR06CPS08:CURRENT_SP ' 1 [6,2] 12 0.2 ; ...
-'7SKQ1 ' 'SR07CPS03:CURRENT_MONITOR' 'SR07CPS03:CURRENT_SP ' 1 [7,1] 13 0.2 ; ...
-'7SKQ2 ' 'SR07CPS08:CURRENT_MONITOR' 'SR07CPS08:CURRENT_SP ' 1 [7,2] 14 0.2 ; ...
-'8SKQ1 ' 'SR08CPS03:CURRENT_MONITOR' 'SR08CPS03:CURRENT_SP ' 1 [8,1] 15 0.2 ; ...
-'8SKQ2 ' 'SR08CPS08:CURRENT_MONITOR' 'SR08CPS08:CURRENT_SP ' 1 [8,2] 16 0.2 ; ...
-'9SKQ1 ' 'SR09CPS03:CURRENT_MONITOR' 'SR09CPS03:CURRENT_SP ' 1 [9,1] 17 0.2 ; ...
-'9SKQ2 ' 'SR09CPS08:CURRENT_MONITOR' 'SR09CPS08:CURRENT_SP ' 1 [9,2] 18 0.2 ; ...
-'10SKQ1 ' 'SR10CPS03:CURRENT_MONITOR' 'SR10CPS03:CURRENT_SP ' 1 [10,1] 19 0.2 ; ...
-'10SKQ2 ' 'SR10CPS08:CURRENT_MONITOR' 'SR10CPS08:CURRENT_SP ' 1 [10,2] 20 0.2 ; ...
-'11SKQ1 ' 'SR11CPS03:CURRENT_MONITOR' 'SR11CPS03:CURRENT_SP ' 1 [11,1] 21 0.2 ; ...
-'11SKQ2 ' 'SR11CPS08:CURRENT_MONITOR' 'SR11CPS08:CURRENT_SP ' 1 [11,2] 22 0.2 ; ...
-'12SKQ1 ' 'SR12CPS03:CURRENT_MONITOR' 'SR12CPS03:CURRENT_SP ' 1 [12,1] 23 0.2 ; ...
-'12SKQ2 ' 'SR12CPS08:CURRENT_MONITOR' 'SR12CPS08:CURRENT_SP ' 1 [12,2] 24 0.2 ; ...
-'13SKQ1 ' 'SR13CPS03:CURRENT_MONITOR' 'SR13CPS03:CURRENT_SP ' 1 [13,1] 25 0.2 ; ...
-'13SKQ2 ' 'SR13CPS08:CURRENT_MONITOR' 'SR13CPS08:CURRENT_SP ' 1 [13,2] 26 0.2 ; ...
-'14SKQ1 ' 'SR14CPS03:CURRENT_MONITOR' 'SR14CPS03:CURRENT_SP ' 1 [14,1] 27 0.2 ; ...
-'14SKQ2 ' 'SR14CPS08:CURRENT_MONITOR' 'SR14CPS08:CURRENT_SP ' 1 [14,2] 28 0.2 ; ...
-};
-
-for ii=1:size(sq,1)
-name=sq{ii,1}; AO.SKQ.CommonNames(ii,:) = name;
-name=sq{ii,2}; AO.SKQ.Monitor.ChannelNames(ii,:) = name;
-name=sq{ii,3}; AO.SKQ.Setpoint.ChannelNames(ii,:) = name;
-val =sq{ii,4}; AO.SKQ.Status(ii,1) = val;
-val =sq{ii,5}; AO.SKQ.DeviceList(ii,:) = val;
-val =sq{ii,6}; AO.SKQ.ElementList(ii,1) = val;
-val =sq{ii,7}; AO.SKQ.Setpoint.Tolerance(ii,1) = val;
-AO.SKQ.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SKQ.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SKQ.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SKQ.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-
-AO.SKQ.Setpoint.Range(ii,:) = [-5 +5];
-end
-
-
-%===============
-%Kicker data
-%===============
-AO.KICK.FamilyName = 'KICK'; dispobject(AO,AO.KICK.FamilyName);
-AO.KICK.MemberOf = {'Injection'; 'MachineConfig'; 'Plotfamily'; 'HCM'; 'Horizontal'};
-
-AO.KICK.Monitor.Mode = Mode;
-AO.KICK.Monitor.DataType = 'Scalar';
-AO.KICK.Monitor.Units = 'Hardware';
-AO.KICK.Monitor.HWUnits = 'kVolts';
-AO.KICK.Monitor.PhysicsUnits = 'mradian';
-
-AO.KICK.Setpoint.Mode = Mode;
-AO.KICK.Setpoint.DataType = 'Scalar';
-AO.KICK.Setpoint.Units = 'Hardware';
-AO.KICK.Setpoint.HWUnits = 'Volts';
-AO.KICK.Setpoint.PhysicsUnits = 'radian';
-
-% From kicker deisgn review the kickers are rated to 4380 Amps giving 0.038
-% Tesla converting this to kickangle. Also convert voltage into amps for
-% the conversion?
-%
-% 2780 V on the capacitor banks will create 5240 A delivered to the kicker
-% magnets.
-% From simulations 4380 A creates 0.038607 T over a length of 0.7 m.
-% Therefore 4380 A => 2.7006 mrad. Therefore 2323.740 V => 2.7006 mrad.
-% HW2PHYSICS conversion factor (kV to rad) is therefore 0.0027006/2.32374 =
-% 0.00116217821271. The Ps also goes through a 1:3 transformer therefore
-% the conversion factor increases by 3. Ie 0.00348653463813
-% For V to rad then 0.00000348653463813.
-hw2physics_conversionfactor = 0.00000348653463813;
-
-% Measured
-% Kicker1 100 V = 0.176 mrad
-% Kicker2 100 V = -0.138 mrad
-% Kicker3 100 V = -0.134 mrad
-% Kicker4 100 V = 0.176 mrad
-
-%common monitor setpoint stat devlist elem tol
-kickeramp={
-'KICK1 ' 'SR14KPS01:VOLTAGE_MONITOR' 'SR14KPS01:VOLTAGE_SP ' 1 [1,1] 1 0.10 ; ...
-'KICK2 ' 'SR01KPS01:VOLTAGE_MONITOR' 'SR01KPS01:VOLTAGE_SP ' 1 [1,2] 2 0.10 ; ...
-'KICK3 ' 'SR01KPS02:VOLTAGE_MONITOR' 'SR01KPS02:VOLTAGE_SP ' 1 [1,3] 3 0.10 ; ...
-'KICK4 ' 'SR02KPS01:VOLTAGE_MONITOR' 'SR02KPS01:VOLTAGE_SP ' 1 [1,4] 4 0.10 ; ...
-};
-
-for ii=1:size(kickeramp,1)
-name=kickeramp{ii,1}; AO.KICK.CommonNames(ii,:) = name;
-name=kickeramp{ii,2}; AO.KICK.Monitor.ChannelNames(ii,:) = name;
-name=kickeramp{ii,3}; AO.KICK.Setpoint.ChannelNames(ii,:)= name;
-val =kickeramp{ii,4}; AO.KICK.Status(ii,1) = val;
-val =kickeramp{ii,5}; AO.KICK.DeviceList(ii,:) = val;
-val =kickeramp{ii,6}; AO.KICK.ElementList(ii,1) = val;
-val =kickeramp{ii,7}; AO.KICK.Setpoint.Tolerance(ii,1) = val;
-
-if ii==1||ii==4
- hw2physics_conversionfactor = 1.7600e-06;
- AO.KICK.Monitor.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
- AO.KICK.Monitor.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
- AO.KICK.Setpoint.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.Range(ii,:) = [-1300 +1300];
-else
- hw2physics_conversionfactor = 1.3600e-06;
- AO.KICK.Monitor.HW2PhysicsParams(ii,:) = -hw2physics_conversionfactor;
- AO.KICK.Monitor.Physics2HWParams(ii,:) = -1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.HW2PhysicsParams(ii,:) = -hw2physics_conversionfactor;
- AO.KICK.Setpoint.Physics2HWParams(ii,:) = -1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.Range(ii,:) = [+1300 -1300];
-end
-end
-
-% *** KICK Delay ***
-% AO.KICK.Delay
-% >> removed >> see previous versions if info needed
-
-
-%============
-%RF System
-%============
-AO.RF.FamilyName = 'RF'; dispobject(AO,AO.RF.FamilyName);
-AO.RF.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
-
-%-------------------------------- 4 cavity Case
-%common stat devlist elem
-rfcommon={
-'RF1 ' 1 [1,1] 1 ; ...
-'RF2 ' 1 [1,2] 2 ; ...
-'RF3 ' 1 [1,3] 3 ; ...
-'RF4 ' 1 [1,4] 4 ; ...
- };
-
-%FreqMon FreqSetpoint HW2PhysicsParams Physics2HWParams Range Tolerance
-rffreq={
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
- };
-
-% PhaseCtrl PhaseMon HW2PhysicsParams Physics2HWParams Range Tolerance
-rfphase={
-'SRF1:STN:PHASE' 'SRF1:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
-'SRF2:STN:PHASE' 'SRF2:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
-'SRF3:STN:PHASE' 'SRF3:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
-'SRF4:STN:PHASE' 'SRF4:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
- };
-
-% VoltCtrl VoltMon HW2PhysicsParams Physics2HWParams Range Tolerance
-rfvolt={
-'SRF1:STN:VOLT:CTRL ' 'SRF1:STN:VOLT' 1 1 [-inf inf] inf ; ...
-'SRF2:STN:VOLT:CTRL ' 'SRF2:STN:VOLT' 1 1 [-inf inf] inf ; ...
-'SRF3:STN:VOLT:CTRL ' 'SRF3:STN:VOLT' 1 1 [-inf inf] inf ; ...
-'SRF4:STN:VOLT:CTRL ' 'SRF4:STN:VOLT' 1 1 [-inf inf] inf ; ...
- };
-% PowerCtrl PowerMon Klystronpower HW2PhysicsParams Physics2HWParams Range Tolerance
-rfpower={
-'SRF1:KLYSDRIVFRWD:POWER:ON ' 'SRF1:KLYSDRIVFRWD:POWER' 'SRF1:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-'SRF2:KLYSDRIVFRWD:POWER:ON ' 'SRF2:KLYSDRIVFRWD:POWER' 'SRF2:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-'SRF3:KLYSDRIVFRWD:POWER:ON ' 'SRF3:KLYSDRIVFRWD:POWER' 'SRF3:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-'SRF4:KLYSDRIVFRWD:POWER:ON ' 'SRF4:KLYSDRIVFRWD:POWER' 'SRF4:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
- };
-
-for ii=1:size(rfcommon,1)
-name=rfcommon{ii,1}; AO.RF.CommonNames(ii,:) = name;
-val =rfcommon{ii,2}; AO.RF.Status(ii,1) = val;
-val =rfcommon{ii,3}; AO.RF.DeviceList(ii,:) = val;
-val =rfcommon{ii,4}; AO.RF.ElementList(ii,1) = val;
-end
-
-for ii=1:size(rffreq,1)
-name=rffreq{ii,1}; AO.RF.Monitor.ChannelNames(ii,:) = name;
-name=rffreq{ii,2}; AO.RF.Setpoint.ChannelNames(ii,:) = name;
-val =rffreq{ii,3}; AO.RF.Monitor.HW2PhysicsParams(ii,1) = val;
- AO.RF.Setpoint.HW2PhysicsParams(ii,1) = val;
-val =rffreq{ii,4}; AO.RF.Monitor.Physics2HWParams(ii,1) = val;
- AO.RF.Setpoint.Physics2HWParams(ii,1) = val;
-val =rffreq{ii,5}; AO.RF.Setpoint.Range(ii,:) = val;
-val =rffreq{ii,6}; AO.RF.Setpoint.Tolerance(ii,1) = val;
-end
-
-
-for ii=1:size(rfphase,1)
-name=rfphase{ii,1}; AO.RF.PhaseCtrl.ChannelNames(ii,:) = name;
-name=rfphase{ii,2}; AO.RF.Phase.ChannelNames(ii,:) = name;
-val =rfphase{ii,3}; AO.RF.PhaseCtrl.HW2PhysicsParams(ii,1) = val;
- AO.RF.Phase.HW2PhysicsParams(ii,1) = val;
-val =rfphase{ii,4}; AO.RF.PhaseCtrl.Physics2HWParams(ii,1) = val;
- AO.RF.Phase.Physics2HWParams(ii,1) = val;
-val =rfphase{ii,5}; AO.RF.PhaseCtrl.Range(ii,:) = val;
- AO.RF.Phase.Range(ii,:) = val;
-val =rfphase{ii,6}; AO.RF.PhaseCtrl.Tolerance(ii,1) = val;
- AO.RF.Phase.Tolerance(ii,1) = val;
-end
-
-
-for ii=1:size(rfvolt,1)
-name=rfvolt{ii,1}; AO.RF.VoltageCtrl.ChannelNames(ii,:) = name;
-name=rfvolt{ii,2}; AO.RF.Voltage.ChannelNames(ii,:) = name;
-val =rfvolt{ii,3}; AO.RF.VoltageCtrl.HW2PhysicsParams(ii,1) = val;
- AO.RF.Voltage.HW2PhysicsParams(ii,1) = val;
-val =rfvolt{ii,4}; AO.RF.VoltageCtrl.Physics2HWParams(ii,1) = val;
- AO.RF.Voltage.Physics2HWParams(ii,1) = val;
-val =rfvolt{ii,5}; AO.RF.VoltageCtrl.Range(ii,:) = val;
- AO.RF.Voltage.Range(ii,:) = val;
-val =rfvolt{ii,6}; AO.RF.VoltageCtrl.Tolerance(ii,1) = val;
- AO.RF.Voltage.Tolerance(ii,1) = val;
-end
-
-
-for ii=1:size(rfpower,1)
-name=rfpower{ii,1}; AO.RF.PowerCtrl.ChannelNames(ii,:) = name;
-name=rfpower{ii,2}; AO.RF.Power.ChannelNames(ii,:) = name;
-name=rfpower{ii,3}; AO.RF.KlysPower.ChannelNames(ii,:) = name;
-val =rfpower{ii,4}; AO.RF.PowerCtrl.HW2PhysicsParams(ii,1) = val;
- AO.RF.Power.HW2PhysicsParams(ii,1) = val;
- AO.RF.KlysPower.HW2PhysicsParams(ii,1) = val;
-val =rfpower{ii,5}; AO.RF.PowerCtrl.Physics2HWParams(ii,1) = val;
- AO.RF.Power.Physics2HWParams(ii,1) = val;
- AO.RF.KlysPower.Physics2HWParams(ii,1) = val;
-val =rfpower{ii,6}; AO.RF.PowerCtrl.Range(ii,:) = val;
- AO.RF.Power.Range(ii,:) = val;
- AO.RF.KlysPower.Range(ii,:) = val;
-val =rfpower{ii,7}; AO.RF.PowerCtrl.Tolerance(ii,1) = val;
- AO.RF.Power.Tolerance(ii,1) = val;
- AO.RF.KlysPower.Tolerance(ii,1) = val;
-end
-
-%Frequency Readback
-AO.RF.Monitor.Mode = Mode;
-AO.RF.Monitor.DataType = 'Scalar';
-AO.RF.Monitor.Units = 'Hardware';
-AO.RF.Monitor.HWUnits = 'Hz';
-AO.RF.Monitor.PhysicsUnits = 'Hz';
-%Frequency Setpoint
-AO.RF.Setpoint.Mode = Mode;
-AO.RF.Setpoint.DataType = 'Scalar';
-AO.RF.Setpoint.Units = 'Hardware';
-AO.RF.Setpoint.HWUnits = 'Hz';
-AO.RF.Setpoint.PhysicsUnits = 'Hz';
-
-%Voltage control
-AO.RF.VoltageCtrl.Mode = Mode;
-AO.RF.VoltageCtrl.DataType = 'Scalar';
-AO.RF.VoltageCtrl.Units = 'Hardware';
-AO.RF.VoltageCtrl.HWUnits = 'Volts';
-AO.RF.VoltageCtrl.PhysicsUnits = 'Volts';
-
-%Voltage monitor
-AO.RF.Voltage.Mode = Mode;
-AO.RF.Voltage.DataType = 'Scalar';
-AO.RF.Voltage.Units = 'Hardware';
-AO.RF.Voltage.HWUnits = 'Volts';
-AO.RF.Voltage.PhysicsUnits = 'Volts';
-
-%Power Control
-AO.RF.PowerCtrl.Mode = Mode;
-AO.RF.PowerCtrl.DataType = 'Scalar';
-AO.RF.PowerCtrl.Units = 'Hardware';
-AO.RF.PowerCtrl.HWUnits = 'MWatts';
-AO.RF.PowerCtrl.PhysicsUnits = 'MWatts';
-
-%Power Monitor
-AO.RF.Power.Mode = Mode;
-AO.RF.Power.DataType = 'Scalar';
-AO.RF.Power.Units = 'Hardware';
-AO.RF.Power.HWUnits = 'MWatts';
-AO.RF.Power.PhysicsUnits = 'MWatts';
-
-%Klystron Forward Power
-AO.RF.KlysPower.Mode = Mode;
-AO.RF.KlysPower.DataType = 'Scalar';
-AO.RF.KlysPower.Units = 'Hardware';
-AO.RF.KlysPower.HWUnits = 'MWatts';
-AO.RF.KlysPower.PhysicsUnits = 'MWatts';
-
-%Station Phase Control
-AO.RF.PhaseCtrl.Mode = Mode;
-AO.RF.PhaseCtrl.DataType = 'Scalar';
-AO.RF.PhaseCtrl.Units = 'Hardware';
-AO.RF.PhaseCtrl.HWUnits = 'Degrees';
-AO.RF.PhaseCtrl.PhysicsUnits = 'Degrees';
-
-
-%Station Phase Monitor
-AO.RF.Phase.Mode = Mode;
-AO.RF.Phase.DataType = 'Scalar';
-AO.RF.Phase.Units = 'Hardware';
-AO.RF.Phase.HWUnits = 'Degrees';
-AO.RF.Phase.PhysicsUnits = 'Degrees';
-
-%====
-%TUNE
-%====
-AO.TUNE.FamilyName = 'TUNE'; dispobject(AO,AO.TUNE.FamilyName);
-AO.TUNE.MemberOf = {'Tune'; 'Diagnostics'};
-AO.TUNE.CommonNames = ['xtune';'ytune'];
-AO.TUNE.DeviceList = [ 1 1; 1 2];
-AO.TUNE.ElementList = [1 2]';
-AO.TUNE.Status = [1 1]';
-
-AO.TUNE.Monitor.Mode = 'Special';
-AO.TUNE.Monitor.SpecialFunction = 'meastune';
-AO.TUNE.Monitor.DataType = 'Vector';
-AO.TUNE.Monitor.DataTypeIndex = [1 2]';
-AO.TUNE.Monitor.Units = 'Hardware';
-AO.TUNE.Monitor.HW2PhysicsParams = 1;
-AO.TUNE.Monitor.Physics2HWParams = 1;
-AO.TUNE.Monitor.HWUnits = 'fractional tune';
-AO.TUNE.Monitor.PhysicsUnits = 'fractional tune';
-
-
-% AO.FTx.Length.Mode = 'Special';
-% AO.FTx.Length.Units = 'Hardware';
-% AO.FTx.Length.DataType = 'Scalar';
-% AO.FTx.Length.SpecialFunction = 'getftlength';
-% AO.FTx.Length.SpecialFunctionSet = 'setftlength';
-% AO.FTx.Length.HWUnits = '32ns samples';
-% AO.FTx.Length.PhysicsUnits = '32ns samples';
-% AO.FTx.Length.HW2PhysicsParams = 1;
-% AO.FTx.Length.Physics2HWParams = 1;
-
-
-%====
-%DCCT
-%====
-AO.DCCT.FamilyName = 'DCCT'; dispobject(AO,AO.DCCT.FamilyName);
-AO.DCCT.MemberOf = {'Diagnostics'};
-AO.DCCT.CommonNames = 'DCCT';
-AO.DCCT.DeviceList = [1 1];
-AO.DCCT.ElementList = [1];
-AO.DCCT.Status = [1];
-
-AO.DCCT.Monitor.Mode = Mode;
-AO.DCCT.Monitor.DataType = 'Scalar';
-AO.DCCT.Monitor.ChannelNames = 'SR11BCM01:CURRENT_MONITOR';
-AO.DCCT.Monitor.Units = 'Hardware';
-AO.DCCT.Monitor.HWUnits = 'milli-ampere';
-AO.DCCT.Monitor.PhysicsUnits = 'ampere';
-AO.DCCT.Monitor.HW2PhysicsParams = 1e-3;
-AO.DCCT.Monitor.Physics2HWParams = 1000;
-
-
-% %==================
-% %Machine Parameters
-% %==================
-% Removed in this version, see pervious version for more info
-
-%======
-%Septum
-%======
-% ifam=ifam+1;
-% AO.Septum.FamilyName = 'Septum'; dispobject(AO,AO.Septum.FamilyName);
-% AO.Septum.MemberOf = {'Injection'};
-% AO.Septum.Status = 1;
-%
-% AO.Septum.CommonNames = 'Septum ';
-% AO.Septum.DeviceList = [3 1];
-% AO.Septum.ElementList = [1];
-%
-% AO.Septum.Monitor.Mode = Mode;
-% AO.Septum.Monitor.DataType = 'Scalar';
-% AO.Septum.Monitor.Units = 'Hardware';
-% AO.Septum.Monitor.HWUnits = 'ampere';
-% AO.Septum.Monitor.PhysicsUnits = 'radian';
-% AO.Septum.Monitor.ChannelNames = 'BTS-B9V:Curr';
-%
-% AO.Septum.Setpoint.Mode = Mode;
-% AO.Septum.Setpoint.DataType = 'Scalar';
-% AO.Septum.Setpoint.Units = 'Hardware';
-% AO.Septum.Setpoint.HWUnits = 'ampere';
-% AO.Septum.Setpoint.PhysicsUnits = 'radian';
-% AO.Septum.Setpoint.ChannelNames = 'BTS-B9V:CurrSetpt';
-% AO.Septum.Setpoint.Range = [0, 2500];
-% AO.Septum.Setpoint.Tolerance = 100.0;
-%
-% AO.Septum.Monitor.HW2PhysicsParams = 1;
-% AO.Septum.Monitor.Physics2HWParams = 1;
-% AO.Septum.Setpoint.HW2PhysicsParams = 1;
-% AO.Septum.Setpoint.Physics2HWParams = 1;
-
-
-%====================
-%Photon Beamline Data
-%====================
-% >> removed >> see previous versions if info needed
-
-%====================
-%BPLD Data
-%====================
-% >> removed >> see previous versions if info needed
-
-
-
-% The operational mode sets the path, filenames, and other important parameters
-% Run setoperationalmode after most of the AO is built so that the Units and Mode fields
-% can be set in setoperationalmode
-fprintf('\n');
-setao(AO);
-setoperationalmode(OperationalMode);
-AO = getao;
-
-
-%%%%%%%%%%%%%%%%
-% DeltaRespMat %
-%%%%%%%%%%%%%%%%
-
-% I remove the physics2hw conversion because the physics2hw is
-% is calibrated yet.
-
-% Set response matrix kick size in hardware units (amps)
-AO.HCM.Setpoint.DeltaRespMat = physics2hw('HCM', 'Setpoint', 2.0e-4*.6, AO.HCM.DeviceList);
-AO.VCM.Setpoint.DeltaRespMat = physics2hw('VCM', 'Setpoint', 1.0e-4*.6, AO.VCM.DeviceList);
-
-%% 'NoEnergyScaling' because I don't want to force a BEND magnet read at this point
-%AO.HCM.Setpoint.DeltaRespMat = mm2amps('HCM', .5, AO.HCM.DeviceList, 'NoEnergyScaling');
-%AO.VCM.Setpoint.DeltaRespMat = mm2amps('VCM', .5, AO.VCM.DeviceList, 'NoEnergyScaling');
-
-
-AO.QFA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFA.FamilyName, 'Setpoint', AO.QFA.Setpoint.DeltaRespMat, AO.QFA.DeviceList);
-AO.QFB.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFB.FamilyName, 'Setpoint', AO.QFB.Setpoint.DeltaRespMat, AO.QFB.DeviceList);
-AO.QDA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QDA.FamilyName, 'Setpoint', AO.QDA.Setpoint.DeltaRespMat, AO.QDA.DeviceList);
-
-
-AO.SFA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFA.FamilyName, 'Setpoint', AO.SFA.Setpoint.DeltaRespMat, AO.SFA.DeviceList);
-AO.SFB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFB.FamilyName, 'Setpoint', AO.SFB.Setpoint.DeltaRespMat, AO.SFB.DeviceList);
-AO.SDA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDA.FamilyName, 'Setpoint', AO.SDA.Setpoint.DeltaRespMat, AO.SDA.DeviceList);
-AO.SDB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDB.FamilyName, 'Setpoint', AO.SDB.Setpoint.DeltaRespMat, AO.SDB.DeviceList);
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get S-positions [meters] %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Using ...ATIndex(:,1) will accomodata for split elements where the first
-% of a group of elements is put in the first column ie, if SFA is split in
-% two then ATIndex will look like [2 3; 11 12; ...] where each row is a
-% magnet and column represents each split.
-global THERING
-AO.BPMx.Position = findspos(THERING, AO.BPMx.AT.ATIndex(:,1))';
-AO.BPMy.Position = findspos(THERING, AO.BPMy.AT.ATIndex(:,1))';
-AO.HCM.Position = findspos(THERING, AO.HCM.AT.ATIndex(:,1))';
-AO.VCM.Position = findspos(THERING, AO.VCM.AT.ATIndex(:,1))';
-AO.QFA.Position = findspos(THERING, AO.QFA.AT.ATIndex(:,1))';
-AO.QDA.Position = findspos(THERING, AO.QDA.AT.ATIndex(:,1))';
-AO.QFB.Position = findspos(THERING, AO.QFB.AT.ATIndex(:,1))';
-AO.SFA.Position = findspos(THERING, AO.SFA.AT.ATIndex(:,1))';
-AO.SFB.Position = findspos(THERING, AO.SFB.AT.ATIndex(:,1))';
-AO.SDA.Position = findspos(THERING, AO.SDA.AT.ATIndex(:,1))';
-AO.SDB.Position = findspos(THERING, AO.SDB.AT.ATIndex(:,1))';
-AO.SKQ.Position = findspos(THERING, AO.SKQ.AT.ATIndex(:,1))';
-AO.BEND.Position = findspos(THERING, AO.BEND.AT.ATIndex(:,1))';
-AO.RF.Position = findspos(THERING, AO.RF.AT.ATIndex(:,1))';
-AO.KICK.Position = findspos(THERING, AO.KICK.AT.ATIndex(:,1))';
-AO.DCCT.Position = 0;
-AO.TUNE.Position = 0;
-
-
-% Save AO
-setao(AO);
-
-
-function dispobject(AO,name)
-
-n = length(fieldnames(AO));
-
-if n > 0
- fprintf(' %10s ',name);
- if mod(n,5) == 0
- fprintf('\n');
- end
-end
\ No newline at end of file
+function aspinit(OperationalMode)
+% aspinit(OperationalMode)
+%
+% Initialize parameters for ASP control in MATLAB
+%
+%==========================
+% Accelerator Family Fields
+%==========================
+% FamilyName BPMx, HCM, etc
+% CommonNames Shortcut name for each element (optional)
+% DeviceList [Sector, Number]
+% ElementList number in list
+% Position m, magnet center
+%
+% MONITOR FIELDS
+% Mode online/manual/special/simulator
+% ChannelNames PV for monitor
+% Units Physics or HW
+% HW2PhysicsFcn function handle used to convert from hardware to physics units ==> inline will not compile, see below
+% HW2PhysicsParams parameters used for conversion function
+% Physics2HWFcn function handle used to convert from physics to hardware units
+% Physics2HWParams parameters used for conversion function
+% HWUnits units for Hardware 'ampere';
+% PhysicsUnits units for physics 'Rad';
+%
+% SETPOINT FIELDS
+% Mode online/manual/special/simulator
+% ChannelNames PV for monitor
+% Units hardware or physics
+% HW2PhysicsFcn function handle used to convert from hardware to physics units
+% HW2PhysicsParams parameters used for conversion function
+% Physics2HWFcn function handle used to convert from physics to hardware units
+% Physics2HWParams parameters used for conversion function
+% HWUnits units for Hardware 'ampere';
+% PhysicsUnits units for physics 'Rad';
+% Range minsetpoint, maxsetpoint;
+% Tolerance setpoint-monitor
+%
+%=============================================
+% Accelerator Toolbox Simulation Fields
+%=============================================
+% ATType Quad, Sext, etc
+% ATIndex index in THERING
+% ATParameterGroup parameter group
+%
+%============
+% Family List
+%============
+% BPMx BPMy - beam position monitors
+% HCM VCM - corrector magnets wound into sextupoles
+% HFC VFC - fast corrector magnets wound into sextupoles (FOFB)
+% BEND - gradient dipoles
+% QFA QDA QFB - quadrupole magnets
+% SFA SDA SDB SFB - sextupole magnets
+% SQK - skew quads wound into SDA magnets
+% KICK - injection kickers (DELTA type)
+% RF - 4 cavities (KEK type?)
+% DCCT
+% Septum (Not in model yet)
+%
+% Normal cell: d1 bpm s1 hcor d2 q1 d3 s2 d4 bpm dip bpm d4 hcor s3 d5 q2 d6 q3 d2 bpm s4
+% d2 q3 d6 q2 d5 s3 hcor d4 bpm dip bpm d4 s2 d3 q1 d2 hcor s1 bpm d1
+
+% === Change Log ===
+% Mark Boland 2004-02-12
+% Eugene Tan 2004-02-23
+% Eugene Tan 2004-12-13
+% Eugene Tan 2005-09-27 ver 4
+% Updated naming convention of the process variables, use version 4 of
+% the lattice "assr4.m" where the correctors have been merged into the
+% sextupoles. Made the necessary changes to updateatindex. Added skew
+% quadrupoles and updated generate_init.
+% Mark Boland 2006-05-27
+% Changed the BPM PVs to ...:SA_X_MONITOR and ...:SA_Y_MONITOR
+%
+% Mark Boland 2006-08-29
+% Changed range on HCM and VCM from - to + since the polarity of the
+% correctors was physically changed in the last weeks.
+% Eugene Tan 2015-09-07
+% Set sensible limits/Range for RF frequency and voltages.
+% Eugene Tan 2015-10-15
+% Added FOFB's HFC and VFC magnets
+
+% === Still to do ===
+% - kicker delays
+% - BPM names and other possible PVs of interest eg. Q factor etc.
+% - clean up and configure the amp2k and k2amp conversion. Control system
+% designed to calculate the strengths and amp values using calc records,
+% therefore we should only need to change the PV name to access for
+% readback at setpoints. Only problem will be in simulation/offline mode
+% where those value are not available online. How do you keep the offline
+% conversion factors up to date with online vals?
+%
+% === Generated from ===
+% aspinit_v5skeleton.m
+
+
+
+% When using the compiler add a line like, "%#function " for
+% for special functions that hidden in strings.
+
+
+% Default operational mode
+if nargin < 1
+ OperationalMode = 2;
+end
+
+
+%=============================================
+% START DEFINITION OF ACCELERATOR OBJECTS
+%=============================================
+fprintf(' Defining the Accelerator Objects. Objects being defined:\n')
+
+
+% Clear previous AcceleratorObjects
+setao([]);
+
+
+Mode = 'Online'; % This gets reset in setoperationalmode
+
+%=============================================
+%BPM data: status field designates if BPM in use
+%=============================================
+ntbpm=98;
+AO.BPMx.FamilyName = 'BPMx'; dispobject(AO,AO.BPMx.FamilyName);
+AO.BPMx.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'; 'BPMx'; 'Horizontal';};
+AO.BPMx.Monitor.Mode = Mode;
+AO.BPMx.Monitor.DataType = 'Scalar';
+AO.BPMx.Monitor.Units = 'Hardware';
+AO.BPMx.Monitor.HWUnits = 'nm';
+AO.BPMx.Monitor.PhysicsUnits = 'meter';
+
+AO.BPMy.FamilyName = 'BPMy'; dispobject(AO,AO.BPMy.FamilyName);
+AO.BPMy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'; 'BPMy'; 'Vertical';};
+AO.BPMy.Monitor.Mode = Mode;
+AO.BPMy.Monitor.DataType = 'Scalar';
+AO.BPMy.Monitor.Units = 'Hardware';
+AO.BPMy.Monitor.HWUnits = 'nm';
+AO.BPMy.Monitor.PhysicsUnits = 'meter';
+
+% x-name x-chname xstat y-name y-chname ystat DevList Elem
+bpm={
+'1BPMx1 ' 'SR01BPM01:SA_X_MONITOR' 1 '1BPMy1 ' 'SR01BPM01:SA_Y_MONITOR' 1 [1,1] 1 ; ...
+'1BPMx2 ' 'SR01BPM02:SA_X_MONITOR' 1 '1BPMy2 ' 'SR01BPM02:SA_Y_MONITOR' 1 [1,2] 2 ; ...
+'1BPMx3 ' 'SR01BPM03:SA_X_MONITOR' 1 '1BPMy3 ' 'SR01BPM03:SA_Y_MONITOR' 1 [1,3] 3 ; ...
+'1BPMx4 ' 'SR01BPM04:SA_X_MONITOR' 1 '1BPMy4 ' 'SR01BPM04:SA_Y_MONITOR' 1 [1,4] 4 ; ...
+'1BPMx5 ' 'SR01BPM05:SA_X_MONITOR' 1 '1BPMy5 ' 'SR01BPM05:SA_Y_MONITOR' 1 [1,5] 5 ; ...
+'1BPMx6 ' 'SR01BPM06:SA_X_MONITOR' 1 '1BPMy6 ' 'SR01BPM06:SA_Y_MONITOR' 1 [1,6] 6 ; ...
+'1BPMx7 ' 'SR01BPM07:SA_X_MONITOR' 1 '1BPMy7 ' 'SR01BPM07:SA_Y_MONITOR' 1 [1,7] 7 ; ...
+'2BPMx1 ' 'SR02BPM01:SA_X_MONITOR' 1 '2BPMy1 ' 'SR02BPM01:SA_Y_MONITOR' 1 [2,1] 8 ; ...
+'2BPMx2 ' 'SR02BPM02:SA_X_MONITOR' 1 '2BPMy2 ' 'SR02BPM02:SA_Y_MONITOR' 1 [2,2] 9 ; ...
+'2BPMx3 ' 'SR02BPM03:SA_X_MONITOR' 1 '2BPMy3 ' 'SR02BPM03:SA_Y_MONITOR' 1 [2,3] 10 ; ...
+'2BPMx4 ' 'SR02BPM04:SA_X_MONITOR' 1 '2BPMy4 ' 'SR02BPM04:SA_Y_MONITOR' 1 [2,4] 11 ; ...
+'2BPMx5 ' 'SR02BPM05:SA_X_MONITOR' 1 '2BPMy5 ' 'SR02BPM05:SA_Y_MONITOR' 1 [2,5] 12 ; ...
+'2BPMx6 ' 'SR02BPM06:SA_X_MONITOR' 1 '2BPMy6 ' 'SR02BPM06:SA_Y_MONITOR' 1 [2,6] 13 ; ...
+'2BPMx7 ' 'SR02BPM07:SA_X_MONITOR' 1 '2BPMy7 ' 'SR02BPM07:SA_Y_MONITOR' 1 [2,7] 14 ; ...
+'3BPMx1 ' 'SR03BPM01:SA_X_MONITOR' 1 '3BPMy1 ' 'SR03BPM01:SA_Y_MONITOR' 1 [3,1] 15 ; ...
+'3BPMx2 ' 'SR03BPM02:SA_X_MONITOR' 1 '3BPMy2 ' 'SR03BPM02:SA_Y_MONITOR' 1 [3,2] 16 ; ...
+'3BPMx3 ' 'SR03BPM03:SA_X_MONITOR' 1 '3BPMy3 ' 'SR03BPM03:SA_Y_MONITOR' 1 [3,3] 17 ; ...
+'3BPMx4 ' 'SR03BPM04:SA_X_MONITOR' 1 '3BPMy4 ' 'SR03BPM04:SA_Y_MONITOR' 1 [3,4] 18 ; ...
+'3BPMx5 ' 'SR03BPM05:SA_X_MONITOR' 1 '3BPMy5 ' 'SR03BPM05:SA_Y_MONITOR' 1 [3,5] 19 ; ...
+'3BPMx6 ' 'SR03BPM06:SA_X_MONITOR' 1 '3BPMy6 ' 'SR03BPM06:SA_Y_MONITOR' 1 [3,6] 20 ; ...
+'3BPMx7 ' 'SR03BPM07:SA_X_MONITOR' 1 '3BPMy7 ' 'SR03BPM07:SA_Y_MONITOR' 1 [3,7] 21 ; ...
+'4BPMx1 ' 'SR04BPM01:SA_X_MONITOR' 1 '4BPMy1 ' 'SR04BPM01:SA_Y_MONITOR' 1 [4,1] 22 ; ...
+'4BPMx2 ' 'SR04BPM02:SA_X_MONITOR' 1 '4BPMy2 ' 'SR04BPM02:SA_Y_MONITOR' 1 [4,2] 23 ; ...
+'4BPMx3 ' 'SR04BPM03:SA_X_MONITOR' 1 '4BPMy3 ' 'SR04BPM03:SA_Y_MONITOR' 1 [4,3] 24 ; ...
+'4BPMx4 ' 'SR04BPM04:SA_X_MONITOR' 1 '4BPMy4 ' 'SR04BPM04:SA_Y_MONITOR' 1 [4,4] 25 ; ...
+'4BPMx5 ' 'SR04BPM05:SA_X_MONITOR' 1 '4BPMy5 ' 'SR04BPM05:SA_Y_MONITOR' 1 [4,5] 26 ; ...
+'4BPMx6 ' 'SR04BPM06:SA_X_MONITOR' 1 '4BPMy6 ' 'SR04BPM06:SA_Y_MONITOR' 1 [4,6] 27 ; ...
+'4BPMx7 ' 'SR04BPM07:SA_X_MONITOR' 1 '4BPMy7 ' 'SR04BPM07:SA_Y_MONITOR' 1 [4,7] 28 ; ...
+'5BPMx1 ' 'SR05BPM01:SA_X_MONITOR' 1 '5BPMy1 ' 'SR05BPM01:SA_Y_MONITOR' 1 [5,1] 29 ; ...
+'5BPMx2 ' 'SR05BPM02:SA_X_MONITOR' 1 '5BPMy2 ' 'SR05BPM02:SA_Y_MONITOR' 1 [5,2] 30 ; ...
+'5BPMx3 ' 'SR05BPM03:SA_X_MONITOR' 1 '5BPMy3 ' 'SR05BPM03:SA_Y_MONITOR' 1 [5,3] 31 ; ...
+'5BPMx4 ' 'SR05BPM04:SA_X_MONITOR' 1 '5BPMy4 ' 'SR05BPM04:SA_Y_MONITOR' 1 [5,4] 32 ; ...
+'5BPMx5 ' 'SR05BPM05:SA_X_MONITOR' 1 '5BPMy5 ' 'SR05BPM05:SA_Y_MONITOR' 1 [5,5] 33 ; ...
+'5BPMx6 ' 'SR05BPM06:SA_X_MONITOR' 1 '5BPMy6 ' 'SR05BPM06:SA_Y_MONITOR' 1 [5,6] 34 ; ...
+'5BPMx7 ' 'SR05BPM07:SA_X_MONITOR' 1 '5BPMy7 ' 'SR05BPM07:SA_Y_MONITOR' 1 [5,7] 35 ; ...
+'6BPMx1 ' 'SR06BPM01:SA_X_MONITOR' 1 '6BPMy1 ' 'SR06BPM01:SA_Y_MONITOR' 1 [6,1] 36 ; ...
+'6BPMx2 ' 'SR06BPM02:SA_X_MONITOR' 1 '6BPMy2 ' 'SR06BPM02:SA_Y_MONITOR' 1 [6,2] 37 ; ...
+'6BPMx3 ' 'SR06BPM03:SA_X_MONITOR' 1 '6BPMy3 ' 'SR06BPM03:SA_Y_MONITOR' 1 [6,3] 38 ; ...
+'6BPMx4 ' 'SR06BPM04:SA_X_MONITOR' 1 '6BPMy4 ' 'SR06BPM04:SA_Y_MONITOR' 1 [6,4] 39 ; ...
+'6BPMx5 ' 'SR06BPM05:SA_X_MONITOR' 1 '6BPMy5 ' 'SR06BPM05:SA_Y_MONITOR' 1 [6,5] 40 ; ...
+'6BPMx6 ' 'SR06BPM06:SA_X_MONITOR' 1 '6BPMy6 ' 'SR06BPM06:SA_Y_MONITOR' 1 [6,6] 41 ; ...
+'6BPMx7 ' 'SR06BPM07:SA_X_MONITOR' 1 '6BPMy7 ' 'SR06BPM07:SA_Y_MONITOR' 1 [6,7] 42 ; ...
+'7BPMx1 ' 'SR07BPM01:SA_X_MONITOR' 1 '7BPMy1 ' 'SR07BPM01:SA_Y_MONITOR' 1 [7,1] 43 ; ...
+'7BPMx2 ' 'SR07BPM02:SA_X_MONITOR' 1 '7BPMy2 ' 'SR07BPM02:SA_Y_MONITOR' 1 [7,2] 44 ; ...
+'7BPMx3 ' 'SR07BPM03:SA_X_MONITOR' 1 '7BPMy3 ' 'SR07BPM03:SA_Y_MONITOR' 1 [7,3] 45 ; ...
+'7BPMx4 ' 'SR07BPM04:SA_X_MONITOR' 1 '7BPMy4 ' 'SR07BPM04:SA_Y_MONITOR' 1 [7,4] 46 ; ...
+'7BPMx5 ' 'SR07BPM05:SA_X_MONITOR' 1 '7BPMy5 ' 'SR07BPM05:SA_Y_MONITOR' 1 [7,5] 47 ; ...
+'7BPMx6 ' 'SR07BPM06:SA_X_MONITOR' 1 '7BPMy6 ' 'SR07BPM06:SA_Y_MONITOR' 1 [7,6] 48 ; ...
+'7BPMx7 ' 'SR07BPM07:SA_X_MONITOR' 1 '7BPMy7 ' 'SR07BPM07:SA_Y_MONITOR' 1 [7,7] 49 ; ...
+'8BPMx1 ' 'SR08BPM01:SA_X_MONITOR' 1 '8BPMy1 ' 'SR08BPM01:SA_Y_MONITOR' 1 [8,1] 50 ; ...
+'8BPMx2 ' 'SR08BPM02:SA_X_MONITOR' 1 '8BPMy2 ' 'SR08BPM02:SA_Y_MONITOR' 1 [8,2] 51 ; ...
+'8BPMx3 ' 'SR08BPM03:SA_X_MONITOR' 1 '8BPMy3 ' 'SR08BPM03:SA_Y_MONITOR' 1 [8,3] 52 ; ...
+'8BPMx4 ' 'SR08BPM04:SA_X_MONITOR' 1 '8BPMy4 ' 'SR08BPM04:SA_Y_MONITOR' 1 [8,4] 53 ; ...
+'8BPMx5 ' 'SR08BPM05:SA_X_MONITOR' 1 '8BPMy5 ' 'SR08BPM05:SA_Y_MONITOR' 1 [8,5] 54 ; ...
+'8BPMx6 ' 'SR08BPM06:SA_X_MONITOR' 1 '8BPMy6 ' 'SR08BPM06:SA_Y_MONITOR' 1 [8,6] 55 ; ...
+'8BPMx7 ' 'SR08BPM07:SA_X_MONITOR' 1 '8BPMy7 ' 'SR08BPM07:SA_Y_MONITOR' 1 [8,7] 56 ; ...
+'9BPMx1 ' 'SR09BPM01:SA_X_MONITOR' 1 '9BPMy1 ' 'SR09BPM01:SA_Y_MONITOR' 1 [9,1] 57 ; ...
+'9BPMx2 ' 'SR09BPM02:SA_X_MONITOR' 1 '9BPMy2 ' 'SR09BPM02:SA_Y_MONITOR' 1 [9,2] 58 ; ...
+'9BPMx3 ' 'SR09BPM03:SA_X_MONITOR' 1 '9BPMy3 ' 'SR09BPM03:SA_Y_MONITOR' 1 [9,3] 59 ; ...
+'9BPMx4 ' 'SR09BPM04:SA_X_MONITOR' 1 '9BPMy4 ' 'SR09BPM04:SA_Y_MONITOR' 1 [9,4] 60 ; ...
+'9BPMx5 ' 'SR09BPM05:SA_X_MONITOR' 1 '9BPMy5 ' 'SR09BPM05:SA_Y_MONITOR' 1 [9,5] 61 ; ...
+'9BPMx6 ' 'SR09BPM06:SA_X_MONITOR' 1 '9BPMy6 ' 'SR09BPM06:SA_Y_MONITOR' 1 [9,6] 62 ; ...
+'9BPMx7 ' 'SR09BPM07:SA_X_MONITOR' 1 '9BPMy7 ' 'SR09BPM07:SA_Y_MONITOR' 1 [9,7] 63 ; ...
+'10BPMx1 ' 'SR10BPM01:SA_X_MONITOR' 1 '10BPMy1 ' 'SR10BPM01:SA_Y_MONITOR' 1 [10,1] 64 ; ...
+'10BPMx2 ' 'SR10BPM02:SA_X_MONITOR' 1 '10BPMy2 ' 'SR10BPM02:SA_Y_MONITOR' 1 [10,2] 65 ; ...
+'10BPMx3 ' 'SR10BPM03:SA_X_MONITOR' 1 '10BPMy3 ' 'SR10BPM03:SA_Y_MONITOR' 1 [10,3] 66 ; ...
+'10BPMx4 ' 'SR10BPM04:SA_X_MONITOR' 1 '10BPMy4 ' 'SR10BPM04:SA_Y_MONITOR' 1 [10,4] 67 ; ...
+'10BPMx5 ' 'SR10BPM05:SA_X_MONITOR' 1 '10BPMy5 ' 'SR10BPM05:SA_Y_MONITOR' 1 [10,5] 68 ; ...
+'10BPMx6 ' 'SR10BPM06:SA_X_MONITOR' 1 '10BPMy6 ' 'SR10BPM06:SA_Y_MONITOR' 1 [10,6] 69 ; ...
+'10BPMx7 ' 'SR10BPM07:SA_X_MONITOR' 1 '10BPMy7 ' 'SR10BPM07:SA_Y_MONITOR' 1 [10,7] 70 ; ...
+'11BPMx1 ' 'SR11BPM01:SA_X_MONITOR' 1 '11BPMy1 ' 'SR11BPM01:SA_Y_MONITOR' 1 [11,1] 71 ; ...
+'11BPMx2 ' 'SR11BPM02:SA_X_MONITOR' 1 '11BPMy2 ' 'SR11BPM02:SA_Y_MONITOR' 1 [11,2] 72 ; ...
+'11BPMx3 ' 'SR11BPM03:SA_X_MONITOR' 1 '11BPMy3 ' 'SR11BPM03:SA_Y_MONITOR' 1 [11,3] 73 ; ...
+'11BPMx4 ' 'SR11BPM04:SA_X_MONITOR' 1 '11BPMy4 ' 'SR11BPM04:SA_Y_MONITOR' 1 [11,4] 74 ; ...
+'11BPMx5 ' 'SR11BPM05:SA_X_MONITOR' 1 '11BPMy5 ' 'SR11BPM05:SA_Y_MONITOR' 1 [11,5] 75 ; ...
+'11BPMx6 ' 'SR11BPM06:SA_X_MONITOR' 1 '11BPMy6 ' 'SR11BPM06:SA_Y_MONITOR' 1 [11,6] 76 ; ...
+'11BPMx7 ' 'SR11BPM07:SA_X_MONITOR' 1 '11BPMy7 ' 'SR11BPM07:SA_Y_MONITOR' 1 [11,7] 77 ; ...
+'12BPMx1 ' 'SR12BPM01:SA_X_MONITOR' 1 '12BPMy1 ' 'SR12BPM01:SA_Y_MONITOR' 1 [12,1] 78 ; ...
+'12BPMx2 ' 'SR12BPM02:SA_X_MONITOR' 1 '12BPMy2 ' 'SR12BPM02:SA_Y_MONITOR' 1 [12,2] 79 ; ...
+'12BPMx3 ' 'SR12BPM03:SA_X_MONITOR' 1 '12BPMy3 ' 'SR12BPM03:SA_Y_MONITOR' 1 [12,3] 80 ; ...
+'12BPMx4 ' 'SR12BPM04:SA_X_MONITOR' 1 '12BPMy4 ' 'SR12BPM04:SA_Y_MONITOR' 1 [12,4] 81 ; ...
+'12BPMx5 ' 'SR12BPM05:SA_X_MONITOR' 1 '12BPMy5 ' 'SR12BPM05:SA_Y_MONITOR' 1 [12,5] 82 ; ...
+'12BPMx6 ' 'SR12BPM06:SA_X_MONITOR' 1 '12BPMy6 ' 'SR12BPM06:SA_Y_MONITOR' 1 [12,6] 83 ; ...
+'12BPMx7 ' 'SR12BPM07:SA_X_MONITOR' 1 '12BPMy7 ' 'SR12BPM07:SA_Y_MONITOR' 1 [12,7] 84 ; ...
+'13BPMx1 ' 'SR13BPM01:SA_X_MONITOR' 1 '13BPMy1 ' 'SR13BPM01:SA_Y_MONITOR' 1 [13,1] 85 ; ...
+'13BPMx2 ' 'SR13BPM02:SA_X_MONITOR' 1 '13BPMy2 ' 'SR13BPM02:SA_Y_MONITOR' 1 [13,2] 86 ; ...
+'13BPMx3 ' 'SR13BPM03:SA_X_MONITOR' 1 '13BPMy3 ' 'SR13BPM03:SA_Y_MONITOR' 1 [13,3] 87 ; ...
+'13BPMx4 ' 'SR13BPM04:SA_X_MONITOR' 1 '13BPMy4 ' 'SR13BPM04:SA_Y_MONITOR' 1 [13,4] 88 ; ...
+'13BPMx5 ' 'SR13BPM05:SA_X_MONITOR' 1 '13BPMy5 ' 'SR13BPM05:SA_Y_MONITOR' 1 [13,5] 89 ; ...
+'13BPMx6 ' 'SR13BPM06:SA_X_MONITOR' 1 '13BPMy6 ' 'SR13BPM06:SA_Y_MONITOR' 1 [13,6] 90 ; ...
+'13BPMx7 ' 'SR13BPM07:SA_X_MONITOR' 1 '13BPMy7 ' 'SR13BPM07:SA_Y_MONITOR' 1 [13,7] 91 ; ...
+'14BPMx1 ' 'SR14BPM01:SA_X_MONITOR' 1 '14BPMy1 ' 'SR14BPM01:SA_Y_MONITOR' 1 [14,1] 92 ; ...
+'14BPMx2 ' 'SR14BPM02:SA_X_MONITOR' 1 '14BPMy2 ' 'SR14BPM02:SA_Y_MONITOR' 1 [14,2] 93 ; ...
+'14BPMx3 ' 'SR14BPM03:SA_X_MONITOR' 1 '14BPMy3 ' 'SR14BPM03:SA_Y_MONITOR' 1 [14,3] 94 ; ...
+'14BPMx4 ' 'SR14BPM04:SA_X_MONITOR' 1 '14BPMy4 ' 'SR14BPM04:SA_Y_MONITOR' 1 [14,4] 95 ; ...
+'14BPMx5 ' 'SR14BPM05:SA_X_MONITOR' 1 '14BPMy5 ' 'SR14BPM05:SA_Y_MONITOR' 1 [14,5] 96 ; ...
+'14BPMx6 ' 'SR14BPM06:SA_X_MONITOR' 1 '14BPMy6 ' 'SR14BPM06:SA_Y_MONITOR' 1 [14,6] 97 ; ...
+'14BPMx7 ' 'SR14BPM07:SA_X_MONITOR' 1 '14BPMy7 ' 'SR14BPM07:SA_Y_MONITOR' 1 [14,7] 98 ; ...
+};
+% 'diag ' 'SR15BPM01:SA_X_MONITOR' 0 'diag ' 'SR15BPM01:SA_Y_MONITOR' 0 [-1,-1] 99 ; ...
+%'14BPMx7 ' 'SR01BPM08:SA_X_MONITOR' 1 '14BPMy7 ' 'SR01BPM08:SA_Y_MONITOR' 1 [14,7] 98 ; ...
+%'14BPMx7 ' 'SR14BPM07:SA_X_MONITOR' 1 '14BPMy7 ' 'SR14BPM07:SA_Y_MONITOR' 1 [14,7] 98 ; ...
+
+% NOTE: BPM [-1 -1] IS A DIAGNOSTIC BPM AND IS NOT TO BE PUT IN SERVICE. NOT
+% PART OF ORBIT CORRECTION ETC. AND NOT IN THE MODEL PER SE. ET 18/11/2008
+
+%Load fields from data block
+for ii=1:size(bpm,1)
+name=bpm{ii,1}; AO.BPMx.CommonNames(ii,:) = name;
+name=bpm{ii,2}; AO.BPMx.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,3}; AO.BPMx.Status(ii,:) = val;
+name=bpm{ii,4}; AO.BPMy.CommonNames(ii,:) = name;
+name=bpm{ii,5}; AO.BPMy.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,6}; AO.BPMy.Status(ii,:) = val;
+val =bpm{ii,7}; AO.BPMx.DeviceList(ii,:) = val;
+ AO.BPMy.DeviceList(ii,:) = val;
+val =bpm{ii,8}; AO.BPMx.ElementList(ii,:) = val;
+ AO.BPMy.ElementList(ii,:) = val;
+ AO.BPMx.Monitor.HW2PhysicsParams(ii,:) = 1e-9;
+ AO.BPMx.Monitor.Physics2HWParams(ii,:) = 1e+9;
+ AO.BPMy.Monitor.HW2PhysicsParams(ii,:) = 1e-9;
+ AO.BPMy.Monitor.Physics2HWParams(ii,:) = 1e+9;
+ % Placeholder for setting software offsets
+ AO.BPMx.Monitor.Offset(ii,:) = 0;
+ AO.BPMy.Monitor.Offset(ii,:) = 0;
+end
+
+
+% % Get sum value from button. Don't need handles and PV namelist as
+% % parameters are the same as the 'monitor' subcategory.
+% AO.BPMx.Sum.Monitor = AO.BPMx.Monitor;
+% AO.BPMx.Sum.SpecialFunction = 'getbpmsumspear';
+% AO.BPMx.Sum.HWUnits = 'ADC Counts';
+% AO.BPMx.Sum.PhysicsUnits = 'ADC Counts';
+% AO.BPMx.Sum.HW2PhysicsParams = 1;
+% AO.BPMx.Sum.Physics2HWParams = 1;
+% % Get q value from BPMs. Don't need handles and PV namelist.
+% AO.BPMx.Q = AO.BPMx.Monitor;
+% AO.BPMx.Q.SpecialFunction = 'getbpmqspear';
+% AO.BPMx.Q.HWUnits = 'mm';
+% AO.BPMx.Q.PhysicsUnits = 'meter';
+% AO.BPMx.Q.HW2PhysicsParams = 1e-3;
+% AO.BPMx.Q.Physics2HWParams = 1000;
+%
+% % Definition above for horiz0ontal. Replicate for vertical.
+% AO.BPMy.Sum = AO.BPMx.Sum;
+% AO.BPMy.Q = AO.BPMx.Q;
+
+%===========================================================
+% Corrector data: status field designates if corrector in use
+% ASP corrector coils wound into sextupoles. Not dynamic correctors.
+%===========================================================
+
+AO.HCM.FamilyName = 'HCM'; dispobject(AO,AO.HCM.FamilyName);
+AO.HCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'HCM'; 'Magnet'; 'Horizontal'};
+
+AO.HCM.Monitor.Mode = Mode;
+AO.HCM.Monitor.DataType = 'Scalar';
+AO.HCM.Monitor.Units = 'Hardware';
+AO.HCM.Monitor.HWUnits = 'ampere';
+AO.HCM.Monitor.PhysicsUnits = 'radian';
+AO.HCM.Monitor.HW2PhysicsFcn = @amp2k;
+AO.HCM.Monitor.Physics2HWFcn = @k2amp;
+
+AO.HCM.Setpoint.Mode = Mode;
+AO.HCM.Setpoint.DataType = 'Scalar';
+AO.HCM.Setpoint.Units = 'Hardware';
+AO.HCM.Setpoint.HWUnits = 'ampere';
+AO.HCM.Setpoint.PhysicsUnits = 'radian';
+AO.HCM.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.HCM.Setpoint.Physics2HWFcn = @k2amp;
+
+% HW in ampere, Physics in radian. Respmat settings below AO definitions.
+% x-common x-monitor x-setpoint stat devlist elem tol
+cor={
+'1HCM1 ' 'SR01CPS01:CURRENT_MONITOR' 'SR01CPS01:BASE_CURRENT_SP ' 1 [1,1] 1 0.1 ; ...
+'1HCM2 ' 'SR01CPS05:CURRENT_MONITOR' 'SR01CPS05:BASE_CURRENT_SP ' 1 [1,2] 2 0.1 ; ...
+'1HCM3 ' 'SR01CPS09:CURRENT_MONITOR' 'SR01CPS09:BASE_CURRENT_SP ' 1 [1,3] 3 0.1 ; ...
+'2HCM1 ' 'SR02CPS01:CURRENT_MONITOR' 'SR02CPS01:BASE_CURRENT_SP ' 1 [2,1] 4 0.1 ; ...
+'2HCM2 ' 'SR02CPS05:CURRENT_MONITOR' 'SR02CPS05:BASE_CURRENT_SP ' 1 [2,2] 5 0.1 ; ...
+'2HCM3 ' 'SR02CPS09:CURRENT_MONITOR' 'SR02CPS09:BASE_CURRENT_SP ' 1 [2,3] 6 0.1 ; ...
+'3HCM1 ' 'SR03CPS01:CURRENT_MONITOR' 'SR03CPS01:BASE_CURRENT_SP ' 1 [3,1] 7 0.1 ; ...
+'3HCM2 ' 'SR03CPS05:CURRENT_MONITOR' 'SR03CPS05:BASE_CURRENT_SP ' 1 [3,2] 8 0.1 ; ...
+'3HCM3 ' 'SR03CPS09:CURRENT_MONITOR' 'SR03CPS09:BASE_CURRENT_SP ' 1 [3,3] 9 0.1 ; ...
+'4HCM1 ' 'SR04CPS01:CURRENT_MONITOR' 'SR04CPS01:BASE_CURRENT_SP ' 1 [4,1] 10 0.1 ; ...
+'4HCM2 ' 'SR04CPS05:CURRENT_MONITOR' 'SR04CPS05:BASE_CURRENT_SP ' 1 [4,2] 11 0.1 ; ...
+'4HCM3 ' 'SR04CPS09:CURRENT_MONITOR' 'SR04CPS09:BASE_CURRENT_SP ' 1 [4,3] 12 0.1 ; ...
+'5HCM1 ' 'SR05CPS01:CURRENT_MONITOR' 'SR05CPS01:BASE_CURRENT_SP ' 1 [5,1] 13 0.1 ; ...
+'5HCM2 ' 'SR05CPS05:CURRENT_MONITOR' 'SR05CPS05:BASE_CURRENT_SP ' 1 [5,2] 14 0.1 ; ...
+'5HCM3 ' 'SR05CPS09:CURRENT_MONITOR' 'SR05CPS09:BASE_CURRENT_SP ' 1 [5,3] 15 0.1 ; ...
+'6HCM1 ' 'SR06CPS01:CURRENT_MONITOR' 'SR06CPS01:BASE_CURRENT_SP ' 1 [6,1] 16 0.1 ; ...
+'6HCM2 ' 'SR06CPS05:CURRENT_MONITOR' 'SR06CPS05:BASE_CURRENT_SP ' 1 [6,2] 17 0.1 ; ...
+'6HCM3 ' 'SR06CPS09:CURRENT_MONITOR' 'SR06CPS09:BASE_CURRENT_SP ' 1 [6,3] 18 0.1 ; ...
+'7HCM1 ' 'SR07CPS01:CURRENT_MONITOR' 'SR07CPS01:BASE_CURRENT_SP ' 1 [7,1] 19 0.1 ; ...
+'7HCM2 ' 'SR07CPS05:CURRENT_MONITOR' 'SR07CPS05:BASE_CURRENT_SP ' 1 [7,2] 20 0.1 ; ...
+'7HCM3 ' 'SR07CPS09:CURRENT_MONITOR' 'SR07CPS09:BASE_CURRENT_SP ' 1 [7,3] 21 0.1 ; ...
+'8HCM1 ' 'SR08CPS01:CURRENT_MONITOR' 'SR08CPS01:BASE_CURRENT_SP ' 1 [8,1] 22 0.1 ; ...
+'8HCM2 ' 'SR08CPS05:CURRENT_MONITOR' 'SR08CPS05:BASE_CURRENT_SP ' 1 [8,2] 23 0.1 ; ...
+'8HCM3 ' 'SR08CPS09:CURRENT_MONITOR' 'SR08CPS09:BASE_CURRENT_SP ' 1 [8,3] 24 0.1 ; ...
+'9HCM1 ' 'SR09CPS01:CURRENT_MONITOR' 'SR09CPS01:BASE_CURRENT_SP ' 1 [9,1] 25 0.1 ; ...
+'9HCM2 ' 'SR09CPS05:CURRENT_MONITOR' 'SR09CPS05:BASE_CURRENT_SP ' 1 [9,2] 26 0.1 ; ...
+'9HCM3 ' 'SR09CPS09:CURRENT_MONITOR' 'SR09CPS09:BASE_CURRENT_SP ' 1 [9,3] 27 0.1 ; ...
+'10HCM1 ' 'SR10CPS01:CURRENT_MONITOR' 'SR10CPS01:BASE_CURRENT_SP ' 1 [10,1] 28 0.1 ; ...
+'10HCM2 ' 'SR10CPS05:CURRENT_MONITOR' 'SR10CPS05:BASE_CURRENT_SP ' 1 [10,2] 29 0.1 ; ...
+'10HCM3 ' 'SR10CPS09:CURRENT_MONITOR' 'SR10CPS09:BASE_CURRENT_SP ' 1 [10,3] 30 0.1 ; ...
+'11HCM1 ' 'SR11CPS01:CURRENT_MONITOR' 'SR11CPS01:BASE_CURRENT_SP ' 1 [11,1] 31 0.1 ; ...
+'11HCM2 ' 'SR11CPS05:CURRENT_MONITOR' 'SR11CPS05:BASE_CURRENT_SP ' 1 [11,2] 32 0.1 ; ...
+'11HCM3 ' 'SR11CPS09:CURRENT_MONITOR' 'SR11CPS09:BASE_CURRENT_SP ' 1 [11,3] 33 0.1 ; ...
+'12HCM1 ' 'SR12CPS01:CURRENT_MONITOR' 'SR12CPS01:BASE_CURRENT_SP ' 1 [12,1] 34 0.1 ; ...
+'12HCM2 ' 'SR12CPS05:CURRENT_MONITOR' 'SR12CPS05:BASE_CURRENT_SP ' 1 [12,2] 35 0.1 ; ...
+'12HCM3 ' 'SR12CPS09:CURRENT_MONITOR' 'SR12CPS09:BASE_CURRENT_SP ' 1 [12,3] 36 0.1 ; ...
+'13HCM1 ' 'SR13CPS01:CURRENT_MONITOR' 'SR13CPS01:BASE_CURRENT_SP ' 1 [13,1] 37 0.1 ; ...
+'13HCM2 ' 'SR13CPS05:CURRENT_MONITOR' 'SR13CPS05:BASE_CURRENT_SP ' 1 [13,2] 38 0.1 ; ...
+'13HCM3 ' 'SR13CPS09:CURRENT_MONITOR' 'SR13CPS09:BASE_CURRENT_SP ' 1 [13,3] 39 0.1 ; ...
+'14HCM1 ' 'SR14CPS01:CURRENT_MONITOR' 'SR14CPS01:BASE_CURRENT_SP ' 1 [14,1] 40 0.1 ; ...
+'14HCM2 ' 'SR14CPS05:CURRENT_MONITOR' 'SR14CPS05:BASE_CURRENT_SP ' 1 [14,2] 41 0.1 ; ...
+'14HCM3 ' 'SR14CPS09:CURRENT_MONITOR' 'SR14CPS09:BASE_CURRENT_SP ' 1 [14,3] 42 0.1 ; ...
+};
+
+[C, Leff, MagnetType] = magnetcoefficients('HCM');
+
+for ii=1:size(cor,1)
+name=cor{ii,1}; AO.HCM.CommonNames(ii,:) = name;
+name=cor{ii,2}; AO.HCM.Monitor.ChannelNames(ii,:) = name;
+name=cor{ii,3}; AO.HCM.Setpoint.ChannelNames(ii,:) = name;
+val =cor{ii,4}; AO.HCM.Status(ii,1) = val;
+val =cor{ii,5}; AO.HCM.DeviceList(ii,:) = val;
+val =cor{ii,6}; AO.HCM.ElementList(ii,1) = val;
+val =cor{ii,7}; AO.HCM.Setpoint.Tolerance(ii,1) = val;
+
+AO.HCM.Setpoint.Range(ii,:) = [-90 +90];
+AO.HCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
+AO.HCM.Monitor.Physics2HWParams{1}(ii,:) = C;
+AO.HCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
+AO.HCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
+end
+
+
+AO.VCM.FamilyName = 'VCM'; dispobject(AO,AO.VCM.FamilyName);
+AO.VCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'VCM'; 'Magnet'; 'Vertical'};
+
+AO.VCM.Monitor.Mode = Mode;
+AO.VCM.Monitor.DataType = 'Scalar';
+AO.VCM.Monitor.Units = 'Hardware';
+AO.VCM.Monitor.HWUnits = 'ampere';
+AO.VCM.Monitor.PhysicsUnits = 'radian';
+AO.VCM.Monitor.HW2PhysicsFcn = @amp2k;
+AO.VCM.Monitor.Physics2HWFcn = @k2amp;
+
+AO.VCM.Setpoint.Mode = Mode;
+AO.VCM.Setpoint.DataType = 'Scalar';
+AO.VCM.Setpoint.Units = 'Hardware';
+AO.VCM.Setpoint.HWUnits = 'ampere';
+AO.VCM.Setpoint.PhysicsUnits = 'radian';
+AO.VCM.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.VCM.Setpoint.Physics2HWFcn = @k2amp;
+
+% HW in ampere, Physics in radian ** radian units converted to ampere below ***
+% y-common y-monitor y-setpoint stat devlist elem
+cor={
+'1VCM1 ' 'SR01CPS02:CURRENT_MONITOR' 'SR01CPS02:BASE_CURRENT_SP ' 1 [1,1] 1 0.2 ; ...
+'1VCM2 ' 'SR01CPS04:CURRENT_MONITOR' 'SR01CPS04:BASE_CURRENT_SP ' 1 [1,2] 2 0.2 ; ...
+'1VCM3 ' 'SR01CPS06:CURRENT_MONITOR' 'SR01CPS06:BASE_CURRENT_SP ' 1 [1,3] 3 0.2 ; ...
+'1VCM4 ' 'SR01CPS07:CURRENT_MONITOR' 'SR01CPS07:BASE_CURRENT_SP ' 1 [1,4] 4 0.2 ; ...
+'2VCM1 ' 'SR02CPS02:CURRENT_MONITOR' 'SR02CPS02:BASE_CURRENT_SP ' 1 [2,1] 5 0.2 ; ...
+'2VCM2 ' 'SR02CPS04:CURRENT_MONITOR' 'SR02CPS04:BASE_CURRENT_SP ' 1 [2,2] 6 0.2 ; ...
+'2VCM3 ' 'SR02CPS06:CURRENT_MONITOR' 'SR02CPS06:BASE_CURRENT_SP ' 1 [2,3] 7 0.2 ; ...
+'2VCM4 ' 'SR02CPS07:CURRENT_MONITOR' 'SR02CPS07:BASE_CURRENT_SP ' 1 [2,4] 8 0.2 ; ...
+'3VCM1 ' 'SR03CPS02:CURRENT_MONITOR' 'SR03CPS02:BASE_CURRENT_SP ' 1 [3,1] 9 0.2 ; ...
+'3VCM2 ' 'SR03CPS04:CURRENT_MONITOR' 'SR03CPS04:BASE_CURRENT_SP ' 1 [3,2] 10 0.2 ; ...
+'3VCM3 ' 'SR03CPS06:CURRENT_MONITOR' 'SR03CPS06:BASE_CURRENT_SP ' 1 [3,3] 11 0.2 ; ...
+'3VCM4 ' 'SR03CPS07:CURRENT_MONITOR' 'SR03CPS07:BASE_CURRENT_SP ' 1 [3,4] 12 0.2 ; ...
+'4VCM1 ' 'SR04CPS02:CURRENT_MONITOR' 'SR04CPS02:BASE_CURRENT_SP ' 1 [4,1] 13 0.2 ; ...
+'4VCM2 ' 'SR04CPS04:CURRENT_MONITOR' 'SR04CPS04:BASE_CURRENT_SP ' 1 [4,2] 14 0.2 ; ...
+'4VCM3 ' 'SR04CPS06:CURRENT_MONITOR' 'SR04CPS06:BASE_CURRENT_SP ' 1 [4,3] 15 0.2 ; ...
+'4VCM4 ' 'SR04CPS07:CURRENT_MONITOR' 'SR04CPS07:BASE_CURRENT_SP ' 1 [4,4] 16 0.2 ; ...
+'5VCM1 ' 'SR05CPS02:CURRENT_MONITOR' 'SR05CPS02:BASE_CURRENT_SP ' 1 [5,1] 17 0.2 ; ...
+'5VCM2 ' 'SR05CPS04:CURRENT_MONITOR' 'SR05CPS04:BASE_CURRENT_SP ' 1 [5,2] 18 0.2 ; ...
+'5VCM3 ' 'SR05CPS06:CURRENT_MONITOR' 'SR05CPS06:BASE_CURRENT_SP ' 1 [5,3] 19 0.2 ; ...
+'5VCM4 ' 'SR05CPS07:CURRENT_MONITOR' 'SR05CPS07:BASE_CURRENT_SP ' 1 [5,4] 20 0.2 ; ...
+'6VCM1 ' 'SR06CPS02:CURRENT_MONITOR' 'SR06CPS02:BASE_CURRENT_SP ' 1 [6,1] 21 0.2 ; ...
+'6VCM2 ' 'SR06CPS04:CURRENT_MONITOR' 'SR06CPS04:BASE_CURRENT_SP ' 1 [6,2] 22 0.2 ; ...
+'6VCM3 ' 'SR06CPS06:CURRENT_MONITOR' 'SR06CPS06:BASE_CURRENT_SP ' 1 [6,3] 23 0.2 ; ...
+'6VCM4 ' 'SR06CPS07:CURRENT_MONITOR' 'SR06CPS07:BASE_CURRENT_SP ' 1 [6,4] 24 0.2 ; ...
+'7VCM1 ' 'SR07CPS02:CURRENT_MONITOR' 'SR07CPS02:BASE_CURRENT_SP ' 1 [7,1] 25 0.2 ; ...
+'7VCM2 ' 'SR07CPS04:CURRENT_MONITOR' 'SR07CPS04:BASE_CURRENT_SP ' 1 [7,2] 26 0.2 ; ...
+'7VCM3 ' 'SR07CPS06:CURRENT_MONITOR' 'SR07CPS06:BASE_CURRENT_SP ' 1 [7,3] 27 0.2 ; ...
+'7VCM4 ' 'SR07CPS07:CURRENT_MONITOR' 'SR07CPS07:BASE_CURRENT_SP ' 1 [7,4] 28 0.2 ; ...
+'8VCM1 ' 'SR08CPS02:CURRENT_MONITOR' 'SR08CPS02:BASE_CURRENT_SP ' 1 [8,1] 29 0.2 ; ...
+'8VCM2 ' 'SR08CPS04:CURRENT_MONITOR' 'SR08CPS04:BASE_CURRENT_SP ' 1 [8,2] 30 0.2 ; ...
+'8VCM3 ' 'SR08CPS06:CURRENT_MONITOR' 'SR08CPS06:BASE_CURRENT_SP ' 1 [8,3] 31 0.2 ; ...
+'8VCM4 ' 'SR08CPS07:CURRENT_MONITOR' 'SR08CPS07:BASE_CURRENT_SP ' 1 [8,4] 32 0.2 ; ...
+'9VCM1 ' 'SR09CPS02:CURRENT_MONITOR' 'SR09CPS02:BASE_CURRENT_SP ' 1 [9,1] 33 0.2 ; ...
+'9VCM2 ' 'SR09CPS04:CURRENT_MONITOR' 'SR09CPS04:BASE_CURRENT_SP ' 1 [9,2] 34 0.2 ; ...
+'9VCM3 ' 'SR09CPS06:CURRENT_MONITOR' 'SR09CPS06:BASE_CURRENT_SP ' 1 [9,3] 35 0.2 ; ...
+'9VCM4 ' 'SR09CPS07:CURRENT_MONITOR' 'SR09CPS07:BASE_CURRENT_SP ' 1 [9,4] 36 0.2 ; ...
+'10VCM1 ' 'SR10CPS02:CURRENT_MONITOR' 'SR10CPS02:BASE_CURRENT_SP ' 1 [10,1] 37 0.2 ; ...
+'10VCM2 ' 'SR10CPS04:CURRENT_MONITOR' 'SR10CPS04:BASE_CURRENT_SP ' 1 [10,2] 38 0.2 ; ...
+'10VCM3 ' 'SR10CPS06:CURRENT_MONITOR' 'SR10CPS06:BASE_CURRENT_SP ' 1 [10,3] 39 0.2 ; ...
+'10VCM4 ' 'SR10CPS07:CURRENT_MONITOR' 'SR10CPS07:BASE_CURRENT_SP ' 1 [10,4] 40 0.2 ; ...
+'11VCM1 ' 'SR11CPS02:CURRENT_MONITOR' 'SR11CPS02:BASE_CURRENT_SP ' 1 [11,1] 41 0.2 ; ...
+'11VCM2 ' 'SR11CPS04:CURRENT_MONITOR' 'SR11CPS04:BASE_CURRENT_SP ' 1 [11,2] 42 0.2 ; ...
+'11VCM3 ' 'SR11CPS06:CURRENT_MONITOR' 'SR11CPS06:BASE_CURRENT_SP ' 1 [11,3] 43 0.2 ; ...
+'11VCM4 ' 'SR11CPS07:CURRENT_MONITOR' 'SR11CPS07:BASE_CURRENT_SP ' 1 [11,4] 44 0.2 ; ...
+'12VCM1 ' 'SR12CPS02:CURRENT_MONITOR' 'SR12CPS02:BASE_CURRENT_SP ' 1 [12,1] 45 0.2 ; ...
+'12VCM2 ' 'SR12CPS04:CURRENT_MONITOR' 'SR12CPS04:BASE_CURRENT_SP ' 1 [12,2] 46 0.2 ; ...
+'12VCM3 ' 'SR12CPS06:CURRENT_MONITOR' 'SR12CPS06:BASE_CURRENT_SP ' 1 [12,3] 47 0.2 ; ...
+'12VCM4 ' 'SR12CPS07:CURRENT_MONITOR' 'SR12CPS07:BASE_CURRENT_SP ' 1 [12,4] 48 0.2 ; ...
+'13VCM1 ' 'SR13CPS02:CURRENT_MONITOR' 'SR13CPS02:BASE_CURRENT_SP ' 1 [13,1] 49 0.2 ; ...
+'13VCM2 ' 'SR13CPS04:CURRENT_MONITOR' 'SR13CPS04:BASE_CURRENT_SP ' 1 [13,2] 50 0.2 ; ...
+'13VCM3 ' 'SR13CPS06:CURRENT_MONITOR' 'SR13CPS06:BASE_CURRENT_SP ' 1 [13,3] 51 0.2 ; ...
+'13VCM4 ' 'SR13CPS07:CURRENT_MONITOR' 'SR13CPS07:BASE_CURRENT_SP ' 1 [13,4] 52 0.2 ; ...
+'14VCM1 ' 'SR14CPS02:CURRENT_MONITOR' 'SR14CPS02:BASE_CURRENT_SP ' 1 [14,1] 53 0.2 ; ...
+'14VCM2 ' 'SR14CPS04:CURRENT_MONITOR' 'SR14CPS04:BASE_CURRENT_SP ' 1 [14,2] 54 0.2 ; ...
+'14VCM3 ' 'SR14CPS06:CURRENT_MONITOR' 'SR14CPS06:BASE_CURRENT_SP ' 1 [14,3] 55 0.2 ; ...
+'14VCM4 ' 'SR14CPS07:CURRENT_MONITOR' 'SR14CPS07:BASE_CURRENT_SP ' 1 [14,4] 56 0.3 ; ...
+};
+
+[C, Leff, MagnetType] = magnetcoefficients('VCM');
+
+for ii=1:size(cor,1)
+name=cor{ii,1}; AO.VCM.CommonNames(ii,:) = name;
+name=cor{ii,2}; AO.VCM.Monitor.ChannelNames(ii,:) = name;
+name=cor{ii,3}; AO.VCM.Setpoint.ChannelNames(ii,:) = name;
+val =cor{ii,4}; AO.VCM.Status(ii,1) = val;
+val =cor{ii,5}; AO.VCM.DeviceList(ii,:) = val;
+val =cor{ii,6}; AO.VCM.ElementList(ii,1) = val;
+val =cor{ii,7}; AO.VCM.Setpoint.Tolerance(ii,1) = val;
+
+AO.VCM.Setpoint.Range(ii,:) = [-125 +125];
+AO.VCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
+AO.VCM.Monitor.Physics2HWParams{1}(ii,:) = C;
+AO.VCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
+AO.VCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
+end
+
+% ============================
+% Fast Corrector Magnets
+% ============================
+
+AO.HFC.FamilyName = 'HFC'; dispobject(AO,AO.HFC.FamilyName);
+AO.HFC.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'HFC'; 'Magnet'; 'Horizontal'};
+
+AO.HFC.Monitor.Mode = Mode;
+AO.HFC.Monitor.DataType = 'Scalar';
+AO.HFC.Monitor.Units = 'Hardware';
+AO.HFC.Monitor.HWUnits = 'ampere';
+AO.HFC.Monitor.PhysicsUnits = 'radian';
+
+AO.HFC.Setpoint.Mode = Mode;
+AO.HFC.Setpoint.DataType = 'Scalar';
+AO.HFC.Setpoint.Units = 'Hardware';
+AO.HFC.Setpoint.HWUnits = 'ampere';
+AO.HFC.Setpoint.PhysicsUnits = 'radian';
+
+k = 16.5e-6; % rad/A
+ind = 1;
+for ii=1:14
+ for jj=1:3
+ AO.HFC.CommonNames(ind,:) = sprintf('%02dHFC%1d',ii,jj);
+ AO.HFC.Monitor.ChannelNames(ind,:) = sprintf('SR%02dHFC%02d:CURRENT_SP_MONITOR',ii,jj);
+ AO.HFC.Setpoint.ChannelNames(ind,:) = sprintf('SR%02dHFC%02d:INT_CURRENT_SP',ii,jj);
+ AO.HFC.Setpoint.Tolerance(ind,1) = 0.05; % 50 mA.
+ AO.HFC.Setpoint.Range(ind,:) = [-1 +1];
+ AO.HFC.Status(ind,1) = 1; % all good for now, will remove later
+ AO.HFC.DeviceList(ind,:) = [ii jj];
+ AO.HFC.ElementList(ind,1) = ind;
+ AO.HFC.Monitor.HW2PhysicsParams(ind,:) = k;
+ AO.HFC.Monitor.Physics2HWParams(ind,:) = 1/k;
+ AO.HFC.Setpoint.HW2PhysicsParams(ind,:) = k;
+ AO.HFC.Setpoint.Physics2HWParams(ind,:) = 1/k;
+ ind = ind+1;
+ end
+end
+
+
+AO.VFC.FamilyName = 'VFC'; dispobject(AO,AO.VFC.FamilyName);
+AO.VFC.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'VFC'; 'Magnet'; 'Horizontal'};
+
+AO.VFC.Monitor.Mode = Mode;
+AO.VFC.Monitor.DataType = 'Scalar';
+AO.VFC.Monitor.Units = 'Hardware';
+AO.VFC.Monitor.HWUnits = 'ampere';
+AO.VFC.Monitor.PhysicsUnits = 'radian';
+
+AO.VFC.Setpoint.Mode = Mode;
+AO.VFC.Setpoint.DataType = 'Scalar';
+AO.VFC.Setpoint.Units = 'Hardware';
+AO.VFC.Setpoint.HWUnits = 'ampere';
+AO.VFC.Setpoint.PhysicsUnits = 'radian';
+
+k = 10.0e-6; % rad/A
+ind = 1;
+for ii=1:14
+ for jj=1:3
+ AO.VFC.CommonNames(ind,:) = sprintf('%02dVFC%1d',ii,jj);
+ AO.VFC.Monitor.ChannelNames(ind,:) = sprintf('SR%02dVFC%02d:CURRENT_SP_MONITOR',ii,jj);
+ AO.VFC.Setpoint.ChannelNames(ind,:) = sprintf('SR%02dVFC%02d:INT_CURRENT_SP',ii,jj);
+ AO.VFC.Setpoint.Tolerance(ind,1) = 0.05; % 5 mA.
+ AO.VFC.Status(ind,1) = 1; % all good for now, will remove later
+ AO.VFC.DeviceList(ind,:) = [ii jj];
+ AO.VFC.ElementList(ind,1) = ind;
+ AO.VFC.Setpoint.Range(ind,:) = [-1 +1];
+ AO.VFC.Monitor.HW2PhysicsParams(ind,:) = k;
+ AO.VFC.Monitor.Physics2HWParams(ind,:) = 1/k;
+ AO.VFC.Setpoint.HW2PhysicsParams(ind,:) = k;
+ AO.VFC.Setpoint.Physics2HWParams(ind,:) = 1/k;
+ ind = ind+1;
+ end
+end
+
+
+%=============================
+% MAIN MAGNETS
+%=============================
+
+%===========
+%Dipole data
+%===========
+
+% *** BEND ***
+AO.BEND.FamilyName = 'BEND'; dispobject(AO,AO.BEND.FamilyName);
+AO.BEND.MemberOf = {'PlotFamily'; 'MachineConfig'; 'BEND'; 'Magnet';};
+HW2PhysicsParams = magnetcoefficients('BEND');
+Physics2HWParams = magnetcoefficients('BEND');
+
+AO.BEND.Monitor.Mode = Mode;
+AO.BEND.Monitor.DataType = 'Scalar';
+AO.BEND.Monitor.Units = 'Hardware';
+AO.BEND.Monitor.HW2PhysicsFcn = @bend2gev; % @bend2gev ???
+AO.BEND.Monitor.Physics2HWFcn = @gev2bend;
+AO.BEND.Monitor.HWUnits = 'ampere';
+AO.BEND.Monitor.PhysicsUnits = 'energy';
+
+AO.BEND.Setpoint.Mode = Mode;
+AO.BEND.Setpoint.DataType = 'Scalar';
+AO.BEND.Setpoint.Units = 'Hardware';
+AO.BEND.Setpoint.HW2PhysicsFcn = @bend2gev;
+AO.BEND.Setpoint.Physics2HWFcn = @gev2bend;
+AO.BEND.Setpoint.HWUnits = 'ampere';
+AO.BEND.Setpoint.PhysicsUnits = 'energy';
+
+% common monitor setpoint stat devlist elem scale tol
+bend={
+'1BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
+'1BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
+'2BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
+'2BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
+'3BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
+'3BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
+'4BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
+'4BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
+'5BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
+'5BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
+'6BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
+'6BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
+'7BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
+'7BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
+'8BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
+'8BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
+'9BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
+'9BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
+'10BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
+'10BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
+'11BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
+'11BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
+'12BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
+'12BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
+'13BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
+'13BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
+'14BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
+'14BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
+};
+
+for ii=1:size(bend,1)
+name=bend{ii,1}; AO.BEND.CommonNames(ii,:) = name;
+name=bend{ii,2}; AO.BEND.Monitor.ChannelNames(ii,:) = name;
+name=bend{ii,3}; AO.BEND.Setpoint.ChannelNames(ii,:) = name;
+val =bend{ii,4}; AO.BEND.Status(ii,1) = val;
+val =bend{ii,5}; AO.BEND.DeviceList(ii,:) = val;
+val =bend{ii,6}; AO.BEND.ElementList(ii,1) = val;
+val =bend{ii,7}; % This is the scale factor
+AO.BEND.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.BEND.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.BEND.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.BEND.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.BEND.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.BEND.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.BEND.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.BEND.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =bend{ii,8}; AO.BEND.Setpoint.Tolerance(ii,1) = val;
+
+AO.BEND.Setpoint.Range(ii,:) = [50 695];
+end
+
+%===============
+%Quadrupole data
+%===============
+
+% *** QFA ***
+AO.QFA.FamilyName = 'QFA'; dispobject(AO,AO.QFA.FamilyName);
+AO.QFA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
+HW2PhysicsParams = magnetcoefficients('QFA');
+Physics2HWParams = magnetcoefficients('QFA');
+
+AO.QFA.Monitor.Mode = Mode;
+AO.QFA.Monitor.DataType = 'Scalar';
+AO.QFA.Monitor.Units = 'Hardware';
+AO.QFA.Monitor.HWUnits = 'ampere';
+AO.QFA.Monitor.PhysicsUnits = 'meter^-2';
+AO.QFA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QFA.Monitor.Physics2HWFcn = @k2amp;
+
+AO.QFA.Setpoint.Mode = Mode;
+AO.QFA.Setpoint.DataType = 'Scalar';
+AO.QFA.Setpoint.Units = 'Hardware';
+AO.QFA.Setpoint.HWUnits = 'ampere';
+AO.QFA.Setpoint.PhysicsUnits = 'meter^-2';
+AO.QFA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QFA.Setpoint.Physics2HWFcn = @k2amp;
+
+% common monitor setpoint stat devlist elem scale tol
+qfa={
+'1QFA1 ' 'SR01QPS01:CURRENT_MONITOR' 'SR01QPS01:BASE_CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
+'1QFA2 ' 'SR01QPS06:CURRENT_MONITOR' 'SR01QPS06:BASE_CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
+'2QFA1 ' 'SR02QPS01:CURRENT_MONITOR' 'SR02QPS01:BASE_CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
+'2QFA2 ' 'SR02QPS06:CURRENT_MONITOR' 'SR02QPS06:BASE_CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
+'3QFA1 ' 'SR03QPS01:CURRENT_MONITOR' 'SR03QPS01:BASE_CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
+'3QFA2 ' 'SR03QPS06:CURRENT_MONITOR' 'SR03QPS06:BASE_CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
+'4QFA1 ' 'SR04QPS01:CURRENT_MONITOR' 'SR04QPS01:BASE_CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
+'4QFA2 ' 'SR04QPS06:CURRENT_MONITOR' 'SR04QPS06:BASE_CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
+'5QFA1 ' 'SR05QPS01:CURRENT_MONITOR' 'SR05QPS01:BASE_CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
+'5QFA2 ' 'SR05QPS06:CURRENT_MONITOR' 'SR05QPS06:BASE_CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
+'6QFA1 ' 'SR06QPS01:CURRENT_MONITOR' 'SR06QPS01:BASE_CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
+'6QFA2 ' 'SR06QPS06:CURRENT_MONITOR' 'SR06QPS06:BASE_CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
+'7QFA1 ' 'SR07QPS01:CURRENT_MONITOR' 'SR07QPS01:BASE_CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
+'7QFA2 ' 'SR07QPS06:CURRENT_MONITOR' 'SR07QPS06:BASE_CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
+'8QFA1 ' 'SR08QPS01:CURRENT_MONITOR' 'SR08QPS01:BASE_CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
+'8QFA2 ' 'SR08QPS06:CURRENT_MONITOR' 'SR08QPS06:BASE_CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
+'9QFA1 ' 'SR09QPS01:CURRENT_MONITOR' 'SR09QPS01:BASE_CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
+'9QFA2 ' 'SR09QPS06:CURRENT_MONITOR' 'SR09QPS06:BASE_CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
+'10QFA1 ' 'SR10QPS01:CURRENT_MONITOR' 'SR10QPS01:BASE_CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
+'10QFA2 ' 'SR10QPS06:CURRENT_MONITOR' 'SR10QPS06:BASE_CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
+'11QFA1 ' 'SR11QPS01:CURRENT_MONITOR' 'SR11QPS01:BASE_CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
+'11QFA2 ' 'SR11QPS06:CURRENT_MONITOR' 'SR11QPS06:BASE_CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
+'12QFA1 ' 'SR12QPS01:CURRENT_MONITOR' 'SR12QPS01:BASE_CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
+'12QFA2 ' 'SR12QPS06:CURRENT_MONITOR' 'SR12QPS06:BASE_CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
+'13QFA1 ' 'SR13QPS01:CURRENT_MONITOR' 'SR13QPS01:BASE_CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
+'13QFA2 ' 'SR13QPS06:CURRENT_MONITOR' 'SR13QPS06:BASE_CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
+'14QFA1 ' 'SR14QPS01:CURRENT_MONITOR' 'SR14QPS01:BASE_CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
+'14QFA2 ' 'SR14QPS06:CURRENT_MONITOR' 'SR14QPS06:BASE_CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
+};
+
+% Calculate the individual magnet scaling factors from the LOCO run below.
+%load c:/middlelayer2/middleLayer/machine/ASP/StorageRingData/User1/LOCO/2010-06-29_after_cycling_to_golden/11-22-12/locoin00.mat
+%qfascale = mean(FitParameters(end).Values(1:28))./FitParameters(end).Values(1:28)*1.006893859274983;
+
+
+
+% data = load('/asp/usr/middleLayer/machine/ASP/StorageRingData/User1/LOCO/2011-03-27/18-17-53/locoin00.mat','LocoMeasData','FitParameters');
+% qfascale =
+
+for ii=1:size(qfa,1)
+name=qfa{ii,1}; AO.QFA.CommonNames(ii,:) = name;
+name=qfa{ii,2}; AO.QFA.Monitor.ChannelNames(ii,:) = name;
+name=qfa{ii,3}; AO.QFA.Setpoint.ChannelNames(ii,:) = name;
+val =qfa{ii,4}; AO.QFA.Status(ii,1) = val;
+val =qfa{ii,5}; AO.QFA.DeviceList(ii,:) = val;
+val =qfa{ii,6}; AO.QFA.ElementList(ii,1) = val;
+val = 1;%qfascale(ii); % This is the scale factor
+AO.QFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFA.Monitor.HW2PhysicsParams{2}(ii,:) = 1/val;
+AO.QFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFA.Setpoint.HW2PhysicsParams{2}(ii,:) = 1/val;
+AO.QFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qfa{ii,8}; AO.QFA.Setpoint.Tolerance(ii,1) = val;
+
+% Important! This determines the cycling range
+AO.QFA.Setpoint.Range(ii,:) = [0 160];
+end
+
+
+% *** QDA ***
+AO.QDA.FamilyName = 'QDA'; dispobject(AO,AO.QDA.FamilyName);
+AO.QDA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QD';};
+HW2PhysicsParams = magnetcoefficients('QDA');
+Physics2HWParams = magnetcoefficients('QDA');
+
+AO.QDA.Monitor.Mode = Mode;
+AO.QDA.Monitor.DataType = 'Scalar';
+AO.QDA.Monitor.Units = 'Hardware';
+AO.QDA.Monitor.HWUnits = 'ampere';
+AO.QDA.Monitor.PhysicsUnits = 'meter^-2';
+AO.QDA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QDA.Monitor.Physics2HWFcn = @k2amp;
+
+AO.QDA.Setpoint.Mode = Mode;
+AO.QDA.Setpoint.DataType = 'Scalar';
+AO.QDA.Setpoint.Units = 'Hardware';
+AO.QDA.Setpoint.HWUnits = 'ampere';
+AO.QDA.Setpoint.PhysicsUnits = 'meter^-2';
+AO.QDA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QDA.Setpoint.Physics2HWFcn = @k2amp;
+
+% common monitor setpoint stat devlist elem scale tol
+qda={
+'1QDA1 ' 'SR01QPS02:CURRENT_MONITOR' 'SR01QPS02:BASE_CURRENT_SP ' 1 [1,1] 1 1.0 0.25 ; ...
+'1QDA2 ' 'SR01QPS05:CURRENT_MONITOR' 'SR01QPS05:BASE_CURRENT_SP ' 1 [1,2] 2 1.0 0.25 ; ...
+'2QDA1 ' 'SR02QPS02:CURRENT_MONITOR' 'SR02QPS02:BASE_CURRENT_SP ' 1 [2,1] 3 1.0 0.25 ; ...
+'2QDA2 ' 'SR02QPS05:CURRENT_MONITOR' 'SR02QPS05:BASE_CURRENT_SP ' 1 [2,2] 4 1.0 0.25 ; ...
+'3QDA1 ' 'SR03QPS02:CURRENT_MONITOR' 'SR03QPS02:BASE_CURRENT_SP ' 1 [3,1] 5 1.0 0.25 ; ...
+'3QDA2 ' 'SR03QPS05:CURRENT_MONITOR' 'SR03QPS05:BASE_CURRENT_SP ' 1 [3,2] 6 1.0 0.25 ; ...
+'4QDA1 ' 'SR04QPS02:CURRENT_MONITOR' 'SR04QPS02:BASE_CURRENT_SP ' 1 [4,1] 7 1.0 0.25 ; ...
+'4QDA2 ' 'SR04QPS05:CURRENT_MONITOR' 'SR04QPS05:BASE_CURRENT_SP ' 1 [4,2] 8 1.0 0.25 ; ...
+'5QDA1 ' 'SR05QPS02:CURRENT_MONITOR' 'SR05QPS02:BASE_CURRENT_SP ' 1 [5,1] 9 1.0 0.25 ; ...
+'5QDA2 ' 'SR05QPS05:CURRENT_MONITOR' 'SR05QPS05:BASE_CURRENT_SP ' 1 [5,2] 10 1.0 0.25 ; ...
+'6QDA1 ' 'SR06QPS02:CURRENT_MONITOR' 'SR06QPS02:BASE_CURRENT_SP ' 1 [6,1] 11 1.0 0.25 ; ...
+'6QDA2 ' 'SR06QPS05:CURRENT_MONITOR' 'SR06QPS05:BASE_CURRENT_SP ' 1 [6,2] 12 1.0 1.00 ; ...
+'7QDA1 ' 'SR07QPS02:CURRENT_MONITOR' 'SR07QPS02:BASE_CURRENT_SP ' 1 [7,1] 13 1.0 0.25 ; ...
+'7QDA2 ' 'SR07QPS05:CURRENT_MONITOR' 'SR07QPS05:BASE_CURRENT_SP ' 1 [7,2] 14 1.0 0.25 ; ...
+'8QDA1 ' 'SR08QPS02:CURRENT_MONITOR' 'SR08QPS02:BASE_CURRENT_SP ' 1 [8,1] 15 1.0 0.25 ; ...
+'8QDA2 ' 'SR08QPS05:CURRENT_MONITOR' 'SR08QPS05:BASE_CURRENT_SP ' 1 [8,2] 16 1.0 0.25 ; ...
+'9QDA1 ' 'SR09QPS02:CURRENT_MONITOR' 'SR09QPS02:BASE_CURRENT_SP ' 1 [9,1] 17 1.0 0.25 ; ...
+'9QDA2 ' 'SR09QPS05:CURRENT_MONITOR' 'SR09QPS05:BASE_CURRENT_SP ' 1 [9,2] 18 1.0 0.25 ; ...
+'10QDA1 ' 'SR10QPS02:CURRENT_MONITOR' 'SR10QPS02:BASE_CURRENT_SP ' 1 [10,1] 19 1.0 0.25 ; ...
+'10QDA2 ' 'SR10QPS05:CURRENT_MONITOR' 'SR10QPS05:BASE_CURRENT_SP ' 1 [10,2] 20 1.0 0.25 ; ...
+'11QDA1 ' 'SR11QPS02:CURRENT_MONITOR' 'SR11QPS02:BASE_CURRENT_SP ' 1 [11,1] 21 1.0 0.25 ; ...
+'11QDA2 ' 'SR11QPS05:CURRENT_MONITOR' 'SR11QPS05:BASE_CURRENT_SP ' 1 [11,2] 22 1.0 0.25 ; ...
+'12QDA1 ' 'SR12QPS02:CURRENT_MONITOR' 'SR12QPS02:BASE_CURRENT_SP ' 1 [12,1] 23 1.0 0.25 ; ...
+'12QDA2 ' 'SR12QPS05:CURRENT_MONITOR' 'SR12QPS05:BASE_CURRENT_SP ' 1 [12,2] 24 1.0 0.25 ; ...
+'13QDA1 ' 'SR13QPS02:CURRENT_MONITOR' 'SR13QPS02:BASE_CURRENT_SP ' 1 [13,1] 25 1.0 0.25 ; ...
+'13QDA2 ' 'SR13QPS05:CURRENT_MONITOR' 'SR13QPS05:BASE_CURRENT_SP ' 1 [13,2] 26 1.0 0.25 ; ...
+'14QDA1 ' 'SR14QPS02:CURRENT_MONITOR' 'SR14QPS02:BASE_CURRENT_SP ' 1 [14,1] 27 1.0 0.25 ; ...
+'14QDA2 ' 'SR14QPS05:CURRENT_MONITOR' 'SR14QPS05:BASE_CURRENT_SP ' 1 [14,2] 28 1.0 0.25 ; ...
+};
+
+% qdascale = mean(FitParameters(end).Values(29:56))./FitParameters(end).Values(29:56);
+
+
+for ii=1:size(qda,1)
+name=qda{ii,1}; AO.QDA.CommonNames(ii,:) = name;
+name=qda{ii,2}; AO.QDA.Monitor.ChannelNames(ii,:) = name;
+name=qda{ii,3}; AO.QDA.Setpoint.ChannelNames(ii,:) = name;
+val =qda{ii,4}; AO.QDA.Status(ii,1) = val;
+val =qda{ii,5}; AO.QDA.DeviceList(ii,:) = val;
+val =qda{ii,6}; AO.QDA.ElementList(ii,1) = val;
+val =1; %qdascale(ii); % This is the scale factor
+AO.QDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QDA.Monitor.HW2PhysicsParams{2}(ii,:) = 1/val;
+AO.QDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QDA.Setpoint.HW2PhysicsParams{2}(ii,:) = 1/val;
+AO.QDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QDA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qda{ii,8}; AO.QDA.Setpoint.Tolerance(ii,1) = val;
+
+% Important! This determines the cycling range
+AO.QDA.Setpoint.Range(ii,:) = [0 90];
+end
+
+
+
+% *** QFB ***
+AO.QFB.FamilyName = 'QFB'; dispobject(AO,AO.QFB.FamilyName);
+AO.QFB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
+HW2PhysicsParams = magnetcoefficients('QFB');
+Physics2HWParams = magnetcoefficients('QFB');
+
+AO.QFB.Monitor.Mode = Mode;
+AO.QFB.Monitor.DataType = 'Scalar';
+AO.QFB.Monitor.Units = 'Hardware';
+AO.QFB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QFB.Monitor.Physics2HWFcn = @k2amp;
+AO.QFB.Monitor.HWUnits = 'ampere';
+AO.QFB.Monitor.PhysicsUnits = 'meter^-2';
+
+AO.QFB.Setpoint.Mode = Mode;
+AO.QFB.Setpoint.DataType = 'Scalar';
+AO.QFB.Setpoint.Units = 'Hardware';
+AO.QFB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QFB.Setpoint.Physics2HWFcn = @k2amp;
+AO.QFB.Setpoint.HWUnits = 'ampere';
+AO.QFB.Setpoint.PhysicsUnits = 'meter^-2';
+
+% common monitor setpoint stat devlist elem scale tol
+qfb={
+'1QFB1 ' 'SR01QPS03:CURRENT_MONITOR' 'SR01QPS03:BASE_CURRENT_SP ' 1 [1,1] 1 1.0 0.35 ; ...
+'1QFB2 ' 'SR01QPS04:CURRENT_MONITOR' 'SR01QPS04:BASE_CURRENT_SP ' 1 [1,2] 2 1.0 0.35 ; ...
+'2QFB1 ' 'SR02QPS03:CURRENT_MONITOR' 'SR02QPS03:BASE_CURRENT_SP ' 1 [2,1] 3 1.0 0.35 ; ...
+'2QFB2 ' 'SR02QPS04:CURRENT_MONITOR' 'SR02QPS04:BASE_CURRENT_SP ' 1 [2,2] 4 1.0 0.35 ; ...
+'3QFB1 ' 'SR03QPS03:CURRENT_MONITOR' 'SR03QPS03:BASE_CURRENT_SP ' 1 [3,1] 5 1.0 0.35 ; ...
+'3QFB2 ' 'SR03QPS04:CURRENT_MONITOR' 'SR03QPS04:BASE_CURRENT_SP ' 1 [3,2] 6 1.0 0.35 ; ...
+'4QFB1 ' 'SR04QPS03:CURRENT_MONITOR' 'SR04QPS03:BASE_CURRENT_SP ' 1 [4,1] 7 1.0 0.35 ; ...
+'4QFB2 ' 'SR04QPS04:CURRENT_MONITOR' 'SR04QPS04:BASE_CURRENT_SP ' 1 [4,2] 8 1.0 0.35 ; ...
+'5QFB1 ' 'SR05QPS03:CURRENT_MONITOR' 'SR05QPS03:BASE_CURRENT_SP ' 1 [5,1] 9 1.0 0.35 ; ...
+'5QFB2 ' 'SR05QPS04:CURRENT_MONITOR' 'SR05QPS04:BASE_CURRENT_SP ' 1 [5,2] 10 1.0 0.35 ; ...
+'6QFB1 ' 'SR06QPS03:CURRENT_MONITOR' 'SR06QPS03:BASE_CURRENT_SP ' 1 [6,1] 11 1.0 0.35 ; ...
+'6QFB2 ' 'SR06QPS04:CURRENT_MONITOR' 'SR06QPS04:BASE_CURRENT_SP ' 1 [6,2] 12 1.0 0.35 ; ...
+'7QFB1 ' 'SR07QPS03:CURRENT_MONITOR' 'SR07QPS03:BASE_CURRENT_SP ' 1 [7,1] 13 1.0 0.35 ; ...
+'7QFB2 ' 'SR07QPS04:CURRENT_MONITOR' 'SR07QPS04:BASE_CURRENT_SP ' 1 [7,2] 14 1.0 0.35 ; ...
+'8QFB1 ' 'SR08QPS03:CURRENT_MONITOR' 'SR08QPS03:BASE_CURRENT_SP ' 1 [8,1] 15 1.0 0.35 ; ...
+'8QFB2 ' 'SR08QPS04:CURRENT_MONITOR' 'SR08QPS04:BASE_CURRENT_SP ' 1 [8,2] 16 1.0 0.35 ; ...
+'9QFB1 ' 'SR09QPS03:CURRENT_MONITOR' 'SR09QPS03:BASE_CURRENT_SP ' 1 [9,1] 17 1.0 0.35 ; ...
+'9QFB2 ' 'SR09QPS04:CURRENT_MONITOR' 'SR09QPS04:BASE_CURRENT_SP ' 1 [9,2] 18 1.0 0.35 ; ...
+'10QFB1 ' 'SR10QPS03:CURRENT_MONITOR' 'SR10QPS03:BASE_CURRENT_SP ' 1 [10,1] 19 1.0 0.35 ; ...
+'10QFB2 ' 'SR10QPS04:CURRENT_MONITOR' 'SR10QPS04:BASE_CURRENT_SP ' 1 [10,2] 20 1.0 0.35 ; ...
+'11QFB1 ' 'SR11QPS03:CURRENT_MONITOR' 'SR11QPS03:BASE_CURRENT_SP ' 1 [11,1] 21 1.0 0.35 ; ...
+'11QFB2 ' 'SR11QPS04:CURRENT_MONITOR' 'SR11QPS04:BASE_CURRENT_SP ' 1 [11,2] 22 1.0 0.35 ; ...
+'12QFB1 ' 'SR12QPS03:CURRENT_MONITOR' 'SR12QPS03:BASE_CURRENT_SP ' 1 [12,1] 23 1.0 0.35 ; ...
+'12QFB2 ' 'SR12QPS04:CURRENT_MONITOR' 'SR12QPS04:BASE_CURRENT_SP ' 1 [12,2] 24 1.0 0.35 ; ...
+'13QFB1 ' 'SR13QPS03:CURRENT_MONITOR' 'SR13QPS03:BASE_CURRENT_SP ' 1 [13,1] 25 1.0 0.35 ; ...
+'13QFB2 ' 'SR13QPS04:CURRENT_MONITOR' 'SR13QPS04:BASE_CURRENT_SP ' 1 [13,2] 26 1.0 0.35 ; ...
+'14QFB1 ' 'SR14QPS03:CURRENT_MONITOR' 'SR14QPS03:BASE_CURRENT_SP ' 1 [14,1] 27 1.0 0.35 ; ...
+'14QFB2 ' 'SR14QPS04:CURRENT_MONITOR' 'SR14QPS04:BASE_CURRENT_SP ' 1 [14,2] 28 1.0 0.35 ; ...
+};
+
+% qfbscale = mean(FitParameters(end).Values(57:84))./FitParameters(end).Values(57:84);
+
+for ii=1:size(qfb,1)
+name=qfb{ii,1}; AO.QFB.CommonNames(ii,:) = name;
+name=qfb{ii,2}; AO.QFB.Monitor.ChannelNames(ii,:) = name;
+name=qfb{ii,3}; AO.QFB.Setpoint.ChannelNames(ii,:) = name;
+val =qfb{ii,4}; AO.QFB.Status(ii,1) = val;
+val =qfb{ii,5}; AO.QFB.DeviceList(ii,:) = val;
+val =qfb{ii,6}; AO.QFB.ElementList(ii,1) = val;
+val =1; %qfbscale(ii); % This is the scale factor
+AO.QFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFB.Monitor.HW2PhysicsParams{2}(ii,:) = 1/val;
+AO.QFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFB.Setpoint.HW2PhysicsParams{2}(ii,:) = 1/val;
+AO.QFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qfb{ii,8}; AO.QFB.Setpoint.Tolerance(ii,1) = val;
+
+% Important! This determines the cycling range
+AO.QFB.Setpoint.Range(ii,:) = [0 160];
+end
+
+
+%===============
+%Sextupole data
+%===============
+% *** SFA ***
+AO.SFA.FamilyName = 'SFA'; dispobject(AO,AO.SFA.FamilyName);
+AO.SFA.MemberOf = {'PlotFamily'; 'SF'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SFA');
+Physics2HWParams = magnetcoefficients('SFA');
+
+AO.SFA.Monitor.Mode = Mode;
+AO.SFA.Monitor.DataType = 'Scalar';
+AO.SFA.Monitor.Units = 'Hardware';
+AO.SFA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SFA.Monitor.Physics2HWFcn = @k2amp;
+AO.SFA.Monitor.HWUnits = 'ampere';
+AO.SFA.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SFA.Setpoint.Mode = Mode;
+AO.SFA.Setpoint.DataType = 'Scalar';
+AO.SFA.Setpoint.Units = 'Hardware';
+AO.SFA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SFA.Setpoint.Physics2HWFcn = @k2amp;
+AO.SFA.Setpoint.HWUnits = 'ampere';
+AO.SFA.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sfa={
+'1SFA1 ' 'SR01SPS01:CURRENT_MONITOR' 'SR01SPS01:BASE_CURRENT_SP ' 1 [1,1] 1 1.0 0.15 ; ...
+'1SFA2 ' 'SR01SPS07:CURRENT_MONITOR' 'SR01SPS07:BASE_CURRENT_SP ' 1 [1,2] 2 1.0 0.15 ; ...
+'2SFA1 ' 'SR02SPS01:CURRENT_MONITOR' 'SR02SPS01:BASE_CURRENT_SP ' 1 [2,1] 3 1.0 0.15 ; ...
+'2SFA2 ' 'SR02SPS07:CURRENT_MONITOR' 'SR02SPS07:BASE_CURRENT_SP ' 1 [2,2] 4 1.0 0.15 ; ...
+'3SFA1 ' 'SR03SPS01:CURRENT_MONITOR' 'SR03SPS01:BASE_CURRENT_SP ' 1 [3,1] 5 1.0 0.15 ; ...
+'3SFA2 ' 'SR03SPS07:CURRENT_MONITOR' 'SR03SPS07:BASE_CURRENT_SP ' 1 [3,2] 6 1.0 0.15 ; ...
+'4SFA1 ' 'SR04SPS01:CURRENT_MONITOR' 'SR04SPS01:BASE_CURRENT_SP ' 1 [4,1] 7 1.0 0.15 ; ...
+'4SFA2 ' 'SR04SPS07:CURRENT_MONITOR' 'SR04SPS07:BASE_CURRENT_SP ' 1 [4,2] 8 1.0 0.15 ; ...
+'5SFA1 ' 'SR05SPS01:CURRENT_MONITOR' 'SR05SPS01:BASE_CURRENT_SP ' 1 [5,1] 9 1.0 0.15 ; ...
+'5SFA2 ' 'SR05SPS07:CURRENT_MONITOR' 'SR05SPS07:BASE_CURRENT_SP ' 1 [5,2] 10 1.0 0.15 ; ...
+'6SFA1 ' 'SR06SPS01:CURRENT_MONITOR' 'SR06SPS01:BASE_CURRENT_SP ' 1 [6,1] 11 1.0 0.15 ; ...
+'6SFA2 ' 'SR06SPS07:CURRENT_MONITOR' 'SR06SPS07:BASE_CURRENT_SP ' 1 [6,2] 12 1.0 0.15 ; ...
+'7SFA1 ' 'SR07SPS01:CURRENT_MONITOR' 'SR07SPS01:BASE_CURRENT_SP ' 1 [7,1] 13 1.0 0.15 ; ...
+'7SFA2 ' 'SR07SPS07:CURRENT_MONITOR' 'SR07SPS07:BASE_CURRENT_SP ' 1 [7,2] 14 1.0 0.15 ; ...
+'8SFA1 ' 'SR08SPS01:CURRENT_MONITOR' 'SR08SPS01:BASE_CURRENT_SP ' 1 [8,1] 15 1.0 0.15 ; ...
+'8SFA2 ' 'SR08SPS07:CURRENT_MONITOR' 'SR08SPS07:BASE_CURRENT_SP ' 1 [8,2] 16 1.0 0.15 ; ...
+'9SFA1 ' 'SR09SPS01:CURRENT_MONITOR' 'SR09SPS01:BASE_CURRENT_SP ' 1 [9,1] 17 1.0 0.15 ; ...
+'9SFA2 ' 'SR09SPS07:CURRENT_MONITOR' 'SR09SPS07:BASE_CURRENT_SP ' 1 [9,2] 18 1.0 0.15 ; ...
+'10SFA1 ' 'SR10SPS01:CURRENT_MONITOR' 'SR10SPS01:BASE_CURRENT_SP ' 1 [10,1] 19 1.0 0.15 ; ...
+'10SFA2 ' 'SR10SPS07:CURRENT_MONITOR' 'SR10SPS07:BASE_CURRENT_SP ' 1 [10,2] 20 1.0 0.15 ; ...
+'11SFA1 ' 'SR11SPS01:CURRENT_MONITOR' 'SR11SPS01:BASE_CURRENT_SP ' 1 [11,1] 21 1.0 0.15 ; ...
+'11SFA2 ' 'SR11SPS07:CURRENT_MONITOR' 'SR11SPS07:BASE_CURRENT_SP ' 1 [11,2] 22 1.0 0.15 ; ...
+'12SFA1 ' 'SR12SPS01:CURRENT_MONITOR' 'SR12SPS01:BASE_CURRENT_SP ' 1 [12,1] 23 1.0 0.15 ; ...
+'12SFA2 ' 'SR12SPS07:CURRENT_MONITOR' 'SR12SPS07:BASE_CURRENT_SP ' 1 [12,2] 24 1.0 0.15 ; ...
+'13SFA1 ' 'SR13SPS01:CURRENT_MONITOR' 'SR13SPS01:BASE_CURRENT_SP ' 1 [13,1] 25 1.0 0.15 ; ...
+'13SFA2 ' 'SR13SPS07:CURRENT_MONITOR' 'SR13SPS07:BASE_CURRENT_SP ' 1 [13,2] 26 1.0 0.15 ; ...
+'14SFA1 ' 'SR14SPS01:CURRENT_MONITOR' 'SR14SPS01:BASE_CURRENT_SP ' 1 [14,1] 27 1.0 0.15 ; ...
+'14SFA2 ' 'SR14SPS07:CURRENT_MONITOR' 'SR14SPS07:BASE_CURRENT_SP ' 1 [14,2] 28 1.0 0.15 ; ...
+};
+
+for ii=1:size(sfa,1)
+name=sfa{ii,1}; AO.SFA.CommonNames(ii,:) = name;
+name=sfa{ii,2}; AO.SFA.Monitor.ChannelNames(ii,:) = name;
+name=sfa{ii,3}; AO.SFA.Setpoint.ChannelNames(ii,:) = name;
+val =sfa{ii,4}; AO.SFA.Status(ii,1) = val;
+val =sfa{ii,5}; AO.SFA.DeviceList(ii,:) = val;
+val =sfa{ii,6}; AO.SFA.ElementList(ii,1) = val;
+val =sfa{ii,7}; % This is the scale factor
+AO.SFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sfa{ii,8}; AO.SFA.Setpoint.Tolerance(ii,1) = val;
+
+% AO.SFA.Setpoint.Range(ii,:) = [0 90];
+AO.SFA.Setpoint.Range(ii,:) = [0 120];
+end
+
+
+
+% *** SDA ***
+AO.SDA.FamilyName = 'SDA'; dispobject(AO,AO.SDA.FamilyName);
+AO.SDA.MemberOf = {'PlotFamily'; 'SD'; 'SEXT'; 'MachineConfig'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SDA');
+Physics2HWParams = magnetcoefficients('SDA');
+AO.SDA.Monitor.Mode = Mode;
+AO.SDA.Monitor.DataType = 'Scalar';
+AO.SDA.Monitor.Units = 'Hardware';
+AO.SDA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SDA.Monitor.Physics2HWFcn = @k2amp;
+AO.SDA.Monitor.HWUnits = 'ampere';
+AO.SDA.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SDA.Setpoint.Mode = Mode;
+AO.SDA.Setpoint.DataType = 'Scalar';
+AO.SDA.Setpoint.Units = 'Hardware';
+AO.SDA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SDA.Setpoint.Physics2HWFcn = @k2amp;
+AO.SDA.Setpoint.HWUnits = 'ampere';
+AO.SDA.Setpoint.PhysicsUnits = 'meter^-3';
+
+
+% common monitor setpoint stat devlist elem scale tol
+sda={
+'1SDA1 ' 'SR01SPS02:CURRENT_MONITOR' 'SR01SPS02:BASE_CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
+'1SDA2 ' 'SR01SPS06:CURRENT_MONITOR' 'SR01SPS06:BASE_CURRENT_SP ' 1 [1,2] 2 1.0 0.2 ; ...
+'2SDA1 ' 'SR02SPS02:CURRENT_MONITOR' 'SR02SPS02:BASE_CURRENT_SP ' 1 [2,1] 3 1.0 0.2 ; ...
+'2SDA2 ' 'SR02SPS06:CURRENT_MONITOR' 'SR02SPS06:BASE_CURRENT_SP ' 1 [2,2] 4 1.0 0.2 ; ...
+'3SDA1 ' 'SR03SPS02:CURRENT_MONITOR' 'SR03SPS02:BASE_CURRENT_SP ' 1 [3,1] 5 1.0 0.2 ; ...
+'3SDA2 ' 'SR03SPS06:CURRENT_MONITOR' 'SR03SPS06:BASE_CURRENT_SP ' 1 [3,2] 6 1.0 0.2 ; ...
+'4SDA1 ' 'SR04SPS02:CURRENT_MONITOR' 'SR04SPS02:BASE_CURRENT_SP ' 1 [4,1] 7 1.0 0.2 ; ...
+'4SDA2 ' 'SR04SPS06:CURRENT_MONITOR' 'SR04SPS06:BASE_CURRENT_SP ' 1 [4,2] 8 1.0 0.2 ; ...
+'5SDA1 ' 'SR05SPS02:CURRENT_MONITOR' 'SR05SPS02:BASE_CURRENT_SP ' 1 [5,1] 9 1.0 0.2 ; ...
+'5SDA2 ' 'SR05SPS06:CURRENT_MONITOR' 'SR05SPS06:BASE_CURRENT_SP ' 1 [5,2] 10 1.0 0.2 ; ...
+'6SDA1 ' 'SR06SPS02:CURRENT_MONITOR' 'SR06SPS02:BASE_CURRENT_SP ' 1 [6,1] 11 1.0 0.2 ; ...
+'6SDA2 ' 'SR06SPS06:CURRENT_MONITOR' 'SR06SPS06:BASE_CURRENT_SP ' 1 [6,2] 12 1.0 0.2 ; ...
+'7SDA1 ' 'SR07SPS02:CURRENT_MONITOR' 'SR07SPS02:BASE_CURRENT_SP ' 1 [7,1] 13 1.0 0.2 ; ...
+'7SDA2 ' 'SR07SPS06:CURRENT_MONITOR' 'SR07SPS06:BASE_CURRENT_SP ' 1 [7,2] 14 1.0 0.2 ; ...
+'8SDA1 ' 'SR08SPS02:CURRENT_MONITOR' 'SR08SPS02:BASE_CURRENT_SP ' 1 [8,1] 15 1.0 0.2 ; ...
+'8SDA2 ' 'SR08SPS06:CURRENT_MONITOR' 'SR08SPS06:BASE_CURRENT_SP ' 1 [8,2] 16 1.0 0.2 ; ...
+'9SDA1 ' 'SR09SPS02:CURRENT_MONITOR' 'SR09SPS02:BASE_CURRENT_SP ' 1 [9,1] 17 1.0 0.2 ; ...
+'9SDA2 ' 'SR09SPS06:CURRENT_MONITOR' 'SR09SPS06:BASE_CURRENT_SP ' 1 [9,2] 18 1.0 0.2 ; ...
+'10SDA1 ' 'SR10SPS02:CURRENT_MONITOR' 'SR10SPS02:BASE_CURRENT_SP ' 1 [10,1] 19 1.0 0.2 ; ...
+'10SDA2 ' 'SR10SPS06:CURRENT_MONITOR' 'SR10SPS06:BASE_CURRENT_SP ' 1 [10,2] 20 1.0 0.2 ; ...
+'11SDA1 ' 'SR11SPS02:CURRENT_MONITOR' 'SR11SPS02:BASE_CURRENT_SP ' 1 [11,1] 21 1.0 0.2 ; ...
+'11SDA2 ' 'SR11SPS06:CURRENT_MONITOR' 'SR11SPS06:BASE_CURRENT_SP ' 1 [11,2] 22 1.0 0.2 ; ...
+'12SDA1 ' 'SR12SPS02:CURRENT_MONITOR' 'SR12SPS02:BASE_CURRENT_SP ' 1 [12,1] 23 1.0 0.2 ; ...
+'12SDA2 ' 'SR12SPS06:CURRENT_MONITOR' 'SR12SPS06:BASE_CURRENT_SP ' 1 [12,2] 24 1.0 0.2 ; ...
+'13SDA1 ' 'SR13SPS02:CURRENT_MONITOR' 'SR13SPS02:BASE_CURRENT_SP ' 1 [13,1] 25 1.0 0.2 ; ...
+'13SDA2 ' 'SR13SPS06:CURRENT_MONITOR' 'SR13SPS06:BASE_CURRENT_SP ' 1 [13,2] 26 1.0 0.2 ; ...
+'14SDA1 ' 'SR14SPS02:CURRENT_MONITOR' 'SR14SPS02:BASE_CURRENT_SP ' 1 [14,1] 27 1.0 0.2 ; ...
+'14SDA2 ' 'SR14SPS06:CURRENT_MONITOR' 'SR14SPS06:BASE_CURRENT_SP ' 1 [14,2] 28 1.0 0.2 ; ...
+};
+
+for ii=1:size(sda,1)
+name=sda{ii,1}; AO.SDA.CommonNames(ii,:) = name;
+name=sda{ii,2}; AO.SDA.Monitor.ChannelNames(ii,:) = name;
+name=sda{ii,3}; AO.SDA.Setpoint.ChannelNames(ii,:) = name;
+val =sda{ii,4}; AO.SDA.Status(ii,1) = val;
+val =sda{ii,5}; AO.SDA.DeviceList(ii,:) = val;
+val =sda{ii,6}; AO.SDA.ElementList(ii,1) = val;
+val =sda{ii,7}; % This is the scale factor
+AO.SDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sda{ii,8}; AO.SDA.Setpoint.Tolerance(ii,1) = val;
+
+% AO.SDA.Setpoint.Range(ii,:) = [0 90];
+AO.SDA.Setpoint.Range(ii,:) = [0 120];
+end
+
+
+% *** SDB ***
+AO.SDB.FamilyName = 'SDB'; dispobject(AO,AO.SDB.FamilyName);
+AO.SDB.MemberOf = {'PlotFamily'; 'SD'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SDB');
+Physics2HWParams = magnetcoefficients('SDB');
+AO.SDB.Monitor.Mode = Mode;
+AO.SDB.Monitor.DataType = 'Scalar';
+AO.SDB.Monitor.Units = 'Hardware';
+AO.SDB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SDB.Monitor.Physics2HWFcn = @k2amp;
+AO.SDB.Monitor.HWUnits = 'ampere';
+AO.SDB.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SDB.Setpoint.Mode = Mode;
+AO.SDB.Setpoint.DataType = 'Scalar';
+AO.SDB.Setpoint.Units = 'Hardware';
+AO.SDB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SDB.Setpoint.Physics2HWFcn = @k2amp;
+AO.SDB.Setpoint.HWUnits = 'ampere';
+AO.SDB.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sdb={
+'1SDB1 ' 'SR01SPS03:CURRENT_MONITOR' 'SR01SPS03:BASE_CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
+'1SDB2 ' 'SR01SPS05:CURRENT_MONITOR' 'SR01SPS05:BASE_CURRENT_SP ' 1 [1,2] 2 1.0 0.2 ; ...
+'2SDB1 ' 'SR02SPS03:CURRENT_MONITOR' 'SR02SPS03:BASE_CURRENT_SP ' 1 [2,1] 3 1.0 0.2 ; ...
+'2SDB2 ' 'SR02SPS05:CURRENT_MONITOR' 'SR02SPS05:BASE_CURRENT_SP ' 1 [2,2] 4 1.0 0.2 ; ...
+'3SDB1 ' 'SR03SPS03:CURRENT_MONITOR' 'SR03SPS03:BASE_CURRENT_SP ' 1 [3,1] 5 1.0 0.2 ; ...
+'3SDB2 ' 'SR03SPS05:CURRENT_MONITOR' 'SR03SPS05:BASE_CURRENT_SP ' 1 [3,2] 6 1.0 0.2 ; ...
+'4SDB1 ' 'SR04SPS03:CURRENT_MONITOR' 'SR04SPS03:BASE_CURRENT_SP ' 1 [4,1] 7 1.0 0.2 ; ...
+'4SDB2 ' 'SR04SPS05:CURRENT_MONITOR' 'SR04SPS05:BASE_CURRENT_SP ' 1 [4,2] 8 1.0 0.2 ; ...
+'5SDB1 ' 'SR05SPS03:CURRENT_MONITOR' 'SR05SPS03:BASE_CURRENT_SP ' 1 [5,1] 9 1.0 0.2 ; ...
+'5SDB2 ' 'SR05SPS05:CURRENT_MONITOR' 'SR05SPS05:BASE_CURRENT_SP ' 1 [5,2] 10 1.0 0.2 ; ...
+'6SDB1 ' 'SR06SPS03:CURRENT_MONITOR' 'SR06SPS03:BASE_CURRENT_SP ' 1 [6,1] 11 1.0 0.2 ; ...
+'6SDB2 ' 'SR06SPS05:CURRENT_MONITOR' 'SR06SPS05:BASE_CURRENT_SP ' 1 [6,2] 12 1.0 0.2 ; ...
+'7SDB1 ' 'SR07SPS03:CURRENT_MONITOR' 'SR07SPS03:BASE_CURRENT_SP ' 1 [7,1] 13 1.0 0.2 ; ...
+'7SDB2 ' 'SR07SPS05:CURRENT_MONITOR' 'SR07SPS05:BASE_CURRENT_SP ' 1 [7,2] 14 1.0 0.2 ; ...
+'8SDB1 ' 'SR08SPS03:CURRENT_MONITOR' 'SR08SPS03:BASE_CURRENT_SP ' 1 [8,1] 15 1.0 0.2 ; ...
+'8SDB2 ' 'SR08SPS05:CURRENT_MONITOR' 'SR08SPS05:BASE_CURRENT_SP ' 1 [8,2] 16 1.0 0.2 ; ...
+'9SDB1 ' 'SR09SPS03:CURRENT_MONITOR' 'SR09SPS03:BASE_CURRENT_SP ' 1 [9,1] 17 1.0 0.2 ; ...
+'9SDB2 ' 'SR09SPS05:CURRENT_MONITOR' 'SR09SPS05:BASE_CURRENT_SP ' 1 [9,2] 18 1.0 0.2 ; ...
+'10SDB1 ' 'SR10SPS03:CURRENT_MONITOR' 'SR10SPS03:BASE_CURRENT_SP ' 1 [10,1] 19 1.0 0.2 ; ...
+'10SDB2 ' 'SR10SPS05:CURRENT_MONITOR' 'SR10SPS05:BASE_CURRENT_SP ' 1 [10,2] 20 1.0 0.2 ; ...
+'11SDB1 ' 'SR11SPS03:CURRENT_MONITOR' 'SR11SPS03:BASE_CURRENT_SP ' 1 [11,1] 21 1.0 0.2 ; ...
+'11SDB2 ' 'SR11SPS05:CURRENT_MONITOR' 'SR11SPS05:BASE_CURRENT_SP ' 1 [11,2] 22 1.0 0.2 ; ...
+'12SDB1 ' 'SR12SPS03:CURRENT_MONITOR' 'SR12SPS03:BASE_CURRENT_SP ' 1 [12,1] 23 1.0 0.2 ; ...
+'12SDB2 ' 'SR12SPS05:CURRENT_MONITOR' 'SR12SPS05:BASE_CURRENT_SP ' 1 [12,2] 24 1.0 0.2 ; ...
+'13SDB1 ' 'SR13SPS03:CURRENT_MONITOR' 'SR13SPS03:BASE_CURRENT_SP ' 1 [13,1] 25 1.0 0.2 ; ...
+'13SDB2 ' 'SR13SPS05:CURRENT_MONITOR' 'SR13SPS05:BASE_CURRENT_SP ' 1 [13,2] 26 1.0 0.2 ; ...
+'14SDB1 ' 'SR14SPS03:CURRENT_MONITOR' 'SR14SPS03:BASE_CURRENT_SP ' 1 [14,1] 27 1.0 0.2 ; ...
+'14SDB2 ' 'SR14SPS05:CURRENT_MONITOR' 'SR14SPS05:BASE_CURRENT_SP ' 1 [14,2] 28 1.0 0.2 ; ...
+};
+
+for ii=1:size(sdb,1)
+name=sdb{ii,1}; AO.SDB.CommonNames(ii,:) = name;
+name=sdb{ii,2}; AO.SDB.Monitor.ChannelNames(ii,:) = name;
+name=sdb{ii,3}; AO.SDB.Setpoint.ChannelNames(ii,:)= name;
+val =sdb{ii,4}; AO.SDB.Status(ii,1) = val;
+val =sdb{ii,5}; AO.SDB.DeviceList(ii,:) = val;
+val =sdb{ii,6}; AO.SDB.ElementList(ii,1) = val;
+val =sdb{ii,7}; % This is the scale factor
+AO.SDB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SDB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sdb{ii,8}; AO.SDB.Setpoint.Tolerance(ii,1) = val;
+
+% AO.SDB.Setpoint.Range(ii,:) = [0 80];
+AO.SDB.Setpoint.Range(ii,:) = [0 120];
+end
+
+
+
+% *** SFB ***
+AO.SFB.FamilyName = 'SFB'; dispobject(AO,AO.SFB.FamilyName);
+AO.SFB.MemberOf = {'PlotFamily'; 'SF'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SFB');
+Physics2HWParams = magnetcoefficients('SFB');
+
+AO.SFB.Monitor.Mode = Mode;
+AO.SFB.Monitor.DataType = 'Scalar';
+AO.SFB.Monitor.Units = 'Hardware';
+AO.SFB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SFB.Monitor.Physics2HWFcn = @k2amp;
+AO.SFB.Monitor.HWUnits = 'ampere';
+AO.SFB.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SFB.Setpoint.Mode = Mode;
+AO.SFB.Setpoint.DataType = 'Scalar';
+AO.SFB.Setpoint.Units = 'Hardware';
+AO.SFB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SFB.Setpoint.Physics2HWFcn = @k2amp;
+AO.SFB.Setpoint.HWUnits = 'ampere';
+AO.SFB.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sfb={
+'1SFB1 ' 'SR01SPS04:CURRENT_MONITOR' 'SR01SPS04:BASE_CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
+'2SFB1 ' 'SR02SPS04:CURRENT_MONITOR' 'SR02SPS04:BASE_CURRENT_SP ' 1 [2,1] 2 1.0 0.2 ; ...
+'3SFB1 ' 'SR03SPS04:CURRENT_MONITOR' 'SR03SPS04:BASE_CURRENT_SP ' 1 [3,1] 3 1.0 0.2 ; ...
+'4SFB1 ' 'SR04SPS04:CURRENT_MONITOR' 'SR04SPS04:BASE_CURRENT_SP ' 1 [4,1] 4 1.0 0.2 ; ...
+'5SFB1 ' 'SR05SPS04:CURRENT_MONITOR' 'SR05SPS04:BASE_CURRENT_SP ' 1 [5,1] 5 1.0 0.2 ; ...
+'6SFB1 ' 'SR06SPS04:CURRENT_MONITOR' 'SR06SPS04:BASE_CURRENT_SP ' 1 [6,1] 6 1.0 0.2 ; ...
+'7SFB1 ' 'SR07SPS04:CURRENT_MONITOR' 'SR07SPS04:BASE_CURRENT_SP ' 1 [7,1] 7 1.0 0.2 ; ...
+'8SFB1 ' 'SR08SPS04:CURRENT_MONITOR' 'SR08SPS04:BASE_CURRENT_SP ' 1 [8,1] 8 1.0 0.2 ; ...
+'9SFB1 ' 'SR09SPS04:CURRENT_MONITOR' 'SR09SPS04:BASE_CURRENT_SP ' 1 [9,1] 9 1.0 0.2 ; ...
+'10SFB1 ' 'SR10SPS04:CURRENT_MONITOR' 'SR10SPS04:BASE_CURRENT_SP ' 1 [10,1] 10 1.0 0.2 ; ...
+'11SFB1 ' 'SR11SPS04:CURRENT_MONITOR' 'SR11SPS04:BASE_CURRENT_SP ' 1 [11,1] 11 1.0 0.2 ; ...
+'12SFB1 ' 'SR12SPS04:CURRENT_MONITOR' 'SR12SPS04:BASE_CURRENT_SP ' 1 [12,1] 12 1.0 0.2 ; ...
+'13SFB1 ' 'SR13SPS04:CURRENT_MONITOR' 'SR13SPS04:BASE_CURRENT_SP ' 1 [13,1] 13 1.0 0.2 ; ...
+'14SFB1 ' 'SR14SPS04:CURRENT_MONITOR' 'SR14SPS04:BASE_CURRENT_SP ' 1 [14,1] 14 1.0 0.2 ; ...
+};
+
+for ii=1:size(sfb,1)
+name=sfb{ii,1}; AO.SFB.CommonNames(ii,:) = name;
+name=sfb{ii,2}; AO.SFB.Monitor.ChannelNames(ii,:) = name;
+name=sfb{ii,3}; AO.SFB.Setpoint.ChannelNames(ii,:)= name;
+val =sfb{ii,4}; AO.SFB.Status(ii,1) = val;
+val =sfb{ii,5}; AO.SFB.DeviceList(ii,:) = val;
+val =sfb{ii,6}; AO.SFB.ElementList(ii,1) = val;
+val =sfb{ii,7}; % This is the scale factor
+AO.SFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sfb{ii,8}; AO.SFB.Setpoint.Tolerance(ii,1) = val;
+
+% AO.SFB.Setpoint.Range(ii,:) = [0 60];
+AO.SFB.Setpoint.Range(ii,:) = [0 120];
+end
+
+%===============
+%Skew Quad data
+%===============
+% *** Skew quadrupoles *** 2005/09/27 Eugene
+AO.SKQ.FamilyName = 'SKQ'; dispobject(AO,AO.SKQ.FamilyName);
+AO.SKQ.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SkewQuad'; 'Magnet';};
+HW2PhysicsParams = magnetcoefficients('SKQ');
+Physics2HWParams = magnetcoefficients('SKQ');
+
+AO.SKQ.Monitor.Mode = Mode;
+AO.SKQ.Monitor.DataType = 'Scalar';
+AO.SKQ.Monitor.Units = 'Hardware';
+AO.SKQ.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SKQ.Monitor.Physics2HWFcn = @k2amp;
+AO.SKQ.Monitor.HWUnits = 'ampere';
+AO.SKQ.Monitor.PhysicsUnits = 'meter^-2';
+
+AO.SKQ.Setpoint.Mode = Mode;
+AO.SKQ.Setpoint.DataType = 'Scalar';
+AO.SKQ.Setpoint.Units = 'Hardware';
+AO.SKQ.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SKQ.Setpoint.Physics2HWFcn = @k2amp;
+AO.SKQ.Setpoint.HWUnits = 'ampere';
+AO.SKQ.Setpoint.PhysicsUnits = 'meter^-2';
+
+% common monitor setpoint stat devlist elem scale tol
+sq={
+'1SKQ1 ' 'SR01CPS03:CURRENT_MONITOR' 'SR01CPS03:BASE_CURRENT_SP ' 1 [1,1] 1 0.2 ; ...
+'1SKQ2 ' 'SR01CPS08:CURRENT_MONITOR' 'SR01CPS08:BASE_CURRENT_SP ' 1 [1,2] 2 0.2 ; ...
+'2SKQ1 ' 'SR02CPS03:CURRENT_MONITOR' 'SR02CPS03:BASE_CURRENT_SP ' 1 [2,1] 3 0.2 ; ...
+'2SKQ2 ' 'SR02CPS08:CURRENT_MONITOR' 'SR02CPS08:BASE_CURRENT_SP ' 1 [2,2] 4 0.2 ; ...
+'3SKQ1 ' 'SR03CPS03:CURRENT_MONITOR' 'SR03CPS03:BASE_CURRENT_SP ' 1 [3,1] 5 0.2 ; ...
+'3SKQ2 ' 'SR03CPS08:CURRENT_MONITOR' 'SR03CPS08:BASE_CURRENT_SP ' 1 [3,2] 6 0.2 ; ...
+'4SKQ1 ' 'SR04CPS03:CURRENT_MONITOR' 'SR04CPS03:BASE_CURRENT_SP ' 1 [4,1] 7 0.2 ; ...
+'4SKQ2 ' 'SR04CPS08:CURRENT_MONITOR' 'SR04CPS08:BASE_CURRENT_SP ' 1 [4,2] 8 0.2 ; ...
+'5SKQ1 ' 'SR05CPS03:CURRENT_MONITOR' 'SR05CPS03:BASE_CURRENT_SP ' 1 [5,1] 9 0.2 ; ...
+'5SKQ2 ' 'SR05CPS08:CURRENT_MONITOR' 'SR05CPS08:BASE_CURRENT_SP ' 1 [5,2] 10 0.2 ; ...
+'6SKQ1 ' 'SR06CPS03:CURRENT_MONITOR' 'SR06CPS03:BASE_CURRENT_SP ' 1 [6,1] 11 0.2 ; ...
+'6SKQ2 ' 'SR06CPS08:CURRENT_MONITOR' 'SR06CPS08:BASE_CURRENT_SP ' 1 [6,2] 12 0.2 ; ...
+'7SKQ1 ' 'SR07CPS03:CURRENT_MONITOR' 'SR07CPS03:BASE_CURRENT_SP ' 1 [7,1] 13 0.2 ; ...
+'7SKQ2 ' 'SR07CPS08:CURRENT_MONITOR' 'SR07CPS08:BASE_CURRENT_SP ' 1 [7,2] 14 0.2 ; ...
+'8SKQ1 ' 'SR08CPS03:CURRENT_MONITOR' 'SR08CPS03:BASE_CURRENT_SP ' 1 [8,1] 15 0.2 ; ...
+'8SKQ2 ' 'SR08CPS08:CURRENT_MONITOR' 'SR08CPS08:BASE_CURRENT_SP ' 1 [8,2] 16 0.2 ; ...
+'9SKQ1 ' 'SR09CPS03:CURRENT_MONITOR' 'SR09CPS03:BASE_CURRENT_SP ' 1 [9,1] 17 0.2 ; ...
+'9SKQ2 ' 'SR09CPS08:CURRENT_MONITOR' 'SR09CPS08:BASE_CURRENT_SP ' 1 [9,2] 18 0.2 ; ...
+'10SKQ1 ' 'SR10CPS03:CURRENT_MONITOR' 'SR10CPS03:BASE_CURRENT_SP ' 1 [10,1] 19 0.2 ; ...
+'10SKQ2 ' 'SR10CPS08:CURRENT_MONITOR' 'SR10CPS08:BASE_CURRENT_SP ' 1 [10,2] 20 0.2 ; ...
+'11SKQ1 ' 'SR11CPS03:CURRENT_MONITOR' 'SR11CPS03:BASE_CURRENT_SP ' 1 [11,1] 21 0.2 ; ...
+'11SKQ2 ' 'SR11CPS08:CURRENT_MONITOR' 'SR11CPS08:BASE_CURRENT_SP ' 1 [11,2] 22 0.2 ; ...
+'12SKQ1 ' 'SR12CPS03:CURRENT_MONITOR' 'SR12CPS03:BASE_CURRENT_SP ' 1 [12,1] 23 0.2 ; ...
+'12SKQ2 ' 'SR12CPS08:CURRENT_MONITOR' 'SR12CPS08:BASE_CURRENT_SP ' 1 [12,2] 24 0.2 ; ...
+'13SKQ1 ' 'SR13CPS03:CURRENT_MONITOR' 'SR13CPS03:BASE_CURRENT_SP ' 1 [13,1] 25 0.2 ; ...
+'13SKQ2 ' 'SR13CPS08:CURRENT_MONITOR' 'SR13CPS08:BASE_CURRENT_SP ' 1 [13,2] 26 0.2 ; ...
+'14SKQ1 ' 'SR14CPS03:CURRENT_MONITOR' 'SR14CPS03:BASE_CURRENT_SP ' 1 [14,1] 27 0.2 ; ...
+'14SKQ2 ' 'SR14CPS08:CURRENT_MONITOR' 'SR14CPS08:BASE_CURRENT_SP ' 1 [14,2] 28 0.2 ; ...
+};
+
+for ii=1:size(sq,1)
+name=sq{ii,1}; AO.SKQ.CommonNames(ii,:) = name;
+name=sq{ii,2}; AO.SKQ.Monitor.ChannelNames(ii,:) = name;
+name=sq{ii,3}; AO.SKQ.Setpoint.ChannelNames(ii,:) = name;
+val =sq{ii,4}; AO.SKQ.Status(ii,1) = val;
+val =sq{ii,5}; AO.SKQ.DeviceList(ii,:) = val;
+val =sq{ii,6}; AO.SKQ.ElementList(ii,1) = val;
+val =sq{ii,7}; AO.SKQ.Setpoint.Tolerance(ii,1) = val;
+AO.SKQ.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SKQ.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SKQ.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SKQ.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+
+AO.SKQ.Setpoint.Range(ii,:) = [-5 +5];
+end
+
+
+%===============
+%Kicker data
+%===============
+AO.KICK.FamilyName = 'KICK'; dispobject(AO,AO.KICK.FamilyName);
+AO.KICK.MemberOf = {'Injection'; 'MachineConfig'; 'Plotfamily'; 'HCM'; 'Horizontal'};
+
+AO.KICK.Monitor.Mode = Mode;
+AO.KICK.Monitor.DataType = 'Scalar';
+AO.KICK.Monitor.Units = 'Hardware';
+AO.KICK.Monitor.HWUnits = 'kVolts';
+AO.KICK.Monitor.PhysicsUnits = 'mradian';
+
+AO.KICK.Setpoint.Mode = Mode;
+AO.KICK.Setpoint.DataType = 'Scalar';
+AO.KICK.Setpoint.Units = 'Hardware';
+AO.KICK.Setpoint.HWUnits = 'Volts';
+AO.KICK.Setpoint.PhysicsUnits = 'radian';
+
+AO.KICK.Delay.Mode = Mode;
+AO.KICK.Delay.MemberOf = {'MachineConfig'};
+AO.KICK.Delay.DataType = 'Scalar';
+AO.KICK.Delay.Units = 'Hardware';
+AO.KICK.Delay.HWUnits = 'Second';
+AO.KICK.Delay.PhysicsUnits = 'Second';
+
+
+% From kicker deisgn review the kickers are rated to 4380 Amps giving 0.038
+% Tesla converting this to kickangle. Also convert voltage into amps for
+% the conversion?
+%
+% 2780 V on the capacitor banks will create 5240 A delivered to the kicker
+% magnets.
+% From simulations 4380 A creates 0.038607 T over a length of 0.7 m.
+% Therefore 4380 A => 2.7006 mrad. Therefore 2323.740 V => 2.7006 mrad.
+% HW2PHYSICS conversion factor (kV to rad) is therefore 0.0027006/2.32374 =
+% 0.00116217821271. The Ps also goes through a 1:3 transformer therefore
+% the conversion factor increases by 3. Ie 0.00348653463813
+% For V to rad then 0.00000348653463813.
+% hw2physics_conversionfactor = 0.00000348653463813;
+
+% Factory test reports give a 1200 v (1223 V average) setting on the panel
+% gives 4200 A. The curve is pretty much linear up to 1000 V, after which
+% it starts to taper off. Data for one of the curves is shown below. The
+% conversion factor for this data is 2.1366e-6.
+% v = [139 378 618 860 984 1111 1249 1396];
+% a = [420 1260 2100 2940 3360 3780 4200 4620];
+% mrad = a*0.0027006/4380;
+% figure; plot(v,mrad,'.-')
+% conversiontfactor = (mrad(5)-mrad(2))/(v(5) - v(2));
+
+% Measured (before fixing the kicker charging unit)
+% Kicker1 100 V = 0.176 mrad
+% Kicker2 100 V = -0.138 mrad
+% Kicker3 100 V = -0.134 mrad
+% Kicker4 100 V = 0.176 mrad
+
+%common monitor setpoint kickerdelay stat devlist elem tol
+kickeramp={
+'KICK1 ' 'SR14KPS01:VOLTAGE_MONITOR' 'SR14KPS01:VOLTAGE_SP ' 'TS01EVR06:TTL00_TIME_DELAY_SP' 1 [1,1] 1 0.10 ; ...
+'KICK2 ' 'SR01KPS01:VOLTAGE_MONITOR' 'SR01KPS01:VOLTAGE_SP ' 'TS01EVR06:TTL01_TIME_DELAY_SP' 1 [1,2] 2 0.10 ; ...
+'KICK3 ' 'SR01KPS02:VOLTAGE_MONITOR' 'SR01KPS02:VOLTAGE_SP ' 'TS01EVR06:TTL02_TIME_DELAY_SP' 1 [1,3] 3 0.10 ; ...
+'KICK4 ' 'SR02KPS01:VOLTAGE_MONITOR' 'SR02KPS01:VOLTAGE_SP ' 'TS01EVR06:TTL03_TIME_DELAY_SP' 1 [1,4] 4 0.10 ; ...
+};
+
+for ii=1:size(kickeramp,1)
+name=kickeramp{ii,1}; AO.KICK.CommonNames(ii,:) = name;
+name=kickeramp{ii,2}; AO.KICK.Monitor.ChannelNames(ii,:) = name;
+name=kickeramp{ii,3}; AO.KICK.Setpoint.ChannelNames(ii,:)= name;
+name=kickeramp{ii,4}; AO.KICK.Delay.ChannelNames(ii,:) = name;
+val =kickeramp{ii,5}; AO.KICK.Status(ii,1) = val;
+val =kickeramp{ii,6}; AO.KICK.DeviceList(ii,:) = val;
+val =kickeramp{ii,7}; AO.KICK.ElementList(ii,1) = val;
+val =kickeramp{ii,8}; AO.KICK.Setpoint.Tolerance(ii,1) = val;
+
+% changed back to one calibration value after kickers 2 and 3 had their
+% charging units repaired
+% Mark Boland 2007-09-17
+if ii==2 || ii==3
+ isign = -1;
+else
+ isign = 1;
+end
+% scaling factor 0.72 arrived by comparing measured with dynamic model
+% where the kick strenght changes like a half sin function.
+hw2physics_conversionfactor = isign*1.7600e-06*0.7211;
+AO.KICK.Monitor.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
+AO.KICK.Monitor.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
+AO.KICK.Setpoint.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
+AO.KICK.Setpoint.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
+AO.KICK.Setpoint.Range(ii,:) = [-1300 +1300];
+AO.KICK.Delay.HW2PhysicsParams(ii,:) = 1;
+AO.KICK.Delay.Physics2HWParams(ii,:) = 1;
+AO.KICK.Delay.Range(ii,:) = [0 1];
+end
+
+% Add kick profile for dynamic modelling
+% Kick profile from measured data to be used as the profile for the kickers
+t = [-0.1 -0.05 0 0.4 1 2 2.5 4 4.8 5.0 5.2 5.4 6.0 7.05 7.1]*1e-6;
+amp = [0 0 0 1000 3000 5500 5900 3000 -200 -400 0 50 0 0 0];
+tspline = [-0.1:0.05:7.1]*1e-6;
+ampspline = spline(t,amp,tspline);
+tspline = [tspline(1)-1.5e-6, tspline, tspline(end)+0.720e-6*10]; % add zeros to ends for interpolation
+ampspline = [0, ampspline, 0];
+
+AO.KICK.profile_t = tspline;
+AO.KICK.profile_amp = ampspline/max(ampspline); % Normalise profile
+
+
+% *** KICK Delay ***
+% AO.KICK.Delay
+% >> removed >> see previous versions if info needed
+
+
+%============
+%RF System
+%============
+AO.RF.FamilyName = 'RF'; dispobject(AO,AO.RF.FamilyName);
+AO.RF.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
+
+%-------------------------------- 4 cavity Case
+%common stat devlist elem
+rfcommon={
+'RF1 ' 1 [1,1] 1 ; ...
+'RF2 ' 1 [1,2] 2 ; ...
+'RF3 ' 1 [1,3] 3 ; ...
+'RF4 ' 1 [1,4] 4 ; ...
+ };
+
+% Set frequency range to be +-30kHz (dP/P = +-2.8%) about 499.674 MHz
+%FreqMon FreqSetpoint HW2PhysicsParams Physics2HWParams Range Tolerance
+rffreq={
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [499.644e6 499.704e6] 100.0; ...
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [499.644e6 499.704e6] 100.0; ...
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [499.644e6 499.704e6] 100.0; ...
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [499.644e6 499.704e6] 100.0; ...
+ };
+
+% PhaseCtrl PhaseMon HW2PhysicsParams Physics2HWParams Range Tolerance
+rfphase={
+'SRF1:STN:PHASE' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
+'SRF2:STN:PHASE' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
+'SRF3:STN:PHASE' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
+'SRF4:STN:PHASE' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
+ };
+
+% VoltCtrl VoltMon HW2PhysicsParams Physics2HWParams Range Tolerance
+rfvolt_sp={
+'SR06RF01CAV01:VOLTAGE_REFERENCE_SP' 754.3/677; ...
+'SR06RF02CAV01:VOLTAGE_REFERENCE_SP' 748.1/664; ...
+'SR07RF01CAV01:VOLTAGE_REFERENCE_SP' 753.4/687; ...
+'SR07RF02CAV01:VOLTAGE_REFERENCE_SP' 754.4/698; ...
+ };
+rfvolt_monitor={
+'SR06RF01CAV01:VOLTAGE_MONITOR' 754.3/707.7; ...
+'SR06RF02CAV01:VOLTAGE_MONITOR' 748.1/701.5; ...
+'SR07RF01CAV01:VOLTAGE_MONITOR' 753.4/726.2; ...
+'SR07RF02CAV01:VOLTAGE_MONITOR' 754.4/727.7; ...
+ };
+
+% PowerCtrl PowerMon Klystronpower HW2PhysicsParams Physics2HWParams Range Tolerance
+rfpower={
+'SRF1:KLYSDRIVFRWD:POWER:ON ' 'SR06RF01CAV01:FWD_MONITOR' 'SR06RF01KLY01:FWD_MONITOR' 1 1 [-inf inf] inf ; ...
+'SRF2:KLYSDRIVFRWD:POWER:ON ' 'SR06RF02CAV01:FWD_MONITOR' 'SR06RF02KLY01:FWD_MONITOR' 1 1 [-inf inf] inf ; ...
+'SRF3:KLYSDRIVFRWD:POWER:ON ' 'SR07RF01CAV01:FWD_MONITOR' 'SR07RF01KLY01:FWD_MONITOR' 1 1 [-inf inf] inf ; ...
+'SRF4:KLYSDRIVFRWD:POWER:ON ' 'SR07RF02CAV01:FWD_MONITOR' 'SR07RF02KLY01:FWD_MONITOR' 1 1 [-inf inf] inf ; ...
+ };
+
+for ii=1:size(rfcommon,1)
+name=rfcommon{ii,1}; AO.RF.CommonNames(ii,:) = name;
+val =rfcommon{ii,2}; AO.RF.Status(ii,1) = val;
+val =rfcommon{ii,3}; AO.RF.DeviceList(ii,:) = val;
+val =rfcommon{ii,4}; AO.RF.ElementList(ii,1) = val;
+end
+
+for ii=1:size(rffreq,1)
+name=rffreq{ii,1}; AO.RF.Monitor.ChannelNames(ii,:) = name;
+name=rffreq{ii,2}; AO.RF.Setpoint.ChannelNames(ii,:) = name;
+val =rffreq{ii,3}; AO.RF.Monitor.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Setpoint.HW2PhysicsParams(ii,1) = val;
+val =rffreq{ii,4}; AO.RF.Monitor.Physics2HWParams(ii,1) = val;
+ AO.RF.Setpoint.Physics2HWParams(ii,1) = val;
+val =rffreq{ii,5}; AO.RF.Setpoint.Range(ii,:) = val;
+val =rffreq{ii,6}; AO.RF.Setpoint.Tolerance(ii,1) = val;
+end
+
+
+for ii=1:size(rfphase,1)
+name=rfphase{ii,1}; AO.RF.PhaseCtrl.ChannelNames(ii,:) = name;
+name=rfphase{ii,2}; AO.RF.Phase.ChannelNames(ii,:) = name;
+val =rfphase{ii,3}; AO.RF.PhaseCtrl.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Phase.HW2PhysicsParams(ii,1) = val;
+val =rfphase{ii,4}; AO.RF.PhaseCtrl.Physics2HWParams(ii,1) = val;
+ AO.RF.Phase.Physics2HWParams(ii,1) = val;
+val =rfphase{ii,5}; AO.RF.PhaseCtrl.Range(ii,:) = val;
+ AO.RF.Phase.Range(ii,:) = val;
+val =rfphase{ii,6}; AO.RF.PhaseCtrl.Tolerance(ii,1) = val;
+ AO.RF.Phase.Tolerance(ii,1) = val;
+end
+
+
+for ii=1:size(rfvolt_sp,1)
+AO.RF.VoltageSP.ChannelNames(ii,:) = rfvolt_sp{ii,1};
+AO.RF.Voltage.ChannelNames(ii,:) = rfvolt_monitor{ii,1};
+
+AO.RF.VoltageSP.HW2PhysicsParams(ii,1) = rfvolt_sp{ii,2};
+AO.RF.Voltage.HW2PhysicsParams(ii,1) = rfvolt_monitor{ii,2};
+
+AO.RF.VoltageSP.Physics2HWParams(ii,1) = 1/rfvolt_sp{ii,2};
+AO.RF.Voltage.Physics2HWParams(ii,1) = 1/rfvolt_monitor{ii,2};
+
+AO.RF.VoltageSP.Range(ii,:) = [0 800];
+AO.RF.Voltage.Range(ii,:) = [0 800];
+
+AO.RF.VoltageSP.Tolerance(ii,1) = 2;
+AO.RF.Voltage.Tolerance(ii,1) = 2;
+end
+
+
+for ii=1:size(rfpower,1)
+name=rfpower{ii,1}; AO.RF.PowerCtrl.ChannelNames(ii,:) = name;
+name=rfpower{ii,2}; AO.RF.Power.ChannelNames(ii,:) = name;
+name=rfpower{ii,3}; AO.RF.KlysPower.ChannelNames(ii,:) = name;
+val =rfpower{ii,4}; AO.RF.PowerCtrl.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Power.HW2PhysicsParams(ii,1) = val;
+ AO.RF.KlysPower.HW2PhysicsParams(ii,1) = val;
+val =rfpower{ii,5}; AO.RF.PowerCtrl.Physics2HWParams(ii,1) = val;
+ AO.RF.Power.Physics2HWParams(ii,1) = val;
+ AO.RF.KlysPower.Physics2HWParams(ii,1) = val;
+val =rfpower{ii,6}; AO.RF.PowerCtrl.Range(ii,:) = val;
+ AO.RF.Power.Range(ii,:) = val;
+ AO.RF.KlysPower.Range(ii,:) = val;
+val =rfpower{ii,7}; AO.RF.PowerCtrl.Tolerance(ii,1) = val;
+ AO.RF.Power.Tolerance(ii,1) = val;
+ AO.RF.KlysPower.Tolerance(ii,1) = val;
+end
+
+%Frequency Readback
+AO.RF.Monitor.Mode = Mode;
+AO.RF.Monitor.DataType = 'Scalar';
+AO.RF.Monitor.Units = 'Hardware';
+AO.RF.Monitor.HWUnits = 'Hz';
+AO.RF.Monitor.PhysicsUnits = 'Hz';
+%Frequency Setpoint
+AO.RF.Setpoint.Mode = Mode;
+AO.RF.Setpoint.DataType = 'Scalar';
+AO.RF.Setpoint.Units = 'Hardware';
+AO.RF.Setpoint.HWUnits = 'Hz';
+AO.RF.Setpoint.PhysicsUnits = 'Hz';
+
+%Voltage control
+AO.RF.VoltageSP.Mode = Mode;
+AO.RF.VoltageSP.DataType = 'Scalar';
+AO.RF.VoltageSP.Units = 'Hardware';
+AO.RF.VoltageSP.HWUnits = 'Volts';
+AO.RF.VoltageSP.PhysicsUnits = 'Volts';
+AO.RF.VoltageSP.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
+
+%Voltage monitor
+AO.RF.Voltage.Mode = Mode;
+AO.RF.Voltage.DataType = 'Scalar';
+AO.RF.Voltage.Units = 'Hardware';
+AO.RF.Voltage.HWUnits = 'kVolts';
+AO.RF.Voltage.PhysicsUnits = 'Volts';
+AO.RF.Voltage.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
+
+%Power Control
+AO.RF.PowerCtrl.Mode = Mode;
+AO.RF.PowerCtrl.DataType = 'Scalar';
+AO.RF.PowerCtrl.Units = 'Hardware';
+AO.RF.PowerCtrl.HWUnits = 'MWatts';
+AO.RF.PowerCtrl.PhysicsUnits = 'MWatts';
+
+%Power Monitor
+AO.RF.Power.Mode = Mode;
+AO.RF.Power.DataType = 'Scalar';
+AO.RF.Power.Units = 'Hardware';
+AO.RF.Power.HWUnits = 'kWatts';
+AO.RF.Power.PhysicsUnits = 'kWatts';
+AO.RF.Power.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
+
+%Klystron Forward Power
+AO.RF.KlysPower.Mode = Mode;
+AO.RF.KlysPower.DataType = 'Scalar';
+AO.RF.KlysPower.Units = 'Hardware';
+AO.RF.KlysPower.HWUnits = 'kWatts';
+AO.RF.KlysPower.PhysicsUnits = 'kWatts';
+AO.RF.KlysPower.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
+
+%Station Phase Control
+AO.RF.PhaseCtrl.Mode = Mode;
+AO.RF.PhaseCtrl.DataType = 'Scalar';
+AO.RF.PhaseCtrl.Units = 'Hardware';
+AO.RF.PhaseCtrl.HWUnits = 'Degrees';
+AO.RF.PhaseCtrl.PhysicsUnits = 'Degrees';
+
+%Station Phase Monitor
+AO.RF.Phase.Mode = Mode;
+AO.RF.Phase.DataType = 'Scalar';
+AO.RF.Phase.Units = 'Hardware';
+AO.RF.Phase.HWUnits = 'Degrees';
+AO.RF.Phase.PhysicsUnits = 'Degrees';
+
+%====
+%TUNE
+%====
+AO.TUNE.FamilyName = 'TUNE'; dispobject(AO,AO.TUNE.FamilyName);
+AO.TUNE.MemberOf = {'Tune'; 'Diagnostics'};
+AO.TUNE.CommonNames = ['xtune';'ytune'];
+AO.TUNE.DeviceList = [ 1 1; 1 2];
+AO.TUNE.ElementList = [1 2]';
+AO.TUNE.Status = [1 1]';
+
+AO.TUNE.Monitor.Mode = 'Special';
+AO.TUNE.Monitor.SpecialFunction = 'meastune';
+AO.TUNE.Monitor.DataType = 'Vector';
+AO.TUNE.Monitor.DataTypeIndex = [1 2]';
+AO.TUNE.Monitor.Units = 'Hardware';
+AO.TUNE.Monitor.HW2PhysicsParams = 1;
+AO.TUNE.Monitor.Physics2HWParams = 1;
+AO.TUNE.Monitor.HWUnits = 'fractional tune';
+AO.TUNE.Monitor.PhysicsUnits = 'fractional tune';
+
+
+%====
+%DCCT
+%====
+AO.DCCT.FamilyName = 'DCCT'; dispobject(AO,AO.DCCT.FamilyName);
+AO.DCCT.MemberOf = {'Diagnostics'};
+AO.DCCT.CommonNames = 'DCCT';
+AO.DCCT.DeviceList = [1 1];
+AO.DCCT.ElementList = [1];
+AO.DCCT.Status = [1];
+
+AO.DCCT.Monitor.Mode = Mode;
+AO.DCCT.Monitor.DataType = 'Scalar';
+AO.DCCT.Monitor.ChannelNames = 'SR11BCM01:CURRENT_MONITOR';
+AO.DCCT.Monitor.Units = 'Hardware';
+AO.DCCT.Monitor.HWUnits = 'milli-ampere';
+AO.DCCT.Monitor.PhysicsUnits = 'ampere';
+AO.DCCT.Monitor.HW2PhysicsParams = 1e-3;
+AO.DCCT.Monitor.Physics2HWParams = 1000;
+
+
+% %==================
+% %Machine Parameters
+% %==================
+% Removed in this version, see pervious version for more info
+
+%======
+%Septum
+%======
+% ifam=ifam+1;
+% AO.Septum.FamilyName = 'Septum'; dispobject(AO,AO.Septum.FamilyName);
+% AO.Septum.MemberOf = {'Injection'};
+% AO.Septum.Status = 1;
+%
+% AO.Septum.CommonNames = 'Septum ';
+% AO.Septum.DeviceList = [3 1];
+% AO.Septum.ElementList = [1];
+%
+% AO.Septum.Monitor.Mode = Mode;
+% AO.Septum.Monitor.DataType = 'Scalar';
+% AO.Septum.Monitor.Units = 'Hardware';
+% AO.Septum.Monitor.HWUnits = 'ampere';
+% AO.Septum.Monitor.PhysicsUnits = 'radian';
+% AO.Septum.Monitor.ChannelNames = 'BTS-B9V:Curr';
+%
+% AO.Septum.Setpoint.Mode = Mode;
+% AO.Septum.Setpoint.DataType = 'Scalar';
+% AO.Septum.Setpoint.Units = 'Hardware';
+% AO.Septum.Setpoint.HWUnits = 'ampere';
+% AO.Septum.Setpoint.PhysicsUnits = 'radian';
+% AO.Septum.Setpoint.ChannelNames = 'BTS-B9V:CurrSetpt';
+% AO.Septum.Setpoint.Range = [0, 2500];
+% AO.Septum.Setpoint.Tolerance = 100.0;
+%
+% AO.Septum.Monitor.HW2PhysicsParams = 1;
+% AO.Septum.Monitor.Physics2HWParams = 1;
+% AO.Septum.Setpoint.HW2PhysicsParams = 1;
+% AO.Septum.Setpoint.Physics2HWParams = 1;
+
+
+%====================
+%Photon Beamline Data
+%====================
+% >> removed >> see previous versions if info needed
+
+%====================
+%BPLD Data
+%====================
+% >> removed >> see previous versions if info needed
+
+% The operational mode sets the path, filenames, and other important parameters
+% Run setoperationalmode after most of the AO is built so that the Units and Mode fields
+% can be set in setoperationalmode
+fprintf('\n');
+setao(AO);
+setoperationalmode(OperationalMode);
+AO = getao;
+
+
+%%%%%%%%%%%%%%%%
+% DeltaRespMat %
+%%%%%%%%%%%%%%%%
+
+% I remove the physics2hw conversion because the physics2hw is
+% is calibrated yet.
+
+% Set response matrix kick size in hardware units (amps)
+%AO = getao;
+AO.HCM.Setpoint.DeltaRespMat = physics2hw('HCM', 'Setpoint', 1.8e-5, AO.HCM.DeviceList);
+AO.VCM.Setpoint.DeltaRespMat = physics2hw('VCM', 'Setpoint', 0.9e-5, AO.VCM.DeviceList);
+%setao(AO);
+%AD = getad;
+%AD.DeltaRFDisp = 500;
+%setad(AD);
+
+AO.HFC.Setpoint.DeltaRespMat = 0.5;
+AO.VFC.Setpoint.DeltaRespMat = 0.5;
+
+AO.KICK.Setpoint.DeltaRespMat = 50;
+
+%% 'NoEnergyScaling' because I don't want to force a BEND magnet read at this point
+%AO.HCM.Setpoint.DeltaRespMat = mm2amps('HCM', .5, AO.HCM.DeviceList, 'NoEnergyScaling');
+%AO.VCM.Setpoint.DeltaRespMat = mm2amps('VCM', .5, AO.VCM.DeviceList, 'NoEnergyScaling');
+
+
+AO.QFA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFA.FamilyName, 'Setpoint', AO.QFA.Setpoint.DeltaRespMat, AO.QFA.DeviceList);
+AO.QFB.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFB.FamilyName, 'Setpoint', AO.QFB.Setpoint.DeltaRespMat, AO.QFB.DeviceList);
+AO.QDA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QDA.FamilyName, 'Setpoint', AO.QDA.Setpoint.DeltaRespMat, AO.QDA.DeviceList);
+
+
+AO.SFA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFA.FamilyName, 'Setpoint', AO.SFA.Setpoint.DeltaRespMat, AO.SFA.DeviceList);
+AO.SFB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFB.FamilyName, 'Setpoint', AO.SFB.Setpoint.DeltaRespMat, AO.SFB.DeviceList);
+AO.SDA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDA.FamilyName, 'Setpoint', AO.SDA.Setpoint.DeltaRespMat, AO.SDA.DeviceList);
+AO.SDB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDB.FamilyName, 'Setpoint', AO.SDB.Setpoint.DeltaRespMat, AO.SDB.DeviceList);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Get S-positions [meters] %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Using ...ATIndex(:,1) will accomodata for split elements where the first
+% of a group of elements is put in the first column ie, if SFA is split in
+% two then ATIndex will look like [2 3; 11 12; ...] where each row is a
+% magnet and column represents each split.
+global THERING
+AO.BPMx.Position = findspos(THERING, AO.BPMx.AT.ATIndex(:,1))';
+AO.BPMy.Position = findspos(THERING, AO.BPMy.AT.ATIndex(:,1))';
+AO.HCM.Position = findspos(THERING, AO.HCM.AT.ATIndex(:,1))';
+AO.VCM.Position = findspos(THERING, AO.VCM.AT.ATIndex(:,1))';
+AO.HFC.Position = findspos(THERING, AO.HFC.AT.ATIndex(:,1))';
+AO.VFC.Position = findspos(THERING, AO.VFC.AT.ATIndex(:,1))';
+AO.QFA.Position = findspos(THERING, AO.QFA.AT.ATIndex(:,1))';
+AO.QDA.Position = findspos(THERING, AO.QDA.AT.ATIndex(:,1))';
+AO.QFB.Position = findspos(THERING, AO.QFB.AT.ATIndex(:,1))';
+AO.SFA.Position = findspos(THERING, AO.SFA.AT.ATIndex(:,1))';
+AO.SFB.Position = findspos(THERING, AO.SFB.AT.ATIndex(:,1))';
+AO.SDA.Position = findspos(THERING, AO.SDA.AT.ATIndex(:,1))';
+AO.SDB.Position = findspos(THERING, AO.SDB.AT.ATIndex(:,1))';
+AO.SKQ.Position = findspos(THERING, AO.SKQ.AT.ATIndex(:,1))';
+AO.BEND.Position = findspos(THERING, AO.BEND.AT.ATIndex(:,1))';
+AO.RF.Position = findspos(THERING, AO.RF.AT.ATIndex(:,1))';
+AO.KICK.Position = findspos(THERING, AO.KICK.AT.ATIndex(:,1))';
+AO.DCCT.Position = 0;
+AO.TUNE.Position = 0;
+
+
+% Save AO
+setao(AO);
+
+
+function dispobject(AO,name)
+
+n = length(fieldnames(AO));
+
+if n > 0
+ fprintf(' %10s ',name);
+ if mod(n,5) == 0
+ fprintf('\n');
+ end
+end
diff --git a/machine/ASP/StorageRing/aspinitRF.m b/machine/ASP/StorageRing/aspinitRF.m
index 1892891d..a8d94b3f 100644
--- a/machine/ASP/StorageRing/aspinitRF.m
+++ b/machine/ASP/StorageRing/aspinitRF.m
@@ -1,1753 +1,1753 @@
-function aspinit(OperationalMode)
-% aspinit(OperationalMode)
-%
-% Initialize parameters for ASP control in MATLAB
-%
-%==========================
-% Accelerator Family Fields
-%==========================
-% FamilyName BPMx, HCM, etc
-% CommonNames Shortcut name for each element (optional)
-% DeviceList [Sector, Number]
-% ElementList number in list
-% Position m, magnet center
-%
-% MONITOR FIELDS
-% Mode online/manual/special/simulator
-% ChannelNames PV for monitor
-% Units Physics or HW
-% HW2PhysicsFcn function handle used to convert from hardware to physics units ==> inline will not compile, see below
-% HW2PhysicsParams parameters used for conversion function
-% Physics2HWFcn function handle used to convert from physics to hardware units
-% Physics2HWParams parameters used for conversion function
-% HWUnits units for Hardware 'ampere';
-% PhysicsUnits units for physics 'Rad';
-%
-% SETPOINT FIELDS
-% Mode online/manual/special/simulator
-% ChannelNames PV for monitor
-% Units hardware or physics
-% HW2PhysicsFcn function handle used to convert from hardware to physics units
-% HW2PhysicsParams parameters used for conversion function
-% Physics2HWFcn function handle used to convert from physics to hardware units
-% Physics2HWParams parameters used for conversion function
-% HWUnits units for Hardware 'ampere';
-% PhysicsUnits units for physics 'Rad';
-% Range minsetpoint, maxsetpoint;
-% Tolerance setpoint-monitor
-%
-%=============================================
-% Accelerator Toolbox Simulation Fields
-%=============================================
-% ATType Quad, Sext, etc
-% ATIndex index in THERING
-% ATParameterGroup parameter group
-%
-%============
-% Family List
-%============
-% BPMx BPMy - beam position monitors
-% HCM VCM - corrector magnets wound into sextupoles
-% BEND - gradient dipoles
-% QFA QDA QFB - quadrupole magnets
-% SFA SDA SDB SFB - sextupole magnets
-% SQK - skew quads wound into SDA magnets
-% KICK - injection kickers (DELTA type)
-% RF - 4 cavities (KEK type?)
-% DCCT
-% Septum (Not in model yet)
-%
-% Normal cell: d1 bpm s1 hcor d2 q1 d3 s2 d4 bpm dip bpm d4 hcor s3 d5 q2 d6 q3 d2 bpm s4
-% d2 q3 d6 q2 d5 s3 hcor d4 bpm dip bpm d4 s2 d3 q1 d2 hcor s1 bpm d1
-
-% === Change Log ===
-% Mark Boland 2004-02-12
-% Eugene Tan 2004-02-23
-% Eugene Tan 2004-12-13
-% Eugene Tan 2005-09-27 ver 4
-% Updated naming convention of the process variables, use version 4 of
-% the lattice "assr4.m" where the correctors have been merged into the
-% sextupoles. Made the necessary changes to updateatindex. Added skew
-% quadrupoles and updated generate_init.
-% Mark Boland 2006-05-27
-% Changed the BPM PVs to ...:SA_HPOS_MONITOR and ...:SA_VPOS_MONITOR
-%
-% === Still to do ===
-% - kicker delays
-% - BPM names and other possible PVs of interest eg. Q factor etc.
-% - clean up and configure the amp2k and k2amp conversion. Control system
-% designed to calculate the strengths and amp values using calc records,
-% therefore we should only need to change the PV name to access for
-% readback at setpoints. Only problem will be in simulation/offline mode
-% where those value are not available online. How do you keep the offline
-% conversion factors up to date with online vals?
-%
-% === Generated from ===
-% aspinit_v5skeleton.m
-
-% Default operational mode
-if nargin < 1
- OperationalMode = 2;
-end
-
-
-%=============================================
-% START DEFINITION OF ACCELERATOR OBJECTS
-%=============================================
-fprintf(' Defining the Accelerator Objects. Objects being defined:\n')
-
-
-% Clear previous AcceleratorObjects
-setao([]);
-
-
-Mode = 'Online'; % This gets reset in setoperationalmode
-
-%=============================================
-%BPM data: status field designates if BPM in use
-%=============================================
-ntbpm=98;
-AO.BPMx.FamilyName = 'BPMx'; dispobject(AO,AO.BPMx.FamilyName);
-AO.BPMx.MemberOf = {'PlotFamily';};% 'BPM'; 'Diagnostics'};
-AO.BPMx.Monitor.Mode = Mode;
-AO.BPMx.Monitor.DataType = 'Scalar';
-AO.BPMx.Monitor.Units = 'Hardware';
-AO.BPMx.Monitor.HWUnits = 'mm';
-AO.BPMx.Monitor.PhysicsUnits = 'meter';
-
-AO.BPMy.FamilyName = 'BPMy'; dispobject(AO,AO.BPMy.FamilyName);
-AO.BPMy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
-AO.BPMy.Monitor.Mode = Mode;
-AO.BPMy.Monitor.DataType = 'Scalar';
-AO.BPMy.Monitor.Units = 'Hardware';
-AO.BPMy.Monitor.HWUnits = 'mm';
-AO.BPMy.Monitor.PhysicsUnits = 'meter';
-
-% x-name x-chname xstat y-name y-chname ystat DevList Elem
-bpm={
-'1BPMx1 ' 'SR01BPM01:SA_HPOS_MONITOR' 1 '1BPMy1 ' 'SR01BPM01:SA_VPOS_MONITOR' 1 [1,1] 1 ; ...
-'1BPMx2 ' 'SR01BPM02:SA_HPOS_MONITOR' 1 '1BPMy2 ' 'SR01BPM02:SA_VPOS_MONITOR' 1 [1,2] 2 ; ...
-'1BPMx3 ' 'SR01BPM03:SA_HPOS_MONITOR' 1 '1BPMy3 ' 'SR01BPM03:SA_VPOS_MONITOR' 1 [1,3] 3 ; ...
-'1BPMx4 ' 'SR01BPM04:SA_HPOS_MONITOR' 1 '1BPMy4 ' 'SR01BPM04:SA_VPOS_MONITOR' 1 [1,4] 4 ; ...
-'1BPMx5 ' 'SR01BPM05:SA_HPOS_MONITOR' 1 '1BPMy5 ' 'SR01BPM05:SA_VPOS_MONITOR' 1 [1,5] 5 ; ...
-'1BPMx6 ' 'SR01BPM06:SA_HPOS_MONITOR' 1 '1BPMy6 ' 'SR01BPM06:SA_VPOS_MONITOR' 1 [1,6] 6 ; ...
-'1BPMx7 ' 'SR01BPM07:SA_HPOS_MONITOR' 1 '1BPMy7 ' 'SR01BPM07:SA_VPOS_MONITOR' 1 [1,7] 7 ; ...
-'2BPMx1 ' 'SR02BPM01:SA_HPOS_MONITOR' 1 '2BPMy1 ' 'SR02BPM01:SA_VPOS_MONITOR' 1 [2,1] 8 ; ...
-'2BPMx2 ' 'SR02BPM02:SA_HPOS_MONITOR' 1 '2BPMy2 ' 'SR02BPM02:SA_VPOS_MONITOR' 1 [2,2] 9 ; ...
-'2BPMx3 ' 'SR02BPM03:SA_HPOS_MONITOR' 1 '2BPMy3 ' 'SR02BPM03:SA_VPOS_MONITOR' 1 [2,3] 10 ; ...
-'2BPMx4 ' 'SR02BPM04:SA_HPOS_MONITOR' 1 '2BPMy4 ' 'SR02BPM04:SA_VPOS_MONITOR' 1 [2,4] 11 ; ...
-'2BPMx5 ' 'SR02BPM05:SA_HPOS_MONITOR' 1 '2BPMy5 ' 'SR02BPM05:SA_VPOS_MONITOR' 1 [2,5] 12 ; ...
-'2BPMx6 ' 'SR02BPM06:SA_HPOS_MONITOR' 1 '2BPMy6 ' 'SR02BPM06:SA_VPOS_MONITOR' 1 [2,6] 13 ; ...
-'2BPMx7 ' 'SR02BPM07:SA_HPOS_MONITOR' 1 '2BPMy7 ' 'SR02BPM07:SA_VPOS_MONITOR' 1 [2,7] 14 ; ...
-'3BPMx1 ' 'SR03BPM01:SA_HPOS_MONITOR' 1 '3BPMy1 ' 'SR03BPM01:SA_VPOS_MONITOR' 1 [3,1] 15 ; ...
-'3BPMx2 ' 'SR03BPM02:SA_HPOS_MONITOR' 1 '3BPMy2 ' 'SR03BPM02:SA_VPOS_MONITOR' 1 [3,2] 16 ; ...
-'3BPMx3 ' 'SR03BPM03:SA_HPOS_MONITOR' 1 '3BPMy3 ' 'SR03BPM03:SA_VPOS_MONITOR' 1 [3,3] 17 ; ...
-'3BPMx4 ' 'SR03BPM04:SA_HPOS_MONITOR' 1 '3BPMy4 ' 'SR03BPM04:SA_VPOS_MONITOR' 1 [3,4] 18 ; ...
-'3BPMx5 ' 'SR03BPM05:SA_HPOS_MONITOR' 1 '3BPMy5 ' 'SR03BPM05:SA_VPOS_MONITOR' 1 [3,5] 19 ; ...
-'3BPMx6 ' 'SR03BPM06:SA_HPOS_MONITOR' 1 '3BPMy6 ' 'SR03BPM06:SA_VPOS_MONITOR' 1 [3,6] 20 ; ...
-'3BPMx7 ' 'SR03BPM07:SA_HPOS_MONITOR' 1 '3BPMy7 ' 'SR03BPM07:SA_VPOS_MONITOR' 1 [3,7] 21 ; ...
-'4BPMx1 ' 'SR04BPM01:SA_HPOS_MONITOR' 1 '4BPMy1 ' 'SR04BPM01:SA_VPOS_MONITOR' 1 [4,1] 22 ; ...
-'4BPMx2 ' 'SR04BPM02:SA_HPOS_MONITOR' 1 '4BPMy2 ' 'SR04BPM02:SA_VPOS_MONITOR' 1 [4,2] 23 ; ...
-'4BPMx3 ' 'SR04BPM03:SA_HPOS_MONITOR' 1 '4BPMy3 ' 'SR04BPM03:SA_VPOS_MONITOR' 1 [4,3] 24 ; ...
-'4BPMx4 ' 'SR04BPM04:SA_HPOS_MONITOR' 1 '4BPMy4 ' 'SR04BPM04:SA_VPOS_MONITOR' 1 [4,4] 25 ; ...
-'4BPMx5 ' 'SR04BPM05:SA_HPOS_MONITOR' 1 '4BPMy5 ' 'SR04BPM05:SA_VPOS_MONITOR' 1 [4,5] 26 ; ...
-'4BPMx6 ' 'SR04BPM06:SA_HPOS_MONITOR' 1 '4BPMy6 ' 'SR04BPM06:SA_VPOS_MONITOR' 1 [4,6] 27 ; ...
-'4BPMx7 ' 'SR04BPM07:SA_HPOS_MONITOR' 1 '4BPMy7 ' 'SR04BPM07:SA_VPOS_MONITOR' 1 [4,7] 28 ; ...
-'5BPMx1 ' 'SR05BPM01:SA_HPOS_MONITOR' 1 '5BPMy1 ' 'SR05BPM01:SA_VPOS_MONITOR' 1 [5,1] 29 ; ...
-'5BPMx2 ' 'SR05BPM02:SA_HPOS_MONITOR' 1 '5BPMy2 ' 'SR05BPM02:SA_VPOS_MONITOR' 1 [5,2] 30 ; ...
-'5BPMx3 ' 'SR05BPM03:SA_HPOS_MONITOR' 1 '5BPMy3 ' 'SR05BPM03:SA_VPOS_MONITOR' 1 [5,3] 31 ; ...
-'5BPMx4 ' 'SR05BPM04:SA_HPOS_MONITOR' 1 '5BPMy4 ' 'SR05BPM04:SA_VPOS_MONITOR' 1 [5,4] 32 ; ...
-'5BPMx5 ' 'SR05BPM05:SA_HPOS_MONITOR' 1 '5BPMy5 ' 'SR05BPM05:SA_VPOS_MONITOR' 1 [5,5] 33 ; ...
-'5BPMx6 ' 'SR05BPM06:SA_HPOS_MONITOR' 1 '5BPMy6 ' 'SR05BPM06:SA_VPOS_MONITOR' 1 [5,6] 34 ; ...
-'5BPMx7 ' 'SR05BPM07:SA_HPOS_MONITOR' 1 '5BPMy7 ' 'SR05BPM07:SA_VPOS_MONITOR' 1 [5,7] 35 ; ...
-'6BPMx1 ' 'SR06BPM01:SA_HPOS_MONITOR' 1 '6BPMy1 ' 'SR06BPM01:SA_VPOS_MONITOR' 1 [6,1] 36 ; ...
-'6BPMx2 ' 'SR06BPM02:SA_HPOS_MONITOR' 1 '6BPMy2 ' 'SR06BPM02:SA_VPOS_MONITOR' 1 [6,2] 37 ; ...
-'6BPMx3 ' 'SR06BPM03:SA_HPOS_MONITOR' 1 '6BPMy3 ' 'SR06BPM03:SA_VPOS_MONITOR' 1 [6,3] 38 ; ...
-'6BPMx4 ' 'SR06BPM04:SA_HPOS_MONITOR' 1 '6BPMy4 ' 'SR06BPM04:SA_VPOS_MONITOR' 1 [6,4] 39 ; ...
-'6BPMx5 ' 'SR06BPM05:SA_HPOS_MONITOR' 1 '6BPMy5 ' 'SR06BPM05:SA_VPOS_MONITOR' 1 [6,5] 40 ; ...
-'6BPMx6 ' 'SR06BPM06:SA_HPOS_MONITOR' 1 '6BPMy6 ' 'SR06BPM06:SA_VPOS_MONITOR' 1 [6,6] 41 ; ...
-'6BPMx7 ' 'SR06BPM07:SA_HPOS_MONITOR' 1 '6BPMy7 ' 'SR06BPM07:SA_VPOS_MONITOR' 1 [6,7] 42 ; ...
-'7BPMx1 ' 'SR07BPM01:SA_HPOS_MONITOR' 1 '7BPMy1 ' 'SR07BPM01:SA_VPOS_MONITOR' 1 [7,1] 43 ; ...
-'7BPMx2 ' 'SR07BPM02:SA_HPOS_MONITOR' 1 '7BPMy2 ' 'SR07BPM02:SA_VPOS_MONITOR' 1 [7,2] 44 ; ...
-'7BPMx3 ' 'SR07BPM03:SA_HPOS_MONITOR' 1 '7BPMy3 ' 'SR07BPM03:SA_VPOS_MONITOR' 1 [7,3] 45 ; ...
-'7BPMx4 ' 'SR07BPM04:SA_HPOS_MONITOR' 1 '7BPMy4 ' 'SR07BPM04:SA_VPOS_MONITOR' 1 [7,4] 46 ; ...
-'7BPMx5 ' 'SR07BPM05:SA_HPOS_MONITOR' 1 '7BPMy5 ' 'SR07BPM05:SA_VPOS_MONITOR' 1 [7,5] 47 ; ...
-'7BPMx6 ' 'SR07BPM06:SA_HPOS_MONITOR' 1 '7BPMy6 ' 'SR07BPM06:SA_VPOS_MONITOR' 1 [7,6] 48 ; ...
-'7BPMx7 ' 'SR07BPM07:SA_HPOS_MONITOR' 1 '7BPMy7 ' 'SR07BPM07:SA_VPOS_MONITOR' 1 [7,7] 49 ; ...
-'8BPMx1 ' 'SR08BPM01:SA_HPOS_MONITOR' 1 '8BPMy1 ' 'SR08BPM01:SA_VPOS_MONITOR' 1 [8,1] 50 ; ...
-'8BPMx2 ' 'SR08BPM02:SA_HPOS_MONITOR' 1 '8BPMy2 ' 'SR08BPM02:SA_VPOS_MONITOR' 1 [8,2] 51 ; ...
-'8BPMx3 ' 'SR08BPM03:SA_HPOS_MONITOR' 1 '8BPMy3 ' 'SR08BPM03:SA_VPOS_MONITOR' 1 [8,3] 52 ; ...
-'8BPMx4 ' 'SR08BPM04:SA_HPOS_MONITOR' 1 '8BPMy4 ' 'SR08BPM04:SA_VPOS_MONITOR' 1 [8,4] 53 ; ...
-'8BPMx5 ' 'SR08BPM05:SA_HPOS_MONITOR' 1 '8BPMy5 ' 'SR08BPM05:SA_VPOS_MONITOR' 1 [8,5] 54 ; ...
-'8BPMx6 ' 'SR08BPM06:SA_HPOS_MONITOR' 1 '8BPMy6 ' 'SR08BPM06:SA_VPOS_MONITOR' 1 [8,6] 55 ; ...
-'8BPMx7 ' 'SR08BPM07:SA_HPOS_MONITOR' 1 '8BPMy7 ' 'SR08BPM07:SA_VPOS_MONITOR' 1 [8,7] 56 ; ...
-'9BPMx1 ' 'SR09BPM01:SA_HPOS_MONITOR' 1 '9BPMy1 ' 'SR09BPM01:SA_VPOS_MONITOR' 1 [9,1] 57 ; ...
-'9BPMx2 ' 'SR09BPM02:SA_HPOS_MONITOR' 1 '9BPMy2 ' 'SR09BPM02:SA_VPOS_MONITOR' 1 [9,2] 58 ; ...
-'9BPMx3 ' 'SR09BPM03:SA_HPOS_MONITOR' 1 '9BPMy3 ' 'SR09BPM03:SA_VPOS_MONITOR' 1 [9,3] 59 ; ...
-'9BPMx4 ' 'SR09BPM04:SA_HPOS_MONITOR' 1 '9BPMy4 ' 'SR09BPM04:SA_VPOS_MONITOR' 1 [9,4] 60 ; ...
-'9BPMx5 ' 'SR09BPM05:SA_HPOS_MONITOR' 1 '9BPMy5 ' 'SR09BPM05:SA_VPOS_MONITOR' 1 [9,5] 61 ; ...
-'9BPMx6 ' 'SR09BPM06:SA_HPOS_MONITOR' 1 '9BPMy6 ' 'SR09BPM06:SA_VPOS_MONITOR' 1 [9,6] 62 ; ...
-'9BPMx7 ' 'SR09BPM07:SA_HPOS_MONITOR' 1 '9BPMy7 ' 'SR09BPM07:SA_VPOS_MONITOR' 1 [9,7] 63 ; ...
-'10BPMx1 ' 'SR10BPM01:SA_HPOS_MONITOR' 1 '10BPMy1 ' 'SR10BPM01:SA_VPOS_MONITOR' 1 [10,1] 64 ; ...
-'10BPMx2 ' 'SR10BPM02:SA_HPOS_MONITOR' 1 '10BPMy2 ' 'SR10BPM02:SA_VPOS_MONITOR' 1 [10,2] 65 ; ...
-'10BPMx3 ' 'SR10BPM03:SA_HPOS_MONITOR' 1 '10BPMy3 ' 'SR10BPM03:SA_VPOS_MONITOR' 1 [10,3] 66 ; ...
-'10BPMx4 ' 'SR10BPM04:SA_HPOS_MONITOR' 1 '10BPMy4 ' 'SR10BPM04:SA_VPOS_MONITOR' 1 [10,4] 67 ; ...
-'10BPMx5 ' 'SR10BPM05:SA_HPOS_MONITOR' 1 '10BPMy5 ' 'SR10BPM05:SA_VPOS_MONITOR' 1 [10,5] 68 ; ...
-'10BPMx6 ' 'SR10BPM06:SA_HPOS_MONITOR' 1 '10BPMy6 ' 'SR10BPM06:SA_VPOS_MONITOR' 1 [10,6] 69 ; ...
-'10BPMx7 ' 'SR10BPM07:SA_HPOS_MONITOR' 1 '10BPMy7 ' 'SR10BPM07:SA_VPOS_MONITOR' 1 [10,7] 70 ; ...
-'11BPMx1 ' 'SR11BPM01:SA_HPOS_MONITOR' 1 '11BPMy1 ' 'SR11BPM01:SA_VPOS_MONITOR' 1 [11,1] 71 ; ...
-'11BPMx2 ' 'SR11BPM02:SA_HPOS_MONITOR' 1 '11BPMy2 ' 'SR11BPM02:SA_VPOS_MONITOR' 1 [11,2] 72 ; ...
-'11BPMx3 ' 'SR11BPM03:SA_HPOS_MONITOR' 1 '11BPMy3 ' 'SR11BPM03:SA_VPOS_MONITOR' 1 [11,3] 73 ; ...
-'11BPMx4 ' 'SR11BPM04:SA_HPOS_MONITOR' 1 '11BPMy4 ' 'SR11BPM04:SA_VPOS_MONITOR' 1 [11,4] 74 ; ...
-'11BPMx5 ' 'SR11BPM05:SA_HPOS_MONITOR' 1 '11BPMy5 ' 'SR11BPM05:SA_VPOS_MONITOR' 1 [11,5] 75 ; ...
-'11BPMx6 ' 'SR11BPM06:SA_HPOS_MONITOR' 1 '11BPMy6 ' 'SR11BPM06:SA_VPOS_MONITOR' 1 [11,6] 76 ; ...
-'11BPMx7 ' 'SR11BPM07:SA_HPOS_MONITOR' 1 '11BPMy7 ' 'SR11BPM07:SA_VPOS_MONITOR' 1 [11,7] 77 ; ...
-'12BPMx1 ' 'SR12BPM01:SA_HPOS_MONITOR' 1 '12BPMy1 ' 'SR12BPM01:SA_VPOS_MONITOR' 1 [12,1] 78 ; ...
-'12BPMx2 ' 'SR12BPM02:SA_HPOS_MONITOR' 1 '12BPMy2 ' 'SR12BPM02:SA_VPOS_MONITOR' 1 [12,2] 79 ; ...
-'12BPMx3 ' 'SR12BPM03:SA_HPOS_MONITOR' 1 '12BPMy3 ' 'SR12BPM03:SA_VPOS_MONITOR' 1 [12,3] 80 ; ...
-'12BPMx4 ' 'SR12BPM04:SA_HPOS_MONITOR' 1 '12BPMy4 ' 'SR12BPM04:SA_VPOS_MONITOR' 1 [12,4] 81 ; ...
-'12BPMx5 ' 'SR12BPM05:SA_HPOS_MONITOR' 1 '12BPMy5 ' 'SR12BPM05:SA_VPOS_MONITOR' 1 [12,5] 82 ; ...
-'12BPMx6 ' 'SR12BPM06:SA_HPOS_MONITOR' 1 '12BPMy6 ' 'SR12BPM06:SA_VPOS_MONITOR' 1 [12,6] 83 ; ...
-'12BPMx7 ' 'SR12BPM07:SA_HPOS_MONITOR' 1 '12BPMy7 ' 'SR12BPM07:SA_VPOS_MONITOR' 1 [12,7] 84 ; ...
-'13BPMx1 ' 'SR13BPM01:SA_HPOS_MONITOR' 1 '13BPMy1 ' 'SR13BPM01:SA_VPOS_MONITOR' 1 [13,1] 85 ; ...
-'13BPMx2 ' 'SR13BPM02:SA_HPOS_MONITOR' 1 '13BPMy2 ' 'SR13BPM02:SA_VPOS_MONITOR' 1 [13,2] 86 ; ...
-'13BPMx3 ' 'SR13BPM03:SA_HPOS_MONITOR' 1 '13BPMy3 ' 'SR13BPM03:SA_VPOS_MONITOR' 1 [13,3] 87 ; ...
-'13BPMx4 ' 'SR13BPM04:SA_HPOS_MONITOR' 1 '13BPMy4 ' 'SR13BPM04:SA_VPOS_MONITOR' 1 [13,4] 88 ; ...
-'13BPMx5 ' 'SR13BPM05:SA_HPOS_MONITOR' 1 '13BPMy5 ' 'SR13BPM05:SA_VPOS_MONITOR' 1 [13,5] 89 ; ...
-'13BPMx6 ' 'SR13BPM06:SA_HPOS_MONITOR' 1 '13BPMy6 ' 'SR13BPM06:SA_VPOS_MONITOR' 1 [13,6] 90 ; ...
-'13BPMx7 ' 'SR13BPM07:SA_HPOS_MONITOR' 1 '13BPMy7 ' 'SR13BPM07:SA_VPOS_MONITOR' 1 [13,7] 91 ; ...
-'14BPMx1 ' 'SR14BPM01:SA_HPOS_MONITOR' 1 '14BPMy1 ' 'SR14BPM01:SA_VPOS_MONITOR' 1 [14,1] 92 ; ...
-'14BPMx2 ' 'SR14BPM02:SA_HPOS_MONITOR' 1 '14BPMy2 ' 'SR14BPM02:SA_VPOS_MONITOR' 1 [14,2] 93 ; ...
-'14BPMx3 ' 'SR14BPM03:SA_HPOS_MONITOR' 1 '14BPMy3 ' 'SR14BPM03:SA_VPOS_MONITOR' 1 [14,3] 94 ; ...
-'14BPMx4 ' 'SR14BPM04:SA_HPOS_MONITOR' 1 '14BPMy4 ' 'SR14BPM04:SA_VPOS_MONITOR' 1 [14,4] 95 ; ...
-'14BPMx5 ' 'SR14BPM05:SA_HPOS_MONITOR' 1 '14BPMy5 ' 'SR14BPM05:SA_VPOS_MONITOR' 1 [14,5] 96 ; ...
-'14BPMx6 ' 'SR14BPM06:SA_HPOS_MONITOR' 1 '14BPMy6 ' 'SR14BPM06:SA_VPOS_MONITOR' 1 [14,6] 97 ; ...
-'14BPMx7 ' 'SR14BPM07:SA_HPOS_MONITOR' 1 '14BPMy7 ' 'SR14BPM07:SA_VPOS_MONITOR' 1 [14,7] 98 ; ...
-};
-
-%Load fields from data block
-for ii=1:size(bpm,1)
-name=bpm{ii,1}; AO.BPMx.CommonNames(ii,:) = name;
-name=bpm{ii,2}; AO.BPMx.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,3}; AO.BPMx.Status(ii,:) = val;
-name=bpm{ii,4}; AO.BPMy.CommonNames(ii,:) = name;
-name=bpm{ii,5}; AO.BPMy.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,6}; AO.BPMy.Status(ii,:) = val;
-val =bpm{ii,7}; AO.BPMx.DeviceList(ii,:) = val;
- AO.BPMy.DeviceList(ii,:) = val;
-val =bpm{ii,8}; AO.BPMx.ElementList(ii,:) = val;
- AO.BPMy.ElementList(ii,:) = val;
- AO.BPMx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.BPMx.Monitor.Physics2HWParams(ii,:) = 1000;
- AO.BPMy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.BPMy.Monitor.Physics2HWParams(ii,:) = 1000;
-end
-
-
-% % Get sum value from button. Don't need handles and PV namelist as
-% % parameters are the same as the 'monitor' subcategory.
-% AO.BPMx.Sum.Monitor = AO.BPMx.Monitor;
-% AO.BPMx.Sum.SpecialFunction = 'getbpmsumspear';
-% AO.BPMx.Sum.HWUnits = 'ADC Counts';
-% AO.BPMx.Sum.PhysicsUnits = 'ADC Counts';
-% AO.BPMx.Sum.HW2PhysicsParams = 1;
-% AO.BPMx.Sum.Physics2HWParams = 1;
-% % Get q value from BPMs. Don't need handles and PV namelist.
-% AO.BPMx.Q = AO.BPMx.Monitor;
-% AO.BPMx.Q.SpecialFunction = 'getbpmqspear';
-% AO.BPMx.Q.HWUnits = 'mm';
-% AO.BPMx.Q.PhysicsUnits = 'meter';
-% AO.BPMx.Q.HW2PhysicsParams = 1e-3;
-% AO.BPMx.Q.Physics2HWParams = 1000;
-%
-% % Definition above for horizontal. Replicate for vertical.
-% AO.BPMy.Sum = AO.BPMx.Sum;
-% AO.BPMy.Q = AO.BPMx.Q;
-
-
-
-%=============================================
-% First Turn BPM data from Libera
-%=============================================
-ntbpm=98;
-AO.FTx.FamilyName = 'FTx'; dispobject(AO,AO.FTx.FamilyName);
-AO.FTx.MemberOf = {'PlotFamily';};% 'BPM'; 'Diagnostics'};
-AO.FTx.Monitor.Mode = Mode;
-AO.FTx.Monitor.DataType = 'Scalar';
-AO.FTx.Monitor.Units = 'Hardware';
-AO.FTx.Monitor.HWUnits = 'mm';
-AO.FTx.Monitor.PhysicsUnits = 'meter';
-
-AO.FTy.FamilyName = 'FTy'; dispobject(AO,AO.FTy.FamilyName);
-AO.FTy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
-AO.FTy.Monitor.Mode = Mode;
-AO.FTy.Monitor.DataType = 'Scalar';
-AO.FTy.Monitor.Units = 'Hardware';
-AO.FTy.Monitor.HWUnits = 'mm';
-AO.FTy.Monitor.PhysicsUnits = 'meter';
-
-% x-name x-chname xstat y-name y-chname ystat DevList Elem
-bpm={
-'1FTx1 ' 'SR01BPM01:FT_HPOS_MONITOR' 1 '1BPMy1 ' 'SR01BPM01:FT_VPOS_MONITOR' 1 [1,1] 1 ; ...
-'1FTx2 ' 'SR01BPM02:FT_HPOS_MONITOR' 1 '1BPMy2 ' 'SR01BPM02:FT_VPOS_MONITOR' 1 [1,2] 2 ; ...
-'1FTx3 ' 'SR01BPM03:FT_HPOS_MONITOR' 1 '1BPMy3 ' 'SR01BPM03:FT_VPOS_MONITOR' 1 [1,3] 3 ; ...
-'1FTx4 ' 'SR01BPM04:FT_HPOS_MONITOR' 1 '1BPMy4 ' 'SR01BPM04:FT_VPOS_MONITOR' 1 [1,4] 4 ; ...
-'1FTx5 ' 'SR01BPM05:FT_HPOS_MONITOR' 1 '1BPMy5 ' 'SR01BPM05:FT_VPOS_MONITOR' 1 [1,5] 5 ; ...
-'1FTx6 ' 'SR01BPM06:FT_HPOS_MONITOR' 1 '1BPMy6 ' 'SR01BPM06:FT_VPOS_MONITOR' 1 [1,6] 6 ; ...
-'1FTx7 ' 'SR01BPM07:FT_HPOS_MONITOR' 1 '1BPMy7 ' 'SR01BPM07:FT_VPOS_MONITOR' 1 [1,7] 7 ; ...
-'2FTx1 ' 'SR02BPM01:FT_HPOS_MONITOR' 1 '2BPMy1 ' 'SR02BPM01:FT_VPOS_MONITOR' 1 [2,1] 8 ; ...
-'2FTx2 ' 'SR02BPM02:FT_HPOS_MONITOR' 1 '2BPMy2 ' 'SR02BPM02:FT_VPOS_MONITOR' 1 [2,2] 9 ; ...
-'2FTx3 ' 'SR02BPM03:FT_HPOS_MONITOR' 1 '2BPMy3 ' 'SR02BPM03:FT_VPOS_MONITOR' 1 [2,3] 10 ; ...
-'2FTx4 ' 'SR02BPM04:FT_HPOS_MONITOR' 1 '2BPMy4 ' 'SR02BPM04:FT_VPOS_MONITOR' 1 [2,4] 11 ; ...
-'2FTx5 ' 'SR02BPM05:FT_HPOS_MONITOR' 1 '2BPMy5 ' 'SR02BPM05:FT_VPOS_MONITOR' 1 [2,5] 12 ; ...
-'2FTx6 ' 'SR02BPM06:FT_HPOS_MONITOR' 1 '2BPMy6 ' 'SR02BPM06:FT_VPOS_MONITOR' 1 [2,6] 13 ; ...
-'2FTx7 ' 'SR02BPM07:FT_HPOS_MONITOR' 1 '2BPMy7 ' 'SR02BPM07:FT_VPOS_MONITOR' 1 [2,7] 14 ; ...
-'3FTx1 ' 'SR03BPM01:FT_HPOS_MONITOR' 1 '3BPMy1 ' 'SR03BPM01:FT_VPOS_MONITOR' 1 [3,1] 15 ; ...
-'3FTx2 ' 'SR03BPM02:FT_HPOS_MONITOR' 1 '3BPMy2 ' 'SR03BPM02:FT_VPOS_MONITOR' 1 [3,2] 16 ; ...
-'3FTx3 ' 'SR03BPM03:FT_HPOS_MONITOR' 1 '3BPMy3 ' 'SR03BPM03:FT_VPOS_MONITOR' 1 [3,3] 17 ; ...
-'3FTx4 ' 'SR03BPM04:FT_HPOS_MONITOR' 1 '3BPMy4 ' 'SR03BPM04:FT_VPOS_MONITOR' 1 [3,4] 18 ; ...
-'3FTx5 ' 'SR03BPM05:FT_HPOS_MONITOR' 1 '3BPMy5 ' 'SR03BPM05:FT_VPOS_MONITOR' 1 [3,5] 19 ; ...
-'3FTx6 ' 'SR03BPM06:FT_HPOS_MONITOR' 1 '3BPMy6 ' 'SR03BPM06:FT_VPOS_MONITOR' 1 [3,6] 20 ; ...
-'3FTx7 ' 'SR03BPM07:FT_HPOS_MONITOR' 1 '3BPMy7 ' 'SR03BPM07:FT_VPOS_MONITOR' 1 [3,7] 21 ; ...
-'4FTx1 ' 'SR04BPM01:FT_HPOS_MONITOR' 1 '4BPMy1 ' 'SR04BPM01:FT_VPOS_MONITOR' 1 [4,1] 22 ; ...
-'4FTx2 ' 'SR04BPM02:FT_HPOS_MONITOR' 1 '4BPMy2 ' 'SR04BPM02:FT_VPOS_MONITOR' 1 [4,2] 23 ; ...
-'4FTx3 ' 'SR04BPM03:FT_HPOS_MONITOR' 1 '4BPMy3 ' 'SR04BPM03:FT_VPOS_MONITOR' 1 [4,3] 24 ; ...
-'4FTx4 ' 'SR04BPM04:FT_HPOS_MONITOR' 1 '4BPMy4 ' 'SR04BPM04:FT_VPOS_MONITOR' 1 [4,4] 25 ; ...
-'4FTx5 ' 'SR04BPM05:FT_HPOS_MONITOR' 1 '4BPMy5 ' 'SR04BPM05:FT_VPOS_MONITOR' 1 [4,5] 26 ; ...
-'4FTx6 ' 'SR04BPM06:FT_HPOS_MONITOR' 1 '4BPMy6 ' 'SR04BPM06:FT_VPOS_MONITOR' 1 [4,6] 27 ; ...
-'4FTx7 ' 'SR04BPM07:FT_HPOS_MONITOR' 1 '4BPMy7 ' 'SR04BPM07:FT_VPOS_MONITOR' 1 [4,7] 28 ; ...
-'5FTx1 ' 'SR05BPM01:FT_HPOS_MONITOR' 1 '5BPMy1 ' 'SR05BPM01:FT_VPOS_MONITOR' 1 [5,1] 29 ; ...
-'5FTx2 ' 'SR05BPM02:FT_HPOS_MONITOR' 1 '5BPMy2 ' 'SR05BPM02:FT_VPOS_MONITOR' 1 [5,2] 30 ; ...
-'5FTx3 ' 'SR05BPM03:FT_HPOS_MONITOR' 1 '5BPMy3 ' 'SR05BPM03:FT_VPOS_MONITOR' 1 [5,3] 31 ; ...
-'5FTx4 ' 'SR05BPM04:FT_HPOS_MONITOR' 1 '5BPMy4 ' 'SR05BPM04:FT_VPOS_MONITOR' 1 [5,4] 32 ; ...
-'5FTx5 ' 'SR05BPM05:FT_HPOS_MONITOR' 1 '5BPMy5 ' 'SR05BPM05:FT_VPOS_MONITOR' 1 [5,5] 33 ; ...
-'5FTx6 ' 'SR05BPM06:FT_HPOS_MONITOR' 1 '5BPMy6 ' 'SR05BPM06:FT_VPOS_MONITOR' 1 [5,6] 34 ; ...
-'5FTx7 ' 'SR05BPM07:FT_HPOS_MONITOR' 1 '5BPMy7 ' 'SR05BPM07:FT_VPOS_MONITOR' 1 [5,7] 35 ; ...
-'6FTx1 ' 'SR06BPM01:FT_HPOS_MONITOR' 1 '6BPMy1 ' 'SR06BPM01:FT_VPOS_MONITOR' 1 [6,1] 36 ; ...
-'6FTx2 ' 'SR06BPM02:FT_HPOS_MONITOR' 1 '6BPMy2 ' 'SR06BPM02:FT_VPOS_MONITOR' 1 [6,2] 37 ; ...
-'6FTx3 ' 'SR06BPM03:FT_HPOS_MONITOR' 1 '6BPMy3 ' 'SR06BPM03:FT_VPOS_MONITOR' 1 [6,3] 38 ; ...
-'6FTx4 ' 'SR06BPM04:FT_HPOS_MONITOR' 1 '6BPMy4 ' 'SR06BPM04:FT_VPOS_MONITOR' 1 [6,4] 39 ; ...
-'6FTx5 ' 'SR06BPM05:FT_HPOS_MONITOR' 1 '6BPMy5 ' 'SR06BPM05:FT_VPOS_MONITOR' 1 [6,5] 40 ; ...
-'6FTx6 ' 'SR06BPM06:FT_HPOS_MONITOR' 1 '6BPMy6 ' 'SR06BPM06:FT_VPOS_MONITOR' 1 [6,6] 41 ; ...
-'6FTx7 ' 'SR06BPM07:FT_HPOS_MONITOR' 1 '6BPMy7 ' 'SR06BPM07:FT_VPOS_MONITOR' 1 [6,7] 42 ; ...
-'7FTx1 ' 'SR07BPM01:FT_HPOS_MONITOR' 1 '7BPMy1 ' 'SR07BPM01:FT_VPOS_MONITOR' 1 [7,1] 43 ; ...
-'7FTx2 ' 'SR07BPM02:FT_HPOS_MONITOR' 1 '7BPMy2 ' 'SR07BPM02:FT_VPOS_MONITOR' 1 [7,2] 44 ; ...
-'7FTx3 ' 'SR07BPM03:FT_HPOS_MONITOR' 1 '7BPMy3 ' 'SR07BPM03:FT_VPOS_MONITOR' 1 [7,3] 45 ; ...
-'7FTx4 ' 'SR07BPM04:FT_HPOS_MONITOR' 1 '7BPMy4 ' 'SR07BPM04:FT_VPOS_MONITOR' 1 [7,4] 46 ; ...
-'7FTx5 ' 'SR07BPM05:FT_HPOS_MONITOR' 1 '7BPMy5 ' 'SR07BPM05:FT_VPOS_MONITOR' 1 [7,5] 47 ; ...
-'7FTx6 ' 'SR07BPM06:FT_HPOS_MONITOR' 1 '7BPMy6 ' 'SR07BPM06:FT_VPOS_MONITOR' 1 [7,6] 48 ; ...
-'7FTx7 ' 'SR07BPM07:FT_HPOS_MONITOR' 1 '7BPMy7 ' 'SR07BPM07:FT_VPOS_MONITOR' 1 [7,7] 49 ; ...
-'8FTx1 ' 'SR08BPM01:FT_HPOS_MONITOR' 1 '8BPMy1 ' 'SR08BPM01:FT_VPOS_MONITOR' 1 [8,1] 50 ; ...
-'8FTx2 ' 'SR08BPM02:FT_HPOS_MONITOR' 1 '8BPMy2 ' 'SR08BPM02:FT_VPOS_MONITOR' 1 [8,2] 51 ; ...
-'8FTx3 ' 'SR08BPM03:FT_HPOS_MONITOR' 1 '8BPMy3 ' 'SR08BPM03:FT_VPOS_MONITOR' 1 [8,3] 52 ; ...
-'8FTx4 ' 'SR08BPM04:FT_HPOS_MONITOR' 1 '8BPMy4 ' 'SR08BPM04:FT_VPOS_MONITOR' 1 [8,4] 53 ; ...
-'8FTx5 ' 'SR08BPM05:FT_HPOS_MONITOR' 1 '8BPMy5 ' 'SR08BPM05:FT_VPOS_MONITOR' 1 [8,5] 54 ; ...
-'8FTx6 ' 'SR08BPM06:FT_HPOS_MONITOR' 1 '8BPMy6 ' 'SR08BPM06:FT_VPOS_MONITOR' 1 [8,6] 55 ; ...
-'8FTx7 ' 'SR08BPM07:FT_HPOS_MONITOR' 1 '8BPMy7 ' 'SR08BPM07:FT_VPOS_MONITOR' 1 [8,7] 56 ; ...
-'9FTx1 ' 'SR09BPM01:FT_HPOS_MONITOR' 1 '9BPMy1 ' 'SR09BPM01:FT_VPOS_MONITOR' 1 [9,1] 57 ; ...
-'9FTx2 ' 'SR09BPM02:FT_HPOS_MONITOR' 1 '9BPMy2 ' 'SR09BPM02:FT_VPOS_MONITOR' 1 [9,2] 58 ; ...
-'9FTx3 ' 'SR09BPM03:FT_HPOS_MONITOR' 1 '9BPMy3 ' 'SR09BPM03:FT_VPOS_MONITOR' 1 [9,3] 59 ; ...
-'9FTx4 ' 'SR09BPM04:FT_HPOS_MONITOR' 1 '9BPMy4 ' 'SR09BPM04:FT_VPOS_MONITOR' 1 [9,4] 60 ; ...
-'9FTx5 ' 'SR09BPM05:FT_HPOS_MONITOR' 1 '9BPMy5 ' 'SR09BPM05:FT_VPOS_MONITOR' 1 [9,5] 61 ; ...
-'9FTx6 ' 'SR09BPM06:FT_HPOS_MONITOR' 1 '9BPMy6 ' 'SR09BPM06:FT_VPOS_MONITOR' 1 [9,6] 62 ; ...
-'9FTx7 ' 'SR09BPM07:FT_HPOS_MONITOR' 1 '9BPMy7 ' 'SR09BPM07:FT_VPOS_MONITOR' 1 [9,7] 63 ; ...
-'10FTx1 ' 'SR10BPM01:FT_HPOS_MONITOR' 1 '10BPMy1 ' 'SR10BPM01:FT_VPOS_MONITOR' 1 [10,1] 64 ; ...
-'10FTx2 ' 'SR10BPM02:FT_HPOS_MONITOR' 1 '10BPMy2 ' 'SR10BPM02:FT_VPOS_MONITOR' 1 [10,2] 65 ; ...
-'10FTx3 ' 'SR10BPM03:FT_HPOS_MONITOR' 1 '10BPMy3 ' 'SR10BPM03:FT_VPOS_MONITOR' 1 [10,3] 66 ; ...
-'10FTx4 ' 'SR10BPM04:FT_HPOS_MONITOR' 1 '10BPMy4 ' 'SR10BPM04:FT_VPOS_MONITOR' 1 [10,4] 67 ; ...
-'10FTx5 ' 'SR10BPM05:FT_HPOS_MONITOR' 1 '10BPMy5 ' 'SR10BPM05:FT_VPOS_MONITOR' 1 [10,5] 68 ; ...
-'10FTx6 ' 'SR10BPM06:FT_HPOS_MONITOR' 1 '10BPMy6 ' 'SR10BPM06:FT_VPOS_MONITOR' 1 [10,6] 69 ; ...
-'10FTx7 ' 'SR10BPM07:FT_HPOS_MONITOR' 1 '10BPMy7 ' 'SR10BPM07:FT_VPOS_MONITOR' 1 [10,7] 70 ; ...
-'11FTx1 ' 'SR11BPM01:FT_HPOS_MONITOR' 1 '11BPMy1 ' 'SR11BPM01:FT_VPOS_MONITOR' 1 [11,1] 71 ; ...
-'11FTx2 ' 'SR11BPM02:FT_HPOS_MONITOR' 1 '11BPMy2 ' 'SR11BPM02:FT_VPOS_MONITOR' 1 [11,2] 72 ; ...
-'11FTx3 ' 'SR11BPM03:FT_HPOS_MONITOR' 1 '11BPMy3 ' 'SR11BPM03:FT_VPOS_MONITOR' 1 [11,3] 73 ; ...
-'11FTx4 ' 'SR11BPM04:FT_HPOS_MONITOR' 1 '11BPMy4 ' 'SR11BPM04:FT_VPOS_MONITOR' 1 [11,4] 74 ; ...
-'11FTx5 ' 'SR11BPM05:FT_HPOS_MONITOR' 1 '11BPMy5 ' 'SR11BPM05:FT_VPOS_MONITOR' 1 [11,5] 75 ; ...
-'11FTx6 ' 'SR11BPM06:FT_HPOS_MONITOR' 1 '11BPMy6 ' 'SR11BPM06:FT_VPOS_MONITOR' 1 [11,6] 76 ; ...
-'11FTx7 ' 'SR11BPM07:FT_HPOS_MONITOR' 1 '11BPMy7 ' 'SR11BPM07:FT_VPOS_MONITOR' 1 [11,7] 77 ; ...
-'12FTx1 ' 'SR12BPM01:FT_HPOS_MONITOR' 1 '12BPMy1 ' 'SR12BPM01:FT_VPOS_MONITOR' 1 [12,1] 78 ; ...
-'12FTx2 ' 'SR12BPM02:FT_HPOS_MONITOR' 1 '12BPMy2 ' 'SR12BPM02:FT_VPOS_MONITOR' 1 [12,2] 79 ; ...
-'12FTx3 ' 'SR12BPM03:FT_HPOS_MONITOR' 1 '12BPMy3 ' 'SR12BPM03:FT_VPOS_MONITOR' 1 [12,3] 80 ; ...
-'12FTx4 ' 'SR12BPM04:FT_HPOS_MONITOR' 1 '12BPMy4 ' 'SR12BPM04:FT_VPOS_MONITOR' 1 [12,4] 81 ; ...
-'12FTx5 ' 'SR12BPM05:FT_HPOS_MONITOR' 1 '12BPMy5 ' 'SR12BPM05:FT_VPOS_MONITOR' 1 [12,5] 82 ; ...
-'12FTx6 ' 'SR12BPM06:FT_HPOS_MONITOR' 1 '12BPMy6 ' 'SR12BPM06:FT_VPOS_MONITOR' 1 [12,6] 83 ; ...
-'12FTx7 ' 'SR12BPM07:FT_HPOS_MONITOR' 1 '12BPMy7 ' 'SR12BPM07:FT_VPOS_MONITOR' 1 [12,7] 84 ; ...
-'13FTx1 ' 'SR13BPM01:FT_HPOS_MONITOR' 1 '13BPMy1 ' 'SR13BPM01:FT_VPOS_MONITOR' 1 [13,1] 85 ; ...
-'13FTx2 ' 'SR13BPM02:FT_HPOS_MONITOR' 1 '13BPMy2 ' 'SR13BPM02:FT_VPOS_MONITOR' 1 [13,2] 86 ; ...
-'13FTx3 ' 'SR13BPM03:FT_HPOS_MONITOR' 1 '13BPMy3 ' 'SR13BPM03:FT_VPOS_MONITOR' 1 [13,3] 87 ; ...
-'13FTx4 ' 'SR13BPM04:FT_HPOS_MONITOR' 1 '13BPMy4 ' 'SR13BPM04:FT_VPOS_MONITOR' 1 [13,4] 88 ; ...
-'13FTx5 ' 'SR13BPM05:FT_HPOS_MONITOR' 1 '13BPMy5 ' 'SR13BPM05:FT_VPOS_MONITOR' 1 [13,5] 89 ; ...
-'13FTx6 ' 'SR13BPM06:FT_HPOS_MONITOR' 1 '13BPMy6 ' 'SR13BPM06:FT_VPOS_MONITOR' 1 [13,6] 90 ; ...
-'13FTx7 ' 'SR13BPM07:FT_HPOS_MONITOR' 1 '13BPMy7 ' 'SR13BPM07:FT_VPOS_MONITOR' 1 [13,7] 91 ; ...
-'14FTx1 ' 'SR14BPM01:FT_HPOS_MONITOR' 1 '14BPMy1 ' 'SR14BPM01:FT_VPOS_MONITOR' 1 [14,1] 92 ; ...
-'14FTx2 ' 'SR14BPM02:FT_HPOS_MONITOR' 1 '14BPMy2 ' 'SR14BPM02:FT_VPOS_MONITOR' 1 [14,2] 93 ; ...
-'14FTx3 ' 'SR14BPM03:FT_HPOS_MONITOR' 1 '14BPMy3 ' 'SR14BPM03:FT_VPOS_MONITOR' 1 [14,3] 94 ; ...
-'14FTx4 ' 'SR14BPM04:FT_HPOS_MONITOR' 1 '14BPMy4 ' 'SR14BPM04:FT_VPOS_MONITOR' 1 [14,4] 95 ; ...
-'14FTx5 ' 'SR14BPM05:FT_HPOS_MONITOR' 1 '14BPMy5 ' 'SR14BPM05:FT_VPOS_MONITOR' 1 [14,5] 96 ; ...
-'14FTx6 ' 'SR14BPM06:FT_HPOS_MONITOR' 1 '14BPMy6 ' 'SR14BPM06:FT_VPOS_MONITOR' 1 [14,6] 97 ; ...
-'14FTx7 ' 'SR14BPM07:FT_HPOS_MONITOR' 1 '14BPMy7 ' 'SR14BPM07:FT_VPOS_MONITOR' 1 [14,7] 98 ; ...
-};
-
-%Load fields from data block
-for ii=1:size(bpm,1)
-name=bpm{ii,1}; AO.FTx.CommonNames(ii,:) = name;
-name=bpm{ii,2}; AO.FTx.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,3}; AO.FTx.Status(ii,:) = val;
-name=bpm{ii,4}; AO.FTy.CommonNames(ii,:) = name;
-name=bpm{ii,5}; AO.FTy.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,6}; AO.FTy.Status(ii,:) = val;
-val =bpm{ii,7}; AO.FTx.DeviceList(ii,:) = val;
- AO.FTy.DeviceList(ii,:) = val;
-val =bpm{ii,8}; AO.FTx.ElementList(ii,:) = val;
- AO.FTy.ElementList(ii,:) = val;
- AO.FTx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.FTx.Monitor.Physics2HWParams(ii,:) = 1000;
- AO.FTy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.FTy.Monitor.Physics2HWParams(ii,:) = 1000;
-end
-AO.FTx.Status = AO.BPMx.Status;
-AO.FTy.Status = AO.BPMy.Status;
-
-AO.FTsum = AO.FTx;
-AO.FTsum.FamilyName = 'FTsum'; dispobject(AO,AO.FTsum.FamilyName);
-AO.FTsum.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
-AO.FTsum.Monitor.Mode = 'Special';
-AO.FTsum.Monitor.Units = 'Hardware';
-AO.FTsum.Monitor.DataType = 'Scalar';
-AO.FTsum.Monitor.SpecialFunction = 'getftsum';
-AO.FTsum.Monitor.HWUnits = 'ADC counts';
-AO.FTsum.Monitor.PhysicsUnits = 'ADC counts';
-AO.FTsum.Monitor.HW2PhysicsParams(:) = 1;
-AO.FTsum.Monitor.Physics2HWParams(:) = 1;
-
-
-% % Get sum value from button. Don't need handles and PV namelist as
-% % parameters are the same as the 'monitor' subcategory.
-AO.FTx.Off.Mode = 'Special';
-AO.FTx.Off.Units = 'Hardware';
-AO.FTx.Off.DataType = 'Scalar';
-AO.FTx.Off.SpecialFunction = 'getftoffset';
-AO.FTx.Off.SpecialFunctionSet = 'setftoffset';
-AO.FTx.Off.HWUnits = '32ns samples';
-AO.FTx.Off.PhysicsUnits = '32ns samples';
-AO.FTx.Off.HW2PhysicsParams = 1;
-AO.FTx.Off.Physics2HWParams = 1;
-
-AO.FTx.Length.Mode = 'Special';
-AO.FTx.Length.Units = 'Hardware';
-AO.FTx.Length.DataType = 'Scalar';
-AO.FTx.Length.SpecialFunction = 'getftlength';
-AO.FTx.Length.SpecialFunctionSet = 'setftlength';
-AO.FTx.Length.HWUnits = '32ns samples';
-AO.FTx.Length.PhysicsUnits = '32ns samples';
-AO.FTx.Length.HW2PhysicsParams = 1;
-AO.FTx.Length.Physics2HWParams = 1;
-
-AO.FTx.Maxadc.Mode = 'Special';
-AO.FTx.Maxadc.Units = 'Hardware';
-AO.FTx.Maxadc.DataType = 'Scalar';
-AO.FTx.Maxadc.SpecialFunction = 'getftmaxadc';
-AO.FTx.Maxadc.HWUnits = 'ADC counts';
-AO.FTx.Maxadc.PhysicsUnits = 'ADC counts';
-AO.FTx.Maxadc.HW2PhysicsParams = 1;
-AO.FTx.Maxadc.Physics2HWParams = 1;
-
-% AO.FTx.Sum.Mode = 'Special';
-% AO.FTx.Sum.Units = 'Hardware';
-% AO.FTx.Sum.DataType = 'Scalar';
-% AO.FTx.Sum.SpecialFunction = 'getftsum';
-% AO.FTx.Sum.HWUnits = 'ADC counts';
-% AO.FTx.Sum.PhysicsUnits = 'ADC counts';
-% AO.FTx.Sum.HW2PhysicsParams = 1;
-% AO.FTx.Sum.Physics2HWParams = 1;
-
-
-%===========================================================
-% Corrector data: status field designates if corrector in use
-% ASP corrector coils wound into sextupoles. Not dynamic correctors.
-%===========================================================
-
-AO.HCM.FamilyName = 'HCM'; dispobject(AO,AO.HCM.FamilyName);
-AO.HCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'HCM'; 'Magnet'};
-
-AO.HCM.Monitor.Mode = Mode;
-AO.HCM.Monitor.DataType = 'Scalar';
-AO.HCM.Monitor.Units = 'Hardware';
-AO.HCM.Monitor.HWUnits = 'ampere';
-AO.HCM.Monitor.PhysicsUnits = 'radian';
-AO.HCM.Monitor.HW2PhysicsFcn = @amp2k;
-AO.HCM.Monitor.Physics2HWFcn = @k2amp;
-
-AO.HCM.Setpoint.Mode = Mode;
-AO.HCM.Setpoint.DataType = 'Scalar';
-AO.HCM.Setpoint.Units = 'Hardware';
-AO.HCM.Setpoint.HWUnits = 'ampere';
-AO.HCM.Setpoint.PhysicsUnits = 'radian';
-AO.HCM.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.HCM.Setpoint.Physics2HWFcn = @k2amp;
-
-% HW in ampere, Physics in radian. Respmat settings below AO definitions.
-% x-common x-monitor x-setpoint stat devlist elem tol
-cor={
-'1HCM1 ' 'SR01CPS01:CURRENT_MONITOR' 'SR01CPS01:CURRENT_SP ' 1 [1,1] 1 1.000 ; ...
-'1HCM2 ' 'SR01CPS05:CURRENT_MONITOR' 'SR01CPS05:CURRENT_SP ' 1 [1,2] 2 1.000 ; ...
-'1HCM3 ' 'SR01CPS09:CURRENT_MONITOR' 'SR01CPS09:CURRENT_SP ' 1 [1,3] 3 1.000 ; ...
-'2HCM1 ' 'SR02CPS01:CURRENT_MONITOR' 'SR02CPS01:CURRENT_SP ' 1 [2,1] 4 1.000 ; ...
-'2HCM2 ' 'SR02CPS05:CURRENT_MONITOR' 'SR02CPS05:CURRENT_SP ' 1 [2,2] 5 1.000 ; ...
-'2HCM3 ' 'SR02CPS09:CURRENT_MONITOR' 'SR02CPS09:CURRENT_SP ' 1 [2,3] 6 1.000 ; ...
-'3HCM1 ' 'SR03CPS01:CURRENT_MONITOR' 'SR03CPS01:CURRENT_SP ' 1 [3,1] 7 1.000 ; ...
-'3HCM2 ' 'SR03CPS05:CURRENT_MONITOR' 'SR03CPS05:CURRENT_SP ' 1 [3,2] 8 1.000 ; ...
-'3HCM3 ' 'SR03CPS09:CURRENT_MONITOR' 'SR03CPS09:CURRENT_SP ' 1 [3,3] 9 1.000 ; ...
-'4HCM1 ' 'SR04CPS01:CURRENT_MONITOR' 'SR04CPS01:CURRENT_SP ' 1 [4,1] 10 1.000 ; ...
-'4HCM2 ' 'SR04CPS05:CURRENT_MONITOR' 'SR04CPS05:CURRENT_SP ' 1 [4,2] 11 1.000 ; ...
-'4HCM3 ' 'SR04CPS09:CURRENT_MONITOR' 'SR04CPS09:CURRENT_SP ' 1 [4,3] 12 1.000 ; ...
-'5HCM1 ' 'SR05CPS01:CURRENT_MONITOR' 'SR05CPS01:CURRENT_SP ' 1 [5,1] 13 1.000 ; ...
-'5HCM2 ' 'SR05CPS05:CURRENT_MONITOR' 'SR05CPS05:CURRENT_SP ' 1 [5,2] 14 1.000 ; ...
-'5HCM3 ' 'SR05CPS09:CURRENT_MONITOR' 'SR05CPS09:CURRENT_SP ' 1 [5,3] 15 1.000 ; ...
-'6HCM1 ' 'SR06CPS01:CURRENT_MONITOR' 'SR06CPS01:CURRENT_SP ' 1 [6,1] 16 1.000 ; ...
-'6HCM2 ' 'SR06CPS05:CURRENT_MONITOR' 'SR06CPS05:CURRENT_SP ' 1 [6,2] 17 1.000 ; ...
-'6HCM3 ' 'SR06CPS09:CURRENT_MONITOR' 'SR06CPS09:CURRENT_SP ' 1 [6,3] 18 1.000 ; ...
-'7HCM1 ' 'SR07CPS01:CURRENT_MONITOR' 'SR07CPS01:CURRENT_SP ' 1 [7,1] 19 1.000 ; ...
-'7HCM2 ' 'SR07CPS05:CURRENT_MONITOR' 'SR07CPS05:CURRENT_SP ' 1 [7,2] 20 1.000 ; ...
-'7HCM3 ' 'SR07CPS09:CURRENT_MONITOR' 'SR07CPS09:CURRENT_SP ' 1 [7,3] 21 1.000 ; ...
-'8HCM1 ' 'SR08CPS01:CURRENT_MONITOR' 'SR08CPS01:CURRENT_SP ' 1 [8,1] 22 1.000 ; ...
-'8HCM2 ' 'SR08CPS05:CURRENT_MONITOR' 'SR08CPS05:CURRENT_SP ' 1 [8,2] 23 1.000 ; ...
-'8HCM3 ' 'SR08CPS09:CURRENT_MONITOR' 'SR08CPS09:CURRENT_SP ' 1 [8,3] 24 1.000 ; ...
-'9HCM1 ' 'SR09CPS01:CURRENT_MONITOR' 'SR09CPS01:CURRENT_SP ' 1 [9,1] 25 1.000 ; ...
-'9HCM2 ' 'SR09CPS05:CURRENT_MONITOR' 'SR09CPS05:CURRENT_SP ' 1 [9,2] 26 1.000 ; ...
-'9HCM3 ' 'SR09CPS09:CURRENT_MONITOR' 'SR09CPS09:CURRENT_SP ' 1 [9,3] 27 1.000 ; ...
-'10HCM1 ' 'SR10CPS01:CURRENT_MONITOR' 'SR10CPS01:CURRENT_SP ' 1 [10,1] 28 1.000 ; ...
-'10HCM2 ' 'SR10CPS05:CURRENT_MONITOR' 'SR10CPS05:CURRENT_SP ' 1 [10,2] 29 1.000 ; ...
-'10HCM3 ' 'SR10CPS09:CURRENT_MONITOR' 'SR10CPS09:CURRENT_SP ' 1 [10,3] 30 1.000 ; ...
-'11HCM1 ' 'SR11CPS01:CURRENT_MONITOR' 'SR11CPS01:CURRENT_SP ' 1 [11,1] 31 1.000 ; ...
-'11HCM2 ' 'SR11CPS05:CURRENT_MONITOR' 'SR11CPS05:CURRENT_SP ' 1 [11,2] 32 1.000 ; ...
-'11HCM3 ' 'SR11CPS09:CURRENT_MONITOR' 'SR11CPS09:CURRENT_SP ' 1 [11,3] 33 1.000 ; ...
-'12HCM1 ' 'SR12CPS01:CURRENT_MONITOR' 'SR12CPS01:CURRENT_SP ' 1 [12,1] 34 1.000 ; ...
-'12HCM2 ' 'SR12CPS05:CURRENT_MONITOR' 'SR12CPS05:CURRENT_SP ' 1 [12,2] 35 1.000 ; ...
-'12HCM3 ' 'SR12CPS09:CURRENT_MONITOR' 'SR12CPS09:CURRENT_SP ' 1 [12,3] 36 1.000 ; ...
-'13HCM1 ' 'SR13CPS01:CURRENT_MONITOR' 'SR13CPS01:CURRENT_SP ' 1 [13,1] 37 1.000 ; ...
-'13HCM2 ' 'SR13CPS05:CURRENT_MONITOR' 'SR13CPS05:CURRENT_SP ' 1 [13,2] 38 1.000 ; ...
-'13HCM3 ' 'SR13CPS09:CURRENT_MONITOR' 'SR13CPS09:CURRENT_SP ' 1 [13,3] 39 1.000 ; ...
-'14HCM1 ' 'SR14CPS01:CURRENT_MONITOR' 'SR14CPS01:CURRENT_SP ' 1 [14,1] 40 1.000 ; ...
-'14HCM2 ' 'SR14CPS05:CURRENT_MONITOR' 'SR14CPS05:CURRENT_SP ' 1 [14,2] 41 1.000 ; ...
-'14HCM3 ' 'SR14CPS09:CURRENT_MONITOR' 'SR14CPS09:CURRENT_SP ' 1 [14,3] 42 1.000 ; ...
-};
-
-[C, Leff, MagnetType] = magnetcoefficients('HCM');
-
-for ii=1:size(cor,1)
-name=cor{ii,1}; AO.HCM.CommonNames(ii,:) = name;
-name=cor{ii,2}; AO.HCM.Monitor.ChannelNames(ii,:) = name;
-name=cor{ii,3}; AO.HCM.Setpoint.ChannelNames(ii,:) = name;
-val =cor{ii,4}; AO.HCM.Status(ii,1) = val;
-val =cor{ii,5}; AO.HCM.DeviceList(ii,:) = val;
-val =cor{ii,6}; AO.HCM.ElementList(ii,1) = val;
-val =cor{ii,7}; AO.HCM.Setpoint.Tolerance(ii,1) = val;
-
-AO.HCM.Setpoint.Range(ii,:) = [+90 -90];
-AO.HCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
-AO.HCM.Monitor.Physics2HWParams{1}(ii,:) = C;
-AO.HCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
-AO.HCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
-end
-
-
-AO.VCM.FamilyName = 'VCM'; dispobject(AO,AO.VCM.FamilyName);
-AO.VCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'VCM'; 'Magnet'};
-
-AO.VCM.Monitor.Mode = Mode;
-AO.VCM.Monitor.DataType = 'Scalar';
-AO.VCM.Monitor.Units = 'Hardware';
-AO.VCM.Monitor.HWUnits = 'ampere';
-AO.VCM.Monitor.PhysicsUnits = 'radian';
-AO.VCM.Monitor.HW2PhysicsFcn = @amp2k;
-AO.VCM.Monitor.Physics2HWFcn = @k2amp;
-
-AO.VCM.Setpoint.Mode = Mode;
-AO.VCM.Setpoint.DataType = 'Scalar';
-AO.VCM.Setpoint.Units = 'Hardware';
-AO.VCM.Setpoint.HWUnits = 'ampere';
-AO.VCM.Setpoint.PhysicsUnits = 'radian';
-AO.VCM.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.VCM.Setpoint.Physics2HWFcn = @k2amp;
-
-% HW in ampere, Physics in radian ** radian units converted to ampere below ***
-% y-common y-monitor y-setpoint stat devlist elem
-cor={
-'1VCM1 ' 'SR01CPS02:CURRENT_MONITOR' 'SR01CPS02:CURRENT_SP ' 1 [1,1] 1 1.000 ; ...
-'1VCM2 ' 'SR01CPS04:CURRENT_MONITOR' 'SR01CPS04:CURRENT_SP ' 1 [1,2] 2 1.000 ; ...
-'1VCM3 ' 'SR01CPS06:CURRENT_MONITOR' 'SR01CPS06:CURRENT_SP ' 1 [1,3] 3 1.000 ; ...
-'1VCM4 ' 'SR01CPS07:CURRENT_MONITOR' 'SR01CPS07:CURRENT_SP ' 1 [1,4] 4 1.000 ; ...
-'2VCM1 ' 'SR02CPS02:CURRENT_MONITOR' 'SR02CPS02:CURRENT_SP ' 1 [2,1] 5 1.000 ; ...
-'2VCM2 ' 'SR02CPS04:CURRENT_MONITOR' 'SR02CPS04:CURRENT_SP ' 1 [2,2] 6 1.000 ; ...
-'2VCM3 ' 'SR02CPS06:CURRENT_MONITOR' 'SR02CPS06:CURRENT_SP ' 1 [2,3] 7 1.000 ; ...
-'2VCM4 ' 'SR02CPS07:CURRENT_MONITOR' 'SR02CPS07:CURRENT_SP ' 1 [2,4] 8 1.000 ; ...
-'3VCM1 ' 'SR03CPS02:CURRENT_MONITOR' 'SR03CPS02:CURRENT_SP ' 1 [3,1] 9 1.000 ; ...
-'3VCM2 ' 'SR03CPS04:CURRENT_MONITOR' 'SR03CPS04:CURRENT_SP ' 1 [3,2] 10 1.000 ; ...
-'3VCM3 ' 'SR03CPS06:CURRENT_MONITOR' 'SR03CPS06:CURRENT_SP ' 1 [3,3] 11 1.000 ; ...
-'3VCM4 ' 'SR03CPS07:CURRENT_MONITOR' 'SR03CPS07:CURRENT_SP ' 1 [3,4] 12 1.000 ; ...
-'4VCM1 ' 'SR04CPS02:CURRENT_MONITOR' 'SR04CPS02:CURRENT_SP ' 1 [4,1] 13 1.000 ; ...
-'4VCM2 ' 'SR04CPS04:CURRENT_MONITOR' 'SR04CPS04:CURRENT_SP ' 1 [4,2] 14 1.000 ; ...
-'4VCM3 ' 'SR04CPS06:CURRENT_MONITOR' 'SR04CPS06:CURRENT_SP ' 1 [4,3] 15 1.000 ; ...
-'4VCM4 ' 'SR04CPS07:CURRENT_MONITOR' 'SR04CPS07:CURRENT_SP ' 1 [4,4] 16 1.000 ; ...
-'5VCM1 ' 'SR05CPS02:CURRENT_MONITOR' 'SR05CPS02:CURRENT_SP ' 1 [5,1] 17 1.000 ; ...
-'5VCM2 ' 'SR05CPS04:CURRENT_MONITOR' 'SR05CPS04:CURRENT_SP ' 1 [5,2] 18 1.000 ; ...
-'5VCM3 ' 'SR05CPS06:CURRENT_MONITOR' 'SR05CPS06:CURRENT_SP ' 1 [5,3] 19 1.000 ; ...
-'5VCM4 ' 'SR05CPS07:CURRENT_MONITOR' 'SR05CPS07:CURRENT_SP ' 1 [5,4] 20 1.000 ; ...
-'6VCM1 ' 'SR06CPS02:CURRENT_MONITOR' 'SR06CPS02:CURRENT_SP ' 1 [6,1] 21 1.000 ; ...
-'6VCM2 ' 'SR06CPS04:CURRENT_MONITOR' 'SR06CPS04:CURRENT_SP ' 1 [6,2] 22 1.000 ; ...
-'6VCM3 ' 'SR06CPS06:CURRENT_MONITOR' 'SR06CPS06:CURRENT_SP ' 1 [6,3] 23 1.000 ; ...
-'6VCM4 ' 'SR06CPS07:CURRENT_MONITOR' 'SR06CPS07:CURRENT_SP ' 1 [6,4] 24 1.000 ; ...
-'7VCM1 ' 'SR07CPS02:CURRENT_MONITOR' 'SR07CPS02:CURRENT_SP ' 1 [7,1] 25 1.000 ; ...
-'7VCM2 ' 'SR07CPS04:CURRENT_MONITOR' 'SR07CPS04:CURRENT_SP ' 1 [7,2] 26 1.000 ; ...
-'7VCM3 ' 'SR07CPS06:CURRENT_MONITOR' 'SR07CPS06:CURRENT_SP ' 1 [7,3] 27 1.000 ; ...
-'7VCM4 ' 'SR07CPS07:CURRENT_MONITOR' 'SR07CPS07:CURRENT_SP ' 1 [7,4] 28 1.000 ; ...
-'8VCM1 ' 'SR08CPS02:CURRENT_MONITOR' 'SR08CPS02:CURRENT_SP ' 1 [8,1] 29 1.000 ; ...
-'8VCM2 ' 'SR08CPS04:CURRENT_MONITOR' 'SR08CPS04:CURRENT_SP ' 1 [8,2] 30 1.000 ; ...
-'8VCM3 ' 'SR08CPS06:CURRENT_MONITOR' 'SR08CPS06:CURRENT_SP ' 1 [8,3] 31 1.000 ; ...
-'8VCM4 ' 'SR08CPS07:CURRENT_MONITOR' 'SR08CPS07:CURRENT_SP ' 1 [8,4] 32 1.000 ; ...
-'9VCM1 ' 'SR09CPS02:CURRENT_MONITOR' 'SR09CPS02:CURRENT_SP ' 1 [9,1] 33 1.000 ; ...
-'9VCM2 ' 'SR09CPS04:CURRENT_MONITOR' 'SR09CPS04:CURRENT_SP ' 1 [9,2] 34 1.000 ; ...
-'9VCM3 ' 'SR09CPS06:CURRENT_MONITOR' 'SR09CPS06:CURRENT_SP ' 1 [9,3] 35 1.000 ; ...
-'9VCM4 ' 'SR09CPS07:CURRENT_MONITOR' 'SR09CPS07:CURRENT_SP ' 1 [9,4] 36 1.000 ; ...
-'10VCM1 ' 'SR10CPS02:CURRENT_MONITOR' 'SR10CPS02:CURRENT_SP ' 1 [10,1] 37 1.000 ; ...
-'10VCM2 ' 'SR10CPS04:CURRENT_MONITOR' 'SR10CPS04:CURRENT_SP ' 1 [10,2] 38 1.000 ; ...
-'10VCM3 ' 'SR10CPS06:CURRENT_MONITOR' 'SR10CPS06:CURRENT_SP ' 1 [10,3] 39 1.000 ; ...
-'10VCM4 ' 'SR10CPS07:CURRENT_MONITOR' 'SR10CPS07:CURRENT_SP ' 1 [10,4] 40 1.000 ; ...
-'11VCM1 ' 'SR11CPS02:CURRENT_MONITOR' 'SR11CPS02:CURRENT_SP ' 1 [11,1] 41 1.000 ; ...
-'11VCM2 ' 'SR11CPS04:CURRENT_MONITOR' 'SR11CPS04:CURRENT_SP ' 1 [11,2] 42 1.000 ; ...
-'11VCM3 ' 'SR11CPS06:CURRENT_MONITOR' 'SR11CPS06:CURRENT_SP ' 1 [11,3] 43 1.000 ; ...
-'11VCM4 ' 'SR11CPS07:CURRENT_MONITOR' 'SR11CPS07:CURRENT_SP ' 1 [11,4] 44 1.000 ; ...
-'12VCM1 ' 'SR12CPS02:CURRENT_MONITOR' 'SR12CPS02:CURRENT_SP ' 1 [12,1] 45 1.000 ; ...
-'12VCM2 ' 'SR12CPS04:CURRENT_MONITOR' 'SR12CPS04:CURRENT_SP ' 1 [12,2] 46 1.000 ; ...
-'12VCM3 ' 'SR12CPS06:CURRENT_MONITOR' 'SR12CPS06:CURRENT_SP ' 1 [12,3] 47 1.000 ; ...
-'12VCM4 ' 'SR12CPS07:CURRENT_MONITOR' 'SR12CPS07:CURRENT_SP ' 1 [12,4] 48 1.000 ; ...
-'13VCM1 ' 'SR13CPS02:CURRENT_MONITOR' 'SR13CPS02:CURRENT_SP ' 1 [13,1] 49 1.000 ; ...
-'13VCM2 ' 'SR13CPS04:CURRENT_MONITOR' 'SR13CPS04:CURRENT_SP ' 1 [13,2] 50 1.000 ; ...
-'13VCM3 ' 'SR13CPS06:CURRENT_MONITOR' 'SR13CPS06:CURRENT_SP ' 1 [13,3] 51 1.000 ; ...
-'13VCM4 ' 'SR13CPS07:CURRENT_MONITOR' 'SR13CPS07:CURRENT_SP ' 1 [13,4] 52 1.000 ; ...
-'14VCM1 ' 'SR14CPS02:CURRENT_MONITOR' 'SR14CPS02:CURRENT_SP ' 1 [14,1] 53 1.000 ; ...
-'14VCM2 ' 'SR14CPS04:CURRENT_MONITOR' 'SR14CPS04:CURRENT_SP ' 1 [14,2] 54 1.000 ; ...
-'14VCM3 ' 'SR14CPS06:CURRENT_MONITOR' 'SR14CPS06:CURRENT_SP ' 1 [14,3] 55 1.000 ; ...
-'14VCM4 ' 'SR14CPS07:CURRENT_MONITOR' 'SR14CPS07:CURRENT_SP ' 1 [14,4] 56 1.000 ; ...
-};
-
-[C, Leff, MagnetType] = magnetcoefficients('VCM');
-
-for ii=1:size(cor,1)
-name=cor{ii,1}; AO.VCM.CommonNames(ii,:) = name;
-name=cor{ii,2}; AO.VCM.Monitor.ChannelNames(ii,:) = name;
-name=cor{ii,3}; AO.VCM.Setpoint.ChannelNames(ii,:) = name;
-val =cor{ii,4}; AO.VCM.Status(ii,1) = val;
-val =cor{ii,5}; AO.VCM.DeviceList(ii,:) = val;
-val =cor{ii,6}; AO.VCM.ElementList(ii,1) = val;
-val =cor{ii,7}; AO.VCM.Setpoint.Tolerance(ii,1) = val;
-
-AO.VCM.Setpoint.Range(ii,:) = [+125 -125];
-AO.VCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
-AO.VCM.Monitor.Physics2HWParams{1}(ii,:) = C;
-AO.VCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
-AO.VCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
-end
-
-
-%=============================
-% MAIN MAGNETS
-%=============================
-
-%===========
-%Dipole data
-%===========
-
-% *** BEND ***
-AO.BEND.FamilyName = 'BEND'; dispobject(AO,AO.BEND.FamilyName);
-AO.BEND.MemberOf = {'PlotFamily'; 'MachineConfig'; 'BEND'; 'Magnet';};
-HW2PhysicsParams = magnetcoefficients('BEND');
-Physics2HWParams = magnetcoefficients('BEND');
-
-AO.BEND.Monitor.Mode = Mode;
-AO.BEND.Monitor.DataType = 'Scalar';
-AO.BEND.Monitor.Units = 'Hardware';
-AO.BEND.Monitor.HW2PhysicsFcn = @bend2gev; % @bend2gev ???
-AO.BEND.Monitor.Physics2HWFcn = @gev2bend;
-AO.BEND.Monitor.HWUnits = 'ampere';
-AO.BEND.Monitor.PhysicsUnits = 'energy';
-
-AO.BEND.Setpoint.Mode = Mode;
-AO.BEND.Setpoint.DataType = 'Scalar';
-AO.BEND.Setpoint.Units = 'Hardware';
-AO.BEND.Setpoint.HW2PhysicsFcn = @bend2gev;
-AO.BEND.Setpoint.Physics2HWFcn = @gev2bend;
-AO.BEND.Setpoint.HWUnits = 'ampere';
-AO.BEND.Setpoint.PhysicsUnits = 'energy';
-
-% common monitor setpoint stat devlist elem scale tol
-bend={
-'1BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.10 ; ...
-'1BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,2] 2 1.0 0.10 ; ...
-'2BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.10 ; ...
-'2BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,2] 4 1.0 0.10 ; ...
-'3BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.10 ; ...
-'3BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,2] 6 1.0 0.10 ; ...
-'4BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.10 ; ...
-'4BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,2] 8 1.0 0.10 ; ...
-'5BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.10 ; ...
-'5BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,2] 10 1.0 0.10 ; ...
-'6BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.10 ; ...
-'6BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,2] 12 1.0 0.10 ; ...
-'7BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.10 ; ...
-'7BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,2] 14 1.0 0.10 ; ...
-'8BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.10 ; ...
-'8BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,2] 16 1.0 0.10 ; ...
-'9BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.10 ; ...
-'9BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,2] 18 1.0 0.10 ; ...
-'10BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.10 ; ...
-'10BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,2] 20 1.0 0.10 ; ...
-'11BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.10 ; ...
-'11BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,2] 22 1.0 0.10 ; ...
-'12BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.10 ; ...
-'12BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,2] 24 1.0 0.10 ; ...
-'13BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.10 ; ...
-'13BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,2] 26 1.0 0.10 ; ...
-'14BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.10 ; ...
-'14BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,2] 28 1.0 0.10 ; ...
-};
-
-for ii=1:size(bend,1)
-name=bend{ii,1}; AO.BEND.CommonNames(ii,:) = name;
-name=bend{ii,2}; AO.BEND.Monitor.ChannelNames(ii,:) = name;
-name=bend{ii,3}; AO.BEND.Setpoint.ChannelNames(ii,:) = name;
-val =bend{ii,4}; AO.BEND.Status(ii,1) = val;
-val =bend{ii,5}; AO.BEND.DeviceList(ii,:) = val;
-val =bend{ii,6}; AO.BEND.ElementList(ii,1) = val;
-val =bend{ii,7}; % This is the scale factor
-AO.BEND.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.BEND.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.BEND.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.BEND.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.BEND.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.BEND.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.BEND.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.BEND.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =bend{ii,8}; AO.BEND.Setpoint.Tolerance(ii,1) = val;
-
-AO.BEND.Setpoint.Range(ii,:) = [50 695];
-end
-
-%===============
-%Quadrupole data
-%===============
-
-% *** QFA ***
-AO.QFA.FamilyName = 'QFA'; dispobject(AO,AO.QFA.FamilyName);
-AO.QFA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
-HW2PhysicsParams = magnetcoefficients('QFA');
-Physics2HWParams = magnetcoefficients('QFA');
-
-AO.QFA.Monitor.Mode = Mode;
-AO.QFA.Monitor.DataType = 'Scalar';
-AO.QFA.Monitor.Units = 'Hardware';
-AO.QFA.Monitor.HWUnits = 'ampere';
-AO.QFA.Monitor.PhysicsUnits = 'meter^-2';
-AO.QFA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QFA.Monitor.Physics2HWFcn = @k2amp;
-
-AO.QFA.Setpoint.Mode = Mode;
-AO.QFA.Setpoint.DataType = 'Scalar';
-AO.QFA.Setpoint.Units = 'Hardware';
-AO.QFA.Setpoint.HWUnits = 'ampere';
-AO.QFA.Setpoint.PhysicsUnits = 'meter^-2';
-AO.QFA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QFA.Setpoint.Physics2HWFcn = @k2amp;
-
-% common monitor setpoint stat devlist elem scale tol
-qfa={
-'1QFA1 ' 'SR01QPS01:CURRENT_MONITOR' 'SR01QPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
-'1QFA2 ' 'SR01QPS06:CURRENT_MONITOR' 'SR01QPS06:CURRENT_SP ' 1 [1,2] 2 1.0 0.2 ; ...
-'2QFA1 ' 'SR02QPS01:CURRENT_MONITOR' 'SR02QPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.2 ; ...
-'2QFA2 ' 'SR02QPS06:CURRENT_MONITOR' 'SR02QPS06:CURRENT_SP ' 1 [2,2] 4 1.0 0.2 ; ...
-'3QFA1 ' 'SR03QPS01:CURRENT_MONITOR' 'SR03QPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.2 ; ...
-'3QFA2 ' 'SR03QPS06:CURRENT_MONITOR' 'SR03QPS06:CURRENT_SP ' 1 [3,2] 6 1.0 0.2 ; ...
-'4QFA1 ' 'SR04QPS01:CURRENT_MONITOR' 'SR04QPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.2 ; ...
-'4QFA2 ' 'SR04QPS06:CURRENT_MONITOR' 'SR04QPS06:CURRENT_SP ' 1 [4,2] 8 1.0 0.2 ; ...
-'5QFA1 ' 'SR05QPS01:CURRENT_MONITOR' 'SR05QPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.2 ; ...
-'5QFA2 ' 'SR05QPS06:CURRENT_MONITOR' 'SR05QPS06:CURRENT_SP ' 1 [5,2] 10 1.0 0.2 ; ...
-'6QFA1 ' 'SR06QPS01:CURRENT_MONITOR' 'SR06QPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.2 ; ...
-'6QFA2 ' 'SR06QPS06:CURRENT_MONITOR' 'SR06QPS06:CURRENT_SP ' 1 [6,2] 12 1.0 0.2 ; ...
-'7QFA1 ' 'SR07QPS01:CURRENT_MONITOR' 'SR07QPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.2 ; ...
-'7QFA2 ' 'SR07QPS06:CURRENT_MONITOR' 'SR07QPS06:CURRENT_SP ' 1 [7,2] 14 1.0 0.2 ; ...
-'8QFA1 ' 'SR08QPS01:CURRENT_MONITOR' 'SR08QPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.2 ; ...
-'8QFA2 ' 'SR08QPS06:CURRENT_MONITOR' 'SR08QPS06:CURRENT_SP ' 1 [8,2] 16 1.0 0.2 ; ...
-'9QFA1 ' 'SR09QPS01:CURRENT_MONITOR' 'SR09QPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.2 ; ...
-'9QFA2 ' 'SR09QPS06:CURRENT_MONITOR' 'SR09QPS06:CURRENT_SP ' 1 [9,2] 18 1.0 0.2 ; ...
-'10QFA1 ' 'SR10QPS01:CURRENT_MONITOR' 'SR10QPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.2 ; ...
-'10QFA2 ' 'SR10QPS06:CURRENT_MONITOR' 'SR10QPS06:CURRENT_SP ' 1 [10,2] 20 1.0 0.2 ; ...
-'11QFA1 ' 'SR11QPS01:CURRENT_MONITOR' 'SR11QPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.2 ; ...
-'11QFA2 ' 'SR11QPS06:CURRENT_MONITOR' 'SR11QPS06:CURRENT_SP ' 1 [11,2] 22 1.0 0.2 ; ...
-'12QFA1 ' 'SR12QPS01:CURRENT_MONITOR' 'SR12QPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.2 ; ...
-'12QFA2 ' 'SR12QPS06:CURRENT_MONITOR' 'SR12QPS06:CURRENT_SP ' 1 [12,2] 24 1.0 0.2 ; ...
-'13QFA1 ' 'SR13QPS01:CURRENT_MONITOR' 'SR13QPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.2 ; ...
-'13QFA2 ' 'SR13QPS06:CURRENT_MONITOR' 'SR13QPS06:CURRENT_SP ' 1 [13,2] 26 1.0 0.2 ; ...
-'14QFA1 ' 'SR14QPS01:CURRENT_MONITOR' 'SR14QPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.2 ; ...
-'14QFA2 ' 'SR14QPS06:CURRENT_MONITOR' 'SR14QPS06:CURRENT_SP ' 1 [14,2] 28 1.0 0.2 ; ...
-};
-
-for ii=1:size(qfa,1)
-name=qfa{ii,1}; AO.QFA.CommonNames(ii,:) = name;
-name=qfa{ii,2}; AO.QFA.Monitor.ChannelNames(ii,:) = name;
-name=qfa{ii,3}; AO.QFA.Setpoint.ChannelNames(ii,:) = name;
-val =qfa{ii,4}; AO.QFA.Status(ii,1) = val;
-val =qfa{ii,5}; AO.QFA.DeviceList(ii,:) = val;
-val =qfa{ii,6}; AO.QFA.ElementList(ii,1) = val;
-val =qfa{ii,7}; % This is the scale factor
-AO.QFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qfa{ii,8}; AO.QFA.Setpoint.Tolerance(ii,1) = val;
-
-AO.QFA.Setpoint.Range(ii,:) = [0 160];
-end
-
-
-% *** QDA ***
-AO.QDA.FamilyName = 'QDA'; dispobject(AO,AO.QDA.FamilyName);
-AO.QDA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QD';};
-HW2PhysicsParams = magnetcoefficients('QDA');
-Physics2HWParams = magnetcoefficients('QDA');
-
-AO.QDA.Monitor.Mode = Mode;
-AO.QDA.Monitor.DataType = 'Scalar';
-AO.QDA.Monitor.Units = 'Hardware';
-AO.QDA.Monitor.HWUnits = 'ampere';
-AO.QDA.Monitor.PhysicsUnits = 'meter^-2';
-AO.QDA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QDA.Monitor.Physics2HWFcn = @k2amp;
-
-AO.QDA.Setpoint.Mode = Mode;
-AO.QDA.Setpoint.DataType = 'Scalar';
-AO.QDA.Setpoint.Units = 'Hardware';
-AO.QDA.Setpoint.HWUnits = 'ampere';
-AO.QDA.Setpoint.PhysicsUnits = 'meter^-2';
-AO.QDA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QDA.Setpoint.Physics2HWFcn = @k2amp;
-
-% common monitor setpoint stat devlist elem scale tol
-qda={
-'1QDA1 ' 'SR01QPS02:CURRENT_MONITOR' 'SR01QPS02:CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
-'1QDA2 ' 'SR01QPS05:CURRENT_MONITOR' 'SR01QPS05:CURRENT_SP ' 1 [1,2] 2 1.0 0.2 ; ...
-'2QDA1 ' 'SR02QPS02:CURRENT_MONITOR' 'SR02QPS02:CURRENT_SP ' 1 [2,1] 3 1.0 0.2 ; ...
-'2QDA2 ' 'SR02QPS05:CURRENT_MONITOR' 'SR02QPS05:CURRENT_SP ' 1 [2,2] 4 1.0 0.2 ; ...
-'3QDA1 ' 'SR03QPS02:CURRENT_MONITOR' 'SR03QPS02:CURRENT_SP ' 1 [3,1] 5 1.0 0.2 ; ...
-'3QDA2 ' 'SR03QPS05:CURRENT_MONITOR' 'SR03QPS05:CURRENT_SP ' 1 [3,2] 6 1.0 0.2 ; ...
-'4QDA1 ' 'SR04QPS02:CURRENT_MONITOR' 'SR04QPS02:CURRENT_SP ' 1 [4,1] 7 1.0 0.2 ; ...
-'4QDA2 ' 'SR04QPS05:CURRENT_MONITOR' 'SR04QPS05:CURRENT_SP ' 1 [4,2] 8 1.0 0.2 ; ...
-'5QDA1 ' 'SR05QPS02:CURRENT_MONITOR' 'SR05QPS02:CURRENT_SP ' 1 [5,1] 9 1.0 0.2 ; ...
-'5QDA2 ' 'SR05QPS05:CURRENT_MONITOR' 'SR05QPS05:CURRENT_SP ' 1 [5,2] 10 1.0 0.2 ; ...
-'6QDA1 ' 'SR06QPS02:CURRENT_MONITOR' 'SR06QPS02:CURRENT_SP ' 1 [6,1] 11 1.0 0.2 ; ...
-'6QDA2 ' 'SR06QPS05:CURRENT_MONITOR' 'SR06QPS05:CURRENT_SP ' 1 [6,2] 12 1.0 0.2 ; ...
-'7QDA1 ' 'SR07QPS02:CURRENT_MONITOR' 'SR07QPS02:CURRENT_SP ' 1 [7,1] 13 1.0 0.2 ; ...
-'7QDA2 ' 'SR07QPS05:CURRENT_MONITOR' 'SR07QPS05:CURRENT_SP ' 1 [7,2] 14 1.0 0.2 ; ...
-'8QDA1 ' 'SR08QPS02:CURRENT_MONITOR' 'SR08QPS02:CURRENT_SP ' 1 [8,1] 15 1.0 0.2 ; ...
-'8QDA2 ' 'SR08QPS05:CURRENT_MONITOR' 'SR08QPS05:CURRENT_SP ' 1 [8,2] 16 1.0 0.2 ; ...
-'9QDA1 ' 'SR09QPS02:CURRENT_MONITOR' 'SR09QPS02:CURRENT_SP ' 1 [9,1] 17 1.0 0.2 ; ...
-'9QDA2 ' 'SR09QPS05:CURRENT_MONITOR' 'SR09QPS05:CURRENT_SP ' 1 [9,2] 18 1.0 0.2 ; ...
-'10QDA1 ' 'SR10QPS02:CURRENT_MONITOR' 'SR10QPS02:CURRENT_SP ' 1 [10,1] 19 1.0 0.2 ; ...
-'10QDA2 ' 'SR10QPS05:CURRENT_MONITOR' 'SR10QPS05:CURRENT_SP ' 1 [10,2] 20 1.0 0.2 ; ...
-'11QDA1 ' 'SR11QPS02:CURRENT_MONITOR' 'SR11QPS02:CURRENT_SP ' 1 [11,1] 21 1.0 0.2 ; ...
-'11QDA2 ' 'SR11QPS05:CURRENT_MONITOR' 'SR11QPS05:CURRENT_SP ' 1 [11,2] 22 1.0 0.2 ; ...
-'12QDA1 ' 'SR12QPS02:CURRENT_MONITOR' 'SR12QPS02:CURRENT_SP ' 1 [12,1] 23 1.0 0.2 ; ...
-'12QDA2 ' 'SR12QPS05:CURRENT_MONITOR' 'SR12QPS05:CURRENT_SP ' 1 [12,2] 24 1.0 0.2 ; ...
-'13QDA1 ' 'SR13QPS02:CURRENT_MONITOR' 'SR13QPS02:CURRENT_SP ' 1 [13,1] 25 1.0 0.2 ; ...
-'13QDA2 ' 'SR13QPS05:CURRENT_MONITOR' 'SR13QPS05:CURRENT_SP ' 1 [13,2] 26 1.0 0.2 ; ...
-'14QDA1 ' 'SR14QPS02:CURRENT_MONITOR' 'SR14QPS02:CURRENT_SP ' 1 [14,1] 27 1.0 0.2 ; ...
-'14QDA2 ' 'SR14QPS05:CURRENT_MONITOR' 'SR14QPS05:CURRENT_SP ' 1 [14,2] 28 1.0 0.2 ; ...
-};
-
-for ii=1:size(qda,1)
-name=qda{ii,1}; AO.QDA.CommonNames(ii,:) = name;
-name=qda{ii,2}; AO.QDA.Monitor.ChannelNames(ii,:) = name;
-name=qda{ii,3}; AO.QDA.Setpoint.ChannelNames(ii,:) = name;
-val =qda{ii,4}; AO.QDA.Status(ii,1) = val;
-val =qda{ii,5}; AO.QDA.DeviceList(ii,:) = val;
-val =qda{ii,6}; AO.QDA.ElementList(ii,1) = val;
-val =qda{ii,7}; % This is the scale factor
-AO.QDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QDA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qda{ii,8}; AO.QDA.Setpoint.Tolerance(ii,1) = val;
-
-AO.QDA.Setpoint.Range(ii,:) = [0 90];
-end
-
-
-
-% *** QFB ***
-AO.QFB.FamilyName = 'QFB'; dispobject(AO,AO.QFB.FamilyName);
-AO.QFB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
-HW2PhysicsParams = magnetcoefficients('QFB');
-Physics2HWParams = magnetcoefficients('QFB');
-
-AO.QFB.Monitor.Mode = Mode;
-AO.QFB.Monitor.DataType = 'Scalar';
-AO.QFB.Monitor.Units = 'Hardware';
-AO.QFB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QFB.Monitor.Physics2HWFcn = @k2amp;
-AO.QFB.Monitor.HWUnits = 'ampere';
-AO.QFB.Monitor.PhysicsUnits = 'meter^-2';
-
-AO.QFB.Setpoint.Mode = Mode;
-AO.QFB.Setpoint.DataType = 'Scalar';
-AO.QFB.Setpoint.Units = 'Hardware';
-AO.QFB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QFB.Setpoint.Physics2HWFcn = @k2amp;
-AO.QFB.Setpoint.HWUnits = 'ampere';
-AO.QFB.Setpoint.PhysicsUnits = 'meter^-2';
-
-% common monitor setpoint stat devlist elem scale tol
-qfb={
-'1QFB1 ' 'SR01QPS03:CURRENT_MONITOR' 'SR01QPS03:CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
-'1QFB2 ' 'SR01QPS04:CURRENT_MONITOR' 'SR01QPS04:CURRENT_SP ' 1 [1,2] 2 1.0 0.2 ; ...
-'2QFB1 ' 'SR02QPS03:CURRENT_MONITOR' 'SR02QPS03:CURRENT_SP ' 1 [2,1] 3 1.0 0.2 ; ...
-'2QFB2 ' 'SR02QPS04:CURRENT_MONITOR' 'SR02QPS04:CURRENT_SP ' 1 [2,2] 4 1.0 0.2 ; ...
-'3QFB1 ' 'SR03QPS03:CURRENT_MONITOR' 'SR03QPS03:CURRENT_SP ' 1 [3,1] 5 1.0 0.2 ; ...
-'3QFB2 ' 'SR03QPS04:CURRENT_MONITOR' 'SR03QPS04:CURRENT_SP ' 1 [3,2] 6 1.0 0.2 ; ...
-'4QFB1 ' 'SR04QPS03:CURRENT_MONITOR' 'SR04QPS03:CURRENT_SP ' 1 [4,1] 7 1.0 0.2 ; ...
-'4QFB2 ' 'SR04QPS04:CURRENT_MONITOR' 'SR04QPS04:CURRENT_SP ' 1 [4,2] 8 1.0 0.2 ; ...
-'5QFB1 ' 'SR05QPS03:CURRENT_MONITOR' 'SR05QPS03:CURRENT_SP ' 1 [5,1] 9 1.0 0.2 ; ...
-'5QFB2 ' 'SR05QPS04:CURRENT_MONITOR' 'SR05QPS04:CURRENT_SP ' 1 [5,2] 10 1.0 0.2 ; ...
-'6QFB1 ' 'SR06QPS03:CURRENT_MONITOR' 'SR06QPS03:CURRENT_SP ' 1 [6,1] 11 1.0 0.2 ; ...
-'6QFB2 ' 'SR06QPS04:CURRENT_MONITOR' 'SR06QPS04:CURRENT_SP ' 1 [6,2] 12 1.0 0.2 ; ...
-'7QFB1 ' 'SR07QPS03:CURRENT_MONITOR' 'SR07QPS03:CURRENT_SP ' 1 [7,1] 13 1.0 0.2 ; ...
-'7QFB2 ' 'SR07QPS04:CURRENT_MONITOR' 'SR07QPS04:CURRENT_SP ' 1 [7,2] 14 1.0 0.2 ; ...
-'8QFB1 ' 'SR08QPS03:CURRENT_MONITOR' 'SR08QPS03:CURRENT_SP ' 1 [8,1] 15 1.0 0.2 ; ...
-'8QFB2 ' 'SR08QPS04:CURRENT_MONITOR' 'SR08QPS04:CURRENT_SP ' 1 [8,2] 16 1.0 0.2 ; ...
-'9QFB1 ' 'SR09QPS03:CURRENT_MONITOR' 'SR09QPS03:CURRENT_SP ' 1 [9,1] 17 1.0 0.2 ; ...
-'9QFB2 ' 'SR09QPS04:CURRENT_MONITOR' 'SR09QPS04:CURRENT_SP ' 1 [9,2] 18 1.0 0.2 ; ...
-'10QFB1 ' 'SR10QPS03:CURRENT_MONITOR' 'SR10QPS03:CURRENT_SP ' 1 [10,1] 19 1.0 0.2 ; ...
-'10QFB2 ' 'SR10QPS04:CURRENT_MONITOR' 'SR10QPS04:CURRENT_SP ' 1 [10,2] 20 1.0 0.2 ; ...
-'11QFB1 ' 'SR11QPS03:CURRENT_MONITOR' 'SR11QPS03:CURRENT_SP ' 1 [11,1] 21 1.0 0.2 ; ...
-'11QFB2 ' 'SR11QPS04:CURRENT_MONITOR' 'SR11QPS04:CURRENT_SP ' 1 [11,2] 22 1.0 0.2 ; ...
-'12QFB1 ' 'SR12QPS03:CURRENT_MONITOR' 'SR12QPS03:CURRENT_SP ' 1 [12,1] 23 1.0 0.2 ; ...
-'12QFB2 ' 'SR12QPS04:CURRENT_MONITOR' 'SR12QPS04:CURRENT_SP ' 1 [12,2] 24 1.0 0.2 ; ...
-'13QFB1 ' 'SR13QPS03:CURRENT_MONITOR' 'SR13QPS03:CURRENT_SP ' 1 [13,1] 25 1.0 0.2 ; ...
-'13QFB2 ' 'SR13QPS04:CURRENT_MONITOR' 'SR13QPS04:CURRENT_SP ' 1 [13,2] 26 1.0 0.2 ; ...
-'14QFB1 ' 'SR14QPS03:CURRENT_MONITOR' 'SR14QPS03:CURRENT_SP ' 1 [14,1] 27 1.0 0.2 ; ...
-'14QFB2 ' 'SR14QPS04:CURRENT_MONITOR' 'SR14QPS04:CURRENT_SP ' 1 [14,2] 28 1.0 0.2 ; ...
-};
-
-for ii=1:size(qfb,1)
-name=qfb{ii,1}; AO.QFB.CommonNames(ii,:) = name;
-name=qfb{ii,2}; AO.QFB.Monitor.ChannelNames(ii,:) = name;
-name=qfb{ii,3}; AO.QFB.Setpoint.ChannelNames(ii,:) = name;
-val =qfb{ii,4}; AO.QFB.Status(ii,1) = val;
-val =qfb{ii,5}; AO.QFB.DeviceList(ii,:) = val;
-val =qfb{ii,6}; AO.QFB.ElementList(ii,1) = val;
-val =qfb{ii,7}; % This is the scale factor
-AO.QFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qfb{ii,8}; AO.QFB.Setpoint.Tolerance(ii,1) = val;
-
-AO.QFB.Setpoint.Range(ii,:) = [0 160];
-end
-
-
-%===============
-%Sextupole data
-%===============
-% *** SFA ***
-AO.SFA.FamilyName = 'SFA'; dispobject(AO,AO.SFA.FamilyName);
-AO.SFA.MemberOf = {'PlotFamily'; 'SF'; 'SEXT'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SFA');
-Physics2HWParams = magnetcoefficients('SFA');
-
-AO.SFA.Monitor.Mode = Mode;
-AO.SFA.Monitor.DataType = 'Scalar';
-AO.SFA.Monitor.Units = 'Hardware';
-AO.SFA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SFA.Monitor.Physics2HWFcn = @k2amp;
-AO.SFA.Monitor.HWUnits = 'ampere';
-AO.SFA.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SFA.Setpoint.Mode = Mode;
-AO.SFA.Setpoint.DataType = 'Scalar';
-AO.SFA.Setpoint.Units = 'Hardware';
-AO.SFA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SFA.Setpoint.Physics2HWFcn = @k2amp;
-AO.SFA.Setpoint.HWUnits = 'ampere';
-AO.SFA.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sfa={
-'1SFA1 ' 'SR01SPS01:CURRENT_MONITOR' 'SR01SPS01:CURRENT_SP ' 0 [1,1] 1 1.0 0.05 ; ...
-'1SFA2 ' 'SR01SPS07:CURRENT_MONITOR' 'SR01SPS07:CURRENT_SP ' 0 [1,2] 2 1.0 0.05 ; ...
-'2SFA1 ' 'SR02SPS01:CURRENT_MONITOR' 'SR02SPS01:CURRENT_SP ' 0 [2,1] 3 1.0 0.05 ; ...
-'2SFA2 ' 'SR02SPS07:CURRENT_MONITOR' 'SR02SPS07:CURRENT_SP ' 0 [2,2] 4 1.0 0.05 ; ...
-'3SFA1 ' 'SR03SPS01:CURRENT_MONITOR' 'SR03SPS01:CURRENT_SP ' 0 [3,1] 5 1.0 0.05 ; ...
-'3SFA2 ' 'SR03SPS07:CURRENT_MONITOR' 'SR03SPS07:CURRENT_SP ' 0 [3,2] 6 1.0 0.05 ; ...
-'4SFA1 ' 'SR04SPS01:CURRENT_MONITOR' 'SR04SPS01:CURRENT_SP ' 0 [4,1] 7 1.0 0.05 ; ...
-'4SFA2 ' 'SR04SPS07:CURRENT_MONITOR' 'SR04SPS07:CURRENT_SP ' 0 [4,2] 8 1.0 0.05 ; ...
-'5SFA1 ' 'SR05SPS01:CURRENT_MONITOR' 'SR05SPS01:CURRENT_SP ' 0 [5,1] 9 1.0 0.05 ; ...
-'5SFA2 ' 'SR05SPS07:CURRENT_MONITOR' 'SR05SPS07:CURRENT_SP ' 0 [5,2] 10 1.0 0.05 ; ...
-'6SFA1 ' 'SR06SPS01:CURRENT_MONITOR' 'SR06SPS01:CURRENT_SP ' 0 [6,1] 11 1.0 0.05 ; ...
-'6SFA2 ' 'SR06SPS07:CURRENT_MONITOR' 'SR06SPS07:CURRENT_SP ' 0 [6,2] 12 1.0 0.05 ; ...
-'7SFA1 ' 'SR07SPS01:CURRENT_MONITOR' 'SR07SPS01:CURRENT_SP ' 0 [7,1] 13 1.0 0.05 ; ...
-'7SFA2 ' 'SR07SPS07:CURRENT_MONITOR' 'SR07SPS07:CURRENT_SP ' 1 [7,2] 14 1.0 0.05 ; ...
-'8SFA1 ' 'SR08SPS01:CURRENT_MONITOR' 'SR08SPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.05 ; ...
-'8SFA2 ' 'SR08SPS07:CURRENT_MONITOR' 'SR08SPS07:CURRENT_SP ' 1 [8,2] 16 1.0 0.05 ; ...
-'9SFA1 ' 'SR09SPS01:CURRENT_MONITOR' 'SR09SPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.05 ; ...
-'9SFA2 ' 'SR09SPS07:CURRENT_MONITOR' 'SR09SPS07:CURRENT_SP ' 1 [9,2] 18 1.0 0.05 ; ...
-'10SFA1 ' 'SR10SPS01:CURRENT_MONITOR' 'SR10SPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.05 ; ...
-'10SFA2 ' 'SR10SPS07:CURRENT_MONITOR' 'SR10SPS07:CURRENT_SP ' 1 [10,2] 20 1.0 0.05 ; ...
-'11SFA1 ' 'SR11SPS01:CURRENT_MONITOR' 'SR11SPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.05 ; ...
-'11SFA2 ' 'SR11SPS07:CURRENT_MONITOR' 'SR11SPS07:CURRENT_SP ' 1 [11,2] 22 1.0 0.05 ; ...
-'12SFA1 ' 'SR12SPS01:CURRENT_MONITOR' 'SR12SPS01:CURRENT_SP ' 0 [12,1] 23 1.0 0.05 ; ...
-'12SFA2 ' 'SR12SPS07:CURRENT_MONITOR' 'SR12SPS07:CURRENT_SP ' 1 [12,2] 24 1.0 0.05 ; ...
-'13SFA1 ' 'SR13SPS01:CURRENT_MONITOR' 'SR13SPS01:CURRENT_SP ' 0 [13,1] 25 1.0 0.05 ; ...
-'13SFA2 ' 'SR13SPS07:CURRENT_MONITOR' 'SR13SPS07:CURRENT_SP ' 0 [13,2] 26 1.0 0.05 ; ...
-'14SFA1 ' 'SR14SPS01:CURRENT_MONITOR' 'SR14SPS01:CURRENT_SP ' 0 [14,1] 27 1.0 0.05 ; ...
-'14SFA2 ' 'SR14SPS07:CURRENT_MONITOR' 'SR14SPS07:CURRENT_SP ' 0 [14,2] 28 1.0 0.05 ; ...
-};
-
-for ii=1:size(sfa,1)
-name=sfa{ii,1}; AO.SFA.CommonNames(ii,:) = name;
-name=sfa{ii,2}; AO.SFA.Monitor.ChannelNames(ii,:) = name;
-name=sfa{ii,3}; AO.SFA.Setpoint.ChannelNames(ii,:) = name;
-val =sfa{ii,4}; AO.SFA.Status(ii,1) = val;
-val =sfa{ii,5}; AO.SFA.DeviceList(ii,:) = val;
-val =sfa{ii,6}; AO.SFA.ElementList(ii,1) = val;
-val =sfa{ii,7}; % This is the scale factor
-AO.SFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sfa{ii,8}; AO.SFA.Setpoint.Tolerance(ii,1) = val;
-
-AO.SFA.Setpoint.Range(ii,:) = [0 140];
-end
-
-
-
-% *** SDA ***
-AO.SDA.FamilyName = 'SDA'; dispobject(AO,AO.SDA.FamilyName);
-AO.SDA.MemberOf = {'PlotFamily'; 'SD'; 'SEXT'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SDA');
-Physics2HWParams = magnetcoefficients('SDA');
-
-AO.SDA.Monitor.Mode = Mode;
-AO.SDA.Monitor.DataType = 'Scalar';
-AO.SDA.Monitor.Units = 'Hardware';
-AO.SDA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SDA.Monitor.Physics2HWFcn = @k2amp;
-AO.SDA.Monitor.HWUnits = 'ampere';
-AO.SDA.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SDA.Setpoint.Mode = Mode;
-AO.SDA.Setpoint.DataType = 'Scalar';
-AO.SDA.Setpoint.Units = 'Hardware';
-AO.SDA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SDA.Setpoint.Physics2HWFcn = @k2amp;
-AO.SDA.Setpoint.HWUnits = 'ampere';
-AO.SDA.Setpoint.PhysicsUnits = 'meter^-3';
-
-
-% common monitor setpoint stat devlist elem scale tol
-sda={
-'1SDA1 ' 'SR01SPS02:CURRENT_MONITOR' 'SR01SPS02:CURRENT_SP ' 0 [1,1] 1 1.0 0.05 ; ...
-'1SDA2 ' 'SR01SPS06:CURRENT_MONITOR' 'SR01SPS06:CURRENT_SP ' 0 [1,2] 2 1.0 0.05 ; ...
-'2SDA1 ' 'SR02SPS02:CURRENT_MONITOR' 'SR02SPS02:CURRENT_SP ' 0 [2,1] 3 1.0 0.05 ; ...
-'2SDA2 ' 'SR02SPS06:CURRENT_MONITOR' 'SR02SPS06:CURRENT_SP ' 0 [2,2] 4 1.0 0.05 ; ...
-'3SDA1 ' 'SR03SPS02:CURRENT_MONITOR' 'SR03SPS02:CURRENT_SP ' 0 [3,1] 5 1.0 0.05 ; ...
-'3SDA2 ' 'SR03SPS06:CURRENT_MONITOR' 'SR03SPS06:CURRENT_SP ' 0 [3,2] 6 1.0 0.05 ; ...
-'4SDA1 ' 'SR04SPS02:CURRENT_MONITOR' 'SR04SPS02:CURRENT_SP ' 0 [4,1] 7 1.0 0.05 ; ...
-'4SDA2 ' 'SR04SPS06:CURRENT_MONITOR' 'SR04SPS06:CURRENT_SP ' 0 [4,2] 8 1.0 0.05 ; ...
-'5SDA1 ' 'SR05SPS02:CURRENT_MONITOR' 'SR05SPS02:CURRENT_SP ' 0 [5,1] 9 1.0 0.05 ; ...
-'5SDA2 ' 'SR05SPS06:CURRENT_MONITOR' 'SR05SPS06:CURRENT_SP ' 0 [5,2] 10 1.0 0.05 ; ...
-'6SDA1 ' 'SR06SPS02:CURRENT_MONITOR' 'SR06SPS02:CURRENT_SP ' 0 [6,1] 11 1.0 0.05 ; ...
-'6SDA2 ' 'SR06SPS06:CURRENT_MONITOR' 'SR06SPS06:CURRENT_SP ' 0 [6,2] 12 1.0 0.05 ; ...
-'7SDA1 ' 'SR07SPS02:CURRENT_MONITOR' 'SR07SPS02:CURRENT_SP ' 0 [7,1] 13 1.0 0.05 ; ...
-'7SDA2 ' 'SR07SPS06:CURRENT_MONITOR' 'SR07SPS06:CURRENT_SP ' 1 [7,2] 14 1.0 0.05 ; ...
-'8SDA1 ' 'SR08SPS02:CURRENT_MONITOR' 'SR08SPS02:CURRENT_SP ' 1 [8,1] 15 1.0 0.05 ; ...
-'8SDA2 ' 'SR08SPS06:CURRENT_MONITOR' 'SR08SPS06:CURRENT_SP ' 1 [8,2] 16 1.0 0.05 ; ...
-'9SDA1 ' 'SR09SPS02:CURRENT_MONITOR' 'SR09SPS02:CURRENT_SP ' 1 [9,1] 17 1.0 0.05 ; ...
-'9SDA2 ' 'SR09SPS06:CURRENT_MONITOR' 'SR09SPS06:CURRENT_SP ' 1 [9,2] 18 1.0 0.05 ; ...
-'10SDA1 ' 'SR10SPS02:CURRENT_MONITOR' 'SR10SPS02:CURRENT_SP ' 1 [10,1] 19 1.0 0.05 ; ...
-'10SDA2 ' 'SR10SPS06:CURRENT_MONITOR' 'SR10SPS06:CURRENT_SP ' 1 [10,2] 20 1.0 0.05 ; ...
-'11SDA1 ' 'SR11SPS02:CURRENT_MONITOR' 'SR11SPS02:CURRENT_SP ' 1 [11,1] 21 1.0 0.05 ; ...
-'11SDA2 ' 'SR11SPS06:CURRENT_MONITOR' 'SR11SPS06:CURRENT_SP ' 1 [11,2] 22 1.0 0.05 ; ...
-'12SDA1 ' 'SR12SPS02:CURRENT_MONITOR' 'SR12SPS02:CURRENT_SP ' 1 [12,1] 23 1.0 0.05 ; ...
-'12SDA2 ' 'SR12SPS06:CURRENT_MONITOR' 'SR12SPS06:CURRENT_SP ' 1 [12,2] 24 1.0 0.05 ; ...
-'13SDA1 ' 'SR13SPS02:CURRENT_MONITOR' 'SR13SPS02:CURRENT_SP ' 0 [13,1] 25 1.0 0.05 ; ...
-'13SDA2 ' 'SR13SPS06:CURRENT_MONITOR' 'SR13SPS06:CURRENT_SP ' 0 [13,2] 26 1.0 0.05 ; ...
-'14SDA1 ' 'SR14SPS02:CURRENT_MONITOR' 'SR14SPS02:CURRENT_SP ' 0 [14,1] 27 1.0 0.05 ; ...
-'14SDA2 ' 'SR14SPS06:CURRENT_MONITOR' 'SR14SPS06:CURRENT_SP ' 0 [14,2] 28 1.0 0.05 ; ...
-};
-
-for ii=1:size(sda,1)
-name=sda{ii,1}; AO.SDA.CommonNames(ii,:) = name;
-name=sda{ii,2}; AO.SDA.Monitor.ChannelNames(ii,:) = name;
-name=sda{ii,3}; AO.SDA.Setpoint.ChannelNames(ii,:) = name;
-val =sda{ii,4}; AO.SDA.Status(ii,1) = val;
-val =sda{ii,5}; AO.SDA.DeviceList(ii,:) = val;
-val =sda{ii,6}; AO.SDA.ElementList(ii,1) = val;
-val =sda{ii,7}; % This is the scale factor
-AO.SDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sda{ii,8}; AO.SDA.Setpoint.Tolerance(ii,1) = val;
-
-AO.SDA.Setpoint.Range(ii,:) = [0 140];
-end
-
-
-% *** SDB ***
-AO.SDB.FamilyName = 'SDB'; dispobject(AO,AO.SDB.FamilyName);
-AO.SDB.MemberOf = {'PlotFamily'; 'SD'; 'SEXT'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SDB');
-Physics2HWParams = magnetcoefficients('SDB');
-
-AO.SDB.Monitor.Mode = Mode;
-AO.SDB.Monitor.DataType = 'Scalar';
-AO.SDB.Monitor.Units = 'Hardware';
-AO.SDB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SDB.Monitor.Physics2HWFcn = @k2amp;
-AO.SDB.Monitor.HWUnits = 'ampere';
-AO.SDB.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SDB.Setpoint.Mode = Mode;
-AO.SDB.Setpoint.DataType = 'Scalar';
-AO.SDB.Setpoint.Units = 'Hardware';
-AO.SDB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SDB.Setpoint.Physics2HWFcn = @k2amp;
-AO.SDB.Setpoint.HWUnits = 'ampere';
-AO.SDB.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sdb={
-'1SDB1 ' 'SR01SPS03:CURRENT_MONITOR' 'SR01SPS03:CURRENT_SP ' 1 [1,1] 1 1.0 0.05 ; ...
-'1SDB2 ' 'SR01SPS05:CURRENT_MONITOR' 'SR01SPS05:CURRENT_SP ' 1 [1,2] 2 1.0 0.05 ; ...
-'2SDB1 ' 'SR02SPS03:CURRENT_MONITOR' 'SR02SPS03:CURRENT_SP ' 1 [2,1] 3 1.0 0.05 ; ...
-'2SDB2 ' 'SR02SPS05:CURRENT_MONITOR' 'SR02SPS05:CURRENT_SP ' 1 [2,2] 4 1.0 0.05 ; ...
-'3SDB1 ' 'SR03SPS03:CURRENT_MONITOR' 'SR03SPS03:CURRENT_SP ' 1 [3,1] 5 1.0 0.05 ; ...
-'3SDB2 ' 'SR03SPS05:CURRENT_MONITOR' 'SR03SPS05:CURRENT_SP ' 1 [3,2] 6 1.0 0.05 ; ...
-'4SDB1 ' 'SR04SPS03:CURRENT_MONITOR' 'SR04SPS03:CURRENT_SP ' 1 [4,1] 7 1.0 0.05 ; ...
-'4SDB2 ' 'SR04SPS05:CURRENT_MONITOR' 'SR04SPS05:CURRENT_SP ' 1 [4,2] 8 1.0 0.05 ; ...
-'5SDB1 ' 'SR05SPS03:CURRENT_MONITOR' 'SR05SPS03:CURRENT_SP ' 1 [5,1] 9 1.0 0.05 ; ...
-'5SDB2 ' 'SR05SPS05:CURRENT_MONITOR' 'SR05SPS05:CURRENT_SP ' 1 [5,2] 10 1.0 0.05 ; ...
-'6SDB1 ' 'SR06SPS03:CURRENT_MONITOR' 'SR06SPS03:CURRENT_SP ' 1 [6,1] 11 1.0 0.05 ; ...
-'6SDB2 ' 'SR06SPS05:CURRENT_MONITOR' 'SR06SPS05:CURRENT_SP ' 1 [6,2] 12 1.0 0.05 ; ...
-'7SDB1 ' 'SR07SPS03:CURRENT_MONITOR' 'SR07SPS03:CURRENT_SP ' 1 [7,1] 13 1.0 0.05 ; ...
-'7SDB2 ' 'SR07SPS05:CURRENT_MONITOR' 'SR07SPS05:CURRENT_SP ' 1 [7,2] 14 1.0 0.05 ; ...
-'8SDB1 ' 'SR08SPS03:CURRENT_MONITOR' 'SR08SPS03:CURRENT_SP ' 1 [8,1] 15 1.0 0.05 ; ...
-'8SDB2 ' 'SR08SPS05:CURRENT_MONITOR' 'SR08SPS05:CURRENT_SP ' 1 [8,2] 16 1.0 0.05 ; ...
-'9SDB1 ' 'SR09SPS03:CURRENT_MONITOR' 'SR09SPS03:CURRENT_SP ' 1 [9,1] 17 1.0 0.05 ; ...
-'9SDB2 ' 'SR09SPS05:CURRENT_MONITOR' 'SR09SPS05:CURRENT_SP ' 1 [9,2] 18 1.0 0.05 ; ...
-'10SDB1 ' 'SR10SPS03:CURRENT_MONITOR' 'SR10SPS03:CURRENT_SP ' 1 [10,1] 19 1.0 0.05 ; ...
-'10SDB2 ' 'SR10SPS05:CURRENT_MONITOR' 'SR10SPS05:CURRENT_SP ' 1 [10,2] 20 1.0 0.05 ; ...
-'11SDB1 ' 'SR11SPS03:CURRENT_MONITOR' 'SR11SPS03:CURRENT_SP ' 1 [11,1] 21 1.0 0.05 ; ...
-'11SDB2 ' 'SR11SPS05:CURRENT_MONITOR' 'SR11SPS05:CURRENT_SP ' 1 [11,2] 22 1.0 0.05 ; ...
-'12SDB1 ' 'SR12SPS03:CURRENT_MONITOR' 'SR12SPS03:CURRENT_SP ' 1 [12,1] 23 1.0 0.05 ; ...
-'12SDB2 ' 'SR12SPS05:CURRENT_MONITOR' 'SR12SPS05:CURRENT_SP ' 1 [12,2] 24 1.0 0.05 ; ...
-'13SDB1 ' 'SR13SPS03:CURRENT_MONITOR' 'SR13SPS03:CURRENT_SP ' 1 [13,1] 25 1.0 0.05 ; ...
-'13SDB2 ' 'SR13SPS05:CURRENT_MONITOR' 'SR13SPS05:CURRENT_SP ' 1 [13,2] 26 1.0 0.05 ; ...
-'14SDB1 ' 'SR14SPS03:CURRENT_MONITOR' 'SR14SPS03:CURRENT_SP ' 1 [14,1] 27 1.0 0.05 ; ...
-'14SDB2 ' 'SR14SPS05:CURRENT_MONITOR' 'SR14SPS05:CURRENT_SP ' 1 [14,2] 28 1.0 0.05 ; ...
-};
-
-for ii=1:size(sdb,1)
-name=sdb{ii,1}; AO.SDB.CommonNames(ii,:) = name;
-name=sdb{ii,2}; AO.SDB.Monitor.ChannelNames(ii,:) = name;
-name=sdb{ii,3}; AO.SDB.Setpoint.ChannelNames(ii,:)= name;
-val =sdb{ii,4}; AO.SDB.Status(ii,1) = val;
-val =sdb{ii,5}; AO.SDB.DeviceList(ii,:) = val;
-val =sdb{ii,6}; AO.SDB.ElementList(ii,1) = val;
-val =sdb{ii,7}; % This is the scale factor
-AO.SDB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SDB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sdb{ii,8}; AO.SDB.Setpoint.Tolerance(ii,1) = val;
-
-AO.SDB.Setpoint.Range(ii,:) = [0 140];
-end
-
-
-
-% *** SFB ***
-AO.SFB.FamilyName = 'SFB'; dispobject(AO,AO.SFB.FamilyName);
-AO.SFB.MemberOf = {'PlotFamily'; 'SF'; 'SEXT'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SFB');
-Physics2HWParams = magnetcoefficients('SFB');
-
-AO.SFB.Monitor.Mode = Mode;
-AO.SFB.Monitor.DataType = 'Scalar';
-AO.SFB.Monitor.Units = 'Hardware';
-AO.SFB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SFB.Monitor.Physics2HWFcn = @k2amp;
-AO.SFB.Monitor.HWUnits = 'ampere';
-AO.SFB.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SFB.Setpoint.Mode = Mode;
-AO.SFB.Setpoint.DataType = 'Scalar';
-AO.SFB.Setpoint.Units = 'Hardware';
-AO.SFB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SFB.Setpoint.Physics2HWFcn = @k2amp;
-AO.SFB.Setpoint.HWUnits = 'ampere';
-AO.SFB.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sfb={
-'1SFB1 ' 'SR01SPS04:CURRENT_MONITOR' 'SR01SPS04:CURRENT_SP ' 1 [1,1] 1 1.0 0.05 ; ...
-'2SFB1 ' 'SR02SPS04:CURRENT_MONITOR' 'SR02SPS04:CURRENT_SP ' 1 [2,1] 2 1.0 0.05 ; ...
-'3SFB1 ' 'SR03SPS04:CURRENT_MONITOR' 'SR03SPS04:CURRENT_SP ' 1 [3,1] 3 1.0 0.05 ; ...
-'4SFB1 ' 'SR04SPS04:CURRENT_MONITOR' 'SR04SPS04:CURRENT_SP ' 1 [4,1] 4 1.0 0.05 ; ...
-'5SFB1 ' 'SR05SPS04:CURRENT_MONITOR' 'SR05SPS04:CURRENT_SP ' 1 [5,1] 5 1.0 0.05 ; ...
-'6SFB1 ' 'SR06SPS04:CURRENT_MONITOR' 'SR06SPS04:CURRENT_SP ' 1 [6,1] 6 1.0 0.05 ; ...
-'7SFB1 ' 'SR07SPS04:CURRENT_MONITOR' 'SR07SPS04:CURRENT_SP ' 1 [7,1] 7 1.0 0.05 ; ...
-'8SFB1 ' 'SR08SPS04:CURRENT_MONITOR' 'SR08SPS04:CURRENT_SP ' 1 [8,1] 8 1.0 0.05 ; ...
-'9SFB1 ' 'SR09SPS04:CURRENT_MONITOR' 'SR09SPS04:CURRENT_SP ' 1 [9,1] 9 1.0 0.05 ; ...
-'10SFB1 ' 'SR10SPS04:CURRENT_MONITOR' 'SR10SPS04:CURRENT_SP ' 1 [10,1] 10 1.0 0.05 ; ...
-'11SFB1 ' 'SR11SPS04:CURRENT_MONITOR' 'SR11SPS04:CURRENT_SP ' 1 [11,1] 11 1.0 0.05 ; ...
-'12SFB1 ' 'SR12SPS04:CURRENT_MONITOR' 'SR12SPS04:CURRENT_SP ' 1 [12,1] 12 1.0 0.05 ; ...
-'13SFB1 ' 'SR13SPS04:CURRENT_MONITOR' 'SR13SPS04:CURRENT_SP ' 1 [13,1] 13 1.0 0.05 ; ...
-'14SFB1 ' 'SR14SPS04:CURRENT_MONITOR' 'SR14SPS04:CURRENT_SP ' 1 [14,1] 14 1.0 0.05 ; ...
-};
-
-for ii=1:size(sfb,1)
-name=sfb{ii,1}; AO.SFB.CommonNames(ii,:) = name;
-name=sfb{ii,2}; AO.SFB.Monitor.ChannelNames(ii,:) = name;
-name=sfb{ii,3}; AO.SFB.Setpoint.ChannelNames(ii,:)= name;
-val =sfb{ii,4}; AO.SFB.Status(ii,1) = val;
-val =sfb{ii,5}; AO.SFB.DeviceList(ii,:) = val;
-val =sfb{ii,6}; AO.SFB.ElementLsist(ii,1) = val;
-val =sfb{ii,7}; % This is the scale factor
-AO.SFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sfb{ii,8}; AO.SFB.Setpoint.Tolerance(ii,1) = val;
-
-AO.SFB.Setpoint.Range(ii,:) = [0 140];
-end
-
-%===============
-%Skew Quad data
-%===============
-% *** Skew quadrupoles *** 2005/09/27 Eugene
-AO.SKQ.FamilyName = 'SKQ'; dispobject(AO,AO.SKQ.FamilyName);
-AO.SKQ.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SkewQuad'; 'Magnet';};
-HW2PhysicsParams = magnetcoefficients('SKQ');
-Physics2HWParams = magnetcoefficients('SKQ');
-
-AO.SKQ.Monitor.Mode = Mode;
-AO.SKQ.Monitor.DataType = 'Scalar';
-AO.SKQ.Monitor.Units = 'Hardware';
-AO.SKQ.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SKQ.Monitor.Physics2HWFcn = @k2amp;
-AO.SKQ.Monitor.HWUnits = 'ampere';
-AO.SKQ.Monitor.PhysicsUnits = 'meter^-2';
-
-AO.SKQ.Setpoint.Mode = Mode;
-AO.SKQ.Setpoint.DataType = 'Scalar';
-AO.SKQ.Setpoint.Units = 'Hardware';
-AO.SKQ.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SKQ.Setpoint.Physics2HWFcn = @k2amp;
-AO.SKQ.Setpoint.HWUnits = 'ampere';
-AO.SKQ.Setpoint.PhysicsUnits = 'meter^-2';
-
-% common monitor setpoint stat devlist elem scale tol
-sq={
-'1SKQ1 ' 'SR01CPS03:CURRENT_MONITOR' 'SR01CPS03:CURRENT_SP ' 1 [1,1] 1 1 ; ...
-'1SKQ2 ' 'SR01CPS08:CURRENT_MONITOR' 'SR01CPS08:CURRENT_SP ' 1 [1,2] 2 1 ; ...
-'2SKQ1 ' 'SR02CPS03:CURRENT_MONITOR' 'SR02CPS03:CURRENT_SP ' 1 [2,1] 3 1 ; ...
-'2SKQ2 ' 'SR02CPS08:CURRENT_MONITOR' 'SR02CPS08:CURRENT_SP ' 1 [2,2] 4 1 ; ...
-'3SKQ1 ' 'SR03CPS03:CURRENT_MONITOR' 'SR03CPS03:CURRENT_SP ' 1 [3,1] 5 1 ; ...
-'3SKQ2 ' 'SR03CPS08:CURRENT_MONITOR' 'SR03CPS08:CURRENT_SP ' 1 [3,2] 6 1 ; ...
-'4SKQ1 ' 'SR04CPS03:CURRENT_MONITOR' 'SR04CPS03:CURRENT_SP ' 1 [4,1] 7 1 ; ...
-'4SKQ2 ' 'SR04CPS08:CURRENT_MONITOR' 'SR04CPS08:CURRENT_SP ' 1 [4,2] 8 1 ; ...
-'5SKQ1 ' 'SR05CPS03:CURRENT_MONITOR' 'SR05CPS03:CURRENT_SP ' 1 [5,1] 9 1 ; ...
-'5SKQ2 ' 'SR05CPS08:CURRENT_MONITOR' 'SR05CPS08:CURRENT_SP ' 1 [5,2] 10 1 ; ...
-'6SKQ1 ' 'SR06CPS03:CURRENT_MONITOR' 'SR06CPS03:CURRENT_SP ' 1 [6,1] 11 1 ; ...
-'6SKQ2 ' 'SR06CPS08:CURRENT_MONITOR' 'SR06CPS08:CURRENT_SP ' 1 [6,2] 12 1 ; ...
-'7SKQ1 ' 'SR07CPS03:CURRENT_MONITOR' 'SR07CPS03:CURRENT_SP ' 1 [7,1] 13 1 ; ...
-'7SKQ2 ' 'SR07CPS08:CURRENT_MONITOR' 'SR07CPS08:CURRENT_SP ' 1 [7,2] 14 1 ; ...
-'8SKQ1 ' 'SR08CPS03:CURRENT_MONITOR' 'SR08CPS03:CURRENT_SP ' 1 [8,1] 15 1 ; ...
-'8SKQ2 ' 'SR08CPS08:CURRENT_MONITOR' 'SR08CPS08:CURRENT_SP ' 1 [8,2] 16 1 ; ...
-'9SKQ1 ' 'SR09CPS03:CURRENT_MONITOR' 'SR09CPS03:CURRENT_SP ' 1 [9,1] 17 1 ; ...
-'9SKQ2 ' 'SR09CPS08:CURRENT_MONITOR' 'SR09CPS08:CURRENT_SP ' 1 [9,2] 18 1 ; ...
-'10SKQ1 ' 'SR10CPS03:CURRENT_MONITOR' 'SR10CPS03:CURRENT_SP ' 1 [10,1] 19 1 ; ...
-'10SKQ2 ' 'SR10CPS08:CURRENT_MONITOR' 'SR10CPS08:CURRENT_SP ' 1 [10,2] 20 1 ; ...
-'11SKQ1 ' 'SR11CPS03:CURRENT_MONITOR' 'SR11CPS03:CURRENT_SP ' 1 [11,1] 21 1 ; ...
-'11SKQ2 ' 'SR11CPS08:CURRENT_MONITOR' 'SR11CPS08:CURRENT_SP ' 1 [11,2] 22 1 ; ...
-'12SKQ1 ' 'SR12CPS03:CURRENT_MONITOR' 'SR12CPS03:CURRENT_SP ' 1 [12,1] 23 1 ; ...
-'12SKQ2 ' 'SR12CPS08:CURRENT_MONITOR' 'SR12CPS08:CURRENT_SP ' 1 [12,2] 24 1 ; ...
-'13SKQ1 ' 'SR13CPS03:CURRENT_MONITOR' 'SR13CPS03:CURRENT_SP ' 1 [13,1] 25 1 ; ...
-'13SKQ2 ' 'SR13CPS08:CURRENT_MONITOR' 'SR13CPS08:CURRENT_SP ' 1 [13,2] 26 1 ; ...
-'14SKQ1 ' 'SR14CPS03:CURRENT_MONITOR' 'SR14CPS03:CURRENT_SP ' 1 [14,1] 27 1 ; ...
-'14SKQ2 ' 'SR14CPS08:CURRENT_MONITOR' 'SR14CPS08:CURRENT_SP ' 1 [14,2] 28 1 ; ...
-};
-
-for ii=1:size(sq,1)
-name=sq{ii,1}; AO.SKQ.CommonNames(ii,:) = name;
-name=sq{ii,2}; AO.SKQ.Monitor.ChannelNames(ii,:) = name;
-name=sq{ii,3}; AO.SKQ.Setpoint.ChannelNames(ii,:) = name;
-val =sq{ii,4}; AO.SKQ.Status(ii,1) = val;
-val =sq{ii,5}; AO.SKQ.DeviceList(ii,:) = val;
-val =sq{ii,6}; AO.SKQ.ElementList(ii,1) = val;
-val =sq{ii,7}; AO.SKQ.Setpoint.Tolerance(ii,1) = val;
-AO.SKQ.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SKQ.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SKQ.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SKQ.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-
-AO.SKQ.Setpoint.Range(ii,:) = [-5 +5];
-end
-
-
-%===============
-%Kicker data
-%===============
-AO.KICK.FamilyName = 'KICK'; dispobject(AO,AO.KICK.FamilyName);
-AO.KICK.MemberOf = {'Injection','MachineConfig'};
-
-AO.KICK.Monitor.Mode = Mode;
-AO.KICK.Monitor.DataType = 'Scalar';
-AO.KICK.Monitor.Units = 'Hardware';
-AO.KICK.Monitor.HWUnits = 'kVolts';
-AO.KICK.Monitor.PhysicsUnits = 'mradian';
-
-AO.KICK.Setpoint.Mode = Mode;
-AO.KICK.Setpoint.DataType = 'Scalar';
-AO.KICK.Setpoint.Units = 'Hardware';
-AO.KICK.Setpoint.HWUnits = 'Volts';
-AO.KICK.Setpoint.PhysicsUnits = 'radian';
-
-% From kicker deisgn review the kickers are rated to 4380 Amps giving 0.038
-% Tesla converting this to kickangle. Also convert voltage into amps for
-% the conversion?
-%
-% 2780 V on the capacitor banks will create 5240 A delivered to the kicker
-% magnets.
-% From simulations 4380 A creates 0.038607 T over a length of 0.7 m.
-% Therefore 4380 A => 2.7006 mrad. Therefore 2323.740 V => 2.7006 mrad.
-% HW2PHYSICS conversion factor (kV to rad) is therefore 0.0027006/2.32374 =
-% 0.00116217821271. The Ps also goes through a 1:3 transformer therefore
-% the conversion factor increases by 3. Ie 0.00348653463813
-% For V to rad then 0.00000348653463813.
-hw2physics_conversionfactor = 0.00000348653463813;
-
-%common monitor setpoint stat devlist elem tol
-kickeramp={
-'KICK1 ' 'SR14KPS01:VOLTAGE_MONITOR' 'SR14KPS01:VOLTAGE_SP ' 1 [1,1] 1 0.10 ; ...
-'KICK2 ' 'SR01KPS01:VOLTAGE_MONITOR' 'SR01KPS01:VOLTAGE_SP ' 1 [1,2] 2 0.10 ; ...
-'KICK3 ' 'SR01KPS02:VOLTAGE_MONITOR' 'SR01KPS02:VOLTAGE_SP ' 1 [1,3] 3 0.10 ; ...
-'KICK4 ' 'SR02KPS01:VOLTAGE_MONITOR' 'SR02KPS01:VOLTAGE_SP ' 1 [1,4] 4 0.10 ; ...
-};
-
-for ii=1:size(kickeramp,1)
-name=kickeramp{ii,1}; AO.KICK.CommonNames(ii,:) = name;
-name=kickeramp{ii,2}; AO.KICK.Monitor.ChannelNames(ii,:) = name;
-name=kickeramp{ii,3}; AO.KICK.Setpoint.ChannelNames(ii,:)= name;
-val =kickeramp{ii,4}; AO.KICK.Status(ii,1) = val;
-val =kickeramp{ii,5}; AO.KICK.DeviceList(ii,:) = val;
-val =kickeramp{ii,6}; AO.KICK.ElementList(ii,1) = val;
-val =kickeramp{ii,7}; AO.KICK.Setpoint.Tolerance(ii,1) = val;
-
-if ii==1||ii==4
- AO.KICK.Monitor.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
- AO.KICK.Monitor.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
- AO.KICK.Setpoint.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.Range(ii,:) = [-1300 +1300];
-else
- AO.KICK.Monitor.HW2PhysicsParams(ii,:) = -hw2physics_conversionfactor;
- AO.KICK.Monitor.Physics2HWParams(ii,:) = -1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.HW2PhysicsParams(ii,:) = -hw2physics_conversionfactor;
- AO.KICK.Setpoint.Physics2HWParams(ii,:) = -1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.Range(ii,:) = [+1300 -1300];
-end
-end
-
-% *** KICK Delay ***
-% AO.KICK.Delay
-% >> removed >> see previous versions if info needed
-
-
-%============
-%RF System
-%============
-AO.RF.FamilyName = 'RF'; dispobject(AO,AO.RF.FamilyName);
-AO.RF.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
-
-%-------------------------------- 4 cavity Case
-%common stat devlist elem
-rfcommon={
-'RF1 ' 1 [1,1] 1 ; ...
-'RF2 ' 1 [1,2] 2 ; ...
-'RF3 ' 1 [1,3] 3 ; ...
-'RF4 ' 1 [1,4] 4 ; ...
- };
-
-%FreqMon FreqSetpoint HW2PhysicsParams Physics2HWParams Range Tolerance
-rffreq={
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 2500000] 100.0; ...
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 2500000] 100.0; ...
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 2500000] 100.0; ...
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 2500000] 100.0; ...
- };
-
-% PhaseCtrl PhaseMon HW2PhysicsParams Physics2HWParams Range Tolerance
-rfphase={
-'SR07RF01LLE01:MASTER_PHASE_REFERENCE_SP' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
-'SR07RF01LLE01:MASTER_PHASE_REFERENCE_SP' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
-'SR07RF01LLE01:MASTER_PHASE_REFERENCE_SP' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
-'SR07RF01LLE01:MASTER_PHASE_REFERENCE_SP' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
- };
-
-% VoltCtrl VoltMon HW2PhysicsParams Physics2HWParams Range Tolerance
-rfvolt={
-'SRF1:STN:VOLT:CTRL ' 'SR06RF01CAV01:VOLTAGE_MONITOR' 1 1 [0 750] inf ; ...
-'SRF2:STN:VOLT:CTRL ' 'SR06RF02CAV01:VOLTAGE_MONITOR' 1 1 [0 750] inf ; ...
-'SRF3:STN:VOLT:CTRL ' 'SR07RF01CAV01:VOLTAGE_MONITOR' 1 1 [0 750] inf ; ...
-'SRF4:STN:VOLT:CTRL ' 'SR07RF02CAV01:VOLTAGE_MONITOR' 1 1 [0 750] inf ; ...
- };
-
-% PowerCtrl PowerMon Klystronpower HW2PhysicsParams Physics2HWParams Range Tolerance
-% rfpower={
-% 'SRF1:KLYSDRIVFRWD:POWER:ON ' 'SRF1:KLYSDRIVFRWD:POWER' 'SRF1:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-% 'SRF2:KLYSDRIVFRWD:POWER:ON ' 'SRF2:KLYSDRIVFRWD:POWER' 'SRF2:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-% 'SRF3:KLYSDRIVFRWD:POWER:ON ' 'SRF3:KLYSDRIVFRWD:POWER' 'SRF3:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-% 'SRF4:KLYSDRIVFRWD:POWER:ON ' 'SRF4:KLYSDRIVFRWD:POWER' 'SRF4:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-% };
-
-for ii=1:size(rfcommon,1)
-name=rfcommon{ii,1}; AO.RF.CommonNames(ii,:) = name;
-val =rfcommon{ii,2}; AO.RF.Status(ii,1) = val;
-val =rfcommon{ii,3}; AO.RF.DeviceList(ii,:) = val;
-val =rfcommon{ii,4}; AO.RF.ElementList(ii,1) = val;
-end
-
-for ii=1:size(rffreq,1)
-name=rffreq{ii,1}; AO.RF.Monitor.ChannelNames(ii,:) = name;
-name=rffreq{ii,2}; AO.RF.Setpoint.ChannelNames(ii,:) = name;
-val =rffreq{ii,3}; AO.RF.Monitor.HW2PhysicsParams(ii,1) = val;
- AO.RF.Setpoint.HW2PhysicsParams(ii,1) = val;
-val =rffreq{ii,4}; AO.RF.Monitor.Physics2HWParams(ii,1) = val;
- AO.RF.Setpoint.Physics2HWParams(ii,1) = val;
-val =rffreq{ii,5}; AO.RF.Setpoint.Range(ii,:) = val;
-val =rffreq{ii,6}; AO.RF.Setpoint.Tolerance(ii,1) = val;
-end
-
-
-for ii=1:size(rfphase,1)
-name=rfphase{ii,1}; AO.RF.PhaseCtrl.ChannelNames(ii,:) = name;
-name=rfphase{ii,2}; AO.RF.Phase.ChannelNames(ii,:) = name;
-val =rfphase{ii,3}; AO.RF.PhaseCtrl.HW2PhysicsParams(ii,1) = val;
- AO.RF.Phase.HW2PhysicsParams(ii,1) = val;
-val =rfphase{ii,4}; AO.RF.PhaseCtrl.Physics2HWParams(ii,1) = val;
- AO.RF.Phase.Physics2HWParams(ii,1) = val;
-val =rfphase{ii,5}; AO.RF.PhaseCtrl.Range(ii,:) = val;
- AO.RF.Phase.Range(ii,:) = val;
-val =rfphase{ii,6}; AO.RF.PhaseCtrl.Tolerance(ii,1) = val;
- AO.RF.Phase.Tolerance(ii,1) = val;
-end
-
-
-for ii=1:size(rfvolt,1)
-% name=rfvolt{ii,1}; AO.RF.VoltageCtrl.ChannelNames(ii,:) = name;
-name=rfvolt{ii,2}; AO.RF.Voltage.ChannelNames(ii,:) = name;
-val =rfvolt{ii,3}; % AO.RF.VoltageCtrl.HW2PhysicsParams(ii,1) = val;
- AO.RF.Voltage.HW2PhysicsParams(ii,1) = val;
-val =rfvolt{ii,4}; % AO.RF.VoltageCtrl.Physics2HWParams(ii,1) = val;
- AO.RF.Voltage.Physics2HWParams(ii,1) = val;
-val =rfvolt{ii,5}; % AO.RF.VoltageCtrl.Range(ii,:) = val;
- AO.RF.Voltage.Range(ii,:) = val;
-val =rfvolt{ii,6}; % AO.RF.VoltageCtrl.Tolerance(ii,1) = val;
- AO.RF.Voltage.Tolerance(ii,1) = val;
-end
-
-
-% for ii=1:size(rfpower,1)
-% name=rfpower{ii,1}; AO.RF.PowerCtrl.ChannelNames(ii,:) = name;
-% name=rfpower{ii,2}; AO.RF.Power.ChannelNames(ii,:) = name;
-% name=rfpower{ii,3}; AO.RF.KlysPower.ChannelNames(ii,:) = name;
-% val =rfpower{ii,4}; AO.RF.PowerCtrl.HW2PhysicsParams(ii,1) = val;
-% AO.RF.Power.HW2PhysicsParams(ii,1) = val;
-% AO.RF.KlysPower.HW2PhysicsParams(ii,1) = val;
-% val =rfpower{ii,5}; AO.RF.PowerCtrl.Physics2HWParams(ii,1) = val;
-% AO.RF.Power.Physics2HWParams(ii,1) = val;
-% AO.RF.KlysPower.Physics2HWParams(ii,1) = val;
-% val =rfpower{ii,6}; AO.RF.PowerCtrl.Range(ii,:) = val;
-% AO.RF.Power.Range(ii,:) = val;
-% AO.RF.KlysPower.Range(ii,:) = val;
-% val =rfpower{ii,7}; AO.RF.PowerCtrl.Tolerance(ii,1) = val;
-% AO.RF.Power.Tolerance(ii,1) = val;
-% AO.RF.KlysPower.Tolerance(ii,1) = val;
-% end
-
-%Frequency Readback
-AO.RF.Monitor.Mode = Mode;
-AO.RF.Monitor.DataType = 'Scalar';
-AO.RF.Monitor.Units = 'Hardware';
-AO.RF.Monitor.HWUnits = 'Hz';
-AO.RF.Monitor.PhysicsUnits = 'Hz';
-%Frequency Setpoint
-AO.RF.Setpoint.Mode = Mode;
-AO.RF.Setpoint.DataType = 'Scalar';
-AO.RF.Setpoint.Units = 'Hardware';
-AO.RF.Setpoint.HWUnits = 'Hz';
-AO.RF.Setpoint.PhysicsUnits = 'Hz';
-
-%Voltage control
-% AO.RF.VoltageCtrl.Mode = Mode;
-% AO.RF.VoltageCtrl.DataType = 'Scalar';
-% AO.RF.VoltageCtrl.Units = 'Hardware';
-% AO.RF.VoltageCtrl.HWUnits = 'Volts';
-% AO.RF.VoltageCtrl.PhysicsUnits = 'Volts';
-
-%Voltage monitor
-AO.RF.Voltage.Mode = Mode;
-AO.RF.Voltage.DataType = 'Scalar';
-AO.RF.Voltage.Units = 'Hardware';
-AO.RF.Voltage.HWUnits = 'Volts';
-AO.RF.Voltage.PhysicsUnits = 'Volts';
-
-%Power Control
-% AO.RF.PowerCtrl.Mode = Mode;
-% AO.RF.PowerCtrl.DataType = 'Scalar';
-% AO.RF.PowerCtrl.Units = 'Hardware';
-% AO.RF.PowerCtrl.HWUnits = 'MWatts';
-% AO.RF.PowerCtrl.PhysicsUnits = 'MWatts';
-
-%Power Monitor
-AO.RF.Power.Mode = Mode;
-AO.RF.Power.DataType = 'Scalar';
-AO.RF.Power.Units = 'Hardware';
-AO.RF.Power.HWUnits = 'MWatts';
-AO.RF.Power.PhysicsUnits = 'MWatts';
-
-% %Klystron Forward Power
-% AO.RF.KlysPower.Mode = Mode;
-% AO.RF.KlysPower.DataType = 'Scalar';
-% AO.RF.KlysPower.Units = 'Hardware';
-% AO.RF.KlysPower.HWUnits = 'MWatts';
-% AO.RF.KlysPower.PhysicsUnits = 'MWatts';
-
-% %Station Phase Control
-% AO.RF.PhaseCtrl.Mode = Mode;
-% AO.RF.PhaseCtrl.DataType = 'Scalar';
-% AO.RF.PhaseCtrl.Units = 'Hardware';
-% AO.RF.PhaseCtrl.HWUnits = 'Degrees';
-% AO.RF.PhaseCtrl.PhysicsUnits = 'Degrees';
-
-%Station Phase Monitor
-AO.RF.Phase.Mode = Mode;
-AO.RF.Phase.DataType = 'Scalar';
-AO.RF.Phase.Units = 'Hardware';
-AO.RF.Phase.HWUnits = 'Degrees';
-AO.RF.Phase.PhysicsUnits = 'Degrees';
-
-%====
-%TUNE
-%====
-AO.TUNE.FamilyName = 'TUNE'; dispobject(AO,AO.TUNE.FamilyName);
-AO.TUNE.MemberOf = {'Tune'; 'Diagnostics'};
-AO.TUNE.CommonNames = ['xtune';'ytune';'stune'];
-AO.TUNE.DeviceList = [ 1 1; 1 2; 1 3];
-AO.TUNE.ElementList = [1 2 3]';
-AO.TUNE.Status = [1 1 0]';
-
-AO.TUNE.Monitor.Mode = Mode;
-AO.TUNE.Monitor.DataType = 'Vector';
-AO.TUNE.Monitor.DataTypeIndex = [1 2 3]';
-AO.TUNE.Monitor.ChannelNames = 'MeasTune';
-AO.TUNE.Monitor.Units = 'Hardware';
-AO.TUNE.Monitor.HW2PhysicsParams = 1;
-AO.TUNE.Monitor.Physics2HWParams = 1;
-AO.TUNE.Monitor.HWUnits = 'fractional tune';
-AO.TUNE.Monitor.PhysicsUnits = 'fractional tune';
-
-
-%====
-%DCCT
-%====
-AO.DCCT.FamilyName = 'DCCT'; dispobject(AO,AO.DCCT.FamilyName);
-AO.DCCT.MemberOf = {'Diagnostics'};
-AO.DCCT.CommonNames = 'DCCT';
-AO.DCCT.DeviceList = [1 1];
-AO.DCCT.ElementList = [1];
-AO.DCCT.Status = [1];
-
-AO.DCCT.Monitor.Mode = Mode;
-AO.DCCT.Monitor.DataType = 'Scalar';
-AO.DCCT.Monitor.ChannelNames = 'SR11BCM01:CURRENT_MONITOR';
-AO.DCCT.Monitor.Units = 'Hardware';
-AO.DCCT.Monitor.HWUnits = 'milli-ampere';
-AO.DCCT.Monitor.PhysicsUnits = 'ampere';
-AO.DCCT.Monitor.HW2PhysicsParams = 1e-3;
-AO.DCCT.Monitor.Physics2HWParams = 1000;
-
-
-% %==================
-% %Machine Parameters
-% %==================
-% Removed in this version, see pervious version for more info
-
-%======
-%Septum
-%======
-% ifam=ifam+1;
-% AO.Septum.FamilyName = 'Septum'; dispobject(AO,AO.Septum.FamilyName);
-% AO.Septum.MemberOf = {'Injection'};
-% AO.Septum.Status = 1;
-%
-% AO.Septum.CommonNames = 'Septum ';
-% AO.Septum.DeviceList = [3 1];
-% AO.Septum.ElementList = [1];
-%
-% AO.Septum.Monitor.Mode = Mode;
-% AO.Septum.Monitor.DataType = 'Scalar';
-% AO.Septum.Monitor.Units = 'Hardware';
-% AO.Septum.Monitor.HWUnits = 'ampere';
-% AO.Septum.Monitor.PhysicsUnits = 'radian';
-% AO.Septum.Monitor.ChannelNames = 'BTS-B9V:Curr';
-%
-% AO.Septum.Setpoint.Mode = Mode;
-% AO.Septum.Setpoint.DataType = 'Scalar';
-% AO.Septum.Setpoint.Units = 'Hardware';
-% AO.Septum.Setpoint.HWUnits = 'ampere';
-% AO.Septum.Setpoint.PhysicsUnits = 'radian';
-% AO.Septum.Setpoint.ChannelNames = 'BTS-B9V:CurrSetpt';
-% AO.Septum.Setpoint.Range = [0, 2500];
-% AO.Septum.Setpoint.Tolerance = 100.0;
-%
-% AO.Septum.Monitor.HW2PhysicsParams = 1;
-% AO.Septum.Monitor.Physics2HWParams = 1;
-% AO.Septum.Setpoint.HW2PhysicsParams = 1;
-% AO.Septum.Setpoint.Physics2HWParams = 1;
-
-
-%====================
-%Photon Beamline Data
-%====================
-% >> removed >> see previous versions if info needed
-
-%====================
-%BPLD Data
-%====================
-% >> removed >> see previous versions if info needed
-
-
-
-% The operational mode sets the path, filenames, and other important parameters
-% Run setoperationalmode after most of the AO is built so that the Units and Mode fields
-% can be set in setoperationalmode
-fprintf('\n');
-setao(AO);
-setoperationalmode(OperationalMode);
-AO = getao;
-
-
-%%%%%%%%%%%%%%%%
-% DeltaRespMat %
-%%%%%%%%%%%%%%%%
-
-% I remove the physics2hw conversion because the physics2hw is
-% is calibrated yet.
-
-% Set response matrix kick size in hardware units (amps)
-AO.HCM.Setpoint.DeltaRespMat = physics2hw('HCM', 'Setpoint', .15e-3 / 1, AO.HCM.DeviceList);
-AO.VCM.Setpoint.DeltaRespMat = physics2hw('VCM', 'Setpoint', .15e-3 / 1, AO.VCM.DeviceList);
-
-%% 'NoEnergyScaling' because I don't want to force a BEND magnet read at this point
-%AO.HCM.Setpoint.DeltaRespMat = mm2amps('HCM', .5, AO.HCM.DeviceList, 'NoEnergyScaling');
-%AO.VCM.Setpoint.DeltaRespMat = mm2amps('VCM', .5, AO.VCM.DeviceList, 'NoEnergyScaling');
-
-
-AO.QFA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFA.FamilyName, 'Setpoint', AO.QFA.Setpoint.DeltaRespMat, AO.QFA.DeviceList);
-AO.QFB.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFB.FamilyName, 'Setpoint', AO.QFB.Setpoint.DeltaRespMat, AO.QFB.DeviceList);
-AO.QDA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QDA.FamilyName, 'Setpoint', AO.QDA.Setpoint.DeltaRespMat, AO.QDA.DeviceList);
-
-
-AO.SFA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFA.FamilyName, 'Setpoint', AO.SFA.Setpoint.DeltaRespMat, AO.SFA.DeviceList);
-AO.SFB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFB.FamilyName, 'Setpoint', AO.SFB.Setpoint.DeltaRespMat, AO.SFB.DeviceList);
-AO.SDA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDA.FamilyName, 'Setpoint', AO.SDA.Setpoint.DeltaRespMat, AO.SDA.DeviceList);
-AO.SDB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDB.FamilyName, 'Setpoint', AO.SDB.Setpoint.DeltaRespMat, AO.SDB.DeviceList);
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get S-positions [meters] %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Using ...ATIndex(:,1) will accomodata for split elements where the first
-% of a group of elements is put in the first column ie, if SFA is split in
-% two then ATIndex will look like [2 3; 11 12; ...] where each row is a
-% magnet and column represents each split.
-global THERING
-AO.BPMx.Position = findspos(THERING, AO.BPMx.AT.ATIndex(:,1))';
-AO.BPMy.Position = findspos(THERING, AO.BPMy.AT.ATIndex(:,1))';
-AO.FTx.Position = findspos(THERING, AO.FTx.AT.ATIndex(:,1))';
-AO.FTy.Position = findspos(THERING, AO.FTy.AT.ATIndex(:,1))';
-AO.FTsum.Position= findspos(THERING, AO.FTsum.AT.ATIndex(:,1))';
-AO.HCM.Position = findspos(THERING, AO.HCM.AT.ATIndex(:,1))';
-AO.VCM.Position = findspos(THERING, AO.VCM.AT.ATIndex(:,1))';
-AO.QFA.Position = findspos(THERING, AO.QFA.AT.ATIndex(:,1))';
-AO.QDA.Position = findspos(THERING, AO.QDA.AT.ATIndex(:,1))';
-AO.QFB.Position = findspos(THERING, AO.QFB.AT.ATIndex(:,1))';
-AO.SFA.Position = findspos(THERING, AO.SFA.AT.ATIndex(:,1))';
-AO.SFB.Position = findspos(THERING, AO.SFB.AT.ATIndex(:,1))';
-AO.SDA.Position = findspos(THERING, AO.SDA.AT.ATIndex(:,1))';
-AO.SDB.Position = findspos(THERING, AO.SDB.AT.ATIndex(:,1))';
-AO.SKQ.Position = findspos(THERING, AO.SKQ.AT.ATIndex(:,1))';
-AO.BEND.Position = findspos(THERING, AO.BEND.AT.ATIndex(:,1))';
-AO.RF.Position = findspos(THERING, AO.RF.AT.ATIndex(:,1))';
-AO.KICK.Position = findspos(THERING, AO.KICK.AT.ATIndex(:,1))';
-AO.DCCT.Position = 0;
-AO.TUNE.Position = 0;
-
-
-% Save AO
-setao(AO);
-
-
-function dispobject(AO,name)
-
-n = length(fieldnames(AO));
-
-if n > 0
- fprintf(' %10s ',name);
- if mod(n,5) == 0
- fprintf('\n');
- end
+function aspinit(OperationalMode)
+% aspinit(OperationalMode)
+%
+% Initialize parameters for ASP control in MATLAB
+%
+%==========================
+% Accelerator Family Fields
+%==========================
+% FamilyName BPMx, HCM, etc
+% CommonNames Shortcut name for each element (optional)
+% DeviceList [Sector, Number]
+% ElementList number in list
+% Position m, magnet center
+%
+% MONITOR FIELDS
+% Mode online/manual/special/simulator
+% ChannelNames PV for monitor
+% Units Physics or HW
+% HW2PhysicsFcn function handle used to convert from hardware to physics units ==> inline will not compile, see below
+% HW2PhysicsParams parameters used for conversion function
+% Physics2HWFcn function handle used to convert from physics to hardware units
+% Physics2HWParams parameters used for conversion function
+% HWUnits units for Hardware 'ampere';
+% PhysicsUnits units for physics 'Rad';
+%
+% SETPOINT FIELDS
+% Mode online/manual/special/simulator
+% ChannelNames PV for monitor
+% Units hardware or physics
+% HW2PhysicsFcn function handle used to convert from hardware to physics units
+% HW2PhysicsParams parameters used for conversion function
+% Physics2HWFcn function handle used to convert from physics to hardware units
+% Physics2HWParams parameters used for conversion function
+% HWUnits units for Hardware 'ampere';
+% PhysicsUnits units for physics 'Rad';
+% Range minsetpoint, maxsetpoint;
+% Tolerance setpoint-monitor
+%
+%=============================================
+% Accelerator Toolbox Simulation Fields
+%=============================================
+% ATType Quad, Sext, etc
+% ATIndex index in THERING
+% ATParameterGroup parameter group
+%
+%============
+% Family List
+%============
+% BPMx BPMy - beam position monitors
+% HCM VCM - corrector magnets wound into sextupoles
+% BEND - gradient dipoles
+% QFA QDA QFB - quadrupole magnets
+% SFA SDA SDB SFB - sextupole magnets
+% SQK - skew quads wound into SDA magnets
+% KICK - injection kickers (DELTA type)
+% RF - 4 cavities (KEK type?)
+% DCCT
+% Septum (Not in model yet)
+%
+% Normal cell: d1 bpm s1 hcor d2 q1 d3 s2 d4 bpm dip bpm d4 hcor s3 d5 q2 d6 q3 d2 bpm s4
+% d2 q3 d6 q2 d5 s3 hcor d4 bpm dip bpm d4 s2 d3 q1 d2 hcor s1 bpm d1
+
+% === Change Log ===
+% Mark Boland 2004-02-12
+% Eugene Tan 2004-02-23
+% Eugene Tan 2004-12-13
+% Eugene Tan 2005-09-27 ver 4
+% Updated naming convention of the process variables, use version 4 of
+% the lattice "assr4.m" where the correctors have been merged into the
+% sextupoles. Made the necessary changes to updateatindex. Added skew
+% quadrupoles and updated generate_init.
+% Mark Boland 2006-05-27
+% Changed the BPM PVs to ...:SA_HPOS_MONITOR and ...:SA_VPOS_MONITOR
+%
+% === Still to do ===
+% - kicker delays
+% - BPM names and other possible PVs of interest eg. Q factor etc.
+% - clean up and configure the amp2k and k2amp conversion. Control system
+% designed to calculate the strengths and amp values using calc records,
+% therefore we should only need to change the PV name to access for
+% readback at setpoints. Only problem will be in simulation/offline mode
+% where those value are not available online. How do you keep the offline
+% conversion factors up to date with online vals?
+%
+% === Generated from ===
+% aspinit_v5skeleton.m
+
+% Default operational mode
+if nargin < 1
+ OperationalMode = 2;
+end
+
+
+%=============================================
+% START DEFINITION OF ACCELERATOR OBJECTS
+%=============================================
+fprintf(' Defining the Accelerator Objects. Objects being defined:\n')
+
+
+% Clear previous AcceleratorObjects
+setao([]);
+
+
+Mode = 'Online'; % This gets reset in setoperationalmode
+
+%=============================================
+%BPM data: status field designates if BPM in use
+%=============================================
+ntbpm=98;
+AO.BPMx.FamilyName = 'BPMx'; dispobject(AO,AO.BPMx.FamilyName);
+AO.BPMx.MemberOf = {'PlotFamily';};% 'BPM'; 'Diagnostics'};
+AO.BPMx.Monitor.Mode = Mode;
+AO.BPMx.Monitor.DataType = 'Scalar';
+AO.BPMx.Monitor.Units = 'Hardware';
+AO.BPMx.Monitor.HWUnits = 'mm';
+AO.BPMx.Monitor.PhysicsUnits = 'meter';
+
+AO.BPMy.FamilyName = 'BPMy'; dispobject(AO,AO.BPMy.FamilyName);
+AO.BPMy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
+AO.BPMy.Monitor.Mode = Mode;
+AO.BPMy.Monitor.DataType = 'Scalar';
+AO.BPMy.Monitor.Units = 'Hardware';
+AO.BPMy.Monitor.HWUnits = 'mm';
+AO.BPMy.Monitor.PhysicsUnits = 'meter';
+
+% x-name x-chname xstat y-name y-chname ystat DevList Elem
+bpm={
+'1BPMx1 ' 'SR01BPM01:SA_HPOS_MONITOR' 1 '1BPMy1 ' 'SR01BPM01:SA_VPOS_MONITOR' 1 [1,1] 1 ; ...
+'1BPMx2 ' 'SR01BPM02:SA_HPOS_MONITOR' 1 '1BPMy2 ' 'SR01BPM02:SA_VPOS_MONITOR' 1 [1,2] 2 ; ...
+'1BPMx3 ' 'SR01BPM03:SA_HPOS_MONITOR' 1 '1BPMy3 ' 'SR01BPM03:SA_VPOS_MONITOR' 1 [1,3] 3 ; ...
+'1BPMx4 ' 'SR01BPM04:SA_HPOS_MONITOR' 1 '1BPMy4 ' 'SR01BPM04:SA_VPOS_MONITOR' 1 [1,4] 4 ; ...
+'1BPMx5 ' 'SR01BPM05:SA_HPOS_MONITOR' 1 '1BPMy5 ' 'SR01BPM05:SA_VPOS_MONITOR' 1 [1,5] 5 ; ...
+'1BPMx6 ' 'SR01BPM06:SA_HPOS_MONITOR' 1 '1BPMy6 ' 'SR01BPM06:SA_VPOS_MONITOR' 1 [1,6] 6 ; ...
+'1BPMx7 ' 'SR01BPM07:SA_HPOS_MONITOR' 1 '1BPMy7 ' 'SR01BPM07:SA_VPOS_MONITOR' 1 [1,7] 7 ; ...
+'2BPMx1 ' 'SR02BPM01:SA_HPOS_MONITOR' 1 '2BPMy1 ' 'SR02BPM01:SA_VPOS_MONITOR' 1 [2,1] 8 ; ...
+'2BPMx2 ' 'SR02BPM02:SA_HPOS_MONITOR' 1 '2BPMy2 ' 'SR02BPM02:SA_VPOS_MONITOR' 1 [2,2] 9 ; ...
+'2BPMx3 ' 'SR02BPM03:SA_HPOS_MONITOR' 1 '2BPMy3 ' 'SR02BPM03:SA_VPOS_MONITOR' 1 [2,3] 10 ; ...
+'2BPMx4 ' 'SR02BPM04:SA_HPOS_MONITOR' 1 '2BPMy4 ' 'SR02BPM04:SA_VPOS_MONITOR' 1 [2,4] 11 ; ...
+'2BPMx5 ' 'SR02BPM05:SA_HPOS_MONITOR' 1 '2BPMy5 ' 'SR02BPM05:SA_VPOS_MONITOR' 1 [2,5] 12 ; ...
+'2BPMx6 ' 'SR02BPM06:SA_HPOS_MONITOR' 1 '2BPMy6 ' 'SR02BPM06:SA_VPOS_MONITOR' 1 [2,6] 13 ; ...
+'2BPMx7 ' 'SR02BPM07:SA_HPOS_MONITOR' 1 '2BPMy7 ' 'SR02BPM07:SA_VPOS_MONITOR' 1 [2,7] 14 ; ...
+'3BPMx1 ' 'SR03BPM01:SA_HPOS_MONITOR' 1 '3BPMy1 ' 'SR03BPM01:SA_VPOS_MONITOR' 1 [3,1] 15 ; ...
+'3BPMx2 ' 'SR03BPM02:SA_HPOS_MONITOR' 1 '3BPMy2 ' 'SR03BPM02:SA_VPOS_MONITOR' 1 [3,2] 16 ; ...
+'3BPMx3 ' 'SR03BPM03:SA_HPOS_MONITOR' 1 '3BPMy3 ' 'SR03BPM03:SA_VPOS_MONITOR' 1 [3,3] 17 ; ...
+'3BPMx4 ' 'SR03BPM04:SA_HPOS_MONITOR' 1 '3BPMy4 ' 'SR03BPM04:SA_VPOS_MONITOR' 1 [3,4] 18 ; ...
+'3BPMx5 ' 'SR03BPM05:SA_HPOS_MONITOR' 1 '3BPMy5 ' 'SR03BPM05:SA_VPOS_MONITOR' 1 [3,5] 19 ; ...
+'3BPMx6 ' 'SR03BPM06:SA_HPOS_MONITOR' 1 '3BPMy6 ' 'SR03BPM06:SA_VPOS_MONITOR' 1 [3,6] 20 ; ...
+'3BPMx7 ' 'SR03BPM07:SA_HPOS_MONITOR' 1 '3BPMy7 ' 'SR03BPM07:SA_VPOS_MONITOR' 1 [3,7] 21 ; ...
+'4BPMx1 ' 'SR04BPM01:SA_HPOS_MONITOR' 1 '4BPMy1 ' 'SR04BPM01:SA_VPOS_MONITOR' 1 [4,1] 22 ; ...
+'4BPMx2 ' 'SR04BPM02:SA_HPOS_MONITOR' 1 '4BPMy2 ' 'SR04BPM02:SA_VPOS_MONITOR' 1 [4,2] 23 ; ...
+'4BPMx3 ' 'SR04BPM03:SA_HPOS_MONITOR' 1 '4BPMy3 ' 'SR04BPM03:SA_VPOS_MONITOR' 1 [4,3] 24 ; ...
+'4BPMx4 ' 'SR04BPM04:SA_HPOS_MONITOR' 1 '4BPMy4 ' 'SR04BPM04:SA_VPOS_MONITOR' 1 [4,4] 25 ; ...
+'4BPMx5 ' 'SR04BPM05:SA_HPOS_MONITOR' 1 '4BPMy5 ' 'SR04BPM05:SA_VPOS_MONITOR' 1 [4,5] 26 ; ...
+'4BPMx6 ' 'SR04BPM06:SA_HPOS_MONITOR' 1 '4BPMy6 ' 'SR04BPM06:SA_VPOS_MONITOR' 1 [4,6] 27 ; ...
+'4BPMx7 ' 'SR04BPM07:SA_HPOS_MONITOR' 1 '4BPMy7 ' 'SR04BPM07:SA_VPOS_MONITOR' 1 [4,7] 28 ; ...
+'5BPMx1 ' 'SR05BPM01:SA_HPOS_MONITOR' 1 '5BPMy1 ' 'SR05BPM01:SA_VPOS_MONITOR' 1 [5,1] 29 ; ...
+'5BPMx2 ' 'SR05BPM02:SA_HPOS_MONITOR' 1 '5BPMy2 ' 'SR05BPM02:SA_VPOS_MONITOR' 1 [5,2] 30 ; ...
+'5BPMx3 ' 'SR05BPM03:SA_HPOS_MONITOR' 1 '5BPMy3 ' 'SR05BPM03:SA_VPOS_MONITOR' 1 [5,3] 31 ; ...
+'5BPMx4 ' 'SR05BPM04:SA_HPOS_MONITOR' 1 '5BPMy4 ' 'SR05BPM04:SA_VPOS_MONITOR' 1 [5,4] 32 ; ...
+'5BPMx5 ' 'SR05BPM05:SA_HPOS_MONITOR' 1 '5BPMy5 ' 'SR05BPM05:SA_VPOS_MONITOR' 1 [5,5] 33 ; ...
+'5BPMx6 ' 'SR05BPM06:SA_HPOS_MONITOR' 1 '5BPMy6 ' 'SR05BPM06:SA_VPOS_MONITOR' 1 [5,6] 34 ; ...
+'5BPMx7 ' 'SR05BPM07:SA_HPOS_MONITOR' 1 '5BPMy7 ' 'SR05BPM07:SA_VPOS_MONITOR' 1 [5,7] 35 ; ...
+'6BPMx1 ' 'SR06BPM01:SA_HPOS_MONITOR' 1 '6BPMy1 ' 'SR06BPM01:SA_VPOS_MONITOR' 1 [6,1] 36 ; ...
+'6BPMx2 ' 'SR06BPM02:SA_HPOS_MONITOR' 1 '6BPMy2 ' 'SR06BPM02:SA_VPOS_MONITOR' 1 [6,2] 37 ; ...
+'6BPMx3 ' 'SR06BPM03:SA_HPOS_MONITOR' 1 '6BPMy3 ' 'SR06BPM03:SA_VPOS_MONITOR' 1 [6,3] 38 ; ...
+'6BPMx4 ' 'SR06BPM04:SA_HPOS_MONITOR' 1 '6BPMy4 ' 'SR06BPM04:SA_VPOS_MONITOR' 1 [6,4] 39 ; ...
+'6BPMx5 ' 'SR06BPM05:SA_HPOS_MONITOR' 1 '6BPMy5 ' 'SR06BPM05:SA_VPOS_MONITOR' 1 [6,5] 40 ; ...
+'6BPMx6 ' 'SR06BPM06:SA_HPOS_MONITOR' 1 '6BPMy6 ' 'SR06BPM06:SA_VPOS_MONITOR' 1 [6,6] 41 ; ...
+'6BPMx7 ' 'SR06BPM07:SA_HPOS_MONITOR' 1 '6BPMy7 ' 'SR06BPM07:SA_VPOS_MONITOR' 1 [6,7] 42 ; ...
+'7BPMx1 ' 'SR07BPM01:SA_HPOS_MONITOR' 1 '7BPMy1 ' 'SR07BPM01:SA_VPOS_MONITOR' 1 [7,1] 43 ; ...
+'7BPMx2 ' 'SR07BPM02:SA_HPOS_MONITOR' 1 '7BPMy2 ' 'SR07BPM02:SA_VPOS_MONITOR' 1 [7,2] 44 ; ...
+'7BPMx3 ' 'SR07BPM03:SA_HPOS_MONITOR' 1 '7BPMy3 ' 'SR07BPM03:SA_VPOS_MONITOR' 1 [7,3] 45 ; ...
+'7BPMx4 ' 'SR07BPM04:SA_HPOS_MONITOR' 1 '7BPMy4 ' 'SR07BPM04:SA_VPOS_MONITOR' 1 [7,4] 46 ; ...
+'7BPMx5 ' 'SR07BPM05:SA_HPOS_MONITOR' 1 '7BPMy5 ' 'SR07BPM05:SA_VPOS_MONITOR' 1 [7,5] 47 ; ...
+'7BPMx6 ' 'SR07BPM06:SA_HPOS_MONITOR' 1 '7BPMy6 ' 'SR07BPM06:SA_VPOS_MONITOR' 1 [7,6] 48 ; ...
+'7BPMx7 ' 'SR07BPM07:SA_HPOS_MONITOR' 1 '7BPMy7 ' 'SR07BPM07:SA_VPOS_MONITOR' 1 [7,7] 49 ; ...
+'8BPMx1 ' 'SR08BPM01:SA_HPOS_MONITOR' 1 '8BPMy1 ' 'SR08BPM01:SA_VPOS_MONITOR' 1 [8,1] 50 ; ...
+'8BPMx2 ' 'SR08BPM02:SA_HPOS_MONITOR' 1 '8BPMy2 ' 'SR08BPM02:SA_VPOS_MONITOR' 1 [8,2] 51 ; ...
+'8BPMx3 ' 'SR08BPM03:SA_HPOS_MONITOR' 1 '8BPMy3 ' 'SR08BPM03:SA_VPOS_MONITOR' 1 [8,3] 52 ; ...
+'8BPMx4 ' 'SR08BPM04:SA_HPOS_MONITOR' 1 '8BPMy4 ' 'SR08BPM04:SA_VPOS_MONITOR' 1 [8,4] 53 ; ...
+'8BPMx5 ' 'SR08BPM05:SA_HPOS_MONITOR' 1 '8BPMy5 ' 'SR08BPM05:SA_VPOS_MONITOR' 1 [8,5] 54 ; ...
+'8BPMx6 ' 'SR08BPM06:SA_HPOS_MONITOR' 1 '8BPMy6 ' 'SR08BPM06:SA_VPOS_MONITOR' 1 [8,6] 55 ; ...
+'8BPMx7 ' 'SR08BPM07:SA_HPOS_MONITOR' 1 '8BPMy7 ' 'SR08BPM07:SA_VPOS_MONITOR' 1 [8,7] 56 ; ...
+'9BPMx1 ' 'SR09BPM01:SA_HPOS_MONITOR' 1 '9BPMy1 ' 'SR09BPM01:SA_VPOS_MONITOR' 1 [9,1] 57 ; ...
+'9BPMx2 ' 'SR09BPM02:SA_HPOS_MONITOR' 1 '9BPMy2 ' 'SR09BPM02:SA_VPOS_MONITOR' 1 [9,2] 58 ; ...
+'9BPMx3 ' 'SR09BPM03:SA_HPOS_MONITOR' 1 '9BPMy3 ' 'SR09BPM03:SA_VPOS_MONITOR' 1 [9,3] 59 ; ...
+'9BPMx4 ' 'SR09BPM04:SA_HPOS_MONITOR' 1 '9BPMy4 ' 'SR09BPM04:SA_VPOS_MONITOR' 1 [9,4] 60 ; ...
+'9BPMx5 ' 'SR09BPM05:SA_HPOS_MONITOR' 1 '9BPMy5 ' 'SR09BPM05:SA_VPOS_MONITOR' 1 [9,5] 61 ; ...
+'9BPMx6 ' 'SR09BPM06:SA_HPOS_MONITOR' 1 '9BPMy6 ' 'SR09BPM06:SA_VPOS_MONITOR' 1 [9,6] 62 ; ...
+'9BPMx7 ' 'SR09BPM07:SA_HPOS_MONITOR' 1 '9BPMy7 ' 'SR09BPM07:SA_VPOS_MONITOR' 1 [9,7] 63 ; ...
+'10BPMx1 ' 'SR10BPM01:SA_HPOS_MONITOR' 1 '10BPMy1 ' 'SR10BPM01:SA_VPOS_MONITOR' 1 [10,1] 64 ; ...
+'10BPMx2 ' 'SR10BPM02:SA_HPOS_MONITOR' 1 '10BPMy2 ' 'SR10BPM02:SA_VPOS_MONITOR' 1 [10,2] 65 ; ...
+'10BPMx3 ' 'SR10BPM03:SA_HPOS_MONITOR' 1 '10BPMy3 ' 'SR10BPM03:SA_VPOS_MONITOR' 1 [10,3] 66 ; ...
+'10BPMx4 ' 'SR10BPM04:SA_HPOS_MONITOR' 1 '10BPMy4 ' 'SR10BPM04:SA_VPOS_MONITOR' 1 [10,4] 67 ; ...
+'10BPMx5 ' 'SR10BPM05:SA_HPOS_MONITOR' 1 '10BPMy5 ' 'SR10BPM05:SA_VPOS_MONITOR' 1 [10,5] 68 ; ...
+'10BPMx6 ' 'SR10BPM06:SA_HPOS_MONITOR' 1 '10BPMy6 ' 'SR10BPM06:SA_VPOS_MONITOR' 1 [10,6] 69 ; ...
+'10BPMx7 ' 'SR10BPM07:SA_HPOS_MONITOR' 1 '10BPMy7 ' 'SR10BPM07:SA_VPOS_MONITOR' 1 [10,7] 70 ; ...
+'11BPMx1 ' 'SR11BPM01:SA_HPOS_MONITOR' 1 '11BPMy1 ' 'SR11BPM01:SA_VPOS_MONITOR' 1 [11,1] 71 ; ...
+'11BPMx2 ' 'SR11BPM02:SA_HPOS_MONITOR' 1 '11BPMy2 ' 'SR11BPM02:SA_VPOS_MONITOR' 1 [11,2] 72 ; ...
+'11BPMx3 ' 'SR11BPM03:SA_HPOS_MONITOR' 1 '11BPMy3 ' 'SR11BPM03:SA_VPOS_MONITOR' 1 [11,3] 73 ; ...
+'11BPMx4 ' 'SR11BPM04:SA_HPOS_MONITOR' 1 '11BPMy4 ' 'SR11BPM04:SA_VPOS_MONITOR' 1 [11,4] 74 ; ...
+'11BPMx5 ' 'SR11BPM05:SA_HPOS_MONITOR' 1 '11BPMy5 ' 'SR11BPM05:SA_VPOS_MONITOR' 1 [11,5] 75 ; ...
+'11BPMx6 ' 'SR11BPM06:SA_HPOS_MONITOR' 1 '11BPMy6 ' 'SR11BPM06:SA_VPOS_MONITOR' 1 [11,6] 76 ; ...
+'11BPMx7 ' 'SR11BPM07:SA_HPOS_MONITOR' 1 '11BPMy7 ' 'SR11BPM07:SA_VPOS_MONITOR' 1 [11,7] 77 ; ...
+'12BPMx1 ' 'SR12BPM01:SA_HPOS_MONITOR' 1 '12BPMy1 ' 'SR12BPM01:SA_VPOS_MONITOR' 1 [12,1] 78 ; ...
+'12BPMx2 ' 'SR12BPM02:SA_HPOS_MONITOR' 1 '12BPMy2 ' 'SR12BPM02:SA_VPOS_MONITOR' 1 [12,2] 79 ; ...
+'12BPMx3 ' 'SR12BPM03:SA_HPOS_MONITOR' 1 '12BPMy3 ' 'SR12BPM03:SA_VPOS_MONITOR' 1 [12,3] 80 ; ...
+'12BPMx4 ' 'SR12BPM04:SA_HPOS_MONITOR' 1 '12BPMy4 ' 'SR12BPM04:SA_VPOS_MONITOR' 1 [12,4] 81 ; ...
+'12BPMx5 ' 'SR12BPM05:SA_HPOS_MONITOR' 1 '12BPMy5 ' 'SR12BPM05:SA_VPOS_MONITOR' 1 [12,5] 82 ; ...
+'12BPMx6 ' 'SR12BPM06:SA_HPOS_MONITOR' 1 '12BPMy6 ' 'SR12BPM06:SA_VPOS_MONITOR' 1 [12,6] 83 ; ...
+'12BPMx7 ' 'SR12BPM07:SA_HPOS_MONITOR' 1 '12BPMy7 ' 'SR12BPM07:SA_VPOS_MONITOR' 1 [12,7] 84 ; ...
+'13BPMx1 ' 'SR13BPM01:SA_HPOS_MONITOR' 1 '13BPMy1 ' 'SR13BPM01:SA_VPOS_MONITOR' 1 [13,1] 85 ; ...
+'13BPMx2 ' 'SR13BPM02:SA_HPOS_MONITOR' 1 '13BPMy2 ' 'SR13BPM02:SA_VPOS_MONITOR' 1 [13,2] 86 ; ...
+'13BPMx3 ' 'SR13BPM03:SA_HPOS_MONITOR' 1 '13BPMy3 ' 'SR13BPM03:SA_VPOS_MONITOR' 1 [13,3] 87 ; ...
+'13BPMx4 ' 'SR13BPM04:SA_HPOS_MONITOR' 1 '13BPMy4 ' 'SR13BPM04:SA_VPOS_MONITOR' 1 [13,4] 88 ; ...
+'13BPMx5 ' 'SR13BPM05:SA_HPOS_MONITOR' 1 '13BPMy5 ' 'SR13BPM05:SA_VPOS_MONITOR' 1 [13,5] 89 ; ...
+'13BPMx6 ' 'SR13BPM06:SA_HPOS_MONITOR' 1 '13BPMy6 ' 'SR13BPM06:SA_VPOS_MONITOR' 1 [13,6] 90 ; ...
+'13BPMx7 ' 'SR13BPM07:SA_HPOS_MONITOR' 1 '13BPMy7 ' 'SR13BPM07:SA_VPOS_MONITOR' 1 [13,7] 91 ; ...
+'14BPMx1 ' 'SR14BPM01:SA_HPOS_MONITOR' 1 '14BPMy1 ' 'SR14BPM01:SA_VPOS_MONITOR' 1 [14,1] 92 ; ...
+'14BPMx2 ' 'SR14BPM02:SA_HPOS_MONITOR' 1 '14BPMy2 ' 'SR14BPM02:SA_VPOS_MONITOR' 1 [14,2] 93 ; ...
+'14BPMx3 ' 'SR14BPM03:SA_HPOS_MONITOR' 1 '14BPMy3 ' 'SR14BPM03:SA_VPOS_MONITOR' 1 [14,3] 94 ; ...
+'14BPMx4 ' 'SR14BPM04:SA_HPOS_MONITOR' 1 '14BPMy4 ' 'SR14BPM04:SA_VPOS_MONITOR' 1 [14,4] 95 ; ...
+'14BPMx5 ' 'SR14BPM05:SA_HPOS_MONITOR' 1 '14BPMy5 ' 'SR14BPM05:SA_VPOS_MONITOR' 1 [14,5] 96 ; ...
+'14BPMx6 ' 'SR14BPM06:SA_HPOS_MONITOR' 1 '14BPMy6 ' 'SR14BPM06:SA_VPOS_MONITOR' 1 [14,6] 97 ; ...
+'14BPMx7 ' 'SR14BPM07:SA_HPOS_MONITOR' 1 '14BPMy7 ' 'SR14BPM07:SA_VPOS_MONITOR' 1 [14,7] 98 ; ...
+};
+
+%Load fields from data block
+for ii=1:size(bpm,1)
+name=bpm{ii,1}; AO.BPMx.CommonNames(ii,:) = name;
+name=bpm{ii,2}; AO.BPMx.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,3}; AO.BPMx.Status(ii,:) = val;
+name=bpm{ii,4}; AO.BPMy.CommonNames(ii,:) = name;
+name=bpm{ii,5}; AO.BPMy.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,6}; AO.BPMy.Status(ii,:) = val;
+val =bpm{ii,7}; AO.BPMx.DeviceList(ii,:) = val;
+ AO.BPMy.DeviceList(ii,:) = val;
+val =bpm{ii,8}; AO.BPMx.ElementList(ii,:) = val;
+ AO.BPMy.ElementList(ii,:) = val;
+ AO.BPMx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.BPMx.Monitor.Physics2HWParams(ii,:) = 1000;
+ AO.BPMy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.BPMy.Monitor.Physics2HWParams(ii,:) = 1000;
+end
+
+
+% % Get sum value from button. Don't need handles and PV namelist as
+% % parameters are the same as the 'monitor' subcategory.
+% AO.BPMx.Sum.Monitor = AO.BPMx.Monitor;
+% AO.BPMx.Sum.SpecialFunction = 'getbpmsumspear';
+% AO.BPMx.Sum.HWUnits = 'ADC Counts';
+% AO.BPMx.Sum.PhysicsUnits = 'ADC Counts';
+% AO.BPMx.Sum.HW2PhysicsParams = 1;
+% AO.BPMx.Sum.Physics2HWParams = 1;
+% % Get q value from BPMs. Don't need handles and PV namelist.
+% AO.BPMx.Q = AO.BPMx.Monitor;
+% AO.BPMx.Q.SpecialFunction = 'getbpmqspear';
+% AO.BPMx.Q.HWUnits = 'mm';
+% AO.BPMx.Q.PhysicsUnits = 'meter';
+% AO.BPMx.Q.HW2PhysicsParams = 1e-3;
+% AO.BPMx.Q.Physics2HWParams = 1000;
+%
+% % Definition above for horizontal. Replicate for vertical.
+% AO.BPMy.Sum = AO.BPMx.Sum;
+% AO.BPMy.Q = AO.BPMx.Q;
+
+
+
+%=============================================
+% First Turn BPM data from Libera
+%=============================================
+ntbpm=98;
+AO.FTx.FamilyName = 'FTx'; dispobject(AO,AO.FTx.FamilyName);
+AO.FTx.MemberOf = {'PlotFamily';};% 'BPM'; 'Diagnostics'};
+AO.FTx.Monitor.Mode = Mode;
+AO.FTx.Monitor.DataType = 'Scalar';
+AO.FTx.Monitor.Units = 'Hardware';
+AO.FTx.Monitor.HWUnits = 'mm';
+AO.FTx.Monitor.PhysicsUnits = 'meter';
+
+AO.FTy.FamilyName = 'FTy'; dispobject(AO,AO.FTy.FamilyName);
+AO.FTy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
+AO.FTy.Monitor.Mode = Mode;
+AO.FTy.Monitor.DataType = 'Scalar';
+AO.FTy.Monitor.Units = 'Hardware';
+AO.FTy.Monitor.HWUnits = 'mm';
+AO.FTy.Monitor.PhysicsUnits = 'meter';
+
+% x-name x-chname xstat y-name y-chname ystat DevList Elem
+bpm={
+'1FTx1 ' 'SR01BPM01:FT_HPOS_MONITOR' 1 '1BPMy1 ' 'SR01BPM01:FT_VPOS_MONITOR' 1 [1,1] 1 ; ...
+'1FTx2 ' 'SR01BPM02:FT_HPOS_MONITOR' 1 '1BPMy2 ' 'SR01BPM02:FT_VPOS_MONITOR' 1 [1,2] 2 ; ...
+'1FTx3 ' 'SR01BPM03:FT_HPOS_MONITOR' 1 '1BPMy3 ' 'SR01BPM03:FT_VPOS_MONITOR' 1 [1,3] 3 ; ...
+'1FTx4 ' 'SR01BPM04:FT_HPOS_MONITOR' 1 '1BPMy4 ' 'SR01BPM04:FT_VPOS_MONITOR' 1 [1,4] 4 ; ...
+'1FTx5 ' 'SR01BPM05:FT_HPOS_MONITOR' 1 '1BPMy5 ' 'SR01BPM05:FT_VPOS_MONITOR' 1 [1,5] 5 ; ...
+'1FTx6 ' 'SR01BPM06:FT_HPOS_MONITOR' 1 '1BPMy6 ' 'SR01BPM06:FT_VPOS_MONITOR' 1 [1,6] 6 ; ...
+'1FTx7 ' 'SR01BPM07:FT_HPOS_MONITOR' 1 '1BPMy7 ' 'SR01BPM07:FT_VPOS_MONITOR' 1 [1,7] 7 ; ...
+'2FTx1 ' 'SR02BPM01:FT_HPOS_MONITOR' 1 '2BPMy1 ' 'SR02BPM01:FT_VPOS_MONITOR' 1 [2,1] 8 ; ...
+'2FTx2 ' 'SR02BPM02:FT_HPOS_MONITOR' 1 '2BPMy2 ' 'SR02BPM02:FT_VPOS_MONITOR' 1 [2,2] 9 ; ...
+'2FTx3 ' 'SR02BPM03:FT_HPOS_MONITOR' 1 '2BPMy3 ' 'SR02BPM03:FT_VPOS_MONITOR' 1 [2,3] 10 ; ...
+'2FTx4 ' 'SR02BPM04:FT_HPOS_MONITOR' 1 '2BPMy4 ' 'SR02BPM04:FT_VPOS_MONITOR' 1 [2,4] 11 ; ...
+'2FTx5 ' 'SR02BPM05:FT_HPOS_MONITOR' 1 '2BPMy5 ' 'SR02BPM05:FT_VPOS_MONITOR' 1 [2,5] 12 ; ...
+'2FTx6 ' 'SR02BPM06:FT_HPOS_MONITOR' 1 '2BPMy6 ' 'SR02BPM06:FT_VPOS_MONITOR' 1 [2,6] 13 ; ...
+'2FTx7 ' 'SR02BPM07:FT_HPOS_MONITOR' 1 '2BPMy7 ' 'SR02BPM07:FT_VPOS_MONITOR' 1 [2,7] 14 ; ...
+'3FTx1 ' 'SR03BPM01:FT_HPOS_MONITOR' 1 '3BPMy1 ' 'SR03BPM01:FT_VPOS_MONITOR' 1 [3,1] 15 ; ...
+'3FTx2 ' 'SR03BPM02:FT_HPOS_MONITOR' 1 '3BPMy2 ' 'SR03BPM02:FT_VPOS_MONITOR' 1 [3,2] 16 ; ...
+'3FTx3 ' 'SR03BPM03:FT_HPOS_MONITOR' 1 '3BPMy3 ' 'SR03BPM03:FT_VPOS_MONITOR' 1 [3,3] 17 ; ...
+'3FTx4 ' 'SR03BPM04:FT_HPOS_MONITOR' 1 '3BPMy4 ' 'SR03BPM04:FT_VPOS_MONITOR' 1 [3,4] 18 ; ...
+'3FTx5 ' 'SR03BPM05:FT_HPOS_MONITOR' 1 '3BPMy5 ' 'SR03BPM05:FT_VPOS_MONITOR' 1 [3,5] 19 ; ...
+'3FTx6 ' 'SR03BPM06:FT_HPOS_MONITOR' 1 '3BPMy6 ' 'SR03BPM06:FT_VPOS_MONITOR' 1 [3,6] 20 ; ...
+'3FTx7 ' 'SR03BPM07:FT_HPOS_MONITOR' 1 '3BPMy7 ' 'SR03BPM07:FT_VPOS_MONITOR' 1 [3,7] 21 ; ...
+'4FTx1 ' 'SR04BPM01:FT_HPOS_MONITOR' 1 '4BPMy1 ' 'SR04BPM01:FT_VPOS_MONITOR' 1 [4,1] 22 ; ...
+'4FTx2 ' 'SR04BPM02:FT_HPOS_MONITOR' 1 '4BPMy2 ' 'SR04BPM02:FT_VPOS_MONITOR' 1 [4,2] 23 ; ...
+'4FTx3 ' 'SR04BPM03:FT_HPOS_MONITOR' 1 '4BPMy3 ' 'SR04BPM03:FT_VPOS_MONITOR' 1 [4,3] 24 ; ...
+'4FTx4 ' 'SR04BPM04:FT_HPOS_MONITOR' 1 '4BPMy4 ' 'SR04BPM04:FT_VPOS_MONITOR' 1 [4,4] 25 ; ...
+'4FTx5 ' 'SR04BPM05:FT_HPOS_MONITOR' 1 '4BPMy5 ' 'SR04BPM05:FT_VPOS_MONITOR' 1 [4,5] 26 ; ...
+'4FTx6 ' 'SR04BPM06:FT_HPOS_MONITOR' 1 '4BPMy6 ' 'SR04BPM06:FT_VPOS_MONITOR' 1 [4,6] 27 ; ...
+'4FTx7 ' 'SR04BPM07:FT_HPOS_MONITOR' 1 '4BPMy7 ' 'SR04BPM07:FT_VPOS_MONITOR' 1 [4,7] 28 ; ...
+'5FTx1 ' 'SR05BPM01:FT_HPOS_MONITOR' 1 '5BPMy1 ' 'SR05BPM01:FT_VPOS_MONITOR' 1 [5,1] 29 ; ...
+'5FTx2 ' 'SR05BPM02:FT_HPOS_MONITOR' 1 '5BPMy2 ' 'SR05BPM02:FT_VPOS_MONITOR' 1 [5,2] 30 ; ...
+'5FTx3 ' 'SR05BPM03:FT_HPOS_MONITOR' 1 '5BPMy3 ' 'SR05BPM03:FT_VPOS_MONITOR' 1 [5,3] 31 ; ...
+'5FTx4 ' 'SR05BPM04:FT_HPOS_MONITOR' 1 '5BPMy4 ' 'SR05BPM04:FT_VPOS_MONITOR' 1 [5,4] 32 ; ...
+'5FTx5 ' 'SR05BPM05:FT_HPOS_MONITOR' 1 '5BPMy5 ' 'SR05BPM05:FT_VPOS_MONITOR' 1 [5,5] 33 ; ...
+'5FTx6 ' 'SR05BPM06:FT_HPOS_MONITOR' 1 '5BPMy6 ' 'SR05BPM06:FT_VPOS_MONITOR' 1 [5,6] 34 ; ...
+'5FTx7 ' 'SR05BPM07:FT_HPOS_MONITOR' 1 '5BPMy7 ' 'SR05BPM07:FT_VPOS_MONITOR' 1 [5,7] 35 ; ...
+'6FTx1 ' 'SR06BPM01:FT_HPOS_MONITOR' 1 '6BPMy1 ' 'SR06BPM01:FT_VPOS_MONITOR' 1 [6,1] 36 ; ...
+'6FTx2 ' 'SR06BPM02:FT_HPOS_MONITOR' 1 '6BPMy2 ' 'SR06BPM02:FT_VPOS_MONITOR' 1 [6,2] 37 ; ...
+'6FTx3 ' 'SR06BPM03:FT_HPOS_MONITOR' 1 '6BPMy3 ' 'SR06BPM03:FT_VPOS_MONITOR' 1 [6,3] 38 ; ...
+'6FTx4 ' 'SR06BPM04:FT_HPOS_MONITOR' 1 '6BPMy4 ' 'SR06BPM04:FT_VPOS_MONITOR' 1 [6,4] 39 ; ...
+'6FTx5 ' 'SR06BPM05:FT_HPOS_MONITOR' 1 '6BPMy5 ' 'SR06BPM05:FT_VPOS_MONITOR' 1 [6,5] 40 ; ...
+'6FTx6 ' 'SR06BPM06:FT_HPOS_MONITOR' 1 '6BPMy6 ' 'SR06BPM06:FT_VPOS_MONITOR' 1 [6,6] 41 ; ...
+'6FTx7 ' 'SR06BPM07:FT_HPOS_MONITOR' 1 '6BPMy7 ' 'SR06BPM07:FT_VPOS_MONITOR' 1 [6,7] 42 ; ...
+'7FTx1 ' 'SR07BPM01:FT_HPOS_MONITOR' 1 '7BPMy1 ' 'SR07BPM01:FT_VPOS_MONITOR' 1 [7,1] 43 ; ...
+'7FTx2 ' 'SR07BPM02:FT_HPOS_MONITOR' 1 '7BPMy2 ' 'SR07BPM02:FT_VPOS_MONITOR' 1 [7,2] 44 ; ...
+'7FTx3 ' 'SR07BPM03:FT_HPOS_MONITOR' 1 '7BPMy3 ' 'SR07BPM03:FT_VPOS_MONITOR' 1 [7,3] 45 ; ...
+'7FTx4 ' 'SR07BPM04:FT_HPOS_MONITOR' 1 '7BPMy4 ' 'SR07BPM04:FT_VPOS_MONITOR' 1 [7,4] 46 ; ...
+'7FTx5 ' 'SR07BPM05:FT_HPOS_MONITOR' 1 '7BPMy5 ' 'SR07BPM05:FT_VPOS_MONITOR' 1 [7,5] 47 ; ...
+'7FTx6 ' 'SR07BPM06:FT_HPOS_MONITOR' 1 '7BPMy6 ' 'SR07BPM06:FT_VPOS_MONITOR' 1 [7,6] 48 ; ...
+'7FTx7 ' 'SR07BPM07:FT_HPOS_MONITOR' 1 '7BPMy7 ' 'SR07BPM07:FT_VPOS_MONITOR' 1 [7,7] 49 ; ...
+'8FTx1 ' 'SR08BPM01:FT_HPOS_MONITOR' 1 '8BPMy1 ' 'SR08BPM01:FT_VPOS_MONITOR' 1 [8,1] 50 ; ...
+'8FTx2 ' 'SR08BPM02:FT_HPOS_MONITOR' 1 '8BPMy2 ' 'SR08BPM02:FT_VPOS_MONITOR' 1 [8,2] 51 ; ...
+'8FTx3 ' 'SR08BPM03:FT_HPOS_MONITOR' 1 '8BPMy3 ' 'SR08BPM03:FT_VPOS_MONITOR' 1 [8,3] 52 ; ...
+'8FTx4 ' 'SR08BPM04:FT_HPOS_MONITOR' 1 '8BPMy4 ' 'SR08BPM04:FT_VPOS_MONITOR' 1 [8,4] 53 ; ...
+'8FTx5 ' 'SR08BPM05:FT_HPOS_MONITOR' 1 '8BPMy5 ' 'SR08BPM05:FT_VPOS_MONITOR' 1 [8,5] 54 ; ...
+'8FTx6 ' 'SR08BPM06:FT_HPOS_MONITOR' 1 '8BPMy6 ' 'SR08BPM06:FT_VPOS_MONITOR' 1 [8,6] 55 ; ...
+'8FTx7 ' 'SR08BPM07:FT_HPOS_MONITOR' 1 '8BPMy7 ' 'SR08BPM07:FT_VPOS_MONITOR' 1 [8,7] 56 ; ...
+'9FTx1 ' 'SR09BPM01:FT_HPOS_MONITOR' 1 '9BPMy1 ' 'SR09BPM01:FT_VPOS_MONITOR' 1 [9,1] 57 ; ...
+'9FTx2 ' 'SR09BPM02:FT_HPOS_MONITOR' 1 '9BPMy2 ' 'SR09BPM02:FT_VPOS_MONITOR' 1 [9,2] 58 ; ...
+'9FTx3 ' 'SR09BPM03:FT_HPOS_MONITOR' 1 '9BPMy3 ' 'SR09BPM03:FT_VPOS_MONITOR' 1 [9,3] 59 ; ...
+'9FTx4 ' 'SR09BPM04:FT_HPOS_MONITOR' 1 '9BPMy4 ' 'SR09BPM04:FT_VPOS_MONITOR' 1 [9,4] 60 ; ...
+'9FTx5 ' 'SR09BPM05:FT_HPOS_MONITOR' 1 '9BPMy5 ' 'SR09BPM05:FT_VPOS_MONITOR' 1 [9,5] 61 ; ...
+'9FTx6 ' 'SR09BPM06:FT_HPOS_MONITOR' 1 '9BPMy6 ' 'SR09BPM06:FT_VPOS_MONITOR' 1 [9,6] 62 ; ...
+'9FTx7 ' 'SR09BPM07:FT_HPOS_MONITOR' 1 '9BPMy7 ' 'SR09BPM07:FT_VPOS_MONITOR' 1 [9,7] 63 ; ...
+'10FTx1 ' 'SR10BPM01:FT_HPOS_MONITOR' 1 '10BPMy1 ' 'SR10BPM01:FT_VPOS_MONITOR' 1 [10,1] 64 ; ...
+'10FTx2 ' 'SR10BPM02:FT_HPOS_MONITOR' 1 '10BPMy2 ' 'SR10BPM02:FT_VPOS_MONITOR' 1 [10,2] 65 ; ...
+'10FTx3 ' 'SR10BPM03:FT_HPOS_MONITOR' 1 '10BPMy3 ' 'SR10BPM03:FT_VPOS_MONITOR' 1 [10,3] 66 ; ...
+'10FTx4 ' 'SR10BPM04:FT_HPOS_MONITOR' 1 '10BPMy4 ' 'SR10BPM04:FT_VPOS_MONITOR' 1 [10,4] 67 ; ...
+'10FTx5 ' 'SR10BPM05:FT_HPOS_MONITOR' 1 '10BPMy5 ' 'SR10BPM05:FT_VPOS_MONITOR' 1 [10,5] 68 ; ...
+'10FTx6 ' 'SR10BPM06:FT_HPOS_MONITOR' 1 '10BPMy6 ' 'SR10BPM06:FT_VPOS_MONITOR' 1 [10,6] 69 ; ...
+'10FTx7 ' 'SR10BPM07:FT_HPOS_MONITOR' 1 '10BPMy7 ' 'SR10BPM07:FT_VPOS_MONITOR' 1 [10,7] 70 ; ...
+'11FTx1 ' 'SR11BPM01:FT_HPOS_MONITOR' 1 '11BPMy1 ' 'SR11BPM01:FT_VPOS_MONITOR' 1 [11,1] 71 ; ...
+'11FTx2 ' 'SR11BPM02:FT_HPOS_MONITOR' 1 '11BPMy2 ' 'SR11BPM02:FT_VPOS_MONITOR' 1 [11,2] 72 ; ...
+'11FTx3 ' 'SR11BPM03:FT_HPOS_MONITOR' 1 '11BPMy3 ' 'SR11BPM03:FT_VPOS_MONITOR' 1 [11,3] 73 ; ...
+'11FTx4 ' 'SR11BPM04:FT_HPOS_MONITOR' 1 '11BPMy4 ' 'SR11BPM04:FT_VPOS_MONITOR' 1 [11,4] 74 ; ...
+'11FTx5 ' 'SR11BPM05:FT_HPOS_MONITOR' 1 '11BPMy5 ' 'SR11BPM05:FT_VPOS_MONITOR' 1 [11,5] 75 ; ...
+'11FTx6 ' 'SR11BPM06:FT_HPOS_MONITOR' 1 '11BPMy6 ' 'SR11BPM06:FT_VPOS_MONITOR' 1 [11,6] 76 ; ...
+'11FTx7 ' 'SR11BPM07:FT_HPOS_MONITOR' 1 '11BPMy7 ' 'SR11BPM07:FT_VPOS_MONITOR' 1 [11,7] 77 ; ...
+'12FTx1 ' 'SR12BPM01:FT_HPOS_MONITOR' 1 '12BPMy1 ' 'SR12BPM01:FT_VPOS_MONITOR' 1 [12,1] 78 ; ...
+'12FTx2 ' 'SR12BPM02:FT_HPOS_MONITOR' 1 '12BPMy2 ' 'SR12BPM02:FT_VPOS_MONITOR' 1 [12,2] 79 ; ...
+'12FTx3 ' 'SR12BPM03:FT_HPOS_MONITOR' 1 '12BPMy3 ' 'SR12BPM03:FT_VPOS_MONITOR' 1 [12,3] 80 ; ...
+'12FTx4 ' 'SR12BPM04:FT_HPOS_MONITOR' 1 '12BPMy4 ' 'SR12BPM04:FT_VPOS_MONITOR' 1 [12,4] 81 ; ...
+'12FTx5 ' 'SR12BPM05:FT_HPOS_MONITOR' 1 '12BPMy5 ' 'SR12BPM05:FT_VPOS_MONITOR' 1 [12,5] 82 ; ...
+'12FTx6 ' 'SR12BPM06:FT_HPOS_MONITOR' 1 '12BPMy6 ' 'SR12BPM06:FT_VPOS_MONITOR' 1 [12,6] 83 ; ...
+'12FTx7 ' 'SR12BPM07:FT_HPOS_MONITOR' 1 '12BPMy7 ' 'SR12BPM07:FT_VPOS_MONITOR' 1 [12,7] 84 ; ...
+'13FTx1 ' 'SR13BPM01:FT_HPOS_MONITOR' 1 '13BPMy1 ' 'SR13BPM01:FT_VPOS_MONITOR' 1 [13,1] 85 ; ...
+'13FTx2 ' 'SR13BPM02:FT_HPOS_MONITOR' 1 '13BPMy2 ' 'SR13BPM02:FT_VPOS_MONITOR' 1 [13,2] 86 ; ...
+'13FTx3 ' 'SR13BPM03:FT_HPOS_MONITOR' 1 '13BPMy3 ' 'SR13BPM03:FT_VPOS_MONITOR' 1 [13,3] 87 ; ...
+'13FTx4 ' 'SR13BPM04:FT_HPOS_MONITOR' 1 '13BPMy4 ' 'SR13BPM04:FT_VPOS_MONITOR' 1 [13,4] 88 ; ...
+'13FTx5 ' 'SR13BPM05:FT_HPOS_MONITOR' 1 '13BPMy5 ' 'SR13BPM05:FT_VPOS_MONITOR' 1 [13,5] 89 ; ...
+'13FTx6 ' 'SR13BPM06:FT_HPOS_MONITOR' 1 '13BPMy6 ' 'SR13BPM06:FT_VPOS_MONITOR' 1 [13,6] 90 ; ...
+'13FTx7 ' 'SR13BPM07:FT_HPOS_MONITOR' 1 '13BPMy7 ' 'SR13BPM07:FT_VPOS_MONITOR' 1 [13,7] 91 ; ...
+'14FTx1 ' 'SR14BPM01:FT_HPOS_MONITOR' 1 '14BPMy1 ' 'SR14BPM01:FT_VPOS_MONITOR' 1 [14,1] 92 ; ...
+'14FTx2 ' 'SR14BPM02:FT_HPOS_MONITOR' 1 '14BPMy2 ' 'SR14BPM02:FT_VPOS_MONITOR' 1 [14,2] 93 ; ...
+'14FTx3 ' 'SR14BPM03:FT_HPOS_MONITOR' 1 '14BPMy3 ' 'SR14BPM03:FT_VPOS_MONITOR' 1 [14,3] 94 ; ...
+'14FTx4 ' 'SR14BPM04:FT_HPOS_MONITOR' 1 '14BPMy4 ' 'SR14BPM04:FT_VPOS_MONITOR' 1 [14,4] 95 ; ...
+'14FTx5 ' 'SR14BPM05:FT_HPOS_MONITOR' 1 '14BPMy5 ' 'SR14BPM05:FT_VPOS_MONITOR' 1 [14,5] 96 ; ...
+'14FTx6 ' 'SR14BPM06:FT_HPOS_MONITOR' 1 '14BPMy6 ' 'SR14BPM06:FT_VPOS_MONITOR' 1 [14,6] 97 ; ...
+'14FTx7 ' 'SR14BPM07:FT_HPOS_MONITOR' 1 '14BPMy7 ' 'SR14BPM07:FT_VPOS_MONITOR' 1 [14,7] 98 ; ...
+};
+
+%Load fields from data block
+for ii=1:size(bpm,1)
+name=bpm{ii,1}; AO.FTx.CommonNames(ii,:) = name;
+name=bpm{ii,2}; AO.FTx.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,3}; AO.FTx.Status(ii,:) = val;
+name=bpm{ii,4}; AO.FTy.CommonNames(ii,:) = name;
+name=bpm{ii,5}; AO.FTy.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,6}; AO.FTy.Status(ii,:) = val;
+val =bpm{ii,7}; AO.FTx.DeviceList(ii,:) = val;
+ AO.FTy.DeviceList(ii,:) = val;
+val =bpm{ii,8}; AO.FTx.ElementList(ii,:) = val;
+ AO.FTy.ElementList(ii,:) = val;
+ AO.FTx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.FTx.Monitor.Physics2HWParams(ii,:) = 1000;
+ AO.FTy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.FTy.Monitor.Physics2HWParams(ii,:) = 1000;
+end
+AO.FTx.Status = AO.BPMx.Status;
+AO.FTy.Status = AO.BPMy.Status;
+
+AO.FTsum = AO.FTx;
+AO.FTsum.FamilyName = 'FTsum'; dispobject(AO,AO.FTsum.FamilyName);
+AO.FTsum.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
+AO.FTsum.Monitor.Mode = 'Special';
+AO.FTsum.Monitor.Units = 'Hardware';
+AO.FTsum.Monitor.DataType = 'Scalar';
+AO.FTsum.Monitor.SpecialFunction = 'getftsum';
+AO.FTsum.Monitor.HWUnits = 'ADC counts';
+AO.FTsum.Monitor.PhysicsUnits = 'ADC counts';
+AO.FTsum.Monitor.HW2PhysicsParams(:) = 1;
+AO.FTsum.Monitor.Physics2HWParams(:) = 1;
+
+
+% % Get sum value from button. Don't need handles and PV namelist as
+% % parameters are the same as the 'monitor' subcategory.
+AO.FTx.Off.Mode = 'Special';
+AO.FTx.Off.Units = 'Hardware';
+AO.FTx.Off.DataType = 'Scalar';
+AO.FTx.Off.SpecialFunction = 'getftoffset';
+AO.FTx.Off.SpecialFunctionSet = 'setftoffset';
+AO.FTx.Off.HWUnits = '32ns samples';
+AO.FTx.Off.PhysicsUnits = '32ns samples';
+AO.FTx.Off.HW2PhysicsParams = 1;
+AO.FTx.Off.Physics2HWParams = 1;
+
+AO.FTx.Length.Mode = 'Special';
+AO.FTx.Length.Units = 'Hardware';
+AO.FTx.Length.DataType = 'Scalar';
+AO.FTx.Length.SpecialFunction = 'getftlength';
+AO.FTx.Length.SpecialFunctionSet = 'setftlength';
+AO.FTx.Length.HWUnits = '32ns samples';
+AO.FTx.Length.PhysicsUnits = '32ns samples';
+AO.FTx.Length.HW2PhysicsParams = 1;
+AO.FTx.Length.Physics2HWParams = 1;
+
+AO.FTx.Maxadc.Mode = 'Special';
+AO.FTx.Maxadc.Units = 'Hardware';
+AO.FTx.Maxadc.DataType = 'Scalar';
+AO.FTx.Maxadc.SpecialFunction = 'getftmaxadc';
+AO.FTx.Maxadc.HWUnits = 'ADC counts';
+AO.FTx.Maxadc.PhysicsUnits = 'ADC counts';
+AO.FTx.Maxadc.HW2PhysicsParams = 1;
+AO.FTx.Maxadc.Physics2HWParams = 1;
+
+% AO.FTx.Sum.Mode = 'Special';
+% AO.FTx.Sum.Units = 'Hardware';
+% AO.FTx.Sum.DataType = 'Scalar';
+% AO.FTx.Sum.SpecialFunction = 'getftsum';
+% AO.FTx.Sum.HWUnits = 'ADC counts';
+% AO.FTx.Sum.PhysicsUnits = 'ADC counts';
+% AO.FTx.Sum.HW2PhysicsParams = 1;
+% AO.FTx.Sum.Physics2HWParams = 1;
+
+
+%===========================================================
+% Corrector data: status field designates if corrector in use
+% ASP corrector coils wound into sextupoles. Not dynamic correctors.
+%===========================================================
+
+AO.HCM.FamilyName = 'HCM'; dispobject(AO,AO.HCM.FamilyName);
+AO.HCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'HCM'; 'Magnet'};
+
+AO.HCM.Monitor.Mode = Mode;
+AO.HCM.Monitor.DataType = 'Scalar';
+AO.HCM.Monitor.Units = 'Hardware';
+AO.HCM.Monitor.HWUnits = 'ampere';
+AO.HCM.Monitor.PhysicsUnits = 'radian';
+AO.HCM.Monitor.HW2PhysicsFcn = @amp2k;
+AO.HCM.Monitor.Physics2HWFcn = @k2amp;
+
+AO.HCM.Setpoint.Mode = Mode;
+AO.HCM.Setpoint.DataType = 'Scalar';
+AO.HCM.Setpoint.Units = 'Hardware';
+AO.HCM.Setpoint.HWUnits = 'ampere';
+AO.HCM.Setpoint.PhysicsUnits = 'radian';
+AO.HCM.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.HCM.Setpoint.Physics2HWFcn = @k2amp;
+
+% HW in ampere, Physics in radian. Respmat settings below AO definitions.
+% x-common x-monitor x-setpoint stat devlist elem tol
+cor={
+'1HCM1 ' 'SR01CPS01:CURRENT_MONITOR' 'SR01CPS01:CURRENT_SP ' 1 [1,1] 1 1.000 ; ...
+'1HCM2 ' 'SR01CPS05:CURRENT_MONITOR' 'SR01CPS05:CURRENT_SP ' 1 [1,2] 2 1.000 ; ...
+'1HCM3 ' 'SR01CPS09:CURRENT_MONITOR' 'SR01CPS09:CURRENT_SP ' 1 [1,3] 3 1.000 ; ...
+'2HCM1 ' 'SR02CPS01:CURRENT_MONITOR' 'SR02CPS01:CURRENT_SP ' 1 [2,1] 4 1.000 ; ...
+'2HCM2 ' 'SR02CPS05:CURRENT_MONITOR' 'SR02CPS05:CURRENT_SP ' 1 [2,2] 5 1.000 ; ...
+'2HCM3 ' 'SR02CPS09:CURRENT_MONITOR' 'SR02CPS09:CURRENT_SP ' 1 [2,3] 6 1.000 ; ...
+'3HCM1 ' 'SR03CPS01:CURRENT_MONITOR' 'SR03CPS01:CURRENT_SP ' 1 [3,1] 7 1.000 ; ...
+'3HCM2 ' 'SR03CPS05:CURRENT_MONITOR' 'SR03CPS05:CURRENT_SP ' 1 [3,2] 8 1.000 ; ...
+'3HCM3 ' 'SR03CPS09:CURRENT_MONITOR' 'SR03CPS09:CURRENT_SP ' 1 [3,3] 9 1.000 ; ...
+'4HCM1 ' 'SR04CPS01:CURRENT_MONITOR' 'SR04CPS01:CURRENT_SP ' 1 [4,1] 10 1.000 ; ...
+'4HCM2 ' 'SR04CPS05:CURRENT_MONITOR' 'SR04CPS05:CURRENT_SP ' 1 [4,2] 11 1.000 ; ...
+'4HCM3 ' 'SR04CPS09:CURRENT_MONITOR' 'SR04CPS09:CURRENT_SP ' 1 [4,3] 12 1.000 ; ...
+'5HCM1 ' 'SR05CPS01:CURRENT_MONITOR' 'SR05CPS01:CURRENT_SP ' 1 [5,1] 13 1.000 ; ...
+'5HCM2 ' 'SR05CPS05:CURRENT_MONITOR' 'SR05CPS05:CURRENT_SP ' 1 [5,2] 14 1.000 ; ...
+'5HCM3 ' 'SR05CPS09:CURRENT_MONITOR' 'SR05CPS09:CURRENT_SP ' 1 [5,3] 15 1.000 ; ...
+'6HCM1 ' 'SR06CPS01:CURRENT_MONITOR' 'SR06CPS01:CURRENT_SP ' 1 [6,1] 16 1.000 ; ...
+'6HCM2 ' 'SR06CPS05:CURRENT_MONITOR' 'SR06CPS05:CURRENT_SP ' 1 [6,2] 17 1.000 ; ...
+'6HCM3 ' 'SR06CPS09:CURRENT_MONITOR' 'SR06CPS09:CURRENT_SP ' 1 [6,3] 18 1.000 ; ...
+'7HCM1 ' 'SR07CPS01:CURRENT_MONITOR' 'SR07CPS01:CURRENT_SP ' 1 [7,1] 19 1.000 ; ...
+'7HCM2 ' 'SR07CPS05:CURRENT_MONITOR' 'SR07CPS05:CURRENT_SP ' 1 [7,2] 20 1.000 ; ...
+'7HCM3 ' 'SR07CPS09:CURRENT_MONITOR' 'SR07CPS09:CURRENT_SP ' 1 [7,3] 21 1.000 ; ...
+'8HCM1 ' 'SR08CPS01:CURRENT_MONITOR' 'SR08CPS01:CURRENT_SP ' 1 [8,1] 22 1.000 ; ...
+'8HCM2 ' 'SR08CPS05:CURRENT_MONITOR' 'SR08CPS05:CURRENT_SP ' 1 [8,2] 23 1.000 ; ...
+'8HCM3 ' 'SR08CPS09:CURRENT_MONITOR' 'SR08CPS09:CURRENT_SP ' 1 [8,3] 24 1.000 ; ...
+'9HCM1 ' 'SR09CPS01:CURRENT_MONITOR' 'SR09CPS01:CURRENT_SP ' 1 [9,1] 25 1.000 ; ...
+'9HCM2 ' 'SR09CPS05:CURRENT_MONITOR' 'SR09CPS05:CURRENT_SP ' 1 [9,2] 26 1.000 ; ...
+'9HCM3 ' 'SR09CPS09:CURRENT_MONITOR' 'SR09CPS09:CURRENT_SP ' 1 [9,3] 27 1.000 ; ...
+'10HCM1 ' 'SR10CPS01:CURRENT_MONITOR' 'SR10CPS01:CURRENT_SP ' 1 [10,1] 28 1.000 ; ...
+'10HCM2 ' 'SR10CPS05:CURRENT_MONITOR' 'SR10CPS05:CURRENT_SP ' 1 [10,2] 29 1.000 ; ...
+'10HCM3 ' 'SR10CPS09:CURRENT_MONITOR' 'SR10CPS09:CURRENT_SP ' 1 [10,3] 30 1.000 ; ...
+'11HCM1 ' 'SR11CPS01:CURRENT_MONITOR' 'SR11CPS01:CURRENT_SP ' 1 [11,1] 31 1.000 ; ...
+'11HCM2 ' 'SR11CPS05:CURRENT_MONITOR' 'SR11CPS05:CURRENT_SP ' 1 [11,2] 32 1.000 ; ...
+'11HCM3 ' 'SR11CPS09:CURRENT_MONITOR' 'SR11CPS09:CURRENT_SP ' 1 [11,3] 33 1.000 ; ...
+'12HCM1 ' 'SR12CPS01:CURRENT_MONITOR' 'SR12CPS01:CURRENT_SP ' 1 [12,1] 34 1.000 ; ...
+'12HCM2 ' 'SR12CPS05:CURRENT_MONITOR' 'SR12CPS05:CURRENT_SP ' 1 [12,2] 35 1.000 ; ...
+'12HCM3 ' 'SR12CPS09:CURRENT_MONITOR' 'SR12CPS09:CURRENT_SP ' 1 [12,3] 36 1.000 ; ...
+'13HCM1 ' 'SR13CPS01:CURRENT_MONITOR' 'SR13CPS01:CURRENT_SP ' 1 [13,1] 37 1.000 ; ...
+'13HCM2 ' 'SR13CPS05:CURRENT_MONITOR' 'SR13CPS05:CURRENT_SP ' 1 [13,2] 38 1.000 ; ...
+'13HCM3 ' 'SR13CPS09:CURRENT_MONITOR' 'SR13CPS09:CURRENT_SP ' 1 [13,3] 39 1.000 ; ...
+'14HCM1 ' 'SR14CPS01:CURRENT_MONITOR' 'SR14CPS01:CURRENT_SP ' 1 [14,1] 40 1.000 ; ...
+'14HCM2 ' 'SR14CPS05:CURRENT_MONITOR' 'SR14CPS05:CURRENT_SP ' 1 [14,2] 41 1.000 ; ...
+'14HCM3 ' 'SR14CPS09:CURRENT_MONITOR' 'SR14CPS09:CURRENT_SP ' 1 [14,3] 42 1.000 ; ...
+};
+
+[C, Leff, MagnetType] = magnetcoefficients('HCM');
+
+for ii=1:size(cor,1)
+name=cor{ii,1}; AO.HCM.CommonNames(ii,:) = name;
+name=cor{ii,2}; AO.HCM.Monitor.ChannelNames(ii,:) = name;
+name=cor{ii,3}; AO.HCM.Setpoint.ChannelNames(ii,:) = name;
+val =cor{ii,4}; AO.HCM.Status(ii,1) = val;
+val =cor{ii,5}; AO.HCM.DeviceList(ii,:) = val;
+val =cor{ii,6}; AO.HCM.ElementList(ii,1) = val;
+val =cor{ii,7}; AO.HCM.Setpoint.Tolerance(ii,1) = val;
+
+AO.HCM.Setpoint.Range(ii,:) = [+90 -90];
+AO.HCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
+AO.HCM.Monitor.Physics2HWParams{1}(ii,:) = C;
+AO.HCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
+AO.HCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
+end
+
+
+AO.VCM.FamilyName = 'VCM'; dispobject(AO,AO.VCM.FamilyName);
+AO.VCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'VCM'; 'Magnet'};
+
+AO.VCM.Monitor.Mode = Mode;
+AO.VCM.Monitor.DataType = 'Scalar';
+AO.VCM.Monitor.Units = 'Hardware';
+AO.VCM.Monitor.HWUnits = 'ampere';
+AO.VCM.Monitor.PhysicsUnits = 'radian';
+AO.VCM.Monitor.HW2PhysicsFcn = @amp2k;
+AO.VCM.Monitor.Physics2HWFcn = @k2amp;
+
+AO.VCM.Setpoint.Mode = Mode;
+AO.VCM.Setpoint.DataType = 'Scalar';
+AO.VCM.Setpoint.Units = 'Hardware';
+AO.VCM.Setpoint.HWUnits = 'ampere';
+AO.VCM.Setpoint.PhysicsUnits = 'radian';
+AO.VCM.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.VCM.Setpoint.Physics2HWFcn = @k2amp;
+
+% HW in ampere, Physics in radian ** radian units converted to ampere below ***
+% y-common y-monitor y-setpoint stat devlist elem
+cor={
+'1VCM1 ' 'SR01CPS02:CURRENT_MONITOR' 'SR01CPS02:CURRENT_SP ' 1 [1,1] 1 1.000 ; ...
+'1VCM2 ' 'SR01CPS04:CURRENT_MONITOR' 'SR01CPS04:CURRENT_SP ' 1 [1,2] 2 1.000 ; ...
+'1VCM3 ' 'SR01CPS06:CURRENT_MONITOR' 'SR01CPS06:CURRENT_SP ' 1 [1,3] 3 1.000 ; ...
+'1VCM4 ' 'SR01CPS07:CURRENT_MONITOR' 'SR01CPS07:CURRENT_SP ' 1 [1,4] 4 1.000 ; ...
+'2VCM1 ' 'SR02CPS02:CURRENT_MONITOR' 'SR02CPS02:CURRENT_SP ' 1 [2,1] 5 1.000 ; ...
+'2VCM2 ' 'SR02CPS04:CURRENT_MONITOR' 'SR02CPS04:CURRENT_SP ' 1 [2,2] 6 1.000 ; ...
+'2VCM3 ' 'SR02CPS06:CURRENT_MONITOR' 'SR02CPS06:CURRENT_SP ' 1 [2,3] 7 1.000 ; ...
+'2VCM4 ' 'SR02CPS07:CURRENT_MONITOR' 'SR02CPS07:CURRENT_SP ' 1 [2,4] 8 1.000 ; ...
+'3VCM1 ' 'SR03CPS02:CURRENT_MONITOR' 'SR03CPS02:CURRENT_SP ' 1 [3,1] 9 1.000 ; ...
+'3VCM2 ' 'SR03CPS04:CURRENT_MONITOR' 'SR03CPS04:CURRENT_SP ' 1 [3,2] 10 1.000 ; ...
+'3VCM3 ' 'SR03CPS06:CURRENT_MONITOR' 'SR03CPS06:CURRENT_SP ' 1 [3,3] 11 1.000 ; ...
+'3VCM4 ' 'SR03CPS07:CURRENT_MONITOR' 'SR03CPS07:CURRENT_SP ' 1 [3,4] 12 1.000 ; ...
+'4VCM1 ' 'SR04CPS02:CURRENT_MONITOR' 'SR04CPS02:CURRENT_SP ' 1 [4,1] 13 1.000 ; ...
+'4VCM2 ' 'SR04CPS04:CURRENT_MONITOR' 'SR04CPS04:CURRENT_SP ' 1 [4,2] 14 1.000 ; ...
+'4VCM3 ' 'SR04CPS06:CURRENT_MONITOR' 'SR04CPS06:CURRENT_SP ' 1 [4,3] 15 1.000 ; ...
+'4VCM4 ' 'SR04CPS07:CURRENT_MONITOR' 'SR04CPS07:CURRENT_SP ' 1 [4,4] 16 1.000 ; ...
+'5VCM1 ' 'SR05CPS02:CURRENT_MONITOR' 'SR05CPS02:CURRENT_SP ' 1 [5,1] 17 1.000 ; ...
+'5VCM2 ' 'SR05CPS04:CURRENT_MONITOR' 'SR05CPS04:CURRENT_SP ' 1 [5,2] 18 1.000 ; ...
+'5VCM3 ' 'SR05CPS06:CURRENT_MONITOR' 'SR05CPS06:CURRENT_SP ' 1 [5,3] 19 1.000 ; ...
+'5VCM4 ' 'SR05CPS07:CURRENT_MONITOR' 'SR05CPS07:CURRENT_SP ' 1 [5,4] 20 1.000 ; ...
+'6VCM1 ' 'SR06CPS02:CURRENT_MONITOR' 'SR06CPS02:CURRENT_SP ' 1 [6,1] 21 1.000 ; ...
+'6VCM2 ' 'SR06CPS04:CURRENT_MONITOR' 'SR06CPS04:CURRENT_SP ' 1 [6,2] 22 1.000 ; ...
+'6VCM3 ' 'SR06CPS06:CURRENT_MONITOR' 'SR06CPS06:CURRENT_SP ' 1 [6,3] 23 1.000 ; ...
+'6VCM4 ' 'SR06CPS07:CURRENT_MONITOR' 'SR06CPS07:CURRENT_SP ' 1 [6,4] 24 1.000 ; ...
+'7VCM1 ' 'SR07CPS02:CURRENT_MONITOR' 'SR07CPS02:CURRENT_SP ' 1 [7,1] 25 1.000 ; ...
+'7VCM2 ' 'SR07CPS04:CURRENT_MONITOR' 'SR07CPS04:CURRENT_SP ' 1 [7,2] 26 1.000 ; ...
+'7VCM3 ' 'SR07CPS06:CURRENT_MONITOR' 'SR07CPS06:CURRENT_SP ' 1 [7,3] 27 1.000 ; ...
+'7VCM4 ' 'SR07CPS07:CURRENT_MONITOR' 'SR07CPS07:CURRENT_SP ' 1 [7,4] 28 1.000 ; ...
+'8VCM1 ' 'SR08CPS02:CURRENT_MONITOR' 'SR08CPS02:CURRENT_SP ' 1 [8,1] 29 1.000 ; ...
+'8VCM2 ' 'SR08CPS04:CURRENT_MONITOR' 'SR08CPS04:CURRENT_SP ' 1 [8,2] 30 1.000 ; ...
+'8VCM3 ' 'SR08CPS06:CURRENT_MONITOR' 'SR08CPS06:CURRENT_SP ' 1 [8,3] 31 1.000 ; ...
+'8VCM4 ' 'SR08CPS07:CURRENT_MONITOR' 'SR08CPS07:CURRENT_SP ' 1 [8,4] 32 1.000 ; ...
+'9VCM1 ' 'SR09CPS02:CURRENT_MONITOR' 'SR09CPS02:CURRENT_SP ' 1 [9,1] 33 1.000 ; ...
+'9VCM2 ' 'SR09CPS04:CURRENT_MONITOR' 'SR09CPS04:CURRENT_SP ' 1 [9,2] 34 1.000 ; ...
+'9VCM3 ' 'SR09CPS06:CURRENT_MONITOR' 'SR09CPS06:CURRENT_SP ' 1 [9,3] 35 1.000 ; ...
+'9VCM4 ' 'SR09CPS07:CURRENT_MONITOR' 'SR09CPS07:CURRENT_SP ' 1 [9,4] 36 1.000 ; ...
+'10VCM1 ' 'SR10CPS02:CURRENT_MONITOR' 'SR10CPS02:CURRENT_SP ' 1 [10,1] 37 1.000 ; ...
+'10VCM2 ' 'SR10CPS04:CURRENT_MONITOR' 'SR10CPS04:CURRENT_SP ' 1 [10,2] 38 1.000 ; ...
+'10VCM3 ' 'SR10CPS06:CURRENT_MONITOR' 'SR10CPS06:CURRENT_SP ' 1 [10,3] 39 1.000 ; ...
+'10VCM4 ' 'SR10CPS07:CURRENT_MONITOR' 'SR10CPS07:CURRENT_SP ' 1 [10,4] 40 1.000 ; ...
+'11VCM1 ' 'SR11CPS02:CURRENT_MONITOR' 'SR11CPS02:CURRENT_SP ' 1 [11,1] 41 1.000 ; ...
+'11VCM2 ' 'SR11CPS04:CURRENT_MONITOR' 'SR11CPS04:CURRENT_SP ' 1 [11,2] 42 1.000 ; ...
+'11VCM3 ' 'SR11CPS06:CURRENT_MONITOR' 'SR11CPS06:CURRENT_SP ' 1 [11,3] 43 1.000 ; ...
+'11VCM4 ' 'SR11CPS07:CURRENT_MONITOR' 'SR11CPS07:CURRENT_SP ' 1 [11,4] 44 1.000 ; ...
+'12VCM1 ' 'SR12CPS02:CURRENT_MONITOR' 'SR12CPS02:CURRENT_SP ' 1 [12,1] 45 1.000 ; ...
+'12VCM2 ' 'SR12CPS04:CURRENT_MONITOR' 'SR12CPS04:CURRENT_SP ' 1 [12,2] 46 1.000 ; ...
+'12VCM3 ' 'SR12CPS06:CURRENT_MONITOR' 'SR12CPS06:CURRENT_SP ' 1 [12,3] 47 1.000 ; ...
+'12VCM4 ' 'SR12CPS07:CURRENT_MONITOR' 'SR12CPS07:CURRENT_SP ' 1 [12,4] 48 1.000 ; ...
+'13VCM1 ' 'SR13CPS02:CURRENT_MONITOR' 'SR13CPS02:CURRENT_SP ' 1 [13,1] 49 1.000 ; ...
+'13VCM2 ' 'SR13CPS04:CURRENT_MONITOR' 'SR13CPS04:CURRENT_SP ' 1 [13,2] 50 1.000 ; ...
+'13VCM3 ' 'SR13CPS06:CURRENT_MONITOR' 'SR13CPS06:CURRENT_SP ' 1 [13,3] 51 1.000 ; ...
+'13VCM4 ' 'SR13CPS07:CURRENT_MONITOR' 'SR13CPS07:CURRENT_SP ' 1 [13,4] 52 1.000 ; ...
+'14VCM1 ' 'SR14CPS02:CURRENT_MONITOR' 'SR14CPS02:CURRENT_SP ' 1 [14,1] 53 1.000 ; ...
+'14VCM2 ' 'SR14CPS04:CURRENT_MONITOR' 'SR14CPS04:CURRENT_SP ' 1 [14,2] 54 1.000 ; ...
+'14VCM3 ' 'SR14CPS06:CURRENT_MONITOR' 'SR14CPS06:CURRENT_SP ' 1 [14,3] 55 1.000 ; ...
+'14VCM4 ' 'SR14CPS07:CURRENT_MONITOR' 'SR14CPS07:CURRENT_SP ' 1 [14,4] 56 1.000 ; ...
+};
+
+[C, Leff, MagnetType] = magnetcoefficients('VCM');
+
+for ii=1:size(cor,1)
+name=cor{ii,1}; AO.VCM.CommonNames(ii,:) = name;
+name=cor{ii,2}; AO.VCM.Monitor.ChannelNames(ii,:) = name;
+name=cor{ii,3}; AO.VCM.Setpoint.ChannelNames(ii,:) = name;
+val =cor{ii,4}; AO.VCM.Status(ii,1) = val;
+val =cor{ii,5}; AO.VCM.DeviceList(ii,:) = val;
+val =cor{ii,6}; AO.VCM.ElementList(ii,1) = val;
+val =cor{ii,7}; AO.VCM.Setpoint.Tolerance(ii,1) = val;
+
+AO.VCM.Setpoint.Range(ii,:) = [+125 -125];
+AO.VCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
+AO.VCM.Monitor.Physics2HWParams{1}(ii,:) = C;
+AO.VCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
+AO.VCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
+end
+
+
+%=============================
+% MAIN MAGNETS
+%=============================
+
+%===========
+%Dipole data
+%===========
+
+% *** BEND ***
+AO.BEND.FamilyName = 'BEND'; dispobject(AO,AO.BEND.FamilyName);
+AO.BEND.MemberOf = {'PlotFamily'; 'MachineConfig'; 'BEND'; 'Magnet';};
+HW2PhysicsParams = magnetcoefficients('BEND');
+Physics2HWParams = magnetcoefficients('BEND');
+
+AO.BEND.Monitor.Mode = Mode;
+AO.BEND.Monitor.DataType = 'Scalar';
+AO.BEND.Monitor.Units = 'Hardware';
+AO.BEND.Monitor.HW2PhysicsFcn = @bend2gev; % @bend2gev ???
+AO.BEND.Monitor.Physics2HWFcn = @gev2bend;
+AO.BEND.Monitor.HWUnits = 'ampere';
+AO.BEND.Monitor.PhysicsUnits = 'energy';
+
+AO.BEND.Setpoint.Mode = Mode;
+AO.BEND.Setpoint.DataType = 'Scalar';
+AO.BEND.Setpoint.Units = 'Hardware';
+AO.BEND.Setpoint.HW2PhysicsFcn = @bend2gev;
+AO.BEND.Setpoint.Physics2HWFcn = @gev2bend;
+AO.BEND.Setpoint.HWUnits = 'ampere';
+AO.BEND.Setpoint.PhysicsUnits = 'energy';
+
+% common monitor setpoint stat devlist elem scale tol
+bend={
+'1BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.10 ; ...
+'1BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,2] 2 1.0 0.10 ; ...
+'2BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.10 ; ...
+'2BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,2] 4 1.0 0.10 ; ...
+'3BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.10 ; ...
+'3BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,2] 6 1.0 0.10 ; ...
+'4BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.10 ; ...
+'4BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,2] 8 1.0 0.10 ; ...
+'5BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.10 ; ...
+'5BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,2] 10 1.0 0.10 ; ...
+'6BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.10 ; ...
+'6BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,2] 12 1.0 0.10 ; ...
+'7BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.10 ; ...
+'7BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,2] 14 1.0 0.10 ; ...
+'8BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.10 ; ...
+'8BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,2] 16 1.0 0.10 ; ...
+'9BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.10 ; ...
+'9BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,2] 18 1.0 0.10 ; ...
+'10BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.10 ; ...
+'10BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,2] 20 1.0 0.10 ; ...
+'11BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.10 ; ...
+'11BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,2] 22 1.0 0.10 ; ...
+'12BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.10 ; ...
+'12BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,2] 24 1.0 0.10 ; ...
+'13BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.10 ; ...
+'13BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,2] 26 1.0 0.10 ; ...
+'14BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.10 ; ...
+'14BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,2] 28 1.0 0.10 ; ...
+};
+
+for ii=1:size(bend,1)
+name=bend{ii,1}; AO.BEND.CommonNames(ii,:) = name;
+name=bend{ii,2}; AO.BEND.Monitor.ChannelNames(ii,:) = name;
+name=bend{ii,3}; AO.BEND.Setpoint.ChannelNames(ii,:) = name;
+val =bend{ii,4}; AO.BEND.Status(ii,1) = val;
+val =bend{ii,5}; AO.BEND.DeviceList(ii,:) = val;
+val =bend{ii,6}; AO.BEND.ElementList(ii,1) = val;
+val =bend{ii,7}; % This is the scale factor
+AO.BEND.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.BEND.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.BEND.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.BEND.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.BEND.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.BEND.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.BEND.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.BEND.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =bend{ii,8}; AO.BEND.Setpoint.Tolerance(ii,1) = val;
+
+AO.BEND.Setpoint.Range(ii,:) = [50 695];
+end
+
+%===============
+%Quadrupole data
+%===============
+
+% *** QFA ***
+AO.QFA.FamilyName = 'QFA'; dispobject(AO,AO.QFA.FamilyName);
+AO.QFA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
+HW2PhysicsParams = magnetcoefficients('QFA');
+Physics2HWParams = magnetcoefficients('QFA');
+
+AO.QFA.Monitor.Mode = Mode;
+AO.QFA.Monitor.DataType = 'Scalar';
+AO.QFA.Monitor.Units = 'Hardware';
+AO.QFA.Monitor.HWUnits = 'ampere';
+AO.QFA.Monitor.PhysicsUnits = 'meter^-2';
+AO.QFA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QFA.Monitor.Physics2HWFcn = @k2amp;
+
+AO.QFA.Setpoint.Mode = Mode;
+AO.QFA.Setpoint.DataType = 'Scalar';
+AO.QFA.Setpoint.Units = 'Hardware';
+AO.QFA.Setpoint.HWUnits = 'ampere';
+AO.QFA.Setpoint.PhysicsUnits = 'meter^-2';
+AO.QFA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QFA.Setpoint.Physics2HWFcn = @k2amp;
+
+% common monitor setpoint stat devlist elem scale tol
+qfa={
+'1QFA1 ' 'SR01QPS01:CURRENT_MONITOR' 'SR01QPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
+'1QFA2 ' 'SR01QPS06:CURRENT_MONITOR' 'SR01QPS06:CURRENT_SP ' 1 [1,2] 2 1.0 0.2 ; ...
+'2QFA1 ' 'SR02QPS01:CURRENT_MONITOR' 'SR02QPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.2 ; ...
+'2QFA2 ' 'SR02QPS06:CURRENT_MONITOR' 'SR02QPS06:CURRENT_SP ' 1 [2,2] 4 1.0 0.2 ; ...
+'3QFA1 ' 'SR03QPS01:CURRENT_MONITOR' 'SR03QPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.2 ; ...
+'3QFA2 ' 'SR03QPS06:CURRENT_MONITOR' 'SR03QPS06:CURRENT_SP ' 1 [3,2] 6 1.0 0.2 ; ...
+'4QFA1 ' 'SR04QPS01:CURRENT_MONITOR' 'SR04QPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.2 ; ...
+'4QFA2 ' 'SR04QPS06:CURRENT_MONITOR' 'SR04QPS06:CURRENT_SP ' 1 [4,2] 8 1.0 0.2 ; ...
+'5QFA1 ' 'SR05QPS01:CURRENT_MONITOR' 'SR05QPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.2 ; ...
+'5QFA2 ' 'SR05QPS06:CURRENT_MONITOR' 'SR05QPS06:CURRENT_SP ' 1 [5,2] 10 1.0 0.2 ; ...
+'6QFA1 ' 'SR06QPS01:CURRENT_MONITOR' 'SR06QPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.2 ; ...
+'6QFA2 ' 'SR06QPS06:CURRENT_MONITOR' 'SR06QPS06:CURRENT_SP ' 1 [6,2] 12 1.0 0.2 ; ...
+'7QFA1 ' 'SR07QPS01:CURRENT_MONITOR' 'SR07QPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.2 ; ...
+'7QFA2 ' 'SR07QPS06:CURRENT_MONITOR' 'SR07QPS06:CURRENT_SP ' 1 [7,2] 14 1.0 0.2 ; ...
+'8QFA1 ' 'SR08QPS01:CURRENT_MONITOR' 'SR08QPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.2 ; ...
+'8QFA2 ' 'SR08QPS06:CURRENT_MONITOR' 'SR08QPS06:CURRENT_SP ' 1 [8,2] 16 1.0 0.2 ; ...
+'9QFA1 ' 'SR09QPS01:CURRENT_MONITOR' 'SR09QPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.2 ; ...
+'9QFA2 ' 'SR09QPS06:CURRENT_MONITOR' 'SR09QPS06:CURRENT_SP ' 1 [9,2] 18 1.0 0.2 ; ...
+'10QFA1 ' 'SR10QPS01:CURRENT_MONITOR' 'SR10QPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.2 ; ...
+'10QFA2 ' 'SR10QPS06:CURRENT_MONITOR' 'SR10QPS06:CURRENT_SP ' 1 [10,2] 20 1.0 0.2 ; ...
+'11QFA1 ' 'SR11QPS01:CURRENT_MONITOR' 'SR11QPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.2 ; ...
+'11QFA2 ' 'SR11QPS06:CURRENT_MONITOR' 'SR11QPS06:CURRENT_SP ' 1 [11,2] 22 1.0 0.2 ; ...
+'12QFA1 ' 'SR12QPS01:CURRENT_MONITOR' 'SR12QPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.2 ; ...
+'12QFA2 ' 'SR12QPS06:CURRENT_MONITOR' 'SR12QPS06:CURRENT_SP ' 1 [12,2] 24 1.0 0.2 ; ...
+'13QFA1 ' 'SR13QPS01:CURRENT_MONITOR' 'SR13QPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.2 ; ...
+'13QFA2 ' 'SR13QPS06:CURRENT_MONITOR' 'SR13QPS06:CURRENT_SP ' 1 [13,2] 26 1.0 0.2 ; ...
+'14QFA1 ' 'SR14QPS01:CURRENT_MONITOR' 'SR14QPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.2 ; ...
+'14QFA2 ' 'SR14QPS06:CURRENT_MONITOR' 'SR14QPS06:CURRENT_SP ' 1 [14,2] 28 1.0 0.2 ; ...
+};
+
+for ii=1:size(qfa,1)
+name=qfa{ii,1}; AO.QFA.CommonNames(ii,:) = name;
+name=qfa{ii,2}; AO.QFA.Monitor.ChannelNames(ii,:) = name;
+name=qfa{ii,3}; AO.QFA.Setpoint.ChannelNames(ii,:) = name;
+val =qfa{ii,4}; AO.QFA.Status(ii,1) = val;
+val =qfa{ii,5}; AO.QFA.DeviceList(ii,:) = val;
+val =qfa{ii,6}; AO.QFA.ElementList(ii,1) = val;
+val =qfa{ii,7}; % This is the scale factor
+AO.QFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qfa{ii,8}; AO.QFA.Setpoint.Tolerance(ii,1) = val;
+
+AO.QFA.Setpoint.Range(ii,:) = [0 160];
+end
+
+
+% *** QDA ***
+AO.QDA.FamilyName = 'QDA'; dispobject(AO,AO.QDA.FamilyName);
+AO.QDA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QD';};
+HW2PhysicsParams = magnetcoefficients('QDA');
+Physics2HWParams = magnetcoefficients('QDA');
+
+AO.QDA.Monitor.Mode = Mode;
+AO.QDA.Monitor.DataType = 'Scalar';
+AO.QDA.Monitor.Units = 'Hardware';
+AO.QDA.Monitor.HWUnits = 'ampere';
+AO.QDA.Monitor.PhysicsUnits = 'meter^-2';
+AO.QDA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QDA.Monitor.Physics2HWFcn = @k2amp;
+
+AO.QDA.Setpoint.Mode = Mode;
+AO.QDA.Setpoint.DataType = 'Scalar';
+AO.QDA.Setpoint.Units = 'Hardware';
+AO.QDA.Setpoint.HWUnits = 'ampere';
+AO.QDA.Setpoint.PhysicsUnits = 'meter^-2';
+AO.QDA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QDA.Setpoint.Physics2HWFcn = @k2amp;
+
+% common monitor setpoint stat devlist elem scale tol
+qda={
+'1QDA1 ' 'SR01QPS02:CURRENT_MONITOR' 'SR01QPS02:CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
+'1QDA2 ' 'SR01QPS05:CURRENT_MONITOR' 'SR01QPS05:CURRENT_SP ' 1 [1,2] 2 1.0 0.2 ; ...
+'2QDA1 ' 'SR02QPS02:CURRENT_MONITOR' 'SR02QPS02:CURRENT_SP ' 1 [2,1] 3 1.0 0.2 ; ...
+'2QDA2 ' 'SR02QPS05:CURRENT_MONITOR' 'SR02QPS05:CURRENT_SP ' 1 [2,2] 4 1.0 0.2 ; ...
+'3QDA1 ' 'SR03QPS02:CURRENT_MONITOR' 'SR03QPS02:CURRENT_SP ' 1 [3,1] 5 1.0 0.2 ; ...
+'3QDA2 ' 'SR03QPS05:CURRENT_MONITOR' 'SR03QPS05:CURRENT_SP ' 1 [3,2] 6 1.0 0.2 ; ...
+'4QDA1 ' 'SR04QPS02:CURRENT_MONITOR' 'SR04QPS02:CURRENT_SP ' 1 [4,1] 7 1.0 0.2 ; ...
+'4QDA2 ' 'SR04QPS05:CURRENT_MONITOR' 'SR04QPS05:CURRENT_SP ' 1 [4,2] 8 1.0 0.2 ; ...
+'5QDA1 ' 'SR05QPS02:CURRENT_MONITOR' 'SR05QPS02:CURRENT_SP ' 1 [5,1] 9 1.0 0.2 ; ...
+'5QDA2 ' 'SR05QPS05:CURRENT_MONITOR' 'SR05QPS05:CURRENT_SP ' 1 [5,2] 10 1.0 0.2 ; ...
+'6QDA1 ' 'SR06QPS02:CURRENT_MONITOR' 'SR06QPS02:CURRENT_SP ' 1 [6,1] 11 1.0 0.2 ; ...
+'6QDA2 ' 'SR06QPS05:CURRENT_MONITOR' 'SR06QPS05:CURRENT_SP ' 1 [6,2] 12 1.0 0.2 ; ...
+'7QDA1 ' 'SR07QPS02:CURRENT_MONITOR' 'SR07QPS02:CURRENT_SP ' 1 [7,1] 13 1.0 0.2 ; ...
+'7QDA2 ' 'SR07QPS05:CURRENT_MONITOR' 'SR07QPS05:CURRENT_SP ' 1 [7,2] 14 1.0 0.2 ; ...
+'8QDA1 ' 'SR08QPS02:CURRENT_MONITOR' 'SR08QPS02:CURRENT_SP ' 1 [8,1] 15 1.0 0.2 ; ...
+'8QDA2 ' 'SR08QPS05:CURRENT_MONITOR' 'SR08QPS05:CURRENT_SP ' 1 [8,2] 16 1.0 0.2 ; ...
+'9QDA1 ' 'SR09QPS02:CURRENT_MONITOR' 'SR09QPS02:CURRENT_SP ' 1 [9,1] 17 1.0 0.2 ; ...
+'9QDA2 ' 'SR09QPS05:CURRENT_MONITOR' 'SR09QPS05:CURRENT_SP ' 1 [9,2] 18 1.0 0.2 ; ...
+'10QDA1 ' 'SR10QPS02:CURRENT_MONITOR' 'SR10QPS02:CURRENT_SP ' 1 [10,1] 19 1.0 0.2 ; ...
+'10QDA2 ' 'SR10QPS05:CURRENT_MONITOR' 'SR10QPS05:CURRENT_SP ' 1 [10,2] 20 1.0 0.2 ; ...
+'11QDA1 ' 'SR11QPS02:CURRENT_MONITOR' 'SR11QPS02:CURRENT_SP ' 1 [11,1] 21 1.0 0.2 ; ...
+'11QDA2 ' 'SR11QPS05:CURRENT_MONITOR' 'SR11QPS05:CURRENT_SP ' 1 [11,2] 22 1.0 0.2 ; ...
+'12QDA1 ' 'SR12QPS02:CURRENT_MONITOR' 'SR12QPS02:CURRENT_SP ' 1 [12,1] 23 1.0 0.2 ; ...
+'12QDA2 ' 'SR12QPS05:CURRENT_MONITOR' 'SR12QPS05:CURRENT_SP ' 1 [12,2] 24 1.0 0.2 ; ...
+'13QDA1 ' 'SR13QPS02:CURRENT_MONITOR' 'SR13QPS02:CURRENT_SP ' 1 [13,1] 25 1.0 0.2 ; ...
+'13QDA2 ' 'SR13QPS05:CURRENT_MONITOR' 'SR13QPS05:CURRENT_SP ' 1 [13,2] 26 1.0 0.2 ; ...
+'14QDA1 ' 'SR14QPS02:CURRENT_MONITOR' 'SR14QPS02:CURRENT_SP ' 1 [14,1] 27 1.0 0.2 ; ...
+'14QDA2 ' 'SR14QPS05:CURRENT_MONITOR' 'SR14QPS05:CURRENT_SP ' 1 [14,2] 28 1.0 0.2 ; ...
+};
+
+for ii=1:size(qda,1)
+name=qda{ii,1}; AO.QDA.CommonNames(ii,:) = name;
+name=qda{ii,2}; AO.QDA.Monitor.ChannelNames(ii,:) = name;
+name=qda{ii,3}; AO.QDA.Setpoint.ChannelNames(ii,:) = name;
+val =qda{ii,4}; AO.QDA.Status(ii,1) = val;
+val =qda{ii,5}; AO.QDA.DeviceList(ii,:) = val;
+val =qda{ii,6}; AO.QDA.ElementList(ii,1) = val;
+val =qda{ii,7}; % This is the scale factor
+AO.QDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.QDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.QDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QDA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qda{ii,8}; AO.QDA.Setpoint.Tolerance(ii,1) = val;
+
+AO.QDA.Setpoint.Range(ii,:) = [0 90];
+end
+
+
+
+% *** QFB ***
+AO.QFB.FamilyName = 'QFB'; dispobject(AO,AO.QFB.FamilyName);
+AO.QFB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
+HW2PhysicsParams = magnetcoefficients('QFB');
+Physics2HWParams = magnetcoefficients('QFB');
+
+AO.QFB.Monitor.Mode = Mode;
+AO.QFB.Monitor.DataType = 'Scalar';
+AO.QFB.Monitor.Units = 'Hardware';
+AO.QFB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QFB.Monitor.Physics2HWFcn = @k2amp;
+AO.QFB.Monitor.HWUnits = 'ampere';
+AO.QFB.Monitor.PhysicsUnits = 'meter^-2';
+
+AO.QFB.Setpoint.Mode = Mode;
+AO.QFB.Setpoint.DataType = 'Scalar';
+AO.QFB.Setpoint.Units = 'Hardware';
+AO.QFB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QFB.Setpoint.Physics2HWFcn = @k2amp;
+AO.QFB.Setpoint.HWUnits = 'ampere';
+AO.QFB.Setpoint.PhysicsUnits = 'meter^-2';
+
+% common monitor setpoint stat devlist elem scale tol
+qfb={
+'1QFB1 ' 'SR01QPS03:CURRENT_MONITOR' 'SR01QPS03:CURRENT_SP ' 1 [1,1] 1 1.0 0.2 ; ...
+'1QFB2 ' 'SR01QPS04:CURRENT_MONITOR' 'SR01QPS04:CURRENT_SP ' 1 [1,2] 2 1.0 0.2 ; ...
+'2QFB1 ' 'SR02QPS03:CURRENT_MONITOR' 'SR02QPS03:CURRENT_SP ' 1 [2,1] 3 1.0 0.2 ; ...
+'2QFB2 ' 'SR02QPS04:CURRENT_MONITOR' 'SR02QPS04:CURRENT_SP ' 1 [2,2] 4 1.0 0.2 ; ...
+'3QFB1 ' 'SR03QPS03:CURRENT_MONITOR' 'SR03QPS03:CURRENT_SP ' 1 [3,1] 5 1.0 0.2 ; ...
+'3QFB2 ' 'SR03QPS04:CURRENT_MONITOR' 'SR03QPS04:CURRENT_SP ' 1 [3,2] 6 1.0 0.2 ; ...
+'4QFB1 ' 'SR04QPS03:CURRENT_MONITOR' 'SR04QPS03:CURRENT_SP ' 1 [4,1] 7 1.0 0.2 ; ...
+'4QFB2 ' 'SR04QPS04:CURRENT_MONITOR' 'SR04QPS04:CURRENT_SP ' 1 [4,2] 8 1.0 0.2 ; ...
+'5QFB1 ' 'SR05QPS03:CURRENT_MONITOR' 'SR05QPS03:CURRENT_SP ' 1 [5,1] 9 1.0 0.2 ; ...
+'5QFB2 ' 'SR05QPS04:CURRENT_MONITOR' 'SR05QPS04:CURRENT_SP ' 1 [5,2] 10 1.0 0.2 ; ...
+'6QFB1 ' 'SR06QPS03:CURRENT_MONITOR' 'SR06QPS03:CURRENT_SP ' 1 [6,1] 11 1.0 0.2 ; ...
+'6QFB2 ' 'SR06QPS04:CURRENT_MONITOR' 'SR06QPS04:CURRENT_SP ' 1 [6,2] 12 1.0 0.2 ; ...
+'7QFB1 ' 'SR07QPS03:CURRENT_MONITOR' 'SR07QPS03:CURRENT_SP ' 1 [7,1] 13 1.0 0.2 ; ...
+'7QFB2 ' 'SR07QPS04:CURRENT_MONITOR' 'SR07QPS04:CURRENT_SP ' 1 [7,2] 14 1.0 0.2 ; ...
+'8QFB1 ' 'SR08QPS03:CURRENT_MONITOR' 'SR08QPS03:CURRENT_SP ' 1 [8,1] 15 1.0 0.2 ; ...
+'8QFB2 ' 'SR08QPS04:CURRENT_MONITOR' 'SR08QPS04:CURRENT_SP ' 1 [8,2] 16 1.0 0.2 ; ...
+'9QFB1 ' 'SR09QPS03:CURRENT_MONITOR' 'SR09QPS03:CURRENT_SP ' 1 [9,1] 17 1.0 0.2 ; ...
+'9QFB2 ' 'SR09QPS04:CURRENT_MONITOR' 'SR09QPS04:CURRENT_SP ' 1 [9,2] 18 1.0 0.2 ; ...
+'10QFB1 ' 'SR10QPS03:CURRENT_MONITOR' 'SR10QPS03:CURRENT_SP ' 1 [10,1] 19 1.0 0.2 ; ...
+'10QFB2 ' 'SR10QPS04:CURRENT_MONITOR' 'SR10QPS04:CURRENT_SP ' 1 [10,2] 20 1.0 0.2 ; ...
+'11QFB1 ' 'SR11QPS03:CURRENT_MONITOR' 'SR11QPS03:CURRENT_SP ' 1 [11,1] 21 1.0 0.2 ; ...
+'11QFB2 ' 'SR11QPS04:CURRENT_MONITOR' 'SR11QPS04:CURRENT_SP ' 1 [11,2] 22 1.0 0.2 ; ...
+'12QFB1 ' 'SR12QPS03:CURRENT_MONITOR' 'SR12QPS03:CURRENT_SP ' 1 [12,1] 23 1.0 0.2 ; ...
+'12QFB2 ' 'SR12QPS04:CURRENT_MONITOR' 'SR12QPS04:CURRENT_SP ' 1 [12,2] 24 1.0 0.2 ; ...
+'13QFB1 ' 'SR13QPS03:CURRENT_MONITOR' 'SR13QPS03:CURRENT_SP ' 1 [13,1] 25 1.0 0.2 ; ...
+'13QFB2 ' 'SR13QPS04:CURRENT_MONITOR' 'SR13QPS04:CURRENT_SP ' 1 [13,2] 26 1.0 0.2 ; ...
+'14QFB1 ' 'SR14QPS03:CURRENT_MONITOR' 'SR14QPS03:CURRENT_SP ' 1 [14,1] 27 1.0 0.2 ; ...
+'14QFB2 ' 'SR14QPS04:CURRENT_MONITOR' 'SR14QPS04:CURRENT_SP ' 1 [14,2] 28 1.0 0.2 ; ...
+};
+
+for ii=1:size(qfb,1)
+name=qfb{ii,1}; AO.QFB.CommonNames(ii,:) = name;
+name=qfb{ii,2}; AO.QFB.Monitor.ChannelNames(ii,:) = name;
+name=qfb{ii,3}; AO.QFB.Setpoint.ChannelNames(ii,:) = name;
+val =qfb{ii,4}; AO.QFB.Status(ii,1) = val;
+val =qfb{ii,5}; AO.QFB.DeviceList(ii,:) = val;
+val =qfb{ii,6}; AO.QFB.ElementList(ii,1) = val;
+val =qfb{ii,7}; % This is the scale factor
+AO.QFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qfb{ii,8}; AO.QFB.Setpoint.Tolerance(ii,1) = val;
+
+AO.QFB.Setpoint.Range(ii,:) = [0 160];
+end
+
+
+%===============
+%Sextupole data
+%===============
+% *** SFA ***
+AO.SFA.FamilyName = 'SFA'; dispobject(AO,AO.SFA.FamilyName);
+AO.SFA.MemberOf = {'PlotFamily'; 'SF'; 'SEXT'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SFA');
+Physics2HWParams = magnetcoefficients('SFA');
+
+AO.SFA.Monitor.Mode = Mode;
+AO.SFA.Monitor.DataType = 'Scalar';
+AO.SFA.Monitor.Units = 'Hardware';
+AO.SFA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SFA.Monitor.Physics2HWFcn = @k2amp;
+AO.SFA.Monitor.HWUnits = 'ampere';
+AO.SFA.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SFA.Setpoint.Mode = Mode;
+AO.SFA.Setpoint.DataType = 'Scalar';
+AO.SFA.Setpoint.Units = 'Hardware';
+AO.SFA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SFA.Setpoint.Physics2HWFcn = @k2amp;
+AO.SFA.Setpoint.HWUnits = 'ampere';
+AO.SFA.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sfa={
+'1SFA1 ' 'SR01SPS01:CURRENT_MONITOR' 'SR01SPS01:CURRENT_SP ' 0 [1,1] 1 1.0 0.05 ; ...
+'1SFA2 ' 'SR01SPS07:CURRENT_MONITOR' 'SR01SPS07:CURRENT_SP ' 0 [1,2] 2 1.0 0.05 ; ...
+'2SFA1 ' 'SR02SPS01:CURRENT_MONITOR' 'SR02SPS01:CURRENT_SP ' 0 [2,1] 3 1.0 0.05 ; ...
+'2SFA2 ' 'SR02SPS07:CURRENT_MONITOR' 'SR02SPS07:CURRENT_SP ' 0 [2,2] 4 1.0 0.05 ; ...
+'3SFA1 ' 'SR03SPS01:CURRENT_MONITOR' 'SR03SPS01:CURRENT_SP ' 0 [3,1] 5 1.0 0.05 ; ...
+'3SFA2 ' 'SR03SPS07:CURRENT_MONITOR' 'SR03SPS07:CURRENT_SP ' 0 [3,2] 6 1.0 0.05 ; ...
+'4SFA1 ' 'SR04SPS01:CURRENT_MONITOR' 'SR04SPS01:CURRENT_SP ' 0 [4,1] 7 1.0 0.05 ; ...
+'4SFA2 ' 'SR04SPS07:CURRENT_MONITOR' 'SR04SPS07:CURRENT_SP ' 0 [4,2] 8 1.0 0.05 ; ...
+'5SFA1 ' 'SR05SPS01:CURRENT_MONITOR' 'SR05SPS01:CURRENT_SP ' 0 [5,1] 9 1.0 0.05 ; ...
+'5SFA2 ' 'SR05SPS07:CURRENT_MONITOR' 'SR05SPS07:CURRENT_SP ' 0 [5,2] 10 1.0 0.05 ; ...
+'6SFA1 ' 'SR06SPS01:CURRENT_MONITOR' 'SR06SPS01:CURRENT_SP ' 0 [6,1] 11 1.0 0.05 ; ...
+'6SFA2 ' 'SR06SPS07:CURRENT_MONITOR' 'SR06SPS07:CURRENT_SP ' 0 [6,2] 12 1.0 0.05 ; ...
+'7SFA1 ' 'SR07SPS01:CURRENT_MONITOR' 'SR07SPS01:CURRENT_SP ' 0 [7,1] 13 1.0 0.05 ; ...
+'7SFA2 ' 'SR07SPS07:CURRENT_MONITOR' 'SR07SPS07:CURRENT_SP ' 1 [7,2] 14 1.0 0.05 ; ...
+'8SFA1 ' 'SR08SPS01:CURRENT_MONITOR' 'SR08SPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.05 ; ...
+'8SFA2 ' 'SR08SPS07:CURRENT_MONITOR' 'SR08SPS07:CURRENT_SP ' 1 [8,2] 16 1.0 0.05 ; ...
+'9SFA1 ' 'SR09SPS01:CURRENT_MONITOR' 'SR09SPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.05 ; ...
+'9SFA2 ' 'SR09SPS07:CURRENT_MONITOR' 'SR09SPS07:CURRENT_SP ' 1 [9,2] 18 1.0 0.05 ; ...
+'10SFA1 ' 'SR10SPS01:CURRENT_MONITOR' 'SR10SPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.05 ; ...
+'10SFA2 ' 'SR10SPS07:CURRENT_MONITOR' 'SR10SPS07:CURRENT_SP ' 1 [10,2] 20 1.0 0.05 ; ...
+'11SFA1 ' 'SR11SPS01:CURRENT_MONITOR' 'SR11SPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.05 ; ...
+'11SFA2 ' 'SR11SPS07:CURRENT_MONITOR' 'SR11SPS07:CURRENT_SP ' 1 [11,2] 22 1.0 0.05 ; ...
+'12SFA1 ' 'SR12SPS01:CURRENT_MONITOR' 'SR12SPS01:CURRENT_SP ' 0 [12,1] 23 1.0 0.05 ; ...
+'12SFA2 ' 'SR12SPS07:CURRENT_MONITOR' 'SR12SPS07:CURRENT_SP ' 1 [12,2] 24 1.0 0.05 ; ...
+'13SFA1 ' 'SR13SPS01:CURRENT_MONITOR' 'SR13SPS01:CURRENT_SP ' 0 [13,1] 25 1.0 0.05 ; ...
+'13SFA2 ' 'SR13SPS07:CURRENT_MONITOR' 'SR13SPS07:CURRENT_SP ' 0 [13,2] 26 1.0 0.05 ; ...
+'14SFA1 ' 'SR14SPS01:CURRENT_MONITOR' 'SR14SPS01:CURRENT_SP ' 0 [14,1] 27 1.0 0.05 ; ...
+'14SFA2 ' 'SR14SPS07:CURRENT_MONITOR' 'SR14SPS07:CURRENT_SP ' 0 [14,2] 28 1.0 0.05 ; ...
+};
+
+for ii=1:size(sfa,1)
+name=sfa{ii,1}; AO.SFA.CommonNames(ii,:) = name;
+name=sfa{ii,2}; AO.SFA.Monitor.ChannelNames(ii,:) = name;
+name=sfa{ii,3}; AO.SFA.Setpoint.ChannelNames(ii,:) = name;
+val =sfa{ii,4}; AO.SFA.Status(ii,1) = val;
+val =sfa{ii,5}; AO.SFA.DeviceList(ii,:) = val;
+val =sfa{ii,6}; AO.SFA.ElementList(ii,1) = val;
+val =sfa{ii,7}; % This is the scale factor
+AO.SFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sfa{ii,8}; AO.SFA.Setpoint.Tolerance(ii,1) = val;
+
+AO.SFA.Setpoint.Range(ii,:) = [0 140];
+end
+
+
+
+% *** SDA ***
+AO.SDA.FamilyName = 'SDA'; dispobject(AO,AO.SDA.FamilyName);
+AO.SDA.MemberOf = {'PlotFamily'; 'SD'; 'SEXT'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SDA');
+Physics2HWParams = magnetcoefficients('SDA');
+
+AO.SDA.Monitor.Mode = Mode;
+AO.SDA.Monitor.DataType = 'Scalar';
+AO.SDA.Monitor.Units = 'Hardware';
+AO.SDA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SDA.Monitor.Physics2HWFcn = @k2amp;
+AO.SDA.Monitor.HWUnits = 'ampere';
+AO.SDA.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SDA.Setpoint.Mode = Mode;
+AO.SDA.Setpoint.DataType = 'Scalar';
+AO.SDA.Setpoint.Units = 'Hardware';
+AO.SDA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SDA.Setpoint.Physics2HWFcn = @k2amp;
+AO.SDA.Setpoint.HWUnits = 'ampere';
+AO.SDA.Setpoint.PhysicsUnits = 'meter^-3';
+
+
+% common monitor setpoint stat devlist elem scale tol
+sda={
+'1SDA1 ' 'SR01SPS02:CURRENT_MONITOR' 'SR01SPS02:CURRENT_SP ' 0 [1,1] 1 1.0 0.05 ; ...
+'1SDA2 ' 'SR01SPS06:CURRENT_MONITOR' 'SR01SPS06:CURRENT_SP ' 0 [1,2] 2 1.0 0.05 ; ...
+'2SDA1 ' 'SR02SPS02:CURRENT_MONITOR' 'SR02SPS02:CURRENT_SP ' 0 [2,1] 3 1.0 0.05 ; ...
+'2SDA2 ' 'SR02SPS06:CURRENT_MONITOR' 'SR02SPS06:CURRENT_SP ' 0 [2,2] 4 1.0 0.05 ; ...
+'3SDA1 ' 'SR03SPS02:CURRENT_MONITOR' 'SR03SPS02:CURRENT_SP ' 0 [3,1] 5 1.0 0.05 ; ...
+'3SDA2 ' 'SR03SPS06:CURRENT_MONITOR' 'SR03SPS06:CURRENT_SP ' 0 [3,2] 6 1.0 0.05 ; ...
+'4SDA1 ' 'SR04SPS02:CURRENT_MONITOR' 'SR04SPS02:CURRENT_SP ' 0 [4,1] 7 1.0 0.05 ; ...
+'4SDA2 ' 'SR04SPS06:CURRENT_MONITOR' 'SR04SPS06:CURRENT_SP ' 0 [4,2] 8 1.0 0.05 ; ...
+'5SDA1 ' 'SR05SPS02:CURRENT_MONITOR' 'SR05SPS02:CURRENT_SP ' 0 [5,1] 9 1.0 0.05 ; ...
+'5SDA2 ' 'SR05SPS06:CURRENT_MONITOR' 'SR05SPS06:CURRENT_SP ' 0 [5,2] 10 1.0 0.05 ; ...
+'6SDA1 ' 'SR06SPS02:CURRENT_MONITOR' 'SR06SPS02:CURRENT_SP ' 0 [6,1] 11 1.0 0.05 ; ...
+'6SDA2 ' 'SR06SPS06:CURRENT_MONITOR' 'SR06SPS06:CURRENT_SP ' 0 [6,2] 12 1.0 0.05 ; ...
+'7SDA1 ' 'SR07SPS02:CURRENT_MONITOR' 'SR07SPS02:CURRENT_SP ' 0 [7,1] 13 1.0 0.05 ; ...
+'7SDA2 ' 'SR07SPS06:CURRENT_MONITOR' 'SR07SPS06:CURRENT_SP ' 1 [7,2] 14 1.0 0.05 ; ...
+'8SDA1 ' 'SR08SPS02:CURRENT_MONITOR' 'SR08SPS02:CURRENT_SP ' 1 [8,1] 15 1.0 0.05 ; ...
+'8SDA2 ' 'SR08SPS06:CURRENT_MONITOR' 'SR08SPS06:CURRENT_SP ' 1 [8,2] 16 1.0 0.05 ; ...
+'9SDA1 ' 'SR09SPS02:CURRENT_MONITOR' 'SR09SPS02:CURRENT_SP ' 1 [9,1] 17 1.0 0.05 ; ...
+'9SDA2 ' 'SR09SPS06:CURRENT_MONITOR' 'SR09SPS06:CURRENT_SP ' 1 [9,2] 18 1.0 0.05 ; ...
+'10SDA1 ' 'SR10SPS02:CURRENT_MONITOR' 'SR10SPS02:CURRENT_SP ' 1 [10,1] 19 1.0 0.05 ; ...
+'10SDA2 ' 'SR10SPS06:CURRENT_MONITOR' 'SR10SPS06:CURRENT_SP ' 1 [10,2] 20 1.0 0.05 ; ...
+'11SDA1 ' 'SR11SPS02:CURRENT_MONITOR' 'SR11SPS02:CURRENT_SP ' 1 [11,1] 21 1.0 0.05 ; ...
+'11SDA2 ' 'SR11SPS06:CURRENT_MONITOR' 'SR11SPS06:CURRENT_SP ' 1 [11,2] 22 1.0 0.05 ; ...
+'12SDA1 ' 'SR12SPS02:CURRENT_MONITOR' 'SR12SPS02:CURRENT_SP ' 1 [12,1] 23 1.0 0.05 ; ...
+'12SDA2 ' 'SR12SPS06:CURRENT_MONITOR' 'SR12SPS06:CURRENT_SP ' 1 [12,2] 24 1.0 0.05 ; ...
+'13SDA1 ' 'SR13SPS02:CURRENT_MONITOR' 'SR13SPS02:CURRENT_SP ' 0 [13,1] 25 1.0 0.05 ; ...
+'13SDA2 ' 'SR13SPS06:CURRENT_MONITOR' 'SR13SPS06:CURRENT_SP ' 0 [13,2] 26 1.0 0.05 ; ...
+'14SDA1 ' 'SR14SPS02:CURRENT_MONITOR' 'SR14SPS02:CURRENT_SP ' 0 [14,1] 27 1.0 0.05 ; ...
+'14SDA2 ' 'SR14SPS06:CURRENT_MONITOR' 'SR14SPS06:CURRENT_SP ' 0 [14,2] 28 1.0 0.05 ; ...
+};
+
+for ii=1:size(sda,1)
+name=sda{ii,1}; AO.SDA.CommonNames(ii,:) = name;
+name=sda{ii,2}; AO.SDA.Monitor.ChannelNames(ii,:) = name;
+name=sda{ii,3}; AO.SDA.Setpoint.ChannelNames(ii,:) = name;
+val =sda{ii,4}; AO.SDA.Status(ii,1) = val;
+val =sda{ii,5}; AO.SDA.DeviceList(ii,:) = val;
+val =sda{ii,6}; AO.SDA.ElementList(ii,1) = val;
+val =sda{ii,7}; % This is the scale factor
+AO.SDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sda{ii,8}; AO.SDA.Setpoint.Tolerance(ii,1) = val;
+
+AO.SDA.Setpoint.Range(ii,:) = [0 140];
+end
+
+
+% *** SDB ***
+AO.SDB.FamilyName = 'SDB'; dispobject(AO,AO.SDB.FamilyName);
+AO.SDB.MemberOf = {'PlotFamily'; 'SD'; 'SEXT'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SDB');
+Physics2HWParams = magnetcoefficients('SDB');
+
+AO.SDB.Monitor.Mode = Mode;
+AO.SDB.Monitor.DataType = 'Scalar';
+AO.SDB.Monitor.Units = 'Hardware';
+AO.SDB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SDB.Monitor.Physics2HWFcn = @k2amp;
+AO.SDB.Monitor.HWUnits = 'ampere';
+AO.SDB.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SDB.Setpoint.Mode = Mode;
+AO.SDB.Setpoint.DataType = 'Scalar';
+AO.SDB.Setpoint.Units = 'Hardware';
+AO.SDB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SDB.Setpoint.Physics2HWFcn = @k2amp;
+AO.SDB.Setpoint.HWUnits = 'ampere';
+AO.SDB.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sdb={
+'1SDB1 ' 'SR01SPS03:CURRENT_MONITOR' 'SR01SPS03:CURRENT_SP ' 1 [1,1] 1 1.0 0.05 ; ...
+'1SDB2 ' 'SR01SPS05:CURRENT_MONITOR' 'SR01SPS05:CURRENT_SP ' 1 [1,2] 2 1.0 0.05 ; ...
+'2SDB1 ' 'SR02SPS03:CURRENT_MONITOR' 'SR02SPS03:CURRENT_SP ' 1 [2,1] 3 1.0 0.05 ; ...
+'2SDB2 ' 'SR02SPS05:CURRENT_MONITOR' 'SR02SPS05:CURRENT_SP ' 1 [2,2] 4 1.0 0.05 ; ...
+'3SDB1 ' 'SR03SPS03:CURRENT_MONITOR' 'SR03SPS03:CURRENT_SP ' 1 [3,1] 5 1.0 0.05 ; ...
+'3SDB2 ' 'SR03SPS05:CURRENT_MONITOR' 'SR03SPS05:CURRENT_SP ' 1 [3,2] 6 1.0 0.05 ; ...
+'4SDB1 ' 'SR04SPS03:CURRENT_MONITOR' 'SR04SPS03:CURRENT_SP ' 1 [4,1] 7 1.0 0.05 ; ...
+'4SDB2 ' 'SR04SPS05:CURRENT_MONITOR' 'SR04SPS05:CURRENT_SP ' 1 [4,2] 8 1.0 0.05 ; ...
+'5SDB1 ' 'SR05SPS03:CURRENT_MONITOR' 'SR05SPS03:CURRENT_SP ' 1 [5,1] 9 1.0 0.05 ; ...
+'5SDB2 ' 'SR05SPS05:CURRENT_MONITOR' 'SR05SPS05:CURRENT_SP ' 1 [5,2] 10 1.0 0.05 ; ...
+'6SDB1 ' 'SR06SPS03:CURRENT_MONITOR' 'SR06SPS03:CURRENT_SP ' 1 [6,1] 11 1.0 0.05 ; ...
+'6SDB2 ' 'SR06SPS05:CURRENT_MONITOR' 'SR06SPS05:CURRENT_SP ' 1 [6,2] 12 1.0 0.05 ; ...
+'7SDB1 ' 'SR07SPS03:CURRENT_MONITOR' 'SR07SPS03:CURRENT_SP ' 1 [7,1] 13 1.0 0.05 ; ...
+'7SDB2 ' 'SR07SPS05:CURRENT_MONITOR' 'SR07SPS05:CURRENT_SP ' 1 [7,2] 14 1.0 0.05 ; ...
+'8SDB1 ' 'SR08SPS03:CURRENT_MONITOR' 'SR08SPS03:CURRENT_SP ' 1 [8,1] 15 1.0 0.05 ; ...
+'8SDB2 ' 'SR08SPS05:CURRENT_MONITOR' 'SR08SPS05:CURRENT_SP ' 1 [8,2] 16 1.0 0.05 ; ...
+'9SDB1 ' 'SR09SPS03:CURRENT_MONITOR' 'SR09SPS03:CURRENT_SP ' 1 [9,1] 17 1.0 0.05 ; ...
+'9SDB2 ' 'SR09SPS05:CURRENT_MONITOR' 'SR09SPS05:CURRENT_SP ' 1 [9,2] 18 1.0 0.05 ; ...
+'10SDB1 ' 'SR10SPS03:CURRENT_MONITOR' 'SR10SPS03:CURRENT_SP ' 1 [10,1] 19 1.0 0.05 ; ...
+'10SDB2 ' 'SR10SPS05:CURRENT_MONITOR' 'SR10SPS05:CURRENT_SP ' 1 [10,2] 20 1.0 0.05 ; ...
+'11SDB1 ' 'SR11SPS03:CURRENT_MONITOR' 'SR11SPS03:CURRENT_SP ' 1 [11,1] 21 1.0 0.05 ; ...
+'11SDB2 ' 'SR11SPS05:CURRENT_MONITOR' 'SR11SPS05:CURRENT_SP ' 1 [11,2] 22 1.0 0.05 ; ...
+'12SDB1 ' 'SR12SPS03:CURRENT_MONITOR' 'SR12SPS03:CURRENT_SP ' 1 [12,1] 23 1.0 0.05 ; ...
+'12SDB2 ' 'SR12SPS05:CURRENT_MONITOR' 'SR12SPS05:CURRENT_SP ' 1 [12,2] 24 1.0 0.05 ; ...
+'13SDB1 ' 'SR13SPS03:CURRENT_MONITOR' 'SR13SPS03:CURRENT_SP ' 1 [13,1] 25 1.0 0.05 ; ...
+'13SDB2 ' 'SR13SPS05:CURRENT_MONITOR' 'SR13SPS05:CURRENT_SP ' 1 [13,2] 26 1.0 0.05 ; ...
+'14SDB1 ' 'SR14SPS03:CURRENT_MONITOR' 'SR14SPS03:CURRENT_SP ' 1 [14,1] 27 1.0 0.05 ; ...
+'14SDB2 ' 'SR14SPS05:CURRENT_MONITOR' 'SR14SPS05:CURRENT_SP ' 1 [14,2] 28 1.0 0.05 ; ...
+};
+
+for ii=1:size(sdb,1)
+name=sdb{ii,1}; AO.SDB.CommonNames(ii,:) = name;
+name=sdb{ii,2}; AO.SDB.Monitor.ChannelNames(ii,:) = name;
+name=sdb{ii,3}; AO.SDB.Setpoint.ChannelNames(ii,:)= name;
+val =sdb{ii,4}; AO.SDB.Status(ii,1) = val;
+val =sdb{ii,5}; AO.SDB.DeviceList(ii,:) = val;
+val =sdb{ii,6}; AO.SDB.ElementList(ii,1) = val;
+val =sdb{ii,7}; % This is the scale factor
+AO.SDB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SDB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sdb{ii,8}; AO.SDB.Setpoint.Tolerance(ii,1) = val;
+
+AO.SDB.Setpoint.Range(ii,:) = [0 140];
+end
+
+
+
+% *** SFB ***
+AO.SFB.FamilyName = 'SFB'; dispobject(AO,AO.SFB.FamilyName);
+AO.SFB.MemberOf = {'PlotFamily'; 'SF'; 'SEXT'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SFB');
+Physics2HWParams = magnetcoefficients('SFB');
+
+AO.SFB.Monitor.Mode = Mode;
+AO.SFB.Monitor.DataType = 'Scalar';
+AO.SFB.Monitor.Units = 'Hardware';
+AO.SFB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SFB.Monitor.Physics2HWFcn = @k2amp;
+AO.SFB.Monitor.HWUnits = 'ampere';
+AO.SFB.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SFB.Setpoint.Mode = Mode;
+AO.SFB.Setpoint.DataType = 'Scalar';
+AO.SFB.Setpoint.Units = 'Hardware';
+AO.SFB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SFB.Setpoint.Physics2HWFcn = @k2amp;
+AO.SFB.Setpoint.HWUnits = 'ampere';
+AO.SFB.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sfb={
+'1SFB1 ' 'SR01SPS04:CURRENT_MONITOR' 'SR01SPS04:CURRENT_SP ' 1 [1,1] 1 1.0 0.05 ; ...
+'2SFB1 ' 'SR02SPS04:CURRENT_MONITOR' 'SR02SPS04:CURRENT_SP ' 1 [2,1] 2 1.0 0.05 ; ...
+'3SFB1 ' 'SR03SPS04:CURRENT_MONITOR' 'SR03SPS04:CURRENT_SP ' 1 [3,1] 3 1.0 0.05 ; ...
+'4SFB1 ' 'SR04SPS04:CURRENT_MONITOR' 'SR04SPS04:CURRENT_SP ' 1 [4,1] 4 1.0 0.05 ; ...
+'5SFB1 ' 'SR05SPS04:CURRENT_MONITOR' 'SR05SPS04:CURRENT_SP ' 1 [5,1] 5 1.0 0.05 ; ...
+'6SFB1 ' 'SR06SPS04:CURRENT_MONITOR' 'SR06SPS04:CURRENT_SP ' 1 [6,1] 6 1.0 0.05 ; ...
+'7SFB1 ' 'SR07SPS04:CURRENT_MONITOR' 'SR07SPS04:CURRENT_SP ' 1 [7,1] 7 1.0 0.05 ; ...
+'8SFB1 ' 'SR08SPS04:CURRENT_MONITOR' 'SR08SPS04:CURRENT_SP ' 1 [8,1] 8 1.0 0.05 ; ...
+'9SFB1 ' 'SR09SPS04:CURRENT_MONITOR' 'SR09SPS04:CURRENT_SP ' 1 [9,1] 9 1.0 0.05 ; ...
+'10SFB1 ' 'SR10SPS04:CURRENT_MONITOR' 'SR10SPS04:CURRENT_SP ' 1 [10,1] 10 1.0 0.05 ; ...
+'11SFB1 ' 'SR11SPS04:CURRENT_MONITOR' 'SR11SPS04:CURRENT_SP ' 1 [11,1] 11 1.0 0.05 ; ...
+'12SFB1 ' 'SR12SPS04:CURRENT_MONITOR' 'SR12SPS04:CURRENT_SP ' 1 [12,1] 12 1.0 0.05 ; ...
+'13SFB1 ' 'SR13SPS04:CURRENT_MONITOR' 'SR13SPS04:CURRENT_SP ' 1 [13,1] 13 1.0 0.05 ; ...
+'14SFB1 ' 'SR14SPS04:CURRENT_MONITOR' 'SR14SPS04:CURRENT_SP ' 1 [14,1] 14 1.0 0.05 ; ...
+};
+
+for ii=1:size(sfb,1)
+name=sfb{ii,1}; AO.SFB.CommonNames(ii,:) = name;
+name=sfb{ii,2}; AO.SFB.Monitor.ChannelNames(ii,:) = name;
+name=sfb{ii,3}; AO.SFB.Setpoint.ChannelNames(ii,:)= name;
+val =sfb{ii,4}; AO.SFB.Status(ii,1) = val;
+val =sfb{ii,5}; AO.SFB.DeviceList(ii,:) = val;
+val =sfb{ii,6}; AO.SFB.ElementLsist(ii,1) = val;
+val =sfb{ii,7}; % This is the scale factor
+AO.SFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sfb{ii,8}; AO.SFB.Setpoint.Tolerance(ii,1) = val;
+
+AO.SFB.Setpoint.Range(ii,:) = [0 140];
+end
+
+%===============
+%Skew Quad data
+%===============
+% *** Skew quadrupoles *** 2005/09/27 Eugene
+AO.SKQ.FamilyName = 'SKQ'; dispobject(AO,AO.SKQ.FamilyName);
+AO.SKQ.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SkewQuad'; 'Magnet';};
+HW2PhysicsParams = magnetcoefficients('SKQ');
+Physics2HWParams = magnetcoefficients('SKQ');
+
+AO.SKQ.Monitor.Mode = Mode;
+AO.SKQ.Monitor.DataType = 'Scalar';
+AO.SKQ.Monitor.Units = 'Hardware';
+AO.SKQ.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SKQ.Monitor.Physics2HWFcn = @k2amp;
+AO.SKQ.Monitor.HWUnits = 'ampere';
+AO.SKQ.Monitor.PhysicsUnits = 'meter^-2';
+
+AO.SKQ.Setpoint.Mode = Mode;
+AO.SKQ.Setpoint.DataType = 'Scalar';
+AO.SKQ.Setpoint.Units = 'Hardware';
+AO.SKQ.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SKQ.Setpoint.Physics2HWFcn = @k2amp;
+AO.SKQ.Setpoint.HWUnits = 'ampere';
+AO.SKQ.Setpoint.PhysicsUnits = 'meter^-2';
+
+% common monitor setpoint stat devlist elem scale tol
+sq={
+'1SKQ1 ' 'SR01CPS03:CURRENT_MONITOR' 'SR01CPS03:CURRENT_SP ' 1 [1,1] 1 1 ; ...
+'1SKQ2 ' 'SR01CPS08:CURRENT_MONITOR' 'SR01CPS08:CURRENT_SP ' 1 [1,2] 2 1 ; ...
+'2SKQ1 ' 'SR02CPS03:CURRENT_MONITOR' 'SR02CPS03:CURRENT_SP ' 1 [2,1] 3 1 ; ...
+'2SKQ2 ' 'SR02CPS08:CURRENT_MONITOR' 'SR02CPS08:CURRENT_SP ' 1 [2,2] 4 1 ; ...
+'3SKQ1 ' 'SR03CPS03:CURRENT_MONITOR' 'SR03CPS03:CURRENT_SP ' 1 [3,1] 5 1 ; ...
+'3SKQ2 ' 'SR03CPS08:CURRENT_MONITOR' 'SR03CPS08:CURRENT_SP ' 1 [3,2] 6 1 ; ...
+'4SKQ1 ' 'SR04CPS03:CURRENT_MONITOR' 'SR04CPS03:CURRENT_SP ' 1 [4,1] 7 1 ; ...
+'4SKQ2 ' 'SR04CPS08:CURRENT_MONITOR' 'SR04CPS08:CURRENT_SP ' 1 [4,2] 8 1 ; ...
+'5SKQ1 ' 'SR05CPS03:CURRENT_MONITOR' 'SR05CPS03:CURRENT_SP ' 1 [5,1] 9 1 ; ...
+'5SKQ2 ' 'SR05CPS08:CURRENT_MONITOR' 'SR05CPS08:CURRENT_SP ' 1 [5,2] 10 1 ; ...
+'6SKQ1 ' 'SR06CPS03:CURRENT_MONITOR' 'SR06CPS03:CURRENT_SP ' 1 [6,1] 11 1 ; ...
+'6SKQ2 ' 'SR06CPS08:CURRENT_MONITOR' 'SR06CPS08:CURRENT_SP ' 1 [6,2] 12 1 ; ...
+'7SKQ1 ' 'SR07CPS03:CURRENT_MONITOR' 'SR07CPS03:CURRENT_SP ' 1 [7,1] 13 1 ; ...
+'7SKQ2 ' 'SR07CPS08:CURRENT_MONITOR' 'SR07CPS08:CURRENT_SP ' 1 [7,2] 14 1 ; ...
+'8SKQ1 ' 'SR08CPS03:CURRENT_MONITOR' 'SR08CPS03:CURRENT_SP ' 1 [8,1] 15 1 ; ...
+'8SKQ2 ' 'SR08CPS08:CURRENT_MONITOR' 'SR08CPS08:CURRENT_SP ' 1 [8,2] 16 1 ; ...
+'9SKQ1 ' 'SR09CPS03:CURRENT_MONITOR' 'SR09CPS03:CURRENT_SP ' 1 [9,1] 17 1 ; ...
+'9SKQ2 ' 'SR09CPS08:CURRENT_MONITOR' 'SR09CPS08:CURRENT_SP ' 1 [9,2] 18 1 ; ...
+'10SKQ1 ' 'SR10CPS03:CURRENT_MONITOR' 'SR10CPS03:CURRENT_SP ' 1 [10,1] 19 1 ; ...
+'10SKQ2 ' 'SR10CPS08:CURRENT_MONITOR' 'SR10CPS08:CURRENT_SP ' 1 [10,2] 20 1 ; ...
+'11SKQ1 ' 'SR11CPS03:CURRENT_MONITOR' 'SR11CPS03:CURRENT_SP ' 1 [11,1] 21 1 ; ...
+'11SKQ2 ' 'SR11CPS08:CURRENT_MONITOR' 'SR11CPS08:CURRENT_SP ' 1 [11,2] 22 1 ; ...
+'12SKQ1 ' 'SR12CPS03:CURRENT_MONITOR' 'SR12CPS03:CURRENT_SP ' 1 [12,1] 23 1 ; ...
+'12SKQ2 ' 'SR12CPS08:CURRENT_MONITOR' 'SR12CPS08:CURRENT_SP ' 1 [12,2] 24 1 ; ...
+'13SKQ1 ' 'SR13CPS03:CURRENT_MONITOR' 'SR13CPS03:CURRENT_SP ' 1 [13,1] 25 1 ; ...
+'13SKQ2 ' 'SR13CPS08:CURRENT_MONITOR' 'SR13CPS08:CURRENT_SP ' 1 [13,2] 26 1 ; ...
+'14SKQ1 ' 'SR14CPS03:CURRENT_MONITOR' 'SR14CPS03:CURRENT_SP ' 1 [14,1] 27 1 ; ...
+'14SKQ2 ' 'SR14CPS08:CURRENT_MONITOR' 'SR14CPS08:CURRENT_SP ' 1 [14,2] 28 1 ; ...
+};
+
+for ii=1:size(sq,1)
+name=sq{ii,1}; AO.SKQ.CommonNames(ii,:) = name;
+name=sq{ii,2}; AO.SKQ.Monitor.ChannelNames(ii,:) = name;
+name=sq{ii,3}; AO.SKQ.Setpoint.ChannelNames(ii,:) = name;
+val =sq{ii,4}; AO.SKQ.Status(ii,1) = val;
+val =sq{ii,5}; AO.SKQ.DeviceList(ii,:) = val;
+val =sq{ii,6}; AO.SKQ.ElementList(ii,1) = val;
+val =sq{ii,7}; AO.SKQ.Setpoint.Tolerance(ii,1) = val;
+AO.SKQ.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SKQ.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SKQ.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SKQ.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+
+AO.SKQ.Setpoint.Range(ii,:) = [-5 +5];
+end
+
+
+%===============
+%Kicker data
+%===============
+AO.KICK.FamilyName = 'KICK'; dispobject(AO,AO.KICK.FamilyName);
+AO.KICK.MemberOf = {'Injection','MachineConfig'};
+
+AO.KICK.Monitor.Mode = Mode;
+AO.KICK.Monitor.DataType = 'Scalar';
+AO.KICK.Monitor.Units = 'Hardware';
+AO.KICK.Monitor.HWUnits = 'kVolts';
+AO.KICK.Monitor.PhysicsUnits = 'mradian';
+
+AO.KICK.Setpoint.Mode = Mode;
+AO.KICK.Setpoint.DataType = 'Scalar';
+AO.KICK.Setpoint.Units = 'Hardware';
+AO.KICK.Setpoint.HWUnits = 'Volts';
+AO.KICK.Setpoint.PhysicsUnits = 'radian';
+
+% From kicker deisgn review the kickers are rated to 4380 Amps giving 0.038
+% Tesla converting this to kickangle. Also convert voltage into amps for
+% the conversion?
+%
+% 2780 V on the capacitor banks will create 5240 A delivered to the kicker
+% magnets.
+% From simulations 4380 A creates 0.038607 T over a length of 0.7 m.
+% Therefore 4380 A => 2.7006 mrad. Therefore 2323.740 V => 2.7006 mrad.
+% HW2PHYSICS conversion factor (kV to rad) is therefore 0.0027006/2.32374 =
+% 0.00116217821271. The Ps also goes through a 1:3 transformer therefore
+% the conversion factor increases by 3. Ie 0.00348653463813
+% For V to rad then 0.00000348653463813.
+hw2physics_conversionfactor = 0.00000348653463813;
+
+%common monitor setpoint stat devlist elem tol
+kickeramp={
+'KICK1 ' 'SR14KPS01:VOLTAGE_MONITOR' 'SR14KPS01:VOLTAGE_SP ' 1 [1,1] 1 0.10 ; ...
+'KICK2 ' 'SR01KPS01:VOLTAGE_MONITOR' 'SR01KPS01:VOLTAGE_SP ' 1 [1,2] 2 0.10 ; ...
+'KICK3 ' 'SR01KPS02:VOLTAGE_MONITOR' 'SR01KPS02:VOLTAGE_SP ' 1 [1,3] 3 0.10 ; ...
+'KICK4 ' 'SR02KPS01:VOLTAGE_MONITOR' 'SR02KPS01:VOLTAGE_SP ' 1 [1,4] 4 0.10 ; ...
+};
+
+for ii=1:size(kickeramp,1)
+name=kickeramp{ii,1}; AO.KICK.CommonNames(ii,:) = name;
+name=kickeramp{ii,2}; AO.KICK.Monitor.ChannelNames(ii,:) = name;
+name=kickeramp{ii,3}; AO.KICK.Setpoint.ChannelNames(ii,:)= name;
+val =kickeramp{ii,4}; AO.KICK.Status(ii,1) = val;
+val =kickeramp{ii,5}; AO.KICK.DeviceList(ii,:) = val;
+val =kickeramp{ii,6}; AO.KICK.ElementList(ii,1) = val;
+val =kickeramp{ii,7}; AO.KICK.Setpoint.Tolerance(ii,1) = val;
+
+if ii==1||ii==4
+ AO.KICK.Monitor.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
+ AO.KICK.Monitor.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
+ AO.KICK.Setpoint.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
+ AO.KICK.Setpoint.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
+ AO.KICK.Setpoint.Range(ii,:) = [-1300 +1300];
+else
+ AO.KICK.Monitor.HW2PhysicsParams(ii,:) = -hw2physics_conversionfactor;
+ AO.KICK.Monitor.Physics2HWParams(ii,:) = -1/hw2physics_conversionfactor;
+ AO.KICK.Setpoint.HW2PhysicsParams(ii,:) = -hw2physics_conversionfactor;
+ AO.KICK.Setpoint.Physics2HWParams(ii,:) = -1/hw2physics_conversionfactor;
+ AO.KICK.Setpoint.Range(ii,:) = [+1300 -1300];
+end
+end
+
+% *** KICK Delay ***
+% AO.KICK.Delay
+% >> removed >> see previous versions if info needed
+
+
+%============
+%RF System
+%============
+AO.RF.FamilyName = 'RF'; dispobject(AO,AO.RF.FamilyName);
+AO.RF.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
+
+%-------------------------------- 4 cavity Case
+%common stat devlist elem
+rfcommon={
+'RF1 ' 1 [1,1] 1 ; ...
+'RF2 ' 1 [1,2] 2 ; ...
+'RF3 ' 1 [1,3] 3 ; ...
+'RF4 ' 1 [1,4] 4 ; ...
+ };
+
+%FreqMon FreqSetpoint HW2PhysicsParams Physics2HWParams Range Tolerance
+rffreq={
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 2500000] 100.0; ...
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 2500000] 100.0; ...
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 2500000] 100.0; ...
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 2500000] 100.0; ...
+ };
+
+% PhaseCtrl PhaseMon HW2PhysicsParams Physics2HWParams Range Tolerance
+rfphase={
+'SR07RF01LLE01:MASTER_PHASE_REFERENCE_SP' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
+'SR07RF01LLE01:MASTER_PHASE_REFERENCE_SP' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
+'SR07RF01LLE01:MASTER_PHASE_REFERENCE_SP' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
+'SR07RF01LLE01:MASTER_PHASE_REFERENCE_SP' 'SR07RF01LLE01:MASTER_PHASE_MONITOR' 1 1 [-200 200] inf ; ...
+ };
+
+% VoltCtrl VoltMon HW2PhysicsParams Physics2HWParams Range Tolerance
+rfvolt={
+'SRF1:STN:VOLT:CTRL ' 'SR06RF01CAV01:VOLTAGE_MONITOR' 1 1 [0 750] inf ; ...
+'SRF2:STN:VOLT:CTRL ' 'SR06RF02CAV01:VOLTAGE_MONITOR' 1 1 [0 750] inf ; ...
+'SRF3:STN:VOLT:CTRL ' 'SR07RF01CAV01:VOLTAGE_MONITOR' 1 1 [0 750] inf ; ...
+'SRF4:STN:VOLT:CTRL ' 'SR07RF02CAV01:VOLTAGE_MONITOR' 1 1 [0 750] inf ; ...
+ };
+
+% PowerCtrl PowerMon Klystronpower HW2PhysicsParams Physics2HWParams Range Tolerance
+% rfpower={
+% 'SRF1:KLYSDRIVFRWD:POWER:ON ' 'SRF1:KLYSDRIVFRWD:POWER' 'SRF1:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+% 'SRF2:KLYSDRIVFRWD:POWER:ON ' 'SRF2:KLYSDRIVFRWD:POWER' 'SRF2:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+% 'SRF3:KLYSDRIVFRWD:POWER:ON ' 'SRF3:KLYSDRIVFRWD:POWER' 'SRF3:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+% 'SRF4:KLYSDRIVFRWD:POWER:ON ' 'SRF4:KLYSDRIVFRWD:POWER' 'SRF4:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+% };
+
+for ii=1:size(rfcommon,1)
+name=rfcommon{ii,1}; AO.RF.CommonNames(ii,:) = name;
+val =rfcommon{ii,2}; AO.RF.Status(ii,1) = val;
+val =rfcommon{ii,3}; AO.RF.DeviceList(ii,:) = val;
+val =rfcommon{ii,4}; AO.RF.ElementList(ii,1) = val;
+end
+
+for ii=1:size(rffreq,1)
+name=rffreq{ii,1}; AO.RF.Monitor.ChannelNames(ii,:) = name;
+name=rffreq{ii,2}; AO.RF.Setpoint.ChannelNames(ii,:) = name;
+val =rffreq{ii,3}; AO.RF.Monitor.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Setpoint.HW2PhysicsParams(ii,1) = val;
+val =rffreq{ii,4}; AO.RF.Monitor.Physics2HWParams(ii,1) = val;
+ AO.RF.Setpoint.Physics2HWParams(ii,1) = val;
+val =rffreq{ii,5}; AO.RF.Setpoint.Range(ii,:) = val;
+val =rffreq{ii,6}; AO.RF.Setpoint.Tolerance(ii,1) = val;
+end
+
+
+for ii=1:size(rfphase,1)
+name=rfphase{ii,1}; AO.RF.PhaseCtrl.ChannelNames(ii,:) = name;
+name=rfphase{ii,2}; AO.RF.Phase.ChannelNames(ii,:) = name;
+val =rfphase{ii,3}; AO.RF.PhaseCtrl.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Phase.HW2PhysicsParams(ii,1) = val;
+val =rfphase{ii,4}; AO.RF.PhaseCtrl.Physics2HWParams(ii,1) = val;
+ AO.RF.Phase.Physics2HWParams(ii,1) = val;
+val =rfphase{ii,5}; AO.RF.PhaseCtrl.Range(ii,:) = val;
+ AO.RF.Phase.Range(ii,:) = val;
+val =rfphase{ii,6}; AO.RF.PhaseCtrl.Tolerance(ii,1) = val;
+ AO.RF.Phase.Tolerance(ii,1) = val;
+end
+
+
+for ii=1:size(rfvolt,1)
+% name=rfvolt{ii,1}; AO.RF.VoltageCtrl.ChannelNames(ii,:) = name;
+name=rfvolt{ii,2}; AO.RF.Voltage.ChannelNames(ii,:) = name;
+val =rfvolt{ii,3}; % AO.RF.VoltageCtrl.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Voltage.HW2PhysicsParams(ii,1) = val;
+val =rfvolt{ii,4}; % AO.RF.VoltageCtrl.Physics2HWParams(ii,1) = val;
+ AO.RF.Voltage.Physics2HWParams(ii,1) = val;
+val =rfvolt{ii,5}; % AO.RF.VoltageCtrl.Range(ii,:) = val;
+ AO.RF.Voltage.Range(ii,:) = val;
+val =rfvolt{ii,6}; % AO.RF.VoltageCtrl.Tolerance(ii,1) = val;
+ AO.RF.Voltage.Tolerance(ii,1) = val;
+end
+
+
+% for ii=1:size(rfpower,1)
+% name=rfpower{ii,1}; AO.RF.PowerCtrl.ChannelNames(ii,:) = name;
+% name=rfpower{ii,2}; AO.RF.Power.ChannelNames(ii,:) = name;
+% name=rfpower{ii,3}; AO.RF.KlysPower.ChannelNames(ii,:) = name;
+% val =rfpower{ii,4}; AO.RF.PowerCtrl.HW2PhysicsParams(ii,1) = val;
+% AO.RF.Power.HW2PhysicsParams(ii,1) = val;
+% AO.RF.KlysPower.HW2PhysicsParams(ii,1) = val;
+% val =rfpower{ii,5}; AO.RF.PowerCtrl.Physics2HWParams(ii,1) = val;
+% AO.RF.Power.Physics2HWParams(ii,1) = val;
+% AO.RF.KlysPower.Physics2HWParams(ii,1) = val;
+% val =rfpower{ii,6}; AO.RF.PowerCtrl.Range(ii,:) = val;
+% AO.RF.Power.Range(ii,:) = val;
+% AO.RF.KlysPower.Range(ii,:) = val;
+% val =rfpower{ii,7}; AO.RF.PowerCtrl.Tolerance(ii,1) = val;
+% AO.RF.Power.Tolerance(ii,1) = val;
+% AO.RF.KlysPower.Tolerance(ii,1) = val;
+% end
+
+%Frequency Readback
+AO.RF.Monitor.Mode = Mode;
+AO.RF.Monitor.DataType = 'Scalar';
+AO.RF.Monitor.Units = 'Hardware';
+AO.RF.Monitor.HWUnits = 'Hz';
+AO.RF.Monitor.PhysicsUnits = 'Hz';
+%Frequency Setpoint
+AO.RF.Setpoint.Mode = Mode;
+AO.RF.Setpoint.DataType = 'Scalar';
+AO.RF.Setpoint.Units = 'Hardware';
+AO.RF.Setpoint.HWUnits = 'Hz';
+AO.RF.Setpoint.PhysicsUnits = 'Hz';
+
+%Voltage control
+% AO.RF.VoltageCtrl.Mode = Mode;
+% AO.RF.VoltageCtrl.DataType = 'Scalar';
+% AO.RF.VoltageCtrl.Units = 'Hardware';
+% AO.RF.VoltageCtrl.HWUnits = 'Volts';
+% AO.RF.VoltageCtrl.PhysicsUnits = 'Volts';
+
+%Voltage monitor
+AO.RF.Voltage.Mode = Mode;
+AO.RF.Voltage.DataType = 'Scalar';
+AO.RF.Voltage.Units = 'Hardware';
+AO.RF.Voltage.HWUnits = 'Volts';
+AO.RF.Voltage.PhysicsUnits = 'Volts';
+
+%Power Control
+% AO.RF.PowerCtrl.Mode = Mode;
+% AO.RF.PowerCtrl.DataType = 'Scalar';
+% AO.RF.PowerCtrl.Units = 'Hardware';
+% AO.RF.PowerCtrl.HWUnits = 'MWatts';
+% AO.RF.PowerCtrl.PhysicsUnits = 'MWatts';
+
+%Power Monitor
+AO.RF.Power.Mode = Mode;
+AO.RF.Power.DataType = 'Scalar';
+AO.RF.Power.Units = 'Hardware';
+AO.RF.Power.HWUnits = 'MWatts';
+AO.RF.Power.PhysicsUnits = 'MWatts';
+
+% %Klystron Forward Power
+% AO.RF.KlysPower.Mode = Mode;
+% AO.RF.KlysPower.DataType = 'Scalar';
+% AO.RF.KlysPower.Units = 'Hardware';
+% AO.RF.KlysPower.HWUnits = 'MWatts';
+% AO.RF.KlysPower.PhysicsUnits = 'MWatts';
+
+% %Station Phase Control
+% AO.RF.PhaseCtrl.Mode = Mode;
+% AO.RF.PhaseCtrl.DataType = 'Scalar';
+% AO.RF.PhaseCtrl.Units = 'Hardware';
+% AO.RF.PhaseCtrl.HWUnits = 'Degrees';
+% AO.RF.PhaseCtrl.PhysicsUnits = 'Degrees';
+
+%Station Phase Monitor
+AO.RF.Phase.Mode = Mode;
+AO.RF.Phase.DataType = 'Scalar';
+AO.RF.Phase.Units = 'Hardware';
+AO.RF.Phase.HWUnits = 'Degrees';
+AO.RF.Phase.PhysicsUnits = 'Degrees';
+
+%====
+%TUNE
+%====
+AO.TUNE.FamilyName = 'TUNE'; dispobject(AO,AO.TUNE.FamilyName);
+AO.TUNE.MemberOf = {'Tune'; 'Diagnostics'};
+AO.TUNE.CommonNames = ['xtune';'ytune';'stune'];
+AO.TUNE.DeviceList = [ 1 1; 1 2; 1 3];
+AO.TUNE.ElementList = [1 2 3]';
+AO.TUNE.Status = [1 1 0]';
+
+AO.TUNE.Monitor.Mode = Mode;
+AO.TUNE.Monitor.DataType = 'Vector';
+AO.TUNE.Monitor.DataTypeIndex = [1 2 3]';
+AO.TUNE.Monitor.ChannelNames = 'MeasTune';
+AO.TUNE.Monitor.Units = 'Hardware';
+AO.TUNE.Monitor.HW2PhysicsParams = 1;
+AO.TUNE.Monitor.Physics2HWParams = 1;
+AO.TUNE.Monitor.HWUnits = 'fractional tune';
+AO.TUNE.Monitor.PhysicsUnits = 'fractional tune';
+
+
+%====
+%DCCT
+%====
+AO.DCCT.FamilyName = 'DCCT'; dispobject(AO,AO.DCCT.FamilyName);
+AO.DCCT.MemberOf = {'Diagnostics'};
+AO.DCCT.CommonNames = 'DCCT';
+AO.DCCT.DeviceList = [1 1];
+AO.DCCT.ElementList = [1];
+AO.DCCT.Status = [1];
+
+AO.DCCT.Monitor.Mode = Mode;
+AO.DCCT.Monitor.DataType = 'Scalar';
+AO.DCCT.Monitor.ChannelNames = 'SR11BCM01:CURRENT_MONITOR';
+AO.DCCT.Monitor.Units = 'Hardware';
+AO.DCCT.Monitor.HWUnits = 'milli-ampere';
+AO.DCCT.Monitor.PhysicsUnits = 'ampere';
+AO.DCCT.Monitor.HW2PhysicsParams = 1e-3;
+AO.DCCT.Monitor.Physics2HWParams = 1000;
+
+
+% %==================
+% %Machine Parameters
+% %==================
+% Removed in this version, see pervious version for more info
+
+%======
+%Septum
+%======
+% ifam=ifam+1;
+% AO.Septum.FamilyName = 'Septum'; dispobject(AO,AO.Septum.FamilyName);
+% AO.Septum.MemberOf = {'Injection'};
+% AO.Septum.Status = 1;
+%
+% AO.Septum.CommonNames = 'Septum ';
+% AO.Septum.DeviceList = [3 1];
+% AO.Septum.ElementList = [1];
+%
+% AO.Septum.Monitor.Mode = Mode;
+% AO.Septum.Monitor.DataType = 'Scalar';
+% AO.Septum.Monitor.Units = 'Hardware';
+% AO.Septum.Monitor.HWUnits = 'ampere';
+% AO.Septum.Monitor.PhysicsUnits = 'radian';
+% AO.Septum.Monitor.ChannelNames = 'BTS-B9V:Curr';
+%
+% AO.Septum.Setpoint.Mode = Mode;
+% AO.Septum.Setpoint.DataType = 'Scalar';
+% AO.Septum.Setpoint.Units = 'Hardware';
+% AO.Septum.Setpoint.HWUnits = 'ampere';
+% AO.Septum.Setpoint.PhysicsUnits = 'radian';
+% AO.Septum.Setpoint.ChannelNames = 'BTS-B9V:CurrSetpt';
+% AO.Septum.Setpoint.Range = [0, 2500];
+% AO.Septum.Setpoint.Tolerance = 100.0;
+%
+% AO.Septum.Monitor.HW2PhysicsParams = 1;
+% AO.Septum.Monitor.Physics2HWParams = 1;
+% AO.Septum.Setpoint.HW2PhysicsParams = 1;
+% AO.Septum.Setpoint.Physics2HWParams = 1;
+
+
+%====================
+%Photon Beamline Data
+%====================
+% >> removed >> see previous versions if info needed
+
+%====================
+%BPLD Data
+%====================
+% >> removed >> see previous versions if info needed
+
+
+
+% The operational mode sets the path, filenames, and other important parameters
+% Run setoperationalmode after most of the AO is built so that the Units and Mode fields
+% can be set in setoperationalmode
+fprintf('\n');
+setao(AO);
+setoperationalmode(OperationalMode);
+AO = getao;
+
+
+%%%%%%%%%%%%%%%%
+% DeltaRespMat %
+%%%%%%%%%%%%%%%%
+
+% I remove the physics2hw conversion because the physics2hw is
+% is calibrated yet.
+
+% Set response matrix kick size in hardware units (amps)
+AO.HCM.Setpoint.DeltaRespMat = physics2hw('HCM', 'Setpoint', .15e-3 / 1, AO.HCM.DeviceList);
+AO.VCM.Setpoint.DeltaRespMat = physics2hw('VCM', 'Setpoint', .15e-3 / 1, AO.VCM.DeviceList);
+
+%% 'NoEnergyScaling' because I don't want to force a BEND magnet read at this point
+%AO.HCM.Setpoint.DeltaRespMat = mm2amps('HCM', .5, AO.HCM.DeviceList, 'NoEnergyScaling');
+%AO.VCM.Setpoint.DeltaRespMat = mm2amps('VCM', .5, AO.VCM.DeviceList, 'NoEnergyScaling');
+
+
+AO.QFA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFA.FamilyName, 'Setpoint', AO.QFA.Setpoint.DeltaRespMat, AO.QFA.DeviceList);
+AO.QFB.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFB.FamilyName, 'Setpoint', AO.QFB.Setpoint.DeltaRespMat, AO.QFB.DeviceList);
+AO.QDA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QDA.FamilyName, 'Setpoint', AO.QDA.Setpoint.DeltaRespMat, AO.QDA.DeviceList);
+
+
+AO.SFA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFA.FamilyName, 'Setpoint', AO.SFA.Setpoint.DeltaRespMat, AO.SFA.DeviceList);
+AO.SFB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFB.FamilyName, 'Setpoint', AO.SFB.Setpoint.DeltaRespMat, AO.SFB.DeviceList);
+AO.SDA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDA.FamilyName, 'Setpoint', AO.SDA.Setpoint.DeltaRespMat, AO.SDA.DeviceList);
+AO.SDB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDB.FamilyName, 'Setpoint', AO.SDB.Setpoint.DeltaRespMat, AO.SDB.DeviceList);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Get S-positions [meters] %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Using ...ATIndex(:,1) will accomodata for split elements where the first
+% of a group of elements is put in the first column ie, if SFA is split in
+% two then ATIndex will look like [2 3; 11 12; ...] where each row is a
+% magnet and column represents each split.
+global THERING
+AO.BPMx.Position = findspos(THERING, AO.BPMx.AT.ATIndex(:,1))';
+AO.BPMy.Position = findspos(THERING, AO.BPMy.AT.ATIndex(:,1))';
+AO.FTx.Position = findspos(THERING, AO.FTx.AT.ATIndex(:,1))';
+AO.FTy.Position = findspos(THERING, AO.FTy.AT.ATIndex(:,1))';
+AO.FTsum.Position= findspos(THERING, AO.FTsum.AT.ATIndex(:,1))';
+AO.HCM.Position = findspos(THERING, AO.HCM.AT.ATIndex(:,1))';
+AO.VCM.Position = findspos(THERING, AO.VCM.AT.ATIndex(:,1))';
+AO.QFA.Position = findspos(THERING, AO.QFA.AT.ATIndex(:,1))';
+AO.QDA.Position = findspos(THERING, AO.QDA.AT.ATIndex(:,1))';
+AO.QFB.Position = findspos(THERING, AO.QFB.AT.ATIndex(:,1))';
+AO.SFA.Position = findspos(THERING, AO.SFA.AT.ATIndex(:,1))';
+AO.SFB.Position = findspos(THERING, AO.SFB.AT.ATIndex(:,1))';
+AO.SDA.Position = findspos(THERING, AO.SDA.AT.ATIndex(:,1))';
+AO.SDB.Position = findspos(THERING, AO.SDB.AT.ATIndex(:,1))';
+AO.SKQ.Position = findspos(THERING, AO.SKQ.AT.ATIndex(:,1))';
+AO.BEND.Position = findspos(THERING, AO.BEND.AT.ATIndex(:,1))';
+AO.RF.Position = findspos(THERING, AO.RF.AT.ATIndex(:,1))';
+AO.KICK.Position = findspos(THERING, AO.KICK.AT.ATIndex(:,1))';
+AO.DCCT.Position = 0;
+AO.TUNE.Position = 0;
+
+
+% Save AO
+setao(AO);
+
+
+function dispobject(AO,name)
+
+n = length(fieldnames(AO));
+
+if n > 0
+ fprintf(' %10s ',name);
+ if mod(n,5) == 0
+ fprintf('\n');
+ end
end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/aspinit_20061204.m b/machine/ASP/StorageRing/aspinit_20061204.m
index 17cba8f3..aaf1d6d4 100644
--- a/machine/ASP/StorageRing/aspinit_20061204.m
+++ b/machine/ASP/StorageRing/aspinit_20061204.m
@@ -1,1777 +1,1777 @@
-function aspinit(OperationalMode)
-% aspinit(OperationalMode)
-%
-% Initialize parameters for ASP control in MATLAB
-%
-%==========================
-% Accelerator Family Fields
-%==========================
-% FamilyName BPMx, HCM, etc
-% CommonNames Shortcut name for each element (optional)
-% DeviceList [Sector, Number]
-% ElementList number in list
-% Position m, magnet center
-%
-% MONITOR FIELDS
-% Mode online/manual/special/simulator
-% ChannelNames PV for monitor
-% Units Physics or HW
-% HW2PhysicsFcn function handle used to convert from hardware to physics units ==> inline will not compile, see below
-% HW2PhysicsParams parameters used for conversion function
-% Physics2HWFcn function handle used to convert from physics to hardware units
-% Physics2HWParams parameters used for conversion function
-% HWUnits units for Hardware 'ampere';
-% PhysicsUnits units for physics 'Rad';
-%
-% SETPOINT FIELDS
-% Mode online/manual/special/simulator
-% ChannelNames PV for monitor
-% Units hardware or physics
-% HW2PhysicsFcn function handle used to convert from hardware to physics units
-% HW2PhysicsParams parameters used for conversion function
-% Physics2HWFcn function handle used to convert from physics to hardware units
-% Physics2HWParams parameters used for conversion function
-% HWUnits units for Hardware 'ampere';
-% PhysicsUnits units for physics 'Rad';
-% Range minsetpoint, maxsetpoint;
-% Tolerance setpoint-monitor
-%
-%=============================================
-% Accelerator Toolbox Simulation Fields
-%=============================================
-% ATType Quad, Sext, etc
-% ATIndex index in THERING
-% ATParameterGroup parameter group
-%
-%============
-% Family List
-%============
-% BPMx BPMy - beam position monitors
-% HCM VCM - corrector magnets wound into sextupoles
-% BEND - gradient dipoles
-% QFA QDA QFB - quadrupole magnets
-% SFA SDA SDB SFB - sextupole magnets
-% SQK - skew quads wound into SDA magnets
-% KICK - injection kickers (DELTA type)
-% RF - 4 cavities (KEK type?)
-% DCCT
-% Septum (Not in model yet)
-%
-% Normal cell: d1 bpm s1 hcor d2 q1 d3 s2 d4 bpm dip bpm d4 hcor s3 d5 q2 d6 q3 d2 bpm s4
-% d2 q3 d6 q2 d5 s3 hcor d4 bpm dip bpm d4 s2 d3 q1 d2 hcor s1 bpm d1
-
-% === Change Log ===
-% Mark Boland 2004-02-12
-% Eugene Tan 2004-02-23
-% Eugene Tan 2004-12-13
-% Eugene Tan 2005-09-27 ver 4
-% Updated naming convention of the process variables, use version 4 of
-% the lattice "assr4.m" where the correctors have been merged into the
-% sextupoles. Made the necessary changes to updateatindex. Added skew
-% quadrupoles and updated generate_init.
-% Mark Boland 2006-05-27
-% Changed the BPM PVs to ...:SA_HPOS_MONITOR and ...:SA_VPOS_MONITOR
-%
-% Mark Boland 2006-08-29
-% Changed range on HCM and VCM from - to + since the polarity of the
-% correctors was physically changed in the last weeks.
-%
-% === Still to do ===
-% - kicker delays
-% - BPM names and other possible PVs of interest eg. Q factor etc.
-% - clean up and configure the amp2k and k2amp conversion. Control system
-% designed to calculate the strengths and amp values using calc records,
-% therefore we should only need to change the PV name to access for
-% readback at setpoints. Only problem will be in simulation/offline mode
-% where those value are not available online. How do you keep the offline
-% conversion factors up to date with online vals?
-%
-% === Generated from ===
-% aspinit_v5skeleton.m
-
-% Default operational mode
-if nargin < 1
- OperationalMode = 1;
-end
-
-
-%=============================================
-% START DEFINITION OF ACCELERATOR OBJECTS
-%=============================================
-fprintf(' Defining the Accelerator Objects. Objects being defined:\n')
-
-
-% Clear previous AcceleratorObjects
-setao([]);
-
-
-Mode = 'Online'; % This gets reset in setoperationalmode
-
-%=============================================
-%BPM data: status field designates if BPM in use
-%=============================================
-ntbpm=98;
-AO.BPMx.FamilyName = 'BPMx'; dispobject(AO,AO.BPMx.FamilyName);
-AO.BPMx.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'; 'BPMx'};
-AO.BPMx.Monitor.Mode = Mode;
-AO.BPMx.Monitor.DataType = 'Scalar';
-AO.BPMx.Monitor.Units = 'Hardware';
-AO.BPMx.Monitor.HWUnits = 'mm';
-AO.BPMx.Monitor.PhysicsUnits = 'meter';
-
-AO.BPMy.FamilyName = 'BPMy'; dispobject(AO,AO.BPMy.FamilyName);
-AO.BPMy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'; 'BPMy'};
-AO.BPMy.Monitor.Mode = Mode;
-AO.BPMy.Monitor.DataType = 'Scalar';
-AO.BPMy.Monitor.Units = 'Hardware';
-AO.BPMy.Monitor.HWUnits = 'mm';
-AO.BPMy.Monitor.PhysicsUnits = 'meter';
-
-% x-name x-chname xstat y-name y-chname ystat DevList Elem
-bpm={
-'1BPMx1 ' 'SR01BPM01:SA_HPOS_MONITOR' 1 '1BPMy1 ' 'SR01BPM01:SA_VPOS_MONITOR' 1 [1,1] 1 ; ...
-'1BPMx2 ' 'SR01BPM02:SA_HPOS_MONITOR' 1 '1BPMy2 ' 'SR01BPM02:SA_VPOS_MONITOR' 1 [1,2] 2 ; ...
-'1BPMx3 ' 'SR01BPM03:SA_HPOS_MONITOR' 1 '1BPMy3 ' 'SR01BPM03:SA_VPOS_MONITOR' 1 [1,3] 3 ; ...
-'1BPMx4 ' 'SR01BPM04:SA_HPOS_MONITOR' 1 '1BPMy4 ' 'SR01BPM04:SA_VPOS_MONITOR' 1 [1,4] 4 ; ...
-'1BPMx5 ' 'SR01BPM05:SA_HPOS_MONITOR' 1 '1BPMy5 ' 'SR01BPM05:SA_VPOS_MONITOR' 1 [1,5] 5 ; ...
-'1BPMx6 ' 'SR01BPM06:SA_HPOS_MONITOR' 1 '1BPMy6 ' 'SR01BPM06:SA_VPOS_MONITOR' 1 [1,6] 6 ; ...
-'1BPMx7 ' 'SR01BPM07:SA_HPOS_MONITOR' 1 '1BPMy7 ' 'SR01BPM07:SA_VPOS_MONITOR' 1 [1,7] 7 ; ...
-'2BPMx1 ' 'SR02BPM01:SA_HPOS_MONITOR' 1 '2BPMy1 ' 'SR02BPM01:SA_VPOS_MONITOR' 1 [2,1] 8 ; ...
-'2BPMx2 ' 'SR02BPM02:SA_HPOS_MONITOR' 0 '2BPMy2 ' 'SR02BPM02:SA_VPOS_MONITOR' 0 [2,2] 9 ; ...
-'2BPMx3 ' 'SR02BPM03:SA_HPOS_MONITOR' 1 '2BPMy3 ' 'SR02BPM03:SA_VPOS_MONITOR' 1 [2,3] 10 ; ...
-'2BPMx4 ' 'SR02BPM04:SA_HPOS_MONITOR' 1 '2BPMy4 ' 'SR02BPM04:SA_VPOS_MONITOR' 1 [2,4] 11 ; ...
-'2BPMx5 ' 'SR02BPM05:SA_HPOS_MONITOR' 1 '2BPMy5 ' 'SR02BPM05:SA_VPOS_MONITOR' 1 [2,5] 12 ; ...
-'2BPMx6 ' 'SR02BPM06:SA_HPOS_MONITOR' 1 '2BPMy6 ' 'SR02BPM06:SA_VPOS_MONITOR' 1 [2,6] 13 ; ...
-'2BPMx7 ' 'SR02BPM07:SA_HPOS_MONITOR' 1 '2BPMy7 ' 'SR02BPM07:SA_VPOS_MONITOR' 1 [2,7] 14 ; ...
-'3BPMx1 ' 'SR03BPM01:SA_HPOS_MONITOR' 1 '3BPMy1 ' 'SR03BPM01:SA_VPOS_MONITOR' 1 [3,1] 15 ; ...
-'3BPMx2 ' 'SR03BPM02:SA_HPOS_MONITOR' 1 '3BPMy2 ' 'SR03BPM02:SA_VPOS_MONITOR' 1 [3,2] 16 ; ...
-'3BPMx3 ' 'SR03BPM03:SA_HPOS_MONITOR' 1 '3BPMy3 ' 'SR03BPM03:SA_VPOS_MONITOR' 1 [3,3] 17 ; ...
-'3BPMx4 ' 'SR03BPM04:SA_HPOS_MONITOR' 1 '3BPMy4 ' 'SR03BPM04:SA_VPOS_MONITOR' 1 [3,4] 18 ; ...
-'3BPMx5 ' 'SR03BPM05:SA_HPOS_MONITOR' 1 '3BPMy5 ' 'SR03BPM05:SA_VPOS_MONITOR' 1 [3,5] 19 ; ...
-'3BPMx6 ' 'SR03BPM06:SA_HPOS_MONITOR' 1 '3BPMy6 ' 'SR03BPM06:SA_VPOS_MONITOR' 1 [3,6] 20 ; ...
-'3BPMx7 ' 'SR03BPM07:SA_HPOS_MONITOR' 1 '3BPMy7 ' 'SR03BPM07:SA_VPOS_MONITOR' 1 [3,7] 21 ; ...
-'4BPMx1 ' 'SR04BPM01:SA_HPOS_MONITOR' 1 '4BPMy1 ' 'SR04BPM01:SA_VPOS_MONITOR' 1 [4,1] 22 ; ...
-'4BPMx2 ' 'SR04BPM02:SA_HPOS_MONITOR' 1 '4BPMy2 ' 'SR04BPM02:SA_VPOS_MONITOR' 1 [4,2] 23 ; ...
-'4BPMx3 ' 'SR04BPM03:SA_HPOS_MONITOR' 1 '4BPMy3 ' 'SR04BPM03:SA_VPOS_MONITOR' 1 [4,3] 24 ; ...
-'4BPMx4 ' 'SR04BPM04:SA_HPOS_MONITOR' 1 '4BPMy4 ' 'SR04BPM04:SA_VPOS_MONITOR' 1 [4,4] 25 ; ...
-'4BPMx5 ' 'SR04BPM05:SA_HPOS_MONITOR' 0 '4BPMy5 ' 'SR04BPM05:SA_VPOS_MONITOR' 0 [4,5] 26 ; ...
-'4BPMx6 ' 'SR04BPM06:SA_HPOS_MONITOR' 1 '4BPMy6 ' 'SR04BPM06:SA_VPOS_MONITOR' 1 [4,6] 27 ; ...
-'4BPMx7 ' 'SR04BPM07:SA_HPOS_MONITOR' 0 '4BPMy7 ' 'SR04BPM07:SA_VPOS_MONITOR' 0 [4,7] 28 ; ...
-'5BPMx1 ' 'SR05BPM01:SA_HPOS_MONITOR' 1 '5BPMy1 ' 'SR05BPM01:SA_VPOS_MONITOR' 1 [5,1] 29 ; ...
-'5BPMx2 ' 'SR05BPM02:SA_HPOS_MONITOR' 1 '5BPMy2 ' 'SR05BPM02:SA_VPOS_MONITOR' 1 [5,2] 30 ; ...
-'5BPMx3 ' 'SR05BPM03:SA_HPOS_MONITOR' 0 '5BPMy3 ' 'SR05BPM03:SA_VPOS_MONITOR' 0 [5,3] 31 ; ...
-'5BPMx4 ' 'SR05BPM04:SA_HPOS_MONITOR' 1 '5BPMy4 ' 'SR05BPM04:SA_VPOS_MONITOR' 1 [5,4] 32 ; ...
-'5BPMx5 ' 'SR05BPM05:SA_HPOS_MONITOR' 1 '5BPMy5 ' 'SR05BPM05:SA_VPOS_MONITOR' 1 [5,5] 33 ; ...
-'5BPMx6 ' 'SR05BPM06:SA_HPOS_MONITOR' 1 '5BPMy6 ' 'SR05BPM06:SA_VPOS_MONITOR' 1 [5,6] 34 ; ...
-'5BPMx7 ' 'SR05BPM07:SA_HPOS_MONITOR' 1 '5BPMy7 ' 'SR05BPM07:SA_VPOS_MONITOR' 1 [5,7] 35 ; ...
-'6BPMx1 ' 'SR06BPM01:SA_HPOS_MONITOR' 1 '6BPMy1 ' 'SR06BPM01:SA_VPOS_MONITOR' 1 [6,1] 36 ; ...
-'6BPMx2 ' 'SR06BPM02:SA_HPOS_MONITOR' 1 '6BPMy2 ' 'SR06BPM02:SA_VPOS_MONITOR' 1 [6,2] 37 ; ...
-'6BPMx3 ' 'SR06BPM03:SA_HPOS_MONITOR' 1 '6BPMy3 ' 'SR06BPM03:SA_VPOS_MONITOR' 1 [6,3] 38 ; ...
-'6BPMx4 ' 'SR06BPM04:SA_HPOS_MONITOR' 1 '6BPMy4 ' 'SR06BPM04:SA_VPOS_MONITOR' 1 [6,4] 39 ; ...
-'6BPMx5 ' 'SR06BPM05:SA_HPOS_MONITOR' 1 '6BPMy5 ' 'SR06BPM05:SA_VPOS_MONITOR' 1 [6,5] 40 ; ...
-'6BPMx6 ' 'SR06BPM06:SA_HPOS_MONITOR' 0 '6BPMy6 ' 'SR06BPM06:SA_VPOS_MONITOR' 0 [6,6] 41 ; ...
-'6BPMx7 ' 'SR06BPM07:SA_HPOS_MONITOR' 1 '6BPMy7 ' 'SR06BPM07:SA_VPOS_MONITOR' 1 [6,7] 42 ; ...
-'7BPMx1 ' 'SR07BPM01:SA_HPOS_MONITOR' 0 '7BPMy1 ' 'SR07BPM01:SA_VPOS_MONITOR' 0 [7,1] 43 ; ...
-'7BPMx2 ' 'SR07BPM02:SA_HPOS_MONITOR' 1 '7BPMy2 ' 'SR07BPM02:SA_VPOS_MONITOR' 1 [7,2] 44 ; ...
-'7BPMx3 ' 'SR07BPM03:SA_HPOS_MONITOR' 0 '7BPMy3 ' 'SR07BPM03:SA_VPOS_MONITOR' 0 [7,3] 45 ; ...
-'7BPMx4 ' 'SR07BPM04:SA_HPOS_MONITOR' 1 '7BPMy4 ' 'SR07BPM04:SA_VPOS_MONITOR' 1 [7,4] 46 ; ...
-'7BPMx5 ' 'SR07BPM05:SA_HPOS_MONITOR' 1 '7BPMy5 ' 'SR07BPM05:SA_VPOS_MONITOR' 1 [7,5] 47 ; ...
-'7BPMx6 ' 'SR07BPM06:SA_HPOS_MONITOR' 1 '7BPMy6 ' 'SR07BPM06:SA_VPOS_MONITOR' 1 [7,6] 48 ; ...
-'7BPMx7 ' 'SR07BPM07:SA_HPOS_MONITOR' 1 '7BPMy7 ' 'SR07BPM07:SA_VPOS_MONITOR' 1 [7,7] 49 ; ...
-'8BPMx1 ' 'SR08BPM01:SA_HPOS_MONITOR' 1 '8BPMy1 ' 'SR08BPM01:SA_VPOS_MONITOR' 1 [8,1] 50 ; ...
-'8BPMx2 ' 'SR08BPM02:SA_HPOS_MONITOR' 1 '8BPMy2 ' 'SR08BPM02:SA_VPOS_MONITOR' 1 [8,2] 51 ; ...
-'8BPMx3 ' 'SR08BPM03:SA_HPOS_MONITOR' 1 '8BPMy3 ' 'SR08BPM03:SA_VPOS_MONITOR' 1 [8,3] 52 ; ...
-'8BPMx4 ' 'SR08BPM04:SA_HPOS_MONITOR' 1 '8BPMy4 ' 'SR08BPM04:SA_VPOS_MONITOR' 1 [8,4] 53 ; ...
-'8BPMx5 ' 'SR08BPM05:SA_HPOS_MONITOR' 1 '8BPMy5 ' 'SR08BPM05:SA_VPOS_MONITOR' 1 [8,5] 54 ; ...
-'8BPMx6 ' 'SR08BPM06:SA_HPOS_MONITOR' 1 '8BPMy6 ' 'SR08BPM06:SA_VPOS_MONITOR' 1 [8,6] 55 ; ...
-'8BPMx7 ' 'SR08BPM07:SA_HPOS_MONITOR' 1 '8BPMy7 ' 'SR08BPM07:SA_VPOS_MONITOR' 1 [8,7] 56 ; ...
-'9BPMx1 ' 'SR09BPM01:SA_HPOS_MONITOR' 1 '9BPMy1 ' 'SR09BPM01:SA_VPOS_MONITOR' 1 [9,1] 57 ; ...
-'9BPMx2 ' 'SR09BPM02:SA_HPOS_MONITOR' 1 '9BPMy2 ' 'SR09BPM02:SA_VPOS_MONITOR' 1 [9,2] 58 ; ...
-'9BPMx3 ' 'SR09BPM03:SA_HPOS_MONITOR' 1 '9BPMy3 ' 'SR09BPM03:SA_VPOS_MONITOR' 1 [9,3] 59 ; ...
-'9BPMx4 ' 'SR09BPM04:SA_HPOS_MONITOR' 1 '9BPMy4 ' 'SR09BPM04:SA_VPOS_MONITOR' 1 [9,4] 60 ; ...
-'9BPMx5 ' 'SR09BPM05:SA_HPOS_MONITOR' 0 '9BPMy5 ' 'SR09BPM05:SA_VPOS_MONITOR' 0 [9,5] 61 ; ...
-'9BPMx6 ' 'SR09BPM06:SA_HPOS_MONITOR' 1 '9BPMy6 ' 'SR09BPM06:SA_VPOS_MONITOR' 1 [9,6] 62 ; ...
-'9BPMx7 ' 'SR09BPM07:SA_HPOS_MONITOR' 1 '9BPMy7 ' 'SR09BPM07:SA_VPOS_MONITOR' 1 [9,7] 63 ; ...
-'10BPMx1 ' 'SR10BPM01:SA_HPOS_MONITOR' 1 '10BPMy1 ' 'SR10BPM01:SA_VPOS_MONITOR' 1 [10,1] 64 ; ...
-'10BPMx2 ' 'SR10BPM02:SA_HPOS_MONITOR' 1 '10BPMy2 ' 'SR10BPM02:SA_VPOS_MONITOR' 1 [10,2] 65 ; ...
-'10BPMx3 ' 'SR10BPM03:SA_HPOS_MONITOR' 1 '10BPMy3 ' 'SR10BPM03:SA_VPOS_MONITOR' 1 [10,3] 66 ; ...
-'10BPMx4 ' 'SR10BPM04:SA_HPOS_MONITOR' 1 '10BPMy4 ' 'SR10BPM04:SA_VPOS_MONITOR' 1 [10,4] 67 ; ...
-'10BPMx5 ' 'SR10BPM05:SA_HPOS_MONITOR' 1 '10BPMy5 ' 'SR10BPM05:SA_VPOS_MONITOR' 1 [10,5] 68 ; ...
-'10BPMx6 ' 'SR10BPM06:SA_HPOS_MONITOR' 1 '10BPMy6 ' 'SR10BPM06:SA_VPOS_MONITOR' 1 [10,6] 69 ; ...
-'10BPMx7 ' 'SR10BPM07:SA_HPOS_MONITOR' 1 '10BPMy7 ' 'SR10BPM07:SA_VPOS_MONITOR' 1 [10,7] 70 ; ...
-'11BPMx1 ' 'SR11BPM01:SA_HPOS_MONITOR' 1 '11BPMy1 ' 'SR11BPM01:SA_VPOS_MONITOR' 1 [11,1] 71 ; ...
-'11BPMx2 ' 'SR11BPM02:SA_HPOS_MONITOR' 0 '11BPMy2 ' 'SR11BPM02:SA_VPOS_MONITOR' 0 [11,2] 72 ; ...
-'11BPMx3 ' 'SR11BPM03:SA_HPOS_MONITOR' 1 '11BPMy3 ' 'SR11BPM03:SA_VPOS_MONITOR' 1 [11,3] 73 ; ...
-'11BPMx4 ' 'SR11BPM04:SA_HPOS_MONITOR' 1 '11BPMy4 ' 'SR11BPM04:SA_VPOS_MONITOR' 1 [11,4] 74 ; ...
-'11BPMx5 ' 'SR11BPM05:SA_HPOS_MONITOR' 0 '11BPMy5 ' 'SR11BPM05:SA_VPOS_MONITOR' 0 [11,5] 75 ; ...
-'11BPMx6 ' 'SR11BPM06:SA_HPOS_MONITOR' 1 '11BPMy6 ' 'SR11BPM06:SA_VPOS_MONITOR' 1 [11,6] 76 ; ...
-'11BPMx7 ' 'SR11BPM07:SA_HPOS_MONITOR' 1 '11BPMy7 ' 'SR11BPM07:SA_VPOS_MONITOR' 1 [11,7] 77 ; ...
-'12BPMx1 ' 'SR12BPM01:SA_HPOS_MONITOR' 1 '12BPMy1 ' 'SR12BPM01:SA_VPOS_MONITOR' 1 [12,1] 78 ; ...
-'12BPMx2 ' 'SR12BPM02:SA_HPOS_MONITOR' 1 '12BPMy2 ' 'SR12BPM02:SA_VPOS_MONITOR' 1 [12,2] 79 ; ...
-'12BPMx3 ' 'SR12BPM03:SA_HPOS_MONITOR' 1 '12BPMy3 ' 'SR12BPM03:SA_VPOS_MONITOR' 1 [12,3] 80 ; ...
-'12BPMx4 ' 'SR12BPM04:SA_HPOS_MONITOR' 1 '12BPMy4 ' 'SR12BPM04:SA_VPOS_MONITOR' 1 [12,4] 81 ; ...
-'12BPMx5 ' 'SR12BPM05:SA_HPOS_MONITOR' 1 '12BPMy5 ' 'SR12BPM05:SA_VPOS_MONITOR' 1 [12,5] 82 ; ...
-'12BPMx6 ' 'SR12BPM06:SA_HPOS_MONITOR' 1 '12BPMy6 ' 'SR12BPM06:SA_VPOS_MONITOR' 1 [12,6] 83 ; ...
-'12BPMx7 ' 'SR12BPM07:SA_HPOS_MONITOR' 1 '12BPMy7 ' 'SR12BPM07:SA_VPOS_MONITOR' 1 [12,7] 84 ; ...
-'13BPMx1 ' 'SR13BPM01:SA_HPOS_MONITOR' 1 '13BPMy1 ' 'SR13BPM01:SA_VPOS_MONITOR' 1 [13,1] 85 ; ...
-'13BPMx2 ' 'SR13BPM02:SA_HPOS_MONITOR' 1 '13BPMy2 ' 'SR13BPM02:SA_VPOS_MONITOR' 1 [13,2] 86 ; ...
-'13BPMx3 ' 'SR13BPM03:SA_HPOS_MONITOR' 1 '13BPMy3 ' 'SR13BPM03:SA_VPOS_MONITOR' 1 [13,3] 87 ; ...
-'13BPMx4 ' 'SR13BPM04:SA_HPOS_MONITOR' 1 '13BPMy4 ' 'SR13BPM04:SA_VPOS_MONITOR' 1 [13,4] 88 ; ...
-'13BPMx5 ' 'SR13BPM05:SA_HPOS_MONITOR' 1 '13BPMy5 ' 'SR13BPM05:SA_VPOS_MONITOR' 1 [13,5] 89 ; ...
-'13BPMx6 ' 'SR13BPM06:SA_HPOS_MONITOR' 0 '13BPMy6 ' 'SR13BPM06:SA_VPOS_MONITOR' 0 [13,6] 90 ; ...
-'13BPMx7 ' 'SR13BPM07:SA_HPOS_MONITOR' 1 '13BPMy7 ' 'SR13BPM07:SA_VPOS_MONITOR' 1 [13,7] 91 ; ...
-'14BPMx1 ' 'SR14BPM01:SA_HPOS_MONITOR' 1 '14BPMy1 ' 'SR14BPM01:SA_VPOS_MONITOR' 1 [14,1] 92 ; ...
-'14BPMx2 ' 'SR14BPM02:SA_HPOS_MONITOR' 1 '14BPMy2 ' 'SR14BPM02:SA_VPOS_MONITOR' 1 [14,2] 93 ; ...
-'14BPMx3 ' 'SR14BPM03:SA_HPOS_MONITOR' 1 '14BPMy3 ' 'SR14BPM03:SA_VPOS_MONITOR' 1 [14,3] 94 ; ...
-'14BPMx4 ' 'SR14BPM04:SA_HPOS_MONITOR' 1 '14BPMy4 ' 'SR14BPM04:SA_VPOS_MONITOR' 1 [14,4] 95 ; ...
-'14BPMx5 ' 'SR14BPM05:SA_HPOS_MONITOR' 1 '14BPMy5 ' 'SR14BPM05:SA_VPOS_MONITOR' 1 [14,5] 96 ; ...
-'14BPMx6 ' 'SR14BPM06:SA_HPOS_MONITOR' 1 '14BPMy6 ' 'SR14BPM06:SA_VPOS_MONITOR' 1 [14,6] 97 ; ...
-'14BPMx7 ' 'SR14BPM07:SA_HPOS_MONITOR' 1 '14BPMy7 ' 'SR14BPM07:SA_VPOS_MONITOR' 1 [14,7] 98 ; ...
-};
-
-%Load fields from data block
-for ii=1:size(bpm,1)
-name=bpm{ii,1}; AO.BPMx.CommonNames(ii,:) = name;
-name=bpm{ii,2}; AO.BPMx.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,3}; AO.BPMx.Status(ii,:) = val;
-name=bpm{ii,4}; AO.BPMy.CommonNames(ii,:) = name;
-name=bpm{ii,5}; AO.BPMy.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,6}; AO.BPMy.Status(ii,:) = val;
-val =bpm{ii,7}; AO.BPMx.DeviceList(ii,:) = val;
- AO.BPMy.DeviceList(ii,:) = val;
-val =bpm{ii,8}; AO.BPMx.ElementList(ii,:) = val;
- AO.BPMy.ElementList(ii,:) = val;
- AO.BPMx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.BPMx.Monitor.Physics2HWParams(ii,:) = 1000;
- AO.BPMy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.BPMy.Monitor.Physics2HWParams(ii,:) = 1000;
-end
-
-
-% % Get sum value from button. Don't need handles and PV namelist as
-% % parameters are the same as the 'monitor' subcategory.
-% AO.BPMx.Sum.Monitor = AO.BPMx.Monitor;
-% AO.BPMx.Sum.SpecialFunction = 'getbpmsumspear';
-% AO.BPMx.Sum.HWUnits = 'ADC Counts';
-% AO.BPMx.Sum.PhysicsUnits = 'ADC Counts';
-% AO.BPMx.Sum.HW2PhysicsParams = 1;
-% AO.BPMx.Sum.Physics2HWParams = 1;
-% % Get q value from BPMs. Don't need handles and PV namelist.
-% AO.BPMx.Q = AO.BPMx.Monitor;
-% AO.BPMx.Q.SpecialFunction = 'getbpmqspear';
-% AO.BPMx.Q.HWUnits = 'mm';
-% AO.BPMx.Q.PhysicsUnits = 'meter';
-% AO.BPMx.Q.HW2PhysicsParams = 1e-3;
-% AO.BPMx.Q.Physics2HWParams = 1000;
-%
-% % Definition above for horiz0ontal. Replicate for vertical.
-% AO.BPMy.Sum = AO.BPMx.Sum;
-% AO.BPMy.Q = AO.BPMx.Q;
-
-
-
-%=============================================
-% First Turn BPM data from Libera
-%=============================================
-ntbpm=98;
-AO.FTx.FamilyName = 'FTx'; dispobject(AO,AO.FTx.FamilyName);
-AO.FTx.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
-AO.FTx.Monitor.Mode = Mode;
-AO.FTx.Monitor.DataType = 'Scalar';
-AO.FTx.Monitor.Units = 'Hardware';
-AO.FTx.Monitor.HWUnits = 'mm';
-AO.FTx.Monitor.PhysicsUnits = 'meter';
-
-AO.FTy.FamilyName = 'FTy'; dispobject(AO,AO.FTy.FamilyName);
-AO.FTy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
-AO.FTy.Monitor.Mode = Mode;
-AO.FTy.Monitor.DataType = 'Scalar';
-AO.FTy.Monitor.Units = 'Hardware';
-AO.FTy.Monitor.HWUnits = 'mm';
-AO.FTy.Monitor.PhysicsUnits = 'meter';
-
-% x-name x-chname xstat y-name y-chname ystat DevList Elem
-bpm={
-'1FTx1 ' 'SR01BPM01:FT_HPOS_MONITOR' 1 '1BPMy1 ' 'SR01BPM01:FT_VPOS_MONITOR' 1 [1,1] 1 ; ...
-'1FTx2 ' 'SR01BPM02:FT_HPOS_MONITOR' 1 '1BPMy2 ' 'SR01BPM02:FT_VPOS_MONITOR' 1 [1,2] 2 ; ...
-'1FTx3 ' 'SR01BPM03:FT_HPOS_MONITOR' 1 '1BPMy3 ' 'SR01BPM03:FT_VPOS_MONITOR' 1 [1,3] 3 ; ...
-'1FTx4 ' 'SR01BPM04:FT_HPOS_MONITOR' 1 '1BPMy4 ' 'SR01BPM04:FT_VPOS_MONITOR' 1 [1,4] 4 ; ...
-'1FTx5 ' 'SR01BPM05:FT_HPOS_MONITOR' 1 '1BPMy5 ' 'SR01BPM05:FT_VPOS_MONITOR' 1 [1,5] 5 ; ...
-'1FTx6 ' 'SR01BPM06:FT_HPOS_MONITOR' 1 '1BPMy6 ' 'SR01BPM06:FT_VPOS_MONITOR' 1 [1,6] 6 ; ...
-'1FTx7 ' 'SR01BPM07:FT_HPOS_MONITOR' 1 '1BPMy7 ' 'SR01BPM07:FT_VPOS_MONITOR' 1 [1,7] 7 ; ...
-'2FTx1 ' 'SR02BPM01:FT_HPOS_MONITOR' 1 '2BPMy1 ' 'SR02BPM01:FT_VPOS_MONITOR' 1 [2,1] 8 ; ...
-'2FTx2 ' 'SR02BPM02:FT_HPOS_MONITOR' 1 '2BPMy2 ' 'SR02BPM02:FT_VPOS_MONITOR' 1 [2,2] 9 ; ...
-'2FTx3 ' 'SR02BPM03:FT_HPOS_MONITOR' 1 '2BPMy3 ' 'SR02BPM03:FT_VPOS_MONITOR' 1 [2,3] 10 ; ...
-'2FTx4 ' 'SR02BPM04:FT_HPOS_MONITOR' 1 '2BPMy4 ' 'SR02BPM04:FT_VPOS_MONITOR' 1 [2,4] 11 ; ...
-'2FTx5 ' 'SR02BPM05:FT_HPOS_MONITOR' 1 '2BPMy5 ' 'SR02BPM05:FT_VPOS_MONITOR' 1 [2,5] 12 ; ...
-'2FTx6 ' 'SR02BPM06:FT_HPOS_MONITOR' 1 '2BPMy6 ' 'SR02BPM06:FT_VPOS_MONITOR' 1 [2,6] 13 ; ...
-'2FTx7 ' 'SR02BPM07:FT_HPOS_MONITOR' 1 '2BPMy7 ' 'SR02BPM07:FT_VPOS_MONITOR' 1 [2,7] 14 ; ...
-'3FTx1 ' 'SR03BPM01:FT_HPOS_MONITOR' 1 '3BPMy1 ' 'SR03BPM01:FT_VPOS_MONITOR' 1 [3,1] 15 ; ...
-'3FTx2 ' 'SR03BPM02:FT_HPOS_MONITOR' 1 '3BPMy2 ' 'SR03BPM02:FT_VPOS_MONITOR' 1 [3,2] 16 ; ...
-'3FTx3 ' 'SR03BPM03:FT_HPOS_MONITOR' 1 '3BPMy3 ' 'SR03BPM03:FT_VPOS_MONITOR' 1 [3,3] 17 ; ...
-'3FTx4 ' 'SR03BPM04:FT_HPOS_MONITOR' 1 '3BPMy4 ' 'SR03BPM04:FT_VPOS_MONITOR' 1 [3,4] 18 ; ...
-'3FTx5 ' 'SR03BPM05:FT_HPOS_MONITOR' 1 '3BPMy5 ' 'SR03BPM05:FT_VPOS_MONITOR' 1 [3,5] 19 ; ...
-'3FTx6 ' 'SR03BPM06:FT_HPOS_MONITOR' 1 '3BPMy6 ' 'SR03BPM06:FT_VPOS_MONITOR' 1 [3,6] 20 ; ...
-'3FTx7 ' 'SR03BPM07:FT_HPOS_MONITOR' 1 '3BPMy7 ' 'SR03BPM07:FT_VPOS_MONITOR' 1 [3,7] 21 ; ...
-'4FTx1 ' 'SR04BPM01:FT_HPOS_MONITOR' 1 '4BPMy1 ' 'SR04BPM01:FT_VPOS_MONITOR' 1 [4,1] 22 ; ...
-'4FTx2 ' 'SR04BPM02:FT_HPOS_MONITOR' 1 '4BPMy2 ' 'SR04BPM02:FT_VPOS_MONITOR' 1 [4,2] 23 ; ...
-'4FTx3 ' 'SR04BPM03:FT_HPOS_MONITOR' 1 '4BPMy3 ' 'SR04BPM03:FT_VPOS_MONITOR' 1 [4,3] 24 ; ...
-'4FTx4 ' 'SR04BPM04:FT_HPOS_MONITOR' 1 '4BPMy4 ' 'SR04BPM04:FT_VPOS_MONITOR' 1 [4,4] 25 ; ...
-'4FTx5 ' 'SR04BPM05:FT_HPOS_MONITOR' 1 '4BPMy5 ' 'SR04BPM05:FT_VPOS_MONITOR' 1 [4,5] 26 ; ...
-'4FTx6 ' 'SR04BPM06:FT_HPOS_MONITOR' 1 '4BPMy6 ' 'SR04BPM06:FT_VPOS_MONITOR' 1 [4,6] 27 ; ...
-'4FTx7 ' 'SR04BPM07:FT_HPOS_MONITOR' 1 '4BPMy7 ' 'SR04BPM07:FT_VPOS_MONITOR' 1 [4,7] 28 ; ...
-'5FTx1 ' 'SR05BPM01:FT_HPOS_MONITOR' 1 '5BPMy1 ' 'SR05BPM01:FT_VPOS_MONITOR' 1 [5,1] 29 ; ...
-'5FTx2 ' 'SR05BPM02:FT_HPOS_MONITOR' 1 '5BPMy2 ' 'SR05BPM02:FT_VPOS_MONITOR' 1 [5,2] 30 ; ...
-'5FTx3 ' 'SR05BPM03:FT_HPOS_MONITOR' 1 '5BPMy3 ' 'SR05BPM03:FT_VPOS_MONITOR' 1 [5,3] 31 ; ...
-'5FTx4 ' 'SR05BPM04:FT_HPOS_MONITOR' 1 '5BPMy4 ' 'SR05BPM04:FT_VPOS_MONITOR' 1 [5,4] 32 ; ...
-'5FTx5 ' 'SR05BPM05:FT_HPOS_MONITOR' 1 '5BPMy5 ' 'SR05BPM05:FT_VPOS_MONITOR' 1 [5,5] 33 ; ...
-'5FTx6 ' 'SR05BPM06:FT_HPOS_MONITOR' 1 '5BPMy6 ' 'SR05BPM06:FT_VPOS_MONITOR' 1 [5,6] 34 ; ...
-'5FTx7 ' 'SR05BPM07:FT_HPOS_MONITOR' 1 '5BPMy7 ' 'SR05BPM07:FT_VPOS_MONITOR' 1 [5,7] 35 ; ...
-'6FTx1 ' 'SR06BPM01:FT_HPOS_MONITOR' 1 '6BPMy1 ' 'SR06BPM01:FT_VPOS_MONITOR' 1 [6,1] 36 ; ...
-'6FTx2 ' 'SR06BPM02:FT_HPOS_MONITOR' 1 '6BPMy2 ' 'SR06BPM02:FT_VPOS_MONITOR' 1 [6,2] 37 ; ...
-'6FTx3 ' 'SR06BPM03:FT_HPOS_MONITOR' 1 '6BPMy3 ' 'SR06BPM03:FT_VPOS_MONITOR' 1 [6,3] 38 ; ...
-'6FTx4 ' 'SR06BPM04:FT_HPOS_MONITOR' 1 '6BPMy4 ' 'SR06BPM04:FT_VPOS_MONITOR' 1 [6,4] 39 ; ...
-'6FTx5 ' 'SR06BPM05:FT_HPOS_MONITOR' 1 '6BPMy5 ' 'SR06BPM05:FT_VPOS_MONITOR' 1 [6,5] 40 ; ...
-'6FTx6 ' 'SR06BPM06:FT_HPOS_MONITOR' 1 '6BPMy6 ' 'SR06BPM06:FT_VPOS_MONITOR' 1 [6,6] 41 ; ...
-'6FTx7 ' 'SR06BPM07:FT_HPOS_MONITOR' 1 '6BPMy7 ' 'SR06BPM07:FT_VPOS_MONITOR' 1 [6,7] 42 ; ...
-'7FTx1 ' 'SR07BPM01:FT_HPOS_MONITOR' 1 '7BPMy1 ' 'SR07BPM01:FT_VPOS_MONITOR' 1 [7,1] 43 ; ...
-'7FTx2 ' 'SR07BPM02:FT_HPOS_MONITOR' 1 '7BPMy2 ' 'SR07BPM02:FT_VPOS_MONITOR' 1 [7,2] 44 ; ...
-'7FTx3 ' 'SR07BPM03:FT_HPOS_MONITOR' 1 '7BPMy3 ' 'SR07BPM03:FT_VPOS_MONITOR' 1 [7,3] 45 ; ...
-'7FTx4 ' 'SR07BPM04:FT_HPOS_MONITOR' 1 '7BPMy4 ' 'SR07BPM04:FT_VPOS_MONITOR' 1 [7,4] 46 ; ...
-'7FTx5 ' 'SR07BPM05:FT_HPOS_MONITOR' 1 '7BPMy5 ' 'SR07BPM05:FT_VPOS_MONITOR' 1 [7,5] 47 ; ...
-'7FTx6 ' 'SR07BPM06:FT_HPOS_MONITOR' 1 '7BPMy6 ' 'SR07BPM06:FT_VPOS_MONITOR' 1 [7,6] 48 ; ...
-'7FTx7 ' 'SR07BPM07:FT_HPOS_MONITOR' 1 '7BPMy7 ' 'SR07BPM07:FT_VPOS_MONITOR' 1 [7,7] 49 ; ...
-'8FTx1 ' 'SR08BPM01:FT_HPOS_MONITOR' 1 '8BPMy1 ' 'SR08BPM01:FT_VPOS_MONITOR' 1 [8,1] 50 ; ...
-'8FTx2 ' 'SR08BPM02:FT_HPOS_MONITOR' 1 '8BPMy2 ' 'SR08BPM02:FT_VPOS_MONITOR' 1 [8,2] 51 ; ...
-'8FTx3 ' 'SR08BPM03:FT_HPOS_MONITOR' 1 '8BPMy3 ' 'SR08BPM03:FT_VPOS_MONITOR' 1 [8,3] 52 ; ...
-'8FTx4 ' 'SR08BPM04:FT_HPOS_MONITOR' 1 '8BPMy4 ' 'SR08BPM04:FT_VPOS_MONITOR' 1 [8,4] 53 ; ...
-'8FTx5 ' 'SR08BPM05:FT_HPOS_MONITOR' 1 '8BPMy5 ' 'SR08BPM05:FT_VPOS_MONITOR' 1 [8,5] 54 ; ...
-'8FTx6 ' 'SR08BPM06:FT_HPOS_MONITOR' 1 '8BPMy6 ' 'SR08BPM06:FT_VPOS_MONITOR' 1 [8,6] 55 ; ...
-'8FTx7 ' 'SR08BPM07:FT_HPOS_MONITOR' 1 '8BPMy7 ' 'SR08BPM07:FT_VPOS_MONITOR' 1 [8,7] 56 ; ...
-'9FTx1 ' 'SR09BPM01:FT_HPOS_MONITOR' 1 '9BPMy1 ' 'SR09BPM01:FT_VPOS_MONITOR' 1 [9,1] 57 ; ...
-'9FTx2 ' 'SR09BPM02:FT_HPOS_MONITOR' 1 '9BPMy2 ' 'SR09BPM02:FT_VPOS_MONITOR' 1 [9,2] 58 ; ...
-'9FTx3 ' 'SR09BPM03:FT_HPOS_MONITOR' 1 '9BPMy3 ' 'SR09BPM03:FT_VPOS_MONITOR' 1 [9,3] 59 ; ...
-'9FTx4 ' 'SR09BPM04:FT_HPOS_MONITOR' 1 '9BPMy4 ' 'SR09BPM04:FT_VPOS_MONITOR' 1 [9,4] 60 ; ...
-'9FTx5 ' 'SR09BPM05:FT_HPOS_MONITOR' 1 '9BPMy5 ' 'SR09BPM05:FT_VPOS_MONITOR' 1 [9,5] 61 ; ...
-'9FTx6 ' 'SR09BPM06:FT_HPOS_MONITOR' 1 '9BPMy6 ' 'SR09BPM06:FT_VPOS_MONITOR' 1 [9,6] 62 ; ...
-'9FTx7 ' 'SR09BPM07:FT_HPOS_MONITOR' 1 '9BPMy7 ' 'SR09BPM07:FT_VPOS_MONITOR' 1 [9,7] 63 ; ...
-'10FTx1 ' 'SR10BPM01:FT_HPOS_MONITOR' 1 '10BPMy1 ' 'SR10BPM01:FT_VPOS_MONITOR' 1 [10,1] 64 ; ...
-'10FTx2 ' 'SR10BPM02:FT_HPOS_MONITOR' 1 '10BPMy2 ' 'SR10BPM02:FT_VPOS_MONITOR' 1 [10,2] 65 ; ...
-'10FTx3 ' 'SR10BPM03:FT_HPOS_MONITOR' 1 '10BPMy3 ' 'SR10BPM03:FT_VPOS_MONITOR' 1 [10,3] 66 ; ...
-'10FTx4 ' 'SR10BPM04:FT_HPOS_MONITOR' 1 '10BPMy4 ' 'SR10BPM04:FT_VPOS_MONITOR' 1 [10,4] 67 ; ...
-'10FTx5 ' 'SR10BPM05:FT_HPOS_MONITOR' 1 '10BPMy5 ' 'SR10BPM05:FT_VPOS_MONITOR' 1 [10,5] 68 ; ...
-'10FTx6 ' 'SR10BPM06:FT_HPOS_MONITOR' 1 '10BPMy6 ' 'SR10BPM06:FT_VPOS_MONITOR' 1 [10,6] 69 ; ...
-'10FTx7 ' 'SR10BPM07:FT_HPOS_MONITOR' 1 '10BPMy7 ' 'SR10BPM07:FT_VPOS_MONITOR' 1 [10,7] 70 ; ...
-'11FTx1 ' 'SR11BPM01:FT_HPOS_MONITOR' 1 '11BPMy1 ' 'SR11BPM01:FT_VPOS_MONITOR' 1 [11,1] 71 ; ...
-'11FTx2 ' 'SR11BPM02:FT_HPOS_MONITOR' 1 '11BPMy2 ' 'SR11BPM02:FT_VPOS_MONITOR' 1 [11,2] 72 ; ...
-'11FTx3 ' 'SR11BPM03:FT_HPOS_MONITOR' 1 '11BPMy3 ' 'SR11BPM03:FT_VPOS_MONITOR' 1 [11,3] 73 ; ...
-'11FTx4 ' 'SR11BPM04:FT_HPOS_MONITOR' 1 '11BPMy4 ' 'SR11BPM04:FT_VPOS_MONITOR' 1 [11,4] 74 ; ...
-'11FTx5 ' 'SR11BPM05:FT_HPOS_MONITOR' 1 '11BPMy5 ' 'SR11BPM05:FT_VPOS_MONITOR' 1 [11,5] 75 ; ...
-'11FTx6 ' 'SR11BPM06:FT_HPOS_MONITOR' 1 '11BPMy6 ' 'SR11BPM06:FT_VPOS_MONITOR' 1 [11,6] 76 ; ...
-'11FTx7 ' 'SR11BPM07:FT_HPOS_MONITOR' 1 '11BPMy7 ' 'SR11BPM07:FT_VPOS_MONITOR' 1 [11,7] 77 ; ...
-'12FTx1 ' 'SR12BPM01:FT_HPOS_MONITOR' 1 '12BPMy1 ' 'SR12BPM01:FT_VPOS_MONITOR' 1 [12,1] 78 ; ...
-'12FTx2 ' 'SR12BPM02:FT_HPOS_MONITOR' 1 '12BPMy2 ' 'SR12BPM02:FT_VPOS_MONITOR' 1 [12,2] 79 ; ...
-'12FTx3 ' 'SR12BPM03:FT_HPOS_MONITOR' 1 '12BPMy3 ' 'SR12BPM03:FT_VPOS_MONITOR' 1 [12,3] 80 ; ...
-'12FTx4 ' 'SR12BPM04:FT_HPOS_MONITOR' 1 '12BPMy4 ' 'SR12BPM04:FT_VPOS_MONITOR' 1 [12,4] 81 ; ...
-'12FTx5 ' 'SR12BPM05:FT_HPOS_MONITOR' 1 '12BPMy5 ' 'SR12BPM05:FT_VPOS_MONITOR' 1 [12,5] 82 ; ...
-'12FTx6 ' 'SR12BPM06:FT_HPOS_MONITOR' 1 '12BPMy6 ' 'SR12BPM06:FT_VPOS_MONITOR' 1 [12,6] 83 ; ...
-'12FTx7 ' 'SR12BPM07:FT_HPOS_MONITOR' 1 '12BPMy7 ' 'SR12BPM07:FT_VPOS_MONITOR' 1 [12,7] 84 ; ...
-'13FTx1 ' 'SR13BPM01:FT_HPOS_MONITOR' 1 '13BPMy1 ' 'SR13BPM01:FT_VPOS_MONITOR' 1 [13,1] 85 ; ...
-'13FTx2 ' 'SR13BPM02:FT_HPOS_MONITOR' 1 '13BPMy2 ' 'SR13BPM02:FT_VPOS_MONITOR' 1 [13,2] 86 ; ...
-'13FTx3 ' 'SR13BPM03:FT_HPOS_MONITOR' 1 '13BPMy3 ' 'SR13BPM03:FT_VPOS_MONITOR' 1 [13,3] 87 ; ...
-'13FTx4 ' 'SR13BPM04:FT_HPOS_MONITOR' 1 '13BPMy4 ' 'SR13BPM04:FT_VPOS_MONITOR' 1 [13,4] 88 ; ...
-'13FTx5 ' 'SR13BPM05:FT_HPOS_MONITOR' 1 '13BPMy5 ' 'SR13BPM05:FT_VPOS_MONITOR' 1 [13,5] 89 ; ...
-'13FTx6 ' 'SR13BPM06:FT_HPOS_MONITOR' 1 '13BPMy6 ' 'SR13BPM06:FT_VPOS_MONITOR' 1 [13,6] 90 ; ...
-'13FTx7 ' 'SR13BPM07:FT_HPOS_MONITOR' 1 '13BPMy7 ' 'SR13BPM07:FT_VPOS_MONITOR' 1 [13,7] 91 ; ...
-'14FTx1 ' 'SR14BPM01:FT_HPOS_MONITOR' 1 '14BPMy1 ' 'SR14BPM01:FT_VPOS_MONITOR' 1 [14,1] 92 ; ...
-'14FTx2 ' 'SR14BPM02:FT_HPOS_MONITOR' 1 '14BPMy2 ' 'SR14BPM02:FT_VPOS_MONITOR' 1 [14,2] 93 ; ...
-'14FTx3 ' 'SR14BPM03:FT_HPOS_MONITOR' 1 '14BPMy3 ' 'SR14BPM03:FT_VPOS_MONITOR' 1 [14,3] 94 ; ...
-'14FTx4 ' 'SR14BPM04:FT_HPOS_MONITOR' 1 '14BPMy4 ' 'SR14BPM04:FT_VPOS_MONITOR' 1 [14,4] 95 ; ...
-'14FTx5 ' 'SR14BPM05:FT_HPOS_MONITOR' 1 '14BPMy5 ' 'SR14BPM05:FT_VPOS_MONITOR' 1 [14,5] 96 ; ...
-'14FTx6 ' 'SR14BPM06:FT_HPOS_MONITOR' 1 '14BPMy6 ' 'SR14BPM06:FT_VPOS_MONITOR' 1 [14,6] 97 ; ...
-'14FTx7 ' 'SR14BPM07:FT_HPOS_MONITOR' 1 '14BPMy7 ' 'SR14BPM07:FT_VPOS_MONITOR' 1 [14,7] 98 ; ...
-};
-
-%Load fields from data block
-for ii=1:size(bpm,1)
-name=bpm{ii,1}; AO.FTx.CommonNames(ii,:) = name;
-name=bpm{ii,2}; AO.FTx.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,3}; AO.FTx.Status(ii,:) = val;
-name=bpm{ii,4}; AO.FTy.CommonNames(ii,:) = name;
-name=bpm{ii,5}; AO.FTy.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,6}; AO.FTy.Status(ii,:) = val;
-val =bpm{ii,7}; AO.FTx.DeviceList(ii,:) = val;
- AO.FTy.DeviceList(ii,:) = val;
-val =bpm{ii,8}; AO.FTx.ElementList(ii,:) = val;
- AO.FTy.ElementList(ii,:) = val;
- AO.FTx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.FTx.Monitor.Physics2HWParams(ii,:) = 1000;
- AO.FTy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.FTy.Monitor.Physics2HWParams(ii,:) = 1000;
-end
-AO.FTx.Status = AO.BPMx.Status;
-AO.FTy.Status = AO.BPMy.Status;
-
-AO.FTsum = AO.FTx;
-AO.FTsum.FamilyName = 'FTsum'; dispobject(AO,AO.FTsum.FamilyName);
-AO.FTsum.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
-AO.FTsum.Monitor.Mode = 'Special';
-AO.FTsum.Monitor.Units = 'Hardware';
-AO.FTsum.Monitor.DataType = 'Scalar';
-AO.FTsum.Monitor.SpecialFunction = 'getftsum';
-AO.FTsum.Monitor.HWUnits = 'ADC counts';
-AO.FTsum.Monitor.PhysicsUnits = 'ADC counts';
-AO.FTsum.Monitor.HW2PhysicsParams(:) = 1;
-AO.FTsum.Monitor.Physics2HWParams(:) = 1;
-
-
-% % Get sum value from button. Don't need handles and PV namelist as
-% % parameters are the same as the 'monitor' subcategory.
-AO.FTx.Off.Mode = 'Special';
-AO.FTx.Off.Units = 'Hardware';
-AO.FTx.Off.DataType = 'Scalar';
-AO.FTx.Off.SpecialFunction = 'getftoffset';
-AO.FTx.Off.SpecialFunctionSet = 'setftoffset';
-AO.FTx.Off.HWUnits = '32ns samples';
-AO.FTx.Off.PhysicsUnits = '32ns samples';
-AO.FTx.Off.HW2PhysicsParams = 1;
-AO.FTx.Off.Physics2HWParams = 1;
-
-AO.FTx.Length.Mode = 'Special';
-AO.FTx.Length.Units = 'Hardware';
-AO.FTx.Length.DataType = 'Scalar';
-AO.FTx.Length.SpecialFunction = 'getftlength';
-AO.FTx.Length.SpecialFunctionSet = 'setftlength';
-AO.FTx.Length.HWUnits = '32ns samples';
-AO.FTx.Length.PhysicsUnits = '32ns samples';
-AO.FTx.Length.HW2PhysicsParams = 1;
-AO.FTx.Length.Physics2HWParams = 1;
-
-AO.FTx.Maxadc.Mode = 'Special';
-AO.FTx.Maxadc.Units = 'Hardware';
-AO.FTx.Maxadc.DataType = 'Scalar';
-AO.FTx.Maxadc.SpecialFunction = 'getftmaxadc';
-AO.FTx.Maxadc.HWUnits = 'ADC counts';
-AO.FTx.Maxadc.PhysicsUnits = 'ADC counts';
-AO.FTx.Maxadc.HW2PhysicsParams = 1;
-AO.FTx.Maxadc.Physics2HWParams = 1;
-
-% AO.FTx.Sum.Mode = 'Special';
-% AO.FTx.Sum.Units = 'Hardware';
-% AO.FTx.Sum.DataType = 'Scalar';
-% AO.FTx.Sum.SpecialFunction = 'getftsum';
-% AO.FTx.Sum.HWUnits = 'ADC counts';
-% AO.FTx.Sum.PhysicsUnits = 'ADC counts';
-% AO.FTx.Sum.HW2PhysicsParams = 1;
-% AO.FTx.Sum.Physics2HWParams = 1;
-
-
-%===========================================================
-% Corrector data: status field designates if corrector in use
-% ASP corrector coils wound into sextupoles. Not dynamic correctors.
-%===========================================================
-
-AO.HCM.FamilyName = 'HCM'; dispobject(AO,AO.HCM.FamilyName);
-AO.HCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'HCM'; 'Magnet'};
-
-AO.HCM.Monitor.Mode = Mode;
-AO.HCM.Monitor.DataType = 'Scalar';
-AO.HCM.Monitor.Units = 'Hardware';
-AO.HCM.Monitor.HWUnits = 'ampere';
-AO.HCM.Monitor.PhysicsUnits = 'radian';
-AO.HCM.Monitor.HW2PhysicsFcn = @amp2k;
-AO.HCM.Monitor.Physics2HWFcn = @k2amp;
-
-AO.HCM.Setpoint.Mode = Mode;
-AO.HCM.Setpoint.DataType = 'Scalar';
-AO.HCM.Setpoint.Units = 'Hardware';
-AO.HCM.Setpoint.HWUnits = 'ampere';
-AO.HCM.Setpoint.PhysicsUnits = 'radian';
-AO.HCM.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.HCM.Setpoint.Physics2HWFcn = @k2amp;
-
-% HW in ampere, Physics in radian. Respmat settings below AO definitions.
-% x-common x-monitor x-setpoint stat devlist elem tol
-cor={
-'1HCM1 ' 'SR01CPS01:CURRENT_MONITOR' 'SR01CPS01:CURRENT_SP ' 1 [1,1] 1 1.000 ; ...
-'1HCM2 ' 'SR01CPS05:CURRENT_MONITOR' 'SR01CPS05:CURRENT_SP ' 1 [1,2] 2 1.000 ; ...
-'1HCM3 ' 'SR01CPS09:CURRENT_MONITOR' 'SR01CPS09:CURRENT_SP ' 1 [1,3] 3 1.000 ; ...
-'2HCM1 ' 'SR02CPS01:CURRENT_MONITOR' 'SR02CPS01:CURRENT_SP ' 1 [2,1] 4 1.000 ; ...
-'2HCM2 ' 'SR02CPS05:CURRENT_MONITOR' 'SR02CPS05:CURRENT_SP ' 1 [2,2] 5 1.000 ; ...
-'2HCM3 ' 'SR02CPS09:CURRENT_MONITOR' 'SR02CPS09:CURRENT_SP ' 1 [2,3] 6 1.000 ; ...
-'3HCM1 ' 'SR03CPS01:CURRENT_MONITOR' 'SR03CPS01:CURRENT_SP ' 1 [3,1] 7 1.000 ; ...
-'3HCM2 ' 'SR03CPS05:CURRENT_MONITOR' 'SR03CPS05:CURRENT_SP ' 1 [3,2] 8 1.000 ; ...
-'3HCM3 ' 'SR03CPS09:CURRENT_MONITOR' 'SR03CPS09:CURRENT_SP ' 1 [3,3] 9 1.000 ; ...
-'4HCM1 ' 'SR04CPS01:CURRENT_MONITOR' 'SR04CPS01:CURRENT_SP ' 1 [4,1] 10 1.000 ; ...
-'4HCM2 ' 'SR04CPS05:CURRENT_MONITOR' 'SR04CPS05:CURRENT_SP ' 1 [4,2] 11 1.000 ; ...
-'4HCM3 ' 'SR04CPS09:CURRENT_MONITOR' 'SR04CPS09:CURRENT_SP ' 1 [4,3] 12 1.000 ; ...
-'5HCM1 ' 'SR05CPS01:CURRENT_MONITOR' 'SR05CPS01:CURRENT_SP ' 1 [5,1] 13 1.000 ; ...
-'5HCM2 ' 'SR05CPS05:CURRENT_MONITOR' 'SR05CPS05:CURRENT_SP ' 1 [5,2] 14 1.000 ; ...
-'5HCM3 ' 'SR05CPS09:CURRENT_MONITOR' 'SR05CPS09:CURRENT_SP ' 1 [5,3] 15 1.000 ; ...
-'6HCM1 ' 'SR06CPS01:CURRENT_MONITOR' 'SR06CPS01:CURRENT_SP ' 1 [6,1] 16 1.000 ; ...
-'6HCM2 ' 'SR06CPS05:CURRENT_MONITOR' 'SR06CPS05:CURRENT_SP ' 1 [6,2] 17 1.000 ; ...
-'6HCM3 ' 'SR06CPS09:CURRENT_MONITOR' 'SR06CPS09:CURRENT_SP ' 1 [6,3] 18 1.000 ; ...
-'7HCM1 ' 'SR07CPS01:CURRENT_MONITOR' 'SR07CPS01:CURRENT_SP ' 1 [7,1] 19 1.000 ; ...
-'7HCM2 ' 'SR07CPS05:CURRENT_MONITOR' 'SR07CPS05:CURRENT_SP ' 1 [7,2] 20 1.000 ; ...
-'7HCM3 ' 'SR07CPS09:CURRENT_MONITOR' 'SR07CPS09:CURRENT_SP ' 1 [7,3] 21 1.000 ; ...
-'8HCM1 ' 'SR08CPS01:CURRENT_MONITOR' 'SR08CPS01:CURRENT_SP ' 1 [8,1] 22 1.000 ; ...
-'8HCM2 ' 'SR08CPS05:CURRENT_MONITOR' 'SR08CPS05:CURRENT_SP ' 1 [8,2] 23 1.000 ; ...
-'8HCM3 ' 'SR08CPS09:CURRENT_MONITOR' 'SR08CPS09:CURRENT_SP ' 1 [8,3] 24 1.000 ; ...
-'9HCM1 ' 'SR09CPS01:CURRENT_MONITOR' 'SR09CPS01:CURRENT_SP ' 1 [9,1] 25 1.000 ; ...
-'9HCM2 ' 'SR09CPS05:CURRENT_MONITOR' 'SR09CPS05:CURRENT_SP ' 1 [9,2] 26 1.000 ; ...
-'9HCM3 ' 'SR09CPS09:CURRENT_MONITOR' 'SR09CPS09:CURRENT_SP ' 1 [9,3] 27 1.000 ; ...
-'10HCM1 ' 'SR10CPS01:CURRENT_MONITOR' 'SR10CPS01:CURRENT_SP ' 1 [10,1] 28 1.000 ; ...
-'10HCM2 ' 'SR10CPS05:CURRENT_MONITOR' 'SR10CPS05:CURRENT_SP ' 1 [10,2] 29 1.000 ; ...
-'10HCM3 ' 'SR10CPS09:CURRENT_MONITOR' 'SR10CPS09:CURRENT_SP ' 1 [10,3] 30 1.000 ; ...
-'11HCM1 ' 'SR11CPS01:CURRENT_MONITOR' 'SR11CPS01:CURRENT_SP ' 1 [11,1] 31 1.000 ; ...
-'11HCM2 ' 'SR11CPS05:CURRENT_MONITOR' 'SR11CPS05:CURRENT_SP ' 1 [11,2] 32 1.000 ; ...
-'11HCM3 ' 'SR11CPS09:CURRENT_MONITOR' 'SR11CPS09:CURRENT_SP ' 1 [11,3] 33 1.000 ; ...
-'12HCM1 ' 'SR12CPS01:CURRENT_MONITOR' 'SR12CPS01:CURRENT_SP ' 1 [12,1] 34 1.000 ; ...
-'12HCM2 ' 'SR12CPS05:CURRENT_MONITOR' 'SR12CPS05:CURRENT_SP ' 1 [12,2] 35 1.000 ; ...
-'12HCM3 ' 'SR12CPS09:CURRENT_MONITOR' 'SR12CPS09:CURRENT_SP ' 1 [12,3] 36 1.000 ; ...
-'13HCM1 ' 'SR13CPS01:CURRENT_MONITOR' 'SR13CPS01:CURRENT_SP ' 1 [13,1] 37 1.000 ; ...
-'13HCM2 ' 'SR13CPS05:CURRENT_MONITOR' 'SR13CPS05:CURRENT_SP ' 1 [13,2] 38 1.000 ; ...
-'13HCM3 ' 'SR13CPS09:CURRENT_MONITOR' 'SR13CPS09:CURRENT_SP ' 1 [13,3] 39 1.000 ; ...
-'14HCM1 ' 'SR14CPS01:CURRENT_MONITOR' 'SR14CPS01:CURRENT_SP ' 1 [14,1] 40 1.000 ; ...
-'14HCM2 ' 'SR14CPS05:CURRENT_MONITOR' 'SR14CPS05:CURRENT_SP ' 1 [14,2] 41 1.000 ; ...
-'14HCM3 ' 'SR14CPS09:CURRENT_MONITOR' 'SR14CPS09:CURRENT_SP ' 1 [14,3] 42 1.000 ; ...
-};
-
-[C, Leff, MagnetType] = magnetcoefficients('HCM');
-
-for ii=1:size(cor,1)
-name=cor{ii,1}; AO.HCM.CommonNames(ii,:) = name;
-name=cor{ii,2}; AO.HCM.Monitor.ChannelNames(ii,:) = name;
-name=cor{ii,3}; AO.HCM.Setpoint.ChannelNames(ii,:) = name;
-val =cor{ii,4}; AO.HCM.Status(ii,1) = val;
-val =cor{ii,5}; AO.HCM.DeviceList(ii,:) = val;
-val =cor{ii,6}; AO.HCM.ElementList(ii,1) = val;
-val =cor{ii,7}; AO.HCM.Setpoint.Tolerance(ii,1) = val;
-
-AO.HCM.Setpoint.Range(ii,:) = [-90 +90];
-AO.HCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
-AO.HCM.Monitor.Physics2HWParams{1}(ii,:) = C;
-AO.HCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
-AO.HCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
-end
-
-
-AO.VCM.FamilyName = 'VCM'; dispobject(AO,AO.VCM.FamilyName);
-AO.VCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'VCM'; 'Magnet'};
-
-AO.VCM.Monitor.Mode = Mode;
-AO.VCM.Monitor.DataType = 'Scalar';
-AO.VCM.Monitor.Units = 'Hardware';
-AO.VCM.Monitor.HWUnits = 'ampere';
-AO.VCM.Monitor.PhysicsUnits = 'radian';
-AO.VCM.Monitor.HW2PhysicsFcn = @amp2k;
-AO.VCM.Monitor.Physics2HWFcn = @k2amp;
-
-AO.VCM.Setpoint.Mode = Mode;
-AO.VCM.Setpoint.DataType = 'Scalar';
-AO.VCM.Setpoint.Units = 'Hardware';
-AO.VCM.Setpoint.HWUnits = 'ampere';
-AO.VCM.Setpoint.PhysicsUnits = 'radian';
-AO.VCM.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.VCM.Setpoint.Physics2HWFcn = @k2amp;
-
-% HW in ampere, Physics in radian ** radian units converted to ampere below ***
-% y-common y-monitor y-setpoint stat devlist elem
-cor={
-'1VCM1 ' 'SR01CPS02:CURRENT_MONITOR' 'SR01CPS02:CURRENT_SP ' 1 [1,1] 1 1.000 ; ...
-'1VCM2 ' 'SR01CPS04:CURRENT_MONITOR' 'SR01CPS04:CURRENT_SP ' 1 [1,2] 2 1.000 ; ...
-'1VCM3 ' 'SR01CPS06:CURRENT_MONITOR' 'SR01CPS06:CURRENT_SP ' 1 [1,3] 3 1.000 ; ...
-'1VCM4 ' 'SR01CPS07:CURRENT_MONITOR' 'SR01CPS07:CURRENT_SP ' 1 [1,4] 4 1.000 ; ...
-'2VCM1 ' 'SR02CPS02:CURRENT_MONITOR' 'SR02CPS02:CURRENT_SP ' 1 [2,1] 5 1.000 ; ...
-'2VCM2 ' 'SR02CPS04:CURRENT_MONITOR' 'SR02CPS04:CURRENT_SP ' 1 [2,2] 6 1.000 ; ...
-'2VCM3 ' 'SR02CPS06:CURRENT_MONITOR' 'SR02CPS06:CURRENT_SP ' 1 [2,3] 7 1.000 ; ...
-'2VCM4 ' 'SR02CPS07:CURRENT_MONITOR' 'SR02CPS07:CURRENT_SP ' 1 [2,4] 8 1.000 ; ...
-'3VCM1 ' 'SR03CPS02:CURRENT_MONITOR' 'SR03CPS02:CURRENT_SP ' 1 [3,1] 9 1.000 ; ...
-'3VCM2 ' 'SR03CPS04:CURRENT_MONITOR' 'SR03CPS04:CURRENT_SP ' 1 [3,2] 10 1.000 ; ...
-'3VCM3 ' 'SR03CPS06:CURRENT_MONITOR' 'SR03CPS06:CURRENT_SP ' 1 [3,3] 11 1.000 ; ...
-'3VCM4 ' 'SR03CPS07:CURRENT_MONITOR' 'SR03CPS07:CURRENT_SP ' 1 [3,4] 12 1.000 ; ...
-'4VCM1 ' 'SR04CPS02:CURRENT_MONITOR' 'SR04CPS02:CURRENT_SP ' 1 [4,1] 13 1.000 ; ...
-'4VCM2 ' 'SR04CPS04:CURRENT_MONITOR' 'SR04CPS04:CURRENT_SP ' 1 [4,2] 14 1.000 ; ...
-'4VCM3 ' 'SR04CPS06:CURRENT_MONITOR' 'SR04CPS06:CURRENT_SP ' 1 [4,3] 15 1.000 ; ...
-'4VCM4 ' 'SR04CPS07:CURRENT_MONITOR' 'SR04CPS07:CURRENT_SP ' 1 [4,4] 16 1.000 ; ...
-'5VCM1 ' 'SR05CPS02:CURRENT_MONITOR' 'SR05CPS02:CURRENT_SP ' 1 [5,1] 17 1.000 ; ...
-'5VCM2 ' 'SR05CPS04:CURRENT_MONITOR' 'SR05CPS04:CURRENT_SP ' 1 [5,2] 18 1.000 ; ...
-'5VCM3 ' 'SR05CPS06:CURRENT_MONITOR' 'SR05CPS06:CURRENT_SP ' 1 [5,3] 19 1.000 ; ...
-'5VCM4 ' 'SR05CPS07:CURRENT_MONITOR' 'SR05CPS07:CURRENT_SP ' 1 [5,4] 20 1.000 ; ...
-'6VCM1 ' 'SR06CPS02:CURRENT_MONITOR' 'SR06CPS02:CURRENT_SP ' 1 [6,1] 21 1.000 ; ...
-'6VCM2 ' 'SR06CPS04:CURRENT_MONITOR' 'SR06CPS04:CURRENT_SP ' 1 [6,2] 22 1.000 ; ...
-'6VCM3 ' 'SR06CPS06:CURRENT_MONITOR' 'SR06CPS06:CURRENT_SP ' 1 [6,3] 23 1.000 ; ...
-'6VCM4 ' 'SR06CPS07:CURRENT_MONITOR' 'SR06CPS07:CURRENT_SP ' 1 [6,4] 24 1.000 ; ...
-'7VCM1 ' 'SR07CPS02:CURRENT_MONITOR' 'SR07CPS02:CURRENT_SP ' 1 [7,1] 25 1.000 ; ...
-'7VCM2 ' 'SR07CPS04:CURRENT_MONITOR' 'SR07CPS04:CURRENT_SP ' 1 [7,2] 26 1.000 ; ...
-'7VCM3 ' 'SR07CPS06:CURRENT_MONITOR' 'SR07CPS06:CURRENT_SP ' 1 [7,3] 27 1.000 ; ...
-'7VCM4 ' 'SR07CPS07:CURRENT_MONITOR' 'SR07CPS07:CURRENT_SP ' 1 [7,4] 28 1.000 ; ...
-'8VCM1 ' 'SR08CPS02:CURRENT_MONITOR' 'SR08CPS02:CURRENT_SP ' 1 [8,1] 29 1.000 ; ...
-'8VCM2 ' 'SR08CPS04:CURRENT_MONITOR' 'SR08CPS04:CURRENT_SP ' 1 [8,2] 30 1.000 ; ...
-'8VCM3 ' 'SR08CPS06:CURRENT_MONITOR' 'SR08CPS06:CURRENT_SP ' 1 [8,3] 31 1.000 ; ...
-'8VCM4 ' 'SR08CPS07:CURRENT_MONITOR' 'SR08CPS07:CURRENT_SP ' 1 [8,4] 32 1.000 ; ...
-'9VCM1 ' 'SR09CPS02:CURRENT_MONITOR' 'SR09CPS02:CURRENT_SP ' 1 [9,1] 33 1.000 ; ...
-'9VCM2 ' 'SR09CPS04:CURRENT_MONITOR' 'SR09CPS04:CURRENT_SP ' 1 [9,2] 34 1.000 ; ...
-'9VCM3 ' 'SR09CPS06:CURRENT_MONITOR' 'SR09CPS06:CURRENT_SP ' 1 [9,3] 35 1.000 ; ...
-'9VCM4 ' 'SR09CPS07:CURRENT_MONITOR' 'SR09CPS07:CURRENT_SP ' 1 [9,4] 36 1.000 ; ...
-'10VCM1 ' 'SR10CPS02:CURRENT_MONITOR' 'SR10CPS02:CURRENT_SP ' 1 [10,1] 37 1.000 ; ...
-'10VCM2 ' 'SR10CPS04:CURRENT_MONITOR' 'SR10CPS04:CURRENT_SP ' 1 [10,2] 38 1.000 ; ...
-'10VCM3 ' 'SR10CPS06:CURRENT_MONITOR' 'SR10CPS06:CURRENT_SP ' 1 [10,3] 39 1.000 ; ...
-'10VCM4 ' 'SR10CPS07:CURRENT_MONITOR' 'SR10CPS07:CURRENT_SP ' 1 [10,4] 40 1.000 ; ...
-'11VCM1 ' 'SR11CPS02:CURRENT_MONITOR' 'SR11CPS02:CURRENT_SP ' 1 [11,1] 41 1.000 ; ...
-'11VCM2 ' 'SR11CPS04:CURRENT_MONITOR' 'SR11CPS04:CURRENT_SP ' 1 [11,2] 42 1.000 ; ...
-'11VCM3 ' 'SR11CPS06:CURRENT_MONITOR' 'SR11CPS06:CURRENT_SP ' 1 [11,3] 43 1.000 ; ...
-'11VCM4 ' 'SR11CPS07:CURRENT_MONITOR' 'SR11CPS07:CURRENT_SP ' 1 [11,4] 44 1.000 ; ...
-'12VCM1 ' 'SR12CPS02:CURRENT_MONITOR' 'SR12CPS02:CURRENT_SP ' 1 [12,1] 45 1.000 ; ...
-'12VCM2 ' 'SR12CPS04:CURRENT_MONITOR' 'SR12CPS04:CURRENT_SP ' 1 [12,2] 46 1.000 ; ...
-'12VCM3 ' 'SR12CPS06:CURRENT_MONITOR' 'SR12CPS06:CURRENT_SP ' 1 [12,3] 47 1.000 ; ...
-'12VCM4 ' 'SR12CPS07:CURRENT_MONITOR' 'SR12CPS07:CURRENT_SP ' 1 [12,4] 48 1.000 ; ...
-'13VCM1 ' 'SR13CPS02:CURRENT_MONITOR' 'SR13CPS02:CURRENT_SP ' 1 [13,1] 49 1.000 ; ...
-'13VCM2 ' 'SR13CPS04:CURRENT_MONITOR' 'SR13CPS04:CURRENT_SP ' 1 [13,2] 50 1.000 ; ...
-'13VCM3 ' 'SR13CPS06:CURRENT_MONITOR' 'SR13CPS06:CURRENT_SP ' 1 [13,3] 51 1.000 ; ...
-'13VCM4 ' 'SR13CPS07:CURRENT_MONITOR' 'SR13CPS07:CURRENT_SP ' 1 [13,4] 52 1.000 ; ...
-'14VCM1 ' 'SR14CPS02:CURRENT_MONITOR' 'SR14CPS02:CURRENT_SP ' 1 [14,1] 53 1.000 ; ...
-'14VCM2 ' 'SR14CPS04:CURRENT_MONITOR' 'SR14CPS04:CURRENT_SP ' 1 [14,2] 54 1.000 ; ...
-'14VCM3 ' 'SR14CPS06:CURRENT_MONITOR' 'SR14CPS06:CURRENT_SP ' 1 [14,3] 55 1.000 ; ...
-'14VCM4 ' 'SR14CPS07:CURRENT_MONITOR' 'SR14CPS07:CURRENT_SP ' 1 [14,4] 56 1.000 ; ...
-};
-
-[C, Leff, MagnetType] = magnetcoefficients('VCM');
-
-for ii=1:size(cor,1)
-name=cor{ii,1}; AO.VCM.CommonNames(ii,:) = name;
-name=cor{ii,2}; AO.VCM.Monitor.ChannelNames(ii,:) = name;
-name=cor{ii,3}; AO.VCM.Setpoint.ChannelNames(ii,:) = name;
-val =cor{ii,4}; AO.VCM.Status(ii,1) = val;
-val =cor{ii,5}; AO.VCM.DeviceList(ii,:) = val;
-val =cor{ii,6}; AO.VCM.ElementList(ii,1) = val;
-val =cor{ii,7}; AO.VCM.Setpoint.Tolerance(ii,1) = val;
-
-AO.VCM.Setpoint.Range(ii,:) = [-125 +125];
-AO.VCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
-AO.VCM.Monitor.Physics2HWParams{1}(ii,:) = C;
-AO.VCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
-AO.VCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
-end
-
-
-%=============================
-% MAIN MAGNETS
-%=============================
-
-%===========
-%Dipole data
-%===========
-
-% *** BEND ***
-AO.BEND.FamilyName = 'BEND'; dispobject(AO,AO.BEND.FamilyName);
-AO.BEND.MemberOf = {'PlotFamily'; 'MachineConfig'; 'BEND'; 'Magnet';};
-HW2PhysicsParams = magnetcoefficients('BEND');
-Physics2HWParams = magnetcoefficients('BEND');
-
-AO.BEND.Monitor.Mode = Mode;
-AO.BEND.Monitor.DataType = 'Scalar';
-AO.BEND.Monitor.Units = 'Hardware';
-AO.BEND.Monitor.HW2PhysicsFcn = @bend2gev; % @bend2gev ???
-AO.BEND.Monitor.Physics2HWFcn = @gev2bend;
-AO.BEND.Monitor.HWUnits = 'ampere';
-AO.BEND.Monitor.PhysicsUnits = 'energy';
-
-AO.BEND.Setpoint.Mode = Mode;
-AO.BEND.Setpoint.DataType = 'Scalar';
-AO.BEND.Setpoint.Units = 'Hardware';
-AO.BEND.Setpoint.HW2PhysicsFcn = @bend2gev;
-AO.BEND.Setpoint.Physics2HWFcn = @gev2bend;
-AO.BEND.Setpoint.HWUnits = 'ampere';
-AO.BEND.Setpoint.PhysicsUnits = 'energy';
-
-% common monitor setpoint stat devlist elem scale tol
-bend={
-'1BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.10 ; ...
-'1BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,2] 2 1.0 0.10 ; ...
-'2BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.10 ; ...
-'2BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,2] 4 1.0 0.10 ; ...
-'3BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.10 ; ...
-'3BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,2] 6 1.0 0.10 ; ...
-'4BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.10 ; ...
-'4BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,2] 8 1.0 0.10 ; ...
-'5BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.10 ; ...
-'5BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,2] 10 1.0 0.10 ; ...
-'6BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.10 ; ...
-'6BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,2] 12 1.0 0.10 ; ...
-'7BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.10 ; ...
-'7BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,2] 14 1.0 0.10 ; ...
-'8BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.10 ; ...
-'8BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,2] 16 1.0 0.10 ; ...
-'9BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.10 ; ...
-'9BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,2] 18 1.0 0.10 ; ...
-'10BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.10 ; ...
-'10BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,2] 20 1.0 0.10 ; ...
-'11BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.10 ; ...
-'11BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,2] 22 1.0 0.10 ; ...
-'12BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.10 ; ...
-'12BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,2] 24 1.0 0.10 ; ...
-'13BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.10 ; ...
-'13BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,2] 26 1.0 0.10 ; ...
-'14BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.10 ; ...
-'14BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,2] 28 1.0 0.10 ; ...
-};
-
-for ii=1:size(bend,1)
-name=bend{ii,1}; AO.BEND.CommonNames(ii,:) = name;
-name=bend{ii,2}; AO.BEND.Monitor.ChannelNames(ii,:) = name;
-name=bend{ii,3}; AO.BEND.Setpoint.ChannelNames(ii,:) = name;
-val =bend{ii,4}; AO.BEND.Status(ii,1) = val;
-val =bend{ii,5}; AO.BEND.DeviceList(ii,:) = val;
-val =bend{ii,6}; AO.BEND.ElementList(ii,1) = val;
-val =bend{ii,7}; % This is the scale factor
-AO.BEND.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.BEND.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.BEND.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.BEND.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.BEND.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.BEND.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.BEND.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.BEND.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =bend{ii,8}; AO.BEND.Setpoint.Tolerance(ii,1) = val;
-
-AO.BEND.Setpoint.Range(ii,:) = [50 695];
-end
-
-%===============
-%Quadrupole data
-%===============
-
-% *** QFA ***
-AO.QFA.FamilyName = 'QFA'; dispobject(AO,AO.QFA.FamilyName);
-AO.QFA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
-HW2PhysicsParams = magnetcoefficients('QFA');
-Physics2HWParams = magnetcoefficients('QFA');
-
-AO.QFA.Monitor.Mode = Mode;
-AO.QFA.Monitor.DataType = 'Scalar';
-AO.QFA.Monitor.Units = 'Hardware';
-AO.QFA.Monitor.HWUnits = 'ampere';
-AO.QFA.Monitor.PhysicsUnits = 'meter^-2';
-AO.QFA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QFA.Monitor.Physics2HWFcn = @k2amp;
-
-AO.QFA.Setpoint.Mode = Mode;
-AO.QFA.Setpoint.DataType = 'Scalar';
-AO.QFA.Setpoint.Units = 'Hardware';
-AO.QFA.Setpoint.HWUnits = 'ampere';
-AO.QFA.Setpoint.PhysicsUnits = 'meter^-2';
-AO.QFA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QFA.Setpoint.Physics2HWFcn = @k2amp;
-
-% common monitor setpoint stat devlist elem scale tol
-qfa={
-'1QFA1 ' 'SR01QPS01:CURRENT_MONITOR' 'SR01QPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
-'1QFA2 ' 'SR01QPS06:CURRENT_MONITOR' 'SR01QPS06:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
-'2QFA1 ' 'SR02QPS01:CURRENT_MONITOR' 'SR02QPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
-'2QFA2 ' 'SR02QPS06:CURRENT_MONITOR' 'SR02QPS06:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
-'3QFA1 ' 'SR03QPS01:CURRENT_MONITOR' 'SR03QPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
-'3QFA2 ' 'SR03QPS06:CURRENT_MONITOR' 'SR03QPS06:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
-'4QFA1 ' 'SR04QPS01:CURRENT_MONITOR' 'SR04QPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
-'4QFA2 ' 'SR04QPS06:CURRENT_MONITOR' 'SR04QPS06:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
-'5QFA1 ' 'SR05QPS01:CURRENT_MONITOR' 'SR05QPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
-'5QFA2 ' 'SR05QPS06:CURRENT_MONITOR' 'SR05QPS06:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
-'6QFA1 ' 'SR06QPS01:CURRENT_MONITOR' 'SR06QPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
-'6QFA2 ' 'SR06QPS06:CURRENT_MONITOR' 'SR06QPS06:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
-'7QFA1 ' 'SR07QPS01:CURRENT_MONITOR' 'SR07QPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
-'7QFA2 ' 'SR07QPS06:CURRENT_MONITOR' 'SR07QPS06:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
-'8QFA1 ' 'SR08QPS01:CURRENT_MONITOR' 'SR08QPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
-'8QFA2 ' 'SR08QPS06:CURRENT_MONITOR' 'SR08QPS06:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
-'9QFA1 ' 'SR09QPS01:CURRENT_MONITOR' 'SR09QPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
-'9QFA2 ' 'SR09QPS06:CURRENT_MONITOR' 'SR09QPS06:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
-'10QFA1 ' 'SR10QPS01:CURRENT_MONITOR' 'SR10QPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
-'10QFA2 ' 'SR10QPS06:CURRENT_MONITOR' 'SR10QPS06:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
-'11QFA1 ' 'SR11QPS01:CURRENT_MONITOR' 'SR11QPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
-'11QFA2 ' 'SR11QPS06:CURRENT_MONITOR' 'SR11QPS06:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
-'12QFA1 ' 'SR12QPS01:CURRENT_MONITOR' 'SR12QPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
-'12QFA2 ' 'SR12QPS06:CURRENT_MONITOR' 'SR12QPS06:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
-'13QFA1 ' 'SR13QPS01:CURRENT_MONITOR' 'SR13QPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
-'13QFA2 ' 'SR13QPS06:CURRENT_MONITOR' 'SR13QPS06:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
-'14QFA1 ' 'SR14QPS01:CURRENT_MONITOR' 'SR14QPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
-'14QFA2 ' 'SR14QPS06:CURRENT_MONITOR' 'SR14QPS06:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
-};
-
-for ii=1:size(qfa,1)
-name=qfa{ii,1}; AO.QFA.CommonNames(ii,:) = name;
-name=qfa{ii,2}; AO.QFA.Monitor.ChannelNames(ii,:) = name;
-name=qfa{ii,3}; AO.QFA.Setpoint.ChannelNames(ii,:) = name;
-val =qfa{ii,4}; AO.QFA.Status(ii,1) = val;
-val =qfa{ii,5}; AO.QFA.DeviceList(ii,:) = val;
-val =qfa{ii,6}; AO.QFA.ElementList(ii,1) = val;
-val =qfa{ii,7}; % This is the scale factor
-AO.QFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qfa{ii,8}; AO.QFA.Setpoint.Tolerance(ii,1) = val;
-
-% Important! This determines the cycling range
-AO.QFA.Setpoint.Range(ii,:) = [0 160];
-end
-
-
-% *** QDA ***
-AO.QDA.FamilyName = 'QDA'; dispobject(AO,AO.QDA.FamilyName);
-AO.QDA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QD';};
-HW2PhysicsParams = magnetcoefficients('QDA');
-Physics2HWParams = magnetcoefficients('QDA');
-
-AO.QDA.Monitor.Mode = Mode;
-AO.QDA.Monitor.DataType = 'Scalar';
-AO.QDA.Monitor.Units = 'Hardware';
-AO.QDA.Monitor.HWUnits = 'ampere';
-AO.QDA.Monitor.PhysicsUnits = 'meter^-2';
-AO.QDA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QDA.Monitor.Physics2HWFcn = @k2amp;
-
-AO.QDA.Setpoint.Mode = Mode;
-AO.QDA.Setpoint.DataType = 'Scalar';
-AO.QDA.Setpoint.Units = 'Hardware';
-AO.QDA.Setpoint.HWUnits = 'ampere';
-AO.QDA.Setpoint.PhysicsUnits = 'meter^-2';
-AO.QDA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QDA.Setpoint.Physics2HWFcn = @k2amp;
-
-% common monitor setpoint stat devlist elem scale tol
-qda={
-'1QDA1 ' 'SR01QPS02:CURRENT_MONITOR' 'SR01QPS02:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
-'1QDA2 ' 'SR01QPS05:CURRENT_MONITOR' 'SR01QPS05:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
-'2QDA1 ' 'SR02QPS02:CURRENT_MONITOR' 'SR02QPS02:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
-'2QDA2 ' 'SR02QPS05:CURRENT_MONITOR' 'SR02QPS05:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
-'3QDA1 ' 'SR03QPS02:CURRENT_MONITOR' 'SR03QPS02:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
-'3QDA2 ' 'SR03QPS05:CURRENT_MONITOR' 'SR03QPS05:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
-'4QDA1 ' 'SR04QPS02:CURRENT_MONITOR' 'SR04QPS02:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
-'4QDA2 ' 'SR04QPS05:CURRENT_MONITOR' 'SR04QPS05:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
-'5QDA1 ' 'SR05QPS02:CURRENT_MONITOR' 'SR05QPS02:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
-'5QDA2 ' 'SR05QPS05:CURRENT_MONITOR' 'SR05QPS05:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
-'6QDA1 ' 'SR06QPS02:CURRENT_MONITOR' 'SR06QPS02:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
-'6QDA2 ' 'SR06QPS05:CURRENT_MONITOR' 'SR06QPS05:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
-'7QDA1 ' 'SR07QPS02:CURRENT_MONITOR' 'SR07QPS02:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
-'7QDA2 ' 'SR07QPS05:CURRENT_MONITOR' 'SR07QPS05:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
-'8QDA1 ' 'SR08QPS02:CURRENT_MONITOR' 'SR08QPS02:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
-'8QDA2 ' 'SR08QPS05:CURRENT_MONITOR' 'SR08QPS05:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
-'9QDA1 ' 'SR09QPS02:CURRENT_MONITOR' 'SR09QPS02:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
-'9QDA2 ' 'SR09QPS05:CURRENT_MONITOR' 'SR09QPS05:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
-'10QDA1 ' 'SR10QPS02:CURRENT_MONITOR' 'SR10QPS02:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
-'10QDA2 ' 'SR10QPS05:CURRENT_MONITOR' 'SR10QPS05:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
-'11QDA1 ' 'SR11QPS02:CURRENT_MONITOR' 'SR11QPS02:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
-'11QDA2 ' 'SR11QPS05:CURRENT_MONITOR' 'SR11QPS05:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
-'12QDA1 ' 'SR12QPS02:CURRENT_MONITOR' 'SR12QPS02:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
-'12QDA2 ' 'SR12QPS05:CURRENT_MONITOR' 'SR12QPS05:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
-'13QDA1 ' 'SR13QPS02:CURRENT_MONITOR' 'SR13QPS02:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
-'13QDA2 ' 'SR13QPS05:CURRENT_MONITOR' 'SR13QPS05:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
-'14QDA1 ' 'SR14QPS02:CURRENT_MONITOR' 'SR14QPS02:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
-'14QDA2 ' 'SR14QPS05:CURRENT_MONITOR' 'SR14QPS05:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
-};
-
-for ii=1:size(qda,1)
-name=qda{ii,1}; AO.QDA.CommonNames(ii,:) = name;
-name=qda{ii,2}; AO.QDA.Monitor.ChannelNames(ii,:) = name;
-name=qda{ii,3}; AO.QDA.Setpoint.ChannelNames(ii,:) = name;
-val =qda{ii,4}; AO.QDA.Status(ii,1) = val;
-val =qda{ii,5}; AO.QDA.DeviceList(ii,:) = val;
-val =qda{ii,6}; AO.QDA.ElementList(ii,1) = val;
-val =qda{ii,7}; % This is the scale factor
-AO.QDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QDA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qda{ii,8}; AO.QDA.Setpoint.Tolerance(ii,1) = val;
-
-% Important! This determines the cycling range
-AO.QDA.Setpoint.Range(ii,:) = [0 90];
-end
-
-
-
-% *** QFB ***
-AO.QFB.FamilyName = 'QFB'; dispobject(AO,AO.QFB.FamilyName);
-AO.QFB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
-HW2PhysicsParams = magnetcoefficients('QFB');
-Physics2HWParams = magnetcoefficients('QFB');
-
-AO.QFB.Monitor.Mode = Mode;
-AO.QFB.Monitor.DataType = 'Scalar';
-AO.QFB.Monitor.Units = 'Hardware';
-AO.QFB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QFB.Monitor.Physics2HWFcn = @k2amp;
-AO.QFB.Monitor.HWUnits = 'ampere';
-AO.QFB.Monitor.PhysicsUnits = 'meter^-2';
-
-AO.QFB.Setpoint.Mode = Mode;
-AO.QFB.Setpoint.DataType = 'Scalar';
-AO.QFB.Setpoint.Units = 'Hardware';
-AO.QFB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QFB.Setpoint.Physics2HWFcn = @k2amp;
-AO.QFB.Setpoint.HWUnits = 'ampere';
-AO.QFB.Setpoint.PhysicsUnits = 'meter^-2';
-
-% common monitor setpoint stat devlist elem scale tol
-qfb={
-'1QFB1 ' 'SR01QPS03:CURRENT_MONITOR' 'SR01QPS03:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
-'1QFB2 ' 'SR01QPS04:CURRENT_MONITOR' 'SR01QPS04:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
-'2QFB1 ' 'SR02QPS03:CURRENT_MONITOR' 'SR02QPS03:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
-'2QFB2 ' 'SR02QPS04:CURRENT_MONITOR' 'SR02QPS04:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
-'3QFB1 ' 'SR03QPS03:CURRENT_MONITOR' 'SR03QPS03:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
-'3QFB2 ' 'SR03QPS04:CURRENT_MONITOR' 'SR03QPS04:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
-'4QFB1 ' 'SR04QPS03:CURRENT_MONITOR' 'SR04QPS03:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
-'4QFB2 ' 'SR04QPS04:CURRENT_MONITOR' 'SR04QPS04:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
-'5QFB1 ' 'SR05QPS03:CURRENT_MONITOR' 'SR05QPS03:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
-'5QFB2 ' 'SR05QPS04:CURRENT_MONITOR' 'SR05QPS04:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
-'6QFB1 ' 'SR06QPS03:CURRENT_MONITOR' 'SR06QPS03:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
-'6QFB2 ' 'SR06QPS04:CURRENT_MONITOR' 'SR06QPS04:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
-'7QFB1 ' 'SR07QPS03:CURRENT_MONITOR' 'SR07QPS03:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
-'7QFB2 ' 'SR07QPS04:CURRENT_MONITOR' 'SR07QPS04:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
-'8QFB1 ' 'SR08QPS03:CURRENT_MONITOR' 'SR08QPS03:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
-'8QFB2 ' 'SR08QPS04:CURRENT_MONITOR' 'SR08QPS04:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
-'9QFB1 ' 'SR09QPS03:CURRENT_MONITOR' 'SR09QPS03:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
-'9QFB2 ' 'SR09QPS04:CURRENT_MONITOR' 'SR09QPS04:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
-'10QFB1 ' 'SR10QPS03:CURRENT_MONITOR' 'SR10QPS03:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
-'10QFB2 ' 'SR10QPS04:CURRENT_MONITOR' 'SR10QPS04:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
-'11QFB1 ' 'SR11QPS03:CURRENT_MONITOR' 'SR11QPS03:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
-'11QFB2 ' 'SR11QPS04:CURRENT_MONITOR' 'SR11QPS04:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
-'12QFB1 ' 'SR12QPS03:CURRENT_MONITOR' 'SR12QPS03:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
-'12QFB2 ' 'SR12QPS04:CURRENT_MONITOR' 'SR12QPS04:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
-'13QFB1 ' 'SR13QPS03:CURRENT_MONITOR' 'SR13QPS03:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
-'13QFB2 ' 'SR13QPS04:CURRENT_MONITOR' 'SR13QPS04:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
-'14QFB1 ' 'SR14QPS03:CURRENT_MONITOR' 'SR14QPS03:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
-'14QFB2 ' 'SR14QPS04:CURRENT_MONITOR' 'SR14QPS04:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
-};
-
-for ii=1:size(qfb,1)
-name=qfb{ii,1}; AO.QFB.CommonNames(ii,:) = name;
-name=qfb{ii,2}; AO.QFB.Monitor.ChannelNames(ii,:) = name;
-name=qfb{ii,3}; AO.QFB.Setpoint.ChannelNames(ii,:) = name;
-val =qfb{ii,4}; AO.QFB.Status(ii,1) = val;
-val =qfb{ii,5}; AO.QFB.DeviceList(ii,:) = val;
-val =qfb{ii,6}; AO.QFB.ElementList(ii,1) = val;
-val =qfb{ii,7}; % This is the scale factor
-AO.QFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qfb{ii,8}; AO.QFB.Setpoint.Tolerance(ii,1) = val;
-
-% Important! This determines the cycling range
-AO.QFB.Setpoint.Range(ii,:) = [0 160];
-end
-
-
-%===============
-%Sextupole data
-%===============
-% *** SFA ***
-AO.SFA.FamilyName = 'SFA'; dispobject(AO,AO.SFA.FamilyName);
-AO.SFA.MemberOf = {'PlotFamily'; 'SF'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SFA');
-Physics2HWParams = magnetcoefficients('SFA');
-
-AO.SFA.Monitor.Mode = Mode;
-AO.SFA.Monitor.DataType = 'Scalar';
-AO.SFA.Monitor.Units = 'Hardware';
-AO.SFA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SFA.Monitor.Physics2HWFcn = @k2amp;
-AO.SFA.Monitor.HWUnits = 'ampere';
-AO.SFA.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SFA.Setpoint.Mode = Mode;
-AO.SFA.Setpoint.DataType = 'Scalar';
-AO.SFA.Setpoint.Units = 'Hardware';
-AO.SFA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SFA.Setpoint.Physics2HWFcn = @k2amp;
-AO.SFA.Setpoint.HWUnits = 'ampere';
-AO.SFA.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sfa={
-'1SFA1 ' 'SR01SPS01:CURRENT_MONITOR' 'SR01SPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
-'1SFA2 ' 'SR01SPS07:CURRENT_MONITOR' 'SR01SPS07:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
-'2SFA1 ' 'SR02SPS01:CURRENT_MONITOR' 'SR02SPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
-'2SFA2 ' 'SR02SPS07:CURRENT_MONITOR' 'SR02SPS07:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
-'3SFA1 ' 'SR03SPS01:CURRENT_MONITOR' 'SR03SPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
-'3SFA2 ' 'SR03SPS07:CURRENT_MONITOR' 'SR03SPS07:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
-'4SFA1 ' 'SR04SPS01:CURRENT_MONITOR' 'SR04SPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
-'4SFA2 ' 'SR04SPS07:CURRENT_MONITOR' 'SR04SPS07:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
-'5SFA1 ' 'SR05SPS01:CURRENT_MONITOR' 'SR05SPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
-'5SFA2 ' 'SR05SPS07:CURRENT_MONITOR' 'SR05SPS07:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
-'6SFA1 ' 'SR06SPS01:CURRENT_MONITOR' 'SR06SPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
-'6SFA2 ' 'SR06SPS07:CURRENT_MONITOR' 'SR06SPS07:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
-'7SFA1 ' 'SR07SPS01:CURRENT_MONITOR' 'SR07SPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
-'7SFA2 ' 'SR07SPS07:CURRENT_MONITOR' 'SR07SPS07:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
-'8SFA1 ' 'SR08SPS01:CURRENT_MONITOR' 'SR08SPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
-'8SFA2 ' 'SR08SPS07:CURRENT_MONITOR' 'SR08SPS07:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
-'9SFA1 ' 'SR09SPS01:CURRENT_MONITOR' 'SR09SPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
-'9SFA2 ' 'SR09SPS07:CURRENT_MONITOR' 'SR09SPS07:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
-'10SFA1 ' 'SR10SPS01:CURRENT_MONITOR' 'SR10SPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
-'10SFA2 ' 'SR10SPS07:CURRENT_MONITOR' 'SR10SPS07:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
-'11SFA1 ' 'SR11SPS01:CURRENT_MONITOR' 'SR11SPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
-'11SFA2 ' 'SR11SPS07:CURRENT_MONITOR' 'SR11SPS07:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
-'12SFA1 ' 'SR12SPS01:CURRENT_MONITOR' 'SR12SPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
-'12SFA2 ' 'SR12SPS07:CURRENT_MONITOR' 'SR12SPS07:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
-'13SFA1 ' 'SR13SPS01:CURRENT_MONITOR' 'SR13SPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
-'13SFA2 ' 'SR13SPS07:CURRENT_MONITOR' 'SR13SPS07:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
-'14SFA1 ' 'SR14SPS01:CURRENT_MONITOR' 'SR14SPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
-'14SFA2 ' 'SR14SPS07:CURRENT_MONITOR' 'SR14SPS07:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
-};
-
-for ii=1:size(sfa,1)
-name=sfa{ii,1}; AO.SFA.CommonNames(ii,:) = name;
-name=sfa{ii,2}; AO.SFA.Monitor.ChannelNames(ii,:) = name;
-name=sfa{ii,3}; AO.SFA.Setpoint.ChannelNames(ii,:) = name;
-val =sfa{ii,4}; AO.SFA.Status(ii,1) = val;
-val =sfa{ii,5}; AO.SFA.DeviceList(ii,:) = val;
-val =sfa{ii,6}; AO.SFA.ElementList(ii,1) = val;
-val =sfa{ii,7}; % This is the scale factor
-AO.SFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sfa{ii,8}; AO.SFA.Setpoint.Tolerance(ii,1) = val;
-
-AO.SFA.Setpoint.Range(ii,:) = [0 90];
-end
-
-
-
-% *** SDA ***
-AO.SDA.FamilyName = 'SDA'; dispobject(AO,AO.SDA.FamilyName);
-AO.SDA.MemberOf = {'PlotFamily'; 'SD'; 'SEXT'; 'MachineConfig'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SDA');
-Physics2HWParams = magnetcoefficients('SDA');
-AO.SDA.Monitor.Mode = Mode;
-AO.SDA.Monitor.DataType = 'Scalar';
-AO.SDA.Monitor.Units = 'Hardware';
-AO.SDA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SDA.Monitor.Physics2HWFcn = @k2amp;
-AO.SDA.Monitor.HWUnits = 'ampere';
-AO.SDA.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SDA.Setpoint.Mode = Mode;
-AO.SDA.Setpoint.DataType = 'Scalar';
-AO.SDA.Setpoint.Units = 'Hardware';
-AO.SDA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SDA.Setpoint.Physics2HWFcn = @k2amp;
-AO.SDA.Setpoint.HWUnits = 'ampere';
-AO.SDA.Setpoint.PhysicsUnits = 'meter^-3';
-
-
-% common monitor setpoint stat devlist elem scale tol
-sda={
-'1SDA1 ' 'SR01SPS02:CURRENT_MONITOR' 'SR01SPS02:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
-'1SDA2 ' 'SR01SPS06:CURRENT_MONITOR' 'SR01SPS06:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
-'2SDA1 ' 'SR02SPS02:CURRENT_MONITOR' 'SR02SPS02:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
-'2SDA2 ' 'SR02SPS06:CURRENT_MONITOR' 'SR02SPS06:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
-'3SDA1 ' 'SR03SPS02:CURRENT_MONITOR' 'SR03SPS02:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
-'3SDA2 ' 'SR03SPS06:CURRENT_MONITOR' 'SR03SPS06:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
-'4SDA1 ' 'SR04SPS02:CURRENT_MONITOR' 'SR04SPS02:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
-'4SDA2 ' 'SR04SPS06:CURRENT_MONITOR' 'SR04SPS06:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
-'5SDA1 ' 'SR05SPS02:CURRENT_MONITOR' 'SR05SPS02:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
-'5SDA2 ' 'SR05SPS06:CURRENT_MONITOR' 'SR05SPS06:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
-'6SDA1 ' 'SR06SPS02:CURRENT_MONITOR' 'SR06SPS02:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
-'6SDA2 ' 'SR06SPS06:CURRENT_MONITOR' 'SR06SPS06:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
-'7SDA1 ' 'SR07SPS02:CURRENT_MONITOR' 'SR07SPS02:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
-'7SDA2 ' 'SR07SPS06:CURRENT_MONITOR' 'SR07SPS06:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
-'8SDA1 ' 'SR08SPS02:CURRENT_MONITOR' 'SR08SPS02:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
-'8SDA2 ' 'SR08SPS06:CURRENT_MONITOR' 'SR08SPS06:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
-'9SDA1 ' 'SR09SPS02:CURRENT_MONITOR' 'SR09SPS02:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
-'9SDA2 ' 'SR09SPS06:CURRENT_MONITOR' 'SR09SPS06:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
-'10SDA1 ' 'SR10SPS02:CURRENT_MONITOR' 'SR10SPS02:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
-'10SDA2 ' 'SR10SPS06:CURRENT_MONITOR' 'SR10SPS06:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
-'11SDA1 ' 'SR11SPS02:CURRENT_MONITOR' 'SR11SPS02:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
-'11SDA2 ' 'SR11SPS06:CURRENT_MONITOR' 'SR11SPS06:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
-'12SDA1 ' 'SR12SPS02:CURRENT_MONITOR' 'SR12SPS02:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
-'12SDA2 ' 'SR12SPS06:CURRENT_MONITOR' 'SR12SPS06:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
-'13SDA1 ' 'SR13SPS02:CURRENT_MONITOR' 'SR13SPS02:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
-'13SDA2 ' 'SR13SPS06:CURRENT_MONITOR' 'SR13SPS06:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
-'14SDA1 ' 'SR14SPS02:CURRENT_MONITOR' 'SR14SPS02:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
-'14SDA2 ' 'SR14SPS06:CURRENT_MONITOR' 'SR14SPS06:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
-};
-
-for ii=1:size(sda,1)
-name=sda{ii,1}; AO.SDA.CommonNames(ii,:) = name;
-name=sda{ii,2}; AO.SDA.Monitor.ChannelNames(ii,:) = name;
-name=sda{ii,3}; AO.SDA.Setpoint.ChannelNames(ii,:) = name;
-val =sda{ii,4}; AO.SDA.Status(ii,1) = val;
-val =sda{ii,5}; AO.SDA.DeviceList(ii,:) = val;
-val =sda{ii,6}; AO.SDA.ElementList(ii,1) = val;
-val =sda{ii,7}; % This is the scale factor
-AO.SDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sda{ii,8}; AO.SDA.Setpoint.Tolerance(ii,1) = val;
-
-AO.SDA.Setpoint.Range(ii,:) = [0 90];
-end
-
-
-% *** SDB ***
-AO.SDB.FamilyName = 'SDB'; dispobject(AO,AO.SDB.FamilyName);
-AO.SDB.MemberOf = {'PlotFamily'; 'SD'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SDB');
-Physics2HWParams = magnetcoefficients('SDB');
-AO.SDB.Monitor.Mode = Mode;
-AO.SDB.Monitor.DataType = 'Scalar';
-AO.SDB.Monitor.Units = 'Hardware';
-AO.SDB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SDB.Monitor.Physics2HWFcn = @k2amp;
-AO.SDB.Monitor.HWUnits = 'ampere';
-AO.SDB.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SDB.Setpoint.Mode = Mode;
-AO.SDB.Setpoint.DataType = 'Scalar';
-AO.SDB.Setpoint.Units = 'Hardware';
-AO.SDB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SDB.Setpoint.Physics2HWFcn = @k2amp;
-AO.SDB.Setpoint.HWUnits = 'ampere';
-AO.SDB.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sdb={
-'1SDB1 ' 'SR01SPS03:CURRENT_MONITOR' 'SR01SPS03:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
-'1SDB2 ' 'SR01SPS05:CURRENT_MONITOR' 'SR01SPS05:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
-'2SDB1 ' 'SR02SPS03:CURRENT_MONITOR' 'SR02SPS03:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
-'2SDB2 ' 'SR02SPS05:CURRENT_MONITOR' 'SR02SPS05:CURRENT_SP ' 1 [2,2] 4 1.0 3.0 ; ...
-'3SDB1 ' 'SR03SPS03:CURRENT_MONITOR' 'SR03SPS03:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
-'3SDB2 ' 'SR03SPS05:CURRENT_MONITOR' 'SR03SPS05:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
-'4SDB1 ' 'SR04SPS03:CURRENT_MONITOR' 'SR04SPS03:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
-'4SDB2 ' 'SR04SPS05:CURRENT_MONITOR' 'SR04SPS05:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
-'5SDB1 ' 'SR05SPS03:CURRENT_MONITOR' 'SR05SPS03:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
-'5SDB2 ' 'SR05SPS05:CURRENT_MONITOR' 'SR05SPS05:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
-'6SDB1 ' 'SR06SPS03:CURRENT_MONITOR' 'SR06SPS03:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
-'6SDB2 ' 'SR06SPS05:CURRENT_MONITOR' 'SR06SPS05:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
-'7SDB1 ' 'SR07SPS03:CURRENT_MONITOR' 'SR07SPS03:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
-'7SDB2 ' 'SR07SPS05:CURRENT_MONITOR' 'SR07SPS05:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
-'8SDB1 ' 'SR08SPS03:CURRENT_MONITOR' 'SR08SPS03:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
-'8SDB2 ' 'SR08SPS05:CURRENT_MONITOR' 'SR08SPS05:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
-'9SDB1 ' 'SR09SPS03:CURRENT_MONITOR' 'SR09SPS03:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
-'9SDB2 ' 'SR09SPS05:CURRENT_MONITOR' 'SR09SPS05:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
-'10SDB1 ' 'SR10SPS03:CURRENT_MONITOR' 'SR10SPS03:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
-'10SDB2 ' 'SR10SPS05:CURRENT_MONITOR' 'SR10SPS05:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
-'11SDB1 ' 'SR11SPS03:CURRENT_MONITOR' 'SR11SPS03:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
-'11SDB2 ' 'SR11SPS05:CURRENT_MONITOR' 'SR11SPS05:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
-'12SDB1 ' 'SR12SPS03:CURRENT_MONITOR' 'SR12SPS03:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
-'12SDB2 ' 'SR12SPS05:CURRENT_MONITOR' 'SR12SPS05:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
-'13SDB1 ' 'SR13SPS03:CURRENT_MONITOR' 'SR13SPS03:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
-'13SDB2 ' 'SR13SPS05:CURRENT_MONITOR' 'SR13SPS05:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
-'14SDB1 ' 'SR14SPS03:CURRENT_MONITOR' 'SR14SPS03:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
-'14SDB2 ' 'SR14SPS05:CURRENT_MONITOR' 'SR14SPS05:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
-};
-
-for ii=1:size(sdb,1)
-name=sdb{ii,1}; AO.SDB.CommonNames(ii,:) = name;
-name=sdb{ii,2}; AO.SDB.Monitor.ChannelNames(ii,:) = name;
-name=sdb{ii,3}; AO.SDB.Setpoint.ChannelNames(ii,:)= name;
-val =sdb{ii,4}; AO.SDB.Status(ii,1) = val;
-val =sdb{ii,5}; AO.SDB.DeviceList(ii,:) = val;
-val =sdb{ii,6}; AO.SDB.ElementList(ii,1) = val;
-val =sdb{ii,7}; % This is the scale factor
-AO.SDB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SDB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sdb{ii,8}; AO.SDB.Setpoint.Tolerance(ii,1) = val;
-
-AO.SDB.Setpoint.Range(ii,:) = [0 80];
-end
-
-
-
-% *** SFB ***
-AO.SFB.FamilyName = 'SFB'; dispobject(AO,AO.SFB.FamilyName);
-AO.SFB.MemberOf = {'PlotFamily'; 'SF'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SFB');
-Physics2HWParams = magnetcoefficients('SFB');
-
-AO.SFB.Monitor.Mode = Mode;
-AO.SFB.Monitor.DataType = 'Scalar';
-AO.SFB.Monitor.Units = 'Hardware';
-AO.SFB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SFB.Monitor.Physics2HWFcn = @k2amp;
-AO.SFB.Monitor.HWUnits = 'ampere';
-AO.SFB.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SFB.Setpoint.Mode = Mode;
-AO.SFB.Setpoint.DataType = 'Scalar';
-AO.SFB.Setpoint.Units = 'Hardware';
-AO.SFB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SFB.Setpoint.Physics2HWFcn = @k2amp;
-AO.SFB.Setpoint.HWUnits = 'ampere';
-AO.SFB.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sfb={
-'1SFB1 ' 'SR01SPS04:CURRENT_MONITOR' 'SR01SPS04:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
-'2SFB1 ' 'SR02SPS04:CURRENT_MONITOR' 'SR02SPS04:CURRENT_SP ' 1 [2,1] 2 1.0 0.5 ; ...
-'3SFB1 ' 'SR03SPS04:CURRENT_MONITOR' 'SR03SPS04:CURRENT_SP ' 1 [3,1] 3 1.0 0.5 ; ...
-'4SFB1 ' 'SR04SPS04:CURRENT_MONITOR' 'SR04SPS04:CURRENT_SP ' 1 [4,1] 4 1.0 0.5 ; ...
-'5SFB1 ' 'SR05SPS04:CURRENT_MONITOR' 'SR05SPS04:CURRENT_SP ' 1 [5,1] 5 1.0 0.5 ; ...
-'6SFB1 ' 'SR06SPS04:CURRENT_MONITOR' 'SR06SPS04:CURRENT_SP ' 1 [6,1] 6 1.0 0.5 ; ...
-'7SFB1 ' 'SR07SPS04:CURRENT_MONITOR' 'SR07SPS04:CURRENT_SP ' 1 [7,1] 7 1.0 0.5 ; ...
-'8SFB1 ' 'SR08SPS04:CURRENT_MONITOR' 'SR08SPS04:CURRENT_SP ' 1 [8,1] 8 1.0 0.5 ; ...
-'9SFB1 ' 'SR09SPS04:CURRENT_MONITOR' 'SR09SPS04:CURRENT_SP ' 1 [9,1] 9 1.0 0.5 ; ...
-'10SFB1 ' 'SR10SPS04:CURRENT_MONITOR' 'SR10SPS04:CURRENT_SP ' 1 [10,1] 10 1.0 0.5 ; ...
-'11SFB1 ' 'SR11SPS04:CURRENT_MONITOR' 'SR11SPS04:CURRENT_SP ' 1 [11,1] 11 1.0 0.5 ; ...
-'12SFB1 ' 'SR12SPS04:CURRENT_MONITOR' 'SR12SPS04:CURRENT_SP ' 1 [12,1] 12 1.0 0.5 ; ...
-'13SFB1 ' 'SR13SPS04:CURRENT_MONITOR' 'SR13SPS04:CURRENT_SP ' 1 [13,1] 13 1.0 0.5 ; ...
-'14SFB1 ' 'SR14SPS04:CURRENT_MONITOR' 'SR14SPS04:CURRENT_SP ' 1 [14,1] 14 1.0 0.5 ; ...
-};
-
-for ii=1:size(sfb,1)
-name=sfb{ii,1}; AO.SFB.CommonNames(ii,:) = name;
-name=sfb{ii,2}; AO.SFB.Monitor.ChannelNames(ii,:) = name;
-name=sfb{ii,3}; AO.SFB.Setpoint.ChannelNames(ii,:)= name;
-val =sfb{ii,4}; AO.SFB.Status(ii,1) = val;
-val =sfb{ii,5}; AO.SFB.DeviceList(ii,:) = val;
-val =sfb{ii,6}; AO.SFB.ElementLsist(ii,1) = val;
-val =sfb{ii,7}; % This is the scale factor
-AO.SFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sfb{ii,8}; AO.SFB.Setpoint.Tolerance(ii,1) = val;
-
-AO.SFB.Setpoint.Range(ii,:) = [0 60];
-end
-
-%===============
-%Skew Quad data
-%===============
-% *** Skew quadrupoles *** 2005/09/27 Eugene
-AO.SKQ.FamilyName = 'SKQ'; dispobject(AO,AO.SKQ.FamilyName);
-AO.SKQ.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SkewQuad'; 'Magnet';};
-HW2PhysicsParams = magnetcoefficients('SKQ');
-Physics2HWParams = magnetcoefficients('SKQ');
-
-AO.SKQ.Monitor.Mode = Mode;
-AO.SKQ.Monitor.DataType = 'Scalar';
-AO.SKQ.Monitor.Units = 'Hardware';
-AO.SKQ.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SKQ.Monitor.Physics2HWFcn = @k2amp;
-AO.SKQ.Monitor.HWUnits = 'ampere';
-AO.SKQ.Monitor.PhysicsUnits = 'meter^-2';
-
-AO.SKQ.Setpoint.Mode = Mode;
-AO.SKQ.Setpoint.DataType = 'Scalar';
-AO.SKQ.Setpoint.Units = 'Hardware';
-AO.SKQ.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SKQ.Setpoint.Physics2HWFcn = @k2amp;
-AO.SKQ.Setpoint.HWUnits = 'ampere';
-AO.SKQ.Setpoint.PhysicsUnits = 'meter^-2';
-
-% common monitor setpoint stat devlist elem scale tol
-sq={
-'1SKQ1 ' 'SR01CPS03:CURRENT_MONITOR' 'SR01CPS03:CURRENT_SP ' 1 [1,1] 1 1 ; ...
-'1SKQ2 ' 'SR01CPS08:CURRENT_MONITOR' 'SR01CPS08:CURRENT_SP ' 1 [1,2] 2 1 ; ...
-'2SKQ1 ' 'SR02CPS03:CURRENT_MONITOR' 'SR02CPS03:CURRENT_SP ' 1 [2,1] 3 1 ; ...
-'2SKQ2 ' 'SR02CPS08:CURRENT_MONITOR' 'SR02CPS08:CURRENT_SP ' 1 [2,2] 4 1 ; ...
-'3SKQ1 ' 'SR03CPS03:CURRENT_MONITOR' 'SR03CPS03:CURRENT_SP ' 1 [3,1] 5 1 ; ...
-'3SKQ2 ' 'SR03CPS08:CURRENT_MONITOR' 'SR03CPS08:CURRENT_SP ' 1 [3,2] 6 1 ; ...
-'4SKQ1 ' 'SR04CPS03:CURRENT_MONITOR' 'SR04CPS03:CURRENT_SP ' 1 [4,1] 7 1 ; ...
-'4SKQ2 ' 'SR04CPS08:CURRENT_MONITOR' 'SR04CPS08:CURRENT_SP ' 1 [4,2] 8 1 ; ...
-'5SKQ1 ' 'SR05CPS03:CURRENT_MONITOR' 'SR05CPS03:CURRENT_SP ' 1 [5,1] 9 1 ; ...
-'5SKQ2 ' 'SR05CPS08:CURRENT_MONITOR' 'SR05CPS08:CURRENT_SP ' 1 [5,2] 10 1 ; ...
-'6SKQ1 ' 'SR06CPS03:CURRENT_MONITOR' 'SR06CPS03:CURRENT_SP ' 1 [6,1] 11 1 ; ...
-'6SKQ2 ' 'SR06CPS08:CURRENT_MONITOR' 'SR06CPS08:CURRENT_SP ' 1 [6,2] 12 1 ; ...
-'7SKQ1 ' 'SR07CPS03:CURRENT_MONITOR' 'SR07CPS03:CURRENT_SP ' 1 [7,1] 13 1 ; ...
-'7SKQ2 ' 'SR07CPS08:CURRENT_MONITOR' 'SR07CPS08:CURRENT_SP ' 1 [7,2] 14 1 ; ...
-'8SKQ1 ' 'SR08CPS03:CURRENT_MONITOR' 'SR08CPS03:CURRENT_SP ' 1 [8,1] 15 1 ; ...
-'8SKQ2 ' 'SR08CPS08:CURRENT_MONITOR' 'SR08CPS08:CURRENT_SP ' 1 [8,2] 16 1 ; ...
-'9SKQ1 ' 'SR09CPS03:CURRENT_MONITOR' 'SR09CPS03:CURRENT_SP ' 1 [9,1] 17 1 ; ...
-'9SKQ2 ' 'SR09CPS08:CURRENT_MONITOR' 'SR09CPS08:CURRENT_SP ' 1 [9,2] 18 1 ; ...
-'10SKQ1 ' 'SR10CPS03:CURRENT_MONITOR' 'SR10CPS03:CURRENT_SP ' 1 [10,1] 19 1 ; ...
-'10SKQ2 ' 'SR10CPS08:CURRENT_MONITOR' 'SR10CPS08:CURRENT_SP ' 1 [10,2] 20 1 ; ...
-'11SKQ1 ' 'SR11CPS03:CURRENT_MONITOR' 'SR11CPS03:CURRENT_SP ' 1 [11,1] 21 1 ; ...
-'11SKQ2 ' 'SR11CPS08:CURRENT_MONITOR' 'SR11CPS08:CURRENT_SP ' 1 [11,2] 22 1 ; ...
-'12SKQ1 ' 'SR12CPS03:CURRENT_MONITOR' 'SR12CPS03:CURRENT_SP ' 1 [12,1] 23 1 ; ...
-'12SKQ2 ' 'SR12CPS08:CURRENT_MONITOR' 'SR12CPS08:CURRENT_SP ' 1 [12,2] 24 1 ; ...
-'13SKQ1 ' 'SR13CPS03:CURRENT_MONITOR' 'SR13CPS03:CURRENT_SP ' 1 [13,1] 25 1 ; ...
-'13SKQ2 ' 'SR13CPS08:CURRENT_MONITOR' 'SR13CPS08:CURRENT_SP ' 1 [13,2] 26 1 ; ...
-'14SKQ1 ' 'SR14CPS03:CURRENT_MONITOR' 'SR14CPS03:CURRENT_SP ' 1 [14,1] 27 1 ; ...
-'14SKQ2 ' 'SR14CPS08:CURRENT_MONITOR' 'SR14CPS08:CURRENT_SP ' 1 [14,2] 28 1 ; ...
-};
-
-for ii=1:size(sq,1)
-name=sq{ii,1}; AO.SKQ.CommonNames(ii,:) = name;
-name=sq{ii,2}; AO.SKQ.Monitor.ChannelNames(ii,:) = name;
-name=sq{ii,3}; AO.SKQ.Setpoint.ChannelNames(ii,:) = name;
-val =sq{ii,4}; AO.SKQ.Status(ii,1) = val;
-val =sq{ii,5}; AO.SKQ.DeviceList(ii,:) = val;
-val =sq{ii,6}; AO.SKQ.ElementList(ii,1) = val;
-val =sq{ii,7}; AO.SKQ.Setpoint.Tolerance(ii,1) = val;
-AO.SKQ.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SKQ.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SKQ.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SKQ.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-
-AO.SKQ.Setpoint.Range(ii,:) = [-5 +5];
-end
-
-
-%===============
-%Kicker data
-%===============
-AO.KICK.FamilyName = 'KICK'; dispobject(AO,AO.KICK.FamilyName);
-AO.KICK.MemberOf = {'Injection','MachineConfig' 'Plotfamily'};
-
-AO.KICK.Monitor.Mode = Mode;
-AO.KICK.Monitor.DataType = 'Scalar';
-AO.KICK.Monitor.Units = 'Hardware';
-AO.KICK.Monitor.HWUnits = 'kVolts';
-AO.KICK.Monitor.PhysicsUnits = 'mradian';
-
-AO.KICK.Setpoint.Mode = Mode;
-AO.KICK.Setpoint.DataType = 'Scalar';
-AO.KICK.Setpoint.Units = 'Hardware';
-AO.KICK.Setpoint.HWUnits = 'Volts';
-AO.KICK.Setpoint.PhysicsUnits = 'radian';
-
-% From kicker deisgn review the kickers are rated to 4380 Amps giving 0.038
-% Tesla converting this to kickangle. Also convert voltage into amps for
-% the conversion?
-%
-% 2780 V on the capacitor banks will create 5240 A delivered to the kicker
-% magnets.
-% From simulations 4380 A creates 0.038607 T over a length of 0.7 m.
-% Therefore 4380 A => 2.7006 mrad. Therefore 2323.740 V => 2.7006 mrad.
-% HW2PHYSICS conversion factor (kV to rad) is therefore 0.0027006/2.32374 =
-% 0.00116217821271. The Ps also goes through a 1:3 transformer therefore
-% the conversion factor increases by 3. Ie 0.00348653463813
-% For V to rad then 0.00000348653463813.
-hw2physics_conversionfactor = 0.00000348653463813;
-
-% Measured
-% Kicker1 100 V = 0.176 mrad
-% Kicker2 100 V = -0.138 mrad
-% Kicker3 100 V = -0.134 mrad
-% Kicker4 100 V = 0.176 mrad
-
-%common monitor setpoint stat devlist elem tol
-kickeramp={
-'KICK1 ' 'SR14KPS01:VOLTAGE_MONITOR' 'SR14KPS01:VOLTAGE_SP ' 1 [1,1] 1 0.10 ; ...
-'KICK2 ' 'SR01KPS01:VOLTAGE_MONITOR' 'SR01KPS01:VOLTAGE_SP ' 1 [1,2] 2 0.10 ; ...
-'KICK3 ' 'SR01KPS02:VOLTAGE_MONITOR' 'SR01KPS02:VOLTAGE_SP ' 1 [1,3] 3 0.10 ; ...
-'KICK4 ' 'SR02KPS01:VOLTAGE_MONITOR' 'SR02KPS01:VOLTAGE_SP ' 1 [1,4] 4 0.10 ; ...
-};
-
-for ii=1:size(kickeramp,1)
-name=kickeramp{ii,1}; AO.KICK.CommonNames(ii,:) = name;
-name=kickeramp{ii,2}; AO.KICK.Monitor.ChannelNames(ii,:) = name;
-name=kickeramp{ii,3}; AO.KICK.Setpoint.ChannelNames(ii,:)= name;
-val =kickeramp{ii,4}; AO.KICK.Status(ii,1) = val;
-val =kickeramp{ii,5}; AO.KICK.DeviceList(ii,:) = val;
-val =kickeramp{ii,6}; AO.KICK.ElementList(ii,1) = val;
-val =kickeramp{ii,7}; AO.KICK.Setpoint.Tolerance(ii,1) = val;
-
-if ii==1||ii==4
- hw2physics_conversionfactor = 1.7600e-06;
- AO.KICK.Monitor.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
- AO.KICK.Monitor.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
- AO.KICK.Setpoint.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.Range(ii,:) = [-1300 +1300];
-else
- hw2physics_conversionfactor = 1.3600e-06;
- AO.KICK.Monitor.HW2PhysicsParams(ii,:) = -hw2physics_conversionfactor;
- AO.KICK.Monitor.Physics2HWParams(ii,:) = -1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.HW2PhysicsParams(ii,:) = -hw2physics_conversionfactor;
- AO.KICK.Setpoint.Physics2HWParams(ii,:) = -1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.Range(ii,:) = [+1300 -1300];
-end
-end
-
-% *** KICK Delay ***
-% AO.KICK.Delay
-% >> removed >> see previous versions if info needed
-
-
-%============
-%RF System
-%============
-AO.RF.FamilyName = 'RF'; dispobject(AO,AO.RF.FamilyName);
-AO.RF.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
-
-%-------------------------------- 4 cavity Case
-%common stat devlist elem
-rfcommon={
-'RF1 ' 1 [1,1] 1 ; ...
-'RF2 ' 1 [1,2] 2 ; ...
-'RF3 ' 1 [1,3] 3 ; ...
-'RF4 ' 1 [1,4] 4 ; ...
- };
-
-%FreqMon FreqSetpoint HW2PhysicsParams Physics2HWParams Range Tolerance
-rffreq={
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
-'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
- };
-
-% PhaseCtrl PhaseMon HW2PhysicsParams Physics2HWParams Range Tolerance
-rfphase={
-'SRF1:STN:PHASE' 'SRF1:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
-'SRF2:STN:PHASE' 'SRF2:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
-'SRF3:STN:PHASE' 'SRF3:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
-'SRF4:STN:PHASE' 'SRF4:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
- };
-
-% VoltCtrl VoltMon HW2PhysicsParams Physics2HWParams Range Tolerance
-rfvolt={
-'SRF1:STN:VOLT:CTRL ' 'SRF1:STN:VOLT' 1 1 [-inf inf] inf ; ...
-'SRF2:STN:VOLT:CTRL ' 'SRF2:STN:VOLT' 1 1 [-inf inf] inf ; ...
-'SRF3:STN:VOLT:CTRL ' 'SRF3:STN:VOLT' 1 1 [-inf inf] inf ; ...
-'SRF4:STN:VOLT:CTRL ' 'SRF4:STN:VOLT' 1 1 [-inf inf] inf ; ...
- };
-% PowerCtrl PowerMon Klystronpower HW2PhysicsParams Physics2HWParams Range Tolerance
-rfpower={
-'SRF1:KLYSDRIVFRWD:POWER:ON ' 'SRF1:KLYSDRIVFRWD:POWER' 'SRF1:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-'SRF2:KLYSDRIVFRWD:POWER:ON ' 'SRF2:KLYSDRIVFRWD:POWER' 'SRF2:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-'SRF3:KLYSDRIVFRWD:POWER:ON ' 'SRF3:KLYSDRIVFRWD:POWER' 'SRF3:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-'SRF4:KLYSDRIVFRWD:POWER:ON ' 'SRF4:KLYSDRIVFRWD:POWER' 'SRF4:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
- };
-
-for ii=1:size(rfcommon,1)
-name=rfcommon{ii,1}; AO.RF.CommonNames(ii,:) = name;
-val =rfcommon{ii,2}; AO.RF.Status(ii,1) = val;
-val =rfcommon{ii,3}; AO.RF.DeviceList(ii,:) = val;
-val =rfcommon{ii,4}; AO.RF.ElementList(ii,1) = val;
-end
-
-for ii=1:size(rffreq,1)
-name=rffreq{ii,1}; AO.RF.Monitor.ChannelNames(ii,:) = name;
-name=rffreq{ii,2}; AO.RF.Setpoint.ChannelNames(ii,:) = name;
-val =rffreq{ii,3}; AO.RF.Monitor.HW2PhysicsParams(ii,1) = val;
- AO.RF.Setpoint.HW2PhysicsParams(ii,1) = val;
-val =rffreq{ii,4}; AO.RF.Monitor.Physics2HWParams(ii,1) = val;
- AO.RF.Setpoint.Physics2HWParams(ii,1) = val;
-val =rffreq{ii,5}; AO.RF.Setpoint.Range(ii,:) = val;
-val =rffreq{ii,6}; AO.RF.Setpoint.Tolerance(ii,1) = val;
-end
-
-
-for ii=1:size(rfphase,1)
-name=rfphase{ii,1}; AO.RF.PhaseCtrl.ChannelNames(ii,:) = name;
-name=rfphase{ii,2}; AO.RF.Phase.ChannelNames(ii,:) = name;
-val =rfphase{ii,3}; AO.RF.PhaseCtrl.HW2PhysicsParams(ii,1) = val;
- AO.RF.Phase.HW2PhysicsParams(ii,1) = val;
-val =rfphase{ii,4}; AO.RF.PhaseCtrl.Physics2HWParams(ii,1) = val;
- AO.RF.Phase.Physics2HWParams(ii,1) = val;
-val =rfphase{ii,5}; AO.RF.PhaseCtrl.Range(ii,:) = val;
- AO.RF.Phase.Range(ii,:) = val;
-val =rfphase{ii,6}; AO.RF.PhaseCtrl.Tolerance(ii,1) = val;
- AO.RF.Phase.Tolerance(ii,1) = val;
-end
-
-
-for ii=1:size(rfvolt,1)
-name=rfvolt{ii,1}; AO.RF.VoltageCtrl.ChannelNames(ii,:) = name;
-name=rfvolt{ii,2}; AO.RF.Voltage.ChannelNames(ii,:) = name;
-val =rfvolt{ii,3}; AO.RF.VoltageCtrl.HW2PhysicsParams(ii,1) = val;
- AO.RF.Voltage.HW2PhysicsParams(ii,1) = val;
-val =rfvolt{ii,4}; AO.RF.VoltageCtrl.Physics2HWParams(ii,1) = val;
- AO.RF.Voltage.Physics2HWParams(ii,1) = val;
-val =rfvolt{ii,5}; AO.RF.VoltageCtrl.Range(ii,:) = val;
- AO.RF.Voltage.Range(ii,:) = val;
-val =rfvolt{ii,6}; AO.RF.VoltageCtrl.Tolerance(ii,1) = val;
- AO.RF.Voltage.Tolerance(ii,1) = val;
-end
-
-
-for ii=1:size(rfpower,1)
-name=rfpower{ii,1}; AO.RF.PowerCtrl.ChannelNames(ii,:) = name;
-name=rfpower{ii,2}; AO.RF.Power.ChannelNames(ii,:) = name;
-name=rfpower{ii,3}; AO.RF.KlysPower.ChannelNames(ii,:) = name;
-val =rfpower{ii,4}; AO.RF.PowerCtrl.HW2PhysicsParams(ii,1) = val;
- AO.RF.Power.HW2PhysicsParams(ii,1) = val;
- AO.RF.KlysPower.HW2PhysicsParams(ii,1) = val;
-val =rfpower{ii,5}; AO.RF.PowerCtrl.Physics2HWParams(ii,1) = val;
- AO.RF.Power.Physics2HWParams(ii,1) = val;
- AO.RF.KlysPower.Physics2HWParams(ii,1) = val;
-val =rfpower{ii,6}; AO.RF.PowerCtrl.Range(ii,:) = val;
- AO.RF.Power.Range(ii,:) = val;
- AO.RF.KlysPower.Range(ii,:) = val;
-val =rfpower{ii,7}; AO.RF.PowerCtrl.Tolerance(ii,1) = val;
- AO.RF.Power.Tolerance(ii,1) = val;
- AO.RF.KlysPower.Tolerance(ii,1) = val;
-end
-
-%Frequency Readback
-AO.RF.Monitor.Mode = Mode;
-AO.RF.Monitor.DataType = 'Scalar';
-AO.RF.Monitor.Units = 'Hardware';
-AO.RF.Monitor.HWUnits = 'Hz';
-AO.RF.Monitor.PhysicsUnits = 'Hz';
-%Frequency Setpoint
-AO.RF.Setpoint.Mode = Mode;
-AO.RF.Setpoint.DataType = 'Scalar';
-AO.RF.Setpoint.Units = 'Hardware';
-AO.RF.Setpoint.HWUnits = 'Hz';
-AO.RF.Setpoint.PhysicsUnits = 'Hz';
-
-%Voltage control
-AO.RF.VoltageCtrl.Mode = Mode;
-AO.RF.VoltageCtrl.DataType = 'Scalar';
-AO.RF.VoltageCtrl.Units = 'Hardware';
-AO.RF.VoltageCtrl.HWUnits = 'Volts';
-AO.RF.VoltageCtrl.PhysicsUnits = 'Volts';
-
-%Voltage monitor
-AO.RF.Voltage.Mode = Mode;
-AO.RF.Voltage.DataType = 'Scalar';
-AO.RF.Voltage.Units = 'Hardware';
-AO.RF.Voltage.HWUnits = 'Volts';
-AO.RF.Voltage.PhysicsUnits = 'Volts';
-
-%Power Control
-AO.RF.PowerCtrl.Mode = Mode;
-AO.RF.PowerCtrl.DataType = 'Scalar';
-AO.RF.PowerCtrl.Units = 'Hardware';
-AO.RF.PowerCtrl.HWUnits = 'MWatts';
-AO.RF.PowerCtrl.PhysicsUnits = 'MWatts';
-
-%Power Monitor
-AO.RF.Power.Mode = Mode;
-AO.RF.Power.DataType = 'Scalar';
-AO.RF.Power.Units = 'Hardware';
-AO.RF.Power.HWUnits = 'MWatts';
-AO.RF.Power.PhysicsUnits = 'MWatts';
-
-%Klystron Forward Power
-AO.RF.KlysPower.Mode = Mode;
-AO.RF.KlysPower.DataType = 'Scalar';
-AO.RF.KlysPower.Units = 'Hardware';
-AO.RF.KlysPower.HWUnits = 'MWatts';
-AO.RF.KlysPower.PhysicsUnits = 'MWatts';
-
-%Station Phase Control
-AO.RF.PhaseCtrl.Mode = Mode;
-AO.RF.PhaseCtrl.DataType = 'Scalar';
-AO.RF.PhaseCtrl.Units = 'Hardware';
-AO.RF.PhaseCtrl.HWUnits = 'Degrees';
-AO.RF.PhaseCtrl.PhysicsUnits = 'Degrees';
-
-
-%Station Phase Monitor
-AO.RF.Phase.Mode = Mode;
-AO.RF.Phase.DataType = 'Scalar';
-AO.RF.Phase.Units = 'Hardware';
-AO.RF.Phase.HWUnits = 'Degrees';
-AO.RF.Phase.PhysicsUnits = 'Degrees';
-
-%====
-%TUNE
-%====
-AO.TUNE.FamilyName = 'TUNE'; dispobject(AO,AO.TUNE.FamilyName);
-AO.TUNE.MemberOf = {'Tune'; 'Diagnostics'};
-AO.TUNE.CommonNames = ['xtune';'ytune'];
-AO.TUNE.DeviceList = [ 1 1; 1 2];
-AO.TUNE.ElementList = [1 2]';
-AO.TUNE.Status = [1 1]';
-
-AO.TUNE.Monitor.Mode = 'Special';
-AO.TUNE.Monitor.SpecialFunction = 'meastune';
-AO.TUNE.Monitor.DataType = 'Vector';
-AO.TUNE.Monitor.DataTypeIndex = [1 2]';
-AO.TUNE.Monitor.Units = 'Hardware';
-AO.TUNE.Monitor.HW2PhysicsParams = 1;
-AO.TUNE.Monitor.Physics2HWParams = 1;
-AO.TUNE.Monitor.HWUnits = 'fractional tune';
-AO.TUNE.Monitor.PhysicsUnits = 'fractional tune';
-
-
-% AO.FTx.Length.Mode = 'Special';
-% AO.FTx.Length.Units = 'Hardware';
-% AO.FTx.Length.DataType = 'Scalar';
-% AO.FTx.Length.SpecialFunction = 'getftlength';
-% AO.FTx.Length.SpecialFunctionSet = 'setftlength';
-% AO.FTx.Length.HWUnits = '32ns samples';
-% AO.FTx.Length.PhysicsUnits = '32ns samples';
-% AO.FTx.Length.HW2PhysicsParams = 1;
-% AO.FTx.Length.Physics2HWParams = 1;
-
-
-%====
-%DCCT
-%====
-AO.DCCT.FamilyName = 'DCCT'; dispobject(AO,AO.DCCT.FamilyName);
-AO.DCCT.MemberOf = {'Diagnostics'};
-AO.DCCT.CommonNames = 'DCCT';
-AO.DCCT.DeviceList = [1 1];
-AO.DCCT.ElementList = [1];
-AO.DCCT.Status = [1];
-
-AO.DCCT.Monitor.Mode = Mode;
-AO.DCCT.Monitor.DataType = 'Scalar';
-AO.DCCT.Monitor.ChannelNames = 'SR11BCM01:CURRENT_MONITOR';
-AO.DCCT.Monitor.Units = 'Hardware';
-AO.DCCT.Monitor.HWUnits = 'milli-ampere';
-AO.DCCT.Monitor.PhysicsUnits = 'ampere';
-AO.DCCT.Monitor.HW2PhysicsParams = 1e-3;
-AO.DCCT.Monitor.Physics2HWParams = 1000;
-
-
-% %==================
-% %Machine Parameters
-% %==================
-% Removed in this version, see pervious version for more info
-
-%======
-%Septum
-%======
-% ifam=ifam+1;
-% AO.Septum.FamilyName = 'Septum'; dispobject(AO,AO.Septum.FamilyName);
-% AO.Septum.MemberOf = {'Injection'};
-% AO.Septum.Status = 1;
-%
-% AO.Septum.CommonNames = 'Septum ';
-% AO.Septum.DeviceList = [3 1];
-% AO.Septum.ElementList = [1];
-%
-% AO.Septum.Monitor.Mode = Mode;
-% AO.Septum.Monitor.DataType = 'Scalar';
-% AO.Septum.Monitor.Units = 'Hardware';
-% AO.Septum.Monitor.HWUnits = 'ampere';
-% AO.Septum.Monitor.PhysicsUnits = 'radian';
-% AO.Septum.Monitor.ChannelNames = 'BTS-B9V:Curr';
-%
-% AO.Septum.Setpoint.Mode = Mode;
-% AO.Septum.Setpoint.DataType = 'Scalar';
-% AO.Septum.Setpoint.Units = 'Hardware';
-% AO.Septum.Setpoint.HWUnits = 'ampere';
-% AO.Septum.Setpoint.PhysicsUnits = 'radian';
-% AO.Septum.Setpoint.ChannelNames = 'BTS-B9V:CurrSetpt';
-% AO.Septum.Setpoint.Range = [0, 2500];
-% AO.Septum.Setpoint.Tolerance = 100.0;
-%
-% AO.Septum.Monitor.HW2PhysicsParams = 1;
-% AO.Septum.Monitor.Physics2HWParams = 1;
-% AO.Septum.Setpoint.HW2PhysicsParams = 1;
-% AO.Septum.Setpoint.Physics2HWParams = 1;
-
-
-%====================
-%Photon Beamline Data
-%====================
-% >> removed >> see previous versions if info needed
-
-%====================
-%BPLD Data
-%====================
-% >> removed >> see previous versions if info needed
-
-
-
-% The operational mode sets the path, filenames, and other important parameters
-% Run setoperationalmode after most of the AO is built so that the Units and Mode fields
-% can be set in setoperationalmode
-fprintf('\n');
-setao(AO);
-setoperationalmode(OperationalMode);
-AO = getao;
-
-
-%%%%%%%%%%%%%%%%
-% DeltaRespMat %
-%%%%%%%%%%%%%%%%
-
-% I remove the physics2hw conversion because the physics2hw is
-% is calibrated yet.
-
-% Set response matrix kick size in hardware units (amps)
-AO.HCM.Setpoint.DeltaRespMat = physics2hw('HCM', 'Setpoint', 2.0e-4, AO.HCM.DeviceList);
-AO.VCM.Setpoint.DeltaRespMat = physics2hw('VCM', 'Setpoint', 1.0e-4, AO.VCM.DeviceList);
-
-%% 'NoEnergyScaling' because I don't want to force a BEND magnet read at this point
-%AO.HCM.Setpoint.DeltaRespMat = mm2amps('HCM', .5, AO.HCM.DeviceList, 'NoEnergyScaling');
-%AO.VCM.Setpoint.DeltaRespMat = mm2amps('VCM', .5, AO.VCM.DeviceList, 'NoEnergyScaling');
-
-
-AO.QFA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFA.FamilyName, 'Setpoint', AO.QFA.Setpoint.DeltaRespMat, AO.QFA.DeviceList);
-AO.QFB.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFB.FamilyName, 'Setpoint', AO.QFB.Setpoint.DeltaRespMat, AO.QFB.DeviceList);
-AO.QDA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QDA.FamilyName, 'Setpoint', AO.QDA.Setpoint.DeltaRespMat, AO.QDA.DeviceList);
-
-
-AO.SFA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFA.FamilyName, 'Setpoint', AO.SFA.Setpoint.DeltaRespMat, AO.SFA.DeviceList);
-AO.SFB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFB.FamilyName, 'Setpoint', AO.SFB.Setpoint.DeltaRespMat, AO.SFB.DeviceList);
-AO.SDA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDA.FamilyName, 'Setpoint', AO.SDA.Setpoint.DeltaRespMat, AO.SDA.DeviceList);
-AO.SDB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDB.FamilyName, 'Setpoint', AO.SDB.Setpoint.DeltaRespMat, AO.SDB.DeviceList);
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get S-positions [meters] %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Using ...ATIndex(:,1) will accomodata for split elements where the first
-% of a group of elements is put in the first column ie, if SFA is split in
-% two then ATIndex will look like [2 3; 11 12; ...] where each row is a
-% magnet and column represents each split.
-global THERING
-AO.BPMx.Position = findspos(THERING, AO.BPMx.AT.ATIndex(:,1))';
-AO.BPMy.Position = findspos(THERING, AO.BPMy.AT.ATIndex(:,1))';
-AO.FTx.Position = findspos(THERING, AO.FTx.AT.ATIndex(:,1))';
-AO.FTy.Position = findspos(THERING, AO.FTy.AT.ATIndex(:,1))';
-AO.FTsum.Position= findspos(THERING, AO.FTsum.AT.ATIndex(:,1))';
-AO.HCM.Position = findspos(THERING, AO.HCM.AT.ATIndex(:,1))';
-AO.VCM.Position = findspos(THERING, AO.VCM.AT.ATIndex(:,1))';
-AO.QFA.Position = findspos(THERING, AO.QFA.AT.ATIndex(:,1))';
-AO.QDA.Position = findspos(THERING, AO.QDA.AT.ATIndex(:,1))';
-AO.QFB.Position = findspos(THERING, AO.QFB.AT.ATIndex(:,1))';
-AO.SFA.Position = findspos(THERING, AO.SFA.AT.ATIndex(:,1))';
-AO.SFB.Position = findspos(THERING, AO.SFB.AT.ATIndex(:,1))';
-AO.SDA.Position = findspos(THERING, AO.SDA.AT.ATIndex(:,1))';
-AO.SDB.Position = findspos(THERING, AO.SDB.AT.ATIndex(:,1))';
-AO.SKQ.Position = findspos(THERING, AO.SKQ.AT.ATIndex(:,1))';
-AO.BEND.Position = findspos(THERING, AO.BEND.AT.ATIndex(:,1))';
-AO.RF.Position = findspos(THERING, AO.RF.AT.ATIndex(:,1))';
-AO.KICK.Position = findspos(THERING, AO.KICK.AT.ATIndex(:,1))';
-AO.DCCT.Position = 0;
-AO.TUNE.Position = 0;
-
-
-% Save AO
-setao(AO);
-
-
-function dispobject(AO,name)
-
-n = length(fieldnames(AO));
-
-if n > 0
- fprintf(' %10s ',name);
- if mod(n,5) == 0
- fprintf('\n');
- end
+function aspinit(OperationalMode)
+% aspinit(OperationalMode)
+%
+% Initialize parameters for ASP control in MATLAB
+%
+%==========================
+% Accelerator Family Fields
+%==========================
+% FamilyName BPMx, HCM, etc
+% CommonNames Shortcut name for each element (optional)
+% DeviceList [Sector, Number]
+% ElementList number in list
+% Position m, magnet center
+%
+% MONITOR FIELDS
+% Mode online/manual/special/simulator
+% ChannelNames PV for monitor
+% Units Physics or HW
+% HW2PhysicsFcn function handle used to convert from hardware to physics units ==> inline will not compile, see below
+% HW2PhysicsParams parameters used for conversion function
+% Physics2HWFcn function handle used to convert from physics to hardware units
+% Physics2HWParams parameters used for conversion function
+% HWUnits units for Hardware 'ampere';
+% PhysicsUnits units for physics 'Rad';
+%
+% SETPOINT FIELDS
+% Mode online/manual/special/simulator
+% ChannelNames PV for monitor
+% Units hardware or physics
+% HW2PhysicsFcn function handle used to convert from hardware to physics units
+% HW2PhysicsParams parameters used for conversion function
+% Physics2HWFcn function handle used to convert from physics to hardware units
+% Physics2HWParams parameters used for conversion function
+% HWUnits units for Hardware 'ampere';
+% PhysicsUnits units for physics 'Rad';
+% Range minsetpoint, maxsetpoint;
+% Tolerance setpoint-monitor
+%
+%=============================================
+% Accelerator Toolbox Simulation Fields
+%=============================================
+% ATType Quad, Sext, etc
+% ATIndex index in THERING
+% ATParameterGroup parameter group
+%
+%============
+% Family List
+%============
+% BPMx BPMy - beam position monitors
+% HCM VCM - corrector magnets wound into sextupoles
+% BEND - gradient dipoles
+% QFA QDA QFB - quadrupole magnets
+% SFA SDA SDB SFB - sextupole magnets
+% SQK - skew quads wound into SDA magnets
+% KICK - injection kickers (DELTA type)
+% RF - 4 cavities (KEK type?)
+% DCCT
+% Septum (Not in model yet)
+%
+% Normal cell: d1 bpm s1 hcor d2 q1 d3 s2 d4 bpm dip bpm d4 hcor s3 d5 q2 d6 q3 d2 bpm s4
+% d2 q3 d6 q2 d5 s3 hcor d4 bpm dip bpm d4 s2 d3 q1 d2 hcor s1 bpm d1
+
+% === Change Log ===
+% Mark Boland 2004-02-12
+% Eugene Tan 2004-02-23
+% Eugene Tan 2004-12-13
+% Eugene Tan 2005-09-27 ver 4
+% Updated naming convention of the process variables, use version 4 of
+% the lattice "assr4.m" where the correctors have been merged into the
+% sextupoles. Made the necessary changes to updateatindex. Added skew
+% quadrupoles and updated generate_init.
+% Mark Boland 2006-05-27
+% Changed the BPM PVs to ...:SA_HPOS_MONITOR and ...:SA_VPOS_MONITOR
+%
+% Mark Boland 2006-08-29
+% Changed range on HCM and VCM from - to + since the polarity of the
+% correctors was physically changed in the last weeks.
+%
+% === Still to do ===
+% - kicker delays
+% - BPM names and other possible PVs of interest eg. Q factor etc.
+% - clean up and configure the amp2k and k2amp conversion. Control system
+% designed to calculate the strengths and amp values using calc records,
+% therefore we should only need to change the PV name to access for
+% readback at setpoints. Only problem will be in simulation/offline mode
+% where those value are not available online. How do you keep the offline
+% conversion factors up to date with online vals?
+%
+% === Generated from ===
+% aspinit_v5skeleton.m
+
+% Default operational mode
+if nargin < 1
+ OperationalMode = 1;
+end
+
+
+%=============================================
+% START DEFINITION OF ACCELERATOR OBJECTS
+%=============================================
+fprintf(' Defining the Accelerator Objects. Objects being defined:\n')
+
+
+% Clear previous AcceleratorObjects
+setao([]);
+
+
+Mode = 'Online'; % This gets reset in setoperationalmode
+
+%=============================================
+%BPM data: status field designates if BPM in use
+%=============================================
+ntbpm=98;
+AO.BPMx.FamilyName = 'BPMx'; dispobject(AO,AO.BPMx.FamilyName);
+AO.BPMx.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'; 'BPMx'};
+AO.BPMx.Monitor.Mode = Mode;
+AO.BPMx.Monitor.DataType = 'Scalar';
+AO.BPMx.Monitor.Units = 'Hardware';
+AO.BPMx.Monitor.HWUnits = 'mm';
+AO.BPMx.Monitor.PhysicsUnits = 'meter';
+
+AO.BPMy.FamilyName = 'BPMy'; dispobject(AO,AO.BPMy.FamilyName);
+AO.BPMy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'; 'BPMy'};
+AO.BPMy.Monitor.Mode = Mode;
+AO.BPMy.Monitor.DataType = 'Scalar';
+AO.BPMy.Monitor.Units = 'Hardware';
+AO.BPMy.Monitor.HWUnits = 'mm';
+AO.BPMy.Monitor.PhysicsUnits = 'meter';
+
+% x-name x-chname xstat y-name y-chname ystat DevList Elem
+bpm={
+'1BPMx1 ' 'SR01BPM01:SA_HPOS_MONITOR' 1 '1BPMy1 ' 'SR01BPM01:SA_VPOS_MONITOR' 1 [1,1] 1 ; ...
+'1BPMx2 ' 'SR01BPM02:SA_HPOS_MONITOR' 1 '1BPMy2 ' 'SR01BPM02:SA_VPOS_MONITOR' 1 [1,2] 2 ; ...
+'1BPMx3 ' 'SR01BPM03:SA_HPOS_MONITOR' 1 '1BPMy3 ' 'SR01BPM03:SA_VPOS_MONITOR' 1 [1,3] 3 ; ...
+'1BPMx4 ' 'SR01BPM04:SA_HPOS_MONITOR' 1 '1BPMy4 ' 'SR01BPM04:SA_VPOS_MONITOR' 1 [1,4] 4 ; ...
+'1BPMx5 ' 'SR01BPM05:SA_HPOS_MONITOR' 1 '1BPMy5 ' 'SR01BPM05:SA_VPOS_MONITOR' 1 [1,5] 5 ; ...
+'1BPMx6 ' 'SR01BPM06:SA_HPOS_MONITOR' 1 '1BPMy6 ' 'SR01BPM06:SA_VPOS_MONITOR' 1 [1,6] 6 ; ...
+'1BPMx7 ' 'SR01BPM07:SA_HPOS_MONITOR' 1 '1BPMy7 ' 'SR01BPM07:SA_VPOS_MONITOR' 1 [1,7] 7 ; ...
+'2BPMx1 ' 'SR02BPM01:SA_HPOS_MONITOR' 1 '2BPMy1 ' 'SR02BPM01:SA_VPOS_MONITOR' 1 [2,1] 8 ; ...
+'2BPMx2 ' 'SR02BPM02:SA_HPOS_MONITOR' 0 '2BPMy2 ' 'SR02BPM02:SA_VPOS_MONITOR' 0 [2,2] 9 ; ...
+'2BPMx3 ' 'SR02BPM03:SA_HPOS_MONITOR' 1 '2BPMy3 ' 'SR02BPM03:SA_VPOS_MONITOR' 1 [2,3] 10 ; ...
+'2BPMx4 ' 'SR02BPM04:SA_HPOS_MONITOR' 1 '2BPMy4 ' 'SR02BPM04:SA_VPOS_MONITOR' 1 [2,4] 11 ; ...
+'2BPMx5 ' 'SR02BPM05:SA_HPOS_MONITOR' 1 '2BPMy5 ' 'SR02BPM05:SA_VPOS_MONITOR' 1 [2,5] 12 ; ...
+'2BPMx6 ' 'SR02BPM06:SA_HPOS_MONITOR' 1 '2BPMy6 ' 'SR02BPM06:SA_VPOS_MONITOR' 1 [2,6] 13 ; ...
+'2BPMx7 ' 'SR02BPM07:SA_HPOS_MONITOR' 1 '2BPMy7 ' 'SR02BPM07:SA_VPOS_MONITOR' 1 [2,7] 14 ; ...
+'3BPMx1 ' 'SR03BPM01:SA_HPOS_MONITOR' 1 '3BPMy1 ' 'SR03BPM01:SA_VPOS_MONITOR' 1 [3,1] 15 ; ...
+'3BPMx2 ' 'SR03BPM02:SA_HPOS_MONITOR' 1 '3BPMy2 ' 'SR03BPM02:SA_VPOS_MONITOR' 1 [3,2] 16 ; ...
+'3BPMx3 ' 'SR03BPM03:SA_HPOS_MONITOR' 1 '3BPMy3 ' 'SR03BPM03:SA_VPOS_MONITOR' 1 [3,3] 17 ; ...
+'3BPMx4 ' 'SR03BPM04:SA_HPOS_MONITOR' 1 '3BPMy4 ' 'SR03BPM04:SA_VPOS_MONITOR' 1 [3,4] 18 ; ...
+'3BPMx5 ' 'SR03BPM05:SA_HPOS_MONITOR' 1 '3BPMy5 ' 'SR03BPM05:SA_VPOS_MONITOR' 1 [3,5] 19 ; ...
+'3BPMx6 ' 'SR03BPM06:SA_HPOS_MONITOR' 1 '3BPMy6 ' 'SR03BPM06:SA_VPOS_MONITOR' 1 [3,6] 20 ; ...
+'3BPMx7 ' 'SR03BPM07:SA_HPOS_MONITOR' 1 '3BPMy7 ' 'SR03BPM07:SA_VPOS_MONITOR' 1 [3,7] 21 ; ...
+'4BPMx1 ' 'SR04BPM01:SA_HPOS_MONITOR' 1 '4BPMy1 ' 'SR04BPM01:SA_VPOS_MONITOR' 1 [4,1] 22 ; ...
+'4BPMx2 ' 'SR04BPM02:SA_HPOS_MONITOR' 1 '4BPMy2 ' 'SR04BPM02:SA_VPOS_MONITOR' 1 [4,2] 23 ; ...
+'4BPMx3 ' 'SR04BPM03:SA_HPOS_MONITOR' 1 '4BPMy3 ' 'SR04BPM03:SA_VPOS_MONITOR' 1 [4,3] 24 ; ...
+'4BPMx4 ' 'SR04BPM04:SA_HPOS_MONITOR' 1 '4BPMy4 ' 'SR04BPM04:SA_VPOS_MONITOR' 1 [4,4] 25 ; ...
+'4BPMx5 ' 'SR04BPM05:SA_HPOS_MONITOR' 0 '4BPMy5 ' 'SR04BPM05:SA_VPOS_MONITOR' 0 [4,5] 26 ; ...
+'4BPMx6 ' 'SR04BPM06:SA_HPOS_MONITOR' 1 '4BPMy6 ' 'SR04BPM06:SA_VPOS_MONITOR' 1 [4,6] 27 ; ...
+'4BPMx7 ' 'SR04BPM07:SA_HPOS_MONITOR' 0 '4BPMy7 ' 'SR04BPM07:SA_VPOS_MONITOR' 0 [4,7] 28 ; ...
+'5BPMx1 ' 'SR05BPM01:SA_HPOS_MONITOR' 1 '5BPMy1 ' 'SR05BPM01:SA_VPOS_MONITOR' 1 [5,1] 29 ; ...
+'5BPMx2 ' 'SR05BPM02:SA_HPOS_MONITOR' 1 '5BPMy2 ' 'SR05BPM02:SA_VPOS_MONITOR' 1 [5,2] 30 ; ...
+'5BPMx3 ' 'SR05BPM03:SA_HPOS_MONITOR' 0 '5BPMy3 ' 'SR05BPM03:SA_VPOS_MONITOR' 0 [5,3] 31 ; ...
+'5BPMx4 ' 'SR05BPM04:SA_HPOS_MONITOR' 1 '5BPMy4 ' 'SR05BPM04:SA_VPOS_MONITOR' 1 [5,4] 32 ; ...
+'5BPMx5 ' 'SR05BPM05:SA_HPOS_MONITOR' 1 '5BPMy5 ' 'SR05BPM05:SA_VPOS_MONITOR' 1 [5,5] 33 ; ...
+'5BPMx6 ' 'SR05BPM06:SA_HPOS_MONITOR' 1 '5BPMy6 ' 'SR05BPM06:SA_VPOS_MONITOR' 1 [5,6] 34 ; ...
+'5BPMx7 ' 'SR05BPM07:SA_HPOS_MONITOR' 1 '5BPMy7 ' 'SR05BPM07:SA_VPOS_MONITOR' 1 [5,7] 35 ; ...
+'6BPMx1 ' 'SR06BPM01:SA_HPOS_MONITOR' 1 '6BPMy1 ' 'SR06BPM01:SA_VPOS_MONITOR' 1 [6,1] 36 ; ...
+'6BPMx2 ' 'SR06BPM02:SA_HPOS_MONITOR' 1 '6BPMy2 ' 'SR06BPM02:SA_VPOS_MONITOR' 1 [6,2] 37 ; ...
+'6BPMx3 ' 'SR06BPM03:SA_HPOS_MONITOR' 1 '6BPMy3 ' 'SR06BPM03:SA_VPOS_MONITOR' 1 [6,3] 38 ; ...
+'6BPMx4 ' 'SR06BPM04:SA_HPOS_MONITOR' 1 '6BPMy4 ' 'SR06BPM04:SA_VPOS_MONITOR' 1 [6,4] 39 ; ...
+'6BPMx5 ' 'SR06BPM05:SA_HPOS_MONITOR' 1 '6BPMy5 ' 'SR06BPM05:SA_VPOS_MONITOR' 1 [6,5] 40 ; ...
+'6BPMx6 ' 'SR06BPM06:SA_HPOS_MONITOR' 0 '6BPMy6 ' 'SR06BPM06:SA_VPOS_MONITOR' 0 [6,6] 41 ; ...
+'6BPMx7 ' 'SR06BPM07:SA_HPOS_MONITOR' 1 '6BPMy7 ' 'SR06BPM07:SA_VPOS_MONITOR' 1 [6,7] 42 ; ...
+'7BPMx1 ' 'SR07BPM01:SA_HPOS_MONITOR' 0 '7BPMy1 ' 'SR07BPM01:SA_VPOS_MONITOR' 0 [7,1] 43 ; ...
+'7BPMx2 ' 'SR07BPM02:SA_HPOS_MONITOR' 1 '7BPMy2 ' 'SR07BPM02:SA_VPOS_MONITOR' 1 [7,2] 44 ; ...
+'7BPMx3 ' 'SR07BPM03:SA_HPOS_MONITOR' 0 '7BPMy3 ' 'SR07BPM03:SA_VPOS_MONITOR' 0 [7,3] 45 ; ...
+'7BPMx4 ' 'SR07BPM04:SA_HPOS_MONITOR' 1 '7BPMy4 ' 'SR07BPM04:SA_VPOS_MONITOR' 1 [7,4] 46 ; ...
+'7BPMx5 ' 'SR07BPM05:SA_HPOS_MONITOR' 1 '7BPMy5 ' 'SR07BPM05:SA_VPOS_MONITOR' 1 [7,5] 47 ; ...
+'7BPMx6 ' 'SR07BPM06:SA_HPOS_MONITOR' 1 '7BPMy6 ' 'SR07BPM06:SA_VPOS_MONITOR' 1 [7,6] 48 ; ...
+'7BPMx7 ' 'SR07BPM07:SA_HPOS_MONITOR' 1 '7BPMy7 ' 'SR07BPM07:SA_VPOS_MONITOR' 1 [7,7] 49 ; ...
+'8BPMx1 ' 'SR08BPM01:SA_HPOS_MONITOR' 1 '8BPMy1 ' 'SR08BPM01:SA_VPOS_MONITOR' 1 [8,1] 50 ; ...
+'8BPMx2 ' 'SR08BPM02:SA_HPOS_MONITOR' 1 '8BPMy2 ' 'SR08BPM02:SA_VPOS_MONITOR' 1 [8,2] 51 ; ...
+'8BPMx3 ' 'SR08BPM03:SA_HPOS_MONITOR' 1 '8BPMy3 ' 'SR08BPM03:SA_VPOS_MONITOR' 1 [8,3] 52 ; ...
+'8BPMx4 ' 'SR08BPM04:SA_HPOS_MONITOR' 1 '8BPMy4 ' 'SR08BPM04:SA_VPOS_MONITOR' 1 [8,4] 53 ; ...
+'8BPMx5 ' 'SR08BPM05:SA_HPOS_MONITOR' 1 '8BPMy5 ' 'SR08BPM05:SA_VPOS_MONITOR' 1 [8,5] 54 ; ...
+'8BPMx6 ' 'SR08BPM06:SA_HPOS_MONITOR' 1 '8BPMy6 ' 'SR08BPM06:SA_VPOS_MONITOR' 1 [8,6] 55 ; ...
+'8BPMx7 ' 'SR08BPM07:SA_HPOS_MONITOR' 1 '8BPMy7 ' 'SR08BPM07:SA_VPOS_MONITOR' 1 [8,7] 56 ; ...
+'9BPMx1 ' 'SR09BPM01:SA_HPOS_MONITOR' 1 '9BPMy1 ' 'SR09BPM01:SA_VPOS_MONITOR' 1 [9,1] 57 ; ...
+'9BPMx2 ' 'SR09BPM02:SA_HPOS_MONITOR' 1 '9BPMy2 ' 'SR09BPM02:SA_VPOS_MONITOR' 1 [9,2] 58 ; ...
+'9BPMx3 ' 'SR09BPM03:SA_HPOS_MONITOR' 1 '9BPMy3 ' 'SR09BPM03:SA_VPOS_MONITOR' 1 [9,3] 59 ; ...
+'9BPMx4 ' 'SR09BPM04:SA_HPOS_MONITOR' 1 '9BPMy4 ' 'SR09BPM04:SA_VPOS_MONITOR' 1 [9,4] 60 ; ...
+'9BPMx5 ' 'SR09BPM05:SA_HPOS_MONITOR' 0 '9BPMy5 ' 'SR09BPM05:SA_VPOS_MONITOR' 0 [9,5] 61 ; ...
+'9BPMx6 ' 'SR09BPM06:SA_HPOS_MONITOR' 1 '9BPMy6 ' 'SR09BPM06:SA_VPOS_MONITOR' 1 [9,6] 62 ; ...
+'9BPMx7 ' 'SR09BPM07:SA_HPOS_MONITOR' 1 '9BPMy7 ' 'SR09BPM07:SA_VPOS_MONITOR' 1 [9,7] 63 ; ...
+'10BPMx1 ' 'SR10BPM01:SA_HPOS_MONITOR' 1 '10BPMy1 ' 'SR10BPM01:SA_VPOS_MONITOR' 1 [10,1] 64 ; ...
+'10BPMx2 ' 'SR10BPM02:SA_HPOS_MONITOR' 1 '10BPMy2 ' 'SR10BPM02:SA_VPOS_MONITOR' 1 [10,2] 65 ; ...
+'10BPMx3 ' 'SR10BPM03:SA_HPOS_MONITOR' 1 '10BPMy3 ' 'SR10BPM03:SA_VPOS_MONITOR' 1 [10,3] 66 ; ...
+'10BPMx4 ' 'SR10BPM04:SA_HPOS_MONITOR' 1 '10BPMy4 ' 'SR10BPM04:SA_VPOS_MONITOR' 1 [10,4] 67 ; ...
+'10BPMx5 ' 'SR10BPM05:SA_HPOS_MONITOR' 1 '10BPMy5 ' 'SR10BPM05:SA_VPOS_MONITOR' 1 [10,5] 68 ; ...
+'10BPMx6 ' 'SR10BPM06:SA_HPOS_MONITOR' 1 '10BPMy6 ' 'SR10BPM06:SA_VPOS_MONITOR' 1 [10,6] 69 ; ...
+'10BPMx7 ' 'SR10BPM07:SA_HPOS_MONITOR' 1 '10BPMy7 ' 'SR10BPM07:SA_VPOS_MONITOR' 1 [10,7] 70 ; ...
+'11BPMx1 ' 'SR11BPM01:SA_HPOS_MONITOR' 1 '11BPMy1 ' 'SR11BPM01:SA_VPOS_MONITOR' 1 [11,1] 71 ; ...
+'11BPMx2 ' 'SR11BPM02:SA_HPOS_MONITOR' 0 '11BPMy2 ' 'SR11BPM02:SA_VPOS_MONITOR' 0 [11,2] 72 ; ...
+'11BPMx3 ' 'SR11BPM03:SA_HPOS_MONITOR' 1 '11BPMy3 ' 'SR11BPM03:SA_VPOS_MONITOR' 1 [11,3] 73 ; ...
+'11BPMx4 ' 'SR11BPM04:SA_HPOS_MONITOR' 1 '11BPMy4 ' 'SR11BPM04:SA_VPOS_MONITOR' 1 [11,4] 74 ; ...
+'11BPMx5 ' 'SR11BPM05:SA_HPOS_MONITOR' 0 '11BPMy5 ' 'SR11BPM05:SA_VPOS_MONITOR' 0 [11,5] 75 ; ...
+'11BPMx6 ' 'SR11BPM06:SA_HPOS_MONITOR' 1 '11BPMy6 ' 'SR11BPM06:SA_VPOS_MONITOR' 1 [11,6] 76 ; ...
+'11BPMx7 ' 'SR11BPM07:SA_HPOS_MONITOR' 1 '11BPMy7 ' 'SR11BPM07:SA_VPOS_MONITOR' 1 [11,7] 77 ; ...
+'12BPMx1 ' 'SR12BPM01:SA_HPOS_MONITOR' 1 '12BPMy1 ' 'SR12BPM01:SA_VPOS_MONITOR' 1 [12,1] 78 ; ...
+'12BPMx2 ' 'SR12BPM02:SA_HPOS_MONITOR' 1 '12BPMy2 ' 'SR12BPM02:SA_VPOS_MONITOR' 1 [12,2] 79 ; ...
+'12BPMx3 ' 'SR12BPM03:SA_HPOS_MONITOR' 1 '12BPMy3 ' 'SR12BPM03:SA_VPOS_MONITOR' 1 [12,3] 80 ; ...
+'12BPMx4 ' 'SR12BPM04:SA_HPOS_MONITOR' 1 '12BPMy4 ' 'SR12BPM04:SA_VPOS_MONITOR' 1 [12,4] 81 ; ...
+'12BPMx5 ' 'SR12BPM05:SA_HPOS_MONITOR' 1 '12BPMy5 ' 'SR12BPM05:SA_VPOS_MONITOR' 1 [12,5] 82 ; ...
+'12BPMx6 ' 'SR12BPM06:SA_HPOS_MONITOR' 1 '12BPMy6 ' 'SR12BPM06:SA_VPOS_MONITOR' 1 [12,6] 83 ; ...
+'12BPMx7 ' 'SR12BPM07:SA_HPOS_MONITOR' 1 '12BPMy7 ' 'SR12BPM07:SA_VPOS_MONITOR' 1 [12,7] 84 ; ...
+'13BPMx1 ' 'SR13BPM01:SA_HPOS_MONITOR' 1 '13BPMy1 ' 'SR13BPM01:SA_VPOS_MONITOR' 1 [13,1] 85 ; ...
+'13BPMx2 ' 'SR13BPM02:SA_HPOS_MONITOR' 1 '13BPMy2 ' 'SR13BPM02:SA_VPOS_MONITOR' 1 [13,2] 86 ; ...
+'13BPMx3 ' 'SR13BPM03:SA_HPOS_MONITOR' 1 '13BPMy3 ' 'SR13BPM03:SA_VPOS_MONITOR' 1 [13,3] 87 ; ...
+'13BPMx4 ' 'SR13BPM04:SA_HPOS_MONITOR' 1 '13BPMy4 ' 'SR13BPM04:SA_VPOS_MONITOR' 1 [13,4] 88 ; ...
+'13BPMx5 ' 'SR13BPM05:SA_HPOS_MONITOR' 1 '13BPMy5 ' 'SR13BPM05:SA_VPOS_MONITOR' 1 [13,5] 89 ; ...
+'13BPMx6 ' 'SR13BPM06:SA_HPOS_MONITOR' 0 '13BPMy6 ' 'SR13BPM06:SA_VPOS_MONITOR' 0 [13,6] 90 ; ...
+'13BPMx7 ' 'SR13BPM07:SA_HPOS_MONITOR' 1 '13BPMy7 ' 'SR13BPM07:SA_VPOS_MONITOR' 1 [13,7] 91 ; ...
+'14BPMx1 ' 'SR14BPM01:SA_HPOS_MONITOR' 1 '14BPMy1 ' 'SR14BPM01:SA_VPOS_MONITOR' 1 [14,1] 92 ; ...
+'14BPMx2 ' 'SR14BPM02:SA_HPOS_MONITOR' 1 '14BPMy2 ' 'SR14BPM02:SA_VPOS_MONITOR' 1 [14,2] 93 ; ...
+'14BPMx3 ' 'SR14BPM03:SA_HPOS_MONITOR' 1 '14BPMy3 ' 'SR14BPM03:SA_VPOS_MONITOR' 1 [14,3] 94 ; ...
+'14BPMx4 ' 'SR14BPM04:SA_HPOS_MONITOR' 1 '14BPMy4 ' 'SR14BPM04:SA_VPOS_MONITOR' 1 [14,4] 95 ; ...
+'14BPMx5 ' 'SR14BPM05:SA_HPOS_MONITOR' 1 '14BPMy5 ' 'SR14BPM05:SA_VPOS_MONITOR' 1 [14,5] 96 ; ...
+'14BPMx6 ' 'SR14BPM06:SA_HPOS_MONITOR' 1 '14BPMy6 ' 'SR14BPM06:SA_VPOS_MONITOR' 1 [14,6] 97 ; ...
+'14BPMx7 ' 'SR14BPM07:SA_HPOS_MONITOR' 1 '14BPMy7 ' 'SR14BPM07:SA_VPOS_MONITOR' 1 [14,7] 98 ; ...
+};
+
+%Load fields from data block
+for ii=1:size(bpm,1)
+name=bpm{ii,1}; AO.BPMx.CommonNames(ii,:) = name;
+name=bpm{ii,2}; AO.BPMx.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,3}; AO.BPMx.Status(ii,:) = val;
+name=bpm{ii,4}; AO.BPMy.CommonNames(ii,:) = name;
+name=bpm{ii,5}; AO.BPMy.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,6}; AO.BPMy.Status(ii,:) = val;
+val =bpm{ii,7}; AO.BPMx.DeviceList(ii,:) = val;
+ AO.BPMy.DeviceList(ii,:) = val;
+val =bpm{ii,8}; AO.BPMx.ElementList(ii,:) = val;
+ AO.BPMy.ElementList(ii,:) = val;
+ AO.BPMx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.BPMx.Monitor.Physics2HWParams(ii,:) = 1000;
+ AO.BPMy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.BPMy.Monitor.Physics2HWParams(ii,:) = 1000;
+end
+
+
+% % Get sum value from button. Don't need handles and PV namelist as
+% % parameters are the same as the 'monitor' subcategory.
+% AO.BPMx.Sum.Monitor = AO.BPMx.Monitor;
+% AO.BPMx.Sum.SpecialFunction = 'getbpmsumspear';
+% AO.BPMx.Sum.HWUnits = 'ADC Counts';
+% AO.BPMx.Sum.PhysicsUnits = 'ADC Counts';
+% AO.BPMx.Sum.HW2PhysicsParams = 1;
+% AO.BPMx.Sum.Physics2HWParams = 1;
+% % Get q value from BPMs. Don't need handles and PV namelist.
+% AO.BPMx.Q = AO.BPMx.Monitor;
+% AO.BPMx.Q.SpecialFunction = 'getbpmqspear';
+% AO.BPMx.Q.HWUnits = 'mm';
+% AO.BPMx.Q.PhysicsUnits = 'meter';
+% AO.BPMx.Q.HW2PhysicsParams = 1e-3;
+% AO.BPMx.Q.Physics2HWParams = 1000;
+%
+% % Definition above for horiz0ontal. Replicate for vertical.
+% AO.BPMy.Sum = AO.BPMx.Sum;
+% AO.BPMy.Q = AO.BPMx.Q;
+
+
+
+%=============================================
+% First Turn BPM data from Libera
+%=============================================
+ntbpm=98;
+AO.FTx.FamilyName = 'FTx'; dispobject(AO,AO.FTx.FamilyName);
+AO.FTx.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
+AO.FTx.Monitor.Mode = Mode;
+AO.FTx.Monitor.DataType = 'Scalar';
+AO.FTx.Monitor.Units = 'Hardware';
+AO.FTx.Monitor.HWUnits = 'mm';
+AO.FTx.Monitor.PhysicsUnits = 'meter';
+
+AO.FTy.FamilyName = 'FTy'; dispobject(AO,AO.FTy.FamilyName);
+AO.FTy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
+AO.FTy.Monitor.Mode = Mode;
+AO.FTy.Monitor.DataType = 'Scalar';
+AO.FTy.Monitor.Units = 'Hardware';
+AO.FTy.Monitor.HWUnits = 'mm';
+AO.FTy.Monitor.PhysicsUnits = 'meter';
+
+% x-name x-chname xstat y-name y-chname ystat DevList Elem
+bpm={
+'1FTx1 ' 'SR01BPM01:FT_HPOS_MONITOR' 1 '1BPMy1 ' 'SR01BPM01:FT_VPOS_MONITOR' 1 [1,1] 1 ; ...
+'1FTx2 ' 'SR01BPM02:FT_HPOS_MONITOR' 1 '1BPMy2 ' 'SR01BPM02:FT_VPOS_MONITOR' 1 [1,2] 2 ; ...
+'1FTx3 ' 'SR01BPM03:FT_HPOS_MONITOR' 1 '1BPMy3 ' 'SR01BPM03:FT_VPOS_MONITOR' 1 [1,3] 3 ; ...
+'1FTx4 ' 'SR01BPM04:FT_HPOS_MONITOR' 1 '1BPMy4 ' 'SR01BPM04:FT_VPOS_MONITOR' 1 [1,4] 4 ; ...
+'1FTx5 ' 'SR01BPM05:FT_HPOS_MONITOR' 1 '1BPMy5 ' 'SR01BPM05:FT_VPOS_MONITOR' 1 [1,5] 5 ; ...
+'1FTx6 ' 'SR01BPM06:FT_HPOS_MONITOR' 1 '1BPMy6 ' 'SR01BPM06:FT_VPOS_MONITOR' 1 [1,6] 6 ; ...
+'1FTx7 ' 'SR01BPM07:FT_HPOS_MONITOR' 1 '1BPMy7 ' 'SR01BPM07:FT_VPOS_MONITOR' 1 [1,7] 7 ; ...
+'2FTx1 ' 'SR02BPM01:FT_HPOS_MONITOR' 1 '2BPMy1 ' 'SR02BPM01:FT_VPOS_MONITOR' 1 [2,1] 8 ; ...
+'2FTx2 ' 'SR02BPM02:FT_HPOS_MONITOR' 1 '2BPMy2 ' 'SR02BPM02:FT_VPOS_MONITOR' 1 [2,2] 9 ; ...
+'2FTx3 ' 'SR02BPM03:FT_HPOS_MONITOR' 1 '2BPMy3 ' 'SR02BPM03:FT_VPOS_MONITOR' 1 [2,3] 10 ; ...
+'2FTx4 ' 'SR02BPM04:FT_HPOS_MONITOR' 1 '2BPMy4 ' 'SR02BPM04:FT_VPOS_MONITOR' 1 [2,4] 11 ; ...
+'2FTx5 ' 'SR02BPM05:FT_HPOS_MONITOR' 1 '2BPMy5 ' 'SR02BPM05:FT_VPOS_MONITOR' 1 [2,5] 12 ; ...
+'2FTx6 ' 'SR02BPM06:FT_HPOS_MONITOR' 1 '2BPMy6 ' 'SR02BPM06:FT_VPOS_MONITOR' 1 [2,6] 13 ; ...
+'2FTx7 ' 'SR02BPM07:FT_HPOS_MONITOR' 1 '2BPMy7 ' 'SR02BPM07:FT_VPOS_MONITOR' 1 [2,7] 14 ; ...
+'3FTx1 ' 'SR03BPM01:FT_HPOS_MONITOR' 1 '3BPMy1 ' 'SR03BPM01:FT_VPOS_MONITOR' 1 [3,1] 15 ; ...
+'3FTx2 ' 'SR03BPM02:FT_HPOS_MONITOR' 1 '3BPMy2 ' 'SR03BPM02:FT_VPOS_MONITOR' 1 [3,2] 16 ; ...
+'3FTx3 ' 'SR03BPM03:FT_HPOS_MONITOR' 1 '3BPMy3 ' 'SR03BPM03:FT_VPOS_MONITOR' 1 [3,3] 17 ; ...
+'3FTx4 ' 'SR03BPM04:FT_HPOS_MONITOR' 1 '3BPMy4 ' 'SR03BPM04:FT_VPOS_MONITOR' 1 [3,4] 18 ; ...
+'3FTx5 ' 'SR03BPM05:FT_HPOS_MONITOR' 1 '3BPMy5 ' 'SR03BPM05:FT_VPOS_MONITOR' 1 [3,5] 19 ; ...
+'3FTx6 ' 'SR03BPM06:FT_HPOS_MONITOR' 1 '3BPMy6 ' 'SR03BPM06:FT_VPOS_MONITOR' 1 [3,6] 20 ; ...
+'3FTx7 ' 'SR03BPM07:FT_HPOS_MONITOR' 1 '3BPMy7 ' 'SR03BPM07:FT_VPOS_MONITOR' 1 [3,7] 21 ; ...
+'4FTx1 ' 'SR04BPM01:FT_HPOS_MONITOR' 1 '4BPMy1 ' 'SR04BPM01:FT_VPOS_MONITOR' 1 [4,1] 22 ; ...
+'4FTx2 ' 'SR04BPM02:FT_HPOS_MONITOR' 1 '4BPMy2 ' 'SR04BPM02:FT_VPOS_MONITOR' 1 [4,2] 23 ; ...
+'4FTx3 ' 'SR04BPM03:FT_HPOS_MONITOR' 1 '4BPMy3 ' 'SR04BPM03:FT_VPOS_MONITOR' 1 [4,3] 24 ; ...
+'4FTx4 ' 'SR04BPM04:FT_HPOS_MONITOR' 1 '4BPMy4 ' 'SR04BPM04:FT_VPOS_MONITOR' 1 [4,4] 25 ; ...
+'4FTx5 ' 'SR04BPM05:FT_HPOS_MONITOR' 1 '4BPMy5 ' 'SR04BPM05:FT_VPOS_MONITOR' 1 [4,5] 26 ; ...
+'4FTx6 ' 'SR04BPM06:FT_HPOS_MONITOR' 1 '4BPMy6 ' 'SR04BPM06:FT_VPOS_MONITOR' 1 [4,6] 27 ; ...
+'4FTx7 ' 'SR04BPM07:FT_HPOS_MONITOR' 1 '4BPMy7 ' 'SR04BPM07:FT_VPOS_MONITOR' 1 [4,7] 28 ; ...
+'5FTx1 ' 'SR05BPM01:FT_HPOS_MONITOR' 1 '5BPMy1 ' 'SR05BPM01:FT_VPOS_MONITOR' 1 [5,1] 29 ; ...
+'5FTx2 ' 'SR05BPM02:FT_HPOS_MONITOR' 1 '5BPMy2 ' 'SR05BPM02:FT_VPOS_MONITOR' 1 [5,2] 30 ; ...
+'5FTx3 ' 'SR05BPM03:FT_HPOS_MONITOR' 1 '5BPMy3 ' 'SR05BPM03:FT_VPOS_MONITOR' 1 [5,3] 31 ; ...
+'5FTx4 ' 'SR05BPM04:FT_HPOS_MONITOR' 1 '5BPMy4 ' 'SR05BPM04:FT_VPOS_MONITOR' 1 [5,4] 32 ; ...
+'5FTx5 ' 'SR05BPM05:FT_HPOS_MONITOR' 1 '5BPMy5 ' 'SR05BPM05:FT_VPOS_MONITOR' 1 [5,5] 33 ; ...
+'5FTx6 ' 'SR05BPM06:FT_HPOS_MONITOR' 1 '5BPMy6 ' 'SR05BPM06:FT_VPOS_MONITOR' 1 [5,6] 34 ; ...
+'5FTx7 ' 'SR05BPM07:FT_HPOS_MONITOR' 1 '5BPMy7 ' 'SR05BPM07:FT_VPOS_MONITOR' 1 [5,7] 35 ; ...
+'6FTx1 ' 'SR06BPM01:FT_HPOS_MONITOR' 1 '6BPMy1 ' 'SR06BPM01:FT_VPOS_MONITOR' 1 [6,1] 36 ; ...
+'6FTx2 ' 'SR06BPM02:FT_HPOS_MONITOR' 1 '6BPMy2 ' 'SR06BPM02:FT_VPOS_MONITOR' 1 [6,2] 37 ; ...
+'6FTx3 ' 'SR06BPM03:FT_HPOS_MONITOR' 1 '6BPMy3 ' 'SR06BPM03:FT_VPOS_MONITOR' 1 [6,3] 38 ; ...
+'6FTx4 ' 'SR06BPM04:FT_HPOS_MONITOR' 1 '6BPMy4 ' 'SR06BPM04:FT_VPOS_MONITOR' 1 [6,4] 39 ; ...
+'6FTx5 ' 'SR06BPM05:FT_HPOS_MONITOR' 1 '6BPMy5 ' 'SR06BPM05:FT_VPOS_MONITOR' 1 [6,5] 40 ; ...
+'6FTx6 ' 'SR06BPM06:FT_HPOS_MONITOR' 1 '6BPMy6 ' 'SR06BPM06:FT_VPOS_MONITOR' 1 [6,6] 41 ; ...
+'6FTx7 ' 'SR06BPM07:FT_HPOS_MONITOR' 1 '6BPMy7 ' 'SR06BPM07:FT_VPOS_MONITOR' 1 [6,7] 42 ; ...
+'7FTx1 ' 'SR07BPM01:FT_HPOS_MONITOR' 1 '7BPMy1 ' 'SR07BPM01:FT_VPOS_MONITOR' 1 [7,1] 43 ; ...
+'7FTx2 ' 'SR07BPM02:FT_HPOS_MONITOR' 1 '7BPMy2 ' 'SR07BPM02:FT_VPOS_MONITOR' 1 [7,2] 44 ; ...
+'7FTx3 ' 'SR07BPM03:FT_HPOS_MONITOR' 1 '7BPMy3 ' 'SR07BPM03:FT_VPOS_MONITOR' 1 [7,3] 45 ; ...
+'7FTx4 ' 'SR07BPM04:FT_HPOS_MONITOR' 1 '7BPMy4 ' 'SR07BPM04:FT_VPOS_MONITOR' 1 [7,4] 46 ; ...
+'7FTx5 ' 'SR07BPM05:FT_HPOS_MONITOR' 1 '7BPMy5 ' 'SR07BPM05:FT_VPOS_MONITOR' 1 [7,5] 47 ; ...
+'7FTx6 ' 'SR07BPM06:FT_HPOS_MONITOR' 1 '7BPMy6 ' 'SR07BPM06:FT_VPOS_MONITOR' 1 [7,6] 48 ; ...
+'7FTx7 ' 'SR07BPM07:FT_HPOS_MONITOR' 1 '7BPMy7 ' 'SR07BPM07:FT_VPOS_MONITOR' 1 [7,7] 49 ; ...
+'8FTx1 ' 'SR08BPM01:FT_HPOS_MONITOR' 1 '8BPMy1 ' 'SR08BPM01:FT_VPOS_MONITOR' 1 [8,1] 50 ; ...
+'8FTx2 ' 'SR08BPM02:FT_HPOS_MONITOR' 1 '8BPMy2 ' 'SR08BPM02:FT_VPOS_MONITOR' 1 [8,2] 51 ; ...
+'8FTx3 ' 'SR08BPM03:FT_HPOS_MONITOR' 1 '8BPMy3 ' 'SR08BPM03:FT_VPOS_MONITOR' 1 [8,3] 52 ; ...
+'8FTx4 ' 'SR08BPM04:FT_HPOS_MONITOR' 1 '8BPMy4 ' 'SR08BPM04:FT_VPOS_MONITOR' 1 [8,4] 53 ; ...
+'8FTx5 ' 'SR08BPM05:FT_HPOS_MONITOR' 1 '8BPMy5 ' 'SR08BPM05:FT_VPOS_MONITOR' 1 [8,5] 54 ; ...
+'8FTx6 ' 'SR08BPM06:FT_HPOS_MONITOR' 1 '8BPMy6 ' 'SR08BPM06:FT_VPOS_MONITOR' 1 [8,6] 55 ; ...
+'8FTx7 ' 'SR08BPM07:FT_HPOS_MONITOR' 1 '8BPMy7 ' 'SR08BPM07:FT_VPOS_MONITOR' 1 [8,7] 56 ; ...
+'9FTx1 ' 'SR09BPM01:FT_HPOS_MONITOR' 1 '9BPMy1 ' 'SR09BPM01:FT_VPOS_MONITOR' 1 [9,1] 57 ; ...
+'9FTx2 ' 'SR09BPM02:FT_HPOS_MONITOR' 1 '9BPMy2 ' 'SR09BPM02:FT_VPOS_MONITOR' 1 [9,2] 58 ; ...
+'9FTx3 ' 'SR09BPM03:FT_HPOS_MONITOR' 1 '9BPMy3 ' 'SR09BPM03:FT_VPOS_MONITOR' 1 [9,3] 59 ; ...
+'9FTx4 ' 'SR09BPM04:FT_HPOS_MONITOR' 1 '9BPMy4 ' 'SR09BPM04:FT_VPOS_MONITOR' 1 [9,4] 60 ; ...
+'9FTx5 ' 'SR09BPM05:FT_HPOS_MONITOR' 1 '9BPMy5 ' 'SR09BPM05:FT_VPOS_MONITOR' 1 [9,5] 61 ; ...
+'9FTx6 ' 'SR09BPM06:FT_HPOS_MONITOR' 1 '9BPMy6 ' 'SR09BPM06:FT_VPOS_MONITOR' 1 [9,6] 62 ; ...
+'9FTx7 ' 'SR09BPM07:FT_HPOS_MONITOR' 1 '9BPMy7 ' 'SR09BPM07:FT_VPOS_MONITOR' 1 [9,7] 63 ; ...
+'10FTx1 ' 'SR10BPM01:FT_HPOS_MONITOR' 1 '10BPMy1 ' 'SR10BPM01:FT_VPOS_MONITOR' 1 [10,1] 64 ; ...
+'10FTx2 ' 'SR10BPM02:FT_HPOS_MONITOR' 1 '10BPMy2 ' 'SR10BPM02:FT_VPOS_MONITOR' 1 [10,2] 65 ; ...
+'10FTx3 ' 'SR10BPM03:FT_HPOS_MONITOR' 1 '10BPMy3 ' 'SR10BPM03:FT_VPOS_MONITOR' 1 [10,3] 66 ; ...
+'10FTx4 ' 'SR10BPM04:FT_HPOS_MONITOR' 1 '10BPMy4 ' 'SR10BPM04:FT_VPOS_MONITOR' 1 [10,4] 67 ; ...
+'10FTx5 ' 'SR10BPM05:FT_HPOS_MONITOR' 1 '10BPMy5 ' 'SR10BPM05:FT_VPOS_MONITOR' 1 [10,5] 68 ; ...
+'10FTx6 ' 'SR10BPM06:FT_HPOS_MONITOR' 1 '10BPMy6 ' 'SR10BPM06:FT_VPOS_MONITOR' 1 [10,6] 69 ; ...
+'10FTx7 ' 'SR10BPM07:FT_HPOS_MONITOR' 1 '10BPMy7 ' 'SR10BPM07:FT_VPOS_MONITOR' 1 [10,7] 70 ; ...
+'11FTx1 ' 'SR11BPM01:FT_HPOS_MONITOR' 1 '11BPMy1 ' 'SR11BPM01:FT_VPOS_MONITOR' 1 [11,1] 71 ; ...
+'11FTx2 ' 'SR11BPM02:FT_HPOS_MONITOR' 1 '11BPMy2 ' 'SR11BPM02:FT_VPOS_MONITOR' 1 [11,2] 72 ; ...
+'11FTx3 ' 'SR11BPM03:FT_HPOS_MONITOR' 1 '11BPMy3 ' 'SR11BPM03:FT_VPOS_MONITOR' 1 [11,3] 73 ; ...
+'11FTx4 ' 'SR11BPM04:FT_HPOS_MONITOR' 1 '11BPMy4 ' 'SR11BPM04:FT_VPOS_MONITOR' 1 [11,4] 74 ; ...
+'11FTx5 ' 'SR11BPM05:FT_HPOS_MONITOR' 1 '11BPMy5 ' 'SR11BPM05:FT_VPOS_MONITOR' 1 [11,5] 75 ; ...
+'11FTx6 ' 'SR11BPM06:FT_HPOS_MONITOR' 1 '11BPMy6 ' 'SR11BPM06:FT_VPOS_MONITOR' 1 [11,6] 76 ; ...
+'11FTx7 ' 'SR11BPM07:FT_HPOS_MONITOR' 1 '11BPMy7 ' 'SR11BPM07:FT_VPOS_MONITOR' 1 [11,7] 77 ; ...
+'12FTx1 ' 'SR12BPM01:FT_HPOS_MONITOR' 1 '12BPMy1 ' 'SR12BPM01:FT_VPOS_MONITOR' 1 [12,1] 78 ; ...
+'12FTx2 ' 'SR12BPM02:FT_HPOS_MONITOR' 1 '12BPMy2 ' 'SR12BPM02:FT_VPOS_MONITOR' 1 [12,2] 79 ; ...
+'12FTx3 ' 'SR12BPM03:FT_HPOS_MONITOR' 1 '12BPMy3 ' 'SR12BPM03:FT_VPOS_MONITOR' 1 [12,3] 80 ; ...
+'12FTx4 ' 'SR12BPM04:FT_HPOS_MONITOR' 1 '12BPMy4 ' 'SR12BPM04:FT_VPOS_MONITOR' 1 [12,4] 81 ; ...
+'12FTx5 ' 'SR12BPM05:FT_HPOS_MONITOR' 1 '12BPMy5 ' 'SR12BPM05:FT_VPOS_MONITOR' 1 [12,5] 82 ; ...
+'12FTx6 ' 'SR12BPM06:FT_HPOS_MONITOR' 1 '12BPMy6 ' 'SR12BPM06:FT_VPOS_MONITOR' 1 [12,6] 83 ; ...
+'12FTx7 ' 'SR12BPM07:FT_HPOS_MONITOR' 1 '12BPMy7 ' 'SR12BPM07:FT_VPOS_MONITOR' 1 [12,7] 84 ; ...
+'13FTx1 ' 'SR13BPM01:FT_HPOS_MONITOR' 1 '13BPMy1 ' 'SR13BPM01:FT_VPOS_MONITOR' 1 [13,1] 85 ; ...
+'13FTx2 ' 'SR13BPM02:FT_HPOS_MONITOR' 1 '13BPMy2 ' 'SR13BPM02:FT_VPOS_MONITOR' 1 [13,2] 86 ; ...
+'13FTx3 ' 'SR13BPM03:FT_HPOS_MONITOR' 1 '13BPMy3 ' 'SR13BPM03:FT_VPOS_MONITOR' 1 [13,3] 87 ; ...
+'13FTx4 ' 'SR13BPM04:FT_HPOS_MONITOR' 1 '13BPMy4 ' 'SR13BPM04:FT_VPOS_MONITOR' 1 [13,4] 88 ; ...
+'13FTx5 ' 'SR13BPM05:FT_HPOS_MONITOR' 1 '13BPMy5 ' 'SR13BPM05:FT_VPOS_MONITOR' 1 [13,5] 89 ; ...
+'13FTx6 ' 'SR13BPM06:FT_HPOS_MONITOR' 1 '13BPMy6 ' 'SR13BPM06:FT_VPOS_MONITOR' 1 [13,6] 90 ; ...
+'13FTx7 ' 'SR13BPM07:FT_HPOS_MONITOR' 1 '13BPMy7 ' 'SR13BPM07:FT_VPOS_MONITOR' 1 [13,7] 91 ; ...
+'14FTx1 ' 'SR14BPM01:FT_HPOS_MONITOR' 1 '14BPMy1 ' 'SR14BPM01:FT_VPOS_MONITOR' 1 [14,1] 92 ; ...
+'14FTx2 ' 'SR14BPM02:FT_HPOS_MONITOR' 1 '14BPMy2 ' 'SR14BPM02:FT_VPOS_MONITOR' 1 [14,2] 93 ; ...
+'14FTx3 ' 'SR14BPM03:FT_HPOS_MONITOR' 1 '14BPMy3 ' 'SR14BPM03:FT_VPOS_MONITOR' 1 [14,3] 94 ; ...
+'14FTx4 ' 'SR14BPM04:FT_HPOS_MONITOR' 1 '14BPMy4 ' 'SR14BPM04:FT_VPOS_MONITOR' 1 [14,4] 95 ; ...
+'14FTx5 ' 'SR14BPM05:FT_HPOS_MONITOR' 1 '14BPMy5 ' 'SR14BPM05:FT_VPOS_MONITOR' 1 [14,5] 96 ; ...
+'14FTx6 ' 'SR14BPM06:FT_HPOS_MONITOR' 1 '14BPMy6 ' 'SR14BPM06:FT_VPOS_MONITOR' 1 [14,6] 97 ; ...
+'14FTx7 ' 'SR14BPM07:FT_HPOS_MONITOR' 1 '14BPMy7 ' 'SR14BPM07:FT_VPOS_MONITOR' 1 [14,7] 98 ; ...
+};
+
+%Load fields from data block
+for ii=1:size(bpm,1)
+name=bpm{ii,1}; AO.FTx.CommonNames(ii,:) = name;
+name=bpm{ii,2}; AO.FTx.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,3}; AO.FTx.Status(ii,:) = val;
+name=bpm{ii,4}; AO.FTy.CommonNames(ii,:) = name;
+name=bpm{ii,5}; AO.FTy.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,6}; AO.FTy.Status(ii,:) = val;
+val =bpm{ii,7}; AO.FTx.DeviceList(ii,:) = val;
+ AO.FTy.DeviceList(ii,:) = val;
+val =bpm{ii,8}; AO.FTx.ElementList(ii,:) = val;
+ AO.FTy.ElementList(ii,:) = val;
+ AO.FTx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.FTx.Monitor.Physics2HWParams(ii,:) = 1000;
+ AO.FTy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.FTy.Monitor.Physics2HWParams(ii,:) = 1000;
+end
+AO.FTx.Status = AO.BPMx.Status;
+AO.FTy.Status = AO.BPMy.Status;
+
+AO.FTsum = AO.FTx;
+AO.FTsum.FamilyName = 'FTsum'; dispobject(AO,AO.FTsum.FamilyName);
+AO.FTsum.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
+AO.FTsum.Monitor.Mode = 'Special';
+AO.FTsum.Monitor.Units = 'Hardware';
+AO.FTsum.Monitor.DataType = 'Scalar';
+AO.FTsum.Monitor.SpecialFunction = 'getftsum';
+AO.FTsum.Monitor.HWUnits = 'ADC counts';
+AO.FTsum.Monitor.PhysicsUnits = 'ADC counts';
+AO.FTsum.Monitor.HW2PhysicsParams(:) = 1;
+AO.FTsum.Monitor.Physics2HWParams(:) = 1;
+
+
+% % Get sum value from button. Don't need handles and PV namelist as
+% % parameters are the same as the 'monitor' subcategory.
+AO.FTx.Off.Mode = 'Special';
+AO.FTx.Off.Units = 'Hardware';
+AO.FTx.Off.DataType = 'Scalar';
+AO.FTx.Off.SpecialFunction = 'getftoffset';
+AO.FTx.Off.SpecialFunctionSet = 'setftoffset';
+AO.FTx.Off.HWUnits = '32ns samples';
+AO.FTx.Off.PhysicsUnits = '32ns samples';
+AO.FTx.Off.HW2PhysicsParams = 1;
+AO.FTx.Off.Physics2HWParams = 1;
+
+AO.FTx.Length.Mode = 'Special';
+AO.FTx.Length.Units = 'Hardware';
+AO.FTx.Length.DataType = 'Scalar';
+AO.FTx.Length.SpecialFunction = 'getftlength';
+AO.FTx.Length.SpecialFunctionSet = 'setftlength';
+AO.FTx.Length.HWUnits = '32ns samples';
+AO.FTx.Length.PhysicsUnits = '32ns samples';
+AO.FTx.Length.HW2PhysicsParams = 1;
+AO.FTx.Length.Physics2HWParams = 1;
+
+AO.FTx.Maxadc.Mode = 'Special';
+AO.FTx.Maxadc.Units = 'Hardware';
+AO.FTx.Maxadc.DataType = 'Scalar';
+AO.FTx.Maxadc.SpecialFunction = 'getftmaxadc';
+AO.FTx.Maxadc.HWUnits = 'ADC counts';
+AO.FTx.Maxadc.PhysicsUnits = 'ADC counts';
+AO.FTx.Maxadc.HW2PhysicsParams = 1;
+AO.FTx.Maxadc.Physics2HWParams = 1;
+
+% AO.FTx.Sum.Mode = 'Special';
+% AO.FTx.Sum.Units = 'Hardware';
+% AO.FTx.Sum.DataType = 'Scalar';
+% AO.FTx.Sum.SpecialFunction = 'getftsum';
+% AO.FTx.Sum.HWUnits = 'ADC counts';
+% AO.FTx.Sum.PhysicsUnits = 'ADC counts';
+% AO.FTx.Sum.HW2PhysicsParams = 1;
+% AO.FTx.Sum.Physics2HWParams = 1;
+
+
+%===========================================================
+% Corrector data: status field designates if corrector in use
+% ASP corrector coils wound into sextupoles. Not dynamic correctors.
+%===========================================================
+
+AO.HCM.FamilyName = 'HCM'; dispobject(AO,AO.HCM.FamilyName);
+AO.HCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'HCM'; 'Magnet'};
+
+AO.HCM.Monitor.Mode = Mode;
+AO.HCM.Monitor.DataType = 'Scalar';
+AO.HCM.Monitor.Units = 'Hardware';
+AO.HCM.Monitor.HWUnits = 'ampere';
+AO.HCM.Monitor.PhysicsUnits = 'radian';
+AO.HCM.Monitor.HW2PhysicsFcn = @amp2k;
+AO.HCM.Monitor.Physics2HWFcn = @k2amp;
+
+AO.HCM.Setpoint.Mode = Mode;
+AO.HCM.Setpoint.DataType = 'Scalar';
+AO.HCM.Setpoint.Units = 'Hardware';
+AO.HCM.Setpoint.HWUnits = 'ampere';
+AO.HCM.Setpoint.PhysicsUnits = 'radian';
+AO.HCM.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.HCM.Setpoint.Physics2HWFcn = @k2amp;
+
+% HW in ampere, Physics in radian. Respmat settings below AO definitions.
+% x-common x-monitor x-setpoint stat devlist elem tol
+cor={
+'1HCM1 ' 'SR01CPS01:CURRENT_MONITOR' 'SR01CPS01:CURRENT_SP ' 1 [1,1] 1 1.000 ; ...
+'1HCM2 ' 'SR01CPS05:CURRENT_MONITOR' 'SR01CPS05:CURRENT_SP ' 1 [1,2] 2 1.000 ; ...
+'1HCM3 ' 'SR01CPS09:CURRENT_MONITOR' 'SR01CPS09:CURRENT_SP ' 1 [1,3] 3 1.000 ; ...
+'2HCM1 ' 'SR02CPS01:CURRENT_MONITOR' 'SR02CPS01:CURRENT_SP ' 1 [2,1] 4 1.000 ; ...
+'2HCM2 ' 'SR02CPS05:CURRENT_MONITOR' 'SR02CPS05:CURRENT_SP ' 1 [2,2] 5 1.000 ; ...
+'2HCM3 ' 'SR02CPS09:CURRENT_MONITOR' 'SR02CPS09:CURRENT_SP ' 1 [2,3] 6 1.000 ; ...
+'3HCM1 ' 'SR03CPS01:CURRENT_MONITOR' 'SR03CPS01:CURRENT_SP ' 1 [3,1] 7 1.000 ; ...
+'3HCM2 ' 'SR03CPS05:CURRENT_MONITOR' 'SR03CPS05:CURRENT_SP ' 1 [3,2] 8 1.000 ; ...
+'3HCM3 ' 'SR03CPS09:CURRENT_MONITOR' 'SR03CPS09:CURRENT_SP ' 1 [3,3] 9 1.000 ; ...
+'4HCM1 ' 'SR04CPS01:CURRENT_MONITOR' 'SR04CPS01:CURRENT_SP ' 1 [4,1] 10 1.000 ; ...
+'4HCM2 ' 'SR04CPS05:CURRENT_MONITOR' 'SR04CPS05:CURRENT_SP ' 1 [4,2] 11 1.000 ; ...
+'4HCM3 ' 'SR04CPS09:CURRENT_MONITOR' 'SR04CPS09:CURRENT_SP ' 1 [4,3] 12 1.000 ; ...
+'5HCM1 ' 'SR05CPS01:CURRENT_MONITOR' 'SR05CPS01:CURRENT_SP ' 1 [5,1] 13 1.000 ; ...
+'5HCM2 ' 'SR05CPS05:CURRENT_MONITOR' 'SR05CPS05:CURRENT_SP ' 1 [5,2] 14 1.000 ; ...
+'5HCM3 ' 'SR05CPS09:CURRENT_MONITOR' 'SR05CPS09:CURRENT_SP ' 1 [5,3] 15 1.000 ; ...
+'6HCM1 ' 'SR06CPS01:CURRENT_MONITOR' 'SR06CPS01:CURRENT_SP ' 1 [6,1] 16 1.000 ; ...
+'6HCM2 ' 'SR06CPS05:CURRENT_MONITOR' 'SR06CPS05:CURRENT_SP ' 1 [6,2] 17 1.000 ; ...
+'6HCM3 ' 'SR06CPS09:CURRENT_MONITOR' 'SR06CPS09:CURRENT_SP ' 1 [6,3] 18 1.000 ; ...
+'7HCM1 ' 'SR07CPS01:CURRENT_MONITOR' 'SR07CPS01:CURRENT_SP ' 1 [7,1] 19 1.000 ; ...
+'7HCM2 ' 'SR07CPS05:CURRENT_MONITOR' 'SR07CPS05:CURRENT_SP ' 1 [7,2] 20 1.000 ; ...
+'7HCM3 ' 'SR07CPS09:CURRENT_MONITOR' 'SR07CPS09:CURRENT_SP ' 1 [7,3] 21 1.000 ; ...
+'8HCM1 ' 'SR08CPS01:CURRENT_MONITOR' 'SR08CPS01:CURRENT_SP ' 1 [8,1] 22 1.000 ; ...
+'8HCM2 ' 'SR08CPS05:CURRENT_MONITOR' 'SR08CPS05:CURRENT_SP ' 1 [8,2] 23 1.000 ; ...
+'8HCM3 ' 'SR08CPS09:CURRENT_MONITOR' 'SR08CPS09:CURRENT_SP ' 1 [8,3] 24 1.000 ; ...
+'9HCM1 ' 'SR09CPS01:CURRENT_MONITOR' 'SR09CPS01:CURRENT_SP ' 1 [9,1] 25 1.000 ; ...
+'9HCM2 ' 'SR09CPS05:CURRENT_MONITOR' 'SR09CPS05:CURRENT_SP ' 1 [9,2] 26 1.000 ; ...
+'9HCM3 ' 'SR09CPS09:CURRENT_MONITOR' 'SR09CPS09:CURRENT_SP ' 1 [9,3] 27 1.000 ; ...
+'10HCM1 ' 'SR10CPS01:CURRENT_MONITOR' 'SR10CPS01:CURRENT_SP ' 1 [10,1] 28 1.000 ; ...
+'10HCM2 ' 'SR10CPS05:CURRENT_MONITOR' 'SR10CPS05:CURRENT_SP ' 1 [10,2] 29 1.000 ; ...
+'10HCM3 ' 'SR10CPS09:CURRENT_MONITOR' 'SR10CPS09:CURRENT_SP ' 1 [10,3] 30 1.000 ; ...
+'11HCM1 ' 'SR11CPS01:CURRENT_MONITOR' 'SR11CPS01:CURRENT_SP ' 1 [11,1] 31 1.000 ; ...
+'11HCM2 ' 'SR11CPS05:CURRENT_MONITOR' 'SR11CPS05:CURRENT_SP ' 1 [11,2] 32 1.000 ; ...
+'11HCM3 ' 'SR11CPS09:CURRENT_MONITOR' 'SR11CPS09:CURRENT_SP ' 1 [11,3] 33 1.000 ; ...
+'12HCM1 ' 'SR12CPS01:CURRENT_MONITOR' 'SR12CPS01:CURRENT_SP ' 1 [12,1] 34 1.000 ; ...
+'12HCM2 ' 'SR12CPS05:CURRENT_MONITOR' 'SR12CPS05:CURRENT_SP ' 1 [12,2] 35 1.000 ; ...
+'12HCM3 ' 'SR12CPS09:CURRENT_MONITOR' 'SR12CPS09:CURRENT_SP ' 1 [12,3] 36 1.000 ; ...
+'13HCM1 ' 'SR13CPS01:CURRENT_MONITOR' 'SR13CPS01:CURRENT_SP ' 1 [13,1] 37 1.000 ; ...
+'13HCM2 ' 'SR13CPS05:CURRENT_MONITOR' 'SR13CPS05:CURRENT_SP ' 1 [13,2] 38 1.000 ; ...
+'13HCM3 ' 'SR13CPS09:CURRENT_MONITOR' 'SR13CPS09:CURRENT_SP ' 1 [13,3] 39 1.000 ; ...
+'14HCM1 ' 'SR14CPS01:CURRENT_MONITOR' 'SR14CPS01:CURRENT_SP ' 1 [14,1] 40 1.000 ; ...
+'14HCM2 ' 'SR14CPS05:CURRENT_MONITOR' 'SR14CPS05:CURRENT_SP ' 1 [14,2] 41 1.000 ; ...
+'14HCM3 ' 'SR14CPS09:CURRENT_MONITOR' 'SR14CPS09:CURRENT_SP ' 1 [14,3] 42 1.000 ; ...
+};
+
+[C, Leff, MagnetType] = magnetcoefficients('HCM');
+
+for ii=1:size(cor,1)
+name=cor{ii,1}; AO.HCM.CommonNames(ii,:) = name;
+name=cor{ii,2}; AO.HCM.Monitor.ChannelNames(ii,:) = name;
+name=cor{ii,3}; AO.HCM.Setpoint.ChannelNames(ii,:) = name;
+val =cor{ii,4}; AO.HCM.Status(ii,1) = val;
+val =cor{ii,5}; AO.HCM.DeviceList(ii,:) = val;
+val =cor{ii,6}; AO.HCM.ElementList(ii,1) = val;
+val =cor{ii,7}; AO.HCM.Setpoint.Tolerance(ii,1) = val;
+
+AO.HCM.Setpoint.Range(ii,:) = [-90 +90];
+AO.HCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
+AO.HCM.Monitor.Physics2HWParams{1}(ii,:) = C;
+AO.HCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
+AO.HCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
+end
+
+
+AO.VCM.FamilyName = 'VCM'; dispobject(AO,AO.VCM.FamilyName);
+AO.VCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'VCM'; 'Magnet'};
+
+AO.VCM.Monitor.Mode = Mode;
+AO.VCM.Monitor.DataType = 'Scalar';
+AO.VCM.Monitor.Units = 'Hardware';
+AO.VCM.Monitor.HWUnits = 'ampere';
+AO.VCM.Monitor.PhysicsUnits = 'radian';
+AO.VCM.Monitor.HW2PhysicsFcn = @amp2k;
+AO.VCM.Monitor.Physics2HWFcn = @k2amp;
+
+AO.VCM.Setpoint.Mode = Mode;
+AO.VCM.Setpoint.DataType = 'Scalar';
+AO.VCM.Setpoint.Units = 'Hardware';
+AO.VCM.Setpoint.HWUnits = 'ampere';
+AO.VCM.Setpoint.PhysicsUnits = 'radian';
+AO.VCM.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.VCM.Setpoint.Physics2HWFcn = @k2amp;
+
+% HW in ampere, Physics in radian ** radian units converted to ampere below ***
+% y-common y-monitor y-setpoint stat devlist elem
+cor={
+'1VCM1 ' 'SR01CPS02:CURRENT_MONITOR' 'SR01CPS02:CURRENT_SP ' 1 [1,1] 1 1.000 ; ...
+'1VCM2 ' 'SR01CPS04:CURRENT_MONITOR' 'SR01CPS04:CURRENT_SP ' 1 [1,2] 2 1.000 ; ...
+'1VCM3 ' 'SR01CPS06:CURRENT_MONITOR' 'SR01CPS06:CURRENT_SP ' 1 [1,3] 3 1.000 ; ...
+'1VCM4 ' 'SR01CPS07:CURRENT_MONITOR' 'SR01CPS07:CURRENT_SP ' 1 [1,4] 4 1.000 ; ...
+'2VCM1 ' 'SR02CPS02:CURRENT_MONITOR' 'SR02CPS02:CURRENT_SP ' 1 [2,1] 5 1.000 ; ...
+'2VCM2 ' 'SR02CPS04:CURRENT_MONITOR' 'SR02CPS04:CURRENT_SP ' 1 [2,2] 6 1.000 ; ...
+'2VCM3 ' 'SR02CPS06:CURRENT_MONITOR' 'SR02CPS06:CURRENT_SP ' 1 [2,3] 7 1.000 ; ...
+'2VCM4 ' 'SR02CPS07:CURRENT_MONITOR' 'SR02CPS07:CURRENT_SP ' 1 [2,4] 8 1.000 ; ...
+'3VCM1 ' 'SR03CPS02:CURRENT_MONITOR' 'SR03CPS02:CURRENT_SP ' 1 [3,1] 9 1.000 ; ...
+'3VCM2 ' 'SR03CPS04:CURRENT_MONITOR' 'SR03CPS04:CURRENT_SP ' 1 [3,2] 10 1.000 ; ...
+'3VCM3 ' 'SR03CPS06:CURRENT_MONITOR' 'SR03CPS06:CURRENT_SP ' 1 [3,3] 11 1.000 ; ...
+'3VCM4 ' 'SR03CPS07:CURRENT_MONITOR' 'SR03CPS07:CURRENT_SP ' 1 [3,4] 12 1.000 ; ...
+'4VCM1 ' 'SR04CPS02:CURRENT_MONITOR' 'SR04CPS02:CURRENT_SP ' 1 [4,1] 13 1.000 ; ...
+'4VCM2 ' 'SR04CPS04:CURRENT_MONITOR' 'SR04CPS04:CURRENT_SP ' 1 [4,2] 14 1.000 ; ...
+'4VCM3 ' 'SR04CPS06:CURRENT_MONITOR' 'SR04CPS06:CURRENT_SP ' 1 [4,3] 15 1.000 ; ...
+'4VCM4 ' 'SR04CPS07:CURRENT_MONITOR' 'SR04CPS07:CURRENT_SP ' 1 [4,4] 16 1.000 ; ...
+'5VCM1 ' 'SR05CPS02:CURRENT_MONITOR' 'SR05CPS02:CURRENT_SP ' 1 [5,1] 17 1.000 ; ...
+'5VCM2 ' 'SR05CPS04:CURRENT_MONITOR' 'SR05CPS04:CURRENT_SP ' 1 [5,2] 18 1.000 ; ...
+'5VCM3 ' 'SR05CPS06:CURRENT_MONITOR' 'SR05CPS06:CURRENT_SP ' 1 [5,3] 19 1.000 ; ...
+'5VCM4 ' 'SR05CPS07:CURRENT_MONITOR' 'SR05CPS07:CURRENT_SP ' 1 [5,4] 20 1.000 ; ...
+'6VCM1 ' 'SR06CPS02:CURRENT_MONITOR' 'SR06CPS02:CURRENT_SP ' 1 [6,1] 21 1.000 ; ...
+'6VCM2 ' 'SR06CPS04:CURRENT_MONITOR' 'SR06CPS04:CURRENT_SP ' 1 [6,2] 22 1.000 ; ...
+'6VCM3 ' 'SR06CPS06:CURRENT_MONITOR' 'SR06CPS06:CURRENT_SP ' 1 [6,3] 23 1.000 ; ...
+'6VCM4 ' 'SR06CPS07:CURRENT_MONITOR' 'SR06CPS07:CURRENT_SP ' 1 [6,4] 24 1.000 ; ...
+'7VCM1 ' 'SR07CPS02:CURRENT_MONITOR' 'SR07CPS02:CURRENT_SP ' 1 [7,1] 25 1.000 ; ...
+'7VCM2 ' 'SR07CPS04:CURRENT_MONITOR' 'SR07CPS04:CURRENT_SP ' 1 [7,2] 26 1.000 ; ...
+'7VCM3 ' 'SR07CPS06:CURRENT_MONITOR' 'SR07CPS06:CURRENT_SP ' 1 [7,3] 27 1.000 ; ...
+'7VCM4 ' 'SR07CPS07:CURRENT_MONITOR' 'SR07CPS07:CURRENT_SP ' 1 [7,4] 28 1.000 ; ...
+'8VCM1 ' 'SR08CPS02:CURRENT_MONITOR' 'SR08CPS02:CURRENT_SP ' 1 [8,1] 29 1.000 ; ...
+'8VCM2 ' 'SR08CPS04:CURRENT_MONITOR' 'SR08CPS04:CURRENT_SP ' 1 [8,2] 30 1.000 ; ...
+'8VCM3 ' 'SR08CPS06:CURRENT_MONITOR' 'SR08CPS06:CURRENT_SP ' 1 [8,3] 31 1.000 ; ...
+'8VCM4 ' 'SR08CPS07:CURRENT_MONITOR' 'SR08CPS07:CURRENT_SP ' 1 [8,4] 32 1.000 ; ...
+'9VCM1 ' 'SR09CPS02:CURRENT_MONITOR' 'SR09CPS02:CURRENT_SP ' 1 [9,1] 33 1.000 ; ...
+'9VCM2 ' 'SR09CPS04:CURRENT_MONITOR' 'SR09CPS04:CURRENT_SP ' 1 [9,2] 34 1.000 ; ...
+'9VCM3 ' 'SR09CPS06:CURRENT_MONITOR' 'SR09CPS06:CURRENT_SP ' 1 [9,3] 35 1.000 ; ...
+'9VCM4 ' 'SR09CPS07:CURRENT_MONITOR' 'SR09CPS07:CURRENT_SP ' 1 [9,4] 36 1.000 ; ...
+'10VCM1 ' 'SR10CPS02:CURRENT_MONITOR' 'SR10CPS02:CURRENT_SP ' 1 [10,1] 37 1.000 ; ...
+'10VCM2 ' 'SR10CPS04:CURRENT_MONITOR' 'SR10CPS04:CURRENT_SP ' 1 [10,2] 38 1.000 ; ...
+'10VCM3 ' 'SR10CPS06:CURRENT_MONITOR' 'SR10CPS06:CURRENT_SP ' 1 [10,3] 39 1.000 ; ...
+'10VCM4 ' 'SR10CPS07:CURRENT_MONITOR' 'SR10CPS07:CURRENT_SP ' 1 [10,4] 40 1.000 ; ...
+'11VCM1 ' 'SR11CPS02:CURRENT_MONITOR' 'SR11CPS02:CURRENT_SP ' 1 [11,1] 41 1.000 ; ...
+'11VCM2 ' 'SR11CPS04:CURRENT_MONITOR' 'SR11CPS04:CURRENT_SP ' 1 [11,2] 42 1.000 ; ...
+'11VCM3 ' 'SR11CPS06:CURRENT_MONITOR' 'SR11CPS06:CURRENT_SP ' 1 [11,3] 43 1.000 ; ...
+'11VCM4 ' 'SR11CPS07:CURRENT_MONITOR' 'SR11CPS07:CURRENT_SP ' 1 [11,4] 44 1.000 ; ...
+'12VCM1 ' 'SR12CPS02:CURRENT_MONITOR' 'SR12CPS02:CURRENT_SP ' 1 [12,1] 45 1.000 ; ...
+'12VCM2 ' 'SR12CPS04:CURRENT_MONITOR' 'SR12CPS04:CURRENT_SP ' 1 [12,2] 46 1.000 ; ...
+'12VCM3 ' 'SR12CPS06:CURRENT_MONITOR' 'SR12CPS06:CURRENT_SP ' 1 [12,3] 47 1.000 ; ...
+'12VCM4 ' 'SR12CPS07:CURRENT_MONITOR' 'SR12CPS07:CURRENT_SP ' 1 [12,4] 48 1.000 ; ...
+'13VCM1 ' 'SR13CPS02:CURRENT_MONITOR' 'SR13CPS02:CURRENT_SP ' 1 [13,1] 49 1.000 ; ...
+'13VCM2 ' 'SR13CPS04:CURRENT_MONITOR' 'SR13CPS04:CURRENT_SP ' 1 [13,2] 50 1.000 ; ...
+'13VCM3 ' 'SR13CPS06:CURRENT_MONITOR' 'SR13CPS06:CURRENT_SP ' 1 [13,3] 51 1.000 ; ...
+'13VCM4 ' 'SR13CPS07:CURRENT_MONITOR' 'SR13CPS07:CURRENT_SP ' 1 [13,4] 52 1.000 ; ...
+'14VCM1 ' 'SR14CPS02:CURRENT_MONITOR' 'SR14CPS02:CURRENT_SP ' 1 [14,1] 53 1.000 ; ...
+'14VCM2 ' 'SR14CPS04:CURRENT_MONITOR' 'SR14CPS04:CURRENT_SP ' 1 [14,2] 54 1.000 ; ...
+'14VCM3 ' 'SR14CPS06:CURRENT_MONITOR' 'SR14CPS06:CURRENT_SP ' 1 [14,3] 55 1.000 ; ...
+'14VCM4 ' 'SR14CPS07:CURRENT_MONITOR' 'SR14CPS07:CURRENT_SP ' 1 [14,4] 56 1.000 ; ...
+};
+
+[C, Leff, MagnetType] = magnetcoefficients('VCM');
+
+for ii=1:size(cor,1)
+name=cor{ii,1}; AO.VCM.CommonNames(ii,:) = name;
+name=cor{ii,2}; AO.VCM.Monitor.ChannelNames(ii,:) = name;
+name=cor{ii,3}; AO.VCM.Setpoint.ChannelNames(ii,:) = name;
+val =cor{ii,4}; AO.VCM.Status(ii,1) = val;
+val =cor{ii,5}; AO.VCM.DeviceList(ii,:) = val;
+val =cor{ii,6}; AO.VCM.ElementList(ii,1) = val;
+val =cor{ii,7}; AO.VCM.Setpoint.Tolerance(ii,1) = val;
+
+AO.VCM.Setpoint.Range(ii,:) = [-125 +125];
+AO.VCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
+AO.VCM.Monitor.Physics2HWParams{1}(ii,:) = C;
+AO.VCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
+AO.VCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
+end
+
+
+%=============================
+% MAIN MAGNETS
+%=============================
+
+%===========
+%Dipole data
+%===========
+
+% *** BEND ***
+AO.BEND.FamilyName = 'BEND'; dispobject(AO,AO.BEND.FamilyName);
+AO.BEND.MemberOf = {'PlotFamily'; 'MachineConfig'; 'BEND'; 'Magnet';};
+HW2PhysicsParams = magnetcoefficients('BEND');
+Physics2HWParams = magnetcoefficients('BEND');
+
+AO.BEND.Monitor.Mode = Mode;
+AO.BEND.Monitor.DataType = 'Scalar';
+AO.BEND.Monitor.Units = 'Hardware';
+AO.BEND.Monitor.HW2PhysicsFcn = @bend2gev; % @bend2gev ???
+AO.BEND.Monitor.Physics2HWFcn = @gev2bend;
+AO.BEND.Monitor.HWUnits = 'ampere';
+AO.BEND.Monitor.PhysicsUnits = 'energy';
+
+AO.BEND.Setpoint.Mode = Mode;
+AO.BEND.Setpoint.DataType = 'Scalar';
+AO.BEND.Setpoint.Units = 'Hardware';
+AO.BEND.Setpoint.HW2PhysicsFcn = @bend2gev;
+AO.BEND.Setpoint.Physics2HWFcn = @gev2bend;
+AO.BEND.Setpoint.HWUnits = 'ampere';
+AO.BEND.Setpoint.PhysicsUnits = 'energy';
+
+% common monitor setpoint stat devlist elem scale tol
+bend={
+'1BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.10 ; ...
+'1BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [1,2] 2 1.0 0.10 ; ...
+'2BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.10 ; ...
+'2BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [2,2] 4 1.0 0.10 ; ...
+'3BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.10 ; ...
+'3BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [3,2] 6 1.0 0.10 ; ...
+'4BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.10 ; ...
+'4BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [4,2] 8 1.0 0.10 ; ...
+'5BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.10 ; ...
+'5BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [5,2] 10 1.0 0.10 ; ...
+'6BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.10 ; ...
+'6BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [6,2] 12 1.0 0.10 ; ...
+'7BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.10 ; ...
+'7BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [7,2] 14 1.0 0.10 ; ...
+'8BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.10 ; ...
+'8BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [8,2] 16 1.0 0.10 ; ...
+'9BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.10 ; ...
+'9BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [9,2] 18 1.0 0.10 ; ...
+'10BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.10 ; ...
+'10BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [10,2] 20 1.0 0.10 ; ...
+'11BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.10 ; ...
+'11BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [11,2] 22 1.0 0.10 ; ...
+'12BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.10 ; ...
+'12BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [12,2] 24 1.0 0.10 ; ...
+'13BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.10 ; ...
+'13BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [13,2] 26 1.0 0.10 ; ...
+'14BEND1 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.10 ; ...
+'14BEND2 ' 'SR00DPS01:CURRENT_MONITOR' 'SR00DPS01:CURRENT_SP ' 1 [14,2] 28 1.0 0.10 ; ...
+};
+
+for ii=1:size(bend,1)
+name=bend{ii,1}; AO.BEND.CommonNames(ii,:) = name;
+name=bend{ii,2}; AO.BEND.Monitor.ChannelNames(ii,:) = name;
+name=bend{ii,3}; AO.BEND.Setpoint.ChannelNames(ii,:) = name;
+val =bend{ii,4}; AO.BEND.Status(ii,1) = val;
+val =bend{ii,5}; AO.BEND.DeviceList(ii,:) = val;
+val =bend{ii,6}; AO.BEND.ElementList(ii,1) = val;
+val =bend{ii,7}; % This is the scale factor
+AO.BEND.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.BEND.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.BEND.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.BEND.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.BEND.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.BEND.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.BEND.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.BEND.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =bend{ii,8}; AO.BEND.Setpoint.Tolerance(ii,1) = val;
+
+AO.BEND.Setpoint.Range(ii,:) = [50 695];
+end
+
+%===============
+%Quadrupole data
+%===============
+
+% *** QFA ***
+AO.QFA.FamilyName = 'QFA'; dispobject(AO,AO.QFA.FamilyName);
+AO.QFA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
+HW2PhysicsParams = magnetcoefficients('QFA');
+Physics2HWParams = magnetcoefficients('QFA');
+
+AO.QFA.Monitor.Mode = Mode;
+AO.QFA.Monitor.DataType = 'Scalar';
+AO.QFA.Monitor.Units = 'Hardware';
+AO.QFA.Monitor.HWUnits = 'ampere';
+AO.QFA.Monitor.PhysicsUnits = 'meter^-2';
+AO.QFA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QFA.Monitor.Physics2HWFcn = @k2amp;
+
+AO.QFA.Setpoint.Mode = Mode;
+AO.QFA.Setpoint.DataType = 'Scalar';
+AO.QFA.Setpoint.Units = 'Hardware';
+AO.QFA.Setpoint.HWUnits = 'ampere';
+AO.QFA.Setpoint.PhysicsUnits = 'meter^-2';
+AO.QFA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QFA.Setpoint.Physics2HWFcn = @k2amp;
+
+% common monitor setpoint stat devlist elem scale tol
+qfa={
+'1QFA1 ' 'SR01QPS01:CURRENT_MONITOR' 'SR01QPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
+'1QFA2 ' 'SR01QPS06:CURRENT_MONITOR' 'SR01QPS06:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
+'2QFA1 ' 'SR02QPS01:CURRENT_MONITOR' 'SR02QPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
+'2QFA2 ' 'SR02QPS06:CURRENT_MONITOR' 'SR02QPS06:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
+'3QFA1 ' 'SR03QPS01:CURRENT_MONITOR' 'SR03QPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
+'3QFA2 ' 'SR03QPS06:CURRENT_MONITOR' 'SR03QPS06:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
+'4QFA1 ' 'SR04QPS01:CURRENT_MONITOR' 'SR04QPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
+'4QFA2 ' 'SR04QPS06:CURRENT_MONITOR' 'SR04QPS06:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
+'5QFA1 ' 'SR05QPS01:CURRENT_MONITOR' 'SR05QPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
+'5QFA2 ' 'SR05QPS06:CURRENT_MONITOR' 'SR05QPS06:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
+'6QFA1 ' 'SR06QPS01:CURRENT_MONITOR' 'SR06QPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
+'6QFA2 ' 'SR06QPS06:CURRENT_MONITOR' 'SR06QPS06:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
+'7QFA1 ' 'SR07QPS01:CURRENT_MONITOR' 'SR07QPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
+'7QFA2 ' 'SR07QPS06:CURRENT_MONITOR' 'SR07QPS06:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
+'8QFA1 ' 'SR08QPS01:CURRENT_MONITOR' 'SR08QPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
+'8QFA2 ' 'SR08QPS06:CURRENT_MONITOR' 'SR08QPS06:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
+'9QFA1 ' 'SR09QPS01:CURRENT_MONITOR' 'SR09QPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
+'9QFA2 ' 'SR09QPS06:CURRENT_MONITOR' 'SR09QPS06:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
+'10QFA1 ' 'SR10QPS01:CURRENT_MONITOR' 'SR10QPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
+'10QFA2 ' 'SR10QPS06:CURRENT_MONITOR' 'SR10QPS06:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
+'11QFA1 ' 'SR11QPS01:CURRENT_MONITOR' 'SR11QPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
+'11QFA2 ' 'SR11QPS06:CURRENT_MONITOR' 'SR11QPS06:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
+'12QFA1 ' 'SR12QPS01:CURRENT_MONITOR' 'SR12QPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
+'12QFA2 ' 'SR12QPS06:CURRENT_MONITOR' 'SR12QPS06:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
+'13QFA1 ' 'SR13QPS01:CURRENT_MONITOR' 'SR13QPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
+'13QFA2 ' 'SR13QPS06:CURRENT_MONITOR' 'SR13QPS06:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
+'14QFA1 ' 'SR14QPS01:CURRENT_MONITOR' 'SR14QPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
+'14QFA2 ' 'SR14QPS06:CURRENT_MONITOR' 'SR14QPS06:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
+};
+
+for ii=1:size(qfa,1)
+name=qfa{ii,1}; AO.QFA.CommonNames(ii,:) = name;
+name=qfa{ii,2}; AO.QFA.Monitor.ChannelNames(ii,:) = name;
+name=qfa{ii,3}; AO.QFA.Setpoint.ChannelNames(ii,:) = name;
+val =qfa{ii,4}; AO.QFA.Status(ii,1) = val;
+val =qfa{ii,5}; AO.QFA.DeviceList(ii,:) = val;
+val =qfa{ii,6}; AO.QFA.ElementList(ii,1) = val;
+val =qfa{ii,7}; % This is the scale factor
+AO.QFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qfa{ii,8}; AO.QFA.Setpoint.Tolerance(ii,1) = val;
+
+% Important! This determines the cycling range
+AO.QFA.Setpoint.Range(ii,:) = [0 160];
+end
+
+
+% *** QDA ***
+AO.QDA.FamilyName = 'QDA'; dispobject(AO,AO.QDA.FamilyName);
+AO.QDA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QD';};
+HW2PhysicsParams = magnetcoefficients('QDA');
+Physics2HWParams = magnetcoefficients('QDA');
+
+AO.QDA.Monitor.Mode = Mode;
+AO.QDA.Monitor.DataType = 'Scalar';
+AO.QDA.Monitor.Units = 'Hardware';
+AO.QDA.Monitor.HWUnits = 'ampere';
+AO.QDA.Monitor.PhysicsUnits = 'meter^-2';
+AO.QDA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QDA.Monitor.Physics2HWFcn = @k2amp;
+
+AO.QDA.Setpoint.Mode = Mode;
+AO.QDA.Setpoint.DataType = 'Scalar';
+AO.QDA.Setpoint.Units = 'Hardware';
+AO.QDA.Setpoint.HWUnits = 'ampere';
+AO.QDA.Setpoint.PhysicsUnits = 'meter^-2';
+AO.QDA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QDA.Setpoint.Physics2HWFcn = @k2amp;
+
+% common monitor setpoint stat devlist elem scale tol
+qda={
+'1QDA1 ' 'SR01QPS02:CURRENT_MONITOR' 'SR01QPS02:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
+'1QDA2 ' 'SR01QPS05:CURRENT_MONITOR' 'SR01QPS05:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
+'2QDA1 ' 'SR02QPS02:CURRENT_MONITOR' 'SR02QPS02:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
+'2QDA2 ' 'SR02QPS05:CURRENT_MONITOR' 'SR02QPS05:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
+'3QDA1 ' 'SR03QPS02:CURRENT_MONITOR' 'SR03QPS02:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
+'3QDA2 ' 'SR03QPS05:CURRENT_MONITOR' 'SR03QPS05:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
+'4QDA1 ' 'SR04QPS02:CURRENT_MONITOR' 'SR04QPS02:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
+'4QDA2 ' 'SR04QPS05:CURRENT_MONITOR' 'SR04QPS05:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
+'5QDA1 ' 'SR05QPS02:CURRENT_MONITOR' 'SR05QPS02:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
+'5QDA2 ' 'SR05QPS05:CURRENT_MONITOR' 'SR05QPS05:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
+'6QDA1 ' 'SR06QPS02:CURRENT_MONITOR' 'SR06QPS02:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
+'6QDA2 ' 'SR06QPS05:CURRENT_MONITOR' 'SR06QPS05:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
+'7QDA1 ' 'SR07QPS02:CURRENT_MONITOR' 'SR07QPS02:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
+'7QDA2 ' 'SR07QPS05:CURRENT_MONITOR' 'SR07QPS05:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
+'8QDA1 ' 'SR08QPS02:CURRENT_MONITOR' 'SR08QPS02:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
+'8QDA2 ' 'SR08QPS05:CURRENT_MONITOR' 'SR08QPS05:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
+'9QDA1 ' 'SR09QPS02:CURRENT_MONITOR' 'SR09QPS02:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
+'9QDA2 ' 'SR09QPS05:CURRENT_MONITOR' 'SR09QPS05:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
+'10QDA1 ' 'SR10QPS02:CURRENT_MONITOR' 'SR10QPS02:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
+'10QDA2 ' 'SR10QPS05:CURRENT_MONITOR' 'SR10QPS05:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
+'11QDA1 ' 'SR11QPS02:CURRENT_MONITOR' 'SR11QPS02:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
+'11QDA2 ' 'SR11QPS05:CURRENT_MONITOR' 'SR11QPS05:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
+'12QDA1 ' 'SR12QPS02:CURRENT_MONITOR' 'SR12QPS02:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
+'12QDA2 ' 'SR12QPS05:CURRENT_MONITOR' 'SR12QPS05:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
+'13QDA1 ' 'SR13QPS02:CURRENT_MONITOR' 'SR13QPS02:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
+'13QDA2 ' 'SR13QPS05:CURRENT_MONITOR' 'SR13QPS05:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
+'14QDA1 ' 'SR14QPS02:CURRENT_MONITOR' 'SR14QPS02:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
+'14QDA2 ' 'SR14QPS05:CURRENT_MONITOR' 'SR14QPS05:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
+};
+
+for ii=1:size(qda,1)
+name=qda{ii,1}; AO.QDA.CommonNames(ii,:) = name;
+name=qda{ii,2}; AO.QDA.Monitor.ChannelNames(ii,:) = name;
+name=qda{ii,3}; AO.QDA.Setpoint.ChannelNames(ii,:) = name;
+val =qda{ii,4}; AO.QDA.Status(ii,1) = val;
+val =qda{ii,5}; AO.QDA.DeviceList(ii,:) = val;
+val =qda{ii,6}; AO.QDA.ElementList(ii,1) = val;
+val =qda{ii,7}; % This is the scale factor
+AO.QDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.QDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.QDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QDA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qda{ii,8}; AO.QDA.Setpoint.Tolerance(ii,1) = val;
+
+% Important! This determines the cycling range
+AO.QDA.Setpoint.Range(ii,:) = [0 90];
+end
+
+
+
+% *** QFB ***
+AO.QFB.FamilyName = 'QFB'; dispobject(AO,AO.QFB.FamilyName);
+AO.QFB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
+HW2PhysicsParams = magnetcoefficients('QFB');
+Physics2HWParams = magnetcoefficients('QFB');
+
+AO.QFB.Monitor.Mode = Mode;
+AO.QFB.Monitor.DataType = 'Scalar';
+AO.QFB.Monitor.Units = 'Hardware';
+AO.QFB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QFB.Monitor.Physics2HWFcn = @k2amp;
+AO.QFB.Monitor.HWUnits = 'ampere';
+AO.QFB.Monitor.PhysicsUnits = 'meter^-2';
+
+AO.QFB.Setpoint.Mode = Mode;
+AO.QFB.Setpoint.DataType = 'Scalar';
+AO.QFB.Setpoint.Units = 'Hardware';
+AO.QFB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QFB.Setpoint.Physics2HWFcn = @k2amp;
+AO.QFB.Setpoint.HWUnits = 'ampere';
+AO.QFB.Setpoint.PhysicsUnits = 'meter^-2';
+
+% common monitor setpoint stat devlist elem scale tol
+qfb={
+'1QFB1 ' 'SR01QPS03:CURRENT_MONITOR' 'SR01QPS03:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
+'1QFB2 ' 'SR01QPS04:CURRENT_MONITOR' 'SR01QPS04:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
+'2QFB1 ' 'SR02QPS03:CURRENT_MONITOR' 'SR02QPS03:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
+'2QFB2 ' 'SR02QPS04:CURRENT_MONITOR' 'SR02QPS04:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
+'3QFB1 ' 'SR03QPS03:CURRENT_MONITOR' 'SR03QPS03:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
+'3QFB2 ' 'SR03QPS04:CURRENT_MONITOR' 'SR03QPS04:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
+'4QFB1 ' 'SR04QPS03:CURRENT_MONITOR' 'SR04QPS03:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
+'4QFB2 ' 'SR04QPS04:CURRENT_MONITOR' 'SR04QPS04:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
+'5QFB1 ' 'SR05QPS03:CURRENT_MONITOR' 'SR05QPS03:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
+'5QFB2 ' 'SR05QPS04:CURRENT_MONITOR' 'SR05QPS04:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
+'6QFB1 ' 'SR06QPS03:CURRENT_MONITOR' 'SR06QPS03:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
+'6QFB2 ' 'SR06QPS04:CURRENT_MONITOR' 'SR06QPS04:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
+'7QFB1 ' 'SR07QPS03:CURRENT_MONITOR' 'SR07QPS03:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
+'7QFB2 ' 'SR07QPS04:CURRENT_MONITOR' 'SR07QPS04:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
+'8QFB1 ' 'SR08QPS03:CURRENT_MONITOR' 'SR08QPS03:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
+'8QFB2 ' 'SR08QPS04:CURRENT_MONITOR' 'SR08QPS04:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
+'9QFB1 ' 'SR09QPS03:CURRENT_MONITOR' 'SR09QPS03:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
+'9QFB2 ' 'SR09QPS04:CURRENT_MONITOR' 'SR09QPS04:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
+'10QFB1 ' 'SR10QPS03:CURRENT_MONITOR' 'SR10QPS03:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
+'10QFB2 ' 'SR10QPS04:CURRENT_MONITOR' 'SR10QPS04:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
+'11QFB1 ' 'SR11QPS03:CURRENT_MONITOR' 'SR11QPS03:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
+'11QFB2 ' 'SR11QPS04:CURRENT_MONITOR' 'SR11QPS04:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
+'12QFB1 ' 'SR12QPS03:CURRENT_MONITOR' 'SR12QPS03:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
+'12QFB2 ' 'SR12QPS04:CURRENT_MONITOR' 'SR12QPS04:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
+'13QFB1 ' 'SR13QPS03:CURRENT_MONITOR' 'SR13QPS03:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
+'13QFB2 ' 'SR13QPS04:CURRENT_MONITOR' 'SR13QPS04:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
+'14QFB1 ' 'SR14QPS03:CURRENT_MONITOR' 'SR14QPS03:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
+'14QFB2 ' 'SR14QPS04:CURRENT_MONITOR' 'SR14QPS04:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
+};
+
+for ii=1:size(qfb,1)
+name=qfb{ii,1}; AO.QFB.CommonNames(ii,:) = name;
+name=qfb{ii,2}; AO.QFB.Monitor.ChannelNames(ii,:) = name;
+name=qfb{ii,3}; AO.QFB.Setpoint.ChannelNames(ii,:) = name;
+val =qfb{ii,4}; AO.QFB.Status(ii,1) = val;
+val =qfb{ii,5}; AO.QFB.DeviceList(ii,:) = val;
+val =qfb{ii,6}; AO.QFB.ElementList(ii,1) = val;
+val =qfb{ii,7}; % This is the scale factor
+AO.QFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qfb{ii,8}; AO.QFB.Setpoint.Tolerance(ii,1) = val;
+
+% Important! This determines the cycling range
+AO.QFB.Setpoint.Range(ii,:) = [0 160];
+end
+
+
+%===============
+%Sextupole data
+%===============
+% *** SFA ***
+AO.SFA.FamilyName = 'SFA'; dispobject(AO,AO.SFA.FamilyName);
+AO.SFA.MemberOf = {'PlotFamily'; 'SF'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SFA');
+Physics2HWParams = magnetcoefficients('SFA');
+
+AO.SFA.Monitor.Mode = Mode;
+AO.SFA.Monitor.DataType = 'Scalar';
+AO.SFA.Monitor.Units = 'Hardware';
+AO.SFA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SFA.Monitor.Physics2HWFcn = @k2amp;
+AO.SFA.Monitor.HWUnits = 'ampere';
+AO.SFA.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SFA.Setpoint.Mode = Mode;
+AO.SFA.Setpoint.DataType = 'Scalar';
+AO.SFA.Setpoint.Units = 'Hardware';
+AO.SFA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SFA.Setpoint.Physics2HWFcn = @k2amp;
+AO.SFA.Setpoint.HWUnits = 'ampere';
+AO.SFA.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sfa={
+'1SFA1 ' 'SR01SPS01:CURRENT_MONITOR' 'SR01SPS01:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
+'1SFA2 ' 'SR01SPS07:CURRENT_MONITOR' 'SR01SPS07:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
+'2SFA1 ' 'SR02SPS01:CURRENT_MONITOR' 'SR02SPS01:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
+'2SFA2 ' 'SR02SPS07:CURRENT_MONITOR' 'SR02SPS07:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
+'3SFA1 ' 'SR03SPS01:CURRENT_MONITOR' 'SR03SPS01:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
+'3SFA2 ' 'SR03SPS07:CURRENT_MONITOR' 'SR03SPS07:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
+'4SFA1 ' 'SR04SPS01:CURRENT_MONITOR' 'SR04SPS01:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
+'4SFA2 ' 'SR04SPS07:CURRENT_MONITOR' 'SR04SPS07:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
+'5SFA1 ' 'SR05SPS01:CURRENT_MONITOR' 'SR05SPS01:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
+'5SFA2 ' 'SR05SPS07:CURRENT_MONITOR' 'SR05SPS07:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
+'6SFA1 ' 'SR06SPS01:CURRENT_MONITOR' 'SR06SPS01:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
+'6SFA2 ' 'SR06SPS07:CURRENT_MONITOR' 'SR06SPS07:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
+'7SFA1 ' 'SR07SPS01:CURRENT_MONITOR' 'SR07SPS01:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
+'7SFA2 ' 'SR07SPS07:CURRENT_MONITOR' 'SR07SPS07:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
+'8SFA1 ' 'SR08SPS01:CURRENT_MONITOR' 'SR08SPS01:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
+'8SFA2 ' 'SR08SPS07:CURRENT_MONITOR' 'SR08SPS07:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
+'9SFA1 ' 'SR09SPS01:CURRENT_MONITOR' 'SR09SPS01:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
+'9SFA2 ' 'SR09SPS07:CURRENT_MONITOR' 'SR09SPS07:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
+'10SFA1 ' 'SR10SPS01:CURRENT_MONITOR' 'SR10SPS01:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
+'10SFA2 ' 'SR10SPS07:CURRENT_MONITOR' 'SR10SPS07:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
+'11SFA1 ' 'SR11SPS01:CURRENT_MONITOR' 'SR11SPS01:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
+'11SFA2 ' 'SR11SPS07:CURRENT_MONITOR' 'SR11SPS07:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
+'12SFA1 ' 'SR12SPS01:CURRENT_MONITOR' 'SR12SPS01:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
+'12SFA2 ' 'SR12SPS07:CURRENT_MONITOR' 'SR12SPS07:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
+'13SFA1 ' 'SR13SPS01:CURRENT_MONITOR' 'SR13SPS01:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
+'13SFA2 ' 'SR13SPS07:CURRENT_MONITOR' 'SR13SPS07:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
+'14SFA1 ' 'SR14SPS01:CURRENT_MONITOR' 'SR14SPS01:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
+'14SFA2 ' 'SR14SPS07:CURRENT_MONITOR' 'SR14SPS07:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
+};
+
+for ii=1:size(sfa,1)
+name=sfa{ii,1}; AO.SFA.CommonNames(ii,:) = name;
+name=sfa{ii,2}; AO.SFA.Monitor.ChannelNames(ii,:) = name;
+name=sfa{ii,3}; AO.SFA.Setpoint.ChannelNames(ii,:) = name;
+val =sfa{ii,4}; AO.SFA.Status(ii,1) = val;
+val =sfa{ii,5}; AO.SFA.DeviceList(ii,:) = val;
+val =sfa{ii,6}; AO.SFA.ElementList(ii,1) = val;
+val =sfa{ii,7}; % This is the scale factor
+AO.SFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sfa{ii,8}; AO.SFA.Setpoint.Tolerance(ii,1) = val;
+
+AO.SFA.Setpoint.Range(ii,:) = [0 90];
+end
+
+
+
+% *** SDA ***
+AO.SDA.FamilyName = 'SDA'; dispobject(AO,AO.SDA.FamilyName);
+AO.SDA.MemberOf = {'PlotFamily'; 'SD'; 'SEXT'; 'MachineConfig'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SDA');
+Physics2HWParams = magnetcoefficients('SDA');
+AO.SDA.Monitor.Mode = Mode;
+AO.SDA.Monitor.DataType = 'Scalar';
+AO.SDA.Monitor.Units = 'Hardware';
+AO.SDA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SDA.Monitor.Physics2HWFcn = @k2amp;
+AO.SDA.Monitor.HWUnits = 'ampere';
+AO.SDA.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SDA.Setpoint.Mode = Mode;
+AO.SDA.Setpoint.DataType = 'Scalar';
+AO.SDA.Setpoint.Units = 'Hardware';
+AO.SDA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SDA.Setpoint.Physics2HWFcn = @k2amp;
+AO.SDA.Setpoint.HWUnits = 'ampere';
+AO.SDA.Setpoint.PhysicsUnits = 'meter^-3';
+
+
+% common monitor setpoint stat devlist elem scale tol
+sda={
+'1SDA1 ' 'SR01SPS02:CURRENT_MONITOR' 'SR01SPS02:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
+'1SDA2 ' 'SR01SPS06:CURRENT_MONITOR' 'SR01SPS06:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
+'2SDA1 ' 'SR02SPS02:CURRENT_MONITOR' 'SR02SPS02:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
+'2SDA2 ' 'SR02SPS06:CURRENT_MONITOR' 'SR02SPS06:CURRENT_SP ' 1 [2,2] 4 1.0 0.5 ; ...
+'3SDA1 ' 'SR03SPS02:CURRENT_MONITOR' 'SR03SPS02:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
+'3SDA2 ' 'SR03SPS06:CURRENT_MONITOR' 'SR03SPS06:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
+'4SDA1 ' 'SR04SPS02:CURRENT_MONITOR' 'SR04SPS02:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
+'4SDA2 ' 'SR04SPS06:CURRENT_MONITOR' 'SR04SPS06:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
+'5SDA1 ' 'SR05SPS02:CURRENT_MONITOR' 'SR05SPS02:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
+'5SDA2 ' 'SR05SPS06:CURRENT_MONITOR' 'SR05SPS06:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
+'6SDA1 ' 'SR06SPS02:CURRENT_MONITOR' 'SR06SPS02:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
+'6SDA2 ' 'SR06SPS06:CURRENT_MONITOR' 'SR06SPS06:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
+'7SDA1 ' 'SR07SPS02:CURRENT_MONITOR' 'SR07SPS02:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
+'7SDA2 ' 'SR07SPS06:CURRENT_MONITOR' 'SR07SPS06:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
+'8SDA1 ' 'SR08SPS02:CURRENT_MONITOR' 'SR08SPS02:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
+'8SDA2 ' 'SR08SPS06:CURRENT_MONITOR' 'SR08SPS06:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
+'9SDA1 ' 'SR09SPS02:CURRENT_MONITOR' 'SR09SPS02:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
+'9SDA2 ' 'SR09SPS06:CURRENT_MONITOR' 'SR09SPS06:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
+'10SDA1 ' 'SR10SPS02:CURRENT_MONITOR' 'SR10SPS02:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
+'10SDA2 ' 'SR10SPS06:CURRENT_MONITOR' 'SR10SPS06:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
+'11SDA1 ' 'SR11SPS02:CURRENT_MONITOR' 'SR11SPS02:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
+'11SDA2 ' 'SR11SPS06:CURRENT_MONITOR' 'SR11SPS06:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
+'12SDA1 ' 'SR12SPS02:CURRENT_MONITOR' 'SR12SPS02:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
+'12SDA2 ' 'SR12SPS06:CURRENT_MONITOR' 'SR12SPS06:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
+'13SDA1 ' 'SR13SPS02:CURRENT_MONITOR' 'SR13SPS02:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
+'13SDA2 ' 'SR13SPS06:CURRENT_MONITOR' 'SR13SPS06:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
+'14SDA1 ' 'SR14SPS02:CURRENT_MONITOR' 'SR14SPS02:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
+'14SDA2 ' 'SR14SPS06:CURRENT_MONITOR' 'SR14SPS06:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
+};
+
+for ii=1:size(sda,1)
+name=sda{ii,1}; AO.SDA.CommonNames(ii,:) = name;
+name=sda{ii,2}; AO.SDA.Monitor.ChannelNames(ii,:) = name;
+name=sda{ii,3}; AO.SDA.Setpoint.ChannelNames(ii,:) = name;
+val =sda{ii,4}; AO.SDA.Status(ii,1) = val;
+val =sda{ii,5}; AO.SDA.DeviceList(ii,:) = val;
+val =sda{ii,6}; AO.SDA.ElementList(ii,1) = val;
+val =sda{ii,7}; % This is the scale factor
+AO.SDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sda{ii,8}; AO.SDA.Setpoint.Tolerance(ii,1) = val;
+
+AO.SDA.Setpoint.Range(ii,:) = [0 90];
+end
+
+
+% *** SDB ***
+AO.SDB.FamilyName = 'SDB'; dispobject(AO,AO.SDB.FamilyName);
+AO.SDB.MemberOf = {'PlotFamily'; 'SD'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SDB');
+Physics2HWParams = magnetcoefficients('SDB');
+AO.SDB.Monitor.Mode = Mode;
+AO.SDB.Monitor.DataType = 'Scalar';
+AO.SDB.Monitor.Units = 'Hardware';
+AO.SDB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SDB.Monitor.Physics2HWFcn = @k2amp;
+AO.SDB.Monitor.HWUnits = 'ampere';
+AO.SDB.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SDB.Setpoint.Mode = Mode;
+AO.SDB.Setpoint.DataType = 'Scalar';
+AO.SDB.Setpoint.Units = 'Hardware';
+AO.SDB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SDB.Setpoint.Physics2HWFcn = @k2amp;
+AO.SDB.Setpoint.HWUnits = 'ampere';
+AO.SDB.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sdb={
+'1SDB1 ' 'SR01SPS03:CURRENT_MONITOR' 'SR01SPS03:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
+'1SDB2 ' 'SR01SPS05:CURRENT_MONITOR' 'SR01SPS05:CURRENT_SP ' 1 [1,2] 2 1.0 0.5 ; ...
+'2SDB1 ' 'SR02SPS03:CURRENT_MONITOR' 'SR02SPS03:CURRENT_SP ' 1 [2,1] 3 1.0 0.5 ; ...
+'2SDB2 ' 'SR02SPS05:CURRENT_MONITOR' 'SR02SPS05:CURRENT_SP ' 1 [2,2] 4 1.0 3.0 ; ...
+'3SDB1 ' 'SR03SPS03:CURRENT_MONITOR' 'SR03SPS03:CURRENT_SP ' 1 [3,1] 5 1.0 0.5 ; ...
+'3SDB2 ' 'SR03SPS05:CURRENT_MONITOR' 'SR03SPS05:CURRENT_SP ' 1 [3,2] 6 1.0 0.5 ; ...
+'4SDB1 ' 'SR04SPS03:CURRENT_MONITOR' 'SR04SPS03:CURRENT_SP ' 1 [4,1] 7 1.0 0.5 ; ...
+'4SDB2 ' 'SR04SPS05:CURRENT_MONITOR' 'SR04SPS05:CURRENT_SP ' 1 [4,2] 8 1.0 0.5 ; ...
+'5SDB1 ' 'SR05SPS03:CURRENT_MONITOR' 'SR05SPS03:CURRENT_SP ' 1 [5,1] 9 1.0 0.5 ; ...
+'5SDB2 ' 'SR05SPS05:CURRENT_MONITOR' 'SR05SPS05:CURRENT_SP ' 1 [5,2] 10 1.0 0.5 ; ...
+'6SDB1 ' 'SR06SPS03:CURRENT_MONITOR' 'SR06SPS03:CURRENT_SP ' 1 [6,1] 11 1.0 0.5 ; ...
+'6SDB2 ' 'SR06SPS05:CURRENT_MONITOR' 'SR06SPS05:CURRENT_SP ' 1 [6,2] 12 1.0 0.5 ; ...
+'7SDB1 ' 'SR07SPS03:CURRENT_MONITOR' 'SR07SPS03:CURRENT_SP ' 1 [7,1] 13 1.0 0.5 ; ...
+'7SDB2 ' 'SR07SPS05:CURRENT_MONITOR' 'SR07SPS05:CURRENT_SP ' 1 [7,2] 14 1.0 0.5 ; ...
+'8SDB1 ' 'SR08SPS03:CURRENT_MONITOR' 'SR08SPS03:CURRENT_SP ' 1 [8,1] 15 1.0 0.5 ; ...
+'8SDB2 ' 'SR08SPS05:CURRENT_MONITOR' 'SR08SPS05:CURRENT_SP ' 1 [8,2] 16 1.0 0.5 ; ...
+'9SDB1 ' 'SR09SPS03:CURRENT_MONITOR' 'SR09SPS03:CURRENT_SP ' 1 [9,1] 17 1.0 0.5 ; ...
+'9SDB2 ' 'SR09SPS05:CURRENT_MONITOR' 'SR09SPS05:CURRENT_SP ' 1 [9,2] 18 1.0 0.5 ; ...
+'10SDB1 ' 'SR10SPS03:CURRENT_MONITOR' 'SR10SPS03:CURRENT_SP ' 1 [10,1] 19 1.0 0.5 ; ...
+'10SDB2 ' 'SR10SPS05:CURRENT_MONITOR' 'SR10SPS05:CURRENT_SP ' 1 [10,2] 20 1.0 0.5 ; ...
+'11SDB1 ' 'SR11SPS03:CURRENT_MONITOR' 'SR11SPS03:CURRENT_SP ' 1 [11,1] 21 1.0 0.5 ; ...
+'11SDB2 ' 'SR11SPS05:CURRENT_MONITOR' 'SR11SPS05:CURRENT_SP ' 1 [11,2] 22 1.0 0.5 ; ...
+'12SDB1 ' 'SR12SPS03:CURRENT_MONITOR' 'SR12SPS03:CURRENT_SP ' 1 [12,1] 23 1.0 0.5 ; ...
+'12SDB2 ' 'SR12SPS05:CURRENT_MONITOR' 'SR12SPS05:CURRENT_SP ' 1 [12,2] 24 1.0 0.5 ; ...
+'13SDB1 ' 'SR13SPS03:CURRENT_MONITOR' 'SR13SPS03:CURRENT_SP ' 1 [13,1] 25 1.0 0.5 ; ...
+'13SDB2 ' 'SR13SPS05:CURRENT_MONITOR' 'SR13SPS05:CURRENT_SP ' 1 [13,2] 26 1.0 0.5 ; ...
+'14SDB1 ' 'SR14SPS03:CURRENT_MONITOR' 'SR14SPS03:CURRENT_SP ' 1 [14,1] 27 1.0 0.5 ; ...
+'14SDB2 ' 'SR14SPS05:CURRENT_MONITOR' 'SR14SPS05:CURRENT_SP ' 1 [14,2] 28 1.0 0.5 ; ...
+};
+
+for ii=1:size(sdb,1)
+name=sdb{ii,1}; AO.SDB.CommonNames(ii,:) = name;
+name=sdb{ii,2}; AO.SDB.Monitor.ChannelNames(ii,:) = name;
+name=sdb{ii,3}; AO.SDB.Setpoint.ChannelNames(ii,:)= name;
+val =sdb{ii,4}; AO.SDB.Status(ii,1) = val;
+val =sdb{ii,5}; AO.SDB.DeviceList(ii,:) = val;
+val =sdb{ii,6}; AO.SDB.ElementList(ii,1) = val;
+val =sdb{ii,7}; % This is the scale factor
+AO.SDB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SDB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sdb{ii,8}; AO.SDB.Setpoint.Tolerance(ii,1) = val;
+
+AO.SDB.Setpoint.Range(ii,:) = [0 80];
+end
+
+
+
+% *** SFB ***
+AO.SFB.FamilyName = 'SFB'; dispobject(AO,AO.SFB.FamilyName);
+AO.SFB.MemberOf = {'PlotFamily'; 'SF'; 'MachineConfig'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SFB');
+Physics2HWParams = magnetcoefficients('SFB');
+
+AO.SFB.Monitor.Mode = Mode;
+AO.SFB.Monitor.DataType = 'Scalar';
+AO.SFB.Monitor.Units = 'Hardware';
+AO.SFB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SFB.Monitor.Physics2HWFcn = @k2amp;
+AO.SFB.Monitor.HWUnits = 'ampere';
+AO.SFB.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SFB.Setpoint.Mode = Mode;
+AO.SFB.Setpoint.DataType = 'Scalar';
+AO.SFB.Setpoint.Units = 'Hardware';
+AO.SFB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SFB.Setpoint.Physics2HWFcn = @k2amp;
+AO.SFB.Setpoint.HWUnits = 'ampere';
+AO.SFB.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sfb={
+'1SFB1 ' 'SR01SPS04:CURRENT_MONITOR' 'SR01SPS04:CURRENT_SP ' 1 [1,1] 1 1.0 0.5 ; ...
+'2SFB1 ' 'SR02SPS04:CURRENT_MONITOR' 'SR02SPS04:CURRENT_SP ' 1 [2,1] 2 1.0 0.5 ; ...
+'3SFB1 ' 'SR03SPS04:CURRENT_MONITOR' 'SR03SPS04:CURRENT_SP ' 1 [3,1] 3 1.0 0.5 ; ...
+'4SFB1 ' 'SR04SPS04:CURRENT_MONITOR' 'SR04SPS04:CURRENT_SP ' 1 [4,1] 4 1.0 0.5 ; ...
+'5SFB1 ' 'SR05SPS04:CURRENT_MONITOR' 'SR05SPS04:CURRENT_SP ' 1 [5,1] 5 1.0 0.5 ; ...
+'6SFB1 ' 'SR06SPS04:CURRENT_MONITOR' 'SR06SPS04:CURRENT_SP ' 1 [6,1] 6 1.0 0.5 ; ...
+'7SFB1 ' 'SR07SPS04:CURRENT_MONITOR' 'SR07SPS04:CURRENT_SP ' 1 [7,1] 7 1.0 0.5 ; ...
+'8SFB1 ' 'SR08SPS04:CURRENT_MONITOR' 'SR08SPS04:CURRENT_SP ' 1 [8,1] 8 1.0 0.5 ; ...
+'9SFB1 ' 'SR09SPS04:CURRENT_MONITOR' 'SR09SPS04:CURRENT_SP ' 1 [9,1] 9 1.0 0.5 ; ...
+'10SFB1 ' 'SR10SPS04:CURRENT_MONITOR' 'SR10SPS04:CURRENT_SP ' 1 [10,1] 10 1.0 0.5 ; ...
+'11SFB1 ' 'SR11SPS04:CURRENT_MONITOR' 'SR11SPS04:CURRENT_SP ' 1 [11,1] 11 1.0 0.5 ; ...
+'12SFB1 ' 'SR12SPS04:CURRENT_MONITOR' 'SR12SPS04:CURRENT_SP ' 1 [12,1] 12 1.0 0.5 ; ...
+'13SFB1 ' 'SR13SPS04:CURRENT_MONITOR' 'SR13SPS04:CURRENT_SP ' 1 [13,1] 13 1.0 0.5 ; ...
+'14SFB1 ' 'SR14SPS04:CURRENT_MONITOR' 'SR14SPS04:CURRENT_SP ' 1 [14,1] 14 1.0 0.5 ; ...
+};
+
+for ii=1:size(sfb,1)
+name=sfb{ii,1}; AO.SFB.CommonNames(ii,:) = name;
+name=sfb{ii,2}; AO.SFB.Monitor.ChannelNames(ii,:) = name;
+name=sfb{ii,3}; AO.SFB.Setpoint.ChannelNames(ii,:)= name;
+val =sfb{ii,4}; AO.SFB.Status(ii,1) = val;
+val =sfb{ii,5}; AO.SFB.DeviceList(ii,:) = val;
+val =sfb{ii,6}; AO.SFB.ElementLsist(ii,1) = val;
+val =sfb{ii,7}; % This is the scale factor
+AO.SFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sfb{ii,8}; AO.SFB.Setpoint.Tolerance(ii,1) = val;
+
+AO.SFB.Setpoint.Range(ii,:) = [0 60];
+end
+
+%===============
+%Skew Quad data
+%===============
+% *** Skew quadrupoles *** 2005/09/27 Eugene
+AO.SKQ.FamilyName = 'SKQ'; dispobject(AO,AO.SKQ.FamilyName);
+AO.SKQ.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SkewQuad'; 'Magnet';};
+HW2PhysicsParams = magnetcoefficients('SKQ');
+Physics2HWParams = magnetcoefficients('SKQ');
+
+AO.SKQ.Monitor.Mode = Mode;
+AO.SKQ.Monitor.DataType = 'Scalar';
+AO.SKQ.Monitor.Units = 'Hardware';
+AO.SKQ.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SKQ.Monitor.Physics2HWFcn = @k2amp;
+AO.SKQ.Monitor.HWUnits = 'ampere';
+AO.SKQ.Monitor.PhysicsUnits = 'meter^-2';
+
+AO.SKQ.Setpoint.Mode = Mode;
+AO.SKQ.Setpoint.DataType = 'Scalar';
+AO.SKQ.Setpoint.Units = 'Hardware';
+AO.SKQ.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SKQ.Setpoint.Physics2HWFcn = @k2amp;
+AO.SKQ.Setpoint.HWUnits = 'ampere';
+AO.SKQ.Setpoint.PhysicsUnits = 'meter^-2';
+
+% common monitor setpoint stat devlist elem scale tol
+sq={
+'1SKQ1 ' 'SR01CPS03:CURRENT_MONITOR' 'SR01CPS03:CURRENT_SP ' 1 [1,1] 1 1 ; ...
+'1SKQ2 ' 'SR01CPS08:CURRENT_MONITOR' 'SR01CPS08:CURRENT_SP ' 1 [1,2] 2 1 ; ...
+'2SKQ1 ' 'SR02CPS03:CURRENT_MONITOR' 'SR02CPS03:CURRENT_SP ' 1 [2,1] 3 1 ; ...
+'2SKQ2 ' 'SR02CPS08:CURRENT_MONITOR' 'SR02CPS08:CURRENT_SP ' 1 [2,2] 4 1 ; ...
+'3SKQ1 ' 'SR03CPS03:CURRENT_MONITOR' 'SR03CPS03:CURRENT_SP ' 1 [3,1] 5 1 ; ...
+'3SKQ2 ' 'SR03CPS08:CURRENT_MONITOR' 'SR03CPS08:CURRENT_SP ' 1 [3,2] 6 1 ; ...
+'4SKQ1 ' 'SR04CPS03:CURRENT_MONITOR' 'SR04CPS03:CURRENT_SP ' 1 [4,1] 7 1 ; ...
+'4SKQ2 ' 'SR04CPS08:CURRENT_MONITOR' 'SR04CPS08:CURRENT_SP ' 1 [4,2] 8 1 ; ...
+'5SKQ1 ' 'SR05CPS03:CURRENT_MONITOR' 'SR05CPS03:CURRENT_SP ' 1 [5,1] 9 1 ; ...
+'5SKQ2 ' 'SR05CPS08:CURRENT_MONITOR' 'SR05CPS08:CURRENT_SP ' 1 [5,2] 10 1 ; ...
+'6SKQ1 ' 'SR06CPS03:CURRENT_MONITOR' 'SR06CPS03:CURRENT_SP ' 1 [6,1] 11 1 ; ...
+'6SKQ2 ' 'SR06CPS08:CURRENT_MONITOR' 'SR06CPS08:CURRENT_SP ' 1 [6,2] 12 1 ; ...
+'7SKQ1 ' 'SR07CPS03:CURRENT_MONITOR' 'SR07CPS03:CURRENT_SP ' 1 [7,1] 13 1 ; ...
+'7SKQ2 ' 'SR07CPS08:CURRENT_MONITOR' 'SR07CPS08:CURRENT_SP ' 1 [7,2] 14 1 ; ...
+'8SKQ1 ' 'SR08CPS03:CURRENT_MONITOR' 'SR08CPS03:CURRENT_SP ' 1 [8,1] 15 1 ; ...
+'8SKQ2 ' 'SR08CPS08:CURRENT_MONITOR' 'SR08CPS08:CURRENT_SP ' 1 [8,2] 16 1 ; ...
+'9SKQ1 ' 'SR09CPS03:CURRENT_MONITOR' 'SR09CPS03:CURRENT_SP ' 1 [9,1] 17 1 ; ...
+'9SKQ2 ' 'SR09CPS08:CURRENT_MONITOR' 'SR09CPS08:CURRENT_SP ' 1 [9,2] 18 1 ; ...
+'10SKQ1 ' 'SR10CPS03:CURRENT_MONITOR' 'SR10CPS03:CURRENT_SP ' 1 [10,1] 19 1 ; ...
+'10SKQ2 ' 'SR10CPS08:CURRENT_MONITOR' 'SR10CPS08:CURRENT_SP ' 1 [10,2] 20 1 ; ...
+'11SKQ1 ' 'SR11CPS03:CURRENT_MONITOR' 'SR11CPS03:CURRENT_SP ' 1 [11,1] 21 1 ; ...
+'11SKQ2 ' 'SR11CPS08:CURRENT_MONITOR' 'SR11CPS08:CURRENT_SP ' 1 [11,2] 22 1 ; ...
+'12SKQ1 ' 'SR12CPS03:CURRENT_MONITOR' 'SR12CPS03:CURRENT_SP ' 1 [12,1] 23 1 ; ...
+'12SKQ2 ' 'SR12CPS08:CURRENT_MONITOR' 'SR12CPS08:CURRENT_SP ' 1 [12,2] 24 1 ; ...
+'13SKQ1 ' 'SR13CPS03:CURRENT_MONITOR' 'SR13CPS03:CURRENT_SP ' 1 [13,1] 25 1 ; ...
+'13SKQ2 ' 'SR13CPS08:CURRENT_MONITOR' 'SR13CPS08:CURRENT_SP ' 1 [13,2] 26 1 ; ...
+'14SKQ1 ' 'SR14CPS03:CURRENT_MONITOR' 'SR14CPS03:CURRENT_SP ' 1 [14,1] 27 1 ; ...
+'14SKQ2 ' 'SR14CPS08:CURRENT_MONITOR' 'SR14CPS08:CURRENT_SP ' 1 [14,2] 28 1 ; ...
+};
+
+for ii=1:size(sq,1)
+name=sq{ii,1}; AO.SKQ.CommonNames(ii,:) = name;
+name=sq{ii,2}; AO.SKQ.Monitor.ChannelNames(ii,:) = name;
+name=sq{ii,3}; AO.SKQ.Setpoint.ChannelNames(ii,:) = name;
+val =sq{ii,4}; AO.SKQ.Status(ii,1) = val;
+val =sq{ii,5}; AO.SKQ.DeviceList(ii,:) = val;
+val =sq{ii,6}; AO.SKQ.ElementList(ii,1) = val;
+val =sq{ii,7}; AO.SKQ.Setpoint.Tolerance(ii,1) = val;
+AO.SKQ.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SKQ.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SKQ.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SKQ.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+
+AO.SKQ.Setpoint.Range(ii,:) = [-5 +5];
+end
+
+
+%===============
+%Kicker data
+%===============
+AO.KICK.FamilyName = 'KICK'; dispobject(AO,AO.KICK.FamilyName);
+AO.KICK.MemberOf = {'Injection','MachineConfig' 'Plotfamily'};
+
+AO.KICK.Monitor.Mode = Mode;
+AO.KICK.Monitor.DataType = 'Scalar';
+AO.KICK.Monitor.Units = 'Hardware';
+AO.KICK.Monitor.HWUnits = 'kVolts';
+AO.KICK.Monitor.PhysicsUnits = 'mradian';
+
+AO.KICK.Setpoint.Mode = Mode;
+AO.KICK.Setpoint.DataType = 'Scalar';
+AO.KICK.Setpoint.Units = 'Hardware';
+AO.KICK.Setpoint.HWUnits = 'Volts';
+AO.KICK.Setpoint.PhysicsUnits = 'radian';
+
+% From kicker deisgn review the kickers are rated to 4380 Amps giving 0.038
+% Tesla converting this to kickangle. Also convert voltage into amps for
+% the conversion?
+%
+% 2780 V on the capacitor banks will create 5240 A delivered to the kicker
+% magnets.
+% From simulations 4380 A creates 0.038607 T over a length of 0.7 m.
+% Therefore 4380 A => 2.7006 mrad. Therefore 2323.740 V => 2.7006 mrad.
+% HW2PHYSICS conversion factor (kV to rad) is therefore 0.0027006/2.32374 =
+% 0.00116217821271. The Ps also goes through a 1:3 transformer therefore
+% the conversion factor increases by 3. Ie 0.00348653463813
+% For V to rad then 0.00000348653463813.
+hw2physics_conversionfactor = 0.00000348653463813;
+
+% Measured
+% Kicker1 100 V = 0.176 mrad
+% Kicker2 100 V = -0.138 mrad
+% Kicker3 100 V = -0.134 mrad
+% Kicker4 100 V = 0.176 mrad
+
+%common monitor setpoint stat devlist elem tol
+kickeramp={
+'KICK1 ' 'SR14KPS01:VOLTAGE_MONITOR' 'SR14KPS01:VOLTAGE_SP ' 1 [1,1] 1 0.10 ; ...
+'KICK2 ' 'SR01KPS01:VOLTAGE_MONITOR' 'SR01KPS01:VOLTAGE_SP ' 1 [1,2] 2 0.10 ; ...
+'KICK3 ' 'SR01KPS02:VOLTAGE_MONITOR' 'SR01KPS02:VOLTAGE_SP ' 1 [1,3] 3 0.10 ; ...
+'KICK4 ' 'SR02KPS01:VOLTAGE_MONITOR' 'SR02KPS01:VOLTAGE_SP ' 1 [1,4] 4 0.10 ; ...
+};
+
+for ii=1:size(kickeramp,1)
+name=kickeramp{ii,1}; AO.KICK.CommonNames(ii,:) = name;
+name=kickeramp{ii,2}; AO.KICK.Monitor.ChannelNames(ii,:) = name;
+name=kickeramp{ii,3}; AO.KICK.Setpoint.ChannelNames(ii,:)= name;
+val =kickeramp{ii,4}; AO.KICK.Status(ii,1) = val;
+val =kickeramp{ii,5}; AO.KICK.DeviceList(ii,:) = val;
+val =kickeramp{ii,6}; AO.KICK.ElementList(ii,1) = val;
+val =kickeramp{ii,7}; AO.KICK.Setpoint.Tolerance(ii,1) = val;
+
+if ii==1||ii==4
+ hw2physics_conversionfactor = 1.7600e-06;
+ AO.KICK.Monitor.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
+ AO.KICK.Monitor.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
+ AO.KICK.Setpoint.HW2PhysicsParams(ii,:) = hw2physics_conversionfactor;
+ AO.KICK.Setpoint.Physics2HWParams(ii,:) = 1/hw2physics_conversionfactor;
+ AO.KICK.Setpoint.Range(ii,:) = [-1300 +1300];
+else
+ hw2physics_conversionfactor = 1.3600e-06;
+ AO.KICK.Monitor.HW2PhysicsParams(ii,:) = -hw2physics_conversionfactor;
+ AO.KICK.Monitor.Physics2HWParams(ii,:) = -1/hw2physics_conversionfactor;
+ AO.KICK.Setpoint.HW2PhysicsParams(ii,:) = -hw2physics_conversionfactor;
+ AO.KICK.Setpoint.Physics2HWParams(ii,:) = -1/hw2physics_conversionfactor;
+ AO.KICK.Setpoint.Range(ii,:) = [+1300 -1300];
+end
+end
+
+% *** KICK Delay ***
+% AO.KICK.Delay
+% >> removed >> see previous versions if info needed
+
+
+%============
+%RF System
+%============
+AO.RF.FamilyName = 'RF'; dispobject(AO,AO.RF.FamilyName);
+AO.RF.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
+
+%-------------------------------- 4 cavity Case
+%common stat devlist elem
+rfcommon={
+'RF1 ' 1 [1,1] 1 ; ...
+'RF2 ' 1 [1,2] 2 ; ...
+'RF3 ' 1 [1,3] 3 ; ...
+'RF4 ' 1 [1,4] 4 ; ...
+ };
+
+%FreqMon FreqSetpoint HW2PhysicsParams Physics2HWParams Range Tolerance
+rffreq={
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
+'SR00MOS01:FREQUENCY_MONITOR' 'SR00MOS01:FREQUENCY_SP' 1 1 [0 6e8] 100.0; ...
+ };
+
+% PhaseCtrl PhaseMon HW2PhysicsParams Physics2HWParams Range Tolerance
+rfphase={
+'SRF1:STN:PHASE' 'SRF1:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
+'SRF2:STN:PHASE' 'SRF2:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
+'SRF3:STN:PHASE' 'SRF3:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
+'SRF4:STN:PHASE' 'SRF4:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
+ };
+
+% VoltCtrl VoltMon HW2PhysicsParams Physics2HWParams Range Tolerance
+rfvolt={
+'SRF1:STN:VOLT:CTRL ' 'SRF1:STN:VOLT' 1 1 [-inf inf] inf ; ...
+'SRF2:STN:VOLT:CTRL ' 'SRF2:STN:VOLT' 1 1 [-inf inf] inf ; ...
+'SRF3:STN:VOLT:CTRL ' 'SRF3:STN:VOLT' 1 1 [-inf inf] inf ; ...
+'SRF4:STN:VOLT:CTRL ' 'SRF4:STN:VOLT' 1 1 [-inf inf] inf ; ...
+ };
+% PowerCtrl PowerMon Klystronpower HW2PhysicsParams Physics2HWParams Range Tolerance
+rfpower={
+'SRF1:KLYSDRIVFRWD:POWER:ON ' 'SRF1:KLYSDRIVFRWD:POWER' 'SRF1:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+'SRF2:KLYSDRIVFRWD:POWER:ON ' 'SRF2:KLYSDRIVFRWD:POWER' 'SRF2:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+'SRF3:KLYSDRIVFRWD:POWER:ON ' 'SRF3:KLYSDRIVFRWD:POWER' 'SRF3:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+'SRF4:KLYSDRIVFRWD:POWER:ON ' 'SRF4:KLYSDRIVFRWD:POWER' 'SRF4:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+ };
+
+for ii=1:size(rfcommon,1)
+name=rfcommon{ii,1}; AO.RF.CommonNames(ii,:) = name;
+val =rfcommon{ii,2}; AO.RF.Status(ii,1) = val;
+val =rfcommon{ii,3}; AO.RF.DeviceList(ii,:) = val;
+val =rfcommon{ii,4}; AO.RF.ElementList(ii,1) = val;
+end
+
+for ii=1:size(rffreq,1)
+name=rffreq{ii,1}; AO.RF.Monitor.ChannelNames(ii,:) = name;
+name=rffreq{ii,2}; AO.RF.Setpoint.ChannelNames(ii,:) = name;
+val =rffreq{ii,3}; AO.RF.Monitor.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Setpoint.HW2PhysicsParams(ii,1) = val;
+val =rffreq{ii,4}; AO.RF.Monitor.Physics2HWParams(ii,1) = val;
+ AO.RF.Setpoint.Physics2HWParams(ii,1) = val;
+val =rffreq{ii,5}; AO.RF.Setpoint.Range(ii,:) = val;
+val =rffreq{ii,6}; AO.RF.Setpoint.Tolerance(ii,1) = val;
+end
+
+
+for ii=1:size(rfphase,1)
+name=rfphase{ii,1}; AO.RF.PhaseCtrl.ChannelNames(ii,:) = name;
+name=rfphase{ii,2}; AO.RF.Phase.ChannelNames(ii,:) = name;
+val =rfphase{ii,3}; AO.RF.PhaseCtrl.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Phase.HW2PhysicsParams(ii,1) = val;
+val =rfphase{ii,4}; AO.RF.PhaseCtrl.Physics2HWParams(ii,1) = val;
+ AO.RF.Phase.Physics2HWParams(ii,1) = val;
+val =rfphase{ii,5}; AO.RF.PhaseCtrl.Range(ii,:) = val;
+ AO.RF.Phase.Range(ii,:) = val;
+val =rfphase{ii,6}; AO.RF.PhaseCtrl.Tolerance(ii,1) = val;
+ AO.RF.Phase.Tolerance(ii,1) = val;
+end
+
+
+for ii=1:size(rfvolt,1)
+name=rfvolt{ii,1}; AO.RF.VoltageCtrl.ChannelNames(ii,:) = name;
+name=rfvolt{ii,2}; AO.RF.Voltage.ChannelNames(ii,:) = name;
+val =rfvolt{ii,3}; AO.RF.VoltageCtrl.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Voltage.HW2PhysicsParams(ii,1) = val;
+val =rfvolt{ii,4}; AO.RF.VoltageCtrl.Physics2HWParams(ii,1) = val;
+ AO.RF.Voltage.Physics2HWParams(ii,1) = val;
+val =rfvolt{ii,5}; AO.RF.VoltageCtrl.Range(ii,:) = val;
+ AO.RF.Voltage.Range(ii,:) = val;
+val =rfvolt{ii,6}; AO.RF.VoltageCtrl.Tolerance(ii,1) = val;
+ AO.RF.Voltage.Tolerance(ii,1) = val;
+end
+
+
+for ii=1:size(rfpower,1)
+name=rfpower{ii,1}; AO.RF.PowerCtrl.ChannelNames(ii,:) = name;
+name=rfpower{ii,2}; AO.RF.Power.ChannelNames(ii,:) = name;
+name=rfpower{ii,3}; AO.RF.KlysPower.ChannelNames(ii,:) = name;
+val =rfpower{ii,4}; AO.RF.PowerCtrl.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Power.HW2PhysicsParams(ii,1) = val;
+ AO.RF.KlysPower.HW2PhysicsParams(ii,1) = val;
+val =rfpower{ii,5}; AO.RF.PowerCtrl.Physics2HWParams(ii,1) = val;
+ AO.RF.Power.Physics2HWParams(ii,1) = val;
+ AO.RF.KlysPower.Physics2HWParams(ii,1) = val;
+val =rfpower{ii,6}; AO.RF.PowerCtrl.Range(ii,:) = val;
+ AO.RF.Power.Range(ii,:) = val;
+ AO.RF.KlysPower.Range(ii,:) = val;
+val =rfpower{ii,7}; AO.RF.PowerCtrl.Tolerance(ii,1) = val;
+ AO.RF.Power.Tolerance(ii,1) = val;
+ AO.RF.KlysPower.Tolerance(ii,1) = val;
+end
+
+%Frequency Readback
+AO.RF.Monitor.Mode = Mode;
+AO.RF.Monitor.DataType = 'Scalar';
+AO.RF.Monitor.Units = 'Hardware';
+AO.RF.Monitor.HWUnits = 'Hz';
+AO.RF.Monitor.PhysicsUnits = 'Hz';
+%Frequency Setpoint
+AO.RF.Setpoint.Mode = Mode;
+AO.RF.Setpoint.DataType = 'Scalar';
+AO.RF.Setpoint.Units = 'Hardware';
+AO.RF.Setpoint.HWUnits = 'Hz';
+AO.RF.Setpoint.PhysicsUnits = 'Hz';
+
+%Voltage control
+AO.RF.VoltageCtrl.Mode = Mode;
+AO.RF.VoltageCtrl.DataType = 'Scalar';
+AO.RF.VoltageCtrl.Units = 'Hardware';
+AO.RF.VoltageCtrl.HWUnits = 'Volts';
+AO.RF.VoltageCtrl.PhysicsUnits = 'Volts';
+
+%Voltage monitor
+AO.RF.Voltage.Mode = Mode;
+AO.RF.Voltage.DataType = 'Scalar';
+AO.RF.Voltage.Units = 'Hardware';
+AO.RF.Voltage.HWUnits = 'Volts';
+AO.RF.Voltage.PhysicsUnits = 'Volts';
+
+%Power Control
+AO.RF.PowerCtrl.Mode = Mode;
+AO.RF.PowerCtrl.DataType = 'Scalar';
+AO.RF.PowerCtrl.Units = 'Hardware';
+AO.RF.PowerCtrl.HWUnits = 'MWatts';
+AO.RF.PowerCtrl.PhysicsUnits = 'MWatts';
+
+%Power Monitor
+AO.RF.Power.Mode = Mode;
+AO.RF.Power.DataType = 'Scalar';
+AO.RF.Power.Units = 'Hardware';
+AO.RF.Power.HWUnits = 'MWatts';
+AO.RF.Power.PhysicsUnits = 'MWatts';
+
+%Klystron Forward Power
+AO.RF.KlysPower.Mode = Mode;
+AO.RF.KlysPower.DataType = 'Scalar';
+AO.RF.KlysPower.Units = 'Hardware';
+AO.RF.KlysPower.HWUnits = 'MWatts';
+AO.RF.KlysPower.PhysicsUnits = 'MWatts';
+
+%Station Phase Control
+AO.RF.PhaseCtrl.Mode = Mode;
+AO.RF.PhaseCtrl.DataType = 'Scalar';
+AO.RF.PhaseCtrl.Units = 'Hardware';
+AO.RF.PhaseCtrl.HWUnits = 'Degrees';
+AO.RF.PhaseCtrl.PhysicsUnits = 'Degrees';
+
+
+%Station Phase Monitor
+AO.RF.Phase.Mode = Mode;
+AO.RF.Phase.DataType = 'Scalar';
+AO.RF.Phase.Units = 'Hardware';
+AO.RF.Phase.HWUnits = 'Degrees';
+AO.RF.Phase.PhysicsUnits = 'Degrees';
+
+%====
+%TUNE
+%====
+AO.TUNE.FamilyName = 'TUNE'; dispobject(AO,AO.TUNE.FamilyName);
+AO.TUNE.MemberOf = {'Tune'; 'Diagnostics'};
+AO.TUNE.CommonNames = ['xtune';'ytune'];
+AO.TUNE.DeviceList = [ 1 1; 1 2];
+AO.TUNE.ElementList = [1 2]';
+AO.TUNE.Status = [1 1]';
+
+AO.TUNE.Monitor.Mode = 'Special';
+AO.TUNE.Monitor.SpecialFunction = 'meastune';
+AO.TUNE.Monitor.DataType = 'Vector';
+AO.TUNE.Monitor.DataTypeIndex = [1 2]';
+AO.TUNE.Monitor.Units = 'Hardware';
+AO.TUNE.Monitor.HW2PhysicsParams = 1;
+AO.TUNE.Monitor.Physics2HWParams = 1;
+AO.TUNE.Monitor.HWUnits = 'fractional tune';
+AO.TUNE.Monitor.PhysicsUnits = 'fractional tune';
+
+
+% AO.FTx.Length.Mode = 'Special';
+% AO.FTx.Length.Units = 'Hardware';
+% AO.FTx.Length.DataType = 'Scalar';
+% AO.FTx.Length.SpecialFunction = 'getftlength';
+% AO.FTx.Length.SpecialFunctionSet = 'setftlength';
+% AO.FTx.Length.HWUnits = '32ns samples';
+% AO.FTx.Length.PhysicsUnits = '32ns samples';
+% AO.FTx.Length.HW2PhysicsParams = 1;
+% AO.FTx.Length.Physics2HWParams = 1;
+
+
+%====
+%DCCT
+%====
+AO.DCCT.FamilyName = 'DCCT'; dispobject(AO,AO.DCCT.FamilyName);
+AO.DCCT.MemberOf = {'Diagnostics'};
+AO.DCCT.CommonNames = 'DCCT';
+AO.DCCT.DeviceList = [1 1];
+AO.DCCT.ElementList = [1];
+AO.DCCT.Status = [1];
+
+AO.DCCT.Monitor.Mode = Mode;
+AO.DCCT.Monitor.DataType = 'Scalar';
+AO.DCCT.Monitor.ChannelNames = 'SR11BCM01:CURRENT_MONITOR';
+AO.DCCT.Monitor.Units = 'Hardware';
+AO.DCCT.Monitor.HWUnits = 'milli-ampere';
+AO.DCCT.Monitor.PhysicsUnits = 'ampere';
+AO.DCCT.Monitor.HW2PhysicsParams = 1e-3;
+AO.DCCT.Monitor.Physics2HWParams = 1000;
+
+
+% %==================
+% %Machine Parameters
+% %==================
+% Removed in this version, see pervious version for more info
+
+%======
+%Septum
+%======
+% ifam=ifam+1;
+% AO.Septum.FamilyName = 'Septum'; dispobject(AO,AO.Septum.FamilyName);
+% AO.Septum.MemberOf = {'Injection'};
+% AO.Septum.Status = 1;
+%
+% AO.Septum.CommonNames = 'Septum ';
+% AO.Septum.DeviceList = [3 1];
+% AO.Septum.ElementList = [1];
+%
+% AO.Septum.Monitor.Mode = Mode;
+% AO.Septum.Monitor.DataType = 'Scalar';
+% AO.Septum.Monitor.Units = 'Hardware';
+% AO.Septum.Monitor.HWUnits = 'ampere';
+% AO.Septum.Monitor.PhysicsUnits = 'radian';
+% AO.Septum.Monitor.ChannelNames = 'BTS-B9V:Curr';
+%
+% AO.Septum.Setpoint.Mode = Mode;
+% AO.Septum.Setpoint.DataType = 'Scalar';
+% AO.Septum.Setpoint.Units = 'Hardware';
+% AO.Septum.Setpoint.HWUnits = 'ampere';
+% AO.Septum.Setpoint.PhysicsUnits = 'radian';
+% AO.Septum.Setpoint.ChannelNames = 'BTS-B9V:CurrSetpt';
+% AO.Septum.Setpoint.Range = [0, 2500];
+% AO.Septum.Setpoint.Tolerance = 100.0;
+%
+% AO.Septum.Monitor.HW2PhysicsParams = 1;
+% AO.Septum.Monitor.Physics2HWParams = 1;
+% AO.Septum.Setpoint.HW2PhysicsParams = 1;
+% AO.Septum.Setpoint.Physics2HWParams = 1;
+
+
+%====================
+%Photon Beamline Data
+%====================
+% >> removed >> see previous versions if info needed
+
+%====================
+%BPLD Data
+%====================
+% >> removed >> see previous versions if info needed
+
+
+
+% The operational mode sets the path, filenames, and other important parameters
+% Run setoperationalmode after most of the AO is built so that the Units and Mode fields
+% can be set in setoperationalmode
+fprintf('\n');
+setao(AO);
+setoperationalmode(OperationalMode);
+AO = getao;
+
+
+%%%%%%%%%%%%%%%%
+% DeltaRespMat %
+%%%%%%%%%%%%%%%%
+
+% I remove the physics2hw conversion because the physics2hw is
+% is calibrated yet.
+
+% Set response matrix kick size in hardware units (amps)
+AO.HCM.Setpoint.DeltaRespMat = physics2hw('HCM', 'Setpoint', 2.0e-4, AO.HCM.DeviceList);
+AO.VCM.Setpoint.DeltaRespMat = physics2hw('VCM', 'Setpoint', 1.0e-4, AO.VCM.DeviceList);
+
+%% 'NoEnergyScaling' because I don't want to force a BEND magnet read at this point
+%AO.HCM.Setpoint.DeltaRespMat = mm2amps('HCM', .5, AO.HCM.DeviceList, 'NoEnergyScaling');
+%AO.VCM.Setpoint.DeltaRespMat = mm2amps('VCM', .5, AO.VCM.DeviceList, 'NoEnergyScaling');
+
+
+AO.QFA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFA.FamilyName, 'Setpoint', AO.QFA.Setpoint.DeltaRespMat, AO.QFA.DeviceList);
+AO.QFB.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFB.FamilyName, 'Setpoint', AO.QFB.Setpoint.DeltaRespMat, AO.QFB.DeviceList);
+AO.QDA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QDA.FamilyName, 'Setpoint', AO.QDA.Setpoint.DeltaRespMat, AO.QDA.DeviceList);
+
+
+AO.SFA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFA.FamilyName, 'Setpoint', AO.SFA.Setpoint.DeltaRespMat, AO.SFA.DeviceList);
+AO.SFB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFB.FamilyName, 'Setpoint', AO.SFB.Setpoint.DeltaRespMat, AO.SFB.DeviceList);
+AO.SDA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDA.FamilyName, 'Setpoint', AO.SDA.Setpoint.DeltaRespMat, AO.SDA.DeviceList);
+AO.SDB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDB.FamilyName, 'Setpoint', AO.SDB.Setpoint.DeltaRespMat, AO.SDB.DeviceList);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Get S-positions [meters] %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Using ...ATIndex(:,1) will accomodata for split elements where the first
+% of a group of elements is put in the first column ie, if SFA is split in
+% two then ATIndex will look like [2 3; 11 12; ...] where each row is a
+% magnet and column represents each split.
+global THERING
+AO.BPMx.Position = findspos(THERING, AO.BPMx.AT.ATIndex(:,1))';
+AO.BPMy.Position = findspos(THERING, AO.BPMy.AT.ATIndex(:,1))';
+AO.FTx.Position = findspos(THERING, AO.FTx.AT.ATIndex(:,1))';
+AO.FTy.Position = findspos(THERING, AO.FTy.AT.ATIndex(:,1))';
+AO.FTsum.Position= findspos(THERING, AO.FTsum.AT.ATIndex(:,1))';
+AO.HCM.Position = findspos(THERING, AO.HCM.AT.ATIndex(:,1))';
+AO.VCM.Position = findspos(THERING, AO.VCM.AT.ATIndex(:,1))';
+AO.QFA.Position = findspos(THERING, AO.QFA.AT.ATIndex(:,1))';
+AO.QDA.Position = findspos(THERING, AO.QDA.AT.ATIndex(:,1))';
+AO.QFB.Position = findspos(THERING, AO.QFB.AT.ATIndex(:,1))';
+AO.SFA.Position = findspos(THERING, AO.SFA.AT.ATIndex(:,1))';
+AO.SFB.Position = findspos(THERING, AO.SFB.AT.ATIndex(:,1))';
+AO.SDA.Position = findspos(THERING, AO.SDA.AT.ATIndex(:,1))';
+AO.SDB.Position = findspos(THERING, AO.SDB.AT.ATIndex(:,1))';
+AO.SKQ.Position = findspos(THERING, AO.SKQ.AT.ATIndex(:,1))';
+AO.BEND.Position = findspos(THERING, AO.BEND.AT.ATIndex(:,1))';
+AO.RF.Position = findspos(THERING, AO.RF.AT.ATIndex(:,1))';
+AO.KICK.Position = findspos(THERING, AO.KICK.AT.ATIndex(:,1))';
+AO.DCCT.Position = 0;
+AO.TUNE.Position = 0;
+
+
+% Save AO
+setao(AO);
+
+
+function dispobject(AO,name)
+
+n = length(fieldnames(AO));
+
+if n > 0
+ fprintf(' %10s ',name);
+ if mod(n,5) == 0
+ fprintf('\n');
+ end
end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/aspinit_v5skeleton.m b/machine/ASP/StorageRing/aspinit_v5skeleton.m
index 3815bc57..a47852a5 100644
--- a/machine/ASP/StorageRing/aspinit_v5skeleton.m
+++ b/machine/ASP/StorageRing/aspinit_v5skeleton.m
@@ -1,1335 +1,1335 @@
-function aspinit(OperationalMode)
-% aspinit(OperationalMode)
-%
-% Initialize parameters for ASP control in MATLAB
-%
-%==========================
-% Accelerator Family Fields
-%==========================
-% FamilyName BPMx, HCM, etc
-% CommonNames Shortcut name for each element (optional)
-% DeviceList [Sector, Number]
-% ElementList number in list
-% Position m, magnet center
-%
-% MONITOR FIELDS
-% Mode online/manual/special/simulator
-% ChannelNames PV for monitor
-% Units Physics or HW
-% HW2PhysicsFcn function handle used to convert from hardware to physics units ==> inline will not compile, see below
-% HW2PhysicsParams parameters used for conversion function
-% Physics2HWFcn function handle used to convert from physics to hardware units
-% Physics2HWParams parameters used for conversion function
-% HWUnits units for Hardware 'ampere';
-% PhysicsUnits units for physics 'Rad';
-%
-% SETPOINT FIELDS
-% Mode online/manual/special/simulator
-% ChannelNames PV for monitor
-% Units hardware or physics
-% HW2PhysicsFcn function handle used to convert from hardware to physics units
-% HW2PhysicsParams parameters used for conversion function
-% Physics2HWFcn function handle used to convert from physics to hardware units
-% Physics2HWParams parameters used for conversion function
-% HWUnits units for Hardware 'ampere';
-% PhysicsUnits units for physics 'Rad';
-% Range minsetpoint, maxsetpoint;
-% Tolerance setpoint-monitor
-%
-%=============================================
-% Accelerator Toolbox Simulation Fields
-%=============================================
-% ATType Quad, Sext, etc
-% ATIndex index in THERING
-% ATParameterGroup parameter group
-%
-%============
-% Family List
-%============
-% BPMx BPMy - beam position monitors
-% HCM VCM - corrector magnets wound into sextupoles
-% BEND - gradient dipoles
-% QFA QDA QFB - quadrupole magnets
-% SFA SDA SDB SFB - sextupole magnets
-% SQK - skew quads wound into SDA magnets
-% KICK - injection kickers (DELTA type)
-% RF - 4 cavities (KEK type?)
-% DCCT
-% Septum (Not in model yet)
-%
-% Normal cell: d1 bpm s1 hcor d2 q1 d3 s2 d4 bpm dip bpm d4 hcor s3 d5 q2 d6 q3 d2 bpm s4
-% d2 q3 d6 q2 d5 s3 hcor d4 bpm dip bpm d4 s2 d3 q1 d2 hcor s1 bpm d1
-
-% === Change Log ===
-% Mark Boland 2004-02-12
-% Eugene Tan 2004-02-23
-% Eugene Tan 2004-12-13
-% Eugene Tan 2005-09-27 ver 4
-% Updated naming convention of the process variables, use version 4 of
-% the lattice "assr4.m" where the correctors have been merged into the
-% sextupoles. Made the necessary changes to updateatindex. Added skew
-% quadrupoles and updated generate_init.
-% Mark Boland 2006-05-27
-% Changed the BPM PVs to ...:SA_HPOS_MONITOR and ...:SA_VPOS_MONITOR
-%
-% === Still to do ===
-% - kicker delays
-% - BPM names and other possible PVs of interest eg. Q factor etc.
-% - clean up and configure the amp2k and k2amp conversion. Control system
-% designed to calculate the strengths and amp values using calc records,
-% therefore we should only need to change the PV name to access for
-% readback at setpoints. Only problem will be in simulation/offline mode
-% where those value are not available online. How do you keep the offline
-% conversion factors up to date with online vals?
-%
-% === Generated from ===
-
-% Default operational mode
-if nargin < 1
- OperationalMode = 1;
-end
-
-
-%=============================================
-% START DEFINITION OF ACCELERATOR OBJECTS
-%=============================================
-fprintf(' Defining the Accelerator Objects. Objects being defined:\n')
-
-
-% Clear previous AcceleratorObjects
-setao([]);
-
-
-Mode = 'Online'; % This gets reset in setoperationalmode
-
-%=============================================
-%BPM data: status field designates if BPM in use
-%=============================================
-ntbpm=98;
-AO.BPMx.FamilyName = 'BPMx'; dispobject(AO,AO.BPMx.FamilyName);
-AO.BPMx.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
-AO.BPMx.Monitor.Mode = Mode;
-AO.BPMx.Monitor.DataType = 'Scalar';
-AO.BPMx.Monitor.Units = 'Hardware';
-AO.BPMx.Monitor.HWUnits = 'mm';
-AO.BPMx.Monitor.PhysicsUnits = 'meter';
-
-AO.BPMy.FamilyName = 'BPMy'; dispobject(AO,AO.BPMy.FamilyName);
-AO.BPMy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
-AO.BPMy.Monitor.Mode = Mode;
-AO.BPMy.Monitor.DataType = 'Scalar';
-AO.BPMy.Monitor.Units = 'Hardware';
-AO.BPMy.Monitor.HWUnits = 'mm';
-AO.BPMy.Monitor.PhysicsUnits = 'meter';
-
-% x-name x-chname xstat y-name y-chname ystat DevList Elem
-bpm={
-% INSERT BPM HERE
-};
-
-%Load fields from data block
-for ii=1:size(bpm,1)
-name=bpm{ii,1}; AO.BPMx.CommonNames(ii,:) = name;
-name=bpm{ii,2}; AO.BPMx.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,3}; AO.BPMx.Status(ii,:) = val;
-name=bpm{ii,4}; AO.BPMy.CommonNames(ii,:) = name;
-name=bpm{ii,5}; AO.BPMy.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,6}; AO.BPMy.Status(ii,:) = val;
-val =bpm{ii,7}; AO.BPMx.DeviceList(ii,:) = val;
- AO.BPMy.DeviceList(ii,:) = val;
-val =bpm{ii,8}; AO.BPMx.ElementList(ii,:) = val;
- AO.BPMy.ElementList(ii,:) = val;
- AO.BPMx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.BPMx.Monitor.Physics2HWParams(ii,:) = 1000;
- AO.BPMy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.BPMy.Monitor.Physics2HWParams(ii,:) = 1000;
-end
-
-
-% % Get sum value from button. Don't need handles and PV namelist as
-% % parameters are the same as the 'monitor' subcategory.
-% AO.BPMx.Sum.Monitor = AO.BPMx.Monitor;
-% AO.BPMx.Sum.SpecialFunction = 'getbpmsumspear';
-% AO.BPMx.Sum.HWUnits = 'ADC Counts';
-% AO.BPMx.Sum.PhysicsUnits = 'ADC Counts';
-% AO.BPMx.Sum.HW2PhysicsParams = 1;
-% AO.BPMx.Sum.Physics2HWParams = 1;
-% % Get q value from BPMs. Don't need handles and PV namelist.
-% AO.BPMx.Q = AO.BPMx.Monitor;
-% AO.BPMx.Q.SpecialFunction = 'getbpmqspear';
-% AO.BPMx.Q.HWUnits = 'mm';
-% AO.BPMx.Q.PhysicsUnits = 'meter';
-% AO.BPMx.Q.HW2PhysicsParams = 1e-3;
-% AO.BPMx.Q.Physics2HWParams = 1000;
-%
-% % Definition above for horizontal. Replicate for vertical.
-% AO.BPMy.Sum = AO.BPMx.Sum;
-% AO.BPMy.Q = AO.BPMx.Q;
-
-
-
-%=============================================
-% First Turn BPM data from Libera
-%=============================================
-ntbpm=98;
-AO.FTx.FamilyName = 'FTx'; dispobject(AO,AO.FTx.FamilyName);
-AO.FTx.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
-AO.FTx.Monitor.Mode = Mode;
-AO.FTx.Monitor.DataType = 'Scalar';
-AO.FTx.Monitor.Units = 'Hardware';
-AO.FTx.Monitor.HWUnits = 'mm';
-AO.FTx.Monitor.PhysicsUnits = 'meter';
-
-AO.FTy.FamilyName = 'FTy'; dispobject(AO,AO.FTy.FamilyName);
-AO.FTy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
-AO.FTy.Monitor.Mode = Mode;
-AO.FTy.Monitor.DataType = 'Scalar';
-AO.FTy.Monitor.Units = 'Hardware';
-AO.FTy.Monitor.HWUnits = 'mm';
-AO.FTy.Monitor.PhysicsUnits = 'meter';
-
-% x-name x-chname xstat y-name y-chname ystat DevList Elem
-bpm={
-% INSERT FT HERE
-};
-
-%Load fields from data block
-for ii=1:size(bpm,1)
-name=bpm{ii,1}; AO.FTx.CommonNames(ii,:) = name;
-name=bpm{ii,2}; AO.FTx.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,3}; AO.FTx.Status(ii,:) = val;
-name=bpm{ii,4}; AO.FTy.CommonNames(ii,:) = name;
-name=bpm{ii,5}; AO.FTy.Monitor.ChannelNames(ii,:)= name;
-val =bpm{ii,6}; AO.FTy.Status(ii,:) = val;
-val =bpm{ii,7}; AO.FTx.DeviceList(ii,:) = val;
- AO.FTy.DeviceList(ii,:) = val;
-val =bpm{ii,8}; AO.FTx.ElementList(ii,:) = val;
- AO.FTy.ElementList(ii,:) = val;
- AO.FTx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.FTx.Monitor.Physics2HWParams(ii,:) = 1000;
- AO.FTy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
- AO.FTy.Monitor.Physics2HWParams(ii,:) = 1000;
-end
-AO.FTx.Status = AO.BPMx.Status;
-AO.FTy.Status = AO.BPMy.Status;
-
-% % Get sum value from button. Don't need handles and PV namelist as
-% % parameters are the same as the 'monitor' subcategory.
-AO.FTx.Offset.Mode = 'Special';
-AO.FTx.Offset.Units = 'Hardware';
-AO.FTx.Offset.DataType = 'Scalar';
-AO.FTx.Offset.SpecialFunction = 'getftoffset';
-AO.FTx.Offset.SpecialFunctionSet = 'setftoffset';
-AO.FTx.Offset.HWUnits = '32ns samples';
-AO.FTx.Offset.PhysicsUnits = '32ns samples';
-AO.FTx.Offset.HW2PhysicsParams = 1;
-AO.FTx.Offset.Physics2HWParams = 1;
-
-AO.FTx.Length.Mode = 'Special';
-AO.FTx.Length.Units = 'Hardware';
-AO.FTx.Length.DataType = 'Scalar';
-AO.FTx.Length.SpecialFunction = 'getftlength';
-AO.FTx.Length.SpecialFunctionSet = 'setftlength';
-AO.FTx.Length.HWUnits = '32ns samples';
-AO.FTx.Length.PhysicsUnits = '32ns samples';
-AO.FTx.Length.HW2PhysicsParams = 1;
-AO.FTx.Length.Physics2HWParams = 1;
-
-AO.FTx.Maxadc.Mode = 'Special';
-AO.FTx.Maxadc.Units = 'Hardware';
-AO.FTx.Maxadc.DataType = 'Scalar';
-AO.FTx.Maxadc.SpecialFunction = 'getftmaxadc';
-AO.FTx.Maxadc.HWUnits = 'ADC counts';
-AO.FTx.Maxadc.PhysicsUnits = 'ADC counts';
-AO.FTx.Maxadc.HW2PhysicsParams = 1;
-AO.FTx.Maxadc.Physics2HWParams = 1;
-
-% AO.FTx.Sum.Mode = 'Special';
-% AO.FTx.Sum.Units = 'Hardware';
-% AO.FTx.Sum.DataType = 'Scalar';
-% AO.FTx.Sum.SpecialFunction = 'getftsum';
-% AO.FTx.Sum.HWUnits = 'ADC counts';
-% AO.FTx.Sum.PhysicsUnits = 'ADC counts';
-% AO.FTx.Sum.HW2PhysicsParams = 1;
-% AO.FTx.Sum.Physics2HWParams = 1;
-
-
-AO.FTsum.FamilyName = 'FTsum'; dispobject(AO,AO.FTsum.FamilyName);
-AO.FTsum.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
-AO.FTsum.Monitor.Mode = 'Special';
-AO.FTsum.Monitor.Units = 'Hardware';
-AO.FTsum.Monitor.DataType = 'Scalar';
-AO.FTsum.Monitor.SpecialFunction = 'getftsum';
-AO.FTsum.Monitor.HWUnits = 'ADC counts';
-AO.FTsum.Monitor.PhysicsUnits = 'ADC counts';
-AO.FTsum.Monitor.HW2PhysicsParams = 1;
-AO.FTsum.Monitor.Physics2HWParams = 1;
-
-
-%===========================================================
-% Corrector data: status field designates if corrector in use
-% ASP corrector coils wound into sextupoles. Not dynamic correctors.
-%===========================================================
-
-AO.HCM.FamilyName = 'HCM'; dispobject(AO,AO.HCM.FamilyName);
-AO.HCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'HCM'; 'Magnet'};
-
-AO.HCM.Monitor.Mode = Mode;
-AO.HCM.Monitor.DataType = 'Scalar';
-AO.HCM.Monitor.Units = 'Hardware';
-AO.HCM.Monitor.HWUnits = 'ampere';
-AO.HCM.Monitor.PhysicsUnits = 'radian';
-AO.HCM.Monitor.HW2PhysicsFcn = @amp2k;
-AO.HCM.Monitor.Physics2HWFcn = @k2amp;
-
-AO.HCM.Setpoint.Mode = Mode;
-AO.HCM.Setpoint.DataType = 'Scalar';
-AO.HCM.Setpoint.Units = 'Hardware';
-AO.HCM.Setpoint.HWUnits = 'ampere';
-AO.HCM.Setpoint.PhysicsUnits = 'radian';
-AO.HCM.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.HCM.Setpoint.Physics2HWFcn = @k2amp;
-
-% HW in ampere, Physics in radian. Respmat settings below AO definitions.
-% x-common x-monitor x-setpoint stat devlist elem tol
-cor={
-% INSERT HCM HERE
-};
-
-[C, Leff, MagnetType] = magnetcoefficients('HCM');
-
-for ii=1:size(cor,1)
-name=cor{ii,1}; AO.HCM.CommonNames(ii,:) = name;
-name=cor{ii,2}; AO.HCM.Monitor.ChannelNames(ii,:) = name;
-name=cor{ii,3}; AO.HCM.Setpoint.ChannelNames(ii,:) = name;
-val =cor{ii,4}; AO.HCM.Status(ii,1) = val;
-val =cor{ii,5}; AO.HCM.DeviceList(ii,:) = val;
-val =cor{ii,6}; AO.HCM.ElementList(ii,1) = val;
-val =cor{ii,7}; AO.HCM.Setpoint.Tolerance(ii,1) = val;
-
-AO.HCM.Setpoint.Range(ii,:) = [-90 +90];
-AO.HCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
-AO.HCM.Monitor.Physics2HWParams{1}(ii,:) = C;
-AO.HCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
-AO.HCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
-end
-
-
-AO.VCM.FamilyName = 'VCM'; dispobject(AO,AO.VCM.FamilyName);
-AO.VCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'VCM'; 'Magnet'};
-
-AO.VCM.Monitor.Mode = Mode;
-AO.VCM.Monitor.DataType = 'Scalar';
-AO.VCM.Monitor.Units = 'Hardware';
-AO.VCM.Monitor.HWUnits = 'ampere';
-AO.VCM.Monitor.PhysicsUnits = 'radian';
-AO.VCM.Monitor.HW2PhysicsFcn = @amp2k;
-AO.VCM.Monitor.Physics2HWFcn = @k2amp;
-
-AO.VCM.Setpoint.Mode = Mode;
-AO.VCM.Setpoint.DataType = 'Scalar';
-AO.VCM.Setpoint.Units = 'Hardware';
-AO.VCM.Setpoint.HWUnits = 'ampere';
-AO.VCM.Setpoint.PhysicsUnits = 'radian';
-AO.VCM.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.VCM.Setpoint.Physics2HWFcn = @k2amp;
-
-% HW in ampere, Physics in radian ** radian units converted to ampere below ***
-% y-common y-monitor y-setpoint stat devlist elem
-cor={
-% INSERT VCM HERE
-};
-
-[C, Leff, MagnetType] = magnetcoefficients('VCM');
-
-for ii=1:size(cor,1)
-name=cor{ii,1}; AO.VCM.CommonNames(ii,:) = name;
-name=cor{ii,2}; AO.VCM.Monitor.ChannelNames(ii,:) = name;
-name=cor{ii,3}; AO.VCM.Setpoint.ChannelNames(ii,:) = name;
-val =cor{ii,4}; AO.VCM.Status(ii,1) = val;
-val =cor{ii,5}; AO.VCM.DeviceList(ii,:) = val;
-val =cor{ii,6}; AO.VCM.ElementList(ii,1) = val;
-val =cor{ii,7}; AO.VCM.Setpoint.Tolerance(ii,1) = val;
-
-AO.VCM.Setpoint.Range(ii,:) = [-125 +125];
-AO.VCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
-AO.VCM.Monitor.Physics2HWParams{1}(ii,:) = C;
-AO.VCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
-AO.VCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
-end
-
-
-%=============================
-% MAIN MAGNETS
-%=============================
-
-%===========
-%Dipole data
-%===========
-
-% *** BEND ***
-AO.BEND.FamilyName = 'BEND'; dispobject(AO,AO.BEND.FamilyName);
-AO.BEND.MemberOf = {'PlotFamily'; 'MachineConfig'; 'BEND'; 'Magnet';};
-HW2PhysicsParams = magnetcoefficients('BEND');
-Physics2HWParams = magnetcoefficients('BEND');
-
-AO.BEND.Monitor.Mode = Mode;
-AO.BEND.Monitor.DataType = 'Scalar';
-AO.BEND.Monitor.Units = 'Hardware';
-AO.BEND.Monitor.HW2PhysicsFcn = @bend2gev; % @bend2gev ???
-AO.BEND.Monitor.Physics2HWFcn = @gev2bend;
-AO.BEND.Monitor.HWUnits = 'ampere';
-AO.BEND.Monitor.PhysicsUnits = 'energy';
-
-AO.BEND.Setpoint.Mode = Mode;
-AO.BEND.Setpoint.DataType = 'Scalar';
-AO.BEND.Setpoint.Units = 'Hardware';
-AO.BEND.Setpoint.HW2PhysicsFcn = @bend2gev;
-AO.BEND.Setpoint.Physics2HWFcn = @gev2bend;
-AO.BEND.Setpoint.HWUnits = 'ampere';
-AO.BEND.Setpoint.PhysicsUnits = 'energy';
-
-% common monitor setpoint stat devlist elem scale tol
-bend={
-% INSERT BEND HERE
-};
-
-for ii=1:size(bend,1)
-name=bend{ii,1}; AO.BEND.CommonNames(ii,:) = name;
-name=bend{ii,2}; AO.BEND.Monitor.ChannelNames(ii,:) = name;
-name=bend{ii,3}; AO.BEND.Setpoint.ChannelNames(ii,:) = name;
-val =bend{ii,4}; AO.BEND.Status(ii,1) = val;
-val =bend{ii,5}; AO.BEND.DeviceList(ii,:) = val;
-val =bend{ii,6}; AO.BEND.ElementList(ii,1) = val;
-val =bend{ii,7}; % This is the scale factor
-AO.BEND.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.BEND.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.BEND.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.BEND.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.BEND.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.BEND.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.BEND.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.BEND.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =bend{ii,8}; AO.BEND.Setpoint.Tolerance(ii,1) = val;
-
-AO.BEND.Setpoint.Range(ii,:) = [0 500];
-end
-
-%===============
-%Quadrupole data
-%===============
-
-% *** QFA ***
-AO.QFA.FamilyName = 'QFA'; dispobject(AO,AO.QFA.FamilyName);
-AO.QFA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
-HW2PhysicsParams = magnetcoefficients('QFA');
-Physics2HWParams = magnetcoefficients('QFA');
-
-AO.QFA.Monitor.Mode = Mode;
-AO.QFA.Monitor.DataType = 'Scalar';
-AO.QFA.Monitor.Units = 'Hardware';
-AO.QFA.Monitor.HWUnits = 'ampere';
-AO.QFA.Monitor.PhysicsUnits = 'meter^-2';
-AO.QFA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QFA.Monitor.Physics2HWFcn = @k2amp;
-
-AO.QFA.Setpoint.Mode = Mode;
-AO.QFA.Setpoint.DataType = 'Scalar';
-AO.QFA.Setpoint.Units = 'Hardware';
-AO.QFA.Setpoint.HWUnits = 'ampere';
-AO.QFA.Setpoint.PhysicsUnits = 'meter^-2';
-AO.QFA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QFA.Setpoint.Physics2HWFcn = @k2amp;
-
-% common monitor setpoint stat devlist elem scale tol
-qfa={
-% INSERT QFA HERE
-};
-
-for ii=1:size(qfa,1)
-name=qfa{ii,1}; AO.QFA.CommonNames(ii,:) = name;
-name=qfa{ii,2}; AO.QFA.Monitor.ChannelNames(ii,:) = name;
-name=qfa{ii,3}; AO.QFA.Setpoint.ChannelNames(ii,:) = name;
-val =qfa{ii,4}; AO.QFA.Status(ii,1) = val;
-val =qfa{ii,5}; AO.QFA.DeviceList(ii,:) = val;
-val =qfa{ii,6}; AO.QFA.ElementList(ii,1) = val;
-val =qfa{ii,7}; % This is the scale factor
-AO.QFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qfa{ii,8}; AO.QFA.Setpoint.Tolerance(ii,1) = val;
-
-AO.QFA.Setpoint.Range(ii,:) = [0 180];
-end
-
-
-% *** QDA ***
-AO.QDA.FamilyName = 'QDA'; dispobject(AO,AO.QDA.FamilyName);
-AO.QDA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QD';};
-HW2PhysicsParams = magnetcoefficients('QDA');
-Physics2HWParams = magnetcoefficients('QDA');
-
-AO.QDA.Monitor.Mode = Mode;
-AO.QDA.Monitor.DataType = 'Scalar';
-AO.QDA.Monitor.Units = 'Hardware';
-AO.QDA.Monitor.HWUnits = 'ampere';
-AO.QDA.Monitor.PhysicsUnits = 'meter^-2';
-AO.QDA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QDA.Monitor.Physics2HWFcn = @k2amp;
-
-AO.QDA.Setpoint.Mode = Mode;
-AO.QDA.Setpoint.DataType = 'Scalar';
-AO.QDA.Setpoint.Units = 'Hardware';
-AO.QDA.Setpoint.HWUnits = 'ampere';
-AO.QDA.Setpoint.PhysicsUnits = 'meter^-2';
-AO.QDA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QDA.Setpoint.Physics2HWFcn = @k2amp;
-
-% common monitor setpoint stat devlist elem scale tol
-qda={
-% INSERT QDA HERE
-};
-
-for ii=1:size(qda,1)
-name=qda{ii,1}; AO.QDA.CommonNames(ii,:) = name;
-name=qda{ii,2}; AO.QDA.Monitor.ChannelNames(ii,:) = name;
-name=qda{ii,3}; AO.QDA.Setpoint.ChannelNames(ii,:) = name;
-val =qda{ii,4}; AO.QDA.Status(ii,1) = val;
-val =qda{ii,5}; AO.QDA.DeviceList(ii,:) = val;
-val =qda{ii,6}; AO.QDA.ElementList(ii,1) = val;
-val =qda{ii,7}; % This is the scale factor
-AO.QDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QDA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qda{ii,8}; AO.QDA.Setpoint.Tolerance(ii,1) = val;
-
-AO.QDA.Setpoint.Range(ii,:) = [0 100];
-end
-
-
-
-% *** QFB ***
-AO.QFB.FamilyName = 'QFB'; dispobject(AO,AO.QFB.FamilyName);
-AO.QFB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
-HW2PhysicsParams = magnetcoefficients('QFB');
-Physics2HWParams = magnetcoefficients('QFB');
-
-AO.QFB.Monitor.Mode = Mode;
-AO.QFB.Monitor.DataType = 'Scalar';
-AO.QFB.Monitor.Units = 'Hardware';
-AO.QFB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.QFB.Monitor.Physics2HWFcn = @k2amp;
-AO.QFB.Monitor.HWUnits = 'ampere';
-AO.QFB.Monitor.PhysicsUnits = 'meter^-2';
-
-AO.QFB.Setpoint.Mode = Mode;
-AO.QFB.Setpoint.DataType = 'Scalar';
-AO.QFB.Setpoint.Units = 'Hardware';
-AO.QFB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.QFB.Setpoint.Physics2HWFcn = @k2amp;
-AO.QFB.Setpoint.HWUnits = 'ampere';
-AO.QFB.Setpoint.PhysicsUnits = 'meter^-2';
-
-% common monitor setpoint stat devlist elem scale tol
-qfb={
-% INSERT QFB HERE
-};
-
-for ii=1:size(qfb,1)
-name=qfb{ii,1}; AO.QFB.CommonNames(ii,:) = name;
-name=qfb{ii,2}; AO.QFB.Monitor.ChannelNames(ii,:) = name;
-name=qfb{ii,3}; AO.QFB.Setpoint.ChannelNames(ii,:) = name;
-val =qfb{ii,4}; AO.QFB.Status(ii,1) = val;
-val =qfb{ii,5}; AO.QFB.DeviceList(ii,:) = val;
-val =qfb{ii,6}; AO.QFB.ElementList(ii,1) = val;
-val =qfb{ii,7}; % This is the scale factor
-AO.QFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.QFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.QFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.QFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.QFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =qfb{ii,8}; AO.QFB.Setpoint.Tolerance(ii,1) = val;
-
-AO.QFB.Setpoint.Range(ii,:) = [0 180];
-end
-
-
-%===============
-%Sextupole data
-%===============
-% *** SFA ***
-AO.SFA.FamilyName = 'SFA'; dispobject(AO,AO.SFA.FamilyName);
-AO.SFA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SF'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SFA');
-Physics2HWParams = magnetcoefficients('SFA');
-
-AO.SFA.Monitor.Mode = Mode;
-AO.SFA.Monitor.DataType = 'Scalar';
-AO.SFA.Monitor.Units = 'Hardware';
-AO.SFA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SFA.Monitor.Physics2HWFcn = @k2amp;
-AO.SFA.Monitor.HWUnits = 'ampere';
-AO.SFA.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SFA.Setpoint.Mode = Mode;
-AO.SFA.Setpoint.DataType = 'Scalar';
-AO.SFA.Setpoint.Units = 'Hardware';
-AO.SFA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SFA.Setpoint.Physics2HWFcn = @k2amp;
-AO.SFA.Setpoint.HWUnits = 'ampere';
-AO.SFA.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sfa={
-% INSERT SFA HERE
-};
-
-for ii=1:size(sfa,1)
-name=sfa{ii,1}; AO.SFA.CommonNames(ii,:) = name;
-name=sfa{ii,2}; AO.SFA.Monitor.ChannelNames(ii,:) = name;
-name=sfa{ii,3}; AO.SFA.Setpoint.ChannelNames(ii,:) = name;
-val =sfa{ii,4}; AO.SFA.Status(ii,1) = val;
-val =sfa{ii,5}; AO.SFA.DeviceList(ii,:) = val;
-val =sfa{ii,6}; AO.SFA.ElementList(ii,1) = val;
-val =sfa{ii,7}; % This is the scale factor
-AO.SFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sfa{ii,8}; AO.SFA.Setpoint.Tolerance(ii,1) = val;
-
-AO.SFA.Setpoint.Range(ii,:) = [0 140];
-end
-
-
-
-% *** SDA ***
-AO.SDA.FamilyName = 'SDA'; dispobject(AO,AO.SDA.FamilyName);
-AO.SDA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SD'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SDA');
-Physics2HWParams = magnetcoefficients('SDA');
-
-AO.SDA.Monitor.Mode = Mode;
-AO.SDA.Monitor.DataType = 'Scalar';
-AO.SDA.Monitor.Units = 'Hardware';
-AO.SDA.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SDA.Monitor.Physics2HWFcn = @k2amp;
-AO.SDA.Monitor.HWUnits = 'ampere';
-AO.SDA.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SDA.Setpoint.Mode = Mode;
-AO.SDA.Setpoint.DataType = 'Scalar';
-AO.SDA.Setpoint.Units = 'Hardware';
-AO.SDA.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SDA.Setpoint.Physics2HWFcn = @k2amp;
-AO.SDA.Setpoint.HWUnits = 'ampere';
-AO.SDA.Setpoint.PhysicsUnits = 'meter^-3';
-
-
-% common monitor setpoint stat devlist elem scale tol
-sda={
-% INSERT SDA HERE
-};
-
-for ii=1:size(sda,1)
-name=sda{ii,1}; AO.SDA.CommonNames(ii,:) = name;
-name=sda{ii,2}; AO.SDA.Monitor.ChannelNames(ii,:) = name;
-name=sda{ii,3}; AO.SDA.Setpoint.ChannelNames(ii,:) = name;
-val =sda{ii,4}; AO.SDA.Status(ii,1) = val;
-val =sda{ii,5}; AO.SDA.DeviceList(ii,:) = val;
-val =sda{ii,6}; AO.SDA.ElementList(ii,1) = val;
-val =sda{ii,7}; % This is the scale factor
-AO.SDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDA.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sda{ii,8}; AO.SDA.Setpoint.Tolerance(ii,1) = val;
-
-AO.SDA.Setpoint.Range(ii,:) = [0 140];
-end
-
-
-% *** SDB ***
-AO.SDB.FamilyName = 'SDB'; dispobject(AO,AO.SDB.FamilyName);
-AO.SDB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SD'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SDB');
-Physics2HWParams = magnetcoefficients('SDB');
-
-AO.SDB.Monitor.Mode = Mode;
-AO.SDB.Monitor.DataType = 'Scalar';
-AO.SDB.Monitor.Units = 'Hardware';
-AO.SDB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SDB.Monitor.Physics2HWFcn = @k2amp;
-AO.SDB.Monitor.HWUnits = 'ampere';
-AO.SDB.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SDB.Setpoint.Mode = Mode;
-AO.SDB.Setpoint.DataType = 'Scalar';
-AO.SDB.Setpoint.Units = 'Hardware';
-AO.SDB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SDB.Setpoint.Physics2HWFcn = @k2amp;
-AO.SDB.Setpoint.HWUnits = 'ampere';
-AO.SDB.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sdb={
-% INSERT SDB HERE
-};
-
-for ii=1:size(sdb,1)
-name=sdb{ii,1}; AO.SDB.CommonNames(ii,:) = name;
-name=sdb{ii,2}; AO.SDB.Monitor.ChannelNames(ii,:) = name;
-name=sdb{ii,3}; AO.SDB.Setpoint.ChannelNames(ii,:)= name;
-val =sdb{ii,4}; AO.SDB.Status(ii,1) = val;
-val =sdb{ii,5}; AO.SDB.DeviceList(ii,:) = val;
-val =sdb{ii,6}; AO.SDB.ElementList(ii,1) = val;
-val =sdb{ii,7}; % This is the scale factor
-AO.SDB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SDB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SDB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SDB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SDB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sdb{ii,8}; AO.SDB.Setpoint.Tolerance(ii,1) = val;
-
-AO.SDB.Setpoint.Range(ii,:) = [0 140];
-end
-
-
-
-% *** SFB ***
-AO.SFB.FamilyName = 'SFB'; dispobject(AO,AO.SFB.FamilyName);
-AO.SFB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SF'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
-HW2PhysicsParams = magnetcoefficients('SFB');
-Physics2HWParams = magnetcoefficients('SFB');
-
-AO.SFB.Monitor.Mode = Mode;
-AO.SFB.Monitor.DataType = 'Scalar';
-AO.SFB.Monitor.Units = 'Hardware';
-AO.SFB.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SFB.Monitor.Physics2HWFcn = @k2amp;
-AO.SFB.Monitor.HWUnits = 'ampere';
-AO.SFB.Monitor.PhysicsUnits = 'meter^-3';
-
-AO.SFB.Setpoint.Mode = Mode;
-AO.SFB.Setpoint.DataType = 'Scalar';
-AO.SFB.Setpoint.Units = 'Hardware';
-AO.SFB.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SFB.Setpoint.Physics2HWFcn = @k2amp;
-AO.SFB.Setpoint.HWUnits = 'ampere';
-AO.SFB.Setpoint.PhysicsUnits = 'meter^-3';
-
-% common monitor setpoint stat devlist elem scale tol
-sfb={
-% INSERT SFB HERE
-};
-
-for ii=1:size(sfb,1)
-name=sfb{ii,1}; AO.SFB.CommonNames(ii,:) = name;
-name=sfb{ii,2}; AO.SFB.Monitor.ChannelNames(ii,:) = name;
-name=sfb{ii,3}; AO.SFB.Setpoint.ChannelNames(ii,:)= name;
-val =sfb{ii,4}; AO.SFB.Status(ii,1) = val;
-val =sfb{ii,5}; AO.SFB.DeviceList(ii,:) = val;
-val =sfb{ii,6}; AO.SFB.ElementLsist(ii,1) = val;
-val =sfb{ii,7}; % This is the scale factor
-AO.SFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
-AO.SFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
-AO.SFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFB.Monitor.Physics2HWParams{2}(ii,:) = val;
-AO.SFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
-AO.SFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
-val =sfb{ii,8}; AO.SFB.Setpoint.Tolerance(ii,1) = val;
-
-AO.SFB.Setpoint.Range(ii,:) = val;
-end
-
-%===============
-%Skew Quad data
-%===============
-% *** Skew quadrupoles *** 2005/09/27 Eugene
-AO.SKQ.FamilyName = 'SKQ'; dispobject(AO,AO.SKQ.FamilyName);
-AO.SKQ.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SkewQuad'; 'Magnet';};
-HW2PhysicsParams = magnetcoefficients('SKQ');
-Physics2HWParams = magnetcoefficients('SKQ');
-
-AO.SKQ.Monitor.Mode = Mode;
-AO.SKQ.Monitor.DataType = 'Scalar';
-AO.SKQ.Monitor.Units = 'Hardware';
-AO.SKQ.Monitor.HW2PhysicsFcn = @amp2k;
-AO.SKQ.Monitor.Physics2HWFcn = @k2amp;
-AO.SKQ.Monitor.HWUnits = 'ampere';
-AO.SKQ.Monitor.PhysicsUnits = 'meter^-2';
-
-AO.SKQ.Setpoint.Mode = Mode;
-AO.SKQ.Setpoint.DataType = 'Scalar';
-AO.SKQ.Setpoint.Units = 'Hardware';
-AO.SKQ.Setpoint.HW2PhysicsFcn = @amp2k;
-AO.SKQ.Setpoint.Physics2HWFcn = @k2amp;
-AO.SKQ.Setpoint.HWUnits = 'ampere';
-AO.SKQ.Setpoint.PhysicsUnits = 'meter^-2';
-
-% common monitor setpoint stat devlist elem scale tol
-sq={
-% INSERT SKQ HERE
-};
-
-for ii=1:size(sq,1)
-name=sq{ii,1}; AO.SKQ.CommonNames(ii,:) = name;
-name=sq{ii,2}; AO.SKQ.Monitor.ChannelNames(ii,:) = name;
-name=sq{ii,3}; AO.SKQ.Setpoint.ChannelNames(ii,:) = name;
-val =sq{ii,4}; AO.SKQ.Status(ii,1) = val;
-val =sq{ii,5}; AO.SKQ.DeviceList(ii,:) = val;
-val =sq{ii,6}; AO.SKQ.ElementList(ii,1) = val;
-val =sq{ii,7}; AO.SKQ.Setpoint.Tolerance(ii,1) = val;
-AO.SKQ.Monitor.HW2PhysicsParams(ii,:) = HW2PhysicsParams;
-AO.SKQ.Setpoint.HW2PhysicsParams(ii,:) = HW2PhysicsParams;
-AO.SKQ.Monitor.Physics2HWParams(ii,:) = Physics2HWParams;
-AO.SKQ.Setpoint.Physics2HWParams(ii,:) = Physics2HWParams;
-
-AO.SKQ.Setpoint.Range(ii,:) = [-5 +5];
-end
-
-
-%===============
-%Kicker data
-%===============
-AO.KICK.FamilyName = 'KICK'; dispobject(AO,AO.KICK.FamilyName);
-AO.KICK.MemberOf = {'Injection','MachineConfig'};
-
-AO.KICK.Monitor.Mode = Mode;
-AO.KICK.Monitor.DataType = 'Scalar';
-AO.KICK.Monitor.Units = 'Hardware';
-AO.KICK.Monitor.HWUnits = 'kVolts';
-AO.KICK.Monitor.PhysicsUnits = 'mradian';
-
-AO.KICK.Setpoint.Mode = Mode;
-AO.KICK.Setpoint.DataType = 'Scalar';
-AO.KICK.Setpoint.Units = 'Hardware';
-AO.KICK.Setpoint.HWUnits = 'kVolts';
-AO.KICK.Setpoint.PhysicsUnits = 'mradian';
-
-hw2physics_conversionfactor = 1;
-
-%common monitor setpoint stat devlist elem tol
-kickeramp={
-% INSERT KICKERS HERE
-};
-
-for ii=1:size(kickeramp,1)
-name=kickeramp{ii,1}; AO.KICK.CommonNames(ii,:) = name;
-name=kickeramp{ii,2}; AO.KICK.Monitor.ChannelNames(ii,:) = name;
-name=kickeramp{ii,3}; AO.KICK.Setpoint.ChannelNames(ii,:)= name;
-val =kickeramp{ii,4}; AO.KICK.Status(ii,1) = val;
-val =kickeramp{ii,5}; AO.KICK.DeviceList(ii,:) = val;
-val =kickeramp{ii,6}; AO.KICK.ElementList(ii,1) = val;
-val =kickeramp{ii,7}; AO.KICK.Setpoint.Tolerance(ii,1) = val;
-
-AO.KICK.Setpoint.Range(ii,:) = [0 3];
-
-if ii==1||ii==4
- AO.KICK.Monitor.HW2PhysicsParams = -hw2physics_conversionfactor;
- AO.KICK.Monitor.Physics2HWParams = -1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.HW2PhysicsParams = -hw2physics_conversionfactor;
- AO.KICK.Setpoint.Physics2HWParams = -1/hw2physics_conversionfactor;
-else
- AO.KICK.Monitor.HW2PhysicsParams = hw2physics_conversionfactor;
- AO.KICK.Monitor.Physics2HWParams = 1/hw2physics_conversionfactor;
- AO.KICK.Setpoint.HW2PhysicsParams = hw2physics_conversionfactor;
- AO.KICK.Setpoint.Physics2HWParams = 1/hw2physics_conversionfactor;
-end
-end
-
-% *** KICK Delay ***
-% AO.KICK.Delay
-% >> removed >> see previous versions if info needed
-
-
-%============
-%RF System
-%============
-AO.RF.FamilyName = 'RF'; dispobject(AO,AO.RF.FamilyName);
-AO.RF.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
-
-if OperationalMode == 3
-%-------------------------------- 4 cavity Case
-%common stat devlist elem
-rfcommon={
-'RF1 ' 1 [6,1] 1 ; ...
-'RF2 ' 1 [6,2] 2 ; ...
-'RF3 ' 1 [7,1] 3 ; ...
-'RF4 ' 1 [7,2] 4 ; ...
- };
-
-%FreqMon FreqSetpoint HW2PhysicsParams Physics2HWParams Range Tolerance
-rffreq={
-'ASP:RFFreq1 ' 'ASP:RFFreqSetpt1' 1e+6 1e-6 [0 2500] 100.0; ...
-'ASP:RFFreq2 ' 'ASP:RFFreqSetpt2' 1e+6 1e-6 [0 2500] 100.0; ...
-'ASP:RFFreq3 ' 'ASP:RFFreqSetpt3' 1e+6 1e-6 [0 2500] 100.0; ...
-'ASP:RFFreq4 ' 'ASP:RFFreqSetpt4' 1e+6 1e-6 [0 2500] 100.0; ...
- };
-
-% PhaseCtrl PhaseMon HW2PhysicsParams Physics2HWParams Range Tolerance
-rfphase={
-'SRF1:STN:PHASE' 'SRF1:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
-'SRF2:STN:PHASE' 'SRF2:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
-'SRF3:STN:PHASE' 'SRF3:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
-'SRF4:STN:PHASE' 'SRF4:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
- };
-
-% VoltCtrl VoltMon HW2PhysicsParams Physics2HWParams Range Tolerance
-rfvolt={
-'SRF1:STN:VOLT:CTRL ' 'SRF1:STN:VOLT' 1 1 [-inf inf] inf ; ...
-'SRF2:STN:VOLT:CTRL ' 'SRF2:STN:VOLT' 1 1 [-inf inf] inf ; ...
-'SRF3:STN:VOLT:CTRL ' 'SRF3:STN:VOLT' 1 1 [-inf inf] inf ; ...
-'SRF4:STN:VOLT:CTRL ' 'SRF4:STN:VOLT' 1 1 [-inf inf] inf ; ...
- };
-% PowerCtrl PowerMon Klystronpower HW2PhysicsParams Physics2HWParams Range Tolerance
-rfpower={
-'SRF1:KLYSDRIVFRWD:POWER:ON ' 'SRF1:KLYSDRIVFRWD:POWER' 'SRF1:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-'SRF2:KLYSDRIVFRWD:POWER:ON ' 'SRF2:KLYSDRIVFRWD:POWER' 'SRF2:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-'SRF3:KLYSDRIVFRWD:POWER:ON ' 'SRF3:KLYSDRIVFRWD:POWER' 'SRF3:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
-'SRF4:KLYSDRIVFRWD:POWER:ON ' 'SRF4:KLYSDRIVFRWD:POWER' 'SRF4:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
- };
-
-for ii=1:size(rfcommon,1)
-name=rfcommon{ii,1}; AO.RF.CommonNames(ii,:) = name;
-val =rfcommon{ii,2}; AO.RF.Status(ii,1) = val;
-val =rfcommon{ii,3}; AO.RF.DeviceList(ii,:) = val;
-val =rfcommon{ii,4}; AO.RF.ElementList(ii,1) = val;
-end
-
-for ii=1:size(rffreq,1)
-name=rffreq{ii,1}; AO.RF.Monitor.ChannelNames(ii,:) = name;
-name=rffreq{ii,2}; AO.RF.Setpoint.ChannelNames(ii,:) = name;
-val =rffreq{ii,3}; AO.RF.Monitor.HW2PhysicsParams(ii,1) = val;
- AO.RF.Setpoint.HW2PhysicsParams(ii,1) = val;
-val =rffreq{ii,4}; AO.RF.Monitor.Physics2HWParams(ii,1) = val;
- AO.RF.Setpoint.Physics2HWParams(ii,1) = val;
-val =rffreq{ii,5}; AO.RF.Setpoint.Range(ii,:) = val;
-val =rffreq{ii,6}; AO.RF.Setpoint.Tolerance(ii,1) = val;
-end
-
-
-for ii=1:size(rfphase,1)
-name=rfphase{ii,1}; AO.RF.PhaseCtrl.ChannelNames(ii,:) = name;
-name=rfphase{ii,2}; AO.RF.Phase.ChannelNames(ii,:) = name;
-val =rfphase{ii,3}; AO.RF.PhaseCtrl.HW2PhysicsParams(ii,1) = val;
- AO.RF.Phase.HW2PhysicsParams(ii,1) = val;
-val =rfphase{ii,4}; AO.RF.PhaseCtrl.Physics2HWParams(ii,1) = val;
- AO.RF.Phase.Physics2HWParams(ii,1) = val;
-val =rfphase{ii,5}; AO.RF.PhaseCtrl.Range(ii,:) = val;
- AO.RF.Phase.Range(ii,:) = val;
-val =rfphase{ii,6}; AO.RF.PhaseCtrl.Tolerance(ii,1) = val;
- AO.RF.Phase.Tolerance(ii,1) = val;
-end
-
-
-for ii=1:size(rfvolt,1)
-name=rfvolt{ii,1}; AO.RF.VoltageCtrl.ChannelNames(ii,:) = name;
-name=rfvolt{ii,2}; AO.RF.Voltage.ChannelNames(ii,:) = name;
-val =rfvolt{ii,3}; AO.RF.VoltageCtrl.HW2PhysicsParams(ii,1) = val;
- AO.RF.Voltage.HW2PhysicsParams(ii,1) = val;
-val =rfvolt{ii,4}; AO.RF.VoltageCtrl.Physics2HWParams(ii,1) = val;
- AO.RF.Voltage.Physics2HWParams(ii,1) = val;
-val =rfvolt{ii,5}; AO.RF.VoltageCtrl.Range(ii,:) = val;
- AO.RF.Voltage.Range(ii,:) = val;
-val =rfvolt{ii,6}; AO.RF.VoltageCtrl.Tolerance(ii,1) = val;
- AO.RF.Voltage.Tolerance(ii,1) = val;
-end
-
-
-for ii=1:size(rfpower,1)
-name=rfpower{ii,1}; AO.RF.PowerCtrl.ChannelNames(ii,:) = name;
-name=rfpower{ii,2}; AO.RF.Power.ChannelNames(ii,:) = name;
-name=rfpower{ii,3}; AO.RF.KlysPower.ChannelNames(ii,:) = name;
-val =rfpower{ii,4}; AO.RF.PowerCtrl.HW2PhysicsParams(ii,1) = val;
- AO.RF.Power.HW2PhysicsParams(ii,1) = val;
- AO.RF.KlysPower.HW2PhysicsParams(ii,1) = val;
-val =rfpower{ii,5}; AO.RF.PowerCtrl.Physics2HWParams(ii,1) = val;
- AO.RF.Power.Physics2HWParams(ii,1) = val;
- AO.RF.KlysPower.Physics2HWParams(ii,1) = val;
-val =rfpower{ii,6}; AO.RF.PowerCtrl.Range(ii,:) = val;
- AO.RF.Power.Range(ii,:) = val;
- AO.RF.KlysPower.Range(ii,:) = val;
-val =rfpower{ii,7}; AO.RF.PowerCtrl.Tolerance(ii,1) = val;
- AO.RF.Power.Tolerance(ii,1) = val;
- AO.RF.KlysPower.Tolerance(ii,1) = val;
-end
-
-%Frequency Readback
-AO.RF.Monitor.Mode = Mode;
-AO.RF.Monitor.DataType = 'Scalar';
-AO.RF.Monitor.Units = 'Hardware';
-AO.RF.Monitor.HWUnits = 'MHz';
-AO.RF.Monitor.PhysicsUnits = 'Hz';
-%Frequency Setpoint
-AO.RF.Setpoint.Mode = Mode;
-AO.RF.Setpoint.DataType = 'Scalar';
-AO.RF.Setpoint.Units = 'Hardware';
-AO.RF.Setpoint.HWUnits = 'MHz';
-AO.RF.Setpoint.PhysicsUnits = 'Hz';
-
-%Voltage control
-AO.RF.VoltageCtrl.Mode = Mode;
-AO.RF.VoltageCtrl.DataType = 'Scalar';
-AO.RF.VoltageCtrl.Units = 'Hardware';
-AO.RF.VoltageCtrl.HWUnits = 'Volts';
-AO.RF.VoltageCtrl.PhysicsUnits = 'Volts';
-
-%Voltage monitor
-AO.RF.Voltage.Mode = Mode;
-AO.RF.Voltage.DataType = 'Scalar';
-AO.RF.Voltage.Units = 'Hardware';
-AO.RF.Voltage.HWUnits = 'Volts';
-AO.RF.Voltage.PhysicsUnits = 'Volts';
-
-%Power Control
-AO.RF.PowerCtrl.Mode = Mode;
-AO.RF.PowerCtrl.DataType = 'Scalar';
-AO.RF.PowerCtrl.Units = 'Hardware';
-AO.RF.PowerCtrl.HWUnits = 'MWatts';
-AO.RF.PowerCtrl.PhysicsUnits = 'MWatts';
-
-%Power Monitor
-AO.RF.Power.Mode = Mode;
-AO.RF.Power.DataType = 'Scalar';
-AO.RF.Power.Units = 'Hardware';
-AO.RF.Power.HWUnits = 'MWatts';
-AO.RF.Power.PhysicsUnits = 'MWatts';
-
-%Klystron Forward Power
-AO.RF.KlysPower.Mode = Mode;
-AO.RF.KlysPower.DataType = 'Scalar';
-AO.RF.KlysPower.Units = 'Hardware';
-AO.RF.KlysPower.HWUnits = 'MWatts';
-AO.RF.KlysPower.PhysicsUnits = 'MWatts';
-
-%Station Phase Control
-AO.RF.PhaseCtrl.Mode = Mode;
-AO.RF.PhaseCtrl.DataType = 'Scalar';
-AO.RF.PhaseCtrl.Units = 'Hardware';
-AO.RF.PhaseCtrl.HWUnits = 'Degrees';
-AO.RF.PhaseCtrl.PhysicsUnits = 'Degrees';
-
-
-%Station Phase Monitor
-AO.RF.Phase.Mode = Mode;
-AO.RF.Phase.DataType = 'Scalar';
-AO.RF.Phase.Units = 'Hardware';
-AO.RF.Phase.HWUnits = 'Degrees';
-AO.RF.Phase.PhysicsUnits = 'Degrees';
-
-
-else
-%------------------------------------- 1 Cavity Case
-AO.RF.Status = 1;
-AO.RF.CommonNames = 'RF';
-AO.RF.DeviceList = [1 1];
-AO.RF.ElementList = [1];
-
-%Frequency Readback
-AO.RF.Monitor.Mode = Mode;
-AO.RF.Monitor.DataType = 'Scalar';
-AO.RF.Monitor.Units = 'Hardware';
-AO.RF.Monitor.HW2PhysicsParams = 1e+6; %no hw2physics function necessary
-AO.RF.Monitor.Physics2HWParams = 1e-6;
-AO.RF.Monitor.HWUnits = 'MHz';
-AO.RF.Monitor.PhysicsUnits = 'Hz';
-AO.RF.Monitor.ChannelNames = 'ASP:RFFreqSetpt';
-
-%Frequency Setpoint
-AO.RF.Setpoint.Mode = Mode;
-AO.RF.Setpoint.DataType = 'Scalar';
-AO.RF.Setpoint.Units = 'Hardware';
-AO.RF.Setpoint.HW2PhysicsParams = 1e+6;
-AO.RF.Setpoint.Physics2HWParams = 1e-6;
-AO.RF.Setpoint.HWUnits = 'MHz';
-AO.RF.Setpoint.PhysicsUnits = 'Hz';
-AO.RF.Setpoint.ChannelNames = 'ASP:RFFreqSetpt';
-AO.RF.Setpoint.Range = [0 2500];
-AO.RF.Setpoint.Tolerance = 100.0;
-
-%Voltage control
-AO.RF.VoltageCtrl.Mode = Mode;
-AO.RF.VoltageCtrl.DataType = 'Scalar';
-AO.RF.VoltageCtrl.Units = 'Hardware';
-AO.RF.VoltageCtrl.HW2PhysicsParams = 1;
-AO.RF.VoltageCtrl.Physics2HWParams = 1;
-AO.RF.VoltageCtrl.HWUnits = 'Volts';
-AO.RF.VoltageCtrl.PhysicsUnits = 'Volts';
-AO.RF.VoltageCtrl.ChannelNames = 'SRF1:STN:VOLT:CTRL';
-AO.RF.VoltageCtrl.Range = [-inf inf];
-AO.RF.VoltageCtrl.Tolerance = inf;
-
-%Voltage monitor
-AO.RF.Voltage.Mode = Mode;
-AO.RF.Voltage.DataType = 'Scalar';
-AO.RF.Voltage.Units = 'Hardware';
-AO.RF.Voltage.HW2PhysicsParams = 1;
-AO.RF.Voltage.Physics2HWParams = 1;
-AO.RF.Voltage.HWUnits = 'Volts';
-AO.RF.Voltage.PhysicsUnits = 'Volts';
-AO.RF.Voltage.ChannelNames = 'SRF1:STN:VOLT';
-AO.RF.Voltage.Range = [-inf inf];
-AO.RF.Voltage.Tolerance = inf;
-
-%Power Control
-AO.RF.PowerCtrl.Mode = Mode;
-AO.RF.PowerCtrl.DataType = 'Scalar';
-AO.RF.PowerCtrl.Units = 'Hardware';
-AO.RF.PowerCtrl.HW2PhysicsParams = 1;
-AO.RF.PowerCtrl.Physics2HWParams = 1;
-AO.RF.PowerCtrl.HWUnits = 'MWatts';
-AO.RF.PowerCtrl.PhysicsUnits = 'MWatts';
-AO.RF.PowerCtrl.ChannelNames = 'SRF1:KLYSDRIVFRWD:POWER:ON';
-AO.RF.PowerCtrl.Range = [-inf inf];
-AO.RF.PowerCtrl.Tolerance = inf;
-
-%Power Monitor
-AO.RF.Power.Mode = Mode;
-AO.RF.Power.DataType = 'Scalar';
-AO.RF.Power.Units = 'Hardware';
-AO.RF.Power.HW2PhysicsParams = 1;
-AO.RF.Power.Physics2HWParams = 1;
-AO.RF.Power.HWUnits = 'MWatts';
-AO.RF.Power.PhysicsUnits = 'MWatts';
-AO.RF.Power.ChannelNames = 'SRF1:KLYSDRIVFRWD:POWER';
-AO.RF.Power.Range = [-inf inf];
-AO.RF.Power.Tolerance = inf;
-
-%Klystron Forward Power
-AO.RF.KlysPower.Mode = Mode;
-AO.RF.KlysPower.DataType = 'Scalar';
-AO.RF.KlysPower.Units = 'Hardware';
-AO.RF.KlysPower.HW2PhysicsParams = 1;
-AO.RF.KlysPower.Physics2HWParams = 1;
-AO.RF.KlysPower.HWUnits = 'MWatts';
-AO.RF.KlysPower.PhysicsUnits = 'MWatts';
-AO.RF.KlysPower.ChannelNames = 'SRF1:KLYSOUTFRWD:POWER';
-AO.RF.KlysPower.Range = [-inf inf];
-AO.RF.KlysPower.Tolerance = inf;
-
-
-%Station Phase Control
-AO.RF.PhaseCtrl.Mode = Mode;
-AO.RF.PhaseCtrl.DataType = 'Scalar';
-AO.RF.PhaseCtrl.Units = 'Hardware';
-AO.RF.PhaseCtrl.HW2PhysicsParams = 1;
-AO.RF.PhaseCtrl.Physics2HWParams = 1;
-AO.RF.PhaseCtrl.HWUnits = 'Degrees';
-AO.RF.PhaseCtrl.PhysicsUnits = 'Degrees';
-AO.RF.PhaseCtrl.ChannelNames = 'SRF1:STN:PHASE';
-AO.RF.PhaseCtrl.Range = [-200 200];
-AO.RF.PhaseCtrl.Tolerance = inf;
-
-%Station Phase Monitor
-AO.RF.Phase.Mode = Mode;
-AO.RF.Phase.DataType = 'Scalar';
-AO.RF.Phase.Units = 'Hardware';
-AO.RF.Phase.HW2PhysicsParams = 1;
-AO.RF.Phase.Physics2HWParams = 1;
-AO.RF.Phase.HWUnits = 'Degrees';
-AO.RF.Phase.PhysicsUnits = 'Degrees';
-AO.RF.Phase.ChannelNames = 'SRF1:STN:PHASE:CALC';
-AO.RF.Phase.Range = [-200 200];
-AO.RF.Phase.Tolerance = inf;
-end
-
-
-
-%====
-%TUNE
-%====
-AO.TUNE.FamilyName = 'TUNE'; dispobject(AO,AO.TUNE.FamilyName);
-AO.TUNE.MemberOf = {'Tune'; 'Diagnostics'};
-AO.TUNE.CommonNames = ['xtune';'ytune';'stune'];
-AO.TUNE.DeviceList = [ 1 1; 1 2; 1 3];
-AO.TUNE.ElementList = [1 2 3]';
-AO.TUNE.Status = [1 1 0]';
-
-AO.TUNE.Monitor.Mode = Mode;
-AO.TUNE.Monitor.DataType = 'Vector';
-AO.TUNE.Monitor.DataTypeIndex = [1 2 3]';
-AO.TUNE.Monitor.ChannelNames = 'MeasTune';
-AO.TUNE.Monitor.Units = 'Hardware';
-AO.TUNE.Monitor.HW2PhysicsParams = 1;
-AO.TUNE.Monitor.Physics2HWParams = 1;
-AO.TUNE.Monitor.HWUnits = 'fractional tune';
-AO.TUNE.Monitor.PhysicsUnits = 'fractional tune';
-
-
-%====
-%DCCT
-%====
-AO.DCCT.FamilyName = 'DCCT'; dispobject(AO,AO.DCCT.FamilyName);
-AO.DCCT.MemberOf = {'Diagnostics'};
-AO.DCCT.CommonNames = 'DCCT';
-AO.DCCT.DeviceList = [1 1];
-AO.DCCT.ElementList = [1];
-AO.DCCT.Status = [1];
-
-AO.DCCT.Monitor.Mode = Mode;
-AO.DCCT.Monitor.DataType = 'Scalar';
-AO.DCCT.Monitor.ChannelNames = 'SR11BCM01:CURRENT_MONITOR';
-AO.DCCT.Monitor.Units = 'Hardware';
-AO.DCCT.Monitor.HWUnits = 'milli-ampere';
-AO.DCCT.Monitor.PhysicsUnits = 'ampere';
-AO.DCCT.Monitor.HW2PhysicsParams = 1e-3;
-AO.DCCT.Monitor.Physics2HWParams = 1000;
-
-
-% %==================
-% %Machine Parameters
-% %==================
-% Removed in this version, see pervious version for more info
-
-%======
-%Septum
-%======
-% ifam=ifam+1;
-% AO.Septum.FamilyName = 'Septum'; dispobject(AO,AO.Septum.FamilyName);
-% AO.Septum.MemberOf = {'Injection'};
-% AO.Septum.Status = 1;
-%
-% AO.Septum.CommonNames = 'Septum ';
-% AO.Septum.DeviceList = [3 1];
-% AO.Septum.ElementList = [1];
-%
-% AO.Septum.Monitor.Mode = Mode;
-% AO.Septum.Monitor.DataType = 'Scalar';
-% AO.Septum.Monitor.Units = 'Hardware';
-% AO.Septum.Monitor.HWUnits = 'ampere';
-% AO.Septum.Monitor.PhysicsUnits = 'radian';
-% AO.Septum.Monitor.ChannelNames = 'BTS-B9V:Curr';
-%
-% AO.Septum.Setpoint.Mode = Mode;
-% AO.Septum.Setpoint.DataType = 'Scalar';
-% AO.Septum.Setpoint.Units = 'Hardware';
-% AO.Septum.Setpoint.HWUnits = 'ampere';
-% AO.Septum.Setpoint.PhysicsUnits = 'radian';
-% AO.Septum.Setpoint.ChannelNames = 'BTS-B9V:CurrSetpt';
-% AO.Septum.Setpoint.Range = [0, 2500];
-% AO.Septum.Setpoint.Tolerance = 100.0;
-%
-% AO.Septum.Monitor.HW2PhysicsParams = 1;
-% AO.Septum.Monitor.Physics2HWParams = 1;
-% AO.Septum.Setpoint.HW2PhysicsParams = 1;
-% AO.Septum.Setpoint.Physics2HWParams = 1;
-
-
-%====================
-%Photon Beamline Data
-%====================
-% >> removed >> see previous versions if info needed
-
-%====================
-%BPLD Data
-%====================
-% >> removed >> see previous versions if info needed
-
-
-
-% The operational mode sets the path, filenames, and other important parameters
-% Run setoperationalmode after most of the AO is built so that the Units and Mode fields
-% can be set in setoperationalmode
-fprintf('\n');
-setao(AO);
-setoperationalmode(OperationalMode);
-AO = getao;
-
-
-%%%%%%%%%%%%%%%%
-% DeltaRespMat %
-%%%%%%%%%%%%%%%%
-
-% I remove the physics2hw conversion because the physics2hw is
-% is calibrated yet.
-
-% Set response matrix kick size in hardware units (amps)
-AO.HCM.Setpoint.DeltaRespMat = physics2hw('HCM', 'Setpoint', .15e-3 / 3, AO.HCM.DeviceList);
-AO.VCM.Setpoint.DeltaRespMat = physics2hw('VCM', 'Setpoint', .15e-3 / 3, AO.VCM.DeviceList);
-
-%% 'NoEnergyScaling' because I don't want to force a BEND magnet read at this point
-%AO.HCM.Setpoint.DeltaRespMat = mm2amps('HCM', .5, AO.HCM.DeviceList, 'NoEnergyScaling');
-%AO.VCM.Setpoint.DeltaRespMat = mm2amps('VCM', .5, AO.VCM.DeviceList, 'NoEnergyScaling');
-
-
-AO.QFA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFA.FamilyName, 'Setpoint', AO.QFA.Setpoint.DeltaRespMat, AO.QFA.DeviceList);
-AO.QFB.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFB.FamilyName, 'Setpoint', AO.QFB.Setpoint.DeltaRespMat, AO.QFB.DeviceList);
-AO.QDA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QDA.FamilyName, 'Setpoint', AO.QDA.Setpoint.DeltaRespMat, AO.QDA.DeviceList);
-
-
-AO.SFA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFA.FamilyName, 'Setpoint', AO.SFA.Setpoint.DeltaRespMat, AO.SFA.DeviceList);
-AO.SFB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFB.FamilyName, 'Setpoint', AO.SFB.Setpoint.DeltaRespMat, AO.SFB.DeviceList);
-AO.SDA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDA.FamilyName, 'Setpoint', AO.SDA.Setpoint.DeltaRespMat, AO.SDA.DeviceList);
-AO.SDB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDB.FamilyName, 'Setpoint', AO.SDB.Setpoint.DeltaRespMat, AO.SDB.DeviceList);
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get S-positions [meters] %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Using ...ATIndex(:,1) will accomodata for split elements where the first
-% of a group of elements is put in the first column ie, if SFA is split in
-% two then ATIndex will look like [2 3; 11 12; ...] where each row is a
-% magnet and column represents each split.
-global THERING
-AO.BPMx.Position = findspos(THERING, AO.BPMx.AT.ATIndex(:,1))';
-AO.BPMy.Position = findspos(THERING, AO.BPMy.AT.ATIndex(:,1))';
-AO.FTx.Position = findspos(THERING, AO.FTx.AT.ATIndex(:,1))';
-AO.FTy.Position = findspos(THERING, AO.FTy.AT.ATIndex(:,1))';
-AO.HCM.Position = findspos(THERING, AO.HCM.AT.ATIndex(:,1))';
-AO.VCM.Position = findspos(THERING, AO.VCM.AT.ATIndex(:,1))';
-AO.QFA.Position = findspos(THERING, AO.QFA.AT.ATIndex(:,1))';
-AO.QDA.Position = findspos(THERING, AO.QDA.AT.ATIndex(:,1))';
-AO.QFB.Position = findspos(THERING, AO.QFB.AT.ATIndex(:,1))';
-AO.SFA.Position = findspos(THERING, AO.SFA.AT.ATIndex(:,1))';
-AO.SFB.Position = findspos(THERING, AO.SFB.AT.ATIndex(:,1))';
-AO.SDA.Position = findspos(THERING, AO.SDA.AT.ATIndex(:,1))';
-AO.SDB.Position = findspos(THERING, AO.SDB.AT.ATIndex(:,1))';
-AO.SKQ.Position = findspos(THERING, AO.SKQ.AT.ATIndex(:,1))';
-AO.BEND.Position = findspos(THERING, AO.BEND.AT.ATIndex(:,1))';
-AO.RF.Position = findspos(THERING, AO.RF.AT.ATIndex(:,1))';
-AO.KICK.Position = findspos(THERING, AO.KICK.AT.ATIndex(:,1))';
-AO.DCCT.Position = 0;
-AO.TUNE.Position = 0;
-
-
-% Save AO
-setao(AO);
-
-
-function dispobject(AO,name)
-
-n = length(fieldnames(AO));
-
-if n > 0
- fprintf(' %10s ',name);
- if mod(n,5) == 0
- fprintf('\n');
- end
+function aspinit(OperationalMode)
+% aspinit(OperationalMode)
+%
+% Initialize parameters for ASP control in MATLAB
+%
+%==========================
+% Accelerator Family Fields
+%==========================
+% FamilyName BPMx, HCM, etc
+% CommonNames Shortcut name for each element (optional)
+% DeviceList [Sector, Number]
+% ElementList number in list
+% Position m, magnet center
+%
+% MONITOR FIELDS
+% Mode online/manual/special/simulator
+% ChannelNames PV for monitor
+% Units Physics or HW
+% HW2PhysicsFcn function handle used to convert from hardware to physics units ==> inline will not compile, see below
+% HW2PhysicsParams parameters used for conversion function
+% Physics2HWFcn function handle used to convert from physics to hardware units
+% Physics2HWParams parameters used for conversion function
+% HWUnits units for Hardware 'ampere';
+% PhysicsUnits units for physics 'Rad';
+%
+% SETPOINT FIELDS
+% Mode online/manual/special/simulator
+% ChannelNames PV for monitor
+% Units hardware or physics
+% HW2PhysicsFcn function handle used to convert from hardware to physics units
+% HW2PhysicsParams parameters used for conversion function
+% Physics2HWFcn function handle used to convert from physics to hardware units
+% Physics2HWParams parameters used for conversion function
+% HWUnits units for Hardware 'ampere';
+% PhysicsUnits units for physics 'Rad';
+% Range minsetpoint, maxsetpoint;
+% Tolerance setpoint-monitor
+%
+%=============================================
+% Accelerator Toolbox Simulation Fields
+%=============================================
+% ATType Quad, Sext, etc
+% ATIndex index in THERING
+% ATParameterGroup parameter group
+%
+%============
+% Family List
+%============
+% BPMx BPMy - beam position monitors
+% HCM VCM - corrector magnets wound into sextupoles
+% BEND - gradient dipoles
+% QFA QDA QFB - quadrupole magnets
+% SFA SDA SDB SFB - sextupole magnets
+% SQK - skew quads wound into SDA magnets
+% KICK - injection kickers (DELTA type)
+% RF - 4 cavities (KEK type?)
+% DCCT
+% Septum (Not in model yet)
+%
+% Normal cell: d1 bpm s1 hcor d2 q1 d3 s2 d4 bpm dip bpm d4 hcor s3 d5 q2 d6 q3 d2 bpm s4
+% d2 q3 d6 q2 d5 s3 hcor d4 bpm dip bpm d4 s2 d3 q1 d2 hcor s1 bpm d1
+
+% === Change Log ===
+% Mark Boland 2004-02-12
+% Eugene Tan 2004-02-23
+% Eugene Tan 2004-12-13
+% Eugene Tan 2005-09-27 ver 4
+% Updated naming convention of the process variables, use version 4 of
+% the lattice "assr4.m" where the correctors have been merged into the
+% sextupoles. Made the necessary changes to updateatindex. Added skew
+% quadrupoles and updated generate_init.
+% Mark Boland 2006-05-27
+% Changed the BPM PVs to ...:SA_HPOS_MONITOR and ...:SA_VPOS_MONITOR
+%
+% === Still to do ===
+% - kicker delays
+% - BPM names and other possible PVs of interest eg. Q factor etc.
+% - clean up and configure the amp2k and k2amp conversion. Control system
+% designed to calculate the strengths and amp values using calc records,
+% therefore we should only need to change the PV name to access for
+% readback at setpoints. Only problem will be in simulation/offline mode
+% where those value are not available online. How do you keep the offline
+% conversion factors up to date with online vals?
+%
+% === Generated from ===
+
+% Default operational mode
+if nargin < 1
+ OperationalMode = 1;
+end
+
+
+%=============================================
+% START DEFINITION OF ACCELERATOR OBJECTS
+%=============================================
+fprintf(' Defining the Accelerator Objects. Objects being defined:\n')
+
+
+% Clear previous AcceleratorObjects
+setao([]);
+
+
+Mode = 'Online'; % This gets reset in setoperationalmode
+
+%=============================================
+%BPM data: status field designates if BPM in use
+%=============================================
+ntbpm=98;
+AO.BPMx.FamilyName = 'BPMx'; dispobject(AO,AO.BPMx.FamilyName);
+AO.BPMx.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
+AO.BPMx.Monitor.Mode = Mode;
+AO.BPMx.Monitor.DataType = 'Scalar';
+AO.BPMx.Monitor.Units = 'Hardware';
+AO.BPMx.Monitor.HWUnits = 'mm';
+AO.BPMx.Monitor.PhysicsUnits = 'meter';
+
+AO.BPMy.FamilyName = 'BPMy'; dispobject(AO,AO.BPMy.FamilyName);
+AO.BPMy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
+AO.BPMy.Monitor.Mode = Mode;
+AO.BPMy.Monitor.DataType = 'Scalar';
+AO.BPMy.Monitor.Units = 'Hardware';
+AO.BPMy.Monitor.HWUnits = 'mm';
+AO.BPMy.Monitor.PhysicsUnits = 'meter';
+
+% x-name x-chname xstat y-name y-chname ystat DevList Elem
+bpm={
+% INSERT BPM HERE
+};
+
+%Load fields from data block
+for ii=1:size(bpm,1)
+name=bpm{ii,1}; AO.BPMx.CommonNames(ii,:) = name;
+name=bpm{ii,2}; AO.BPMx.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,3}; AO.BPMx.Status(ii,:) = val;
+name=bpm{ii,4}; AO.BPMy.CommonNames(ii,:) = name;
+name=bpm{ii,5}; AO.BPMy.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,6}; AO.BPMy.Status(ii,:) = val;
+val =bpm{ii,7}; AO.BPMx.DeviceList(ii,:) = val;
+ AO.BPMy.DeviceList(ii,:) = val;
+val =bpm{ii,8}; AO.BPMx.ElementList(ii,:) = val;
+ AO.BPMy.ElementList(ii,:) = val;
+ AO.BPMx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.BPMx.Monitor.Physics2HWParams(ii,:) = 1000;
+ AO.BPMy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.BPMy.Monitor.Physics2HWParams(ii,:) = 1000;
+end
+
+
+% % Get sum value from button. Don't need handles and PV namelist as
+% % parameters are the same as the 'monitor' subcategory.
+% AO.BPMx.Sum.Monitor = AO.BPMx.Monitor;
+% AO.BPMx.Sum.SpecialFunction = 'getbpmsumspear';
+% AO.BPMx.Sum.HWUnits = 'ADC Counts';
+% AO.BPMx.Sum.PhysicsUnits = 'ADC Counts';
+% AO.BPMx.Sum.HW2PhysicsParams = 1;
+% AO.BPMx.Sum.Physics2HWParams = 1;
+% % Get q value from BPMs. Don't need handles and PV namelist.
+% AO.BPMx.Q = AO.BPMx.Monitor;
+% AO.BPMx.Q.SpecialFunction = 'getbpmqspear';
+% AO.BPMx.Q.HWUnits = 'mm';
+% AO.BPMx.Q.PhysicsUnits = 'meter';
+% AO.BPMx.Q.HW2PhysicsParams = 1e-3;
+% AO.BPMx.Q.Physics2HWParams = 1000;
+%
+% % Definition above for horizontal. Replicate for vertical.
+% AO.BPMy.Sum = AO.BPMx.Sum;
+% AO.BPMy.Q = AO.BPMx.Q;
+
+
+
+%=============================================
+% First Turn BPM data from Libera
+%=============================================
+ntbpm=98;
+AO.FTx.FamilyName = 'FTx'; dispobject(AO,AO.FTx.FamilyName);
+AO.FTx.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
+AO.FTx.Monitor.Mode = Mode;
+AO.FTx.Monitor.DataType = 'Scalar';
+AO.FTx.Monitor.Units = 'Hardware';
+AO.FTx.Monitor.HWUnits = 'mm';
+AO.FTx.Monitor.PhysicsUnits = 'meter';
+
+AO.FTy.FamilyName = 'FTy'; dispobject(AO,AO.FTy.FamilyName);
+AO.FTy.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
+AO.FTy.Monitor.Mode = Mode;
+AO.FTy.Monitor.DataType = 'Scalar';
+AO.FTy.Monitor.Units = 'Hardware';
+AO.FTy.Monitor.HWUnits = 'mm';
+AO.FTy.Monitor.PhysicsUnits = 'meter';
+
+% x-name x-chname xstat y-name y-chname ystat DevList Elem
+bpm={
+% INSERT FT HERE
+};
+
+%Load fields from data block
+for ii=1:size(bpm,1)
+name=bpm{ii,1}; AO.FTx.CommonNames(ii,:) = name;
+name=bpm{ii,2}; AO.FTx.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,3}; AO.FTx.Status(ii,:) = val;
+name=bpm{ii,4}; AO.FTy.CommonNames(ii,:) = name;
+name=bpm{ii,5}; AO.FTy.Monitor.ChannelNames(ii,:)= name;
+val =bpm{ii,6}; AO.FTy.Status(ii,:) = val;
+val =bpm{ii,7}; AO.FTx.DeviceList(ii,:) = val;
+ AO.FTy.DeviceList(ii,:) = val;
+val =bpm{ii,8}; AO.FTx.ElementList(ii,:) = val;
+ AO.FTy.ElementList(ii,:) = val;
+ AO.FTx.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.FTx.Monitor.Physics2HWParams(ii,:) = 1000;
+ AO.FTy.Monitor.HW2PhysicsParams(ii,:) = 1e-3;
+ AO.FTy.Monitor.Physics2HWParams(ii,:) = 1000;
+end
+AO.FTx.Status = AO.BPMx.Status;
+AO.FTy.Status = AO.BPMy.Status;
+
+% % Get sum value from button. Don't need handles and PV namelist as
+% % parameters are the same as the 'monitor' subcategory.
+AO.FTx.Offset.Mode = 'Special';
+AO.FTx.Offset.Units = 'Hardware';
+AO.FTx.Offset.DataType = 'Scalar';
+AO.FTx.Offset.SpecialFunction = 'getftoffset';
+AO.FTx.Offset.SpecialFunctionSet = 'setftoffset';
+AO.FTx.Offset.HWUnits = '32ns samples';
+AO.FTx.Offset.PhysicsUnits = '32ns samples';
+AO.FTx.Offset.HW2PhysicsParams = 1;
+AO.FTx.Offset.Physics2HWParams = 1;
+
+AO.FTx.Length.Mode = 'Special';
+AO.FTx.Length.Units = 'Hardware';
+AO.FTx.Length.DataType = 'Scalar';
+AO.FTx.Length.SpecialFunction = 'getftlength';
+AO.FTx.Length.SpecialFunctionSet = 'setftlength';
+AO.FTx.Length.HWUnits = '32ns samples';
+AO.FTx.Length.PhysicsUnits = '32ns samples';
+AO.FTx.Length.HW2PhysicsParams = 1;
+AO.FTx.Length.Physics2HWParams = 1;
+
+AO.FTx.Maxadc.Mode = 'Special';
+AO.FTx.Maxadc.Units = 'Hardware';
+AO.FTx.Maxadc.DataType = 'Scalar';
+AO.FTx.Maxadc.SpecialFunction = 'getftmaxadc';
+AO.FTx.Maxadc.HWUnits = 'ADC counts';
+AO.FTx.Maxadc.PhysicsUnits = 'ADC counts';
+AO.FTx.Maxadc.HW2PhysicsParams = 1;
+AO.FTx.Maxadc.Physics2HWParams = 1;
+
+% AO.FTx.Sum.Mode = 'Special';
+% AO.FTx.Sum.Units = 'Hardware';
+% AO.FTx.Sum.DataType = 'Scalar';
+% AO.FTx.Sum.SpecialFunction = 'getftsum';
+% AO.FTx.Sum.HWUnits = 'ADC counts';
+% AO.FTx.Sum.PhysicsUnits = 'ADC counts';
+% AO.FTx.Sum.HW2PhysicsParams = 1;
+% AO.FTx.Sum.Physics2HWParams = 1;
+
+
+AO.FTsum.FamilyName = 'FTsum'; dispobject(AO,AO.FTsum.FamilyName);
+AO.FTsum.MemberOf = {'PlotFamily'; 'BPM'; 'Diagnostics'};
+AO.FTsum.Monitor.Mode = 'Special';
+AO.FTsum.Monitor.Units = 'Hardware';
+AO.FTsum.Monitor.DataType = 'Scalar';
+AO.FTsum.Monitor.SpecialFunction = 'getftsum';
+AO.FTsum.Monitor.HWUnits = 'ADC counts';
+AO.FTsum.Monitor.PhysicsUnits = 'ADC counts';
+AO.FTsum.Monitor.HW2PhysicsParams = 1;
+AO.FTsum.Monitor.Physics2HWParams = 1;
+
+
+%===========================================================
+% Corrector data: status field designates if corrector in use
+% ASP corrector coils wound into sextupoles. Not dynamic correctors.
+%===========================================================
+
+AO.HCM.FamilyName = 'HCM'; dispobject(AO,AO.HCM.FamilyName);
+AO.HCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'HCM'; 'Magnet'};
+
+AO.HCM.Monitor.Mode = Mode;
+AO.HCM.Monitor.DataType = 'Scalar';
+AO.HCM.Monitor.Units = 'Hardware';
+AO.HCM.Monitor.HWUnits = 'ampere';
+AO.HCM.Monitor.PhysicsUnits = 'radian';
+AO.HCM.Monitor.HW2PhysicsFcn = @amp2k;
+AO.HCM.Monitor.Physics2HWFcn = @k2amp;
+
+AO.HCM.Setpoint.Mode = Mode;
+AO.HCM.Setpoint.DataType = 'Scalar';
+AO.HCM.Setpoint.Units = 'Hardware';
+AO.HCM.Setpoint.HWUnits = 'ampere';
+AO.HCM.Setpoint.PhysicsUnits = 'radian';
+AO.HCM.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.HCM.Setpoint.Physics2HWFcn = @k2amp;
+
+% HW in ampere, Physics in radian. Respmat settings below AO definitions.
+% x-common x-monitor x-setpoint stat devlist elem tol
+cor={
+% INSERT HCM HERE
+};
+
+[C, Leff, MagnetType] = magnetcoefficients('HCM');
+
+for ii=1:size(cor,1)
+name=cor{ii,1}; AO.HCM.CommonNames(ii,:) = name;
+name=cor{ii,2}; AO.HCM.Monitor.ChannelNames(ii,:) = name;
+name=cor{ii,3}; AO.HCM.Setpoint.ChannelNames(ii,:) = name;
+val =cor{ii,4}; AO.HCM.Status(ii,1) = val;
+val =cor{ii,5}; AO.HCM.DeviceList(ii,:) = val;
+val =cor{ii,6}; AO.HCM.ElementList(ii,1) = val;
+val =cor{ii,7}; AO.HCM.Setpoint.Tolerance(ii,1) = val;
+
+AO.HCM.Setpoint.Range(ii,:) = [-90 +90];
+AO.HCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
+AO.HCM.Monitor.Physics2HWParams{1}(ii,:) = C;
+AO.HCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
+AO.HCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
+end
+
+
+AO.VCM.FamilyName = 'VCM'; dispobject(AO,AO.VCM.FamilyName);
+AO.VCM.MemberOf = {'PlotFamily'; 'MachineConfig'; 'COR'; 'VCM'; 'Magnet'};
+
+AO.VCM.Monitor.Mode = Mode;
+AO.VCM.Monitor.DataType = 'Scalar';
+AO.VCM.Monitor.Units = 'Hardware';
+AO.VCM.Monitor.HWUnits = 'ampere';
+AO.VCM.Monitor.PhysicsUnits = 'radian';
+AO.VCM.Monitor.HW2PhysicsFcn = @amp2k;
+AO.VCM.Monitor.Physics2HWFcn = @k2amp;
+
+AO.VCM.Setpoint.Mode = Mode;
+AO.VCM.Setpoint.DataType = 'Scalar';
+AO.VCM.Setpoint.Units = 'Hardware';
+AO.VCM.Setpoint.HWUnits = 'ampere';
+AO.VCM.Setpoint.PhysicsUnits = 'radian';
+AO.VCM.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.VCM.Setpoint.Physics2HWFcn = @k2amp;
+
+% HW in ampere, Physics in radian ** radian units converted to ampere below ***
+% y-common y-monitor y-setpoint stat devlist elem
+cor={
+% INSERT VCM HERE
+};
+
+[C, Leff, MagnetType] = magnetcoefficients('VCM');
+
+for ii=1:size(cor,1)
+name=cor{ii,1}; AO.VCM.CommonNames(ii,:) = name;
+name=cor{ii,2}; AO.VCM.Monitor.ChannelNames(ii,:) = name;
+name=cor{ii,3}; AO.VCM.Setpoint.ChannelNames(ii,:) = name;
+val =cor{ii,4}; AO.VCM.Status(ii,1) = val;
+val =cor{ii,5}; AO.VCM.DeviceList(ii,:) = val;
+val =cor{ii,6}; AO.VCM.ElementList(ii,1) = val;
+val =cor{ii,7}; AO.VCM.Setpoint.Tolerance(ii,1) = val;
+
+AO.VCM.Setpoint.Range(ii,:) = [-125 +125];
+AO.VCM.Monitor.HW2PhysicsParams{1}(ii,:) = C;
+AO.VCM.Monitor.Physics2HWParams{1}(ii,:) = C;
+AO.VCM.Setpoint.HW2PhysicsParams{1}(ii,:) = C;
+AO.VCM.Setpoint.Physics2HWParams{1}(ii,:) = C;
+end
+
+
+%=============================
+% MAIN MAGNETS
+%=============================
+
+%===========
+%Dipole data
+%===========
+
+% *** BEND ***
+AO.BEND.FamilyName = 'BEND'; dispobject(AO,AO.BEND.FamilyName);
+AO.BEND.MemberOf = {'PlotFamily'; 'MachineConfig'; 'BEND'; 'Magnet';};
+HW2PhysicsParams = magnetcoefficients('BEND');
+Physics2HWParams = magnetcoefficients('BEND');
+
+AO.BEND.Monitor.Mode = Mode;
+AO.BEND.Monitor.DataType = 'Scalar';
+AO.BEND.Monitor.Units = 'Hardware';
+AO.BEND.Monitor.HW2PhysicsFcn = @bend2gev; % @bend2gev ???
+AO.BEND.Monitor.Physics2HWFcn = @gev2bend;
+AO.BEND.Monitor.HWUnits = 'ampere';
+AO.BEND.Monitor.PhysicsUnits = 'energy';
+
+AO.BEND.Setpoint.Mode = Mode;
+AO.BEND.Setpoint.DataType = 'Scalar';
+AO.BEND.Setpoint.Units = 'Hardware';
+AO.BEND.Setpoint.HW2PhysicsFcn = @bend2gev;
+AO.BEND.Setpoint.Physics2HWFcn = @gev2bend;
+AO.BEND.Setpoint.HWUnits = 'ampere';
+AO.BEND.Setpoint.PhysicsUnits = 'energy';
+
+% common monitor setpoint stat devlist elem scale tol
+bend={
+% INSERT BEND HERE
+};
+
+for ii=1:size(bend,1)
+name=bend{ii,1}; AO.BEND.CommonNames(ii,:) = name;
+name=bend{ii,2}; AO.BEND.Monitor.ChannelNames(ii,:) = name;
+name=bend{ii,3}; AO.BEND.Setpoint.ChannelNames(ii,:) = name;
+val =bend{ii,4}; AO.BEND.Status(ii,1) = val;
+val =bend{ii,5}; AO.BEND.DeviceList(ii,:) = val;
+val =bend{ii,6}; AO.BEND.ElementList(ii,1) = val;
+val =bend{ii,7}; % This is the scale factor
+AO.BEND.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.BEND.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.BEND.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.BEND.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.BEND.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.BEND.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.BEND.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.BEND.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =bend{ii,8}; AO.BEND.Setpoint.Tolerance(ii,1) = val;
+
+AO.BEND.Setpoint.Range(ii,:) = [0 500];
+end
+
+%===============
+%Quadrupole data
+%===============
+
+% *** QFA ***
+AO.QFA.FamilyName = 'QFA'; dispobject(AO,AO.QFA.FamilyName);
+AO.QFA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
+HW2PhysicsParams = magnetcoefficients('QFA');
+Physics2HWParams = magnetcoefficients('QFA');
+
+AO.QFA.Monitor.Mode = Mode;
+AO.QFA.Monitor.DataType = 'Scalar';
+AO.QFA.Monitor.Units = 'Hardware';
+AO.QFA.Monitor.HWUnits = 'ampere';
+AO.QFA.Monitor.PhysicsUnits = 'meter^-2';
+AO.QFA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QFA.Monitor.Physics2HWFcn = @k2amp;
+
+AO.QFA.Setpoint.Mode = Mode;
+AO.QFA.Setpoint.DataType = 'Scalar';
+AO.QFA.Setpoint.Units = 'Hardware';
+AO.QFA.Setpoint.HWUnits = 'ampere';
+AO.QFA.Setpoint.PhysicsUnits = 'meter^-2';
+AO.QFA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QFA.Setpoint.Physics2HWFcn = @k2amp;
+
+% common monitor setpoint stat devlist elem scale tol
+qfa={
+% INSERT QFA HERE
+};
+
+for ii=1:size(qfa,1)
+name=qfa{ii,1}; AO.QFA.CommonNames(ii,:) = name;
+name=qfa{ii,2}; AO.QFA.Monitor.ChannelNames(ii,:) = name;
+name=qfa{ii,3}; AO.QFA.Setpoint.ChannelNames(ii,:) = name;
+val =qfa{ii,4}; AO.QFA.Status(ii,1) = val;
+val =qfa{ii,5}; AO.QFA.DeviceList(ii,:) = val;
+val =qfa{ii,6}; AO.QFA.ElementList(ii,1) = val;
+val =qfa{ii,7}; % This is the scale factor
+AO.QFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qfa{ii,8}; AO.QFA.Setpoint.Tolerance(ii,1) = val;
+
+AO.QFA.Setpoint.Range(ii,:) = [0 180];
+end
+
+
+% *** QDA ***
+AO.QDA.FamilyName = 'QDA'; dispobject(AO,AO.QDA.FamilyName);
+AO.QDA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QD';};
+HW2PhysicsParams = magnetcoefficients('QDA');
+Physics2HWParams = magnetcoefficients('QDA');
+
+AO.QDA.Monitor.Mode = Mode;
+AO.QDA.Monitor.DataType = 'Scalar';
+AO.QDA.Monitor.Units = 'Hardware';
+AO.QDA.Monitor.HWUnits = 'ampere';
+AO.QDA.Monitor.PhysicsUnits = 'meter^-2';
+AO.QDA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QDA.Monitor.Physics2HWFcn = @k2amp;
+
+AO.QDA.Setpoint.Mode = Mode;
+AO.QDA.Setpoint.DataType = 'Scalar';
+AO.QDA.Setpoint.Units = 'Hardware';
+AO.QDA.Setpoint.HWUnits = 'ampere';
+AO.QDA.Setpoint.PhysicsUnits = 'meter^-2';
+AO.QDA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QDA.Setpoint.Physics2HWFcn = @k2amp;
+
+% common monitor setpoint stat devlist elem scale tol
+qda={
+% INSERT QDA HERE
+};
+
+for ii=1:size(qda,1)
+name=qda{ii,1}; AO.QDA.CommonNames(ii,:) = name;
+name=qda{ii,2}; AO.QDA.Monitor.ChannelNames(ii,:) = name;
+name=qda{ii,3}; AO.QDA.Setpoint.ChannelNames(ii,:) = name;
+val =qda{ii,4}; AO.QDA.Status(ii,1) = val;
+val =qda{ii,5}; AO.QDA.DeviceList(ii,:) = val;
+val =qda{ii,6}; AO.QDA.ElementList(ii,1) = val;
+val =qda{ii,7}; % This is the scale factor
+AO.QDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.QDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.QDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QDA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qda{ii,8}; AO.QDA.Setpoint.Tolerance(ii,1) = val;
+
+AO.QDA.Setpoint.Range(ii,:) = [0 100];
+end
+
+
+
+% *** QFB ***
+AO.QFB.FamilyName = 'QFB'; dispobject(AO,AO.QFB.FamilyName);
+AO.QFB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'QUAD'; 'Magnet'; 'Tune Corrector'; 'QF';};
+HW2PhysicsParams = magnetcoefficients('QFB');
+Physics2HWParams = magnetcoefficients('QFB');
+
+AO.QFB.Monitor.Mode = Mode;
+AO.QFB.Monitor.DataType = 'Scalar';
+AO.QFB.Monitor.Units = 'Hardware';
+AO.QFB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.QFB.Monitor.Physics2HWFcn = @k2amp;
+AO.QFB.Monitor.HWUnits = 'ampere';
+AO.QFB.Monitor.PhysicsUnits = 'meter^-2';
+
+AO.QFB.Setpoint.Mode = Mode;
+AO.QFB.Setpoint.DataType = 'Scalar';
+AO.QFB.Setpoint.Units = 'Hardware';
+AO.QFB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.QFB.Setpoint.Physics2HWFcn = @k2amp;
+AO.QFB.Setpoint.HWUnits = 'ampere';
+AO.QFB.Setpoint.PhysicsUnits = 'meter^-2';
+
+% common monitor setpoint stat devlist elem scale tol
+qfb={
+% INSERT QFB HERE
+};
+
+for ii=1:size(qfb,1)
+name=qfb{ii,1}; AO.QFB.CommonNames(ii,:) = name;
+name=qfb{ii,2}; AO.QFB.Monitor.ChannelNames(ii,:) = name;
+name=qfb{ii,3}; AO.QFB.Setpoint.ChannelNames(ii,:) = name;
+val =qfb{ii,4}; AO.QFB.Status(ii,1) = val;
+val =qfb{ii,5}; AO.QFB.DeviceList(ii,:) = val;
+val =qfb{ii,6}; AO.QFB.ElementList(ii,1) = val;
+val =qfb{ii,7}; % This is the scale factor
+AO.QFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.QFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.QFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.QFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.QFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =qfb{ii,8}; AO.QFB.Setpoint.Tolerance(ii,1) = val;
+
+AO.QFB.Setpoint.Range(ii,:) = [0 180];
+end
+
+
+%===============
+%Sextupole data
+%===============
+% *** SFA ***
+AO.SFA.FamilyName = 'SFA'; dispobject(AO,AO.SFA.FamilyName);
+AO.SFA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SF'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SFA');
+Physics2HWParams = magnetcoefficients('SFA');
+
+AO.SFA.Monitor.Mode = Mode;
+AO.SFA.Monitor.DataType = 'Scalar';
+AO.SFA.Monitor.Units = 'Hardware';
+AO.SFA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SFA.Monitor.Physics2HWFcn = @k2amp;
+AO.SFA.Monitor.HWUnits = 'ampere';
+AO.SFA.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SFA.Setpoint.Mode = Mode;
+AO.SFA.Setpoint.DataType = 'Scalar';
+AO.SFA.Setpoint.Units = 'Hardware';
+AO.SFA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SFA.Setpoint.Physics2HWFcn = @k2amp;
+AO.SFA.Setpoint.HWUnits = 'ampere';
+AO.SFA.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sfa={
+% INSERT SFA HERE
+};
+
+for ii=1:size(sfa,1)
+name=sfa{ii,1}; AO.SFA.CommonNames(ii,:) = name;
+name=sfa{ii,2}; AO.SFA.Monitor.ChannelNames(ii,:) = name;
+name=sfa{ii,3}; AO.SFA.Setpoint.ChannelNames(ii,:) = name;
+val =sfa{ii,4}; AO.SFA.Status(ii,1) = val;
+val =sfa{ii,5}; AO.SFA.DeviceList(ii,:) = val;
+val =sfa{ii,6}; AO.SFA.ElementList(ii,1) = val;
+val =sfa{ii,7}; % This is the scale factor
+AO.SFA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SFA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sfa{ii,8}; AO.SFA.Setpoint.Tolerance(ii,1) = val;
+
+AO.SFA.Setpoint.Range(ii,:) = [0 140];
+end
+
+
+
+% *** SDA ***
+AO.SDA.FamilyName = 'SDA'; dispobject(AO,AO.SDA.FamilyName);
+AO.SDA.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SD'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SDA');
+Physics2HWParams = magnetcoefficients('SDA');
+
+AO.SDA.Monitor.Mode = Mode;
+AO.SDA.Monitor.DataType = 'Scalar';
+AO.SDA.Monitor.Units = 'Hardware';
+AO.SDA.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SDA.Monitor.Physics2HWFcn = @k2amp;
+AO.SDA.Monitor.HWUnits = 'ampere';
+AO.SDA.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SDA.Setpoint.Mode = Mode;
+AO.SDA.Setpoint.DataType = 'Scalar';
+AO.SDA.Setpoint.Units = 'Hardware';
+AO.SDA.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SDA.Setpoint.Physics2HWFcn = @k2amp;
+AO.SDA.Setpoint.HWUnits = 'ampere';
+AO.SDA.Setpoint.PhysicsUnits = 'meter^-3';
+
+
+% common monitor setpoint stat devlist elem scale tol
+sda={
+% INSERT SDA HERE
+};
+
+for ii=1:size(sda,1)
+name=sda{ii,1}; AO.SDA.CommonNames(ii,:) = name;
+name=sda{ii,2}; AO.SDA.Monitor.ChannelNames(ii,:) = name;
+name=sda{ii,3}; AO.SDA.Setpoint.ChannelNames(ii,:) = name;
+val =sda{ii,4}; AO.SDA.Status(ii,1) = val;
+val =sda{ii,5}; AO.SDA.DeviceList(ii,:) = val;
+val =sda{ii,6}; AO.SDA.ElementList(ii,1) = val;
+val =sda{ii,7}; % This is the scale factor
+AO.SDA.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDA.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDA.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDA.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDA.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDA.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SDA.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDA.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sda{ii,8}; AO.SDA.Setpoint.Tolerance(ii,1) = val;
+
+AO.SDA.Setpoint.Range(ii,:) = [0 140];
+end
+
+
+% *** SDB ***
+AO.SDB.FamilyName = 'SDB'; dispobject(AO,AO.SDB.FamilyName);
+AO.SDB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SD'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SDB');
+Physics2HWParams = magnetcoefficients('SDB');
+
+AO.SDB.Monitor.Mode = Mode;
+AO.SDB.Monitor.DataType = 'Scalar';
+AO.SDB.Monitor.Units = 'Hardware';
+AO.SDB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SDB.Monitor.Physics2HWFcn = @k2amp;
+AO.SDB.Monitor.HWUnits = 'ampere';
+AO.SDB.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SDB.Setpoint.Mode = Mode;
+AO.SDB.Setpoint.DataType = 'Scalar';
+AO.SDB.Setpoint.Units = 'Hardware';
+AO.SDB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SDB.Setpoint.Physics2HWFcn = @k2amp;
+AO.SDB.Setpoint.HWUnits = 'ampere';
+AO.SDB.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sdb={
+% INSERT SDB HERE
+};
+
+for ii=1:size(sdb,1)
+name=sdb{ii,1}; AO.SDB.CommonNames(ii,:) = name;
+name=sdb{ii,2}; AO.SDB.Monitor.ChannelNames(ii,:) = name;
+name=sdb{ii,3}; AO.SDB.Setpoint.ChannelNames(ii,:)= name;
+val =sdb{ii,4}; AO.SDB.Status(ii,1) = val;
+val =sdb{ii,5}; AO.SDB.DeviceList(ii,:) = val;
+val =sdb{ii,6}; AO.SDB.ElementList(ii,1) = val;
+val =sdb{ii,7}; % This is the scale factor
+AO.SDB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SDB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SDB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SDB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SDB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sdb{ii,8}; AO.SDB.Setpoint.Tolerance(ii,1) = val;
+
+AO.SDB.Setpoint.Range(ii,:) = [0 140];
+end
+
+
+
+% *** SFB ***
+AO.SFB.FamilyName = 'SFB'; dispobject(AO,AO.SFB.FamilyName);
+AO.SFB.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SF'; 'SEXT'; 'Magnet'; 'Chromaticity Corrector';};
+HW2PhysicsParams = magnetcoefficients('SFB');
+Physics2HWParams = magnetcoefficients('SFB');
+
+AO.SFB.Monitor.Mode = Mode;
+AO.SFB.Monitor.DataType = 'Scalar';
+AO.SFB.Monitor.Units = 'Hardware';
+AO.SFB.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SFB.Monitor.Physics2HWFcn = @k2amp;
+AO.SFB.Monitor.HWUnits = 'ampere';
+AO.SFB.Monitor.PhysicsUnits = 'meter^-3';
+
+AO.SFB.Setpoint.Mode = Mode;
+AO.SFB.Setpoint.DataType = 'Scalar';
+AO.SFB.Setpoint.Units = 'Hardware';
+AO.SFB.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SFB.Setpoint.Physics2HWFcn = @k2amp;
+AO.SFB.Setpoint.HWUnits = 'ampere';
+AO.SFB.Setpoint.PhysicsUnits = 'meter^-3';
+
+% common monitor setpoint stat devlist elem scale tol
+sfb={
+% INSERT SFB HERE
+};
+
+for ii=1:size(sfb,1)
+name=sfb{ii,1}; AO.SFB.CommonNames(ii,:) = name;
+name=sfb{ii,2}; AO.SFB.Monitor.ChannelNames(ii,:) = name;
+name=sfb{ii,3}; AO.SFB.Setpoint.ChannelNames(ii,:)= name;
+val =sfb{ii,4}; AO.SFB.Status(ii,1) = val;
+val =sfb{ii,5}; AO.SFB.DeviceList(ii,:) = val;
+val =sfb{ii,6}; AO.SFB.ElementLsist(ii,1) = val;
+val =sfb{ii,7}; % This is the scale factor
+AO.SFB.Monitor.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFB.Monitor.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFB.Setpoint.HW2PhysicsParams{1}(ii,:) = HW2PhysicsParams;
+AO.SFB.Setpoint.HW2PhysicsParams{2}(ii,:) = val;
+AO.SFB.Monitor.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFB.Monitor.Physics2HWParams{2}(ii,:) = val;
+AO.SFB.Setpoint.Physics2HWParams{1}(ii,:) = Physics2HWParams;
+AO.SFB.Setpoint.Physics2HWParams{2}(ii,:) = val;
+val =sfb{ii,8}; AO.SFB.Setpoint.Tolerance(ii,1) = val;
+
+AO.SFB.Setpoint.Range(ii,:) = val;
+end
+
+%===============
+%Skew Quad data
+%===============
+% *** Skew quadrupoles *** 2005/09/27 Eugene
+AO.SKQ.FamilyName = 'SKQ'; dispobject(AO,AO.SKQ.FamilyName);
+AO.SKQ.MemberOf = {'PlotFamily'; 'MachineConfig'; 'SkewQuad'; 'Magnet';};
+HW2PhysicsParams = magnetcoefficients('SKQ');
+Physics2HWParams = magnetcoefficients('SKQ');
+
+AO.SKQ.Monitor.Mode = Mode;
+AO.SKQ.Monitor.DataType = 'Scalar';
+AO.SKQ.Monitor.Units = 'Hardware';
+AO.SKQ.Monitor.HW2PhysicsFcn = @amp2k;
+AO.SKQ.Monitor.Physics2HWFcn = @k2amp;
+AO.SKQ.Monitor.HWUnits = 'ampere';
+AO.SKQ.Monitor.PhysicsUnits = 'meter^-2';
+
+AO.SKQ.Setpoint.Mode = Mode;
+AO.SKQ.Setpoint.DataType = 'Scalar';
+AO.SKQ.Setpoint.Units = 'Hardware';
+AO.SKQ.Setpoint.HW2PhysicsFcn = @amp2k;
+AO.SKQ.Setpoint.Physics2HWFcn = @k2amp;
+AO.SKQ.Setpoint.HWUnits = 'ampere';
+AO.SKQ.Setpoint.PhysicsUnits = 'meter^-2';
+
+% common monitor setpoint stat devlist elem scale tol
+sq={
+% INSERT SKQ HERE
+};
+
+for ii=1:size(sq,1)
+name=sq{ii,1}; AO.SKQ.CommonNames(ii,:) = name;
+name=sq{ii,2}; AO.SKQ.Monitor.ChannelNames(ii,:) = name;
+name=sq{ii,3}; AO.SKQ.Setpoint.ChannelNames(ii,:) = name;
+val =sq{ii,4}; AO.SKQ.Status(ii,1) = val;
+val =sq{ii,5}; AO.SKQ.DeviceList(ii,:) = val;
+val =sq{ii,6}; AO.SKQ.ElementList(ii,1) = val;
+val =sq{ii,7}; AO.SKQ.Setpoint.Tolerance(ii,1) = val;
+AO.SKQ.Monitor.HW2PhysicsParams(ii,:) = HW2PhysicsParams;
+AO.SKQ.Setpoint.HW2PhysicsParams(ii,:) = HW2PhysicsParams;
+AO.SKQ.Monitor.Physics2HWParams(ii,:) = Physics2HWParams;
+AO.SKQ.Setpoint.Physics2HWParams(ii,:) = Physics2HWParams;
+
+AO.SKQ.Setpoint.Range(ii,:) = [-5 +5];
+end
+
+
+%===============
+%Kicker data
+%===============
+AO.KICK.FamilyName = 'KICK'; dispobject(AO,AO.KICK.FamilyName);
+AO.KICK.MemberOf = {'Injection','MachineConfig'};
+
+AO.KICK.Monitor.Mode = Mode;
+AO.KICK.Monitor.DataType = 'Scalar';
+AO.KICK.Monitor.Units = 'Hardware';
+AO.KICK.Monitor.HWUnits = 'kVolts';
+AO.KICK.Monitor.PhysicsUnits = 'mradian';
+
+AO.KICK.Setpoint.Mode = Mode;
+AO.KICK.Setpoint.DataType = 'Scalar';
+AO.KICK.Setpoint.Units = 'Hardware';
+AO.KICK.Setpoint.HWUnits = 'kVolts';
+AO.KICK.Setpoint.PhysicsUnits = 'mradian';
+
+hw2physics_conversionfactor = 1;
+
+%common monitor setpoint stat devlist elem tol
+kickeramp={
+% INSERT KICKERS HERE
+};
+
+for ii=1:size(kickeramp,1)
+name=kickeramp{ii,1}; AO.KICK.CommonNames(ii,:) = name;
+name=kickeramp{ii,2}; AO.KICK.Monitor.ChannelNames(ii,:) = name;
+name=kickeramp{ii,3}; AO.KICK.Setpoint.ChannelNames(ii,:)= name;
+val =kickeramp{ii,4}; AO.KICK.Status(ii,1) = val;
+val =kickeramp{ii,5}; AO.KICK.DeviceList(ii,:) = val;
+val =kickeramp{ii,6}; AO.KICK.ElementList(ii,1) = val;
+val =kickeramp{ii,7}; AO.KICK.Setpoint.Tolerance(ii,1) = val;
+
+AO.KICK.Setpoint.Range(ii,:) = [0 3];
+
+if ii==1||ii==4
+ AO.KICK.Monitor.HW2PhysicsParams = -hw2physics_conversionfactor;
+ AO.KICK.Monitor.Physics2HWParams = -1/hw2physics_conversionfactor;
+ AO.KICK.Setpoint.HW2PhysicsParams = -hw2physics_conversionfactor;
+ AO.KICK.Setpoint.Physics2HWParams = -1/hw2physics_conversionfactor;
+else
+ AO.KICK.Monitor.HW2PhysicsParams = hw2physics_conversionfactor;
+ AO.KICK.Monitor.Physics2HWParams = 1/hw2physics_conversionfactor;
+ AO.KICK.Setpoint.HW2PhysicsParams = hw2physics_conversionfactor;
+ AO.KICK.Setpoint.Physics2HWParams = 1/hw2physics_conversionfactor;
+end
+end
+
+% *** KICK Delay ***
+% AO.KICK.Delay
+% >> removed >> see previous versions if info needed
+
+
+%============
+%RF System
+%============
+AO.RF.FamilyName = 'RF'; dispobject(AO,AO.RF.FamilyName);
+AO.RF.MemberOf = {'MachineConfig'; 'RF'; 'RFSystem'};
+
+if OperationalMode == 3
+%-------------------------------- 4 cavity Case
+%common stat devlist elem
+rfcommon={
+'RF1 ' 1 [6,1] 1 ; ...
+'RF2 ' 1 [6,2] 2 ; ...
+'RF3 ' 1 [7,1] 3 ; ...
+'RF4 ' 1 [7,2] 4 ; ...
+ };
+
+%FreqMon FreqSetpoint HW2PhysicsParams Physics2HWParams Range Tolerance
+rffreq={
+'ASP:RFFreq1 ' 'ASP:RFFreqSetpt1' 1e+6 1e-6 [0 2500] 100.0; ...
+'ASP:RFFreq2 ' 'ASP:RFFreqSetpt2' 1e+6 1e-6 [0 2500] 100.0; ...
+'ASP:RFFreq3 ' 'ASP:RFFreqSetpt3' 1e+6 1e-6 [0 2500] 100.0; ...
+'ASP:RFFreq4 ' 'ASP:RFFreqSetpt4' 1e+6 1e-6 [0 2500] 100.0; ...
+ };
+
+% PhaseCtrl PhaseMon HW2PhysicsParams Physics2HWParams Range Tolerance
+rfphase={
+'SRF1:STN:PHASE' 'SRF1:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
+'SRF2:STN:PHASE' 'SRF2:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
+'SRF3:STN:PHASE' 'SRF3:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
+'SRF4:STN:PHASE' 'SRF4:STN:PHASE:CALC' 1 1 [-200 200] inf ; ...
+ };
+
+% VoltCtrl VoltMon HW2PhysicsParams Physics2HWParams Range Tolerance
+rfvolt={
+'SRF1:STN:VOLT:CTRL ' 'SRF1:STN:VOLT' 1 1 [-inf inf] inf ; ...
+'SRF2:STN:VOLT:CTRL ' 'SRF2:STN:VOLT' 1 1 [-inf inf] inf ; ...
+'SRF3:STN:VOLT:CTRL ' 'SRF3:STN:VOLT' 1 1 [-inf inf] inf ; ...
+'SRF4:STN:VOLT:CTRL ' 'SRF4:STN:VOLT' 1 1 [-inf inf] inf ; ...
+ };
+% PowerCtrl PowerMon Klystronpower HW2PhysicsParams Physics2HWParams Range Tolerance
+rfpower={
+'SRF1:KLYSDRIVFRWD:POWER:ON ' 'SRF1:KLYSDRIVFRWD:POWER' 'SRF1:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+'SRF2:KLYSDRIVFRWD:POWER:ON ' 'SRF2:KLYSDRIVFRWD:POWER' 'SRF2:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+'SRF3:KLYSDRIVFRWD:POWER:ON ' 'SRF3:KLYSDRIVFRWD:POWER' 'SRF3:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+'SRF4:KLYSDRIVFRWD:POWER:ON ' 'SRF4:KLYSDRIVFRWD:POWER' 'SRF4:KLYSOUTFRWD:POWER' 1 1 [-inf inf] inf ; ...
+ };
+
+for ii=1:size(rfcommon,1)
+name=rfcommon{ii,1}; AO.RF.CommonNames(ii,:) = name;
+val =rfcommon{ii,2}; AO.RF.Status(ii,1) = val;
+val =rfcommon{ii,3}; AO.RF.DeviceList(ii,:) = val;
+val =rfcommon{ii,4}; AO.RF.ElementList(ii,1) = val;
+end
+
+for ii=1:size(rffreq,1)
+name=rffreq{ii,1}; AO.RF.Monitor.ChannelNames(ii,:) = name;
+name=rffreq{ii,2}; AO.RF.Setpoint.ChannelNames(ii,:) = name;
+val =rffreq{ii,3}; AO.RF.Monitor.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Setpoint.HW2PhysicsParams(ii,1) = val;
+val =rffreq{ii,4}; AO.RF.Monitor.Physics2HWParams(ii,1) = val;
+ AO.RF.Setpoint.Physics2HWParams(ii,1) = val;
+val =rffreq{ii,5}; AO.RF.Setpoint.Range(ii,:) = val;
+val =rffreq{ii,6}; AO.RF.Setpoint.Tolerance(ii,1) = val;
+end
+
+
+for ii=1:size(rfphase,1)
+name=rfphase{ii,1}; AO.RF.PhaseCtrl.ChannelNames(ii,:) = name;
+name=rfphase{ii,2}; AO.RF.Phase.ChannelNames(ii,:) = name;
+val =rfphase{ii,3}; AO.RF.PhaseCtrl.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Phase.HW2PhysicsParams(ii,1) = val;
+val =rfphase{ii,4}; AO.RF.PhaseCtrl.Physics2HWParams(ii,1) = val;
+ AO.RF.Phase.Physics2HWParams(ii,1) = val;
+val =rfphase{ii,5}; AO.RF.PhaseCtrl.Range(ii,:) = val;
+ AO.RF.Phase.Range(ii,:) = val;
+val =rfphase{ii,6}; AO.RF.PhaseCtrl.Tolerance(ii,1) = val;
+ AO.RF.Phase.Tolerance(ii,1) = val;
+end
+
+
+for ii=1:size(rfvolt,1)
+name=rfvolt{ii,1}; AO.RF.VoltageCtrl.ChannelNames(ii,:) = name;
+name=rfvolt{ii,2}; AO.RF.Voltage.ChannelNames(ii,:) = name;
+val =rfvolt{ii,3}; AO.RF.VoltageCtrl.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Voltage.HW2PhysicsParams(ii,1) = val;
+val =rfvolt{ii,4}; AO.RF.VoltageCtrl.Physics2HWParams(ii,1) = val;
+ AO.RF.Voltage.Physics2HWParams(ii,1) = val;
+val =rfvolt{ii,5}; AO.RF.VoltageCtrl.Range(ii,:) = val;
+ AO.RF.Voltage.Range(ii,:) = val;
+val =rfvolt{ii,6}; AO.RF.VoltageCtrl.Tolerance(ii,1) = val;
+ AO.RF.Voltage.Tolerance(ii,1) = val;
+end
+
+
+for ii=1:size(rfpower,1)
+name=rfpower{ii,1}; AO.RF.PowerCtrl.ChannelNames(ii,:) = name;
+name=rfpower{ii,2}; AO.RF.Power.ChannelNames(ii,:) = name;
+name=rfpower{ii,3}; AO.RF.KlysPower.ChannelNames(ii,:) = name;
+val =rfpower{ii,4}; AO.RF.PowerCtrl.HW2PhysicsParams(ii,1) = val;
+ AO.RF.Power.HW2PhysicsParams(ii,1) = val;
+ AO.RF.KlysPower.HW2PhysicsParams(ii,1) = val;
+val =rfpower{ii,5}; AO.RF.PowerCtrl.Physics2HWParams(ii,1) = val;
+ AO.RF.Power.Physics2HWParams(ii,1) = val;
+ AO.RF.KlysPower.Physics2HWParams(ii,1) = val;
+val =rfpower{ii,6}; AO.RF.PowerCtrl.Range(ii,:) = val;
+ AO.RF.Power.Range(ii,:) = val;
+ AO.RF.KlysPower.Range(ii,:) = val;
+val =rfpower{ii,7}; AO.RF.PowerCtrl.Tolerance(ii,1) = val;
+ AO.RF.Power.Tolerance(ii,1) = val;
+ AO.RF.KlysPower.Tolerance(ii,1) = val;
+end
+
+%Frequency Readback
+AO.RF.Monitor.Mode = Mode;
+AO.RF.Monitor.DataType = 'Scalar';
+AO.RF.Monitor.Units = 'Hardware';
+AO.RF.Monitor.HWUnits = 'MHz';
+AO.RF.Monitor.PhysicsUnits = 'Hz';
+%Frequency Setpoint
+AO.RF.Setpoint.Mode = Mode;
+AO.RF.Setpoint.DataType = 'Scalar';
+AO.RF.Setpoint.Units = 'Hardware';
+AO.RF.Setpoint.HWUnits = 'MHz';
+AO.RF.Setpoint.PhysicsUnits = 'Hz';
+
+%Voltage control
+AO.RF.VoltageCtrl.Mode = Mode;
+AO.RF.VoltageCtrl.DataType = 'Scalar';
+AO.RF.VoltageCtrl.Units = 'Hardware';
+AO.RF.VoltageCtrl.HWUnits = 'Volts';
+AO.RF.VoltageCtrl.PhysicsUnits = 'Volts';
+
+%Voltage monitor
+AO.RF.Voltage.Mode = Mode;
+AO.RF.Voltage.DataType = 'Scalar';
+AO.RF.Voltage.Units = 'Hardware';
+AO.RF.Voltage.HWUnits = 'Volts';
+AO.RF.Voltage.PhysicsUnits = 'Volts';
+
+%Power Control
+AO.RF.PowerCtrl.Mode = Mode;
+AO.RF.PowerCtrl.DataType = 'Scalar';
+AO.RF.PowerCtrl.Units = 'Hardware';
+AO.RF.PowerCtrl.HWUnits = 'MWatts';
+AO.RF.PowerCtrl.PhysicsUnits = 'MWatts';
+
+%Power Monitor
+AO.RF.Power.Mode = Mode;
+AO.RF.Power.DataType = 'Scalar';
+AO.RF.Power.Units = 'Hardware';
+AO.RF.Power.HWUnits = 'MWatts';
+AO.RF.Power.PhysicsUnits = 'MWatts';
+
+%Klystron Forward Power
+AO.RF.KlysPower.Mode = Mode;
+AO.RF.KlysPower.DataType = 'Scalar';
+AO.RF.KlysPower.Units = 'Hardware';
+AO.RF.KlysPower.HWUnits = 'MWatts';
+AO.RF.KlysPower.PhysicsUnits = 'MWatts';
+
+%Station Phase Control
+AO.RF.PhaseCtrl.Mode = Mode;
+AO.RF.PhaseCtrl.DataType = 'Scalar';
+AO.RF.PhaseCtrl.Units = 'Hardware';
+AO.RF.PhaseCtrl.HWUnits = 'Degrees';
+AO.RF.PhaseCtrl.PhysicsUnits = 'Degrees';
+
+
+%Station Phase Monitor
+AO.RF.Phase.Mode = Mode;
+AO.RF.Phase.DataType = 'Scalar';
+AO.RF.Phase.Units = 'Hardware';
+AO.RF.Phase.HWUnits = 'Degrees';
+AO.RF.Phase.PhysicsUnits = 'Degrees';
+
+
+else
+%------------------------------------- 1 Cavity Case
+AO.RF.Status = 1;
+AO.RF.CommonNames = 'RF';
+AO.RF.DeviceList = [1 1];
+AO.RF.ElementList = [1];
+
+%Frequency Readback
+AO.RF.Monitor.Mode = Mode;
+AO.RF.Monitor.DataType = 'Scalar';
+AO.RF.Monitor.Units = 'Hardware';
+AO.RF.Monitor.HW2PhysicsParams = 1e+6; %no hw2physics function necessary
+AO.RF.Monitor.Physics2HWParams = 1e-6;
+AO.RF.Monitor.HWUnits = 'MHz';
+AO.RF.Monitor.PhysicsUnits = 'Hz';
+AO.RF.Monitor.ChannelNames = 'ASP:RFFreqSetpt';
+
+%Frequency Setpoint
+AO.RF.Setpoint.Mode = Mode;
+AO.RF.Setpoint.DataType = 'Scalar';
+AO.RF.Setpoint.Units = 'Hardware';
+AO.RF.Setpoint.HW2PhysicsParams = 1e+6;
+AO.RF.Setpoint.Physics2HWParams = 1e-6;
+AO.RF.Setpoint.HWUnits = 'MHz';
+AO.RF.Setpoint.PhysicsUnits = 'Hz';
+AO.RF.Setpoint.ChannelNames = 'ASP:RFFreqSetpt';
+AO.RF.Setpoint.Range = [0 2500];
+AO.RF.Setpoint.Tolerance = 100.0;
+
+%Voltage control
+AO.RF.VoltageCtrl.Mode = Mode;
+AO.RF.VoltageCtrl.DataType = 'Scalar';
+AO.RF.VoltageCtrl.Units = 'Hardware';
+AO.RF.VoltageCtrl.HW2PhysicsParams = 1;
+AO.RF.VoltageCtrl.Physics2HWParams = 1;
+AO.RF.VoltageCtrl.HWUnits = 'Volts';
+AO.RF.VoltageCtrl.PhysicsUnits = 'Volts';
+AO.RF.VoltageCtrl.ChannelNames = 'SRF1:STN:VOLT:CTRL';
+AO.RF.VoltageCtrl.Range = [-inf inf];
+AO.RF.VoltageCtrl.Tolerance = inf;
+
+%Voltage monitor
+AO.RF.Voltage.Mode = Mode;
+AO.RF.Voltage.DataType = 'Scalar';
+AO.RF.Voltage.Units = 'Hardware';
+AO.RF.Voltage.HW2PhysicsParams = 1;
+AO.RF.Voltage.Physics2HWParams = 1;
+AO.RF.Voltage.HWUnits = 'Volts';
+AO.RF.Voltage.PhysicsUnits = 'Volts';
+AO.RF.Voltage.ChannelNames = 'SRF1:STN:VOLT';
+AO.RF.Voltage.Range = [-inf inf];
+AO.RF.Voltage.Tolerance = inf;
+
+%Power Control
+AO.RF.PowerCtrl.Mode = Mode;
+AO.RF.PowerCtrl.DataType = 'Scalar';
+AO.RF.PowerCtrl.Units = 'Hardware';
+AO.RF.PowerCtrl.HW2PhysicsParams = 1;
+AO.RF.PowerCtrl.Physics2HWParams = 1;
+AO.RF.PowerCtrl.HWUnits = 'MWatts';
+AO.RF.PowerCtrl.PhysicsUnits = 'MWatts';
+AO.RF.PowerCtrl.ChannelNames = 'SRF1:KLYSDRIVFRWD:POWER:ON';
+AO.RF.PowerCtrl.Range = [-inf inf];
+AO.RF.PowerCtrl.Tolerance = inf;
+
+%Power Monitor
+AO.RF.Power.Mode = Mode;
+AO.RF.Power.DataType = 'Scalar';
+AO.RF.Power.Units = 'Hardware';
+AO.RF.Power.HW2PhysicsParams = 1;
+AO.RF.Power.Physics2HWParams = 1;
+AO.RF.Power.HWUnits = 'MWatts';
+AO.RF.Power.PhysicsUnits = 'MWatts';
+AO.RF.Power.ChannelNames = 'SRF1:KLYSDRIVFRWD:POWER';
+AO.RF.Power.Range = [-inf inf];
+AO.RF.Power.Tolerance = inf;
+
+%Klystron Forward Power
+AO.RF.KlysPower.Mode = Mode;
+AO.RF.KlysPower.DataType = 'Scalar';
+AO.RF.KlysPower.Units = 'Hardware';
+AO.RF.KlysPower.HW2PhysicsParams = 1;
+AO.RF.KlysPower.Physics2HWParams = 1;
+AO.RF.KlysPower.HWUnits = 'MWatts';
+AO.RF.KlysPower.PhysicsUnits = 'MWatts';
+AO.RF.KlysPower.ChannelNames = 'SRF1:KLYSOUTFRWD:POWER';
+AO.RF.KlysPower.Range = [-inf inf];
+AO.RF.KlysPower.Tolerance = inf;
+
+
+%Station Phase Control
+AO.RF.PhaseCtrl.Mode = Mode;
+AO.RF.PhaseCtrl.DataType = 'Scalar';
+AO.RF.PhaseCtrl.Units = 'Hardware';
+AO.RF.PhaseCtrl.HW2PhysicsParams = 1;
+AO.RF.PhaseCtrl.Physics2HWParams = 1;
+AO.RF.PhaseCtrl.HWUnits = 'Degrees';
+AO.RF.PhaseCtrl.PhysicsUnits = 'Degrees';
+AO.RF.PhaseCtrl.ChannelNames = 'SRF1:STN:PHASE';
+AO.RF.PhaseCtrl.Range = [-200 200];
+AO.RF.PhaseCtrl.Tolerance = inf;
+
+%Station Phase Monitor
+AO.RF.Phase.Mode = Mode;
+AO.RF.Phase.DataType = 'Scalar';
+AO.RF.Phase.Units = 'Hardware';
+AO.RF.Phase.HW2PhysicsParams = 1;
+AO.RF.Phase.Physics2HWParams = 1;
+AO.RF.Phase.HWUnits = 'Degrees';
+AO.RF.Phase.PhysicsUnits = 'Degrees';
+AO.RF.Phase.ChannelNames = 'SRF1:STN:PHASE:CALC';
+AO.RF.Phase.Range = [-200 200];
+AO.RF.Phase.Tolerance = inf;
+end
+
+
+
+%====
+%TUNE
+%====
+AO.TUNE.FamilyName = 'TUNE'; dispobject(AO,AO.TUNE.FamilyName);
+AO.TUNE.MemberOf = {'Tune'; 'Diagnostics'};
+AO.TUNE.CommonNames = ['xtune';'ytune';'stune'];
+AO.TUNE.DeviceList = [ 1 1; 1 2; 1 3];
+AO.TUNE.ElementList = [1 2 3]';
+AO.TUNE.Status = [1 1 0]';
+
+AO.TUNE.Monitor.Mode = Mode;
+AO.TUNE.Monitor.DataType = 'Vector';
+AO.TUNE.Monitor.DataTypeIndex = [1 2 3]';
+AO.TUNE.Monitor.ChannelNames = 'MeasTune';
+AO.TUNE.Monitor.Units = 'Hardware';
+AO.TUNE.Monitor.HW2PhysicsParams = 1;
+AO.TUNE.Monitor.Physics2HWParams = 1;
+AO.TUNE.Monitor.HWUnits = 'fractional tune';
+AO.TUNE.Monitor.PhysicsUnits = 'fractional tune';
+
+
+%====
+%DCCT
+%====
+AO.DCCT.FamilyName = 'DCCT'; dispobject(AO,AO.DCCT.FamilyName);
+AO.DCCT.MemberOf = {'Diagnostics'};
+AO.DCCT.CommonNames = 'DCCT';
+AO.DCCT.DeviceList = [1 1];
+AO.DCCT.ElementList = [1];
+AO.DCCT.Status = [1];
+
+AO.DCCT.Monitor.Mode = Mode;
+AO.DCCT.Monitor.DataType = 'Scalar';
+AO.DCCT.Monitor.ChannelNames = 'SR11BCM01:CURRENT_MONITOR';
+AO.DCCT.Monitor.Units = 'Hardware';
+AO.DCCT.Monitor.HWUnits = 'milli-ampere';
+AO.DCCT.Monitor.PhysicsUnits = 'ampere';
+AO.DCCT.Monitor.HW2PhysicsParams = 1e-3;
+AO.DCCT.Monitor.Physics2HWParams = 1000;
+
+
+% %==================
+% %Machine Parameters
+% %==================
+% Removed in this version, see pervious version for more info
+
+%======
+%Septum
+%======
+% ifam=ifam+1;
+% AO.Septum.FamilyName = 'Septum'; dispobject(AO,AO.Septum.FamilyName);
+% AO.Septum.MemberOf = {'Injection'};
+% AO.Septum.Status = 1;
+%
+% AO.Septum.CommonNames = 'Septum ';
+% AO.Septum.DeviceList = [3 1];
+% AO.Septum.ElementList = [1];
+%
+% AO.Septum.Monitor.Mode = Mode;
+% AO.Septum.Monitor.DataType = 'Scalar';
+% AO.Septum.Monitor.Units = 'Hardware';
+% AO.Septum.Monitor.HWUnits = 'ampere';
+% AO.Septum.Monitor.PhysicsUnits = 'radian';
+% AO.Septum.Monitor.ChannelNames = 'BTS-B9V:Curr';
+%
+% AO.Septum.Setpoint.Mode = Mode;
+% AO.Septum.Setpoint.DataType = 'Scalar';
+% AO.Septum.Setpoint.Units = 'Hardware';
+% AO.Septum.Setpoint.HWUnits = 'ampere';
+% AO.Septum.Setpoint.PhysicsUnits = 'radian';
+% AO.Septum.Setpoint.ChannelNames = 'BTS-B9V:CurrSetpt';
+% AO.Septum.Setpoint.Range = [0, 2500];
+% AO.Septum.Setpoint.Tolerance = 100.0;
+%
+% AO.Septum.Monitor.HW2PhysicsParams = 1;
+% AO.Septum.Monitor.Physics2HWParams = 1;
+% AO.Septum.Setpoint.HW2PhysicsParams = 1;
+% AO.Septum.Setpoint.Physics2HWParams = 1;
+
+
+%====================
+%Photon Beamline Data
+%====================
+% >> removed >> see previous versions if info needed
+
+%====================
+%BPLD Data
+%====================
+% >> removed >> see previous versions if info needed
+
+
+
+% The operational mode sets the path, filenames, and other important parameters
+% Run setoperationalmode after most of the AO is built so that the Units and Mode fields
+% can be set in setoperationalmode
+fprintf('\n');
+setao(AO);
+setoperationalmode(OperationalMode);
+AO = getao;
+
+
+%%%%%%%%%%%%%%%%
+% DeltaRespMat %
+%%%%%%%%%%%%%%%%
+
+% I remove the physics2hw conversion because the physics2hw is
+% is calibrated yet.
+
+% Set response matrix kick size in hardware units (amps)
+AO.HCM.Setpoint.DeltaRespMat = physics2hw('HCM', 'Setpoint', .15e-3 / 3, AO.HCM.DeviceList);
+AO.VCM.Setpoint.DeltaRespMat = physics2hw('VCM', 'Setpoint', .15e-3 / 3, AO.VCM.DeviceList);
+
+%% 'NoEnergyScaling' because I don't want to force a BEND magnet read at this point
+%AO.HCM.Setpoint.DeltaRespMat = mm2amps('HCM', .5, AO.HCM.DeviceList, 'NoEnergyScaling');
+%AO.VCM.Setpoint.DeltaRespMat = mm2amps('VCM', .5, AO.VCM.DeviceList, 'NoEnergyScaling');
+
+
+AO.QFA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFA.FamilyName, 'Setpoint', AO.QFA.Setpoint.DeltaRespMat, AO.QFA.DeviceList);
+AO.QFB.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QFB.FamilyName, 'Setpoint', AO.QFB.Setpoint.DeltaRespMat, AO.QFB.DeviceList);
+AO.QDA.Setpoint.DeltaRespMat = .2; %physics2hw(AO.QDA.FamilyName, 'Setpoint', AO.QDA.Setpoint.DeltaRespMat, AO.QDA.DeviceList);
+
+
+AO.SFA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFA.FamilyName, 'Setpoint', AO.SFA.Setpoint.DeltaRespMat, AO.SFA.DeviceList);
+AO.SFB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SFB.FamilyName, 'Setpoint', AO.SFB.Setpoint.DeltaRespMat, AO.SFB.DeviceList);
+AO.SDA.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDA.FamilyName, 'Setpoint', AO.SDA.Setpoint.DeltaRespMat, AO.SDA.DeviceList);
+AO.SDB.Setpoint.DeltaRespMat = 3; %physics2hw(AO.SDB.FamilyName, 'Setpoint', AO.SDB.Setpoint.DeltaRespMat, AO.SDB.DeviceList);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Get S-positions [meters] %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Using ...ATIndex(:,1) will accomodata for split elements where the first
+% of a group of elements is put in the first column ie, if SFA is split in
+% two then ATIndex will look like [2 3; 11 12; ...] where each row is a
+% magnet and column represents each split.
+global THERING
+AO.BPMx.Position = findspos(THERING, AO.BPMx.AT.ATIndex(:,1))';
+AO.BPMy.Position = findspos(THERING, AO.BPMy.AT.ATIndex(:,1))';
+AO.FTx.Position = findspos(THERING, AO.FTx.AT.ATIndex(:,1))';
+AO.FTy.Position = findspos(THERING, AO.FTy.AT.ATIndex(:,1))';
+AO.HCM.Position = findspos(THERING, AO.HCM.AT.ATIndex(:,1))';
+AO.VCM.Position = findspos(THERING, AO.VCM.AT.ATIndex(:,1))';
+AO.QFA.Position = findspos(THERING, AO.QFA.AT.ATIndex(:,1))';
+AO.QDA.Position = findspos(THERING, AO.QDA.AT.ATIndex(:,1))';
+AO.QFB.Position = findspos(THERING, AO.QFB.AT.ATIndex(:,1))';
+AO.SFA.Position = findspos(THERING, AO.SFA.AT.ATIndex(:,1))';
+AO.SFB.Position = findspos(THERING, AO.SFB.AT.ATIndex(:,1))';
+AO.SDA.Position = findspos(THERING, AO.SDA.AT.ATIndex(:,1))';
+AO.SDB.Position = findspos(THERING, AO.SDB.AT.ATIndex(:,1))';
+AO.SKQ.Position = findspos(THERING, AO.SKQ.AT.ATIndex(:,1))';
+AO.BEND.Position = findspos(THERING, AO.BEND.AT.ATIndex(:,1))';
+AO.RF.Position = findspos(THERING, AO.RF.AT.ATIndex(:,1))';
+AO.KICK.Position = findspos(THERING, AO.KICK.AT.ATIndex(:,1))';
+AO.DCCT.Position = 0;
+AO.TUNE.Position = 0;
+
+
+% Save AO
+setao(AO);
+
+
+function dispobject(AO,name)
+
+n = length(fieldnames(AO));
+
+if n > 0
+ fprintf(' %10s ',name);
+ if mod(n,5) == 0
+ fprintf('\n');
+ end
end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/assr4.m b/machine/ASP/StorageRing/assr4.m
index 717b646a..51959daa 100644
--- a/machine/ASP/StorageRing/assr4.m
+++ b/machine/ASP/StorageRing/assr4.m
@@ -22,7 +22,9 @@ function assr4(varargin)
GLOBVAL.LatticeFile = mfilename;
FAMLIST = cell(0);
-L0 = 2.159946602239996e+02; % calculated using findspos %215.9945540689991;% with new dipole path lengths. Designed for 216m.
+L0 = 2.159946602239996e+02; % calculated using findspos
+L0 = 2.159945540689997e+02;% with new dipole path lengths. Designed for 216m. 28/4/2010 Eugene
+
C0 = 299792458; % speed of light [m/s]
HarmNumber = 360;
@@ -37,12 +39,15 @@ function assr4(varargin)
% ap = aperture('AP',[-32 17 -16 16]*1e-3,'AperturePass');
ap = aperture('AP',[-16 17 -16 16]*1e2,'AperturePass');
+% Quadrupole field extent on one end past the magnet iron length as
+% measured by RMIT student Neville.
+quadDL_2 = 0.0042;
d1 = drift('D1' ,2.698300e+000,'DriftPass'); % (2.698286 -> to get closer to the design distance of 216m)
-d2 = drift('D2' ,1.900000e-001,'DriftPass');
-d3 = drift('D3' ,1.650000e-001,'DriftPass');
+d2 = drift('D2' ,1.900000e-001-quadDL_2,'DriftPass');
+d3 = drift('D3' ,1.650000e-001-quadDL_2,'DriftPass');
d4 = drift('D4' ,2.750000e-001,'DriftPass');
-d5 = drift('D5' ,1.550000e-001,'DriftPass');
-d6 = drift('D6' ,4.500000e-001,'DriftPass');
+d5 = drift('D5' ,1.550000e-001-quadDL_2,'DriftPass');
+d6 = drift('D6' ,4.500000e-001-quadDL_2*2,'DriftPass');
% Modified drifts around BPM sections.
bpm = monitor('BPM' ,'IdentityPass');
@@ -58,15 +63,30 @@ function assr4(varargin)
d2b = drift('D2B' , 1.030000e-001,'DriftPass');
% Dipoles
-% design -> rbend('BEND',1.726000e+000,2.243995e-001,1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
+% design -> rbend('BEND',1.726000e+000,2.243995e-001,...
+% 1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
% From numerical studies -> L: 1.72579121675e+000
% K: 0.33295132
% Sext: 0.01092687
% Oct: 0.15166053
-scalek = 0.98855592463187;
-edge_offset = 0.03603626237179;
-dip1 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'BndMPoleSymplectic4Pass');
-dip2 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'BndMPoleSymplectic4Pass');
+% 1.006150825679126; % scaling factor for chromaticity comparison Eugene
+% 24/1/2008
+scalek = 1;
+edge_offset = 0.01;
+dip1 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'BndMPoleSymplectic4E2Pass');
+dip2 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'BndMPoleSymplectic4E2Pass');
+FAMLIST{dip1}.ElemData.PolynomA = [0 0 0 0];
+FAMLIST{dip1}.ElemData.PolynomB = [0 -0.33295132*scalek -.05 0];
+FAMLIST{dip1}.ElemData.FullGap = 0.045;
+FAMLIST{dip1}.ElemData.FringeInt1 = 0.5;
+FAMLIST{dip1}.ElemData.FringeInt2 = 0.5;
+FAMLIST{dip2}.ElemData.PolynomA = [0 0 0 0];
+FAMLIST{dip2}.ElemData.PolynomB = [0 -0.33295132*scalek -.05 0];
+FAMLIST{dip2}.ElemData.FullGap = 0.045;
+FAMLIST{dip2}.ElemData.FringeInt1 = 0.5;
+FAMLIST{dip2}.ElemData.FringeInt2 = 0.5;
+
+
% Quadrupoles (for design dipole: [QFA,QDA,QFB]=[1.761741,-1.038377,1.533802];
% To match new dipole values from numerical studies
@@ -76,18 +96,37 @@ function assr4(varargin)
% qfb = quadrupole('QFB' ,3.550000e-001, 1.5406418e+000,'QuadLinearPass');
% To match split dipole values from numerical studies (SBENDS)
% tune of 13.29, 5.216 and 0 dispersion in straights.
-qfa = quadrupole('QFA' ,3.550000e-001, 1.76272982211693,'QuadLinearPass');
-qda = quadrupole('QDA' ,1.800000e-001,-1.06276736743823,'QuadLinearPass');
-qfb = quadrupole('QFB' ,3.550000e-001, 1.53992875479511,'QuadLinearPass');
+% qfa = quadrupole('QFA' ,3.550000e-001, 1.76272982211693,'QuadLinearPass');
+% qda = quadrupole('QDA' ,1.800000e-001,-1.06276736743823,'QuadLinearPass');
+% qfb = quadrupole('QFB' ,3.550000e-001, 1.53992875479511,'QuadLinearPass');
+% Match single bends above to tune of 13.29, 5.216 and 0 dispersion. EUgene
+% 9/2/2009
+qfa = quadrupole('QFA' ,3.550000e-001 + quadDL_2*2, 1.762632151326440/1.0282,'StrMPoleSymplectic4Pass');
+qda = quadrupole('QDA' ,1.800000e-001 + quadDL_2*2,-1.064480621954161/1.0555,'StrMPoleSymplectic4Pass');
+qfb = quadrupole('QFB' ,3.550000e-001 + quadDL_2*2, 1.540311343769903/1.0282,'StrMPoleSymplectic4Pass');
+
% Sextupoles with built in correctors. Corrector settings given by kick
% angle in radians.
-sfa = sextcorr('SFA' ,2.000000e-001, 1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
-sda = sextcorr('SDA' ,2.000000e-001,-1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
-sdb = sextcorr('SDB' ,2.000000e-001,-7.014635e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
-sfb = sextcorr('SFB' ,2.000000e-001, 7.189346e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
-
+if exist('StrCorrMPoleSymplectic4Pass') == 3
+ % Old AT 1.3
+ sfa = sextcorr('SFA' ,2.000000e-001, 1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
+ sda = sextcorr('SDA' ,2.000000e-001,-1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
+ sdb = sextcorr('SDB' ,2.000000e-001,-7.014635e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
+ sfb = sextcorr('SFB' ,2.000000e-001, 7.189346e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
+else
+ sfa = sextupole('SFA' ,2.000000e-001, 1.400000e+001,'StrMPoleSymplectic4Pass');
+ sda = sextupole('SDA' ,2.000000e-001,-1.400000e+001,'StrMPoleSymplectic4Pass');
+ sdb = sextupole('SDB' ,2.000000e-001,-7.098322,'StrMPoleSymplectic4Pass');
+ sfb = sextupole('SFB' ,2.000000e-001, 7.271212,'StrMPoleSymplectic4Pass');
+
+ FAMLIST{sfa}.ElemData.KickAngle = [0 0];
+ FAMLIST{sda}.ElemData.KickAngle = [0 0];
+ FAMLIST{sfb}.ElemData.KickAngle = [0 0];
+ FAMLIST{sdb}.ElemData.KickAngle = [0 0];
+end
+
% RF cavity and the corresponding straight used to position the cavity.
% 4.996540652069698e+008 old freq for 216m for 216.0004 its different. Also
% we are using ThinCavities therefore the drifts have to be set
@@ -181,7 +220,8 @@ function assr4(varargin)
% Definition of the types of rings
kickring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
cavity1ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];;
-cavity4ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_4 celrf07_4 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+% cavity4ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_4 celrf07_4 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+cavity4ring = [ ap unit_cel unit_cel unit_cel unit_cel unit_cel celrf06_4 celrf07_4 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel];
fullring_startwithRF = [ ap cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 ];
ring = [ ap unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
diff --git a/machine/ASP/StorageRing/assr4_disp.m b/machine/ASP/StorageRing/assr4_disp.m
index 2e4d74bc..d1e5cb5e 100644
--- a/machine/ASP/StorageRing/assr4_disp.m
+++ b/machine/ASP/StorageRing/assr4_disp.m
@@ -58,13 +58,14 @@ function assr4(varargin)
d2b = drift('D2B' , 1.030000e-001,'DriftPass');
% Dipoles
-% design -> rbend_asp('BEND',1.726000e+000,2.243995e-001,1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
+% design -> rbend('BEND',1.726000e+000,2.243995e-001,...
+% 1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
% From numerical studies -> L: 1.72579121675e+000
% K: 0.33295132
% Sext: 0.01092687
% Oct: 0.15166053
-dip1 = rbend_asp('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BndMPoleSymplectic4Pass');
-dip2 = rbend_asp('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BndMPoleSymplectic4Pass');
+dip1 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BndMPoleSymplectic4Pass');
+dip2 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BndMPoleSymplectic4Pass');
scalek = 1;
leftdrift_a = drift('leftdrift',0.076,'DriftPass');
@@ -72,38 +73,38 @@ function assr4(varargin)
rightdrift_b = drift('rightdrift',0.064,'DriftPass');
rightdrift_a = drift('rightdrift',0.0887292346-len(rightdrift_b),'DriftPass');
-% b_left01 = rbend_asp('b_left01',0.0695312761,0.0001684486,0.0000000000,0.0000000000,-0.0058550750*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0058550750*scalek 0.0862147892 -1.2289013273]);
-% b_left02 = rbend_asp('b_left02',0.0695282915,0.0007117061,0.0000000000,0.0000000000,-0.0239389168*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0239389168*scalek -0.0583359949 -0.0632750927]);
-% b_left03 = rbend_asp('b_left03',0.0695152451,0.0032675350,0.0000000000,0.0000000000,-0.2254325358*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.2254325358*scalek 0.2451727966 -0.1103893288]);
-% b_left04 = rbend_asp('b_left04',0.0694679183,0.0087995936,0.0000000000,0.0000000000,-0.4158165694*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.4158165694*scalek -0.1443627022 0.6681103839]);
-% b_left05 = rbend_asp('b_left05',0.0694041758,0.0092692887,0.0000000000,0.0000000000,-0.3298403749*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3298403749*scalek -0.0340207205 0.3349521492]);
-% b_centre01 = rbend_asp('b_centre01',0.2820465390,0.0367531161,0.0000000000,0.0000000000,-0.3315842393*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3315842393*scalek 0.0083655817 0.2965845308]);
-% b_centre02 = rbend_asp('b_centre02',0.2815037989,0.0354072994,0.0000000000,0.0000000000,-0.3306516396*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3306516396*scalek 0.0236710994 -0.2196079070]);
-% b_centre03 = rbend_asp('b_centre03',0.2813281018,0.0349189639,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673 -0.5218735605]);
-% b_centre04 = rbend_asp('b_centre04',0.2814996751,0.0353946664,0.0000000000,0.0000000000,-0.3302155286*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3302155286*scalek 0.0236248098 -0.2148826863]);
-% b_centre05 = rbend_asp('b_centre05',0.2820380879,0.0367421671,0.0000000000,0.0000000000,-0.3312220213*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3312220213*scalek 0.0103909753 0.2969171603]);
-% b_right01 = rbend_asp('b_right01',0.0694014448,0.0092683157,0.0000000000,0.0000000000,-0.3292611055*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3292611055*scalek -0.0291322494 0.3681905186]);
-% b_right02 = rbend_asp('b_right02',0.0694650575,0.0090036557,0.0000000000,0.0000000000,-0.3961176951*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3961176951*scalek -0.1539214712 0.9528854933]);
-% b_right03 = rbend_asp('b_right03',0.0695141539,0.0037120061,0.0000000000,0.0000000000,-0.2701751814*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.2701751814*scalek 0.3742213022 0.7022676128]);
-% b_right04 = rbend_asp('b_right04',0.0695280819,0.0007962279,0.0000000000,0.0000000000,-0.0288159660*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0288159660*scalek -0.0571472318 0.2460706289]);
-% b_right05 = rbend_asp('b_right05',0.0695312501,0.0001902235,0.0000000000,0.0000000000,-0.0028161106*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0028161106*scalek -0.1077402629 0.7697020810]);
-
-% rbend_asp
-b_left01 = rbend_asp('b_left01',0.0695312761,0.0001700782,0.1121962211,-0.1120187381,0.0026580668*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0026580668*scalek -0.0222542890 -0.0307698880]);
-b_left02 = rbend_asp('b_left02',0.0695282915,0.0007118132,0.1120187381,-0.1112734474,0.0004302895*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0004302895*scalek -0.0824996146 -0.0652385243]);
-b_left03 = rbend_asp('b_left03',0.0695152451,0.0032678721,0.1112734474,-0.1078414785,-0.1045888695*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.1045888695*scalek -0.0928717833 0.2254072448]);
-b_left04 = rbend_asp('b_left04',0.0694679183,0.0088002187,0.1078414785,-0.0989182337,-0.3486275471*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3486275471*scalek -0.0656081148 0.3572852967]);
-b_left05 = rbend_asp('b_left05',0.0694041758,0.0092692888,0.0989182337,-0.0896518010,-0.3281526271*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3281526271*scalek -0.0355726539 0.3355904266]);
-b_centre01 = rbend_asp('b_centre01',0.2820465390,0.0367531221,0.0896518010,-0.0529125655,-0.3312315118*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3312315118*scalek 0.0081060667 0.2963931827]);
-b_centre02 = rbend_asp('b_centre02',0.2815037989,0.0354072962,0.0529125655,-0.0175134439,-0.3306429237*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3306429237*scalek 0.0237264198 -0.2192733272]);
-b_centre03 = rbend_asp('b_centre03',0.2813281018,0.0349189640,0.0175134439,0.0174054578,-0.3300984023*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300984023*scalek 0.0101509428 -0.5218382720]);
-b_centre04 = rbend_asp('b_centre04',0.2814996751,0.0353946633,-0.0174054578,0.0528080683,-0.3302048119*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3302048119*scalek 0.0235987043 -0.2144554284]);
-b_centre05 = rbend_asp('b_centre05',0.2820380879,0.0367421699,-0.0528080683,0.0895641319,-0.3309037380*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3309037380*scalek 0.0102169077 0.2963545009]);
-b_right01 = rbend_asp('b_right01',0.0694014448,0.0092683188,-0.0895641319,0.0988345428,-0.3275972520*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3275972520*scalek -0.0308930090 0.3680490900]);
-b_right02 = rbend_asp('b_right02',0.0694650575,0.0090032960,-0.0988345428,0.1077882518,-0.3467634133*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3467634133*scalek -0.0345063628 0.6218385567]);
-b_right03 = rbend_asp('b_right03',0.0695141539,0.0037116695,-0.1077882518,0.1112699557,-0.1347732139*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.1347732139*scalek 0.0189958278 0.8526578807]);
-b_right04 = rbend_asp('b_right04',0.0695280819,0.0007961566,-0.1112699557,0.1120205593,-0.0014988960*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0014988960*scalek -0.0849450391 0.2100836063]);
-b_right05 = rbend_asp('b_right05',0.0695312501,0.0001897883,-0.1120205593,0.1121997376,0.0026764692*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0026764692*scalek -0.0276971797 0.0360627830]);
+% b_left01 = rbend('b_left01',0.0695312761,0.0001684486,0.0000000000,0.0000000000,-0.0058550750*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0058550750*scalek 0.0862147892 -1.2289013273]);
+% b_left02 = rbend('b_left02',0.0695282915,0.0007117061,0.0000000000,0.0000000000,-0.0239389168*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0239389168*scalek -0.0583359949 -0.0632750927]);
+% b_left03 = rbend('b_left03',0.0695152451,0.0032675350,0.0000000000,0.0000000000,-0.2254325358*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.2254325358*scalek 0.2451727966 -0.1103893288]);
+% b_left04 = rbend('b_left04',0.0694679183,0.0087995936,0.0000000000,0.0000000000,-0.4158165694*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.4158165694*scalek -0.1443627022 0.6681103839]);
+% b_left05 = rbend('b_left05',0.0694041758,0.0092692887,0.0000000000,0.0000000000,-0.3298403749*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3298403749*scalek -0.0340207205 0.3349521492]);
+% b_centre01 = rbend('b_centre01',0.2820465390,0.0367531161,0.0000000000,0.0000000000,-0.3315842393*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3315842393*scalek 0.0083655817 0.2965845308]);
+% b_centre02 = rbend('b_centre02',0.2815037989,0.0354072994,0.0000000000,0.0000000000,-0.3306516396*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3306516396*scalek 0.0236710994 -0.2196079070]);
+% b_centre03 = rbend('b_centre03',0.2813281018,0.0349189639,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673 -0.5218735605]);
+% b_centre04 = rbend('b_centre04',0.2814996751,0.0353946664,0.0000000000,0.0000000000,-0.3302155286*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3302155286*scalek 0.0236248098 -0.2148826863]);
+% b_centre05 = rbend('b_centre05',0.2820380879,0.0367421671,0.0000000000,0.0000000000,-0.3312220213*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3312220213*scalek 0.0103909753 0.2969171603]);
+% b_right01 = rbend('b_right01',0.0694014448,0.0092683157,0.0000000000,0.0000000000,-0.3292611055*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3292611055*scalek -0.0291322494 0.3681905186]);
+% b_right02 = rbend('b_right02',0.0694650575,0.0090036557,0.0000000000,0.0000000000,-0.3961176951*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3961176951*scalek -0.1539214712 0.9528854933]);
+% b_right03 = rbend('b_right03',0.0695141539,0.0037120061,0.0000000000,0.0000000000,-0.2701751814*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.2701751814*scalek 0.3742213022 0.7022676128]);
+% b_right04 = rbend('b_right04',0.0695280819,0.0007962279,0.0000000000,0.0000000000,-0.0288159660*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0288159660*scalek -0.0571472318 0.2460706289]);
+% b_right05 = rbend('b_right05',0.0695312501,0.0001902235,0.0000000000,0.0000000000,-0.0028161106*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0028161106*scalek -0.1077402629 0.7697020810]);
+
+% RBEND
+b_left01 = rbend('b_left01',0.0695312761,0.0001700782,0.1121962211,-0.1120187381,0.0026580668*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0026580668*scalek -0.0222542890 -0.0307698880]);
+b_left02 = rbend('b_left02',0.0695282915,0.0007118132,0.1120187381,-0.1112734474,0.0004302895*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0004302895*scalek -0.0824996146 -0.0652385243]);
+b_left03 = rbend('b_left03',0.0695152451,0.0032678721,0.1112734474,-0.1078414785,-0.1045888695*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.1045888695*scalek -0.0928717833 0.2254072448]);
+b_left04 = rbend('b_left04',0.0694679183,0.0088002187,0.1078414785,-0.0989182337,-0.3486275471*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3486275471*scalek -0.0656081148 0.3572852967]);
+b_left05 = rbend('b_left05',0.0694041758,0.0092692888,0.0989182337,-0.0896518010,-0.3281526271*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3281526271*scalek -0.0355726539 0.3355904266]);
+b_centre01 = rbend('b_centre01',0.2820465390,0.0367531221,0.0896518010,-0.0529125655,-0.3312315118*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3312315118*scalek 0.0081060667 0.2963931827]);
+b_centre02 = rbend('b_centre02',0.2815037989,0.0354072962,0.0529125655,-0.0175134439,-0.3306429237*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3306429237*scalek 0.0237264198 -0.2192733272]);
+b_centre03 = rbend('b_centre03',0.2813281018,0.0349189640,0.0175134439,0.0174054578,-0.3300984023*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300984023*scalek 0.0101509428 -0.5218382720]);
+b_centre04 = rbend('b_centre04',0.2814996751,0.0353946633,-0.0174054578,0.0528080683,-0.3302048119*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3302048119*scalek 0.0235987043 -0.2144554284]);
+b_centre05 = rbend('b_centre05',0.2820380879,0.0367421699,-0.0528080683,0.0895641319,-0.3309037380*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3309037380*scalek 0.0102169077 0.2963545009]);
+b_right01 = rbend('b_right01',0.0694014448,0.0092683188,-0.0895641319,0.0988345428,-0.3275972520*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3275972520*scalek -0.0308930090 0.3680490900]);
+b_right02 = rbend('b_right02',0.0694650575,0.0090032960,-0.0988345428,0.1077882518,-0.3467634133*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3467634133*scalek -0.0345063628 0.6218385567]);
+b_right03 = rbend('b_right03',0.0695141539,0.0037116695,-0.1077882518,0.1112699557,-0.1347732139*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.1347732139*scalek 0.0189958278 0.8526578807]);
+b_right04 = rbend('b_right04',0.0695280819,0.0007961566,-0.1112699557,0.1120205593,-0.0014988960*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0014988960*scalek -0.0849450391 0.2100836063]);
+b_right05 = rbend('b_right05',0.0695312501,0.0001897883,-0.1120205593,0.1121997376,0.0026764692*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0026764692*scalek -0.0276971797 0.0360627830]);
newbend = [leftdrift_a bpm leftdrift_b b_left01 b_left02 b_left03 b_left04 ...
b_left05 b_centre01 b_centre02 b_centre03 b_centre04 ...
diff --git a/machine/ASP/StorageRing/assr4_id.m b/machine/ASP/StorageRing/assr4_id.m
index f6ee4e3f..cc79eb5e 100644
--- a/machine/ASP/StorageRing/assr4_id.m
+++ b/machine/ASP/StorageRing/assr4_id.m
@@ -65,10 +65,17 @@ function assr4(varargin)
% K: 0.33295132
% Sext: 0.01092687
% Oct: 0.15166053
-scalek = 0.98855592463187;
-edge_offset = 0.03603626237179;
-dip1 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'BndMPoleSymplectic4Pass');
-dip2 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'BndMPoleSymplectic4Pass');
+scalek = 1;
+edge_offset = 0.01;
+dip1 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'BndMPoleSymplectic4E2Pass');
+dip2 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'BndMPoleSymplectic4E2Pass');
+FAMLIST{dip1}.ElemData.FullGap = 0.045;
+FAMLIST{dip1}.ElemData.FringeInt1 = 0.5;
+FAMLIST{dip1}.ElemData.FringeInt2 = 0.5;
+FAMLIST{dip2}.ElemData.FullGap = 0.045;
+FAMLIST{dip2}.ElemData.FringeInt1 = 0.5;
+FAMLIST{dip2}.ElemData.FringeInt2 = 0.5;
+
% Quadrupoles (for design dipole: [QFA,QDA,QFB]=[1.761741,-1.038377,1.533802];
% To match new dipole values from numerical studies
@@ -91,28 +98,153 @@ function assr4(varargin)
sfb = sextcorr('SFB' ,2.000000e-001, 7.189346e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
% Define the wiggler as a 6x6 matrix element pass
-wig = marker('wig','Matrix66Pass');
+
+id01 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{id01}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+id02 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{id02}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+ivu_sector3 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{ivu_sector3}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+id04 = marker('wig','Matrix66Pass');
L = 0;
Kx = 0; Ky = 0;
-FAMLIST{wig}.ElemData.M66 = [1 L 0 0 0 0;
+FAMLIST{id04}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+ivu_sector5 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{ivu_sector5}.ElemData.M66 = [1 L 0 0 0 0;
Kx 1 0 0 0 0;
0 0 1 L 0 0;
0 0 Ky 1 0 0;
0 0 0 0 1 0;
0 0 0 0 0 1];
+id06 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{id06}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+id07 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{id07}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+id08 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{id08}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+id09 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{id09}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+id10 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{id10}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+id11 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{id11}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+
+wig_12 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{wig_12}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+ivu_sector13 = marker('wig','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{ivu_sector13}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
% Define the APPLE2 as a 6x6 matrix element pass
-app = marker('wig','Matrix66Pass');
+EPU_14 = marker('wig','Matrix66Pass');
L = 0;
Kx = 0; Ky = 0;
-FAMLIST{app}.ElemData.M66 = [1 L 0 0 0 0;
+FAMLIST{EPU_14}.ElemData.M66 = [1 L 0 0 0 0;
Kx 1 0 0 0 0;
0 0 1 L 0 0;
0 0 Ky 1 0 0;
0 0 0 0 1 0;
0 0 0 0 0 1];
+
+
+
+
+
% RF cavity and the corresponding straight used to position the cavity.
% 4.996540652069698e+008 old freq for 216m for 216.0004 its different. Also
% we are using ThinCavities therefore the drifts have to be set
@@ -213,7 +345,7 @@ function assr4(varargin)
%fast feedback kicker included:
ffbring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel celffb10_1 unit_cel unit_cel unit_cel celkick14];
% wiggler ring (based on cavity4ring). Wiggler in sector 12
-wigring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_4 celrf07_4 unit_cel unit_cel unit_cel unit_cel wig unit_cel unit_cel app celkick14];
+wigring = [ ap id01 celkick01 id02 unit_cel ivu_sector3 unit_cel id04 unit_cel ivu_sector5 unit_cel id06 celrf06_4 id07 celrf07_4 id08 unit_cel id09 unit_cel id10 unit_cel id11 unit_cel wig_12 unit_cel ivu_sector13 unit_cel EPU_14 celkick14];
% Choose which lattice to load else load "fullring" as the default.
if nargin > 0
diff --git a/machine/ASP/StorageRing/assr4_modbend.m b/machine/ASP/StorageRing/assr4_modbend.m
new file mode 100644
index 00000000..646af0b5
--- /dev/null
+++ b/machine/ASP/StorageRing/assr4_modbend.m
@@ -0,0 +1,242 @@
+function assr4(varargin)
+% Lattice definition file - generated by dimad2at v1.300000
+%
+% Eugene 2004-12-13 Updating the generalised file to realign the family
+% names and elements with aspinit. NOTE: aspinit will not work with split
+% elements... not without modification of the init file.
+%
+% Eugene 2005-09-16 Standardise all lattices being used to this. "Custom"
+% versions of the lattice files, eg for ML, ID studies etc will take this
+% file as a template. The following major changes were made -
+% * All family names in CAPS in line with ALS and SPEAR convention.
+% * Dipole path and gradient updated to reflect numerical studies on
+% measured data. Quadrupole values fitted for a tune of 13.3, 5.2 and
+% zero dispersion given the new dipole gradient fields.
+% * Merged with "aspsr_msrf.m" with independent/individual cavitie(s).
+% * Element positions/lengths should be inline with engineering
+% drawings.
+
+global FAMLIST THERING GLOBVAL
+
+GLOBVAL.E0 = 3e9;
+GLOBVAL.LatticeFile = mfilename;
+FAMLIST = cell(0);
+
+L0 = 2.159946602239996e+02; % calculated using findspos %215.9945540689991;% with new dipole path lengths. Designed for 216m.
+C0 = 299792458; % speed of light [m/s]
+HarmNumber = 360;
+
+disp(' ');
+fprintf('*** Loading lattice from %s.m ***\n',GLOBVAL.LatticeFile);
+
+% With AT1.3 ringpass and linepass, particles limited by the apperturepass
+% will have [x,x',y,y',delta,dl] = [NaN,0,0,0,0,0]. All pass methods will
+% check for this and do nothing to particles with these coordinates.
+% Ring/linepass will both return particle positions as well as the number
+% of turns the particles achieved.
+% ap = aperture('AP',[-32 17 -16 16]*1e-3,'AperturePass');
+ap = aperture('AP',[-16 17 -16 16]*1e2,'AperturePass');
+
+d1 = drift('D1' ,2.698300e+000,'DriftPass'); % (2.698286 -> to get closer to the design distance of 216m)
+d2 = drift('D2' ,1.900000e-001,'DriftPass');
+d3 = drift('D3' ,1.650000e-001,'DriftPass');
+d4 = drift('D4' ,2.750000e-001,'DriftPass');
+d5 = drift('D5' ,1.550000e-001,'DriftPass');
+d6 = drift('D6' ,4.500000e-001,'DriftPass');
+
+% Modified drifts around BPM sections.
+bpm = monitor('BPM' ,'IdentityPass');
+d1a = drift('D1A' ,len(d1)-3.942860e-001,'DriftPass'); % 2.304000e+000
+d1b = drift('D1B' , 3.942860e-001,'DriftPass');
+d1aa= drift('D1A' ,len(d1)-0.58,'DriftPass'); % Last bpm
+d1bb= drift('D1B' , 0.58,'DriftPass');
+d4a = drift('D4A' ,len(d4)-1.990000e-001,'DriftPass'); % 7.600000e-002
+d4b = drift('D4B' , 1.990000e-001,'DriftPass');
+d4aa = drift('D4AA' ,len(d4)-6.400000e-002,'DriftPass'); % 2.110000e-001
+d4bb = drift('D4BB' , 6.400000e-002,'DriftPass');
+d2a = drift('D2A' ,len(d2)-1.030000e-001,'DriftPass'); % 8.700000e-002
+d2b = drift('D2B' , 1.030000e-001,'DriftPass');
+
+% Dipoles
+% design -> rbend('BEND',1.726000e+000,2.243995e-001,...
+% 1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
+% From numerical studies -> L: 1.72579121675e+000
+% K: 0.33295132
+% Sext: 0.01092687
+% Oct: 0.15166053
+% 1.006150825679126; % scaling factor for chromaticity comparison Eugene
+% 24/1/2008
+scalek = 1; 0.981726405990326;
+0.981726405990326; % with edge offset
+0.995226405990326; % without edge offset
+0.98855592463187*(1-(1/3000));
+edge_offset = 0.012; 0.03603626237179;
+% dip1 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'ASBndMPoleSymplectic4Pass');
+% dip2 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'ASBndMPoleSymplectic4Pass');
+% 2E
+dip1 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'BndMPoleSymplectic4E2Pass');
+dip2 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001+edge_offset,1.121997e-001+edge_offset,-0.33295132*scalek,'BndMPoleSymplectic4E2Pass');
+
+
+% Quadrupoles (for design dipole: [QFA,QDA,QFB]=[1.761741,-1.038377,1.533802];
+% To match new dipole values from numerical studies
+% tune of 13.3, 5.2 and 0 dispersion in straights.
+% qfa = quadrupole('QFA' ,3.550000e-001, 1.7610967e+000,'QuadLinearPass');
+% qda = quadrupole('QDA' ,1.800000e-001,-1.0715748e+000,'QuadLinearPass');
+% qfb = quadrupole('QFB' ,3.550000e-001, 1.5406418e+000,'QuadLinearPass');
+% To match split dipole values from numerical studies (SBENDS)
+% tune of 13.29, 5.216 and 0 dispersion in straights.
+
+% qfa = quadrupole('QFA' ,3.550000e-001, 1.76272982211693,'QuadLinearPass');
+% qda = quadrupole('QDA' ,1.800000e-001,-1.06276736743823,'QuadLinearPass');
+% qfb = quadrupole('QFB' ,3.550000e-001, 1.53992875479511,'QuadLinearPass');
+
+qfa = quadrupole('QFA' ,3.550000e-001, 1.76272982211693,'StrMPoleSymplectic4Pass');
+qda = quadrupole('QDA' ,1.800000e-001,-1.06276736743823,'StrMPoleSymplectic4Pass');
+qfb = quadrupole('QFB' ,3.550000e-001, 1.53992875479511,'StrMPoleSymplectic4Pass');
+
+% Sextupoles with built in correctors. Corrector settings given by kick
+% angle in radians.
+try
+ % applies to AT1.3 only. for older installations
+ sfa = sextcorr('SFA' ,2.000000e-001, 1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
+ sda = sextcorr('SDA' ,2.000000e-001,-1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
+ sdb = sextcorr('SDB' ,2.000000e-001,-7.014635e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
+ sfb = sextcorr('SFB' ,2.000000e-001, 7.189346e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
+catch
+ % used for AT1.4 onwards
+ sfa = sextupole('SFA' ,2.000000e-001, 1.400000e+001,'StrMPoleSymplectic4Pass');
+ sda = sextupole('SDA' ,2.000000e-001,-1.400000e+001,'StrMPoleSymplectic4Pass');
+ sdb = sextupole('SDB' ,2.000000e-001,-7.014635e+000,'StrMPoleSymplectic4Pass');
+ sfb = sextupole('SFB' ,2.000000e-001, 7.189346e+000,'StrMPoleSymplectic4Pass');
+ FAMLIST{sfa}.ElemData.KickAngle = [0 0];
+ FAMLIST{sda}.ElemData.KickAngle = [0 0];
+ FAMLIST{sfb}.ElemData.KickAngle = [0 0];
+ FAMLIST{sdb}.ElemData.KickAngle = [0 0];
+end
+
+% RF cavity and the corresponding straight used to position the cavity.
+% 4.996540652069698e+008 old freq for 216m for 216.0004 its different. Also
+% we are using ThinCavities therefore the drifts have to be set
+% accordingly.
+cav_single = rfcavity('RF' ,0.0,3.00e+006,C0/L0*HarmNumber,HarmNumber,'CavityPass');
+cav = rfcavity('RF' ,0.0,0.75e+006,C0/L0*HarmNumber,HarmNumber,'CavityPass');
+% drifts around the rf cavities and space between them
+d1ar1 = drift('D1AR1' ,len(d1a)-len(cav_single)/2 ,'DriftPass'); % for just 1 cavity
+drf = drift('DRF' ,0.45 ,'DriftPass'); % space between cavities
+d1ar4 = drift('D1AR4' ,len(d1a)-len(cav)-len(drf)/2,'DriftPass'); % for 4 cavities
+cav_pair = [cav drf cav];
+dRF1 = drift('dRF1' ,len(d1)-2.55 ,'DriftPass');
+dRF2 = drift('dRF2' ,2.55/3 ,'DriftPass');
+
+
+% Kickers and the associated drifts to position them. (to be checked)
+kick1 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick2 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick3 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick4 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+%fast feedback kicks
+ffbh = corrector('FFBH' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+ffbv = corrector('FFBV' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+% Drift spaces to replace D1A for the upstream kickers, ie kickers 1 and 3.
+d1ak2_up= drift('D1AK2_UP' ,0.779 - len(d1b),'DriftPass');
+d1ak1_up= drift('D1AK1_UP' ,len(d1a) - len(d1ak2_up),'DriftPass');
+% Drift spaces to replace D1A for the downstream kickers, ie kickers 2 and 4.
+d1ak2_do= drift('D1AK2_DO' ,1.073 - len(d1bb),'DriftPass');
+d1ak1_do= drift('D1AK1_DO' ,len(d1aa) - len(d1ak2_do),'DriftPass');
+
+
+% Define the position of the bpm. bpm1d1 represents BPM number 1 in the D1
+% straight and bpm5d4 represents BPM number 5 in straight d4. bpm7dk and
+% bpm7dr repreents BPM number 7 in either the kicker stright or RF
+% straight.
+bpm1d1 = [ d1a bpm d1b ];
+bpm1d1k = inline(['[' num2str(d1ak1_up) ' ' 'kicker ' num2str(d1ak2_up) ' ' num2str(bpm) ' ' num2str(d1b) ' ' ']' ], 'kicker'); % Kicker
+bpm1d1r1 = [ d1ar1 bpm d1b ]; % RF 1 cavity
+%bpm1d1r4 = [ d1ar4 bpm d1b ]; % RF 4 cavity
+bpm2d4 = [ d4a bpm d4b ];
+bpm3d4 = [ d4aa bpm d4bb ];
+bpm4d2 = [ d2a bpm d2b ];
+bpm5d4 = [ bpm2d4 ];
+bpm6d4 = [ bpm3d4 ];
+bpm7d1 = [ d1bb bpm d1aa ];
+bpm7d1k = inline(['[' num2str(d1bb) ' ' num2str(bpm) ' ' num2str(d1ak2_do) ' ' 'kicker ' num2str(d1ak1_do) ' ' ']' ], 'kicker'); % Kicker
+bpm7d1r1 = [ d1b bpm d1ar1 ]; % RF 1 cavity
+%bpm7d1r4 = [ d1b bpm d1ar4 ]; % RF 4 cavity
+bpm1d1RF = [ dRF1 bpm dRF2 cav dRF2 cav dRF2 ];
+
+d1ffb = [];
+bpm7d1ffb = [ d1b bpm d1ffb ]; %fast feedback kicker
+
+% Arrange the elements onto the girders and use markers to define the
+% sections for misalignment studies.
+g1m1 = marker('g1m1','IdentityPass');
+g1m2 = marker('g1m2','IdentityPass');
+g2m1 = marker('g2m1','IdentityPass');
+g2m2 = marker('g2m2','IdentityPass');
+% girder1 = [ g1m1 sfa hcor sfa d2 qfa d3 sda vcor sda g1m2];
+% girder2 = [ g2m1 sdb vcor sdb d5 qda d6 qfb d2 sfb hcor sfb bpm4d2 qfb d6 qda d5 sdb vcor sdb g2m2];
+% girder3 = [ g1m1 sda vcor sda d3 qfa d2 sfa hcor sfa g1m2];
+girder1 = [ g1m1 sfa d2 qfa d3 sda g1m2];
+girder2 = [ g2m1 sdb d5 qda d6 qfb d2 sfb bpm4d2 qfb d6 qda d5 sdb g2m2];
+girder3 = [ g1m1 sda d3 qfa d2 sfa g1m2];
+
+dipole_arc1 = [bpm2d4 dip1 bpm3d4];
+dipole_arc2 = [bpm5d4 dip2 bpm6d4];
+
+% Arrange the girders into the different cell arrangements.
+unit_cel = [ bpm1d1 girder1 dipole_arc1 girder2 dipole_arc2 girder3 bpm7d1 ];
+% Kickers in cells 1 and 14
+celkick14 = [ bpm1d1k(kick1) girder1 dipole_arc1 girder2 dipole_arc2 girder3 bpm7d1k(kick2) ];
+celkick01 = [ bpm1d1k(kick3) girder1 dipole_arc1 girder2 dipole_arc2 girder3 bpm7d1k(kick4) ];
+% Shorten the straights in cells 6, 7 and 8 to put in the rf
+% 4 RF cavities
+
+celrf06_4 = [ bpm1d1RF girder1 dipole_arc1 girder2 dipole_arc2 girder3 bpm7d1 ];
+celrf07_4 = [ bpm1d1RF girder1 dipole_arc1 girder2 dipole_arc2 girder3 bpm7d1 ];
+%celrf06_4 = [ bpm1d1 girder1 dipole_arc1 girder2 dipole_arc2 girder3 bpm7d1r4 ];
+%celrf07_4 = [ bpm1d1r4 girder1 dipole_arc1 girder2 dipole_arc2 girder3 bpm7d1r4 ];
+%celrf08_4 = [ bpm1d1r4 girder1 dipole_arc1 girder2 dipole_arc2 girder3 bpm7d1 ];
+
+% Single RF cavity
+celrf06_1 = [ bpm1d1 girder1 dipole_arc1 girder2 dipole_arc2 girder3 bpm7d1r1 ];
+celrf07_1 = [ bpm1d1r1 girder1 dipole_arc1 girder2 dipole_arc2 girder3 bpm7d1 ];
+%diagnostic straight with fast feedback kicker
+celffb10_1 = [ bpm1d1 girder1 dipole_arc1 girder2 dipole_arc2 girder3 bpm7d1ffb ]; %includes fast feedback kicker
+
+
+% Definition of the types of rings
+kickring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+cavity1ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];;
+cavity4ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_4 celrf07_4 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+
+fullring_startwithRF = [ ap cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 ];
+ring = [ ap unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+%fast feedback kicker included:
+ffbring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel celffb10_1 unit_cel unit_cel unit_cel celkick14];
+
+% Choose which lattice to load else load "fullring" as the default.
+if nargin > 0
+ fprintf('Using lattice : %s \n', varargin{1});
+ eval(['buildlat(' varargin{1} ');']);
+else
+ % Default lattice to load
+ fprintf('Using default lattice : cavity4ring\n');
+ buildlat(cavity4ring);
+end
+
+% Make the variables THERING and GLOBVAL available to the caller's
+% workspace.
+evalin('caller','global THERING GLOBVAL');
+disp('** Done **');
+
+% New AT 1.3 does not require FAMLIST and is fazing out GLOBVAL
+clear global FAMLIST
+
+setenergymodel(3);
+
+% Internal function used to return the length of a defined element.
+function res = len(id)
+global FAMLIST
+res = FAMLIST{id}.ElemData.Length;
+
diff --git a/machine/ASP/StorageRing/assr4_splitbends.m b/machine/ASP/StorageRing/assr4_splitbends.m
index 4ec84f0b..f4d6a981 100644
--- a/machine/ASP/StorageRing/assr4_splitbends.m
+++ b/machine/ASP/StorageRing/assr4_splitbends.m
@@ -15,17 +15,40 @@ function assr4(varargin)
% * Merged with "aspsr_msrf.m" with independent/individual cavitie(s).
% * Element positions/lengths should be inline with engineering
% drawings.
+%
+% Eugene 2010-07-08
+% * now we define the RF frequency and this will automatically scale the
+% drift sections to match
+% * Changed the dipole pass method to BndMPoleSymplectic4E2RadPass that
+% correctly tracks off energy particles through the dipole.
+% * added scaling factors.
+%
+% Eugene 2010-07-27
+% * Plan to make this lattice the standard general lattice for all LOCO
+% fits.
+% * Added IDs into this lattice. Scaling of 'quadDL_2', 'scalek' and
+% 'scalem' set by balancing the relative quadrupole strengths between
+% families so that they are the same as in the machine. The sextupole
+% component was scaled so that the modeled chromaticity matches what we
+% measure.
+
global FAMLIST THERING GLOBVAL
-GLOBVAL.E0 = 3e9;
+GLOBVAL.E0 = 3.0134e9; % Measured by Harris and Kent using resonant depolrasiation July 2010.
GLOBVAL.LatticeFile = mfilename;
FAMLIST = cell(0);
-L0 = 2.159946602239996e+02;
-L0 = 2.159946602239993e+02; % calculated using findspos %215.9945540689991;% with new dipole path lengths. Designed for 216m.
+arclen = 10.031590015999999; % length bpm to bpm without the straight sections.
+% ringrf = 499.6716341346960e6;
+% ringrf = 499.674000e6;
+ringrf = 499.675982e6; % 16/01/2017 ET
C0 = 299792458; % speed of light [m/s]
HarmNumber = 360;
+L0 = C0*HarmNumber/ringrf;
+halfstraightlength = (L0/14-arclen)/2; (L0 - arclen*14)/14/2;
+% L0 = 2.159946602239996e+02;
+% L0 = 2.159946602239993e+02; % calculated using findspos %215.9945540689991;% with new dipole path lengths. Designed for 216m.
disp(' ');
fprintf('*** Loading lattice from %s.m ***\n',GLOBVAL.LatticeFile);
@@ -35,15 +58,19 @@ function assr4(varargin)
% check for this and do nothing to particles with these coordinates.
% Ring/linepass will both return particle positions as well as the number
% of turns the particles achieved.
-% ap = aperture('AP',[-32 17 -16 16]*1e-3,'AperturePass');
ap = aperture('AP',[-16 17 -16 16]*1e2,'AperturePass');
-d1 = drift('D1' ,2.698300e+000,'DriftPass'); % (2.698286 -> to get closer to the design distance of 216m)
-d2 = drift('D2' ,1.900000e-001,'DriftPass');
-d3 = drift('D3' ,1.650000e-001,'DriftPass');
+% Quadrupole field extent on one end past the magnet iron length as
+% measured by RMIT student Neville. quadDL_2 = 0.005;
+% Empirically modified so relative strengths between QFA, QDA and QFB are
+% the same as those set on the ring.
+quadDL_2 = 0.0042;
+d1 = drift('D1' ,halfstraightlength,'DriftPass'); % (2.698286 -> to get closer to the design distance of 216m)
+d2 = drift('D2' ,1.900000e-001-quadDL_2,'DriftPass');
+d3 = drift('D3' ,1.650000e-001-quadDL_2,'DriftPass');
d4 = drift('D4' ,2.750000e-001,'DriftPass');
-d5 = drift('D5' ,1.550000e-001,'DriftPass');
-d6 = drift('D6' ,4.500000e-001,'DriftPass');
+d5 = drift('D5' ,1.550000e-001-quadDL_2,'DriftPass');
+d6 = drift('D6' ,4.500000e-001-quadDL_2*2,'DriftPass');
% Modified drifts around BPM sections.
bpm = monitor('BPM' ,'IdentityPass');
@@ -59,113 +86,91 @@ function assr4(varargin)
d2b = drift('D2B' , 1.030000e-001,'DriftPass');
% Dipoles
-% design -> rbend_asp('BEND',1.726000e+000,2.243995e-001,1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
+% design -> rbend('BEND',1.726000e+000,2.243995e-001,...
+% 1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
% From numerical studies -> L: 1.72579121675e+000
% K: 0.33295132
% Sext: 0.01092687
% Oct: 0.15166053
-dip1 = rbend_asp('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BndMPoleSymplectic4Pass');
-dip2 = rbend_asp('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BndMPoleSymplectic4Pass');
+dip1 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BendLinearPass');
+dip2 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BendLinearPass');
-scalek = 1.00;
+scalek = 1; % Quadrupole components scaled to get the relative strengths between the quadrupoles in the model to match with the machine.
+scalem = 3.15; % Sextupole component scaled to get model chromaticities to match with measured chromaticities
+scalen = 0.0;
+thinsext = sextupole('thinsext' ,0,0.0,'ThinMPolePass');
leftdrift_a = drift('leftdrift',0.076,'DriftPass');
leftdrift_b = drift('leftdrift',0.0837626757-len(leftdrift_a),'DriftPass');
rightdrift_b = drift('rightdrift',0.064,'DriftPass');
rightdrift_a = drift('rightdrift',0.0887292346-len(rightdrift_b),'DriftPass');
-b_left01 = rbend_asp('b_left01',0.0695312761,0.0001684486,0.0000000000,0.0000000000,-0.0058550750*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0058550750*scalek 0.0862147892 -1.2289013273]);
-b_left02 = rbend_asp('b_left02',0.0695282915,0.0007117061,0.0000000000,0.0000000000,-0.0239389168*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0239389168*scalek -0.0583359949 -0.0632750927]);
-b_left03 = rbend_asp('b_left03',0.0695152451,0.0032675350,0.0000000000,0.0000000000,-0.2254325358*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.2254325358*scalek 0.2451727966 -0.1103893288]);
-b_left04 = rbend_asp('b_left04',0.0694679183,0.0087995936,0.0000000000,0.0000000000,-0.4158165694*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.4158165694*scalek -0.1443627022 0.6681103839]);
-b_left05 = rbend_asp('b_left05',0.0694041758,0.0092692887,0.0000000000,0.0000000000,-0.3298403749*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3298403749*scalek -0.0340207205 0.3349521492]);
-b_centre01 = rbend_asp('b_centre01',0.2820465390,0.0367531161,0.0000000000,0.0000000000,-0.3315842393*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3315842393*scalek 0.0083655817 0.2965845308]);
-b_centre02 = rbend_asp('b_centre02',0.2815037989,0.0354072994,0.0000000000,0.0000000000,-0.3306516396*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3306516396*scalek 0.0236710994 -0.2196079070]);
-b_centre03 = rbend_asp('b_centre03',0.2813281018,0.0349189639,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673 -0.5218735605]);
-b_centre04 = rbend_asp('b_centre04',0.2814996751,0.0353946664,0.0000000000,0.0000000000,-0.3302155286*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3302155286*scalek 0.0236248098 -0.2148826863]);
-b_centre05 = rbend_asp('b_centre05',0.2820380879,0.0367421671,0.0000000000,0.0000000000,-0.3312220213*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3312220213*scalek 0.0103909753 0.2969171603]);
-b_right01 = rbend_asp('b_right01',0.0694014448,0.0092683157,0.0000000000,0.0000000000,-0.3292611055*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3292611055*scalek -0.0291322494 0.3681905186]);
-b_right02 = rbend_asp('b_right02',0.0694650575,0.0090036557,0.0000000000,0.0000000000,-0.3961176951*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3961176951*scalek -0.1539214712 0.9528854933]);
-b_right03 = rbend_asp('b_right03',0.0695141539,0.0037120061,0.0000000000,0.0000000000,-0.2701751814*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.2701751814*scalek 0.3742213022 0.7022676128]);
-b_right04 = rbend_asp('b_right04',0.0695280819,0.0007962279,0.0000000000,0.0000000000,-0.0288159660*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0288159660*scalek -0.0571472318 0.2460706289]);
-b_right05 = rbend_asp('b_right05',0.0695312501,0.0001902235,0.0000000000,0.0000000000,-0.0028161106*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0028161106*scalek -0.1077402629 0.7697020810]);
-
-% rbend_asp
-% b_left01 = rbend_asp('b_left01',0.0695312761,0.0001700782,0.1121962211,-0.1120187381,0.0026580668*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0026580668*scalek -0.0222542890 -0.0307698880]);
-% b_left02 = rbend_asp('b_left02',0.0695282915,0.0007118132,0.1120187381,-0.1112734474,0.0004302895*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0004302895*scalek -0.0824996146 -0.0652385243]);
-% b_left03 = rbend_asp('b_left03',0.0695152451,0.0032678721,0.1112734474,-0.1078414785,-0.1045888695*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.1045888695*scalek -0.0928717833 0.2254072448]);
-% b_left04 = rbend_asp('b_left04',0.0694679183,0.0088002187,0.1078414785,-0.0989182337,-0.3486275471*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3486275471*scalek -0.0656081148 0.3572852967]);
-% b_left05 = rbend_asp('b_left05',0.0694041758,0.0092692888,0.0989182337,-0.0896518010,-0.3281526271*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3281526271*scalek -0.0355726539 0.3355904266]);
-% b_centre01 = rbend_asp('b_centre01',0.2820465390,0.0367531221,0.0896518010,-0.0529125655,-0.3312315118*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3312315118*scalek 0.0081060667 0.2963931827]);
-% b_centre02 = rbend_asp('b_centre02',0.2815037989,0.0354072962,0.0529125655,-0.0175134439,-0.3306429237*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3306429237*scalek 0.0237264198 -0.2192733272]);
-% b_centre03 = rbend_asp('b_centre03',0.2813281018,0.0349189640,0.0175134439,0.0174054578,-0.3300984023*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300984023*scalek 0.0101509428 -0.5218382720]);
-% b_centre04 = rbend_asp('b_centre04',0.2814996751,0.0353946633,-0.0174054578,0.0528080683,-0.3302048119*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3302048119*scalek 0.0235987043 -0.2144554284]);
-% b_centre05 = rbend_asp('b_centre05',0.2820380879,0.0367421699,-0.0528080683,0.0895641319,-0.3309037380*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3309037380*scalek 0.0102169077 0.2963545009]);
-% b_right01 = rbend_asp('b_right01',0.0694014448,0.0092683188,-0.0895641319,0.0988345428,-0.3275972520*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3275972520*scalek -0.0308930090 0.3680490900]);
-% b_right02 = rbend_asp('b_right02',0.0694650575,0.0090032960,-0.0988345428,0.1077882518,-0.3467634133*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3467634133*scalek -0.0345063628 0.6218385567]);
-% b_right03 = rbend_asp('b_right03',0.0695141539,0.0037116695,-0.1077882518,0.1112699557,-0.1347732139*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.1347732139*scalek 0.0189958278 0.8526578807]);
-% b_right04 = rbend_asp('b_right04',0.0695280819,0.0007961566,-0.1112699557,0.1120205593,-0.0014988960*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0014988960*scalek -0.0849450391 0.2100836063]);
-% b_right05 = rbend_asp('b_right05',0.0695312501,0.0001897883,-0.1120205593,0.1121997376,0.0026764692*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0026764692*scalek -0.0276971797 0.0360627830]);
+b_left01 = rbend('b_left01',0.0695312761,0.0001684486,0.0000000000,0.0000000000,-0.0058550750*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0058550750*scalek 0.0862147892*scalem -1.2289013273*scalen]);
+b_left02 = rbend('b_left02',0.0695282915,0.0007117061,0.0000000000,0.0000000000,-0.0239389168*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0239389168*scalek -0.0583359949*scalem -0.0632750927*scalen]);
+b_left03 = rbend('b_left03',0.0695152451,0.0032675350,0.0000000000,0.0000000000,-0.2254325358*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.2254325358*scalek 0.2451727966*scalem -0.1103893288*scalen]);
+b_left04 = rbend('b_left04',0.0694679183,0.0087995936,0.0000000000,0.0000000000,-0.4158165694*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.4158165694*scalek -0.1443627022*scalem 0.6681103839*scalen]);
+b_left05 = rbend('b_left05',0.0694041758,0.0092692887,0.0000000000,0.0000000000,-0.3298403749*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3298403749*scalek -0.0340207205*scalem 0.3349521492*scalen]);
+b_centre01 = rbend('b_centre01',0.2820465390,0.0367531161,0.0000000000,0.0000000000,-0.3315842393*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3315842393*scalek 0.0083655817*scalem 0.2965845308*scalen]);
+b_centre02 = rbend('b_centre02',0.2815037989,0.0354072994,0.0000000000,0.0000000000,-0.3306516396*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3306516396*scalek 0.0236710994*scalem -0.2196079070*scalen]);
+
+b_centre03a = rbend('b_centre03',0.07039827720955,0.0349189639*0.2502,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673*scalem -0.5218735605*scalen]);
+b_centre03b = rbend('b_centre04',0.16393005016542,0.0349189639*0.5827,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673*scalem -0.5218735605*scalen]);
+b_centre03c = rbend('b_centre05',0.04699977442503,0.0349189639*0.1671,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673*scalem -0.5218735605*scalen]);
+source_six = marker('source_six','IdentityPass');
+source_seven = marker('source_seven','IdentityPass');
+b_centre03 = [b_centre03a source_six b_centre03b source_seven b_centre03c];
+%b_centre03 = rbend('b_centre03',0.2813281018,0.0349189639,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673 -0.5218735605]);
+
+b_centre04 = rbend('b_centre06',0.2814996751,0.0353946664,0.0000000000,0.0000000000,-0.3302155286*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3302155286*scalek 0.0236248098*scalem -0.2148826863*scalen]);
+b_centre05 = rbend('b_centre07',0.2820380879,0.0367421671,0.0000000000,0.0000000000,-0.3312220213*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3312220213*scalek 0.0103909753*scalem 0.2969171603*scalen]);
+b_right01 = rbend('b_right01',0.0694014448,0.0092683157,0.0000000000,0.0000000000,-0.3292611055*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3292611055*scalek -0.0291322494*scalem 0.3681905186*scalen]);
+b_right02 = rbend('b_right02',0.0694650575,0.0090036557,0.0000000000,0.0000000000,-0.3961176951*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3961176951*scalek -0.1539214712*scalem 0.9528854933*scalen]);
+b_right03 = rbend('b_right03',0.0695141539,0.0037120061,0.0000000000,0.0000000000,-0.2701751814*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.2701751814*scalek 0.3742213022*scalem 0.7022676128*scalen]);
+b_right04 = rbend('b_right04',0.0695280819,0.0007962279,0.0000000000,0.0000000000,-0.0288159660*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0288159660*scalek -0.0571472318*scalem 0.2460706289*scalen]);
+b_right05 = rbend('b_right05',0.0695312501,0.0001902235,0.0000000000,0.0000000000,-0.0028161106*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0028161106*scalek -0.1077402629*scalem 0.7697020810*scalen]);
+
dipole_arc = [leftdrift_a bpm leftdrift_b b_left01 b_left02 b_left03 b_left04 ...
- b_left05 b_centre01 b_centre02 b_centre03 b_centre04 ...
- b_centre05 b_right01 b_right02 b_right03 b_right04 ...
+ b_left05 thinsext b_centre01 b_centre02 b_centre03 b_centre04 ...
+ b_centre05 thinsext b_right01 b_right02 b_right03 b_right04 ...
b_right05 rightdrift_a bpm rightdrift_b];
-% Quadrupoles (for design dipole: [QFA,QDA,QFB]=[1.761741,-1.038377,1.533802];
-% To match new single dipole values from numerical studies
-% tune of 13.3, 5.2 and 0 dispersion in straights.
-% qfa = quadrupole('QFA' ,3.550000e-001, 1.7610967e+000,'QuadLinearPass');
-% qda = quadrupole('QDA' ,1.800000e-001,-1.0715748e+000,'QuadLinearPass');
-% qfb = quadrupole('QFB' ,3.550000e-001, 1.5406418e+000,'QuadLinearPass');
-
-% To match split dipole values from numerical studies (SBENDS)
-% tune of 13.216, 5.3006 and 0 dispersion in straights.
-% qfa = quadrupole('QFA' ,3.550000e-001, 1.7610967e+000,'QuadLinearPass');
-% qda = quadrupole('QDA' ,1.800000e-001,-1.0715748e+000,'QuadLinearPass');
-% qfb = quadrupole('QFB' ,3.550000e-001, 1.5406418e+000,'QuadLinearPass');
-
-% To match split dipole values from numerical studies (RBENDS)
-% tune of 13.216, 5.3006 and 0 dispersion in straights.
-% qfa = quadrupole('QFA' ,3.550000e-001, 1.7521052e+000,'QuadLinearPass');
-% qda = quadrupole('QDA' ,1.800000e-001,-1.0897262e+000,'QuadLinearPass');
-% qfb = quadrupole('QFB' ,3.550000e-001, 1.5452228e+000,'QuadLinearPass');
-
-% To match split dipole values from numerical studies (RBENDS)
-% tune of 13.29, 5.216 and 0 dispersion in straights.
-% -1.08597141914729
-% qfa = quadrupole('QFA' ,3.550000e-001, 1.76190217411609,'QuadLinearPass');
-% qda = quadrupole('QDA' ,1.800000e-001,-1.08597141914729,'QuadLinearPass');
-% qfb = quadrupole('QFB' ,3.550000e-001, 1.54443756044807,'QuadLinearPass');
-
% To match split dipole values from numerical studies (SBENDS)
% tune of 13.29, 5.216 and 0 dispersion in straights.
-qfa = quadrupole('QFA' ,3.550000e-001, 1.76272982211693,'QuadLinearPass');
-qda = quadrupole('QDA' ,1.800000e-001,-1.06276736743823,'QuadLinearPass');
-qfb = quadrupole('QFB' ,3.550000e-001, 1.53992875479511,'QuadLinearPass');
+qfa = quadrupole('QFA' ,3.550000e-001 + quadDL_2*2, 1.725375769247917,'StrMPoleSymplectic4Pass');
+qda = quadrupole('QDA' ,1.800000e-001 + quadDL_2*2,-1.025712814328698,'StrMPoleSymplectic4Pass');
+qfb = quadrupole('QFB' ,3.550000e-001 + quadDL_2*2, 1.508192835147978,'StrMPoleSymplectic4Pass');
% Sextupoles with built in correctors. Corrector settings given by kick
-% angle in radians.
+% angle in radians. ([1 1] chromaticity with zero dispersion)
sfa = sextcorr('SFA' ,2.000000e-001, 1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
sda = sextcorr('SDA' ,2.000000e-001,-1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
-sdb = sextcorr('SDB' ,2.000000e-001,-7.014635e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
-sfb = sextcorr('SFB' ,2.000000e-001, 7.189346e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
-
-
-wig = multipole('wig',0,[0 0 0 0],[0 0 0 10],'ThinMPolePass');
+sdb = sextcorr('SDB' ,2.000000e-001,-7.158624455551593,[0 0],'StrCorrMPoleSymplectic4Pass');
+sfb = sextcorr('SFB' ,2.000000e-001, 7.327438689781832,[0 0],'StrCorrMPoleSymplectic4Pass');
+
+%
+id = marker('ID','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0; Kxy = 0; Kyx = 0;
+FAMLIST{id}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 Kxy 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ Kyx 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+% id = corrector('ID',0,[0 0],'CorrectorPass');
% RF cavity and the corresponding straight used to position the cavity.
% 4.996540652069698e+008 old freq for 216m for 216.0004 its different. Also
% we are using ThinCavities therefore the drifts have to be set
% accordingly.
-cav_single = rfcavity('RF' ,0.0,3.00e+006,C0/L0*HarmNumber,HarmNumber,'CavityPass');
-cav = rfcavity('RF' ,0.0,0.75e+006,C0/L0*HarmNumber,HarmNumber,'CavityPass');
+cav_single = rfcavity('RF' ,0.0,3.00e+006,ringrf,HarmNumber,'DriftPass');
+cav = rfcavity('RF' ,0.0,0.75e+006,ringrf,HarmNumber,'DriftPass');
% drifts around the rf cavities and space between them
d1ar1 = drift('D1AR1' ,len(d1a)-len(cav_single)/2 ,'DriftPass'); % for just 1 cavity
drf = drift('DRF' ,0.45 ,'DriftPass'); % space between cavities
d1ar4 = drift('D1AR4' ,len(d1a)-len(cav)-len(drf)/2,'DriftPass'); % for 4 cavities
cav_pair = [cav drf cav];
-% dRF1 = drift('dRF1' ,len(d1)-2.55 ,'DriftPass');
-% dRF2 = drift('dRF2' ,2.55/3 ,'DriftPass');
dRF1 = drift('dRF1' ,len(d1)-2.55 ,'DriftPass');
dRF2 = drift('dRF2' ,2.55/3 ,'DriftPass');
@@ -178,6 +183,7 @@ function assr4(varargin)
ffbh = corrector('FFBH' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
ffbv = corrector('FFBV' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
% Drift spaces to replace D1A for the upstream kickers, ie kickers 1 and 3.
+% d1ak2_up= drift('D1AK2_UP' ,0.779 - len(d1b),'DriftPass');
d1ak2_up= drift('D1AK2_UP' ,0.779 - len(d1b),'DriftPass');
d1ak1_up= drift('D1AK1_UP' ,len(d1a) - len(d1ak2_up),'DriftPass');
% Drift spaces to replace D1A for the downstream kickers, ie kickers 2 and 4.
@@ -249,18 +255,19 @@ function assr4(varargin)
kickring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
% cavity1ring = [ ap celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
% cavity4ring = [ ap celrf06_4 cav_pair celrf07_4 cav_pair celrf08_4 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
-cavity1ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];;
-cavity4ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_4 celrf07_4 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+cavity1ring = [ ap id celkick01 id unit_cel id unit_cel id unit_cel id unit_cel id celrf06_1 id cav_single id celrf07_1 id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id celkick14];
+cavity4ring = [ ap id celkick01 id unit_cel id unit_cel id unit_cel id unit_cel id celrf06_4 id celrf07_4 id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id celkick14];
%cavity4ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_4 cav_pair celrf07_4 cav_pair celrf08_4 unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+% Ring starting with the RF
fullring_startwithRF = [ ap cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 ];
+% Ring with no RF and no Kickers
ring = [ ap unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+% Ring starting in straight 14 rather than straight 1, outside of the kick orbit.
fullring = [ ap celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
-%fast feedback kicker included:
+% fast feedback kicker included:
ffbring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel celffb10_1 unit_cel unit_cel unit_cel celkick14];
-% Wiggler
-wigring = [ ap unit_cel wig unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
% Choose which lattice to load else load "fullring" as the default.
if nargin > 0
@@ -285,5 +292,4 @@ function assr4(varargin)
% Internal function used to return the length of a defined element.
function res = len(id)
global FAMLIST
-res = FAMLIST{id}.ElemData.Length;
-
+res = FAMLIST{id}.ElemData.Length;
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/assr4_splitbends.m.bak b/machine/ASP/StorageRing/assr4_splitbends.m.bak
new file mode 100644
index 00000000..4d1a2382
--- /dev/null
+++ b/machine/ASP/StorageRing/assr4_splitbends.m.bak
@@ -0,0 +1,258 @@
+function assr4(varargin)
+% Lattice definition file - generated by dimad2at v1.300000
+%
+% Eugene 2004-12-13 Updating the generalised file to realign the family
+% names and elements with aspinit. NOTE: aspinit will not work with split
+% elements... not without modification of the init file.
+%
+% Eugene 2005-09-16 Standardise all lattices being used to this. "Custom"
+% versions of the lattice files, eg for ML, ID studies etc will take this
+% file as a template. The following major changes were made -
+% * All family names in CAPS in line with ALS and SPEAR convention.
+% * Dipole path and gradient updated to reflect numerical studies on
+% measured data. Quadrupole values fitted for a tune of 13.3, 5.2 and
+% zero dispersion given the new dipole gradient fields.
+% * Merged with "aspsr_msrf.m" with independent/individual cavitie(s).
+% * Element positions/lengths should be inline with engineering
+% drawings.
+
+global FAMLIST THERING GLOBVAL
+
+GLOBVAL.E0 = 3e9;
+GLOBVAL.LatticeFile = mfilename;
+FAMLIST = cell(0);
+
+L0 = 2.159946602239996e+02; % calculated using findspos %215.9945540689991;% with new dipole path lengths. Designed for 216m.
+C0 = 299792458; % speed of light [m/s]
+HarmNumber = 360;
+
+disp(' ');
+fprintf('*** Loading lattice from %s.m ***\n',GLOBVAL.LatticeFile);
+
+% With AT1.3 ringpass and linepass, particles limited by the apperturepass
+% will have [x,x',y,y',delta,dl] = [NaN,0,0,0,0,0]. All pass methods will
+% check for this and do nothing to particles with these coordinates.
+% Ring/linepass will both return particle positions as well as the number
+% of turns the particles achieved.
+% ap = aperture('AP',[-32 17 -16 16]*1e-3,'AperturePass');
+ap = aperture('AP',[-16 17 -16 16]*1e2,'AperturePass');
+
+d1 = drift('D1' ,2.698300e+000,'DriftPass'); % (2.698286 -> to get closer to the design distance of 216m)
+d2 = drift('D2' ,1.900000e-001,'DriftPass');
+d3 = drift('D3' ,1.650000e-001,'DriftPass');
+d4 = drift('D4' ,2.750000e-001,'DriftPass');
+d5 = drift('D5' ,1.550000e-001,'DriftPass');
+d6 = drift('D6' ,4.500000e-001,'DriftPass');
+
+% Modified drifts around BPM sections.
+bpm = monitor('BPM' ,'IdentityPass');
+d1a = drift('D1A' ,len(d1)-3.942860e-001,'DriftPass'); % 2.304000e+000
+d1b = drift('D1B' , 3.942860e-001,'DriftPass');
+d4a = drift('D4A' ,len(d4)-1.990000e-001,'DriftPass'); % 7.600000e-002
+d4b = drift('D4B' , 1.990000e-001,'DriftPass');
+d4aa = drift('D4AA' ,len(d4)-6.400000e-002,'DriftPass'); % 2.110000e-001
+d4bb = drift('D4BB' , 6.400000e-002,'DriftPass');
+d2a = drift('D2A' ,len(d2)-1.030000e-001,'DriftPass'); % 8.700000e-002
+d2b = drift('D2B' , 1.030000e-001,'DriftPass');
+
+% Dipoles
+% design -> rbend('BEND',1.726000e+000,2.243995e-001,...
+% 1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
+% From numerical studies -> L: 1.72579121675e+000
+% K: 0.33295132
+% Sext: 0.01092687
+% Oct: 0.15166053
+dip1 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BndMPoleSymplectic4Pass');
+dip2 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BndMPoleSymplectic4Pass');
+
+scalek = 1;
+leftdrift = drift('leftdrift',0.0837626757,'DriftPass');
+rightdrift = drift('rightdrift',0.0887292346,'DriftPass');
+% b_left01 = rbend('b_left01',0.0695312761,0.0001684486,0.0000000000,0.0000000000,-0.0058550750*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0058550750*scalek 0.0862147892 -1.2289013273]);
+% b_left02 = rbend('b_left02',0.0695282915,0.0007117061,0.0000000000,0.0000000000,-0.0239389168*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0239389168*scalek -0.0583359949 -0.0632750927]);
+% b_left03 = rbend('b_left03',0.0695152451,0.0032675350,0.0000000000,0.0000000000,-0.2254325358*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.2254325358*scalek 0.2451727966 -0.1103893288]);
+% b_left04 = rbend('b_left04',0.0694679183,0.0087995936,0.0000000000,0.0000000000,-0.4158165694*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.4158165694*scalek -0.1443627022 0.6681103839]);
+% b_left05 = rbend('b_left05',0.0694041758,0.0092692887,0.0000000000,0.0000000000,-0.3298403749*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3298403749*scalek -0.0340207205 0.3349521492]);
+% b_centre01 = rbend('b_centre01',0.2820465390,0.0367531161,0.0000000000,0.0000000000,-0.3315842393*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3315842393*scalek 0.0083655817 0.2965845308]);
+% b_centre02 = rbend('b_centre02',0.2815037989,0.0354072994,0.0000000000,0.0000000000,-0.3306516396*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3306516396*scalek 0.0236710994 -0.2196079070]);
+% b_centre03 = rbend('b_centre03',0.2813281018,0.0349189639,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673 -0.5218735605]);
+% b_centre04 = rbend('b_centre04',0.2814996751,0.0353946664,0.0000000000,0.0000000000,-0.3302155286*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3302155286*scalek 0.0236248098 -0.2148826863]);
+% b_centre05 = rbend('b_centre05',0.2820380879,0.0367421671,0.0000000000,0.0000000000,-0.3312220213*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3312220213*scalek 0.0103909753 0.2969171603]);
+% b_right01 = rbend('b_right01',0.0694014448,0.0092683157,0.0000000000,0.0000000000,-0.3292611055*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3292611055*scalek -0.0291322494 0.3681905186]);
+% b_right02 = rbend('b_right02',0.0694650575,0.0090036557,0.0000000000,0.0000000000,-0.3961176951*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3961176951*scalek -0.1539214712 0.9528854933]);
+% b_right03 = rbend('b_right03',0.0695141539,0.0037120061,0.0000000000,0.0000000000,-0.2701751814*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.2701751814*scalek 0.3742213022 0.7022676128]);
+% b_right04 = rbend('b_right04',0.0695280819,0.0007962279,0.0000000000,0.0000000000,-0.0288159660*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0288159660*scalek -0.0571472318 0.2460706289]);
+% b_right05 = rbend('b_right05',0.0695312501,0.0001902235,0.0000000000,0.0000000000,-0.0028161106*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0028161106*scalek -0.1077402629 0.7697020810]);
+
+% RBEND
+b_left01 = rbend('b_left01',0.0695312761,0.0001700782,0.1121962211,-0.1120187381,0.0026580668*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0026580668*scalek -0.0222542890 -0.0307698880]);
+b_left02 = rbend('b_left02',0.0695282915,0.0007118132,0.1120187381,-0.1112734474,0.0004302895*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0004302895*scalek -0.0824996146 -0.0652385243]);
+b_left03 = rbend('b_left03',0.0695152451,0.0032678721,0.1112734474,-0.1078414785,-0.1045888695*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.1045888695*scalek -0.0928717833 0.2254072448]);
+b_left04 = rbend('b_left04',0.0694679183,0.0088002187,0.1078414785,-0.0989182337,-0.3486275471*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3486275471*scalek -0.0656081148 0.3572852967]);
+b_left05 = rbend('b_left05',0.0694041758,0.0092692888,0.0989182337,-0.0896518010,-0.3281526271*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3281526271*scalek -0.0355726539 0.3355904266]);
+b_centre01 = rbend('b_centre01',0.2820465390,0.0367531221,0.0896518010,-0.0529125655,-0.3312315118*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3312315118*scalek 0.0081060667 0.2963931827]);
+b_centre02 = rbend('b_centre02',0.2815037989,0.0354072962,0.0529125655,-0.0175134439,-0.3306429237*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3306429237*scalek 0.0237264198 -0.2192733272]);
+b_centre03 = rbend('b_centre03',0.2813281018,0.0349189640,0.0175134439,0.0174054578,-0.3300984023*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300984023*scalek 0.0101509428 -0.5218382720]);
+b_centre04 = rbend('b_centre04',0.2814996751,0.0353946633,-0.0174054578,0.0528080683,-0.3302048119*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3302048119*scalek 0.0235987043 -0.2144554284]);
+b_centre05 = rbend('b_centre05',0.2820380879,0.0367421699,-0.0528080683,0.0895641319,-0.3309037380*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3309037380*scalek 0.0102169077 0.2963545009]);
+b_right01 = rbend('b_right01',0.0694014448,0.0092683188,-0.0895641319,0.0988345428,-0.3275972520*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3275972520*scalek -0.0308930090 0.3680490900]);
+b_right02 = rbend('b_right02',0.0694650575,0.0090032960,-0.0988345428,0.1077882518,-0.3467634133*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3467634133*scalek -0.0345063628 0.6218385567]);
+b_right03 = rbend('b_right03',0.0695141539,0.0037116695,-0.1077882518,0.1112699557,-0.1347732139*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.1347732139*scalek 0.0189958278 0.8526578807]);
+b_right04 = rbend('b_right04',0.0695280819,0.0007961566,-0.1112699557,0.1120205593,-0.0014988960*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0014988960*scalek -0.0849450391 0.2100836063]);
+b_right05 = rbend('b_right05',0.0695312501,0.0001897883,-0.1120205593,0.1121997376,0.0026764692*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0026764692*scalek -0.0276971797 0.0360627830]);
+
+newbend = [leftdrift bpm b_left01 b_left02 b_left03 b_left04 ...
+ b_left05 b_centre01 b_centre02 b_centre03 b_centre04 ...
+ b_centre05 b_right01 b_right02 b_right03 b_right04 ...
+ b_right05 bpm rightdrift];
+
+% Quadrupoles (for design dipole: [QFA,QDA,QFB]=[1.761741,-1.038377,1.533802];
+% To match new single dipole values from numerical studies
+% tune of 13.3, 5.2 and 0 dispersion in straights.
+% qfa = quadrupole('QFA' ,3.550000e-001, 1.7610967e+000,'QuadLinearPass');
+% qda = quadrupole('QDA' ,1.800000e-001,-1.0715748e+000,'QuadLinearPass');
+% qfb = quadrupole('QFB' ,3.550000e-001, 1.5406418e+000,'QuadLinearPass');
+
+% To match split dipole values from numerical studies (SBENDS)
+% tune of 13.216, 5.3006 and 0 dispersion in straights.
+% qfa = quadrupole('QFA' ,3.550000e-001, 1.7610967e+000,'QuadLinearPass');
+% qda = quadrupole('QDA' ,1.800000e-001,-1.0715748e+000,'QuadLinearPass');
+% qfb = quadrupole('QFB' ,3.550000e-001, 1.5406418e+000,'QuadLinearPass');
+
+% To match split dipole values from numerical studies (RBENDS)
+% tune of 13.216, 5.3006 and 0 dispersion in straights.
+qfa = quadrupole('QFA' ,3.550000e-001, 1.7521052e+000,'QuadLinearPass');
+qda = quadrupole('QDA' ,1.800000e-001,-1.0897262e+000,'QuadLinearPass');
+qfb = quadrupole('QFB' ,3.550000e-001, 1.5452228e+000,'QuadLinearPass');
+
+
+% Sextupoles with built in correctors. Corrector settings given by kick
+% angle in radians.
+sfa = sextcorr('SFA' ,2.000000e-001, 1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
+sda = sextcorr('SDA' ,2.000000e-001,-1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
+sdb = sextcorr('SDB' ,2.000000e-001,-7.014635e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
+sfb = sextcorr('SFB' ,2.000000e-001, 7.189346e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
+
+wig = multipole('wig',0,[0 0 0 0],[0 0 0 10],'ThinMPolePass');
+
+% RF cavity and the corresponding straight used to position the cavity.
+% 4.996540652069698e+008 old freq for 216m for 216.0004 its different. Also
+% we are using ThinCavities therefore the drifts have to be set
+% accordingly.
+cav_single = rfcavity('RF' ,0.0,3.00e+006,C0/L0*HarmNumber,HarmNumber,'CavityPass');
+cav = rfcavity('RF' ,0.0,0.75e+006,C0/L0*HarmNumber,HarmNumber,'CavityPass');
+% drifts around the rf cavities and space between them
+d1ar1 = drift('D1AR1' ,len(d1a)-len(cav_single)/2 ,'DriftPass'); % for just 1 cavity
+drf = drift('DRF' ,0.45 ,'DriftPass'); % space between cavities
+d1ar4 = drift('D1AR4' ,len(d1a)-len(cav)-len(drf)/2,'DriftPass'); % for 4 cavities
+cav_pair = [cav drf cav];
+
+% Kickers and the associated drifts to position them. (to be checked)
+kick1 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick2 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick3 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick4 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+%fast feedback kicks
+ffbh = corrector('FFBH' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+ffbv = corrector('FFBV' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+% Drift spaces to replace D1A for the upstream kickers, ie kickers 1 and 3.
+d1ak2_up= drift('D1AK2_UP' ,0.779 - len(d1b),'DriftPass');
+d1ak1_up= drift('D1AK1_UP' ,len(d1a) - len(d1ak2_up),'DriftPass');
+% Drift spaces to replace D1A for the downstream kickers, ie kickers 2 and 4.
+d1ak2_do= drift('D1AK2_DO' ,1.073 - len(d1b),'DriftPass');
+d1ak1_do= drift('D1AK1_DO' ,len(d1a) - len(d1ak2_do),'DriftPass');
+
+
+% Define the position of the bpm. bpm1d1 represents BPM number 1 in the D1
+% straight and bpm5d4 represents BPM number 5 in straight d4. bpm7dk and
+% bpm7dr repreents BPM number 7 in either the kicker stright or RF
+% straight.
+bpm1d1 = [ d1a bpm d1b ];
+bpm1d1k = inline(['[' num2str(d1ak1_up) ' ' 'kicker ' num2str(d1ak2_up) ' ' num2str(bpm) ' ' num2str(d1b) ' ' ']' ], 'kicker'); % Kicker
+bpm1d1r1 = [ d1ar1 bpm d1b ]; % RF 1 cavity
+bpm1d1r4 = [ d1ar4 bpm d1b ]; % RF 4 cavity
+bpm2d4 = [ d4a bpm d4b ];
+bpm3d4 = [ d4aa bpm d4bb ];
+bpm4d2 = [ d2a bpm d2b ];
+bpm5d4 = [ bpm2d4 ];
+bpm6d4 = [ bpm3d4 ];
+bpm7d1 = [ d1b bpm d1a ];
+bpm7d1k = inline(['[' num2str(d1b) ' ' num2str(bpm) ' ' num2str(d1ak2_do) ' ' 'kicker ' num2str(d1ak1_do) ' ' ']' ], 'kicker'); % Kicker
+bpm7d1r1 = [ d1b bpm d1ar1 ]; % RF 1 cavity
+bpm7d1r4 = [ d1b bpm d1ar4 ]; % RF 4 cavity
+
+d1ffb = [];
+bpm7d1ffb = [ d1b bpm d1ffb ]; %fast feedback kicker
+
+% Arrange the elements onto the girders and use markers to define the
+% sections for misalignment studies.
+g1m1 = marker('g1m1','IdentityPass');
+g1m2 = marker('g1m2','IdentityPass');
+g2m1 = marker('g2m1','IdentityPass');
+g2m2 = marker('g2m2','IdentityPass');
+% girder1 = [ g1m1 sfa hcor sfa d2 qfa d3 sda vcor sda g1m2];
+% girder2 = [ g2m1 sdb vcor sdb d5 qda d6 qfb d2 sfb hcor sfb bpm4d2 qfb d6 qda d5 sdb vcor sdb g2m2];
+% girder3 = [ g1m1 sda vcor sda d3 qfa d2 sfa hcor sfa g1m2];
+girder1 = [ g1m1 sfa d2 qfa d3 sda g1m2];
+girder2 = [ g2m1 sdb d5 qda d6 qfb d2 sfb bpm4d2 qfb d6 qda d5 sdb g2m2];
+girder3 = [ g1m1 sda d3 qfa d2 sfa g1m2];
+
+
+% Arrange the girders into the different cell arrangements.
+unit_cel = [ bpm1d1 girder1 newbend girder2 newbend girder3 bpm7d1 ];
+% Kickers in cells 1 and 14
+celkick14 = [ bpm1d1k(kick1) girder1 newbend girder2 newbend girder3 bpm7d1k(kick2) ];
+celkick01 = [ bpm1d1k(kick3) girder1 newbend girder2 newbend girder3 bpm7d1k(kick4) ];
+% Shorten the straights in cells 6, 7 and 8 to put in the rf
+% 4 RF cavities
+celrf06_4 = [ bpm1d1 girder1 newbend girder2 newbend girder3 bpm7d1r4 ];
+celrf07_4 = [ bpm1d1r4 girder1 newbend girder2 newbend girder3 bpm7d1r4 ];
+celrf08_4 = [ bpm1d1r4 girder1 newbend girder2 newbend girder3 bpm7d1 ];
+% Single RF cavity
+celrf06_1 = [ bpm1d1 girder1 newbend girder2 newbend girder3 bpm7d1r1 ];
+celrf07_1 = [ bpm1d1r1 girder1 newbend girder2 newbend girder3 bpm7d1 ];
+%diagnostic straight with fast feedback kicker
+celffb10_1 = [ bpm1d1 girder1 newbend girder2 newbend girder3 bpm7d1ffb ]; %includes fast feedback kicker
+
+% Shift sector
+shift1 = quadrupole('SHIFT1' ,0, 0,'QuadLinearPass');
+shift2 = quadrupole('SHIFT2' ,0, 0,'QuadLinearPass');
+
+% Definition of the types of rings
+kickring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+% cavity1ring = [ ap celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+% cavity4ring = [ ap celrf06_4 cav_pair celrf07_4 cav_pair celrf08_4 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+cavity1ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];;
+cavity4ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_4 cav_pair celrf07_4 cav_pair celrf08_4 unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+fullring_startwithRF = [ ap cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 ];
+ring = [ ap unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+fullring = [ ap celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+%fast feedback kicker included:
+ffbring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel celffb10_1 unit_cel unit_cel unit_cel celkick14];
+% Wiggler
+wigring = [ ap unit_cel wig unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+
+% Choose which lattice to load else load "fullring" as the default.
+if nargin > 0
+ fprintf('Using lattice : %s \n', varargin{1});
+ eval(['buildlat(' varargin{1} ');']);
+else
+ % Default lattice to load
+ fprintf('Using default lattice : cavity1ring\n');
+ buildlat(cavity4ring);
+end
+
+% Make the variables THERING and GLOBVAL available to the caller's
+% workspace.
+evalin('caller','global THERING GLOBVAL');
+disp('** Done **');
+
+% New AT 1.3 does not require FAMLIST and is fazing out GLOBVAL
+clear global FAMLIST
+
+setenergymodel(3);
+
+% Internal function used to return the length of a defined element.
+function res = len(id)
+global FAMLIST
+res = FAMLIST{id}.ElemData.Length;
diff --git a/machine/ASP/StorageRing/assr4_splitbends_kent.m b/machine/ASP/StorageRing/assr4_splitbends_kent.m
new file mode 100644
index 00000000..c3fd9e5d
--- /dev/null
+++ b/machine/ASP/StorageRing/assr4_splitbends_kent.m
@@ -0,0 +1,490 @@
+function assr4_splitbends_kent(varargin)
+% Lattice definition file - generated by dimad2at v1.300000
+%
+% Eugene 2004-12-13 Updating the generalised file to realign the family
+% names and elements with aspinit. NOTE: aspinit will not work with split
+% elements... not without modification of the init file.
+%
+% Eugene 2005-09-16 Standardise all lattices being used to this. "Custom"
+% versions of the lattice files, eg for ML, ID studies etc will take this
+% file as a template. The following major changes were made -
+% * All family names in CAPS in line with ALS and SPEAR convention.
+% * Dipole path and gradient updated to reflect numerical studies on
+% measured data. Quadrupole values fitted for a tune of 13.3, 5.2 and
+% zero dispersion given the new dipole gradient fields.
+% * Merged with "aspsr_msrf.m" with independent/individual cavitie(s).
+% * Element positions/lengths should be inline with engineering
+% drawings.
+%
+% Eugene 2010-07-08
+% * now we define the RF frequency and this will automatically scale the
+% drift sections to match
+% * Changed the dipole pass method to BndMPoleSymplectic4E2RadPass that
+% correctly tracks off energy particles through the dipole.
+% * added scaling factors.
+%
+% Eugene 2010-07-27
+% * Plan to make this lattice the standard general lattice for all LOCO
+% fits.
+% * Added IDs into this lattice. Scaling of 'quadDL_2', 'scalek' and
+% 'scalem' set by balancing the relative quadrupole strengths between
+% families so that they are the same as in the machine. The sextupole
+% component was scaled so that the modeled chromaticity matches what we
+% measure.
+
+
+global FAMLIST THERING GLOBVAL
+
+GLOBVAL.E0 = 3.0134e9; % Measured by Harris and Kent using resonant depolrasiation July 2010.
+GLOBVAL.LatticeFile = mfilename;
+FAMLIST = cell(0);
+
+arclen = 10.031590015999999; % length bpm to bpm without the straight sections.
+ringrf = 499.6685923893040e6;
+C0 = 299792458; % speed of light [m/s]
+HarmNumber = 360;
+L0 = C0*HarmNumber/ringrf;
+halfstraightlength = (L0/14-arclen)/2; (L0 - arclen*14)/14/2;
+% L0 = 2.159946602239996e+02;
+% L0 = 2.159946602239993e+02; % calculated using findspos %215.9945540689991;% with new dipole path lengths. Designed for 216m.
+
+
+disp(' ');
+fprintf('*** Loading lattice from %s.m ***\n',GLOBVAL.LatticeFile);
+
+% With AT1.3 ringpass and linepass, particles limited by the apperturepass
+% will have [x,x',y,y',delta,dl] = [NaN,0,0,0,0,0]. All pass methods will
+% check for this and do nothing to particles with these coordinates.
+% Ring/linepass will both return particle positions as well as the number
+% of turns the particles achieved.
+% ap = aperture('AP',[-32 17 -16 16]*1e-3,'AperturePass');
+ap = aperture('AP',[-16 17 -16 16]*1e2,'AperturePass');
+
+% Quadrupole field extent on one end past the magnet iron length as
+% measured by RMIT student Neville. quadDL_2 = 0.005;
+% Empirically modified so relative strengths between QFA, QDA and QFB are
+% the same as those set on the ring.
+quadDL_2 = 0.0042;
+d1 = drift('D1' ,halfstraightlength,'DriftPass'); % (2.698286 -> to get closer to the design distance of 216m)
+d2 = drift('D2' ,0.1900000 - quadDL_2,'DriftPass');
+d3 = drift('D3' ,0.1650000 - quadDL_2,'DriftPass');
+d4 = drift('D4' ,0.2750000, 'DriftPass');
+d5 = drift('D5' ,0.1550000 - quadDL_2,'DriftPass');
+d6 = drift('D6' ,0.4500000 - quadDL_2*2,'DriftPass');
+
+% Modified drifts around BPM sections.
+bpm = monitor('BPM', 'IdentityPass');
+d1a = drift('D1A', len(d1)-0.3942860,'DriftPass'); % 2.304000e+000
+d1b = drift('D1B', 0.3942860,'DriftPass');
+d1aa= drift('D1A', len(d1)-0.58,'DriftPass'); % Last bpm
+d1bb= drift('D1B', 0.58,'DriftPass');
+d4a = drift('D4A', len(d4)-0.1990000,'DriftPass'); % 7.600000e-002
+d4b = drift('D4B', 0.1990000,'DriftPass');
+d4aa= drift('D4AA',len(d4)-6.400000e-002,'DriftPass'); % 2.110000e-001
+d4bb= drift('D4BB', 6.400000e-002,'DriftPass');
+d2a = drift('D2A' ,len(d2)-0.1030000,'DriftPass'); % 8.700000e-002
+d2b = drift('D2B' , 0.1030000,'DriftPass');
+
+% Dipoles
+% design -> rbend('BEND',1.726000e+000,2.243995e-001,...
+% 1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
+% From numerical studies -> L: 1.72579121675e+000
+% K: 0.33295132
+% Sext: 0.01092687
+% Oct: 0.15166053
+dip1 = rbend('BEND' ,1.72579121675,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BendLinearPass');
+dip2 = rbend('BEND' ,1.72579121675,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BendLinearPass');
+
+scalek = 1.0135; % Quadrupole components scaled to get the relative strengths between the quadrupoles in the model to match with the machine.
+scalem = 3.15; % Sextupole component scaled to get model chromaticities to match with measured chromaticities
+scalen = 0.0;
+thinsext = sextupole('thinsext' ,0,0.0,'ThinMPolePass');
+leftdrift_a = drift('leftdrift',0.076,'DriftPass');
+leftdrift_b = drift('leftdrift',0.0837626757-len(leftdrift_a),'DriftPass');
+rightdrift_b = drift('rightdrift',0.064,'DriftPass');
+rightdrift_a = drift('rightdrift',0.0887292346-len(rightdrift_b),'DriftPass');
+
+b_left01 = rbend('b_left01',0.0695312761,0.0001684486,0.0000000000,0.0000000000,-0.0058550750*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0058550750*scalek 0.0862147892*scalem -1.2289013273*scalen]);
+b_left02 = rbend('b_left02',0.0695282915,0.0007117061,0.0000000000,0.0000000000,-0.0239389168*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0239389168*scalek -0.0583359949*scalem -0.0632750927*scalen]);
+b_left03 = rbend('b_left03',0.0695152451,0.0032675350,0.0000000000,0.0000000000,-0.2254325358*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.2254325358*scalek 0.2451727966*scalem -0.1103893288*scalen]);
+b_left04 = rbend('b_left04',0.0694679183,0.0087995936,0.0000000000,0.0000000000,-0.4158165694*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.4158165694*scalek -0.1443627022*scalem 0.6681103839*scalen]);
+b_left05 = rbend('b_left05',0.0694041758,0.0092692887,0.0000000000,0.0000000000,-0.3298403749*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3298403749*scalek -0.0340207205*scalem 0.3349521492*scalen]);
+b_centre01 = rbend('b_centre01',0.2820465390,0.0367531161,0.0000000000,0.0000000000,-0.3315842393*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3315842393*scalek 0.0083655817*scalem 0.2965845308*scalen]);
+b_centre02 = rbend('b_centre02',0.2815037989,0.0354072994,0.0000000000,0.0000000000,-0.3306516396*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3306516396*scalek 0.0236710994*scalem -0.2196079070*scalen]);
+
+b_centre03a = rbend('b_centre03',0.07039827720955,0.0349189639*0.2502,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673*scalem -0.5218735605*scalen]);
+b_centre03b = rbend('b_centre04',0.16393005016542,0.0349189639*0.5827,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673*scalem -0.5218735605*scalen]);
+b_centre03c = rbend('b_centre05',0.04699977442503,0.0349189639*0.1671,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673*scalem -0.5218735605*scalen]);
+source_six = marker('source_six','IdentityPass');
+source_seven = marker('source_seven','IdentityPass');
+b_centre03 = [b_centre03a source_six b_centre03b source_seven b_centre03c];
+%b_centre03 = rbend('b_centre03',0.2813281018,0.0349189639,0.0000000000,0.0000000000,-0.3300962629*scalek,'BendLinearPass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673 -0.5218735605]);
+
+b_centre04 = rbend('b_centre06',0.2814996751,0.0353946664,0.0000000000,0.0000000000,-0.3302155286*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3302155286*scalek 0.0236248098*scalem -0.2148826863*scalen]);
+b_centre05 = rbend('b_centre07',0.2820380879,0.0367421671,0.0000000000,0.0000000000,-0.3312220213*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3312220213*scalek 0.0103909753*scalem 0.2969171603*scalen]);
+b_right01 = rbend('b_right01',0.0694014448,0.0092683157,0.0000000000,0.0000000000,-0.3292611055*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3292611055*scalek -0.0291322494*scalem 0.3681905186*scalen]);
+b_right02 = rbend('b_right02',0.0694650575,0.0090036557,0.0000000000,0.0000000000,-0.3961176951*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3961176951*scalek -0.1539214712*scalem 0.9528854933*scalen]);
+b_right03 = rbend('b_right03',0.0695141539,0.0037120061,0.0000000000,0.0000000000,-0.2701751814*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.2701751814*scalek 0.3742213022*scalem 0.7022676128*scalen]);
+b_right04 = rbend('b_right04',0.0695280819,0.0007962279,0.0000000000,0.0000000000,-0.0288159660*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0288159660*scalek -0.0571472318*scalem 0.2460706289*scalen]);
+b_right05 = rbend('b_right05',0.0695312501,0.0001902235,0.0000000000,0.0000000000,-0.0028161106*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0028161106*scalek -0.1077402629*scalem 0.7697020810*scalen]);
+
+% RBEND
+% b_left01 = rbend('b_left01',0.0695312761,0.0001700782,0.1121962211,-0.1120187381,0.0026580668*scalek,'BendLinearPass',[0 0 0 0],[0 0.0026580668*scalek -0.0222542890 -0.0307698880]);
+% b_left02 = rbend('b_left02',0.0695282915,0.0007118132,0.1120187381,-0.1112734474,0.0004302895*scalek,'BendLinearPass',[0 0 0 0],[0 0.0004302895*scalek -0.0824996146 -0.0652385243]);
+% b_left03 = rbend('b_left03',0.0695152451,0.0032678721,0.1112734474,-0.1078414785,-0.1045888695*scalek,'BendLinearPass',[0 0 0 0],[0 -0.1045888695*scalek -0.0928717833 0.2254072448]);
+% b_left04 = rbend('b_left04',0.0694679183,0.0088002187,0.1078414785,-0.0989182337,-0.3486275471*scalek,'BendLinearPass',[0 0 0 0],[0 -0.3486275471*scalek -0.0656081148 0.3572852967]);
+% b_left05 = rbend('b_left05',0.0694041758,0.0092692888,0.0989182337,-0.0896518010,-0.3281526271*scalek,'BendLinearPass',[0 0 0 0],[0 -0.3281526271*scalek -0.0355726539 0.3355904266]);
+% b_centre01 = rbend('b_centre01',0.2820465390,0.0367531221,0.0896518010,-0.0529125655,-0.3312315118*scalek,'BendLinearPass',[0 0 0 0],[0 -0.3312315118*scalek 0.0081060667 0.2963931827]);
+% b_centre02 = rbend('b_centre02',0.2815037989,0.0354072962,0.0529125655,-0.0175134439,-0.3306429237*scalek,'BendLinearPass',[0 0 0 0],[0 -0.3306429237*scalek 0.0237264198 -0.2192733272]);
+% b_centre03 = rbend('b_centre03',0.2813281018,0.0349189640,0.0175134439,0.0174054578,-0.3300984023*scalek,'BendLinearPass',[0 0 0 0],[0 -0.3300984023*scalek 0.0101509428 -0.5218382720]);
+% b_centre04 = rbend('b_centre04',0.2814996751,0.0353946633,-0.0174054578,0.0528080683,-0.3302048119*scalek,'BendLinearPass',[0 0 0 0],[0 -0.3302048119*scalek 0.0235987043 -0.2144554284]);
+% b_centre05 = rbend('b_centre05',0.2820380879,0.0367421699,-0.0528080683,0.0895641319,-0.3309037380*scalek,'BendLinearPass',[0 0 0 0],[0 -0.3309037380*scalek 0.0102169077 0.2963545009]);
+% b_right01 = rbend('b_right01',0.0694014448,0.0092683188,-0.0895641319,0.0988345428,-0.3275972520*scalek,'BendLinearPass',[0 0 0 0],[0 -0.3275972520*scalek -0.0308930090 0.3680490900]);
+% b_right02 = rbend('b_right02',0.0694650575,0.0090032960,-0.0988345428,0.1077882518,-0.3467634133*scalek,'BendLinearPass',[0 0 0 0],[0 -0.3467634133*scalek -0.0345063628 0.6218385567]);
+% b_right03 = rbend('b_right03',0.0695141539,0.0037116695,-0.1077882518,0.1112699557,-0.1347732139*scalek,'BendLinearPass',[0 0 0 0],[0 -0.1347732139*scalek 0.0189958278 0.8526578807]);
+% b_right04 = rbend('b_right04',0.0695280819,0.0007961566,-0.1112699557,0.1120205593,-0.0014988960*scalek,'BendLinearPass',[0 0 0 0],[0 -0.0014988960*scalek -0.0849450391 0.2100836063]);
+% b_right05 = rbend('b_right05',0.0695312501,0.0001897883,-0.1120205593,0.1121997376,0.0026764692*scalek,'BendLinearPass',[0 0 0 0],[0 0.0026764692*scalek -0.0276971797 0.0360627830]);
+
+dipole_arc = [leftdrift_a bpm leftdrift_b b_left01 b_left02 b_left03 b_left04 ...
+ b_left05 thinsext b_centre01 b_centre02 b_centre03 b_centre04 ...
+ b_centre05 thinsext b_right01 b_right02 b_right03 b_right04 ...
+ b_right05 rightdrift_a bpm rightdrift_b];
+
+% To match split dipole values from numerical studies (SBENDS)
+% tune of 13.29, 5.216 and 0 dispersion in straights.
+qfa = quadrupole('QFA', 0.355 + quadDL_2*2, 1.725373108609119,'StrMPoleSymplectic4Pass');
+qda = quadrupole('QDA', 0.180 + quadDL_2*2,-1.025718284909907,'StrMPoleSymplectic4Pass');
+qfb = quadrupole('QFB', 0.355 + quadDL_2*2, 1.508194290530376,'StrMPoleSymplectic4Pass');
+
+% Sextupoles with built in correctors. Corrector settings given by kick
+% angle in radians. ([1 1] chromaticity with zero dispersion)
+sfa = sextcorr('SFA', 0.200, 14.00000,[0 0],'StrCorrMPoleSymplectic4Pass');
+sda = sextcorr('SDA', 0.200,-14.00000,[0 0],'StrCorrMPoleSymplectic4Pass');
+sdb = sextcorr('SDB', 0.200,-7.098322,[0 0],'StrCorrMPoleSymplectic4Pass');
+sfb = sextcorr('SFB', 0.200, 7.271212,[0 0],'StrCorrMPoleSymplectic4Pass');
+
+%--------------------------------------------------------------------------
+
+% RF cavity and the corresponding straight used to position the cavity.
+% 4.996540652069698e+008 old freq for 216m for 216.0004 its different. Also
+% we are using ThinCavities therefore the drifts have to be set
+% accordingly.
+cav_single = rfcavity('RF' ,0.0,3.00e+006,ringrf,HarmNumber,'DriftPass');
+cav = rfcavity('RF' ,0.0,0.75e+006,ringrf,HarmNumber,'DriftPass');
+% drifts around the rf cavities and space between them
+d1ar1 = drift('D1AR1' ,len(d1a)-len(cav_single)/2 ,'DriftPass'); % for just 1 cavity
+drf = drift('DRF' ,0.45 ,'DriftPass'); % space between cavities
+d1ar4 = drift('D1AR4' ,len(d1a)-len(cav)-len(drf)/2,'DriftPass'); % for 4 cavities
+cav_pair = [cav drf cav];
+dRF1 = drift('dRF1' ,len(d1)-2.55 ,'DriftPass');
+dRF2 = drift('dRF2' ,2.55/3 ,'DriftPass');
+
+%--------------------------------------------------------------------------
+% Kickers and the associated drifts to position them. (to be checked)
+kicker_14_1 = corrector('KICK' ,0.000000,[0.000000 0.0],'CorrectorPass');
+kicker_01_1 = corrector('KICK' ,0.000000,[0.000000 0.0],'CorrectorPass');
+kicker_01_2 = corrector('KICK' ,0.000000,[0.000000 0.0],'CorrectorPass');
+kicker_02_1 = corrector('KICK' ,0.000000,[0.000000 0.0],'CorrectorPass');
+%fast feedback kicks
+ffbh = corrector('FFBH' ,0.000000,[0.000000 0.0],'CorrectorPass');
+ffbv = corrector('FFBV' ,0.000000,[0.000000 0.0],'CorrectorPass');
+% Drift spaces to replace D1A for the upstream kickers, ie kickers 1 and 3.
+% As in, upstream of the Unit Cell, which is downstream of the centre of
+% the straight.
+% KICKER 1 is kicker 14 1
+d1ak2_up = drift('D1AK2_UP' ,0.779 - len(d1b),'DriftPass');
+d1ak1_up = drift('D1AK1_UP' ,len(d1a) - len(d1ak2_up),'DriftPass');
+% Drift spaces to replace D1A for the downstream kickers, ie kickers 2 and 4.
+d1ak2_do = drift('D1AK2_DO' ,1.073 - len(d1bb),'DriftPass');
+d1ak1_do = drift('D1AK1_DO' ,len(d1aa) - len(d1ak2_do),'DriftPass');
+
+%--------------------------------------------------------------------------
+% Define the position of the bpm. bpm1d1 represents BPM number 1 in the D1
+% straight and bpm5d4 represents BPM number 5 in straight d4. bpm7dk and
+% bpm7dr repreents BPM number 7 in either the kicker stright or RF
+% straight.
+bpm1d1 = [ d1a bpm d1b ];
+bpm1d1r1 = [ d1ar1 bpm d1b ]; % RF 1 cavity
+bpm1d1_id = [bpm d1b];
+%bpm1d1r4 = [ d1ar4 bpm d1b ]; % RF 4 cavity
+bpm2d4 = [ d4a bpm d4b ];
+bpm3d4 = [ d4aa bpm d4bb ];
+bpm4d2 = [ d2a bpm d2b ];
+bpm5d4 = [ bpm2d4 ];
+bpm6d4 = [ bpm3d4 ];
+bpm7d1 = [ d1bb bpm d1aa ];
+bpm7d1r1 = [ d1b bpm d1ar1 ]; % RF 1 cavity
+%bpm7d1r4 = [ d1b bpm d1ar4 ]; % RF 4 cavity
+bpm1d1RF = [ dRF1 bpm dRF2 cav dRF2 cav dRF2 ];
+bpm7d1_id = [ d1bb bpm ];
+
+d1ffb = [];
+bpm7d1ffb = [ d1b bpm d1ffb ]; %fast feedback kicker
+
+% Arrange the elements onto the girders and use markers to define the
+% sections for misalignment studies.
+g1m1 = marker('g1m1','IdentityPass');
+g1m2 = marker('g1m2','IdentityPass');
+g2m1 = marker('g2m1','IdentityPass');
+g2m2 = marker('g2m2','IdentityPass');
+% girder1 = [ g1m1 sfa hcor sfa d2 qfa d3 sda vcor sda g1m2];
+% girder2 = [ g2m1 sdb vcor sdb d5 qda d6 qfb d2 sfb hcor sfb bpm4d2 qfb d6 qda d5 sdb vcor sdb g2m2];
+% girder3 = [ g1m1 sda vcor sda d3 qfa d2 sfa hcor sfa g1m2];
+girder1 = [ g1m1 sfa d2 qfa d3 sda g1m2];
+girder2 = [ g2m1 sdb d5 qda d6 qfb d2 sfb bpm4d2 qfb d6 qda d5 sdb g2m2];
+girder3 = [ g1m1 sda d3 qfa d2 sfa g1m2];
+
+
+% IDs
+%--------------------------------------------------------------------------
+% Want the lattice to be able to place an arbitrary length ID in an
+% arbitrary straight, within the constraint of straights with RF and
+% kickers already installed.
+%
+% To that end, I'm giving the drifts (between the BPMs) to the straights,
+% and the leaving the unit cell as just the unit cell.
+
+% Define the length of the ID
+L_id = [0; %1 kicker - kicker % please don't try to put an ID here
+ 0; %2 kicker - ID
+ 3; %3
+ 0; %4
+ 2; %5
+ 0; %6 ID - RF
+ 0; %7 ID - RF
+ 2.5; %8
+ 0; %9
+ 0; %10
+ 0; %11
+ 2.5; %12
+ 3; %13
+ 2]; %14 ID - kicker
+
+% Total wiggler length [m]
+L_id = [0; %1 kicker - kicker % please don't try to put an ID here
+ 0; %2 kicker - ID
+ 0; %3
+ 0; %4
+ 0; %5
+ 0; %6 ID - RF
+ 0; %7 ID - RF
+ 0; %8
+ 0; %9
+ 0; %10
+ 0; %11
+ 0; %12
+ 0; %13
+ 1.95]; %14 ID - kicker
+
+% Wiggler period [m]
+period_id = [ 0; %1 kicker - kicker % please don't try to put an ID here
+ 0; %2 kicker - ID
+ 0; %3
+ 0; %4
+ 0; %5
+ 0; %6 ID - RF
+ 0; %7 ID - RF
+ 0; %8
+ 0; %9
+ 0; %10
+ 0; %11
+ 0; %12
+ 0; %13
+ 0.075]; %14 ID - kicker
+
+% magnetic field [T]
+Bmax_id = [ 0; %1 kicker - kicker % please don't try to put an ID here
+ 0; %2 kicker - ID
+ 0; %3
+ 0; %4
+ 0; %5
+ 0; %6 ID - RF
+ 0; %7 ID - RF
+ 0; %8
+ 0; %9
+ 0; %10
+ 0; %11
+ 0; %12
+ 0; %13
+ 0.49]; %14 ID - kicker
+
+% Vertical magnetic field [T]
+By_id = [ 0 0 0 0 0; %1 kicker - kicker % please don't try to put an ID here
+ 0 0 0 0 0; %2 kicker - ID
+ 0 0 0 0 0; %3
+ 0 0 0 0 0; %4
+ 0 0 0 0 0; %5
+ 0 0 0 0 0; %6 ID - RF
+ 0 0 0 0 0; %7 ID - RF
+ 0 0 0 0 0; %8
+ 0 0 0 0 0; %9
+ 0 0 0 0 0; %10
+ 0 0 0 0 0; %11
+ 0 0 0 0 0; %12
+ 0 0 0 0 0; %13
+ 0 0 0 0 0]; %14 ID - kicker
+
+ % Vertical magnetic field [T]
+Bx_id = [ 0 0 0 0 0; %1 kicker - kicker % please don't try to put an ID here
+ 0 0 0 0 0; %2 kicker - ID
+ 0 0 0 0 0; %3
+ 0 0 0 0 0; %4
+ 0 0 0 0 0; %5
+ 0 0 0 0 0; %6 ID - RF
+ 0 0 0 0 0; %7 ID - RF
+ 0 0 0 0 0; %8
+ 0 0 0 0 0; %9
+ 0 0 0 0 0; %10
+ 0 0 0 0 0; %11
+ 0 0 0 0 0; %12
+ 0 0 0 0 0; %13
+ 1 1 1 0 0]; %14 ID - kicker
+
+Nstep = 5; % num of integration steps per period
+Nmeth = 4; % symplectic integration method, 2nd or 4th order: 2 or 4
+
+% Kx = 0; Ky = 0; Kxy = 0; Kyx = 0;
+
+for n = 1:14
+ % Define the ID
+ %id(n) = drift('ID',L_id(n), 'Matrix66Pass');
+% id(n) = ins_dev('ID',L_id(n), 'InsDevPass');
+ if L_id(n) ~= 0
+ %id(n) = wiggler('ID', L_id(n), period_id(n), Bmax_id(n), Nstep, Nmeth, [], Bx_id(n,:)', 'WigSymplectic4Pass');
+ id(n) = wiggler('ID', L_id(n), period_id(n), Bmax_id(n), Nstep, Nmeth, [], Bx_id(n,:)', 'WigSymplectic4Pass');
+ else
+ id(n) = drift('ID', 0, 'DriftPass');
+ end
+ % Define transfer matrix
+% FAMLIST{id(n)}.ElemData.M66 = [1 L_id(n) 0 0 0 0;
+% Kx 1 Kxy 0 0 0;
+% Kyx 0 1 L_id(n) 0 0;
+% 0 0 Ky 1 0 0;
+% 0 0 0 0 1 L_id(n);
+% 0 0 0 0 0 1 ];
+ % Define the drifts around it
+ switch n
+ case 1 % kicker kicker
+ bpm7d1_01 = [d1bb bpm d1ak2_do kicker_01_2];
+ d1aa_id(n) = drift('D1A', len(d1ak1_do) - L_id(n)/2,'DriftPass');
+ d1a_id(n) = drift('D1A', len(d1ak1_up) - L_id(n)/2,'DriftPass');
+ bpm1d1_01 = [kicker_01_1 d1ak2_up bpm d1b];
+
+ straight{n} = [bpm7d1_01 d1aa_id(n) id(n) d1a_id(n) bpm1d1_01];
+ straight_01_01 = [bpm7d1_01 d1aa_id(n)];
+ straight_01_02 = [d1a_id(n) bpm1d1_01];
+ case 2 % kicker - ID
+ bpm7d1_02 = [d1bb bpm d1ak2_do kicker_02_1];
+ d1aa_id(n) = drift('D1A', (len(d1ak1_do) + len(d1a) - L_id(n)) ./ 2,'DriftPass');
+ d1a_id(n) = drift('D1A', (len(d1ak1_do) + len(d1a) - L_id(n)) ./ 2,'DriftPass');
+
+ straight{n} = [bpm7d1_02 d1aa_id(n) id(n) d1a_id(n) bpm1d1_id];
+ case 6 % ID - RF
+ d1aa_id(n) = drift('D1A', (len(d1aa) + len(dRF1) - L_id(n))/2,'DriftPass');
+ d1a_id(n) = drift('D1A', (len(d1aa) + len(dRF1) - L_id(n))/2,'DriftPass');
+ bpm1d1_06 = [bpm dRF2 cav dRF2 cav dRF2];
+
+ straight{n} = [bpm7d1_id d1aa_id(n) id(n) d1a_id(n) bpm1d1_06];
+ case 7 % ID - RF
+ d1aa_id(n) = drift('D1A', (len(d1aa) + len(dRF1) - L_id(n))/2,'DriftPass');
+ d1a_id(n) = drift('D1A', (len(d1aa) + len(dRF1) - L_id(n))/2,'DriftPass');
+ bpm1d1_07 = [bpm dRF2 cav dRF2 cav dRF2];
+
+ straight{n} = [bpm7d1_id d1aa_id(n) id(n) d1a_id(n) bpm1d1_07];
+ case 14 % ID - kicker
+ d1aa_id(n) = drift('D1A', (len(d1ak1_up) + len(d1aa) - L_id(n)) ./ 2,'DriftPass');
+ d1a_id(n) = drift('D1A', (len(d1ak1_up) + len(d1aa) - L_id(n)) ./ 2,'DriftPass');
+ bpm1d1_14 = [kicker_14_1 d1ak2_up bpm d1b];
+
+ straight{n} = [bpm7d1_id d1aa_id(n) id(n) d1a_id(n) bpm1d1_14];
+ otherwise % Normal straight
+ % Define drifts around ID
+ d1aa_id(n) = drift('D1A', len(d1aa) - L_id(n)/2,'DriftPass');
+ d1a_id(n) = drift('D1A', len(d1a) - L_id(n)/2,'DriftPass');
+% % Define position of BPMs for ID lattice definition
+% for n = 1:14
+% bpm7d1_id(n) = [d1bb bpm d1aa_id(n)];
+% bpm1d1_id(n) = [d1a_id(n) bpm d1b];
+% end
+
+ straight{n} = [d1bb bpm d1aa_id(n) id(n) d1a_id(n) bpm d1b];
+ end
+end
+
+% Define the special straights
+
+%-------------------------------------------------------------------------
+% Ring lattices
+
+% ID ring
+arc_cell = [girder1 dipole_arc girder2 dipole_arc girder3];
+%cavity4ringkent = [ ap straight{1} arc_cell straight{2} arc_cell straight{3} arc_cell straight{4} arc_cell straight{5} arc_cell straight{6} arc_cell straight{7} arc_cell straight{8} arc_cell straight{9} arc_cell straight{10} arc_cell straight{11} arc_cell straight{12} arc_cell straight{13} arc_cell straight{14} arc_cell];
+%2012_03_05 - need to start in middle of straight 1 to have BPM index correct.
+cavity4ringkent = [ ap id(1) straight_01_02 arc_cell straight{2} arc_cell straight{3} arc_cell straight{4} arc_cell straight{5} arc_cell straight{6} arc_cell straight{7} arc_cell straight{8} arc_cell straight{9} arc_cell straight{10} arc_cell straight{11} arc_cell straight{12} arc_cell straight{13} arc_cell straight{14} arc_cell straight_01_01];
+
+% % Arrange the girders into the different cell arrangements.
+% unit_cel = [bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1];
+% % Kickers in cells 1 and 14
+% % celkick14 = [ bpm1d1k(kicker_14_1) girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1k(kicker_01_1) ];
+% % celkick01 = [ bpm1d1k(kicker_01_2) girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1k(kicker_02_1) ];
+% % Shorten the straights in cells 6, 7 and 8 to put in the rf
+% % 4 RF cavities
+%
+% celrf06_4 = [ bpm1d1RF girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+% celrf07_4 = [ bpm1d1RF girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+% %celrf06_4 = [ bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1r4 ];
+% %celrf07_4 = [ bpm1d1r4 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1r4 ];
+% %celrf08_4 = [ bpm1d1r4 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+%
+% % Single RF cavity
+% celrf06_1 = [ bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1r1 ];
+% celrf07_1 = [ bpm1d1r1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+% %diagnostic straight with fast feedback kicker
+% celffb10_1 = [ bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1ffb ]; %includes fast feedback kicker
+%
+% % Shift sector
+% shift1 = quadrupole('SHIFT1' ,0, 0,'QuadLinearPass');
+% shift2 = quadrupole('SHIFT2' ,0, 0,'QuadLinearPass');
+
+% Definition of the types of rings
+% kickring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+% cavity1ring = [ ap celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+% cavity4ring = [ ap celrf06_4 cav_pair celrf07_4 cav_pair celrf08_4 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+% cavity1ring = [ ap id celkick01 id unit_cel id unit_cel id unit_cel id unit_cel id celrf06_1 id cav_single id celrf07_1 id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id celkick14];
+% cavity4ring = [ ap id celkick01 id unit_cel id unit_cel id unit_cel id unit_cel id celrf06_4 id celrf07_4 id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id celkick14];
+
+%cavity4ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_4 cav_pair celrf07_4 cav_pair celrf08_4 unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+
+% Ring starting with the RF
+% fullring_startwithRF = [ ap cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 ];
+% Ring with no RF and no Kickers
+% ring = [ ap unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+% Ring starting in straight 14 rather than straight 1, outside of the kick orbit.
+% fullring = [ ap celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+% fast feedback kicker included:
+% ffbring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel celffb10_1 unit_cel unit_cel unit_cel celkick14];
+
+% Choose which lattice to load else load "fullring" as the default.
+if nargin > 0
+ fprintf('Using lattice : %s \n', varargin{1});
+ eval(['buildlat(' varargin{1} ');']);
+else
+ % Default lattice to load
+ fprintf('Using default lattice : cavity4ringkent\n');
+ buildlat(cavity4ringkent);
+end
+
+% Make the variables THERING and GLOBVAL available to the caller's
+% workspace.
+evalin('caller','global THERING GLOBVAL');
+disp('** Done **');
+
+% New AT 1.3 does not require FAMLIST and is fazing out GLOBVAL
+clear global FAMLIST
+
+setenergymodel(3);
+
+% Internal function used to return the length of a defined element.
+function res = len(id)
+global FAMLIST
+res = FAMLIST{id}.ElemData.Length;
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/assr4_splitbends_mod.m b/machine/ASP/StorageRing/assr4_splitbends_mod.m
new file mode 100644
index 00000000..98d69a23
--- /dev/null
+++ b/machine/ASP/StorageRing/assr4_splitbends_mod.m
@@ -0,0 +1,386 @@
+function assr4(varargin)
+% Lattice definition file - generated by dimad2at v1.300000
+%
+% Eugene 2004-12-13 Updating the generalised file to realign the family
+% names and elements with aspinit. NOTE: aspinit will not work with split
+% elements... not without modification of the init file.
+%
+% Eugene 2005-09-16 Standardise all lattices being used to this. "Custom"
+% versions of the lattice files, eg for ML, ID studies etc will take this
+% file as a template. The following major changes were made -
+% * All family names in CAPS in line with ALS and SPEAR convention.
+% * Dipole path and gradient updated to reflect numerical studies on
+% measured data. Quadrupole values fitted for a tune of 13.3, 5.2 and
+% zero dispersion given the new dipole gradient fields.
+% * Merged with "aspsr_msrf.m" with independent/individual cavitie(s).
+% * Element positions/lengths should be inline with engineering
+% drawings.
+%
+% Eugene 2010-07-08
+% * now we define the RF frequency and this will automatically scale the
+% drift sections to match
+% * Changed the dipole pass method to BndMPoleSymplectic4E2Pass that
+% correctly tracks off energy particles through the dipole.
+% * added scaling factors.
+%
+% Eugene 2010-07-27
+% * Plan to make this lattice the standard general lattice for all LOCO
+% fits.
+% * Added IDs into this lattice. Scaling of 'quadDL_2', 'scalek' and
+% 'scalem' set by balancing the relative quadrupole strengths between
+% families so that they are the same as in the machine. The sextupole
+% component was scaled so that the modeled chromaticity matches what we
+% measure.
+%
+% Eugene 2011-07-20
+% * Finally added the calibrated cavity voltage. The ring energy was
+% changed in July 2010 after direct measurement however the cavity voltage
+% was not changed.
+
+global FAMLIST THERING GLOBVAL
+
+GLOBVAL.E0 = 3.0134e9; % Measured by Harris and Kent using resonant depolrasiation July 2010.
+GLOBVAL.LatticeFile = mfilename;
+FAMLIST = cell(0);
+
+arclen = 10.031590015999972; % length bpm to bpm without the straight sections.
+ringrf = 499670012; 499.6685923893040e6; 499666449;
+ringrf = 499.675982e6; % 16/01/2017 ET
+C0 = 299792458; % speed of light [m/s]
+HarmNumber = 360;
+L0 = C0*HarmNumber/ringrf;
+halfstraightlength = (L0/14-arclen)/2; (L0 - arclen*14)/14/2;
+% L0 = 2.159946602239996e+02;
+% L0 = 2.159946602239993e+02; % calculated using findspos %215.9945540689991;% with new dipole path lengths. Designed for 216m.
+
+
+disp(' ');
+fprintf('*** Loading lattice from %s.m ***\n',GLOBVAL.LatticeFile);
+
+% With AT1.3 ringpass and linepass, particles limited by the apperturepass
+% will have [x,x',y,y',delta,dl] = [NaN,0,0,0,0,0]. All pass methods will
+% check for this and do nothing to particles with these coordinates.
+% Ring/linepass will both return particle positions as well as the number
+% of turns the particles achieved.
+% ap = aperture('AP',[-32 17 -16 16]*1e-3,'AperturePass');
+ap = aperture('AP',[-16 17 -16 16]*1e2,'AperturePass');
+
+% Quadrupole field extent on one end past the magnet iron length as
+% measured by RMIT student Neville.
+% Empirically modified so relative strengths between QFA, QDA and QFB are
+% the same as those set on the ring.
+quadDL_2 = 0.0042;
+d1 = drift('D1' ,halfstraightlength,'DriftPass'); % (2.698286 -> to get closer to the design distance of 216m)
+% d1 = drift('D1' ,2.698286,'DriftPass'); % (2.698286 -> to get closer to the design distance of 216m)
+d2 = drift('D2' ,1.900000e-001-quadDL_2,'DriftPass');
+d3 = drift('D3' ,1.650000e-001-quadDL_2,'DriftPass');
+d4 = drift('D4' ,2.750000e-001,'DriftPass');
+d5 = drift('D5' ,1.550000e-001-quadDL_2,'DriftPass');
+d6 = drift('D6' ,4.500000e-001-quadDL_2*2,'DriftPass');
+
+% Modified drifts around BPM sections.
+bpm = monitor('BPM' ,'IdentityPass');
+d1a = drift('D1A' ,len(d1)-3.942860e-001,'DriftPass'); % 2.304000e+000
+d1b = drift('D1B' , 3.942860e-001,'DriftPass');
+d1aa= drift('D1A' ,len(d1)-0.58,'DriftPass'); % Last bpm
+d1bb= drift('D1B' , 0.58,'DriftPass');
+d4a = drift('D4A' ,len(d4)-1.990000e-001,'DriftPass'); % 7.600000e-002
+d4b = drift('D4B' , 1.990000e-001,'DriftPass');
+d4aa = drift('D4AA' ,len(d4)-6.400000e-002,'DriftPass'); % 2.110000e-001
+d4bb = drift('D4BB' , 6.400000e-002,'DriftPass');
+d2a = drift('D2A' ,len(d2)-1.030000e-001,'DriftPass'); % 8.700000e-002
+d2b = drift('D2B' , 1.030000e-001,'DriftPass');
+
+% Dipoles
+% design -> rbendMod('BEND',1.726000e+000,2.243995e-001,...
+% 1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
+% From numerical studies -> L: 1.72579121675e+000
+% K: 0.33295132
+% Sext: 0.01092687
+% Oct: 0.15166053
+dip1 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BendLinearPass');
+dip2 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BendLinearPass');
+
+scalek = 1;
+scalem = 3.15; % Sextupole component scaled to get model chromaticities to match with measured chromaticities
+scalen = 0.0;
+thinsext = sextupole('thinsext' ,0,0.0,'ThinMPolePass');
+leftdrift_a = drift('leftdrift',0.076,'DriftPass');
+leftdrift_b = drift('leftdrift',0.0837626757-len(leftdrift_a),'DriftPass');
+rightdrift_b = drift('rightdrift',0.064,'DriftPass');
+rightdrift_a = drift('rightdrift',0.0887292346-len(rightdrift_b),'DriftPass');
+
+b_left01 = rbendMod('b_left01',0.0695312761,0.0001684486,0.0000000000,0.0000000000,-0.0058550750*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0058550750*scalek 0.0862147892*scalem -1.2289013273*scalen]);
+b_left02 = rbendMod('b_left02',0.0695282915,0.0007117061,0.0000000000,0.0000000000,-0.0239389168*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0239389168*scalek -0.0583359949*scalem -0.0632750927*scalen]);
+b_left03 = rbendMod('b_left03',0.0695152451,0.0032675350,0.0000000000,0.0000000000,-0.2254325358*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.2254325358*scalek 0.2451727966*scalem -0.1103893288*scalen]);
+b_left04 = rbendMod('b_left04',0.0694679183,0.0087995936,0.0000000000,0.0000000000,-0.4158165694*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.4158165694*scalek -0.1443627022*scalem 0.6681103839*scalen]);
+b_left05 = rbendMod('b_left05',0.0694041758,0.0092692887,0.0000000000,0.0000000000,-0.3298403749*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3298403749*scalek -0.0340207205*scalem 0.3349521492*scalen]);
+b_centre01 = rbendMod('b_centre01',0.2820465390,0.0367531161,0.0000000000,0.0000000000,-0.3315842393*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3315842393*scalek 0.0083655817*scalem 0.2965845308*scalen]);
+b_centre02 = rbendMod('b_centre02',0.2815037989,0.0354072994,0.0000000000,0.0000000000,-0.3306516396*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3306516396*scalek 0.0236710994*scalem -0.2196079070*scalen]);
+
+b_centre03a = rbendMod('b_centre03',0.2813281018*0.2962,0.0349189639*0.2962,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673*scalem -0.5218735605*scalen]);
+b_centre03b = rbendMod('b_centre04',0.2813281018*0.4998,0.0349189639*0.4998,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673*scalem -0.5218735605*scalen]);
+b_centre03c = rbendMod('b_centre05',0.2813281018*0.2040,0.0349189639*0.2040,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673*scalem -0.5218735605*scalen]);
+source_six = marker('source_six','IdentityPass'); % Dipole 2
+source_seven = marker('source_seven','IdentityPass'); % Dipole 1
+b_centre03 = [b_centre03a source_six b_centre03b source_seven b_centre03c];
+%b_centre03 = rbendMod('b_centre03',0.2813281018,0.0349189639,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673 -0.5218735605]);
+
+b_centre04 = rbendMod('b_centre06',0.2814996751,0.0353946664,0.0000000000,0.0000000000,-0.3302155286*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3302155286*scalek 0.0236248098*scalem -0.2148826863*scalen]);
+b_centre05 = rbendMod('b_centre07',0.2820380879,0.0367421671,0.0000000000,0.0000000000,-0.3312220213*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3312220213*scalek 0.0103909753*scalem 0.2969171603*scalen]);
+b_right01 = rbendMod('b_right01',0.0694014448,0.0092683157,0.0000000000,0.0000000000,-0.3292611055*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3292611055*scalek -0.0291322494*scalem 0.3681905186*scalen]);
+b_right02 = rbendMod('b_right02',0.0694650575,0.0090036557,0.0000000000,0.0000000000,-0.3961176951*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3961176951*scalek -0.1539214712*scalem 0.9528854933*scalen]);
+b_right03 = rbendMod('b_right03',0.0695141539,0.0037120061,0.0000000000,0.0000000000,-0.2701751814*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.2701751814*scalek 0.3742213022*scalem 0.7022676128*scalen]);
+b_right04 = rbendMod('b_right04',0.0695280819,0.0007962279,0.0000000000,0.0000000000,-0.0288159660*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0288159660*scalek -0.0571472318*scalem 0.2460706289*scalen]);
+b_right05 = rbendMod('b_right05',0.0695312501,0.0001902235,0.0000000000,0.0000000000,-0.0028161106*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0028161106*scalek -0.1077402629*scalem 0.7697020810*scalen]);
+
+% RBEND
+% b_left01 = rbend('b_left01',0.0695312761,0.0001700782,0.1121962211,-0.1120187381,0.0026580668*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 0.0026580668*scalek -0.0222542890 -0.0307698880]);
+% b_left02 = rbend('b_left02',0.0695282915,0.0007118132,0.1120187381,-0.1112734474,0.0004302895*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 0.0004302895*scalek -0.0824996146 -0.0652385243]);
+% b_left03 = rbend('b_left03',0.0695152451,0.0032678721,0.1112734474,-0.1078414785,-0.1045888695*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.1045888695*scalek -0.0928717833 0.2254072448]);
+% b_left04 = rbend('b_left04',0.0694679183,0.0088002187,0.1078414785,-0.0989182337,-0.3486275471*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3486275471*scalek -0.0656081148 0.3572852967]);
+% b_left05 = rbend('b_left05',0.0694041758,0.0092692888,0.0989182337,-0.0896518010,-0.3281526271*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3281526271*scalek -0.0355726539 0.3355904266]);
+% b_centre01 = rbend('b_centre01',0.2820465390,0.0367531221,0.0896518010,-0.0529125655,-0.3312315118*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3312315118*scalek 0.0081060667 0.2963931827]);
+% b_centre02 = rbend('b_centre02',0.2815037989,0.0354072962,0.0529125655,-0.0175134439,-0.3306429237*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3306429237*scalek 0.0237264198 -0.2192733272]);
+% b_centre03 = rbend('b_centre03',0.2813281018,0.0349189640,0.0175134439,0.0174054578,-0.3300984023*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3300984023*scalek 0.0101509428 -0.5218382720]);
+% b_centre04 = rbend('b_centre04',0.2814996751,0.0353946633,-0.0174054578,0.0528080683,-0.3302048119*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3302048119*scalek 0.0235987043 -0.2144554284]);
+% b_centre05 = rbend('b_centre05',0.2820380879,0.0367421699,-0.0528080683,0.0895641319,-0.3309037380*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3309037380*scalek 0.0102169077 0.2963545009]);
+% b_right01 = rbend('b_right01',0.0694014448,0.0092683188,-0.0895641319,0.0988345428,-0.3275972520*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3275972520*scalek -0.0308930090 0.3680490900]);
+% b_right02 = rbend('b_right02',0.0694650575,0.0090032960,-0.0988345428,0.1077882518,-0.3467634133*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.3467634133*scalek -0.0345063628 0.6218385567]);
+% b_right03 = rbend('b_right03',0.0695141539,0.0037116695,-0.1077882518,0.1112699557,-0.1347732139*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.1347732139*scalek 0.0189958278 0.8526578807]);
+% b_right04 = rbend('b_right04',0.0695280819,0.0007961566,-0.1112699557,0.1120205593,-0.0014988960*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 -0.0014988960*scalek -0.0849450391 0.2100836063]);
+% b_right05 = rbend('b_right05',0.0695312501,0.0001897883,-0.1120205593,0.1121997376,0.0026764692*scalek,'BndMPoleSymplectic4E2Pass',[0 0 0 0],[0 0.0026764692*scalek -0.0276971797 0.0360627830]);
+
+dipole_arc = [leftdrift_a bpm leftdrift_b b_left01 b_left02 b_left03 b_left04 ...
+ b_left05 thinsext b_centre01 b_centre02 b_centre03 b_centre04 ...
+ b_centre05 thinsext b_right01 b_right02 b_right03 b_right04 ...
+ b_right05 rightdrift_a bpm rightdrift_b];
+
+% To match split dipole values from numerical studies (SBENDS)
+% tune of 13.29, 5.216 and 0.1 dispersion in straights.
+qfa = quadrupole('QFA' ,3.550000e-001 + quadDL_2*2, 1.733657724410066,'StrMPoleSymplectic4Pass');
+qda = quadrupole('QDA' ,1.800000e-001 + quadDL_2*2,-1.022013422983443,'StrMPoleSymplectic4Pass');
+qfb = quadrupole('QFB' ,3.550000e-001 + quadDL_2*2, 1.501312135889473,'StrMPoleSymplectic4Pass');
+
+% Sextupoles with built in correctors. Corrector settings given by kick
+% angle in radians. ([1 1] chromaticity with zero dispersion)
+%sfa = sextcorr('SFA' ,2.000000e-001, 1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
+%sda = sextcorr('SDA' ,2.000000e-001,-1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
+%sdb = sextcorr('SDB' ,2.000000e-001,-7.098322,[0 0],'StrCorrMPoleSymplectic4Pass');
+%sfb = sextcorr('SFB' ,2.000000e-001, 7.271212,[0 0],'StrCorrMPoleSymplectic4Pass');
+sfa = sextupole('SFA' ,2.000000e-001, 1.400000e+001,'StrMPoleSymplectic4Pass');
+sda = sextupole('SDA' ,2.000000e-001,-1.400000e+001,'StrMPoleSymplectic4Pass');
+sdb = sextupole('SDB' ,2.000000e-001,-7.098322,'StrMPoleSymplectic4Pass');
+sfb = sextupole('SFB' ,2.000000e-001, 7.271212,'StrMPoleSymplectic4Pass');
+
+FAMLIST{sfa}.ElemData.KickAngle = [0 0];
+FAMLIST{sda}.ElemData.KickAngle = [0 0];
+FAMLIST{sfb}.ElemData.KickAngle = [0 0];
+FAMLIST{sdb}.ElemData.KickAngle = [0 0];
+
+id = marker('ID','Matrix66Pass');
+L = 0;
+Kx = 0; Ky = 0;
+FAMLIST{id}.ElemData.M66 = [1 L 0 0 0 0;
+ Kx 1 0 0 0 0;
+ 0 0 1 L 0 0;
+ 0 0 Ky 1 0 0;
+ 0 0 0 0 1 0;
+ 0 0 0 0 0 1];
+
+
+% RF cavity and the corresponding straight used to position the cavity.
+% 4.996540652069698e+008 old freq for 216m for 216.0004 its different. Also
+% we are using ThinCavities therefore the drifts have to be set
+% accordingly.
+
+cav_single = rfcavityMod('RF' ,0.0,2993700,ringrf,HarmNumber,GLOBVAL.E0,'CavityPass');
+cav = rfcavityMod('RF' ,0.0,2993700/4,ringrf,HarmNumber,GLOBVAL.E0,'CavityPass');
+% drifts around the rf cavities and space between them
+d1ar1 = drift('D1AR1' ,len(d1a)-len(cav_single)/2 ,'DriftPass'); % for just 1 cavity
+drf = drift('DRF' ,0.45 ,'DriftPass'); % space between cavities
+d1ar4 = drift('D1AR4' ,len(d1a)-len(cav)-len(drf)/2,'DriftPass'); % for 4 cavities
+cav_pair = [cav drf cav];
+dRF1 = drift('dRF1' ,len(d1)-2.55 ,'DriftPass');
+dRF2 = drift('dRF2' ,2.55/3 ,'DriftPass');
+
+% Kickers and the associated drifts to position them. (to be checked)
+kick1 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick2 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick3 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick4 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+%fast feedback kicks
+ffbh = corrector('FFBH' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+ffbv = corrector('FFBV' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+% Drift spaces to replace D1A for the upstream kickers, ie kickers 1 and 3.
+% d1ak2_up= drift('D1AK2_UP' ,0.779 - len(d1b),'DriftPass');
+d1ak2_up= drift('D1AK2_UP' ,0.779 - len(d1b),'DriftPass');
+d1ak1_up= drift('D1AK1_UP' ,len(d1a) - len(d1ak2_up),'DriftPass');
+% Drift spaces to replace D1A for the downstream kickers, ie kickers 2 and 4.
+d1ak2_do= drift('D1AK2_DO' ,1.073 - len(d1bb),'DriftPass');
+d1ak1_do= drift('D1AK1_DO' ,len(d1aa) - len(d1ak2_do),'DriftPass');
+
+%fast feedback kicks
+fcorr = [];
+% fcorr = corrector('FCORR' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+
+
+% Define the position of the bpm. bpm1d1 represents BPM number 1 in the D1
+% straight and bpm5d4 represents BPM number 5 in straight d4. bpm7dk and
+% bpm7dr repreents BPM number 7 in either the kicker stright or RF
+% straight.
+bpm1d1 = [ d1a bpm fcorr d1b ];
+bpm1d1k = inline(['[' num2str(d1ak1_up) ' ' 'kicker ' num2str(d1ak2_up) ' ' num2str(bpm) ' ' num2str(fcorr) ' ' num2str(d1b) ' ' ']' ], 'kicker'); % Kicker
+bpm1d1r1 = [ d1ar1 bpm fcorr d1b ]; % RF 1 cavity
+bpm1d1RF = [ dRF1 bpm fcorr dRF2 cav dRF2 cav dRF2 ];
+bpm2d4 = [ d4a bpm d4b ];
+bpm3d4 = [ d4aa bpm d4bb ];
+bpm4d2 = [ d2a bpm d2b ];
+bpm5d4 = [ bpm2d4 ];
+bpm6d4 = [ bpm3d4 ];
+bpm7d1 = [ d1bb bpm fcorr d1aa ];
+bpm7d1k = inline(['[' num2str(d1bb) ' ' num2str(fcorr) ' ' num2str(bpm) ' ' num2str(d1ak2_do) ' ' 'kicker ' num2str(d1ak1_do) ' ' ']' ], 'kicker'); % Kicker
+bpm7d1r1 = [ d1b bpm fcorr d1ar1 ]; % RF 1 cavity
+
+d1ffb = [];
+bpm7d1ffb = [ d1b bpm d1ffb ]; %fast feedback kicker
+
+% Arrange the elements onto the girders and use markers to define the
+% sections for misalignment studies.
+g1m1 = marker('g1m1','IdentityPass');
+g1m2 = marker('g1m2','IdentityPass');
+g2m1 = marker('g2m1','IdentityPass');
+g2m2 = marker('g2m2','IdentityPass');
+% girder1 = [ g1m1 sfa hcor sfa d2 qfa d3 sda vcor sda g1m2];
+% girder2 = [ g2m1 sdb vcor sdb d5 qda d6 qfb d2 sfb hcor sfb bpm4d2 qfb d6 qda d5 sdb vcor sdb g2m2];
+% girder3 = [ g1m1 sda vcor sda d3 qfa d2 sfa hcor sfa g1m2];
+girder1 = [ g1m1 sfa d2 qfa d3 sda g1m2];
+girder2 = [ g2m1 sdb d5 qda d6 qfb d2 sfb bpm4d2 qfb d6 qda d5 sdb g2m2];
+girder3 = [ g1m1 sda d3 qfa d2 sfa g1m2];
+
+
+% Arrange the girders into the different cell arrangements.
+unit_cel = [ bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+unit_cel2 = [unit_cel unit_cel];
+unit_cel3 = [unit_cel unit_cel unit_cel];
+unit_cel7 = [unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel];
+% Kickers in cells 1 and 14
+celkick14 = [ bpm1d1k(kick1) girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1k(kick2) ];
+celkick01 = [ bpm1d1k(kick3) girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1k(kick4) ];
+% Shorten the straights in cells 6, 7 and 8 to put in the rf
+% 4 RF cavities
+
+celrf06_4 = [ bpm1d1RF girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+celrf07_4 = [ bpm1d1RF girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+%celrf06_4 = [ bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1r4 ];
+%celrf07_4 = [ bpm1d1r4 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1r4 ];
+%celrf08_4 = [ bpm1d1r4 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+
+% Single RF cavity
+celrf06_1 = [ bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1r1 ];
+celrf07_1 = [ bpm1d1r1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+%diagnostic straight with fast feedback kicker
+celffb10_1 = [ bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1ffb ]; %includes fast feedback kicker
+
+% Shift sector
+shift1 = quadrupole('SHIFT1' ,0, 0,'QuadLinearPass');
+shift2 = quadrupole('SHIFT2' ,0, 0,'QuadLinearPass');
+
+% Definition of the types of rings
+kickring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+% cavity1ring = [ ap celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+% cavity4ring = [ ap celrf06_4 cav_pair celrf07_4 cav_pair celrf08_4 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+cavity1ring = [ ap id celkick01 id unit_cel id unit_cel id unit_cel id unit_cel id celrf06_1 id cav_single id celrf07_1 id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id celkick14];;
+cavity4ring = [ ap id celkick01 id unit_cel id unit_cel id unit_cel id unit_cel id celrf06_4 id celrf07_4 id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id unit_cel id celkick14];
+
+%cavity4ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_4 cav_pair celrf07_4 cav_pair celrf08_4 unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+
+% Ring starting with the RF
+fullring_startwithRF = [ ap cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 ];
+% Ring with no RF and no Kickers
+ring = [ ap unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+% Ring starting in straight 14 rather than straight 1, outside of the kick orbit.
+fullring = [ ap celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+% fast feedback kicker included:
+ffbring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel celffb10_1 unit_cel unit_cel unit_cel celkick14];
+
+% Choose which lattice to load else load "fullring" as the default.
+if nargin > 0
+ fprintf('Using lattice : %s \n', varargin{1});
+ eval(['buildlat(' varargin{1} ');']);
+else
+ % Default lattice to load
+ fprintf('Using default lattice : cavity4ring\n');
+ buildlat(cavity4ring);
+end
+
+% Make the variables THERING and GLOBVAL available to the caller's
+% workspace.
+evalin('caller','global THERING GLOBVAL');
+disp('** Done **');
+
+% New AT 1.3 does not require FAMLIST and is fazing out GLOBVAL
+clear global FAMLIST
+
+%setenergymodel(GLOBVAL.E0*1e-9);
+
+% Internal function used to return the length of a defined element.
+function res = len(id)
+global FAMLIST
+res = FAMLIST{id}.ElemData.Length;
+
+
+%modified rbend function
+function z=rbendMod(fname,L,A,A1,A2,K,method,PolynomA,PolynomB)
+%BEND('FAMILYNAME', Length[m], BendingAngle[rad], EntranceAngle[rad],
+% ExitAngle[rad], K, 'METHOD')
+% creates a new family in the FAMLIST - a structure with fields
+% FamName family name
+% Length length of the arc for an on-energy particle [m]
+% BendingAngle total bending angle [rad]
+% EntranceAngle [rad] (A/2 - for rectangular bends)
+% ExitAngle [rad] (A/2 - for rectangular bends)
+% ByError error in the dipole field relative to the design value
+% K quadrupole K-value for combined funtion bends
+% PassMethod name of the function to use for tracking
+% returns assigned address in the FAMLIST that is uniquely identifies
+% the family
+
+ElemData=atrbend(fname,L,A,K,method);
+ElemData.EntranceAngle=A1; %for backwards compatibility
+ElemData.ExitAngle=A2;
+ElemData.PolynomA=PolynomA;
+ElemData.PolynomB=PolynomB;
+ElemData.MaxOrder=3;
+
+
+global FAMLIST
+z = length(FAMLIST)+1; % number of declare families including this one
+FAMLIST{z}.FamName = fname;
+FAMLIST{z}.NumKids = 0;
+FAMLIST{z}.KidsList= [];
+FAMLIST{z}.ElemData= ElemData;
+
+
+function z = rfcavityMod(fname,L,V,F,H,E,method)
+%RFCAVITY('FAMILYNAME',Length [m],Voltage[V], Frequency[Hz], Harmonic Number,'METHOD')
+% creates a new family in the FAMLIST - a structure with fields
+% FamName family name
+% Length length[m]
+% Voltage peak voltage (V)
+% Frequency RF frequency [Hz]
+% HarmNumber Harmonic Number
+% PassMethod name of the function on disk to use for tracking
+% returns assigned address in the FAMLIST that uniquely identifies
+% the family
+
+ElemData = atrfcavity(fname,L,V,F,H,E,method);
+
+global FAMLIST
+z = length(FAMLIST)+1; % number of declare families including this one
+FAMLIST{z}.FamName = fname;
+FAMLIST{z}.NumKids = 0;
+FAMLIST{z}.KidsList= [];
+FAMLIST{z}.ElemData= ElemData;
+
+
diff --git a/machine/ASP/StorageRing/assr4_splitbends_sourcedip.m b/machine/ASP/StorageRing/assr4_splitbends_sourcedip.m
new file mode 100644
index 00000000..e0b3e612
--- /dev/null
+++ b/machine/ASP/StorageRing/assr4_splitbends_sourcedip.m
@@ -0,0 +1,297 @@
+function assr4(varargin)
+% Lattice definition file - generated by dimad2at v1.300000
+%
+% Eugene 2004-12-13 Updating the generalised file to realign the family
+% names and elements with aspinit. NOTE: aspinit will not work with split
+% elements... not without modification of the init file.
+%
+% Eugene 2005-09-16 Standardise all lattices being used to this. "Custom"
+% versions of the lattice files, eg for ML, ID studies etc will take this
+% file as a template. The following major changes were made -
+% * All family names in CAPS in line with ALS and SPEAR convention.
+% * Dipole path and gradient updated to reflect numerical studies on
+% measured data. Quadrupole values fitted for a tune of 13.3, 5.2 and
+% zero dispersion given the new dipole gradient fields.
+% * Merged with "aspsr_msrf.m" with independent/individual cavitie(s).
+% * Element positions/lengths should be inline with engineering
+% drawings.
+
+global FAMLIST THERING GLOBVAL
+
+GLOBVAL.E0 = 3e9;
+GLOBVAL.LatticeFile = mfilename;
+FAMLIST = cell(0);
+
+L0 = 2.159946602239996e+02;
+L0 = 2.159946602239993e+02; % calculated using findspos %215.9945540689991;% with new dipole path lengths. Designed for 216m.
+C0 = 299792458; % speed of light [m/s]
+HarmNumber = 360;
+
+disp(' ');
+fprintf('*** Loading lattice from %s.m ***\n',GLOBVAL.LatticeFile);
+
+% With AT1.3 ringpass and linepass, particles limited by the apperturepass
+% will have [x,x',y,y',delta,dl] = [NaN,0,0,0,0,0]. All pass methods will
+% check for this and do nothing to particles with these coordinates.
+% Ring/linepass will both return particle positions as well as the number
+% of turns the particles achieved.
+% ap = aperture('AP',[-32 17 -16 16]*1e-3,'AperturePass');
+ap = aperture('AP',[-16 17 -16 16]*1e2,'AperturePass');
+
+d1 = drift('D1' ,2.698300e+000,'DriftPass'); % (2.698286 -> to get closer to the design distance of 216m)
+d2 = drift('D2' ,1.900000e-001,'DriftPass');
+d3 = drift('D3' ,1.650000e-001,'DriftPass');
+d4 = drift('D4' ,2.750000e-001,'DriftPass');
+d5 = drift('D5' ,1.550000e-001,'DriftPass');
+d6 = drift('D6' ,4.500000e-001,'DriftPass');
+
+% Modified drifts around BPM sections.
+bpm = monitor('BPM' ,'IdentityPass');
+d1a = drift('D1A' ,len(d1)-3.942860e-001,'DriftPass'); % 2.304000e+000
+d1b = drift('D1B' , 3.942860e-001,'DriftPass');
+d1aa= drift('D1A' ,len(d1)-0.58,'DriftPass'); % Last bpm
+d1bb= drift('D1B' , 0.58,'DriftPass');
+d4a = drift('D4A' ,len(d4)-1.990000e-001,'DriftPass'); % 7.600000e-002
+d4b = drift('D4B' , 1.990000e-001,'DriftPass');
+d4aa = drift('D4AA' ,len(d4)-6.400000e-002,'DriftPass'); % 2.110000e-001
+d4bb = drift('D4BB' , 6.400000e-002,'DriftPass');
+d2a = drift('D2A' ,len(d2)-1.030000e-001,'DriftPass'); % 8.700000e-002
+d2b = drift('D2B' , 1.030000e-001,'DriftPass');
+
+% Dipoles
+% design -> rbend('BEND',1.726000e+000,2.243995e-001,...
+% 1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
+% From numerical studies -> L: 1.72579121675e+000
+% K: 0.33295132
+% Sext: 0.01092687
+% Oct: 0.15166053
+dip1 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BndMPoleSymplectic4Pass');
+dip2 = rbend('BEND' ,1.72579121675e+000,2.243995e-001,1.121997e-001,1.121997e-001,-0.33295132,'BndMPoleSymplectic4Pass');
+
+scalek = 1.00;
+leftdrift_a = drift('leftdrift',0.076,'DriftPass');
+leftdrift_b = drift('leftdrift',0.0837626757-len(leftdrift_a),'DriftPass');
+rightdrift_b = drift('rightdrift',0.064,'DriftPass');
+rightdrift_a = drift('rightdrift',0.0887292346-len(rightdrift_b),'DriftPass');
+
+b_left01 = rbend('b_left01',0.0695312761,0.0001684486,0.0000000000,0.0000000000,-0.0058550750*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0058550750*scalek 0.0862147892 -1.2289013273]);
+b_left02 = rbend('b_left02',0.0695282915,0.0007117061,0.0000000000,0.0000000000,-0.0239389168*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0239389168*scalek -0.0583359949 -0.0632750927]);
+b_left03 = rbend('b_left03',0.0695152451,0.0032675350,0.0000000000,0.0000000000,-0.2254325358*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.2254325358*scalek 0.2451727966 -0.1103893288]);
+b_left04 = rbend('b_left04',0.0694679183,0.0087995936,0.0000000000,0.0000000000,-0.4158165694*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.4158165694*scalek -0.1443627022 0.6681103839]);
+b_left05 = rbend('b_left05',0.0694041758,0.0092692887,0.0000000000,0.0000000000,-0.3298403749*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3298403749*scalek -0.0340207205 0.3349521492]);
+b_centre01 = rbend('b_centre01',0.2820465390,0.0367531161,0.0000000000,0.0000000000,-0.3315842393*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3315842393*scalek 0.0083655817 0.2965845308]);
+b_centre02 = rbend('b_centre02',0.2815037989,0.0354072994,0.0000000000,0.0000000000,-0.3306516396*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3306516396*scalek 0.0236710994 -0.2196079070]);
+
+b_centre03a = rbend('b_centre03',0.07039827720955,0.0349189639*0.2502,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673 -0.5218735605]);
+b_centre03b = rbend('b_centre04',0.16393005016542,0.0349189639*0.5827,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673 -0.5218735605]);
+b_centre03c = rbend('b_centre05',0.04699977442503,0.0349189639*0.1671,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673 -0.5218735605]);
+b_centre03 = [b_centre03a b_centre03b b_centre03c];
+%b_centre03 = rbend('b_centre03',0.2813281018,0.0349189639,0.0000000000,0.0000000000,-0.3300962629*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300962629*scalek 0.0101400673 -0.5218735605]);
+
+b_centre04 = rbend('b_centre06',0.2814996751,0.0353946664,0.0000000000,0.0000000000,-0.3302155286*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3302155286*scalek 0.0236248098 -0.2148826863]);
+b_centre05 = rbend('b_centre07',0.2820380879,0.0367421671,0.0000000000,0.0000000000,-0.3312220213*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3312220213*scalek 0.0103909753 0.2969171603]);
+b_right01 = rbend('b_right01',0.0694014448,0.0092683157,0.0000000000,0.0000000000,-0.3292611055*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3292611055*scalek -0.0291322494 0.3681905186]);
+b_right02 = rbend('b_right02',0.0694650575,0.0090036557,0.0000000000,0.0000000000,-0.3961176951*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3961176951*scalek -0.1539214712 0.9528854933]);
+b_right03 = rbend('b_right03',0.0695141539,0.0037120061,0.0000000000,0.0000000000,-0.2701751814*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.2701751814*scalek 0.3742213022 0.7022676128]);
+b_right04 = rbend('b_right04',0.0695280819,0.0007962279,0.0000000000,0.0000000000,-0.0288159660*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0288159660*scalek -0.0571472318 0.2460706289]);
+b_right05 = rbend('b_right05',0.0695312501,0.0001902235,0.0000000000,0.0000000000,-0.0028161106*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0028161106*scalek -0.1077402629 0.7697020810]);
+
+% RBEND
+% b_left01 = rbend('b_left01',0.0695312761,0.0001700782,0.1121962211,-0.1120187381,0.0026580668*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0026580668*scalek -0.0222542890 -0.0307698880]);
+% b_left02 = rbend('b_left02',0.0695282915,0.0007118132,0.1120187381,-0.1112734474,0.0004302895*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0004302895*scalek -0.0824996146 -0.0652385243]);
+% b_left03 = rbend('b_left03',0.0695152451,0.0032678721,0.1112734474,-0.1078414785,-0.1045888695*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.1045888695*scalek -0.0928717833 0.2254072448]);
+% b_left04 = rbend('b_left04',0.0694679183,0.0088002187,0.1078414785,-0.0989182337,-0.3486275471*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3486275471*scalek -0.0656081148 0.3572852967]);
+% b_left05 = rbend('b_left05',0.0694041758,0.0092692888,0.0989182337,-0.0896518010,-0.3281526271*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3281526271*scalek -0.0355726539 0.3355904266]);
+% b_centre01 = rbend('b_centre01',0.2820465390,0.0367531221,0.0896518010,-0.0529125655,-0.3312315118*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3312315118*scalek 0.0081060667 0.2963931827]);
+% b_centre02 = rbend('b_centre02',0.2815037989,0.0354072962,0.0529125655,-0.0175134439,-0.3306429237*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3306429237*scalek 0.0237264198 -0.2192733272]);
+% b_centre03 = rbend('b_centre03',0.2813281018,0.0349189640,0.0175134439,0.0174054578,-0.3300984023*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3300984023*scalek 0.0101509428 -0.5218382720]);
+% b_centre04 = rbend('b_centre04',0.2814996751,0.0353946633,-0.0174054578,0.0528080683,-0.3302048119*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3302048119*scalek 0.0235987043 -0.2144554284]);
+% b_centre05 = rbend('b_centre05',0.2820380879,0.0367421699,-0.0528080683,0.0895641319,-0.3309037380*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3309037380*scalek 0.0102169077 0.2963545009]);
+% b_right01 = rbend('b_right01',0.0694014448,0.0092683188,-0.0895641319,0.0988345428,-0.3275972520*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3275972520*scalek -0.0308930090 0.3680490900]);
+% b_right02 = rbend('b_right02',0.0694650575,0.0090032960,-0.0988345428,0.1077882518,-0.3467634133*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.3467634133*scalek -0.0345063628 0.6218385567]);
+% b_right03 = rbend('b_right03',0.0695141539,0.0037116695,-0.1077882518,0.1112699557,-0.1347732139*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.1347732139*scalek 0.0189958278 0.8526578807]);
+% b_right04 = rbend('b_right04',0.0695280819,0.0007961566,-0.1112699557,0.1120205593,-0.0014988960*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 -0.0014988960*scalek -0.0849450391 0.2100836063]);
+% b_right05 = rbend('b_right05',0.0695312501,0.0001897883,-0.1120205593,0.1121997376,0.0026764692*scalek,'BndMPoleSymplectic4Pass',[0 0 0 0],[0 0.0026764692*scalek -0.0276971797 0.0360627830]);
+
+dipole_arc = [leftdrift_a bpm leftdrift_b b_left01 b_left02 b_left03 b_left04 ...
+ b_left05 b_centre01 b_centre02 b_centre03 b_centre04 ...
+ b_centre05 b_right01 b_right02 b_right03 b_right04 ...
+ b_right05 rightdrift_a bpm rightdrift_b];
+
+% Quadrupoles (for design dipole: [QFA,QDA,QFB]=[1.761741,-1.038377,1.533802];
+% To match new single dipole values from numerical studies
+% tune of 13.3, 5.2 and 0 dispersion in straights.
+% qfa = quadrupole('QFA' ,3.550000e-001, 1.7610967e+000,'QuadLinearPass');
+% qda = quadrupole('QDA' ,1.800000e-001,-1.0715748e+000,'QuadLinearPass');
+% qfb = quadrupole('QFB' ,3.550000e-001, 1.5406418e+000,'QuadLinearPass');
+
+% To match split dipole values from numerical studies (SBENDS)
+% tune of 13.216, 5.3006 and 0 dispersion in straights.
+% qfa = quadrupole('QFA' ,3.550000e-001, 1.7610967e+000,'QuadLinearPass');
+% qda = quadrupole('QDA' ,1.800000e-001,-1.0715748e+000,'QuadLinearPass');
+% qfb = quadrupole('QFB' ,3.550000e-001, 1.5406418e+000,'QuadLinearPass');
+
+% To match split dipole values from numerical studies (RBENDS)
+% tune of 13.216, 5.3006 and 0 dispersion in straights.
+% qfa = quadrupole('QFA' ,3.550000e-001, 1.7521052e+000,'QuadLinearPass');
+% qda = quadrupole('QDA' ,1.800000e-001,-1.0897262e+000,'QuadLinearPass');
+% qfb = quadrupole('QFB' ,3.550000e-001, 1.5452228e+000,'QuadLinearPass');
+
+% To match split dipole values from numerical studies (RBENDS)
+% tune of 13.29, 5.216 and 0 dispersion in straights.
+% -1.08597141914729
+% qfa = quadrupole('QFA' ,3.550000e-001, 1.76190217411609,'QuadLinearPass');
+% qda = quadrupole('QDA' ,1.800000e-001,-1.08597141914729,'QuadLinearPass');
+% qfb = quadrupole('QFB' ,3.550000e-001, 1.54443756044807,'QuadLinearPass');
+
+% To match split dipole values from numerical studies (SBENDS)
+% tune of 13.29, 5.216 and 0 dispersion in straights.
+qfa = quadrupole('QFA' ,3.550000e-001, 1.76272982211693,'QuadLinearPass');
+qda = quadrupole('QDA' ,1.800000e-001,-1.06276736743823,'QuadLinearPass');
+qfb = quadrupole('QFB' ,3.550000e-001, 1.53992875479511,'QuadLinearPass');
+
+% Sextupoles with built in correctors. Corrector settings given by kick
+% angle in radians. (zero chromaticity with zero dispersion and original
+% model without split measured bends)
+sfa = sextcorr('SFA' ,2.000000e-001, 1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
+sda = sextcorr('SDA' ,2.000000e-001,-1.400000e+001,[0 0],'StrCorrMPoleSymplectic4Pass');
+sdb = sextcorr('SDB' ,2.000000e-001,-7.014635e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
+sfb = sextcorr('SFB' ,2.000000e-001, 7.189346e+000,[0 0],'StrCorrMPoleSymplectic4Pass');
+
+
+wig = multipole('wig',0,[0 0 0 0],[0 0 0 10],'ThinMPolePass');
+
+% RF cavity and the corresponding straight used to position the cavity.
+% 4.996540652069698e+008 old freq for 216m for 216.0004 its different. Also
+% we are using ThinCavities therefore the drifts have to be set
+% accordingly.
+cav_single = rfcavity('RF' ,0.0,3.00e+006,C0/L0*HarmNumber,HarmNumber,'CavityPass');
+cav = rfcavity('RF' ,0.0,0.75e+006,C0/L0*HarmNumber,HarmNumber,'CavityPass');
+% drifts around the rf cavities and space between them
+d1ar1 = drift('D1AR1' ,len(d1a)-len(cav_single)/2 ,'DriftPass'); % for just 1 cavity
+drf = drift('DRF' ,0.45 ,'DriftPass'); % space between cavities
+d1ar4 = drift('D1AR4' ,len(d1a)-len(cav)-len(drf)/2,'DriftPass'); % for 4 cavities
+cav_pair = [cav drf cav];
+% dRF1 = drift('dRF1' ,len(d1)-2.55 ,'DriftPass');
+% dRF2 = drift('dRF2' ,2.55/3 ,'DriftPass');
+dRF1 = drift('dRF1' ,len(d1)-2.55 ,'DriftPass');
+dRF2 = drift('dRF2' ,2.55/3 ,'DriftPass');
+
+% Kickers and the associated drifts to position them. (to be checked)
+kick1 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick2 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick3 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+kick4 = corrector('KICK' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+%fast feedback kicks
+ffbh = corrector('FFBH' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+ffbv = corrector('FFBV' ,0.000000e+000,[0.000000e+000 0.0],'CorrectorPass');
+% Drift spaces to replace D1A for the upstream kickers, ie kickers 1 and 3.
+d1ak2_up= drift('D1AK2_UP' ,0.779 - len(d1b),'DriftPass');
+d1ak1_up= drift('D1AK1_UP' ,len(d1a) - len(d1ak2_up),'DriftPass');
+% Drift spaces to replace D1A for the downstream kickers, ie kickers 2 and 4.
+d1ak2_do= drift('D1AK2_DO' ,1.073 - len(d1bb),'DriftPass');
+d1ak1_do= drift('D1AK1_DO' ,len(d1aa) - len(d1ak2_do),'DriftPass');
+
+
+% Define the position of the bpm. bpm1d1 represents BPM number 1 in the D1
+% straight and bpm5d4 represents BPM number 5 in straight d4. bpm7dk and
+% bpm7dr repreents BPM number 7 in either the kicker stright or RF
+% straight.
+bpm1d1 = [ d1a bpm d1b ];
+bpm1d1k = inline(['[' num2str(d1ak1_up) ' ' 'kicker ' num2str(d1ak2_up) ' ' num2str(bpm) ' ' num2str(d1b) ' ' ']' ], 'kicker'); % Kicker
+bpm1d1r1 = [ d1ar1 bpm d1b ]; % RF 1 cavity
+%bpm1d1r4 = [ d1ar4 bpm d1b ]; % RF 4 cavity
+bpm2d4 = [ d4a bpm d4b ];
+bpm3d4 = [ d4aa bpm d4bb ];
+bpm4d2 = [ d2a bpm d2b ];
+bpm5d4 = [ bpm2d4 ];
+bpm6d4 = [ bpm3d4 ];
+bpm7d1 = [ d1bb bpm d1aa ];
+bpm7d1k = inline(['[' num2str(d1bb) ' ' num2str(bpm) ' ' num2str(d1ak2_do) ' ' 'kicker ' num2str(d1ak1_do) ' ' ']' ], 'kicker'); % Kicker
+bpm7d1r1 = [ d1b bpm d1ar1 ]; % RF 1 cavity
+%bpm7d1r4 = [ d1b bpm d1ar4 ]; % RF 4 cavity
+bpm1d1RF = [ dRF1 bpm dRF2 cav dRF2 cav dRF2 ];
+
+d1ffb = [];
+bpm7d1ffb = [ d1b bpm d1ffb ]; %fast feedback kicker
+
+% Arrange the elements onto the girders and use markers to define the
+% sections for misalignment studies.
+g1m1 = marker('g1m1','IdentityPass');
+g1m2 = marker('g1m2','IdentityPass');
+g2m1 = marker('g2m1','IdentityPass');
+g2m2 = marker('g2m2','IdentityPass');
+% girder1 = [ g1m1 sfa hcor sfa d2 qfa d3 sda vcor sda g1m2];
+% girder2 = [ g2m1 sdb vcor sdb d5 qda d6 qfb d2 sfb hcor sfb bpm4d2 qfb d6 qda d5 sdb vcor sdb g2m2];
+% girder3 = [ g1m1 sda vcor sda d3 qfa d2 sfa hcor sfa g1m2];
+girder1 = [ g1m1 sfa d2 qfa d3 sda g1m2];
+girder2 = [ g2m1 sdb d5 qda d6 qfb d2 sfb bpm4d2 qfb d6 qda d5 sdb g2m2];
+girder3 = [ g1m1 sda d3 qfa d2 sfa g1m2];
+
+
+% Arrange the girders into the different cell arrangements.
+unit_cel = [ bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+% Kickers in cells 1 and 14
+celkick14 = [ bpm1d1k(kick1) girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1k(kick2) ];
+celkick01 = [ bpm1d1k(kick3) girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1k(kick4) ];
+% Shorten the straights in cells 6, 7 and 8 to put in the rf
+% 4 RF cavities
+
+celrf06_4 = [ bpm1d1RF girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+celrf07_4 = [ bpm1d1RF girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+%celrf06_4 = [ bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1r4 ];
+%celrf07_4 = [ bpm1d1r4 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1r4 ];
+%celrf08_4 = [ bpm1d1r4 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+
+% Single RF cavity
+celrf06_1 = [ bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1r1 ];
+celrf07_1 = [ bpm1d1r1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1 ];
+%diagnostic straight with fast feedback kicker
+celffb10_1 = [ bpm1d1 girder1 dipole_arc girder2 dipole_arc girder3 bpm7d1ffb ]; %includes fast feedback kicker
+
+% Shift sector
+shift1 = quadrupole('SHIFT1' ,0, 0,'QuadLinearPass');
+shift2 = quadrupole('SHIFT2' ,0, 0,'QuadLinearPass');
+
+% Definition of the types of rings
+kickring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+% cavity1ring = [ ap celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+% cavity4ring = [ ap celrf06_4 cav_pair celrf07_4 cav_pair celrf08_4 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+cavity1ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];;
+cavity4ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_4 celrf07_4 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+
+%cavity4ring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_4 cav_pair celrf07_4 cav_pair celrf08_4 unit_cel unit_cel unit_cel unit_cel unit_cel celkick14];
+
+fullring_startwithRF = [ ap cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 ];
+ring = [ ap unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+fullring = [ ap celkick14 celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+%fast feedback kicker included:
+ffbring = [ ap celkick01 unit_cel unit_cel unit_cel unit_cel celrf06_1 cav_single celrf07_1 unit_cel unit_cel celffb10_1 unit_cel unit_cel unit_cel celkick14];
+% Wiggler
+wigring = [ ap unit_cel wig unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel unit_cel ];
+
+% Choose which lattice to load else load "fullring" as the default.
+if nargin > 0
+ fprintf('Using lattice : %s \n', varargin{1});
+ eval(['buildlat(' varargin{1} ');']);
+else
+ % Default lattice to load
+ fprintf('Using default lattice : cavity4ring\n');
+ buildlat(cavity4ring);
+end
+
+% Make the variables THERING and GLOBVAL available to the caller's
+% workspace.
+evalin('caller','global THERING GLOBVAL');
+disp('** Done **');
+
+% New AT 1.3 does not require FAMLIST and is fazing out GLOBVAL
+clear global FAMLIST
+
+setenergymodel(3);
+
+% Internal function used to return the length of a defined element.
+function res = len(id)
+global FAMLIST
+res = FAMLIST{id}.ElemData.Length;
+
diff --git a/machine/ASP/StorageRing/assr4_wiggler.m b/machine/ASP/StorageRing/assr4_wiggler.m
index a2a51975..ad09184d 100644
--- a/machine/ASP/StorageRing/assr4_wiggler.m
+++ b/machine/ASP/StorageRing/assr4_wiggler.m
@@ -59,7 +59,8 @@ function assr4(varargin)
d2b = drift('D2B' , 1.030000e-001,'DriftPass');
% Dipoles
-% design -> rbend('BEND',1.726000e+000,2.243995e-001,1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
+% design -> rbend('BEND',1.726000e+000,2.243995e-001,...
+% 1.121997e-001,1.121997e-001,-3.349992e-001,[method]);
% From numerical studies -> L: 1.72579121675e+000
% K: 0.33295132
% Sext: 0.01092687
diff --git a/machine/ASP/StorageRing/atsummary.m b/machine/ASP/StorageRing/atsummary.m
deleted file mode 100644
index 9441095d..00000000
--- a/machine/ASP/StorageRing/atsummary.m
+++ /dev/null
@@ -1,151 +0,0 @@
-function varargout = atsummary(varargin)
-% ATSUMMARY(['verbose']) will print out the paramters of the lattice
-% currently loaded in AT. The parameters that come after the Synchrotron
-% Integrals are parameters that depend on the Integrals themselves. The
-% equations to calculate them were taken from [1].
-%
-% 'verbose' will make ATSUMMARY print out a summary
-%
-% [1] Alexander Wu Chao and Maury Tigner, Handbook of Accelerator Physics
-% and Engineering (World Scientific, Singapore, 1998), pp. 183-187. (or
-% 187-190 in ed. 2)
-%
-% Written by Eugene Tan
-% Updated 04/05/2005: Check for EntranceAngle since multipoles have
-% BendingAngle as well.
-% Revised by Laurent S. Nadolski
-
-
-global THERING GLOBVAL
-
-% if exist('sum','var')
-% clear global sum;
-% global sum;
-% end
-
-% Structure to store info
-sum.e0 = GLOBVAL.E0*1e-9;
-sum.circumference = findspos(THERING, length(THERING)+1);
-sum.revTime = sum.circumference / 2.99792458e8;
-sum.revFreq = 2.99792458e8 / sum.circumference;
-sum.gamma = sum.e0 / 0.51099906e-3;
-sum.beta = sqrt(1 - 1/sum.gamma);
-[TD sum.tunes sum.chromaticity] = twissring(THERING, 0, 1:length(THERING)+1, 'chrom', 1e-8);
-sum.compactionFactor = mcf(THERING);
-
-% For calculating the synchrotron interals
-temp = cat(2,TD.Dispersion);
-D_x = temp(1,:)';
-D_x_ = temp(2,:)';
-beta = cat(1, TD.beta);
-alpha = cat(1, TD.alpha);
-gamma = (1 + alpha.^2) ./ beta;
-circ = TD(length(THERING)+1).SPos;
-
-% Synchrotron integral calculation
-sum.integrals = [0.0 0.0 0.0 0.0 0.0 0.0];
-
-for i = 1:length(THERING)
- if isfield(THERING{i}, 'BendingAngle') && isfield(THERING{i}, 'EntranceAngle')
- rho = THERING{i}.Length/THERING{i}.BendingAngle;
- dispersion = 0.5*(D_x(i)+D_x(i+1));
- sum.integrals(1) = sum.integrals(1) + dispersion*THERING{i}.Length/rho;
- sum.integrals(2) = sum.integrals(2) + THERING{i}.Length/(rho^2);
- sum.integrals(3) = sum.integrals(3) + THERING{i}.Length/(rho^3);
- % For general wedge magnets
- sum.integrals(4) = sum.integrals(4) + ...
- D_x(i)*tan(THERING{i}.EntranceAngle)/rho^2 + ...
- (1 + 2*rho^2*THERING{i}.PolynomB(2))*(D_x(i)+D_x(i+1))*THERING{i}.Length/(2*rho^3) + ...
- D_x(i+1)*tan(THERING{i}.ExitAngle)/rho^2;
- % sum.integrals(4) = sum.integrals(4) + 2*0.5*(D_x(i)+D_x(i+1))*THERING{i}.Length/rho^3;
- H1 = beta(i,1)*D_x_(i)*D_x_(i)+2*alpha(i)*D_x(i)*D_x_(i)+gamma(i)*D_x(i)*D_x(i);
- H0 = beta(i+1,1)*D_x_(i+1)*D_x_(i+1)+2*alpha(i+1)*D_x(i+1)*D_x_(i+1)+gamma(i+1)*D_x(i+1)*D_x(i+1);
- sum.integrals(5) = sum.integrals(5) + THERING{i}.Length*(H1+H0)*0.5/(rho^3);
- % if H1+H0 < 0
- % fprintf('%f %i %s\n', H1+H0, i, THERING{i}.FamName)
- % end
- sum.integrals(6) = sum.integrals(6) + ...
- THERING{i}.PolynomB(2)^2*dispersion^2*THERING{i}.Length;
- end
-end
-
-% Damping numbers
-% Use Robinson's Theorem
-sum.damping(1) = 1 - sum.integrals(4)/sum.integrals(2);
-sum.damping(2) = 1;
-sum.damping(3) = 2 + sum.integrals(4)/sum.integrals(2);
-
-sum.radiation = 8.846e-5*sum.e0.^4*sum.integrals(2)/(2*pi);
-sum.naturalEnergySpread = sqrt(3.8319e-13*sum.gamma.^2*sum.integrals(3)/(2*sum.integrals(2) + sum.integrals(4)));
-sum.naturalEmittance = 3.8319e-13*(sum.e0*1e3/0.510999).^2*sum.integrals(5)/(sum.damping(1)*sum.integrals(2));
-
-% Damping times
-sum.radiationDamping(1) = 1/(2113.1*sum.e0.^3*sum.integrals(2)*sum.damping(1)/circ);
-sum.radiationDamping(2) = 1/(2113.1*sum.e0.^3*sum.integrals(2)*sum.damping(2)/circ);
-sum.radiationDamping(3) = 1/(2113.1*sum.e0.^3*sum.integrals(2)*sum.damping(3)/circ);
-
-% Slip factor
-sum.etac = sum.gamma^(-2) - sum.compactionFactor;
-
-cavind = findcells(THERING,'HarmNumber');
-if ~isempty(cavind)
- freq = THERING{cavind(1)}.Frequency;
- v_cav = THERING{cavind(1)}.Voltage*length(cavind);
-else
- % Default
- freq = 4.996540652069698e+008;
- v_cav = 3e6;
-end
-sum.harmon = sum.circumference/(2.99792458e8/freq); % Assuming 499.654MHz RF
-sum.overvoltage = v_cav/(sum.radiation*1e9); % Assuming 3e6 volt cavities.
-% Assuming the harmon and overvoltage above.
-% references: H. Winick, "Synchrotron Radiation Sources: A Primer",
-% World Scientific Publishing, Singapore, pp92-95. (1995)
-% Wiedermann, pp290,350. Chao, pp189.
-sum.syncphase = pi - asin(1/sum.overvoltage);
-sum.energyacceptance = sqrt(v_cav*sin(sum.syncphase)*2*(sqrt(sum.overvoltage^2-1) - acos(1/sum.overvoltage))/(pi*sum.harmon*abs(sum.etac)*sum.e0*1e9));
-sum.synctune = sqrt((sum.etac*sum.harmon*v_cav*cos(sum.syncphase))/(2*pi*sum.e0*1e9));
-sum.bunchlength = sum.beta*299792458*abs(sum.etac)*sum.naturalEnergySpread/(sum.synctune*sum.revFreq*2*pi);
-
-if nargin > 0 && ischar(varargin{1}) && strcmpi(varargin{1},'verbose')
- fprintf('\n');
- fprintf(' ******** Summary for ''%s'' ********\n', GLOBVAL.LatticeFile);
- fprintf(' Energy: \t\t\t%4.5f [GeV]\n', sum.e0);
- fprintf(' Gamma: \t\t\t%4.5f \n', sum.gamma);
- fprintf(' Circumference: \t\t%4.5f [m]\n', sum.circumference);
- fprintf(' Revolution time: \t\t%4.5f [ns] (%4.5f [MHz]) \n', sum.revTime*1e9,sum.revFreq*1e-6);
- fprintf(' Betatron tune H: \t\t%4.5f (%4.5f [kHz])\n', sum.tunes(1),sum.tunes(1)/sum.revTime*1e-3);
- fprintf(' V: \t\t%4.5f (%4.5f [kHz])\n', sum.tunes(2),sum.tunes(2)/sum.revTime*1e-3);
- fprintf(' Momentum Compaction Factor: \t%4.5f\n', sum.compactionFactor);
- fprintf(' Chromaticity H: \t\t%+4.5f\n', sum.chromaticity(1));
- fprintf(' V: \t\t%+4.5f\n', sum.chromaticity(2));
- fprintf(' Synchrotron Integral 1: \t%4.5f [m]\n', sum.integrals(1));
- fprintf(' 2: \t%4.5f [m^-1]\n', sum.integrals(2));
- fprintf(' 3: \t%4.5f [m^-2]\n', sum.integrals(3));
- fprintf(' 4: \t%4.5f [m^-1]\n', sum.integrals(4));
- fprintf(' 5: \t%4.5f [m^-1]\n', sum.integrals(5));
- fprintf(' 6: \t%4.5f [m^-1]\n', sum.integrals(6));
- fprintf(' Damping Partition H: \t%4.5f\n', sum.damping(1));
- fprintf(' V: \t%4.5f\n', sum.damping(2));
- fprintf(' E: \t%4.5f\n', sum.damping(3));
- fprintf(' Radiation Loss: \t\t%4.5f [keV]\n', sum.radiation*1e6);
- fprintf(' Natural Energy Spread: \t%4.5e\n', sum.naturalEnergySpread);
- fprintf(' Natural Emittance: \t\t%4.5e [mrad]\n', sum.naturalEmittance);
- fprintf(' Radiation Damping H: \t%4.5f [ms]\n', sum.radiationDamping(1)*1e3);
- fprintf(' V: \t%4.5f [ms]\n', sum.radiationDamping(2)*1e3);
- fprintf(' E: \t%4.5f [ms]\n', sum.radiationDamping(3)*1e3);
- fprintf(' Slip factor : \t%4.5f\n', sum.etac);
- fprintf('\n');
- fprintf(' Assuming cavities Voltage: %4.5f [kV]\n', v_cav/1e3);
- fprintf(' Frequency: %4.5f [MHz]\n', freq/1e6);
- fprintf(' Harmonic Number: %4.5f\n', sum.harmon);
- fprintf(' Overvoltage factor: %4.5f\n', sum.overvoltage);
- fprintf(' Synchronous Phase: %4.5f [rad] (%4.5f [deg])\n', sum.syncphase, sum.syncphase*180/pi);
- fprintf(' Linear Energy Acceptance: %4.5f %%\n', sum.energyacceptance*100);
- fprintf(' Synchrotron Tune: %4.5f (%4.5f kHz or %4.2f turns) \n', sum.synctune, sum.synctune/sum.revTime*1e-3, 1/sum.synctune);
- fprintf(' Bunch Length: %4.5f [mm]\n', sum.bunchlength*1e3);
-end
-
-if nargout > 0
- varargout{1} = sum;
-end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/bend2gev.m b/machine/ASP/StorageRing/bend2gev.m
index 3bd5a084..b2880fa5 100644
--- a/machine/ASP/StorageRing/bend2gev.m
+++ b/machine/ASP/StorageRing/bend2gev.m
@@ -1,231 +1,231 @@
-function GeV = bend2gev(varargin)
-%BEND2GEV - Compute the energy based on the ramp tables
-% GeV = bend2gev(Family, Field, Amps, DeviceList, BranchFlag)
-%
-% INPUTS
-% 1. Bend - Bend magnet family {Optional}
-% 2. Field - Field {Optional}
-% 3. Amps - Bend magnet current
-% 4. DeviceList - Bend magnet device list to reference energy to {Default: BEND(1,1)}
-% 5. BranchFlag - 1 -> Lower branch
-% 2 -> Upper branch {Default}
-% Not working at Spear yet, since there isn't any magnet measurements on hysteresis
-%
-% OUTPUTS
-% 1. GeV - Electron beam energy [GeV]
-%
-% Written by Greg Portmann
-% Modified by E. Tan for ASP 31/05/2006
-
-% Default
-Family = '';
-Field = '';
-Amps = [];
-DeviceList = [];
-BranchFlag = [];
-
-ModeFlag = ''; % model, online, manual
-UnitsFlag = ''; % hardware, physics
-for i = length(varargin):-1:1
- if isstruct(varargin{i})
- % Ignor structures
- elseif iscell(varargin{i})
- % Ignor cells
- elseif strcmpi(varargin{i},'struct')
- varargin(i) = [];
- elseif strcmpi(varargin{i},'numeric')
- varargin(i) = [];
- elseif strcmpi(varargin{i},'physics')
- UnitsFlag = 'Physics';
- varargin(i) = [];
- elseif strcmpi(varargin{i},'hardware')
- UnitsFlag = 'Hardware';
- varargin(i) = [];
- elseif strcmpi(varargin{i},'simulator') | strcmpi(varargin{i},'model')
- ModeFlag = varargin{i};
- varargin(i) = [];
- elseif strcmpi(varargin{i},'online')
- ModeFlag = varargin{i};
- varargin(i) = [];
- elseif strcmpi(varargin{i},'manual')
- ModeFlag = varargin{i};
- varargin(i) = [];
- end
-end
-
-
-if length(varargin) >= 1
- if ischar(varargin{1})
- Family = varargin{1};
- varargin(1) = [];
- else
- Amps = varargin{1};
- varargin(1) = [];
- if length(varargin) >= 1
- DeviceList = varargin{1};
- varargin(1) = [];
- end
- if length(varargin) >= 1
- BranchFlag = varargin{1};
- varargin(1:end) = [];
- end
- end
-end
-if length(varargin) >= 1 & ischar(varargin{1})
- Field = varargin{1};
- varargin(1) = [];
-end
-if length(varargin) >= 1
- Amps = varargin{1};
- varargin(1) = [];
-end
-if length(varargin) >= 1
- DeviceList = varargin{1};
- varargin(1) = [];
-end
-if length(varargin) >= 1
- BranchFlag = varargin{1};
- varargin(1) = [];
-end
-
-
-if isempty(Family)
- Family = 'BEND';
-end
-if isempty(ModeFlag)
- ModeFlag = getmode(Family);
-end
-
-if isempty(Field)
- Field = 'Setpoint';
-end
-if isempty(DeviceList)
- DeviceList = family2dev(Family);
- if all(size(Amps)==[1 1]) | isempty(Amps)
- DeviceList = DeviceList(1,:);
- end
-end
-if isempty(BranchFlag)
- % Default is upper branch
- BranchFlag = 2;
-end
-if isempty(Amps)
- if strcmpi(ModeFlag,'simulator') | strcmpi(ModeFlag,'model')
- % The model energy is used only if Amps is empty
- % Otherwise "Maximum recursion limit"
- GeV = getenergymodel;
- return;
-
- %GeVmodel = getenergymodel;
- %kmodel = getpvmodel(Family, Field, DeviceList, 'Physics');
- %Amps = k2amp(Family, Field, kmodel, DeviceList, [], 1, GeVmodel);
- else
- Amps = getpv(Family, Field, [1 1], 'Hardware', ModeFlag);
- UnitsFlag = 'UnitsFlag';
- end
-end
-
-% End of input checking
-% Machine dependent stuff below
-
-
-% Amps should be in hardware units
-if strcmpi(UnitsFlag,'Physics')
- Amps = physics2hw(Family, 'Setpoint', Amps, DeviceList);
-end
-
-DeviceListTotal = family2dev(Family, 0);
-
-for ii = 1:size(DeviceList,1)
- if length(Amps) == 1
- BEND = Amps;
- else
- BEND = Amps(ii);
- end
-
- % Convert to energy
-
- temp = getfamilydata(Family, Field, 'HW2PhysicsParams', DeviceList(ii,:));
- C = temp{1};
-
- % The function/curve used here is Energy vs Current and is calculated
- % from tracking studies using a 2D field map.
- splitind = size(C,2)/2;
- I = C(1,1:splitind);
- Energy = C(1,splitind+1:end); % in GeV
- gev1 = interp1(I,Energy,BEND,'linear','extrap');
-
- if size(Amps,2) == 1
- GeV(ii,1) = gev1;
- else
- GeV(1,ii) = gev1;
- end
-
-end
-
-%
-% B = C(8)*BEND + C(7)*BEND.^2 + C(6)*BEND.^3 + C(5)*BEND.^4 + C(4)*BEND.^5 + C(3)*BEND.^6 + C(2)*BEND.^7 + C(1)*BEND.^8;
-% % k(i,1) = polyval(C, Amps(i)) / brho;
-%
-% % k is fixed to be -0.31537858
-% k = -0.31537858;
-%
-% % Convert to BEND angle
-% %K2BendingAngle = 2.54842790129284;
-% if any(DeviceList(ii,1) == [1 9 10 18])
-% K2BendingAngle = 2.54842790129284 * -0.43947079695140; % BendAngle / K
-% else
-% K2BendingAngle = 2.54842790129284 * -0.58596106939159; % BendAngle / K
-% end
-% %K2BendingAngle = -0.43947079695140; % BendAngle / K
-% k = K2BendingAngle * k;
-%
-%
-% boverbprime = 0.392348;
-% bprime = B / boverbprime;
-% brho = bprime / k;
-%
-% % now return energy in GeV
-% gev1 = brho / 3.33620907461447;
-%
-% cur = BEND;
-% % Convert to energy
-%
-% a7= 0.0137956;
-% a6=-0.0625519;
-% a5= 0.1156769;
-% a4=-0.1141570;
-% a3= 0.0652128;
-% a2=-0.0216472;
-% a1= 0.0038866;
-% a0= 0.0028901;
-%
-% i0=700.;
-% c7=a7/(i0^7);
-% c6=a6/(i0^6);
-% c5=a5/(i0^5);
-% c4=a4/(i0^4);
-% c3=a3/(i0^3);
-% c2=a2/(i0^2);
-% c1=a1/i0;
-% c0=a0;
-% leff=1.5048;
-%
-%
-% % kl = (cur/brho)*(c0+c1*cur+c2*cur^2+c3*cur^3+c4*cur^4+c5*cur^5+c6*cur^6+c7*cur^7);
-% % k = kl/Leff;
-% % k is fixed to be -0.31537858
-% k = -0.31537858;
-%
-% BLeff = cur.*(c0+c1*cur+c2*cur.^2+c3*cur.^3+c4*cur.^4+c5*cur.^5+c6*cur.^6+c7*cur.^7);
-% field = BLeff / Leff;
-%
-% boverbprime = 0.392348;
-% bprime = field / boverbprime;
-% brho = bprime / k;
-%
-% % now return energy in GeV
-% GeV = brho / 3.33620907461447;
-
-
-
+function GeV = bend2gev(varargin)
+%BEND2GEV - Compute the energy based on the ramp tables
+% GeV = bend2gev(Family, Field, Amps, DeviceList, BranchFlag)
+%
+% INPUTS
+% 1. Bend - Bend magnet family {Optional}
+% 2. Field - Field {Optional}
+% 3. Amps - Bend magnet current
+% 4. DeviceList - Bend magnet device list to reference energy to {Default: BEND(1,1)}
+% 5. BranchFlag - 1 -> Lower branch
+% 2 -> Upper branch {Default}
+% Not working at Spear yet, since there isn't any magnet measurements on hysteresis
+%
+% OUTPUTS
+% 1. GeV - Electron beam energy [GeV]
+%
+% Written by Greg Portmann
+% Modified by E. Tan for ASP 31/05/2006
+
+% Default
+Family = '';
+Field = '';
+Amps = [];
+DeviceList = [];
+BranchFlag = [];
+
+ModeFlag = ''; % model, online, manual
+UnitsFlag = ''; % hardware, physics
+for i = length(varargin):-1:1
+ if isstruct(varargin{i})
+ % Ignor structures
+ elseif iscell(varargin{i})
+ % Ignor cells
+ elseif strcmpi(varargin{i},'struct')
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'numeric')
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'physics')
+ UnitsFlag = 'Physics';
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'hardware')
+ UnitsFlag = 'Hardware';
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'simulator') | strcmpi(varargin{i},'model')
+ ModeFlag = varargin{i};
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'online')
+ ModeFlag = varargin{i};
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'manual')
+ ModeFlag = varargin{i};
+ varargin(i) = [];
+ end
+end
+
+
+if length(varargin) >= 1
+ if ischar(varargin{1})
+ Family = varargin{1};
+ varargin(1) = [];
+ else
+ Amps = varargin{1};
+ varargin(1) = [];
+ if length(varargin) >= 1
+ DeviceList = varargin{1};
+ varargin(1) = [];
+ end
+ if length(varargin) >= 1
+ BranchFlag = varargin{1};
+ varargin(1:end) = [];
+ end
+ end
+end
+if length(varargin) >= 1 & ischar(varargin{1})
+ Field = varargin{1};
+ varargin(1) = [];
+end
+if length(varargin) >= 1
+ Amps = varargin{1};
+ varargin(1) = [];
+end
+if length(varargin) >= 1
+ DeviceList = varargin{1};
+ varargin(1) = [];
+end
+if length(varargin) >= 1
+ BranchFlag = varargin{1};
+ varargin(1) = [];
+end
+
+
+if isempty(Family)
+ Family = 'BEND';
+end
+if isempty(ModeFlag)
+ ModeFlag = getmode(Family);
+end
+
+if isempty(Field)
+ Field = 'Setpoint';
+end
+if isempty(DeviceList)
+ DeviceList = family2dev(Family);
+ if all(size(Amps)==[1 1]) | isempty(Amps)
+ DeviceList = DeviceList(1,:);
+ end
+end
+if isempty(BranchFlag)
+ % Default is upper branch
+ BranchFlag = 2;
+end
+if isempty(Amps)
+ if strcmpi(ModeFlag,'simulator') | strcmpi(ModeFlag,'model')
+ % The model energy is used only if Amps is empty
+ % Otherwise "Maximum recursion limit"
+ GeV = getenergymodel;
+ return;
+
+ %GeVmodel = getenergymodel;
+ %kmodel = getpvmodel(Family, Field, DeviceList, 'Physics');
+ %Amps = k2amp(Family, Field, kmodel, DeviceList, [], 1, GeVmodel);
+ else
+ Amps = getpv(Family, Field, [1 1], 'Hardware', ModeFlag);
+ UnitsFlag = 'UnitsFlag';
+ end
+end
+
+% End of input checking
+% Machine dependent stuff below
+
+
+% Amps should be in hardware units
+if strcmpi(UnitsFlag,'Physics')
+ Amps = physics2hw(Family, 'Setpoint', Amps, DeviceList);
+end
+
+DeviceListTotal = family2dev(Family, 0);
+
+for ii = 1:size(DeviceList,1)
+ if length(Amps) == 1
+ BEND = Amps;
+ else
+ BEND = Amps(ii);
+ end
+
+ % Convert to energy
+
+ temp = getfamilydata(Family, Field, 'HW2PhysicsParams', DeviceList(ii,:));
+ C = temp{1};
+
+ % The function/curve used here is Energy vs Current and is calculated
+ % from tracking studies using a 2D field map.
+ splitind = size(C,2)/2;
+ I = C(1,1:splitind);
+ Energy = C(1,splitind+1:end); % in GeV
+ gev1 = interp1(I,Energy,BEND,'linear','extrap');
+
+ if size(Amps,2) == 1
+ GeV(ii,1) = gev1;
+ else
+ GeV(1,ii) = gev1;
+ end
+
+end
+
+%
+% B = C(8)*BEND + C(7)*BEND.^2 + C(6)*BEND.^3 + C(5)*BEND.^4 + C(4)*BEND.^5 + C(3)*BEND.^6 + C(2)*BEND.^7 + C(1)*BEND.^8;
+% % k(i,1) = polyval(C, Amps(i)) / brho;
+%
+% % k is fixed to be -0.31537858
+% k = -0.31537858;
+%
+% % Convert to BEND angle
+% %K2BendingAngle = 2.54842790129284;
+% if any(DeviceList(ii,1) == [1 9 10 18])
+% K2BendingAngle = 2.54842790129284 * -0.43947079695140; % BendAngle / K
+% else
+% K2BendingAngle = 2.54842790129284 * -0.58596106939159; % BendAngle / K
+% end
+% %K2BendingAngle = -0.43947079695140; % BendAngle / K
+% k = K2BendingAngle * k;
+%
+%
+% boverbprime = 0.392348;
+% bprime = B / boverbprime;
+% brho = bprime / k;
+%
+% % now return energy in GeV
+% gev1 = brho / 3.33620907461447;
+%
+% cur = BEND;
+% % Convert to energy
+%
+% a7= 0.0137956;
+% a6=-0.0625519;
+% a5= 0.1156769;
+% a4=-0.1141570;
+% a3= 0.0652128;
+% a2=-0.0216472;
+% a1= 0.0038866;
+% a0= 0.0028901;
+%
+% i0=700.;
+% c7=a7/(i0^7);
+% c6=a6/(i0^6);
+% c5=a5/(i0^5);
+% c4=a4/(i0^4);
+% c3=a3/(i0^3);
+% c2=a2/(i0^2);
+% c1=a1/i0;
+% c0=a0;
+% leff=1.5048;
+%
+%
+% % kl = (cur/brho)*(c0+c1*cur+c2*cur^2+c3*cur^3+c4*cur^4+c5*cur^5+c6*cur^6+c7*cur^7);
+% % k = kl/Leff;
+% % k is fixed to be -0.31537858
+% k = -0.31537858;
+%
+% BLeff = cur.*(c0+c1*cur+c2*cur.^2+c3*cur.^3+c4*cur.^4+c5*cur.^5+c6*cur.^6+c7*cur.^7);
+% field = BLeff / Leff;
+%
+% boverbprime = 0.392348;
+% bprime = field / boverbprime;
+% brho = bprime / k;
+%
+% % now return energy in GeV
+% GeV = brho / 3.33620907461447;
+
+
+
diff --git a/machine/ASP/StorageRing/bpm_scripts/archivedoffsets/archivedoffsets.mat b/machine/ASP/StorageRing/bpm_scripts/archivedoffsets/archivedoffsets.mat
new file mode 100644
index 00000000..df73b856
Binary files /dev/null and b/machine/ASP/StorageRing/bpm_scripts/archivedoffsets/archivedoffsets.mat differ
diff --git a/machine/ASP/StorageRing/bpm_scripts/archivedoffsets/convertfile.m b/machine/ASP/StorageRing/bpm_scripts/archivedoffsets/convertfile.m
new file mode 100644
index 00000000..ab2d1255
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/archivedoffsets/convertfile.m
@@ -0,0 +1,20 @@
+load archivedoffsets.mat
+
+for i=1:length(archivedoffsets.xcomment)
+ clear offsetdata
+ offsetdata.xoffsets = archivedoffsets.xoffsets(:,i);
+ offsetdata.yoffsets = archivedoffsets.yoffsets(:,i);
+ offsetdata.comment = sprintf('x: %s y: %s',...
+ archivedoffsets.xcomment{i}, archivedoffsets.ycomment{i});
+ offsetdata.datatime = archivedoffsets.xdatatimestr{i};
+
+ prefix = sprintf('archivedoffsets_%04d',i);
+ try
+ t = datenum(offsetdata.datatime,'dd-mmm-yyyy HH:MM:SS');
+ fname = appendtimestamp(prefix,datevec(t));
+ catch
+ fname = prefix;
+ end
+
+ save(fname,'offsetdata');
+end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/bpm_scripts/booster/getliberatbt.m b/machine/ASP/StorageRing/bpm_scripts/booster/getliberatbt.m
new file mode 100644
index 00000000..adca9002
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/booster/getliberatbt.m
@@ -0,0 +1,171 @@
+function varargout = getliberatbt(varargin)
+%
+% data = getliberatbt(STREAM, [DEVICELIST, TRIG_ACQUIRE, NUMSAMPLES])
+%
+% STREAM = libera stream e.g. 'DD1' 'DD3'. (default = 'DD3')
+% * DD1 - data decimated at 64 bit. ie. collect every 64th turn
+% * DD2 - amplitude and phase data
+% * DD3 - data for 10,000 turns - can be used for high repetition
+% * DD4 - data for 100,000 turns - resource intensive, long measurements
+% DEVICELIST = devicelist, [] will use all devices returned by
+% getlist('BPMx'). (default = [])
+% TRIG_ACQUIRE = this will get the liberas to acquire fresh data. Currently
+% defaults to on trigger with whatever offsets loaded into
+% the libera. '0' to not acquire fresh data while '1' will
+% refresh the data. (default = 1)
+% NUMSAMPLES = number of samples to return. If NUMSAMPLES > number of
+% available data then getliberatbt will only return as many
+% data points as there are in the PV.
+%
+% Eugene
+% 10-04-2007
+% 14-06-2011 Small update to the way it triggers using new BPM Event.
+
+if nargin > 0 && ischar(varargin{1})
+ stream = varargin{1};
+else
+ stream = 'DD3';
+end
+
+if nargin > 1 && ~isempty(varargin{2})
+ % User specified device list
+ devicelist = varargin{2};
+else
+ % Use default bpms
+ devicelist = getlist('BPMx');
+end
+
+if nargin > 2 && isnumeric(varargin{3})
+ trigger = varargin{3};
+else
+ trigger = 1;
+end
+
+if nargin > 3 && isnumeric(varargin{4})
+ nelem = varargin{4};
+else
+ nelem = 0;
+end
+
+if trigger
+ % Disable the BPM trigger event from the EVG. 0: disable, 1:
+ % continuous, 3: single shot.
+% setpv('TS01EVG01:EVENT_02_MODE_CMD',0);
+% pause(0.1);
+
+ % read current counter then arm for a single acquisition
+ finished_num = getlibera([stream '_FINISHED_MONITOR'], devicelist);
+% % setlibera(['DD4_ON_NEXT_TRIG_CMD'],1, devicelist);
+ setlibera([stream '_ON_NEXT_TRIG_CMD'],1, devicelist);
+ pause(1.5);
+
+ % Get the EVR to send a trigger signal to the Liberas.
+ setliberatrigger(1);
+
+ ii = 0;
+ temp = getlibera([stream '_FINISHED_MONITOR'],devicelist) == finished_num;
+ while any(temp)
+ pause(0.1);
+ temp = getlibera([stream '_FINISHED_MONITOR'],devicelist) == finished_num;
+ ii = ii + 1;
+ if ii > 60
+ disp('Trigger may not be enabled for the Liberas (please check)');
+ disp('The data acquisition counter did not increment for the following BPMs:');
+ fprintf('[%2d %d]\n',devicelist(temp,:)');
+ if nargout > 0
+ varargout{1} = [];
+ end
+
+ return
+ end
+ end
+end
+
+% Convert the nm units that is Hardware into meters (physics) or nm (hardware).
+if strcmpi(getunits('BPMx'),'Physics')
+ units_conversion = 1e-9; % in meters
+ unitsstr = 'm';
+else
+ units_conversion = 1; % hardware in nm
+ unitsstr = 'nm';
+end
+
+if strcmpi(stream,'ADC')
+ etime = zeros(1,4);
+ datatime = zeros(size(devicelist,1),4);
+
+ [data.a etime(:,1) datatime(:,1)] = getlibera([stream '_A_MONITOR'],devicelist,0,nelem);
+ [data.b etime(:,2) datatime(:,2)] = getlibera([stream '_B_MONITOR'],devicelist,0,nelem);
+ [data.c etime(:,3) datatime(:,3)] = getlibera([stream '_C_MONITOR'],devicelist,0,nelem);
+ [data.d etime(:,4) datatime(:,4)] = getlibera([stream '_D_MONITOR'],devicelist,0,nelem);
+elseif strcmpi(stream,'DD2')
+ etime = zeros(1,10);
+ datatime = zeros(size(devicelist,1),10);
+ % Try to avoid memory problems
+ [data.ia etime(:,1) datatime(:,1)] = getlibera([stream '_IA_MONITOR'],devicelist,0,nelem);
+ [data.qa etime(:,2) datatime(:,2)] = getlibera([stream '_QA_MONITOR'],devicelist,0,nelem);
+ [data.ib etime(:,3) datatime(:,3)] = getlibera([stream '_IB_MONITOR'],devicelist,0,nelem);
+ [data.qb etime(:,4) datatime(:,4)] = getlibera([stream '_QB_MONITOR'],devicelist,0,nelem);
+ [data.ic etime(:,5) datatime(:,5)] = getlibera([stream '_IC_MONITOR'],devicelist,0,nelem);
+ [data.qc etime(:,6) datatime(:,6)] = getlibera([stream '_QC_MONITOR'],devicelist,0,nelem);
+ [data.id etime(:,7) datatime(:,7)] = getlibera([stream '_ID_MONITOR'],devicelist,0,nelem);
+ [data.qd etime(:,8) datatime(:,8)] = getlibera([stream '_QD_MONITOR'],devicelist,0,nelem);
+ [data.MT etime(:,9) datatime(:,9)] = getlibera([stream '_MT_MONITOR'],devicelist,0,nelem);
+ [data.ST etime(:,10) datatime(:,10)] = getlibera([stream '_ST_MONITOR'],devicelist,0,nelem);
+else
+ etime = zeros(1,9);
+ datatime = zeros(size(devicelist,1),9);
+ % Try to avoid memory problems
+ [data.tbtsum etime(:,1) datatime(:,1)] = getlibera([stream '_SUM_MONITOR'],devicelist,0,nelem);
+ [data.tbtx etime(:,2) datatime(:,2)] = getlibera([stream '_X_MONITOR'],devicelist,0,nelem);
+ data.tbtx = data.tbtx*units_conversion;
+ [data.tbty etime(:,3) datatime(:,3)] = getlibera([stream '_Y_MONITOR'],devicelist,0,nelem);
+ data.tbty = data.tbty*units_conversion;
+ [data.VA etime(:,4) datatime(:,4)] = getlibera([stream '_VA_MONITOR'],devicelist,0,nelem);
+ [data.VB etime(:,5) datatime(:,5)] = getlibera([stream '_VB_MONITOR'],devicelist,0,nelem);
+ [data.VC etime(:,6) datatime(:,6)] = getlibera([stream '_VC_MONITOR'],devicelist,0,nelem);
+ [data.VD etime(:,7) datatime(:,7)] = getlibera([stream '_VD_MONITOR'],devicelist,0,nelem);
+ [data.MT etime(:,8) datatime(:,8)] = getlibera([stream '_MT_MONITOR'],devicelist,0,nelem);
+ [data.ST etime(:,9) datatime(:,9)] = getlibera([stream '_ST_MONITOR'],devicelist,0,nelem);
+
+ % Turn offset to try to synchronise the turns
+% for i=1:size(devicelist,1)
+% switch devicelist(i,1)
+% case {6 7 8 9 10 11 13 14}
+% data.tbtsum(i,:) = circshift(data.tbtsum(i,:),[0 -1]);
+% data.tbtx(i,:) = circshift(data.tbtx(i,:),[0 -1]);
+% data.tbty(i,:) = circshift(data.tbty(i,:),[0 -1]);
+% data.VA(i,:) = circshift(data.VA(i,:),[0 -1]);
+% data.VB(i,:) = circshift(data.VB(i,:),[0 -1]);
+% data.VC(i,:) = circshift(data.VC(i,:),[0 -1]);
+% data.VD(i,:) = circshift(data.VD(i,:),[0 -1]);
+% case 12
+% data.tbtsum(i,:) = circshift(data.tbtsum(i,:),[0 -1]);
+% data.tbtx(i,:) = circshift(data.tbtx(i,:),[0 -1]);
+% data.VA(i,:) = circshift(data.VA(i,:),[0 -1]);
+% data.VB(i,:) = circshift(data.VB(i,:),[0 -1]);
+% data.VC(i,:) = circshift(data.VC(i,:),[0 -1]);
+% data.VD(i,:) = circshift(data.VD(i,:),[0 -1]);
+% end
+% end
+end
+data.elapsed_time = sum(etime); % elapsed time to download the PV the wait is longer to ensure all the Liberas have triggered.
+data.mean_datatime = mean(datatime,2); % mean data time that all the PVs have been updated, as a function of the devicelist.
+
+% Log status of the Libera
+if isnumeric(devicelist)
+ % To differentiate the the booster BPMs that are currently not
+ % version 2.06 and don't have some of these features.
+ data.switches = getlibera('ENV_SWITCHES_MONITOR',devicelist,0,nelem);
+ data.plloffset = getlibera('ENV_PLL_OFFSETTUNE_MONITOR',devicelist,0,nelem);
+ data.pllcomptune = getlibera('ENV_PLL_COMPTUNE_MONITOR',devicelist,0,nelem);
+end
+
+data.deviceList = devicelist;
+data.TimeStamp = clock;
+data.CreatedBy = mfilename;
+data.UnitsString = unitsstr;
+data.Units = getunits('BPMx');
+data.Mode = 'Online'; % By definition for now.
+
+varargout{1} = data;
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/bpm_scripts/booster/plotbrdata.m b/machine/ASP/StorageRing/bpm_scripts/booster/plotbrdata.m
new file mode 100644
index 00000000..8cd0ce91
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/booster/plotbrdata.m
@@ -0,0 +1,75 @@
+clear data;
+
+data.dd1.x = getpv('BR01BPM12:DD1_X_MONITOR');
+data.dd1.y = getpv('BR01BPM12:DD1_Y_MONITOR');
+data.dd1.sum = getpv('BR01BPM12:DD1_SUM_MONITOR');
+
+data.dd3.x = getpv('BR01BPM12:DD3_X_MONITOR');
+data.dd3.y = getpv('BR01BPM12:DD3_Y_MONITOR');
+data.dd3.sum = getpv('BR01BPM12:DD3_SUM_MONITOR');
+
+data.adc.A = getpv('BR01BPM12:ADC_A_MONITOR');
+data.adc.B = getpv('BR01BPM12:ADC_B_MONITOR');
+data.adc.C = getpv('BR01BPM12:ADC_C_MONITOR');
+data.adc.D = getpv('BR01BPM12:ADC_D_MONITOR');
+
+data.picoscope.A = getpv('BR01PSC01:CHANNEL_A_MONITOR');
+data.picoscope.B = getpv('BR01PSC01:CHANNEL_B_MONITOR');
+
+%%
+figure(440);
+fs = 119361788.8;
+t = ((1:1024)-1)/fs * 1e6;
+
+subplot(2,2,1);
+plot(t,data.adc.A); title('A');
+xlabel('Time (us)');
+subplot(2,2,2);
+plot(t,data.adc.B); title('B');
+xlabel('Time (us)');
+subplot(2,2,3);
+plot(t,data.adc.C); title('C');
+xlabel('Time (us)');
+subplot(2,2,4);
+plot(t,data.adc.D); title('D');
+xlabel('Time (us)');
+
+figure(441);
+set(gcf,'Position',[ 24 490 1204 823])
+clf;
+fs = 1.387927776744186e+06/64; 1.387991888888889e+06/64;
+t = ((1:2e4)-1)/fs * 1e3;
+t2 = (1:1000)/(1000) * 1e3; % NEED TO CONFIRM SAMPLE TIME of the picoscope
+
+h(1) = subplot(2,2,1);
+plot(t,data.dd1.x*1e-3)
+grid on;
+ylabel('X (um)');
+xlabel('Time (ms)');
+title('BR01BPM12 (21.69 kHz)')
+
+h(2) = subplot(2,2,2);
+plot(t,data.dd1.y*1e-3)
+grid on;
+ylabel('Y (um)');
+xlabel('Time (ms)');
+h(3) = subplot(2,1,2);
+toffset = t2( find(data.picoscope.A < -0.1,1,'first') );
+plot(t + toffset,data.dd1.sum);
+hold on;
+yscale = diff(ylim);
+plot(t2,(-data.picoscope.A)*yscale)
+plot(t2,(data.picoscope.B)*yscale/10)
+grid on;
+xlabel('Time (ms)');
+legend('BPM Sum','Pico A','Pico B');
+linkaxes(h,'x')
+
+
+figure(443);
+clf;
+fs = 1.387991888888889e+06;
+t = ((1:1e4)-1)/fs * 1e6;
+
+plotyy(t,data.dd3.x,t,data.dd3.sum)
+xlabel('Time (us)');
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/bpm_scripts/booster/setbr01bpm12.m b/machine/ASP/StorageRing/bpm_scripts/booster/setbr01bpm12.m
new file mode 100644
index 00000000..6e51ab7e
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/booster/setbr01bpm12.m
@@ -0,0 +1,35 @@
+setpv('BR01BPM12:ENV_AGC_SP',0);
+setpv('BR01BPM12:ENV_GAIN_SP',-51);
+setpv('BR01BPM12:ENV_DSC_SP',0);
+setpv('BR01BPM12:ENV_TRIGDELAY_SP',0);
+
+% set these to zero to start triggering to get data.
+fprintf('Warning: trigger turned off at the moment!!!!\n');
+setpv('BR01BPM12:ADC_IGNORE_TRIG_SP',1);
+setpv('BR01BPM12:DD1_IGNORE_TRIG_SP',1);
+setpv('BR01BPM12:DD2_IGNORE_TRIG_SP',1);
+setpv('BR01BPM12:DD3_IGNORE_TRIG_SP',1);
+setpv('BR01BPM12:DD4_IGNORE_TRIG_SP',1);
+
+
+setpv('BR01BPM12:ADC_ON_NEXT_TRIG_CMD',1);
+setpv('BR01BPM12:DD1_ON_NEXT_TRIG_CMD',1);
+setpv('BR01BPM12:DD2_ON_NEXT_TRIG_CMD',1);
+setpv('BR01BPM12:DD3_ON_NEXT_TRIG_CMD',1);
+setpv('BR01BPM12:DD4_ON_NEXT_TRIG_CMD',0);
+
+setpv('BR01BPM12:DD1_MT_OFFSET_SP',0);
+setpv('BR01BPM12:DD2_MT_OFFSET_SP',0);
+setpv('BR01BPM12:DD3_MT_OFFSET_SP',0);
+setpv('BR01BPM12:DD4_MT_OFFSET_SP',0);
+
+setpv('BR01BPM12:DD1_ST_OFFSET_SP',0);
+setpv('BR01BPM12:DD2_ST_OFFSET_SP',0);
+setpv('BR01BPM12:DD3_ST_OFFSET_SP',0);
+setpv('BR01BPM12:DD4_ST_OFFSET_SP',0);
+
+% Seek point 0 (trigger), 1 (MT), 2 (ST)
+setpv('BR01BPM12:DD1_SEEK_POINT_SP',0);
+setpv('BR01BPM12:DD2_SEEK_POINT_SP',0);
+setpv('BR01BPM12:DD3_SEEK_POINT_SP',0);
+setpv('BR01BPM12:DD4_SEEK_POINT_SP',0);
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/bpm_scripts/booster/setliberaconfig.m b/machine/ASP/StorageRing/bpm_scripts/booster/setliberaconfig.m
new file mode 100644
index 00000000..fedeb292
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/booster/setliberaconfig.m
@@ -0,0 +1,444 @@
+function varargout = setliberaconfig(varargin)
+
+% SETLIBERACONFIG([deviceList | 'diag'])
+%
+% This function sets the default configuration for the Liberas. The
+% optional parameters are:
+%
+% deviceList A vector of nx2 specifying which devices to configure
+% 'diag' (String) configure the diagnostic BPM
+%
+% If no parameters are set, the configuration will be applied to all the
+% liberas that are enabled in middleLayer ("aspinit").
+%
+% e.g. >> setliberaconfig
+% >> setliberaconfig([1 2; 1 3; 1 4; 1 5;])
+% >> setliberaconfig('diag')
+%
+% 13/08/0009 Eugene Added comments and modified to add deviceList options
+
+% 21/11/2012 Removed Topup Check as added event to topup_timing.pcf JT
+% if getpv('TS01FPC01:FILL_CMD') == 7
+% % If in Topup
+
+% setpv('TS01EVR01:TTL01_EVENT_CODE_CMD',3); % Gun event
+% else
+% % Set the BPM trigger to Storage Ring BPM event
+% setpv('TS01EVR01:TTL01_EVENT_CODE_CMD',13);
+% end
+
+error('**** Need to run setliberabconfig for the Brilliance+ units ****');
+
+% configure the diagnostic BPM only
+if nargin > 0 && ischar(varargin{1}) && strcmpi(lower(varargin{1}),'diag')
+ disp('Configuring Diagnostic BPM');
+ fprintf('Setting SWITCHES to 255\n');
+ setlibera('ENV_SWITCHES_SP',255,[-1 -1]);
+
+ % Digital signal conditioning
+ fprintf('Turning _ON_ DSC\n');
+ setlibera('ENV_DSC_SP',2,[-1 -1]);
+
+ % Auto Gain Control
+ fprintf('Turning _ON_ AGC\n');
+ setlibera('ENV_AGC_SP',1,[-1 -1]);
+
+ % Interlocks
+ fprintf('Turning _OFF_ Interlocks\n');
+ setlibera('ENV_ILK_MODE_SP',0,[-1 -1]);
+ pause(5);
+ setlibera('ENV_SET_INTERLOCK_PARAM_CMD.PROC',0,[-1 -1]);
+
+ % Setting gains on the Diag libera
+ fprintf('Setting Kx and Ky...\n');
+ setlibera('ENV_KX_SP',14.8e6,[-1 -1]);
+ setlibera('ENV_KY_SP',15.1e6,[-1 -1]);
+
+ % Setting offsets on the Diag libera
+ fprintf('Setting x_offset and y_offset...\n');
+ setlibera('ENV_X_OFFSET_SP',-810474,[-1 -1]);
+ setlibera('ENV_Y_OFFSET_SP',+386743,[-1 -1]);
+
+ fprintf('Setting Swithing Synchronisation to External');
+ setlibera('ENV_EXTSWITCH_SP',1,[-1 -1]);
+ fprintf(' done.\n');
+
+ fprintf('Turning Spike Removal OFF: \n');
+ setliberasr('off','off',[-1 -1]);
+ fprintf(' done.\n');
+
+ fprintf('Setting PLL offset tune to 434 units (~17 kHz): \n');
+ setlibera('ENV_PLL_OFFSETTUNE_SP',434,[-1 -1]);
+ setlibera('ENV_PLL_COMPTUNE_SP',1,[-1 -1]);
+ fprintf(' done.\n');
+
+ return
+elseif nargin > 0 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+else
+ deviceList = getlist('BPMx');
+end
+
+if ~(nargin > 0 && isnumeric(varargin{1}))
+ % If configuring for specific Liberas, its been unlikely I'd want to
+ % change the timing. So when specifying the deviceList don't run this
+ % part.
+
+ % Set the delay. This has been optimised for topup and should also work for
+ % normal operation.
+ setliberatiming
+end
+
+bpmstatus = getfamilydata('BPMx','Status',deviceList);
+
+% Switches
+fprintf('Setting SWITCHES to 255\n');
+setlibera('ENV_SWITCHES_SP',255,deviceList);
+
+% Digital signal conditioning
+fprintf('Turning _ON_ DSC\n');
+setlibera('ENV_DSC_SP',2,deviceList);
+
+fprintf(' Setting Libera Interlocks ... ');
+% Setting HW interlock parameters
+% Limits have been changed after reevaluation of raytrace information
+% 18-10-2007 ET
+xlimits = [-1 1]; %mm
+ylimits = [-1 1]; %mm
+
+% Below is a list of BPMs that need the orbit interlock. Have added 2's and
+% 6's as backups if the primary ones fail. [2 2; and 2 3] aer for the IR
+% mirror.
+templist = [ [[1:14]' ones(14,1)]; [[1:14]' ones(14,1)*7];
+ [[1:14]' ones(14,1)*2]; [[1:14]' ones(14,1)*6]; [2 3] ];
+ind = findrowindex(templist,deviceList);
+devlist = deviceList(sort(ind),:);
+if ~isempty(devlist)
+ % 0 = disable; 1 = position; 3 = position and gain
+ setlibera('ENV_ILK_MODE_SP',0,deviceList); % turn everything else off and only turn specific ones on.
+ setlibera('ENV_ILK_MODE_SP',3,devlist);
+ setlibera('ENV_ILK_X_LOW_SP',xlimits(1)*1e6,devlist);
+ setlibera('ENV_ILK_X_HIGH_SP',xlimits(2)*1e6,devlist);
+ setlibera('ENV_ILK_Y_LOW_SP',ylimits(1)*1e6,devlist);
+ setlibera('ENV_ILK_Y_HIGH_SP',ylimits(2)*1e6,devlist);
+ setlibera('ENV_ILK_OF_LIMIT_SP',1900,devlist);
+ % The duration changed to match the rough duration of a standard fill
+ % pattern in the ring in raw ADC samples.
+ setlibera('ENV_ILK_OF_DUR_SP',40,devlist);
+end
+
+% Backup interlocks (ultra conservative here)
+templist = [[1:14]' ones(14,1)*2]; [[1:14]' ones(14,1)*6];
+ind = findrowindex(templist,deviceList);
+devlist = deviceList(sort(ind),:);
+if ~isempty(devlist)
+ setlibera('ENV_ILK_Y_LOW_SP',-0.5*1e6,devlist);
+ setlibera('ENV_ILK_Y_HIGH_SP',0.5*1e6,devlist);
+end
+
+% IR interlock (something different from the rest)
+templist = [2 2; 2 3];
+ind = findrowindex(templist,deviceList);
+devlist = devlist(sort(ind),:);
+if ~isempty(devlist)
+ setlibera('ENV_ILK_Y_LOW_SP',-0.7*1e6,devlist);
+ setlibera('ENV_ILK_Y_HIGH_SP',0.7*1e6,devlist);
+end
+
+% Measured at 18.45 mA on 16/02/07
+gain_limit = [...
+ -26.00000000 -26.00000000 -26.00000000 -24.00000000 -24.00000000 -26.00000000 -26.00000000, ... %
+ -27.00000000 -30.00000000 -32.00000000 -30.00000000 -30.00000000 -30.00000000 -30.00000000, ... %
+ -30.00000000 -33.00000000 -34.00000000 -33.00000000 -34.00000000 -34.00000000 -34.00000000, ... %
+ -28.00000000 -28.00000000 -27.00000000 -28.00000000 -29.00000000 -26.00000000 -26.00000000, ... %
+ -27.00000000 -27.00000000 -28.00000000 -27.00000000 -27.00000000 -25.00000000 -25.00000000, ... %
+ -33.00000000 -33.00000000 -35.00000000 -34.00000000 -34.00000000 -29.00000000 -29.00000000, ... %
+ -37.00000000 -37.00000000 -38.00000000 -38.00000000 -37.00000000 -32.00000000 -32.00000000, ... %
+ -31.00000000 -31.00000000 -32.00000000 -32.00000000 -32.00000000 -28.00000000 -28.00000000, ... %
+ -29.00000000 -28.00000000 -30.00000000 -29.00000000 -30.00000000 -28.00000000 -27.00000000, ... %
+ -29.00000000 -30.00000000 -32.00000000 -32.00000000 -32.00000000 -29.00000000 -29.00000000, ... %
+ -29.00000000 -29.00000000 -30.00000000 -30.00000000 -30.00000000 -29.00000000 -31.00000000, ... %
+ -32.00000000 -30.00000000 -32.00000000 -33.00000000 -33.00000000 -33.00000000 -34.00000000, ... %
+ -27.00000000 -28.00000000 -28.00000000 -26.00000000 -27.00000000 -25.00000000 -26.00000000, ... %
+ -27.00000000 -26.00000000 -27.00000000 -28.00000000 -28.00000000 -28.00000000 -28.00000000, ... %
+];
+
+% Measured at 25 mA on 22/02/07
+gain_limit = [...
+ -24 -23 -23 -23 -23 -24 -24, ... %
+ -24 -23 -29 -28 -29 -28 -27, ... %
+ -31 -31 -32 -31 -32 -31 -31, ... %
+ -26 -27 -26 -26 -27 -23 -24, ... %
+ -24 -25 -26 -26 -25 -23 -23, ... %
+ -31 -32 -32 -31 -32 -27 -26, ... %
+ -35 -34 -36 -35 -35 -30 -30, ... %
+ -29 -28 -29 -30 -28 -26 -26, ... %
+ -26 -26 -28 -26 -27 -27 -25, ... %
+ -26 -28 -29 -29 -30 -26 -26, ... %
+ -26 -27 -28 -27 -27 -28 -29, ... %
+ -29 -29 -29 -31 -30 -31 -32, ... %
+ -25 -26 -26 -24 -24 -23 -24, ... %
+ -26 -24 -26 -26 -26 -26 -26, ... %
+ ];
+
+% Measured at 26.7 mA on 17/11/2008
+% Changed thresholds for sector 7 after move. Cable attenuation reduced by
+% 6 dB. ET 2/8/2009
+gain_limit = [...
+ -23 -22 -23 -21 -21 -23 -23, ... %
+ -23 -22 -29 -27 -28 -27 -27, ... %
+ -29 -29 -31 -30 -31 -31 -31, ... %
+ -25 -26 -26 -26 -26 -22 -22, ... %
+ -23 -24 -25 -24 -23 -22 -21, ... %
+ -30 -30 -32 -31 -31 -27 -26, ... %
+ [-33 -33 -34 -34 -33 -29 -29]+6, ... %
+ -28 -28 -29 -29 -28 -26 -24, ... %
+ -26 -25 -27 -26 -27 -26 -23, ... %
+ -26 -28 -29 -29 -29 -26 -26, ... %
+ -26 -26 -27 -27 -27 -28 -26, ... %
+ -28 -28 -29 -30 -30 -30 -30, ... %
+ -24 -25 -25 -23 -23 -22 -23, ... %
+ -24 -23 -24 -25 -25 -26 -25, ... %
+ ];
+% However as the AGC is slow to respond the gain limits should be put at a
+% lower level comparable to
+
+% Ensure that a column vector is passed to setlibera.
+temp = gain_limit(dev2elem('BPMx',deviceList));
+setlibera('ENV_ILK_GAIN_LIMIT_SP',temp(:),deviceList);
+% Apply changes. This also resets the orbit interlock status PV.
+setlibera('ENV_SET_INTERLOCK_PARAM_CMD',1,deviceList);
+
+% Acknowledge all interlocks
+setlibera('ENV_INTERLOCK_CLEAR_CMD.PROC',1,deviceList);
+
+fprintf(' done.\n');
+
+% As of 22/09/2011 Software orbit interlock has been removed. Eugene
+% fprintf(' Disabling software orbit interlock...');
+% for i=[1 2 3 4 5 6 7 8 9 10 11 12 13 14]
+% try
+% setpv(sprintf('SR%02dOI01:INHIBIT_ENABLE_CMD.DISP',i),0);
+% pause(0.01);
+% setpv(sprintf('SR%02dOI01:INHIBIT_ENABLE_CMD',i),1);
+% catch
+% end
+% end;
+% fprintf(' done.\n');
+
+
+fprintf(' Setting Libera Gain ... ');
+K = [14.593 14.648];
+libera_gain_x = [ ...
+ +0.966948080 +0.959619910 +0.959120392 +0.959046416 +0.958646839 +0.970136269 +0.989077507, ... %
+ +0.962305519 +1.000000000 +0.972453818 +0.973353564 +0.968318612 +0.974381125 +0.950104340, ... %
+ +0.955556319 +0.967719387 +0.981479354 +0.967697565 +0.974265951 +0.974843991 +0.960286102, ... %
+ +0.955195998 +0.962080805 +0.966617065 +0.963776590 +1.000000000 +0.962251920 +0.950797707, ... %
+ +0.962338934 +0.960510260 +1.000000000 +0.963476055 +0.955816561 +0.970940062 +0.970461463, ... %
+ +0.978357029 +0.960498444 +0.978981418 +0.975108996 +0.967525095 +1.000000000 +0.995110939, ... %
+ +1.008955830 +0.981430592 +1.000000000 +0.975632632 +0.983720220 +0.965493949 +0.968582952, ... %
+ +0.961121710 +0.966910076 +0.961221400 +0.980075750 +0.965634395 +0.965313494 +0.955373284, ... %
+ +0.970222644 +0.965991662 +0.962625146 +0.966684034 +1.000000000 +0.959439683 +0.957108540, ... %
+ +0.963204585 +0.966602116 +0.984932228 +0.968120932 +0.972003650 +0.973590996 +0.979101961, ... %
+ +0.952306249 +1.000000000 +0.964035998 +0.974901575 +0.985506540 +0.968637792 +0.982478924, ... %
+ +0.983423472 +0.971033202 +0.968951290 +0.974224051 +0.981495416 +0.975066573 +0.965662919, ... %
+ +0.962029114 +0.959208439 +0.967355776 +0.967418693 +0.971780196 +1.000000000 +0.957020986, ... %
+ +0.976673428 +0.973211075 +0.964885897 +0.968629156 +0.960083213 +0.959900844 +0.945449626, ... %
+ ]';
+libera_gain_y = [ ...
+ +0.948742740 +0.938985980 +0.947990664 +0.946717526 +0.943606693 +0.948187874 +0.919157421, ... %
+ +0.942776941 +1.000000000 +0.946087417 +0.956274522 +0.947370487 +0.949872141 +0.946387610, ... %
+ +0.939869535 +0.954926521 +0.956387595 +0.949416686 +0.953505592 +0.953622843 +0.954557915, ... %
+ +0.945121854 +0.952457360 +0.947382619 +0.941596137 +1.000000000 +0.936874260 +0.928534297, ... %
+ +0.942307791 +0.945010554 +1.000000000 +0.946576270 +0.946095974 +0.940937320 +0.940093187, ... %
+ +0.939533330 +0.948664068 +0.953825209 +0.952652917 +0.956446497 +1.000000000 +0.921532602, ... %
+ +0.959464550 +0.950304327 +1.000000000 +0.953212616 +0.958565862 +0.947571387 +0.946256864, ... %
+ +0.947723060 +0.946544009 +0.945606560 +0.962324655 +0.953574090 +0.949310515 +0.946090734, ... %
+ +0.950022254 +0.933364762 +0.943970019 +0.952200155 +1.000000000 +0.935012402 +0.943822892, ... %
+ +0.948076061 +0.948695079 +0.955976906 +0.949857838 +0.946005079 +0.948099472 +0.998813326, ... %
+ +0.936645213 +1.000000000 +0.938436145 +0.951387541 +0.970085370 +0.943411291 +0.943139410, ... %
+ +0.955283538 +0.949711620 +0.952274079 +0.958000353 +0.953091159 +0.941295894 +0.948895146, ... %
+ +0.942522818 +0.936837423 +0.944267089 +0.940357974 +0.947760848 +1.000000000 +0.921421809, ... %
+ +0.925439928 +0.938130282 +0.942509420 +0.951921198 +0.942846824 +0.946266672 +0.951273619, ... %
+ ]';
+% 16/02/2007
+libera_gain_x = [ ...
+ +0.98065084 +0.96332305 +0.96462458 +0.97356900 +0.96644755 +0.98972762 +0.99803758, ... %
+ +0.97381483 +1.00000000 +0.97937956 +0.98981618 +0.98112604 +0.98608984 +0.95923814, ... %
+ +0.95555632 +0.97971727 +1.00418594 +0.97887852 +0.98570080 +0.99278104 +0.97781389, ... %
+ +0.96079200 +0.97471975 +0.96661706 +0.97214864 +1.04170927 +0.96953238 +0.94940742, ... %
+ +0.97111888 +0.96728025 +1.04651477 +0.97728357 +0.96134764 +0.97719961 +0.98916880, ... %
+ +1.00224357 +0.97100221 +0.99091069 +0.99486417 +0.98754895 +1.03052325 +1.00773195, ... %
+ +1.03127963 +1.01229856 +1.03881681 +0.99565998 +1.01411043 +0.97823481 +0.98682531, ... %
+ +0.96897460 +0.97478013 +0.96496404 +1.00582362 +0.97265235 +0.97059168 +0.96498306, ... %
+ +0.98836325 +0.97360393 +0.96967122 +0.97685603 +1.04347456 +0.96842185 +0.96794714, ... %
+ +0.96987239 +0.97460713 +1.01118380 +0.98267390 +0.98871913 +0.99071220 +1.00808455, ... %
+ +0.94231696 +1.04594128 +0.97280204 +0.99082037 +1.00855885 +0.98444284 +1.01422470, ... %
+ +1.03416337 +0.97676445 +0.98023853 +1.00049481 +1.00887827 +0.99040517 +0.98213874, ... %
+ +0.97292523 +0.96235993 +0.97823893 +0.97860437 +0.98810766 +1.03935436 +0.96070000, ... %
+ +0.98200130 +0.98785254 +0.95847647 +0.97832909 +0.95822393 +0.96253495 +0.95473355, ... %
+]';
+libera_gain_y = [ ...
+ +0.97309509 +0.95609923 +0.96630216 +0.96348775 +0.95850788 +0.96687943 +0.91988411, ... %
+ +0.95833878 +1.00000000 +0.96101345 +0.97624167 +0.96241716 +0.96955358 +0.96275598, ... %
+ +0.93986954 +0.97532650 +0.97840062 +0.96031310 +0.97333007 +0.97804858 +0.97561475, ... %
+ +0.96234509 +0.97390607 +0.94738262 +0.95395284 +1.07350723 +0.94489729 +0.93738772, ... %
+ +0.95643798 +0.95852768 +1.06902251 +0.96104282 +0.95822695 +0.95902437 +0.95678273, ... %
+ +0.95319748 +0.96729898 +0.97248842 +0.96621831 +0.97749538 +1.07041318 +0.92861579, ... %
+ +1.00004803 +0.97045198 +1.07282384 +0.96641823 +0.98364057 +0.96840075 +0.96511461, ... %
+ +0.96646593 +0.96477837 +0.95773646 +0.98867225 +0.97471819 +0.96884309 +0.96058673, ... %
+ +0.96605015 +0.93746399 +0.95458147 +0.97029753 +1.07443478 +0.94686388 +0.95509890, ... %
+ +0.96180766 +0.96899984 +0.97873461 +0.96592276 +0.96368095 +0.96553179 +1.07651530, ... %
+ +0.94872454 +1.07492964 +0.95261031 +0.96855645 +1.00765275 +0.94137132 +0.94387467, ... %
+ +0.96791978 +0.97084230 +0.96651960 +0.98027098 +0.97387417 +0.95433885 +0.97518112, ... %
+ +0.95650968 +0.94694534 +0.95358627 +0.94820797 +0.96586596 +1.07797176 +0.92007440, ... %
+ +0.93155173 +0.95037365 +0.95099987 +0.96492413 +0.95059941 +0.95620621 +0.95743179, ... %
+]';
+
+% setlibera('ENV_KX_SP',K(1).*libera_gain_x(find(bpmstatus))*1e6);
+% setlibera('ENV_KY_SP',K(2).*libera_gain_y(find(bpmstatus))*1e6);
+
+% 9-3-2008 Eugenee: Make gains uniform for now. This needs to be revisited
+setlibera('ENV_KX_SP',14.8e6,deviceList);
+setlibera('ENV_KY_SP',15.1e6,deviceList);
+
+fprintf(' done.\n');
+
+
+% With the new I-Tech epics driver commissioning we need to make sure
+% certain features are turned off first.
+% fprintf('\nSetting Gains\n');
+setgains('auto',deviceList);
+
+fprintf('Setting Swithing Synchronisation to External');
+setlibera('ENV_EXTSWITCH_SP',1,deviceList);
+fprintf(' done.\n');
+
+fprintf('Turning Spike Removal OFF: \n')
+setliberasr('off','off',deviceList);
+fprintf(' done.\n');
+
+% 30/03/2016 Eugene change default offset tuning from 125 to 110, to shift
+% the major noise peaks to above 500 Hz.
+% 31/03/2016 Eugene: further investigation showed pll offset = 434 was
+% better still.
+fprintf('Setting PLL offset tune to 434 units (17.36 kHz): \n');
+setlibera('ENV_PLL_OFFSETTUNE_SP',434,deviceList);
+setlibera('ENV_PLL_COMPTUNE_SP',1,deviceList);
+fprintf(' done.\n');
+
+% Libera synchronisation MUST be after setting the PLL tune and offset
+% tune.
+fprintf('Machine time INITIALISATION (will take 5 seconds)')
+setliberasync(deviceList);
+fprintf(' done.\n');
+
+
+
+fprintf('-------------[ BR Libera ]-------------\n')
+try
+ setliberabr;
+catch
+ lasterr
+end
+fprintf('-------------[ LTB/BTS Libera ]-------------\n')
+try
+ setliberaconfig_tl;
+catch
+ lasterr
+end
+
+% temporary
+fprintf('*** TEMP PV CORRECTIONS (FANS) ***\n');
+% deviceList = getlist('BPMx');
+setlibera('ENV_FRONT_VENT_ACT_MONITOR.HIHI',5500,deviceList);
+setlibera('ENV_FRONT_VENT_ACT_MONITOR.LOLO',3500,deviceList);
+setlibera('ENV_FRONT_VENT_ACT_MONITOR.HIGH',5500,deviceList);
+setlibera('ENV_FRONT_VENT_ACT_MONITOR.LOW',3500,deviceList);
+setlibera('ENV_BACK_VENT_ACT_MONITOR.HIHI',5500,deviceList);
+setlibera('ENV_BACK_VENT_ACT_MONITOR.LOLO',3500,deviceList);
+setlibera('ENV_BACK_VENT_ACT_MONITOR.HIGH',5500,deviceList);
+setlibera('ENV_BACK_VENT_ACT_MONITOR.LOW',3500,deviceList);
+
+fprintf('*** TEMP PV CORRECTIONS (DD seek point and Ignore trig) ***\n');
+% deviceList = getlist('BPMx');
+setlibera('DD1_SEEK_POINT_SP',0,deviceList);
+setlibera('DD2_SEEK_POINT_SP',0,deviceList);
+setlibera('DD3_SEEK_POINT_SP',0,deviceList);
+setlibera('DD4_SEEK_POINT_SP',0,deviceList);
+setlibera('DD5_SEEK_POINT_SP',0,deviceList);
+
+setlibera('ADC_IGNORE_TRIG_SP',0,deviceList);
+setlibera('DD1_IGNORE_TRIG_SP',0,deviceList);
+setlibera('DD2_IGNORE_TRIG_SP',1,deviceList);
+setlibera('DD3_IGNORE_TRIG_SP',0,deviceList);
+setlibera('DD4_IGNORE_TRIG_SP',1,deviceList);
+setlibera('DD5_IGNORE_TRIG_SP',0,deviceList);
+
+
+return
+
+
+
+
+
+
+
+
+% Set to 1 to set the attenuation factors for the liberas. Refer to the
+% attenuation table below to determine exactly what attenuations are used.
+setLiberaAttenuation = 0;
+
+if setLiberaAttenuation
+ fprintf(' Setting Libera Attenuation ... ');
+
+ [pin att1_list att2_list] = textread('libera_attn_table3.txt','%d %d %d','headerlines',1);
+
+ BPMcableattenuation = [...
+ -6.6500 -5.9750 -5.9250 -5.6000 -5.4500 -6.3750 -6.3750, ... % Sector 1
+ -6.8250 -6.5000 -12.2750 -11.9500 -11.5250 -10.9000 -10.8250, ... % 2
+ -13.3750 -13.5750 -14.8250 -14.4000 -14.3250 -14.7750 -14.8000, ... % 3
+ -9.4250 -9.3500 -10.8500 -10.4250 -10.4000 -5.9000 -5.9000, ... % 4
+ -7.1000 -7.0000 -8.4000 -7.9000 -7.8000 -5.4000 -5.4750, ... % 5
+ -13.7750 -13.7150 -15.3250 -14.8250 -14.7000 -10.3000 -10.3000, ... % 6
+ -16.6650 -16.5225 -18.1550 -17.7575 -17.3075 -12.7400 -12.7125, ... % 7
+ -11.9150 -11.5875 -13.0550 -12.5450 -12.3350 -9.0550 -9.1575, ... % 8
+ -10.0225 -9.7075 -11.0775 -10.7075 -10.6400 -8.6800 -8.4350, ... % 9
+ -11.4725 -11.3575 -12.4475 -12.1825 -11.9750 -9.6700 -9.6575, ... %10
+ -9.9525 -9.7900 -10.6475 -10.5100 -10.4750 -11.5050 -11.5725, ... %11
+ -12.9225 -12.6525 -14.0425 -13.6075 -13.4225 -14.1350 -14.0025, ... %12
+ -8.7000 -8.8750 -8.3250 -7.7250 -7.4200 -6.4150 -6.5250, ... %13
+ -8.0925 -7.7950 -9.0725 -8.5625 -8.4475 -9.2050 -9.2225, ... %14
+ ];
+
+ % Beam power -12 dBm at 70.0 mA --> mean(getam('FTx', 'Maxadc')) = 1312.
+ % Beam power -14 dBm at 49.8 mA --> mean(getam('FTx', 'Maxadc')) = 1319.
+ % Beam power -15 dBm at 45.5 mA --> mean(getam('FTx', 'Maxadc')) = 1384.
+ % Beam power -17 dBm at 35.0 mA --> mean(getam('FTx', 'Maxadc')) = 1306.
+ % Beam power -18 dBm at 32.4 mA --> mean(getam('FTx', 'Maxadc')) = 1345.
+ % Beam power -19 dBm at 29.7 mA --> mean(getam('FTx', 'Maxadc')) = 1356.
+
+ % With an even fill the maximum ADC values have decreased a lot to get
+ % the same signal level as before we need to apply a factor of 0.11
+% beam_power = fix(getam('DCCT')*0.11/3 - 28);
+ beam_power = fix(110*0.11/3 - 28);
+ beam_power = -20;
+
+ power_into_libera = beam_power + BPMcableattenuation;
+
+ bpmstatus = getfamilydata('BPMx','Status');
+ setlibera('ENV_GAIN_SP',round(power_into_libera(find(bpmstatus)))');
+
+% att1 = zeros(size(family2dev('BPMx',0),1));
+% att2 = att1;
+% for i=1:length(power_into_libera)
+% att1(i) = interp1(pin,att1_list,power_into_libera(i),'nearest');
+% att2(i) = interp1(pin,att2_list,power_into_libera(i),'nearest');
+% end
+%
+% bpmstatus = getfamilydata('BPMx','Status');
+% setlibera('CF_ATT1_S_SP',att1(find(bpmstatus)));
+% setlibera('CF_ATT2_S_SP',att2(find(bpmstatus)));
+
+ fprintf(' done.\n');
+end
diff --git a/machine/ASP/StorageRing/bpm_scripts/functionSignatures.json b/machine/ASP/StorageRing/bpm_scripts/functionSignatures.json
new file mode 100644
index 00000000..b4760f74
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/functionSignatures.json
@@ -0,0 +1,197 @@
+{
+"srbpm.getfield":
+{
+ "inputs":
+ [
+ {"name":"field", "kind":"required", "type":"choices={
+'SA_X_MONITOR',
+'SA_Y_MONITOR',
+'AGC_ATT_MONITOR',
+'AGC_POWER_LEVEL_MONITOR',
+'AGC_ENABLED_STATUS',
+'AGC_ENABLED_CMD',
+'AGC_ATT_SP',
+'AGC_POWER_LEVEL_SP',
+'DSC_COEFF_ADJUST_STATUS',
+'DSC_COEFF_ATT_DEPENDENT_STATUS',
+'SWITCHING_DELAY_MONITOR',
+'SWITCHING_ENABLE_STATUS',
+'SWITCHING_SOURCE_STATUS',
+'DSC_COEFF_TYPE_STATUS',
+'DSC_COEFF_ADJUST_CMD',
+'DSC_COEFF_ADJUST_CMD',
+'DSC_COEFF_ATT_DEPENDENT_CMD',
+'DSC_COEFF_ATT_DEPENDENT_CMD',
+'SWITCHING_ENABLE_CMD',
+'SWITCHING_ENABLE_CMD',
+'SWITCHING_SOURCE_CMD',
+'SWITCHING_SOURCE_CMD',
+'DSC_COEFF_TYPE_CMD',
+'DSC_COEFF_TYPE_CMD',
+'SWITCHING_DELAY_SP',
+'ILK_ENABLED_STATUS',
+'ILK_GAIN_DEPENDENT_ENABLED_STATUS',
+'ILK_GAIN_DEPENDENT_THRESHOLD_MONITOR',
+'ILK_GAIN_DEPENDENT_THRESHOLD_DB_MONITOR',
+'ILK_LIMITS_MIN_X_MONITOR',
+'ILK_LIMITS_MIN_Y_MONITOR',
+'ILK_LIMITS_MAX_X_MONITOR',
+'ILK_LIMITS_MAX_Y_MONITOR',
+'ILK_LIMITS_OVF_THRESHOLD_MONITOR',
+'ILK_LIMITS_OVF_MODE_STATUS',
+'ILK_LIMITS_OVF_DURATION_MONITOR',
+'ILK_STATUS_X_STATUS',
+'ILK_STATUS_RESET_CMD',
+'ILK_STATUS_ATTENUATOR_STATUS',
+'ILK_STATUS_STATUS',
+'ILK_STATUS_Y_STATUS',
+'ILK_LIMITS_MAX_X_SP',
+'ILK_LIMITS_MIN_Y_SP',
+'ILK_LIMITS_MAX_Y_SP',
+'ILK_LIMITS_MIN_X_SP',
+'ILK_STATUS_RESET_CMD',
+'ILK_ENABLED_CMD',
+'ILK_GAIN_DEPENDENT_ENABLED_CMD',
+'ILK_GAIN_DEPENDENT_ENABLED_CMD',
+'ILK_GAIN_DEPENDENT_THRESHOLD_SP',
+'ILK_LIMITS_OVF_DURATION_SP',
+'ILK_LIMITS_OVF_THRESHOLD_SP',
+'KX_MONITOR',
+'KY_MONITOR',
+'OFF_X_MONITOR',
+'OFF_Y_MONITOR',
+'OFF_S_MONITOR',
+'OFF_Q_MONITOR',
+'KS_MONITOR',
+'MAXADC_MONITOR',
+'OFF_S_SP',
+'OFF_Q_SP',
+'OFF_Y_SP',
+'OFF_X_SP',
+'KX_SP',
+'KS_SP',
+'KY_SP',
+'STAT_SA_X_MEAN_MONITOR',
+'STAT_SA_Y_MEAN_MONITOR',
+'STAT_SA_Y_STD_MONITOR',
+'STAT_SA_X_STD_MONITOR',
+'STAT_TBT_Y_MEAN_MONITOR',
+'STAT_TBT_Y_STD_MONITOR',
+'STAT_TBT_X_STD_MONITOR',
+'STAT_TBT_X_MEAN_MONITOR',
+'STAT_TBT_MODE_STATUS',
+'STAT_TBT_PERIOD_MONITOR',
+'STAT_TBT_WINDOW_MONITOR',
+'STAT_TBT_MODE_CMD',
+'STAT_TBT_PERIOD_SP',
+'STAT_TBT_WINDOW_SP',
+'STAT_SA_WINDOW_MONITOR',
+'STAT_SA_STEP_MONITOR',
+'STAT_SA_WINDOW_SP',
+'STAT_SA_STEP_SP',
+'ID_MONITOR',
+'ID_SP',
+'TDP_SYNTH_SIGNAL.X',
+'TDP_SYNTH_SIGNAL.Y',
+'TDP_SYNTH_SIGNAL.Sum',
+'TDP_SYNTH_SIGNAL.Va',
+'TDP_SYNTH_SIGNAL.Vb',
+'TDP_SYNTH_SIGNAL.Vc',
+'TDP_SYNTH_SIGNAL.Vd',
+'TDP_SYNTH_SIGNAL.SCAN',
+'TDP_SYNTH_SIGNAL.ACQM',
+'TDP_SYNTH_SIGNAL.MT',
+'ADC_SIGNAL.SCAN',
+'ADC_SIGNAL.ACQM',
+'ADC_SIGNAL.ChannelB',
+'ADC_SIGNAL.ChannelA',
+'ADC_SIGNAL.ChannelD',
+'ADC_SIGNAL.ChannelC',
+'EVRX_PLL_LOCKED_STATUS',
+'EVRX_PLL_MAX_ERR_MONITOR',
+'EVRX_PLL_OS_UNLOCK_TIME_MONITOR',
+'SYNC_ST_M_STATUS',
+'GDX_SYNC_STATUS',
+'EVRX_RTC_MC_IN_MASK_MONITOR',
+'EVRX_RTC_MC_IN_FUNCTION_MONITOR',
+'EVRX_TRIGGERS_MC_SOURCE_STATUS',
+'EVRX_EVENTS_MC_COUNT_MONITOR',
+'EVRX_RTC_T0_IN_MASK_MONITOR',
+'EVRX_RTC_T0_IN_FUNCTION_MONITOR',
+'EVRX_TRIGGERS_T0_SOURCE_STATUS',
+'EVRX_EVENTS_T0_COUNT_MONITOR',
+'EVRX_RTC_T1_IN_MASK_MONITOR',
+'EVRX_RTC_T1_IN_FUNCTION_MONITOR',
+'EVRX_TRIGGERS_T1_SOURCE_STATUS',
+'EVRX_EVENTS_T1_COUNT_MONITOR',
+'EVRX_RTC_T2_IN_MASK_MONITOR',
+'EVRX_RTC_T2_IN_FUNCTION_MONITOR',
+'EVRX_TRIGGERS_T2_SOURCE_STATUS',
+'EVRX_EVENTS_T2_COUNT_MONITOR',
+}"}
+ ]
+}
+,
+"srbpm.setfield":
+{
+ "inputs":
+ [
+ {"name":"field", "kind":"required", "type":"choices={
+'AGC_ENABLED_CMD',
+'AGC_ATT_SP',
+'AGC_POWER_LEVEL_SP',
+'DSC_COEFF_ADJUST_CMD',
+'DSC_COEFF_ADJUST_CMD',
+'DSC_COEFF_ATT_DEPENDENT_CMD',
+'DSC_COEFF_ATT_DEPENDENT_CMD',
+'SWITCHING_ENABLE_CMD',
+'SWITCHING_ENABLE_CMD',
+'SWITCHING_SOURCE_CMD',
+'SWITCHING_SOURCE_CMD',
+'DSC_COEFF_TYPE_CMD',
+'DSC_COEFF_TYPE_CMD',
+'SWITCHING_DELAY_SP',
+'ILK_LIMITS_MAX_X_SP',
+'ILK_LIMITS_MIN_Y_SP',
+'ILK_LIMITS_MAX_Y_SP',
+'ILK_LIMITS_MIN_X_SP',
+'ILK_ENABLED_CMD',
+'ILK_GAIN_DEPENDENT_ENABLED_CMD',
+'ILK_GAIN_DEPENDENT_ENABLED_CMD',
+'ILK_GAIN_DEPENDENT_THRESHOLD_SP',
+'ILK_LIMITS_OVF_DURATION_SP',
+'ILK_LIMITS_OVF_THRESHOLD_SP',
+'OFF_S_SP',
+'OFF_Q_SP',
+'OFF_Y_SP',
+'OFF_X_SP',
+'KX_SP',
+'KS_SP',
+'KY_SP',
+'STAT_TBT_MODE_CMD',
+'STAT_TBT_PERIOD_SP',
+'STAT_TBT_WINDOW_SP',
+'STAT_SA_WINDOW_SP',
+'STAT_SA_STEP_SP',
+'ID_SP',
+'TDP_SYNTH_SIGNAL.X',
+'TDP_SYNTH_SIGNAL.Y',
+'TDP_SYNTH_SIGNAL.Sum',
+'TDP_SYNTH_SIGNAL.Va',
+'TDP_SYNTH_SIGNAL.Vb',
+'TDP_SYNTH_SIGNAL.Vc',
+'TDP_SYNTH_SIGNAL.Vd',
+'TDP_SYNTH_SIGNAL.SCAN',
+'TDP_SYNTH_SIGNAL.ACQM',
+'TDP_SYNTH_SIGNAL.MT',
+'ADC_SIGNAL.SCAN',
+'ADC_SIGNAL.ACQM',
+'ADC_SIGNAL.ChannelB',
+'ADC_SIGNAL.ChannelA',
+'ADC_SIGNAL.ChannelD',
+'ADC_SIGNAL.ChannelC',
+'',
+}"}
+ ]
+}
+}
diff --git a/machine/ASP/StorageRing/bpm_scripts/generatefunctionSignatures.m b/machine/ASP/StorageRing/bpm_scripts/generatefunctionSignatures.m
new file mode 100644
index 00000000..2af7562d
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/generatefunctionSignatures.m
@@ -0,0 +1,66 @@
+fid = fopen('functionSignatures.json','w');
+
+fprintf(fid,'{\n'); % open object
+
+fprintf(fid,'"srbpm.getfield":\n');
+fprintf(fid,'{\n');
+fprintf(fid,' "inputs":\n');
+fprintf(fid,' [\n');
+fprintf(fid,' {"name":"field", "kind":"required", "type":"choices={\n');
+
+pvfid = fopen('tlibera_brilliance_bpm_form_20180720_155855.txt','r');
+C = textscan(pvfid,'%s%s\n','CommentStyle','#','Whitespace',' \b\t:');
+fclose(pvfid);
+fprintf(fid,'''%s'',\n',string(C{2}));
+
+addpvs = [
+ "EVRX_PLL_LOCKED_STATUS"
+ "EVRX_PLL_MAX_ERR_MONITOR"
+ "EVRX_PLL_OS_UNLOCK_TIME_MONITOR"
+ "SYNC_ST_M_STATUS"
+ "GDX_SYNC_STATUS"
+ "EVRX_RTC_MC_IN_MASK_MONITOR"
+ "EVRX_RTC_MC_IN_FUNCTION_MONITOR"
+ "EVRX_TRIGGERS_MC_SOURCE_STATUS"
+ "EVRX_EVENTS_MC_COUNT_MONITOR"
+ "EVRX_RTC_T0_IN_MASK_MONITOR"
+ "EVRX_RTC_T0_IN_FUNCTION_MONITOR"
+ "EVRX_TRIGGERS_T0_SOURCE_STATUS"
+ "EVRX_EVENTS_T0_COUNT_MONITOR"
+ "EVRX_RTC_T1_IN_MASK_MONITOR"
+ "EVRX_RTC_T1_IN_FUNCTION_MONITOR"
+ "EVRX_TRIGGERS_T1_SOURCE_STATUS"
+ "EVRX_EVENTS_T1_COUNT_MONITOR"
+ "EVRX_RTC_T2_IN_MASK_MONITOR"
+ "EVRX_RTC_T2_IN_FUNCTION_MONITOR"
+ "EVRX_TRIGGERS_T2_SOURCE_STATUS"
+ "EVRX_EVENTS_T2_COUNT_MONITOR"
+ ];
+fprintf(fid,'''%s'',\n',addpvs);
+
+fprintf(fid,'}"}\n');
+fprintf(fid,' ]\n');
+fprintf(fid,'}\n');
+
+fprintf(fid,',\n');
+
+fprintf(fid,'"srbpm.setfield":\n');
+fprintf(fid,'{\n');
+fprintf(fid,' "inputs":\n');
+fprintf(fid,' [\n');
+fprintf(fid,' {"name":"field", "kind":"required", "type":"choices={\n');
+
+% Same as before but remove all monitors and status PVs as these cannot be
+% set
+fprintf(fid,'''%s'',\n',string( C{2}( ~contains(C{2},'MONITOR') & ~contains(C{2},'STATUS') ) ));
+fprintf(fid,'''%s'',\n',addpvs( ~contains(addpvs,'MONITOR') & ~contains(addpvs,'STATUS') ));
+
+fprintf(fid,'}"}\n');
+fprintf(fid,' ]\n');
+fprintf(fid,'}\n');
+
+
+
+fprintf(fid,'}\n'); % Close object
+
+fclose(fid);
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/bpm_scripts/getbpmaverages.m b/machine/ASP/StorageRing/bpm_scripts/getbpmaverages.m
new file mode 100644
index 00000000..ec4e7a8a
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/getbpmaverages.m
@@ -0,0 +1,32 @@
+function [N, T] = getbpmaverages(varargin)
+%GETBPMAVERAGES - Gets the BPM averages
+% [N, T] = getbpmaverages
+% N = Number of averages
+% T = Sampling period after averaging [seconds]
+%
+% In Simlutor mode, N = 1 and T = 0
+%
+% This is used by MML to determine the delays required for fresh BPM data.
+
+Mode = getfamilydata('BPMx','Monitor','Mode');
+if strcmpi(Mode,'Simulator')
+
+ N = 1;
+ T = 0;
+
+else
+
+ % Libera update period, T, should be around 0.1 s but for added
+ % security we'll use something larger. This value is important as the
+ % use of WaitFlags = -2 will use this time period to wait for the BPMs
+ % to update with new data.
+ % changed to 0.1 from 0.3 ET 02-11-2009
+ % Changed back from 0.1 to 0.3 ET 03/02/2017
+ T = 0.3;
+ % N is supposed to signify how many samples are averaged over to get
+ % the resulting BPM position. With Liberas this is not so clear cut so
+ % for now will use 5000.
+ % 27-07-2006 Eugene
+ N = 5000;
+
+end
diff --git a/machine/ASP/StorageRing/bpm_scripts/getliberadata.m b/machine/ASP/StorageRing/bpm_scripts/getliberadata.m
new file mode 100644
index 00000000..c518542c
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/getliberadata.m
@@ -0,0 +1,161 @@
+function varargout = getliberadata(varargin)
+%
+% data = getliberadata(STREAM, [DEVICELIST, TRIG_ACQUIRE, NUMSAMPLES])
+%
+% STREAM = libera stream e.g. 'DD1' 'DD3'. (default = 'DD3')
+% * ADC_SIGNAL - RAW ADC acquired data
+% * TBT_TBT_WINDOW_SIGNAL - ADC points used to compute TBT data
+% * DDC_RAW_SIGNAL - amplitude and phase data
+% * DDC_SYNTH_SIGNAL - down converted x and y data
+% * TDP_SYNTH_SIGNAL - time domain converted x and y data
+% * PM_DDC_SYNTH_SIGNAL - post mortem data
+% DEVICELIST = devicelist, [] will use all devices returned by
+% getlist('BPMx'). (default = [])
+% TRIG_ACQUIRE = this will get the liberas to acquire fresh data. Currently
+% defaults to on trigger with whatever offsets loaded into
+% the libera. '0' to not acquire fresh data while '1' will
+% refresh the data. (default = 0)
+% NUMSAMPLES = number of samples to return. If NUMSAMPLES > number of
+% available data then getliberabtbt will only return as many
+% data points as there are in the PV.
+%
+% Examples
+%
+% >> d = getliberadata('TDP_SYNTH');
+% >> d = getliberadata('TDP_SYNTH',[],1); % Collect from all bpms and apply trigger (SR BPM trigger)
+%
+% Eugene
+% 10-04-2007
+% 14-06-2011 Small update to the way it triggers using new BPM Event.
+% 06-09-2017 ET updated for libera Brilliance
+%
+
+
+
+
+if nargin > 0 && ischar(varargin{1})
+ stream = [varargin{1}];
+else
+ stream = 'TDP_SYNTH_SIGNAL';
+end
+
+if nargin > 1 && ~isempty(varargin{2})
+ % User specified device list
+ devicelist = varargin{2};
+else
+ % Use default bpms
+ devicelist = getlist('BPMx');
+end
+if size(devicelist,2) == 1
+ % assume user has used element number instead
+ devicelist = elem2dev('BPMx',devicelist);
+end
+
+if nargin > 2 && isnumeric(varargin{3})
+ trigger = varargin{3};
+else
+ trigger = 0;
+end
+
+if nargin > 3 && isnumeric(varargin{4})
+ nelem = varargin{4};
+else
+ nelem = 0;
+end
+
+
+% No need for trigger for PM data
+if trigger && ~(strcmpi(stream,'PM_DDC_SYNTH_SIGNAL') || strcmpi(stream,'PM_DDC_RAW_SIGNAL'))
+ % We will assume here that there is no trigger being sent to the bpm.
+ % Also assume the first in the devicelist as a representative of the
+ % rest that it is receiving the trigger and updating data.
+ if strncmp(stream,'ADC_SIGNAL',3)
+ timestampfield = [stream '.LMT'];
+ else
+ timestampfield = [stream '.MT' ];
+ end
+ mt0 = srbpm.getfield(timestampfield,devicelist(1,:));
+ pause(0.1);
+
+ % TBT_TBT_WINDOW needs to be proc'ed however there is no valid MT data
+ % to compare to see if there is fresh data.
+ if ~strcmpi(stream,'TBT_TBT_WINDOW_SIGNAL')
+ % Get the EVR to send a trigger signal to the Liberas. Triggers at the
+ % AS are slaved to the 1Hz master clock. To ensure that the data is
+ % refreshed we
+ srbpm.trigger;
+ while mt0 == srbpm.getfield(timestampfield,devicelist(1,:))
+ pause(0.1);
+ end
+ end
+end
+
+% Convert the nm units that is Hardware into meters (physics) or nm (hardware).
+if strcmpi(getunits('BPMx'),'Physics')
+ units_conversion = 1e-9; % in meters
+ unitsstr = 'm';
+else
+ units_conversion = 1; % hardware in nm
+ unitsstr = 'nm';
+end
+
+
+if strcmpi(stream,'ADC_SIGNAL') || strcmpi(stream,'TBT_TBT_WINDOW_SIGNAL')
+ etime = zeros(1,4);
+ datatime = zeros(size(devicelist,1),4);
+
+ [data.a etime(:,1) datatime(:,1)] = srbpm.getfield([stream '.ChannelA'],devicelist,'Waveform',nelem);
+ [data.b etime(:,2) datatime(:,2)] = srbpm.getfield([stream '.ChannelB'],devicelist,'Waveform',nelem);
+ [data.c etime(:,3) datatime(:,3)] = srbpm.getfield([stream '.ChannelC'],devicelist,'Waveform',nelem);
+ [data.d etime(:,4) datatime(:,4)] = srbpm.getfield([stream '.ChannelD'],devicelist,'Waveform',nelem);
+ [data.LMT etime(:,5) datatime(:,5)] = srbpm.getfield([stream '.LMT'],devicelist);
+elseif strcmpi(stream,'DDC_RAW_SIGNAL') || strcmpi(stream,'PM_DDC_RAW_SIGNAL')
+ etime = zeros(1,9);
+ datatime = zeros(size(devicelist,1),9);
+ % Try to avoid memory problems
+ [data.ia etime(:,1) datatime(:,1)] = srbpm.getfield([stream '.Ia'],devicelist,'Waveform',nelem);
+ [data.qa etime(:,2) datatime(:,2)] = srbpm.getfield([stream '.Qa'],devicelist,'Waveform',nelem);
+ [data.ib etime(:,3) datatime(:,3)] = srbpm.getfield([stream '.Ib'],devicelist,'Waveform',nelem);
+ [data.qb etime(:,4) datatime(:,4)] = srbpm.getfield([stream '.Qb'],devicelist,'Waveform',nelem);
+ [data.ic etime(:,5) datatime(:,5)] = srbpm.getfield([stream '.Ic'],devicelist,'Waveform',nelem);
+ [data.qc etime(:,6) datatime(:,6)] = srbpm.getfield([stream '.Qc'],devicelist,'Waveform',nelem);
+ [data.id etime(:,7) datatime(:,7)] = srbpm.getfield([stream '.Id'],devicelist,'Waveform',nelem);
+ [data.qd etime(:,8) datatime(:,8)] = srbpm.getfield([stream '.Qd'],devicelist,'Waveform',nelem);
+ [data.MT etime(:,9) datatime(:,9)] = srbpm.getfield([stream '.MT'],devicelist);
+else
+ etime = zeros(1,8);
+ datatime = zeros(size(devicelist,1),8);
+ % Try to avoid memory problems
+ [data.sum etime(:,1) datatime(:,1)] = srbpm.getfield([stream '.Sum'],devicelist,'Waveform',nelem);
+ [data.x etime(:,2) datatime(:,2)] = srbpm.getfield([stream '.X'],devicelist,'Waveform',nelem);
+ data.x = data.x*units_conversion;
+ [data.y etime(:,3) datatime(:,3)] = srbpm.getfield([stream '.Y'],devicelist,'Waveform',nelem);
+ data.y = data.y*units_conversion;
+ [data.VA etime(:,4) datatime(:,4)] = srbpm.getfield([stream '.Va'],devicelist,'Waveform',nelem);
+ [data.VB etime(:,5) datatime(:,5)] = srbpm.getfield([stream '.Vb'],devicelist,'Waveform',nelem);
+ [data.VC etime(:,6) datatime(:,6)] = srbpm.getfield([stream '.Vc'],devicelist,'Waveform',nelem);
+ [data.VD etime(:,7) datatime(:,7)] = srbpm.getfield([stream '.Vd'],devicelist,'Waveform',nelem);
+ [data.MT etime(:,8) datatime(:,8)] = srbpm.getfield([stream '.MT'],devicelist);
+end
+data.elapsed_time = sum(etime); % elapsed time to download the PV the wait is longer to ensure all the Liberas have triggered.
+data.mean_datatime = mean(datatime,2); % mean data time that all the PVs have been updated, as a function of the devicelist.
+data.datatime = datatime;
+
+
+% Log status of the Libera
+% if isnumeric(devicelist)
+% % To differentiate the the booster BPMs that are currently not
+% % version 2.06 and don't have some of these features.
+% data.switches = srbpm.getfield('ENV_SWITCHES_MONITOR',devicelist,'Waveform',nelem);
+% data.plloffset = srbpm.getfield('ENV_PLL_OFFSETTUNE_MONITOR',devicelist,'Waveform',nelem);
+% data.pllcomptune = srbpm.getfield('ENV_PLL_COMPTUNE_MONITOR',devicelist,'Waveform',nelem);
+% end
+
+data.DeviceList = devicelist;
+data.TimeStamp = clock;
+data.CreatedBy = mfilename;
+data.UnitsString = unitsstr;
+data.Units = getunits('BPMx');
+data.Mode = 'Online'; % By definition for now.
+
+varargout{1} = data;
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/bpm_scripts/getliberafadata.m b/machine/ASP/StorageRing/bpm_scripts/getliberafadata.m
new file mode 100644
index 00000000..fb929b5e
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/getliberafadata.m
@@ -0,0 +1,145 @@
+function varargout = getliberafadata(varargin)
+%
+% fadata = GETLIBERAFADATA(end_date,[keyword_pairs])
+%
+% END_DATE = end of the data acquisition
+%
+% The default without any other parameters is to return 10,000 samples of
+% 10kHz data up undil the END_DATE
+%
+% NOTE: the date format can be the Matlab numeric format (i.e. output of
+% the function 'datenum')
+%
+% KEYWORD_PAIRS:
+%
+% 'decimation' = 'F' -> 10 kHz
+% 'd' -> 10058/64 decimated
+% 'D' -> 10058/16384 decimated
+% 'start' = start date 'dd/mm/yyyy HH:MM:SS' format
+%
+% E.g.
+%
+% fadata = getliberafadata('4/2/2013 09:00:00');
+% fadata = getliberafadata(now);
+% getliberafadata('4/2/2013 09:00:00')
+%
+% 4/2/2013 Eugene. Beta release.
+%
+%
+% if length of first parameter is equal to 1 and is numeric
+% retreive data using the first parameter as offset in seconds till now
+% else if length of first parameter is equal to 1 and is a character array
+% retrieve data using the frist parameter as a date till now
+% else if length of first parameter is equal to 2 and is numeric
+% retrieve data using the two numbers as datenum in Matlab formatl.
+% else if length of first parameter is equal to 2 and is a character array
+% retrive data using the two character strings as date in Matlab format
+% else
+% don't know what you want
+% end
+
+[reg, prop] = parseparams(varargin);
+sec2day = inline('x/(24*60*60)');
+
+if nargin > 0
+ if isempty(reg)
+ reg{1} = prop{1};
+ prop = {prop{2:end}};
+ end
+
+ if ischar(reg{1})
+ enddate = datenum(reg{1},'dd/mm/yyyy HH:MM:SS');
+ else
+ enddate = reg{1};
+ end
+
+ if abs(now - enddate) < sec2day(5)
+ % If the enddate is too close to the current time period it can
+ % cause problems with the archiver, so wait 5 seconds.
+ pause(5);
+ end
+
+else
+ disp('Need an end date.');
+ return
+end
+
+% defaults
+decimation = 'F';
+startdate = [];
+for i=1:length(prop)/2
+ ind = (i-1)*2+1;
+ switch lower(prop{ind})
+ case 'decimation'
+ decimation = prop{ind+1};
+ case 'start'
+ if ischar(prop{ind+1})
+ startdate = datenum(prop{ind+1},'dd/mm/yyyy HH:MM:SS');
+ else
+ startdate = prop{ind+1};
+ end
+ end
+end
+
+% dt = time period per sample
+switch decimation
+ case 'F'
+ dt = 1/10058;
+ case 'd'
+ dt = 64/10058;
+ case 'D'
+ dt = 64/10058;
+end
+
+if isempty(startdate)
+ % Default 10000 samples grab a bit more so we don't accidentally have
+ % less than 10000.
+ startdate = datenum(enddate) - sec2day(10100*dt);
+
+ defaultsused = 1;
+else
+ defaultsused = 0;
+end
+
+temp = fa_load([startdate enddate],[1:98],decimation,'10.17.100.25');
+% temp = fa_load([startdate enddate],[18],decimation,'10.17.100.25');
+
+if strcmpi(decimation,'F')
+ if defaultsused
+ % Just return everything so dont' truncate to 10000 Eugene
+ % 24/10/2016
+% temp.data = temp.data(:,:,1:10000);
+% temp.t = temp.t(1:10000);
+ end
+ temp.x = squeeze(temp.data(1,:,:));
+ temp.y = squeeze(temp.data(2,:,:));
+ temp = rmfield(temp,'data');
+ temp.DeviceList = elem2dev('BPMx',temp.ids);
+ temp.timestamp = datestr(temp.timestamp);
+else
+ if defaultsused
+ % Just return everything so dont' truncate to 10000 Eugene
+ % 24/10/2016
+% temp.data = temp.data(:,:,:,1:10000);
+% temp.t = temp.t(1:10000);
+ end
+
+ n = size(temp.data,3);
+
+ temp.x = squeeze(temp.data(1,1,:,:));
+ temp.xmin = squeeze(temp.data(1,2,:,:));
+ temp.xmax = squeeze(temp.data(1,3,:,:));
+ temp.xstd = squeeze(temp.data(1,4,:,:));
+
+ temp.y = squeeze(temp.data(2,1,:,:));
+ temp.ymin = squeeze(temp.data(2,2,:,:));
+ temp.ymax = squeeze(temp.data(2,3,:,:));
+ temp.ystd = squeeze(temp.data(2,4,:,:));
+
+ temp = rmfield(temp,'data');
+ temp.DeviceList = elem2dev('BPMx',temp.ids);
+ temp.timestamp = datestr(temp.timestamp);
+end
+varargout{1} = orderfields(temp);
+
+
diff --git a/machine/ASP/StorageRing/bpm_scripts/mytestf.m b/machine/ASP/StorageRing/bpm_scripts/mytestf.m
new file mode 100644
index 00000000..bc609cdd
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/mytestf.m
@@ -0,0 +1,4 @@
+function mytestf(field)
+
+fprintf('something: %s\n',field);
+
diff --git a/machine/ASP/StorageRing/bpm_scripts/new_EPICS_conversion/srbpm_v2.m b/machine/ASP/StorageRing/bpm_scripts/new_EPICS_conversion/srbpm_v2.m
new file mode 100644
index 00000000..5e683d1d
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/new_EPICS_conversion/srbpm_v2.m
@@ -0,0 +1,760 @@
+classdef srbpm_v2
+ properties (Access=private)
+ fullDeviceList
+ bpmpvnames
+ iocpvnames
+ end
+
+ methods (Static)
+ %% Version and Help functions
+
+ function version(varargin)
+ fprintf("srbpm\n");
+ fprintf("Version 2.1\n");
+ fprintf("Updated to use the new PV's with the updated EPICS base\n\n");
+ end
+
+ function help(varargin)
+ fprintf("Help Menu\n");
+ fprintf("(WIP)\n\n");
+ end
+
+ %% Get Methods
+
+ function varargout = getfield(field,varargin)
+ % Wrap the internal function as a method
+ varargout = getfield(field,varargin{:});
+ end
+
+ function status = getagc(varargin)
+ % agcstate = getagc([DeviceList]);
+ %
+ % Returns the state of the AGC
+ status = local_getPV('BPMx','AGC_ENABLED_STATUS',varargin{1:end});
+ if isnan(status)
+ fprintf("Failed to get AGC status\n");
+ return;
+ end
+ end
+
+ function maxadc = getmaxadc(varargin)
+ % maxadc = getmaxadc([DeviceList]);
+ %
+ % Returns the MAXADC values
+ maxadc = local_getPV('BPMx','MAXADC_MONITOR',varargin{1:end});
+ if isnan(maxadc)
+ fprintf("Failed to get max adc values\n");
+ return;
+ end
+ end
+
+ function status = getsyncstate(varargin)
+ % Return the synchronisation state of all the BPMs
+ % 0:NoSync, 1:tracking, 2:synchronised
+ status = local_getPV('BPMx','SYNC_ST_M_STATUS',varargin{:});
+ if isnan(status)
+ fprintf("Failed to get synchronisation state\n");
+ return;
+ end
+ end
+
+ function eventcode = gettriggerevent(varargin)
+ % eventcode = gettriggerevent
+ %
+ % Get the current T2 (general trigger) event codes
+ eventcode = getfield('EVRX_RTC_T2_IN_FUNCTION_MONITOR', varargin{1:end});
+ end
+
+ function eventcode = getpmevent(varargin)
+ % eventcode = getpmevent
+ %
+ % Get the current T1 (post mortem trigger) event codes
+ eventcode = getfield('EVRX_RTC_T1_IN_FUNCTION_MONITOR', varargin{1:end});
+ end
+
+ function status = getmclock(varargin)
+ % mclockstate = getmclock([DeviceList]);
+ %
+ % Returns the state of the MC lock (EVRX_PLL_LOCKED)
+ status = getfield('EVRX_PLL_LOCKED_STATUS', varargin{1:end});
+ end
+
+
+ %% Set Methods
+
+ function status = setfield(field,value,varargin)
+ % Wrap the internal function as a method
+ status = setfield(field,value,varargin{:});
+ end
+
+ function setagc(varargin)
+ % getagc(['on'/1,'off'/0],[DeviceList])
+ %
+ % Set the state of the Auto Gain Control (AGC)
+ if nargin > 0
+ switch varargin{1}
+ case {'on', 1}
+ local_setPV('BPMx','AGC_ENABLED',1,varargin{2:end});
+ case {'off', 0}
+ local_setPV('BPMx','AGC_ENABLED',0,varargin{2:end});
+ end
+ end
+ end
+
+ function setswitches(varargin)
+ % setswitches(['on'/1,'off/0],[DeviceList])col
+ %
+ % Set the state of the crossbar switches on the Brilliance+
+ % units in conjunction with the digital signal conditioning.
+ if nargin > 0
+ if ischar(varargin{1}); varargin{1} = lower(varargin{1}); end
+ if getpv('SR00OFB01:MODE_STATUS') == 2
+ warning('Changing switching status while orbit feedback is RUNNING is not recommended.');
+ end
+ switch varargin{1}
+ case {'on', 1}
+ local_setPV('BPMx','SWITCHING_ENABLE',1,varargin{2:end});
+ local_setPV('BPMx','DSC_COEFF_ADJUST',1,varargin{2:end});
+ local_setPV('BPMx','DSC_COEFF_TYPE',1,varargin{2:end});
+ case {'off', 0}
+ local_setPV('BPMx','SWITCHING_ENABLE',0,varargin{2:end});
+ local_setPV('BPMx','DSC_COEFF_ADJUST',0,varargin{2:end});
+ local_setPV('BPMx','DSC_COEFF_TYPE',1,varargin{2:end});
+ end
+ end
+ end
+
+ function settriggerevent(eventcode, varargin)
+ % settriggerevent(eventcode, [DeviceList])
+ % Set the current T2 (general trigger) event codes
+ %
+ % 0 = nullevent
+ % 1 = master
+ % 2 = injection
+ % 3 = gun
+ % 4 = extraction without gun
+ % 5 = extraction with gun
+ % 6 = User Event_ bunch by bunch
+ % 7 = User Event_ SR BPM
+ % 8 = User Event_ General purpose (default)
+ % 9 = User Event_ topup warning
+ % 10 = User Event_ beam dump
+ % 11 = User Event_ FFM timing reset
+ % 16 = User Event_ SR Injection
+ % 20 = SROC/N1
+ % 21 = SROC/N2
+ % 22 = SROC/N3
+ %
+ % you can set multiple events to trigger on. Example:
+ %
+ % >> srbpm.settriggerevent([7 8])
+ % >> srbpm.settriggerevent([7 5])
+ if nargin > 1 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+ else
+ deviceList = getlist('BPMx');
+ end
+ eventmaskarr = [repmat(hex2dec('00ff'),length(deviceList),length(eventcode)), repmat(65535,length(deviceList),16-length(eventcode))];
+ eventcodearr = [repmat(eventcode ,length(deviceList),1), repmat(65535,length(deviceList),16-length(eventcode))];
+
+ setfield('EVRX_RTC_T2_IN_FUNCTION', eventcodearr);
+ setfield('EVRX_RTC_T2_IN_MASK', eventmaskarr);
+ end
+
+ function setpmevent(eventcode, varargin)
+ % setpmevent(eventcode, [DeviceList])
+ % Set the current T1 (Post Mortem trigger) see SETTRIGGEREVENTS
+ % for the event codes. You can set multiple events to trigger
+ % on. Example:
+ %
+ % >> srbpm.setpmevent([10 7])
+ % >> srbpm.setpmevent([10])
+ if nargin > 1 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+ else
+ deviceList = getlist('BPMx');
+ end
+ eventmaskarr = [repmat(hex2dec('00ff'),length(deviceList),length(eventcode)), repmat(65535,length(deviceList),16-length(eventcode))];
+ eventcodearr = [repmat(eventcode ,length(deviceList),1), repmat(65535,length(deviceList),16-length(eventcode))];
+
+ setfield('EVRX_RTC_T1_IN_FUNCTION', eventcodearr);
+ setfield('EVRX_RTC_T1_IN_MASK', eventmaskarr);
+ end
+
+ function setevrxmode(mode,varargin)
+ % setevrxmode(mode,[DeviceList])
+ % Set EVRx mode for MC, T1 and T2 to 'RTC' or 'External'.
+ switch mode
+ case 'RTC'
+ setfield('EVRX_TRIGGERS_MC_SOURCE' , 5, varargin{:});
+ setfield('EVRX_TRIGGERS_T0_SOURCE' , 0, varargin{:});
+ setfield('EVRX_TRIGGERS_T1_SOURCE' , 5, varargin{:});
+ setfield('EVRX_TRIGGERS_T2_SOURCE' , 5, varargin{:});
+ case 'External'
+ setfield('EVRX_TRIGGERS_MC_SOURCE' , 1, varargin{:});
+ setfield('EVRX_TRIGGERS_T0_SOURCE' , 0, varargin{:});
+ setfield('EVRX_TRIGGERS_T1_SOURCE' , 1, varargin{:});
+ setfield('EVRX_TRIGGERS_T2_SOURCE' , 1, varargin{:});
+ otherwise
+ disp('Nothing done');
+ end
+ end
+
+
+ %% File I/O
+
+ function [xoff, yoff] = getarchivedoffsets(varargin)
+ % [xoff yoff] = getarchivedoffsets([number],['quiet'])
+ %
+ % will search and extract the offsets from:
+ % ../bpm_scripts/archivedoffsets/archivedoffsets_[num]_[date].mat
+ % Default without a number will return the last set of offsets.
+ % The option of 'quiet' will stop all printout.
+ %
+
+ archivedir = fileparts(mfilename('fullpath'));
+ archivedir = [archivedir filesep 'archivedoffsets'];
+
+ files = dir([archivedir filesep 'archivedoffsets_*.mat']);
+
+ if nargin > 0 && isnumeric(varargin{1})
+ % user specified a specific offset to retrieve
+ filename = files(varargin{1}).name;
+ else
+ % assume that you want the last one if you don't have any
+ % input
+ filename = files(end).name;
+ end
+
+ load(fullfile(archivedir,filename));
+ if ~any(strcmpi(varargin,'quiet'))
+ fprintf('Loading: %s\n',filename);
+ fprintf(' Datestr: %s\n',offsetdata.datatime);
+ fprintf(' Comments: %s\n',offsetdata.comment);
+ end
+
+ % The archived offsets are in meters
+ if strcmpi(getunits('BPMx'),'hardware')
+ scale = 1e9;
+ else
+ scale = 1;
+ end
+
+ if nargout > 0
+ xoff = offsetdata.xoffsets*scale;
+ end
+ if nargout > 1
+ yoff = offsetdata.yoffsets*scale;
+ end
+ end
+
+ function setarchivedoffsets(xoff,xdev,yoff,ydev)
+ % setarchivedoffsets(xoff,xdev,yoff,ydev)
+ %
+ % save the offsets into the archive.
+ archivedir = fileparts(mfilename('fullpath'));
+ archivedir = [archivedir filesep 'archivedoffsets'];
+ files = dir([archivedir filesep 'archivedoffsets_*.mat']);
+ i = sscanf(files(end).name,'archivedoffsets_%d_%*s.mat');
+
+ % Grab previous list
+ [xoff0, yoff0] = srbpm.getarchivedoffsets('quiet');
+ % Updated with new
+ ind = dev2elem('BPMx',xdev);
+ xoff0(ind) = xoff;
+ ind = dev2elem('BPMx',ydev);
+ yoff0(ind) = yoff;
+
+ % Prompt user to input data
+ prompt = {'Date','Comments'};
+ dlg_title = 'Archive Offsets to file';
+ t = now;
+ def = {datestr(t) ''};
+ answer = inputdlg(prompt, dlg_title,1,def);
+ if isempty(answer)
+ disp('No offsets saved');
+ return
+ end
+
+ offsetdata.xoffsets = xoff0;
+ offsetdata.yoffsets = yoff0;
+ offsetdata.comment = answer{2};
+ offsetdata.datatime = answer{1};
+
+ % Increment the index of the archived datafiles and resave
+ prefix = sprintf('archivedoffsets_%04d',i+1);
+ fname = appendtimestamp(prefix,datevec(t));
+ save(fullfile(archivedir,fname),'offsetdata');
+
+ end
+
+ %% Utilities
+
+ function trigger(varargin)
+ % trigger([triggertype])
+ %
+ % Gets the event generator to transmit a SR BPM event, where
+ % triggertype=0/'stop'
+ % triggertype=1/'single' (default)
+ % triggertype=2/'continuous'/'cont'
+ %
+ if nargin == 0
+ varargin{1} = 1;
+ end
+ switch varargin{1}
+ case {0,'stop'}
+ % set the BPM trigger event on the EVG for a single event.
+ setpv('TS01EVG01:EVENT_02_MODE_CMD',0); % stop
+ case {1,'single'}
+ % set the BPM trigger event on the EVG for a single event.
+ setpv('TS01EVG01:EVENT_02_MODE_CMD',3); % single shot
+ case {2,'continuous','cont'}
+ % set the BPM trigger event on the EVG for a continuous event.
+ setpv('TS01EVG01:EVENT_02_MODE_CMD',1); % continuous shot
+ end
+ end
+
+ function synchronise(varargin)
+ % Synchronise *ALL ACTIVE* Libera Brillinace+ units. Assumes
+ % that Trigger event code is 7 (SR BPM Event).
+
+ % Disable Sync Event
+ % Stop SR BPM trigger: 0=Disabled, 1:Continuous, 2:Active/Single, 3:Armed
+ setpv('TS01EVG01:EVENT_02_MODE_CMD',0);
+ pause(1);
+ % Arm the Liberas to Synchronise
+ % Wait before sending the trigger
+ setfield('SYNC_CMD.PROC',1,varargin{:});
+
+ fprintf('Waiting to get into tracking mode: ');
+ while any( getfield('SYNC_ST_M_STATUS') ~= 1 )
+ fprintf('.');
+ pause(0.5);
+ end
+ fprintf('\n');
+ pause(0.5);
+
+
+ % Send Single Trigger to Synchronise
+ % Wait for system to synchronise
+ setpv('TS01EVG01:EVENT_02_MODE_CMD',3);
+ end
+
+ function varargout = collectpmdata(varargin)
+ % this script will collect the PM data, collect the interlock statuses,
+ % reset the interlock statuse on the liberas and reset the PM triggering
+ % system.
+ %
+ % All data will be archived to /asp/usr/data/bpmpmdata/
+
+ datenow = datevec(now);
+ if isunix
+ dirname = sprintf('/asp/usr/data/bpmpmdata/');
+ elseif ispc
+ dirname = sprintf('u:\\data\\bpmpmdata\\');
+ end
+ if exist(dirname,'dir') ~= 7
+ mkdir(dirname);
+ end
+
+ fprintf('Collecting PM data...');
+ pm = getliberadata('PM_DDC_SYNTH');
+ fprintf(' done\n');
+
+ fprintf('Collecting Interlock Status... ');
+ pm.ilkxstatus = getfield('ILK_STATUS_X');
+ pm.ilkystatus = getfield('ILK_STATUS_Y');
+ fprintf(' done\n');
+
+ fprintf('Acknowledging interlock status and resetting PM on the Libera...');
+ setfield('ILK_STATUS_RESET',0);
+ setfield('PM_CAPTURE',1);
+ fprintf(' done\n');
+
+ fprintf('Reseting the PM triggering system...');
+ setpv('TS01EVR11:TTL03_ENABLE_CMD',1);
+ pause(1);
+ setpv('TS01EVR11:TTL03_ENABLE_CMD',0);
+ fprintf(' done\n');
+
+ fname = appendtimestamp([dirname 'pmdata']);
+ fprintf('Saving to file: %s.mat\n',fname);
+ save(fname,'pm')
+ if nargout > 0
+ varargout{1} = pm;
+ end
+ end
+
+ function setdefaultconfig(varargin)
+ % setdefaultconfig([DeviceList])
+ %
+ % This function sets the default configuration for the Liberas Brillinace+
+ % in the storage ring. Optional parameters:
+ %
+ % DeviceList A vector of nx2 specifying which devices to configure
+ %
+ % If no parameters are set, the configuration will be applied to all the
+ % liberas that are enabled in middleLayer ("aspinit").
+ %
+ % e.g. >> setliberabconfig
+ % >> setliberabconfig([1 2; 1 3; 1 4; 1 5;])
+
+ if nargin > 0 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+ else
+ deviceList = getlist('BPMx');
+ end
+ el = dev2elem('BPMx',deviceList);
+
+
+ % =======================================================================
+ % EVRX related PVs
+% fprintf('Setting TIMING to RTC\n');
+% % Make sure the decoder is turned on
+% setfield('EVRX_RTC_DECODER_SWITCH' , 1, varargin{:});
+% % MC to trigger on SROC with a hex value of 0x0200
+% setfield('EVRX_RTC_MC_IN_MASK' , hex2dec('0200'), varargin{:});
+% setfield('EVRX_RTC_MC_IN_FUNCTION' , hex2dec('0200'), varargin{:});
+%
+% % Post mortem event is locked in as event code 10 (Beam Dump
+% % Event)
+% setfield('EVRX_RTC_T1_IN_MASK' , hex2dec('00ff'), varargin{:});
+% setfield('EVRX_RTC_T1_IN_FUNCTION' , 10 , varargin{:});
+%
+% % Trigger event is defaulted to event code 7 (SR BPM Event)
+% setfield('EVRX_RTC_T2_IN_MASK' , hex2dec('00ff'), varargin{:});
+% setfield('EVRX_RTC_T2_IN_FUNCTION' , 7 , varargin{:});
+%
+% % PLL offset tuning
+% fprintf('Setting PLL offset tune to 0 units (0 kHz) and no compensation: \n');
+% setfield('EVRX_PLL_VCXO_OFFSET' ,0,varargin{:});
+% setfield('EVRX_PLL_COMPENSATE_OFFSET' ,0,varargin{:});
+
+ % =======================================================================
+
+
+ % AGC
+ fprintf('Settting AGC to 1 (ENABLED)\n');
+ if (local_setPV('BPMx','AGC_ENABLED',1,varargin{:}) == 0)
+ fprintf("Failed to set PV");
+ return;
+ end
+
+ % Switches
+ fprintf('Setting SWITCHES to 1 (ENABLED)\n');
+ local_setPV('BPMx','SWITCHING_ENABLE',1,varargin{:});
+ local_setPV('BPMx','SWITCHING_SOURCE',1,varargin{:});
+ local_setPV('BPMx','SWITCHING_DELAY',0,varargin{:});
+
+ % Digital signal conditioning
+ fprintf('Turning _ON_ DSC\n');
+ local_setPV('BPMx','DSC_COEFF_ADJUST',1,varargin{:});
+ local_setPV('BPMx','DSC_COEFF_TYPE',2,varargin{:}); %0-PHASE, 1-AMPLITUDE, 2-ADJUST
+ local_setPV('BPMx','DSC_COEFF_ATT_DEPENDENT',0,varargin{:});
+
+ % Gain
+ fprintf('Setting GAINS \n');
+ local_setPV('BPMx','KX',14.8e6,varargin{:});
+ local_setPV('BPMx','KY',15.1e6,varargin{:});
+ local_setPV('BPMx','KS',67108864,varargin{:});
+
+ % Libera Offsets
+ [libera_offset_x, libera_offset_y] = srbpm.getarchivedoffsets('last');
+ fprintf('Setting Libera Offsets \n');
+ local_setPV('BPMx','OFF_X',libera_offset_x(el),varargin{:});
+ local_setPV('BPMx','OFF_Y',libera_offset_y(el),varargin{:});
+
+ % Interlock
+ fprintf('Setting INTERLOCKS \n');
+ gain_threshold = [...
+ -23 -22 -23 -21 -21 -23 -23, ... %
+ -23 -22 -29 -27 -28 -27 -27, ... %
+ -29 -29 -31 -30 -31 -31 -31, ... %
+ -25 -26 -26 -26 -26 -22 -22, ... %
+ -23 -24 -25 -24 -23 -22 -21, ... %
+ -30 -30 -32 -31 -31 -27 -26, ... %
+ -33 -33 -34 -34 -33 -29 -29, ... %
+ -28 -28 -29 -29 -28 -26 -24, ... %
+ -26 -25 -27 -26 -27 -26 -23, ... %
+ -26 -28 -29 -29 -29 -26 -26, ... %
+ -26 -26 -27 -27 -27 -28 -26, ... %
+ -28 -28 -29 -30 -30 -30 -30, ... %
+ -24 -25 -25 -23 -23 -22 -23, ... %
+ -24 -23 -24 -25 -25 -26 -25, ... %
+ ] + 3 ; gain_threshold(gain_threshold<-32) = -32;
+ local_setPV('BPMx','ILK_LIMITS_MIN_X',-1e6,deviceList);
+ local_setPV('BPMx','ILK_LIMITS_MIN_Y',-1e6,deviceList);
+ local_setPV('BPMx','ILK_LIMITS_MAX_X',+1e6,deviceList);
+ local_setPV('BPMx','ILK_LIMITS_MAX_Y',+1e6,deviceList);
+ local_setPV('BPMx','ILK_GAIN_DEPENDENT_THRESHOLD',gain_threshold(el)',deviceList);
+ local_setPV('BPMx','ILK_ENABLED',0,deviceList);
+ local_setPV('BPMx','ILK_GAIN_DEPENDENT_ENABLED',0,deviceList);
+ ii = [find(deviceList(:,2) == 1 | deviceList(:,2) == 7); findrowindex([2 2; 2 3],getlist('BPMx'))];
+ local_setPV('BPMx','ILK_ENABLED',1,deviceList(ii,:));
+ local_setPV('BPMx','ILK_GAIN_DEPENDENT_ENABLED',1,deviceList(ii,:));
+ local_setPV('BPMx','ILK_STATUS_RESET',0,deviceList);
+
+% delay=[
+% 22 94 180 282 350 506 483 538 475 416 349 297 198 129
+% 21 92 184 284 354 504 487 538 475 414 350 298 200 125
+% 20 109 188 286 354 513 490 540 477 419 355 297 200 132
+% 19 110 184 289 356 512 487 543 478 419 352 301 198 132
+% 0 86 164 264 330 441 464 520 454 396 331 278 173 109
+% 0 83 166 254 325 433 457 510 452 392 336 277 172 109
+% 3 87 166 259 326 430 455 512 450 395 335 277 173 113];
+ delay=[
+ 29 102 188 288 356 514 491 545 479 421 354 299 204 134
+ 25 101 189 290 358 517 492 545 479 421 355 300 206 133
+ 27 115 193 294 361 518 495 549 484 424 358 302 203 138
+ 26 113 192 292 360 520 495 550 482 423 358 303 204 137
+ 4 89 169 271 337 447 471 527 459 401 334 282 181 113
+ 7 89 172 261 333 436 464 519 457 396 337 284 180 116
+ 7 90 171 263 333 438 465 521 455 395 339 284 178 117];
+ local_setPV('BPMx','TRIG_DELAY',delay(el),deviceList); % Send default
+ % SR02BPM01:TBT_TBT_WINDOW.ChannelA --> set offset so that data 1 to 86 is
+ % used for turn 1, 87 to 172 for turn 2, etc.
+ local_setPV('BPMx','TBT_PHASE_OFFSET',10,varargin{:});
+
+
+ % Setting whether to use DDC (0) or TDP (1) tbt data for decimated data
+ local_setPV('BPMx','TBT_DATA_TYPE',0,varargin{:});
+
+ % After setting the mask it this result can be seen on the TBT_TBT_WINDOW
+ % !!!!!!! Below does not work yet !!!!!!!!!!!!!!!!
+ % setpv('BPMx','TBT_ADC_MASK',ones(98,86)); % zero or one to mask the ADC samples to use to calculate TBT data
+ % setpv('BPMx','TBT_ADC_MASK',repmat([zeros(43,1); ones(43,1)],1,98)');
+
+ % Post mortem
+ %info PM signal arrives ~78.5 SROC after event (6752 ADC Clocks)
+ fprintf('Setting PM \n');
+ local_setPV('BPMx','PM_CAPTURE',1,varargin{:}); %Enable PM Capture
+ local_setPV('BPMx','PM_SOURCE_SELECT',0,varargin{:}); %Select external Trigger
+ local_setPV('BPMx','PM_OFFSET',-15000,varargin{:});
+
+ % Disable Spike removal for now ET 5/9/2017
+ fprintf('Setting spike removal DISABLE\n');
+ local_setPV('BPMx','TBT_SR_TBT_ENABLE',0,varargin{:});
+ local_setPV('BPMx','TBT_SR_FA_ENABLE',0,varargin{:});
+
+ % Set the libera IDs (careful as this will affect the FOFB)
+ fprintf('Setting data BPM unique IDs\n');
+ ids = dev2elem('BPMx',varargin{:});
+ local_setPV('BPMx','ID',ids,varargin{:});
+
+ fprintf('Setting data on demand PVs\n');
+ % ACQM: now (1), Event (2), Stream (3) only for FA and SA
+ % SCAN: passive (0), Event (1-unused), i/O interupt (2), periodic (3-9)
+ % If SCAN==0 then sequence is .PROC --> [trigger] --> caget
+ local_setPV('BPMx','ADC.ACQM',2,varargin{:});
+ local_setPV('BPMx','ADC.SCAN',2,varargin{:});
+
+ local_setPV('BPMx','TBT_TBT_WINDOW.ACQM',1,varargin{:});
+ local_setPV('BPMx','TBT_TBT_WINDOW.SCAN',0,varargin{:});
+ local_setPV('BPMx','TBT_TBT_WINDOW.PROC',0,varargin{:});
+
+ local_setPV('BPMx','DDC_RAW.ACQM',2,varargin{:});
+ local_setPV('BPMx','DDC_RAW.SCAN',0,varargin{:});
+ local_setPV('BPMx','DDC_RAW.OFFS',23298,varargin{:}); % Offset relative to extraction trigger
+
+ local_setPV('BPMx','DDC_SYNTH.ACQM',2,varargin{:});
+ local_setPV('BPMx','DDC_SYNTH.SCAN',0,varargin{:});
+ local_setPV('BPMx','DDC_SYNTH.OFFS',23298,varargin{:}); % Offset relative to extraction trigger
+
+ local_setPV('BPMx','TDP_SYNTH.ACQM',2,varargin{:});
+ local_setPV('BPMx','TDP_SYNTH.SCAN',2,varargin{:});
+ local_setPV('BPMx','TDP_SYNTH.OFFS',23298,varargin{:}); % Offset relative to extraction trigger
+
+ local_setPV('BPMx','PM_DDC_SYNTH.ACQM',2,varargin{:});
+ local_setPV('BPMx','PM_DDC_SYNTH.SCAN',2,varargin{:});
+ local_setPV('BPMx','PM_DDC_SYNTH.PROC',0,varargin{:});
+
+
+ fprintf('Resetting MC PLL status monitor\n');
+ srbpm.reset_pll_status;
+
+ end
+
+ %% Misc Functions
+
+ function plotadcsynchronisation(varargin)
+ % plotadcsynchronisation
+ %
+ % function to plot the adc channels to see if the TRIG_DELAY
+ % and TBT_PHASE_OFFSET are set correctly.
+ fprintf('Collecting ADC data... ');
+ adc = getliberadata('ADC');
+ fprintf('TBT_TBT_WINDOW data... ');
+ tbtw = getliberadata('TBT_TBT_WINDOW');
+ fprintf('done.\n');
+
+ ii = 1:200;
+
+ h = figure(301);
+ set(h,'Position',[1794 44 1147 1124]);
+ clf;
+ subplot(1,2,1);
+ surface(adc.a(:,ii) + adc.b(:,ii) + adc.c(:,ii) + adc.d(:,ii));
+ shading flat;
+ xlabel('BPM number');
+ ylabel('Time (ADC samples)');
+ title({'Sum ADC values';'Set TRIG_DELAY to align ADCs'},'Interpreter','None');
+ axis tight;
+
+ subplot(2,2,2);
+ plot(adc.a(1,ii),'.-');
+ hold on;
+ plot(tbtw.a(1,ii),'r.-','LineWidth',1.5);
+ a = axis;
+ plot([86 86],[-16000 16000],'r--','LineWidth',1.5);
+ axis(a);
+ title({'BPM 1-1';'Set TBT_PHASE_OFFSET to put';'bunch train (red) within first 86 samples'}','Interpreter','None');
+ legend('ADC','TBT TBT WINDOW');
+ grid on;
+ xlabel('Time (ADC samples)');
+ ylabel('Amplitude (Counts)');
+
+ subplot(2,2,4);
+ plot(adc.a(3,ii),'.-');
+ hold on;
+ plot(tbtw.a(3,ii),'r.-','LineWidth',1.5);
+ a = axis;
+ plot([86 86],[-16000 16000],'r--','LineWidth',1.5);
+ axis(a);
+ title('BPM 1-3');
+ grid on;
+ xlabel('Time (ADC samples)');
+ ylabel('Amplitude (Counts)');
+ end
+
+ function reset_pll_status(varargin)
+ % Function to reset the PLL latched status monitor
+ % srbpm.reset_pll_status([DeviceList])
+ %
+ setfield('EVRX_PLL_MAX_ERR_RESET_CMD',0,varargin{:});
+ setfield('EVRX_PLL_OS_UNLOCK_TIME_RESET_CMD',0,varargin{:});
+
+ end
+
+ function varargout = printraftemps(varargin)
+ % table plots and/or returns the temperatures for all the BPMs
+ % temptable = printraftemps([DeviceList])
+ if nargin > 0 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+ else
+ deviceList = getlist('BPMx');
+ end
+ for i=1:7
+ raftemps{i} = local_getPV('BPMx', sprintf('ID_%d_VALUE',i), deviceList);
+ temp = char(local_getPV('BPMx',sprintf('ID_%d_NAME',i),deviceList));
+ temp = strrep(temp,'-','_');
+ temp = strrep(temp,'.','_');
+ raftempnames{i} = ['Temp_', temp];
+ end
+ rafrownames = strrep(cellstr(family2channel('BPMx',deviceList)),':SA_X_MONITOR','');
+
+ t = table(raftemps{:},'VariableNames',raftempnames,'RowNames',rafrownames);
+ if nargout > 0
+ varargout{1} = t;
+ end
+
+ end
+
+ end
+
+ %% Other Methods
+ methods
+ function obj = srbpm
+ obj.fullDeviceList = family2dev('BPMx','',0);
+ obj.bpmpvnames = cellstr(family2channel('BPMx',obj.fullDeviceList));
+ obj.bpmpvnames = regexprep(obj.bpmpvnames,'SA_X_MONITOR','MYCOMMAND');
+ obj.iocpvnames = regexprep(obj.bpmpvnames,'BPM0[1,2,3,4]','IOC41');
+ obj.iocpvnames = regexprep(obj.iocpvnames,'BPM0[5,6,7,8]','IOC42');
+ end
+ end
+end
+
+%% Utility Functions
+
+function output = local_getPV(varargin)
+% Wrapper for getpv to try add some error handling.
+ try
+ output = getpv(varargin{:});
+ catch
+ warning('Problem using getpv. Are the BPMs online?');
+ output = nan;
+ end
+end
+
+function output = local_setPV(varargin)
+% Wrapper for setpv to try add some error handling.
+ try
+ output = setpv(varargin{:});
+ catch
+ warning('Problem using setpv. Are the BPMs online?');
+ output = nan;
+ end
+end
+
+function varargout = getfield(field,varargin)
+ % data = getfield(field,[DeviceList,...])
+ %
+ % Function to return an arbitrary field and is a wrapper for
+ % getpv('BPMx',field,[DeviceList,...])
+ if strncmpi(field,'evrx',4) || strncmpi(field,'gdx',4) || strncmpi(field,'box_status',4) || (strncmpi(field,'sync',4) && ~strncmpi(field,'sync_st_m',6))
+ % Change the original SR01BPM01 channel names to SR01IOC41
+ % temporarily then reset the channel names.
+ origpvnames = getfamilydata('BPMx','Monitor','ChannelNames');
+ newpvnames = char(regexprep( regexprep(cellstr(origpvnames),'BPM0[1,2,3,4]','IOC41'), 'BPM0[5,6,7,8]','IOC42'));
+ setfamilydata(newpvnames,'BPMx','Monitor','ChannelNames');
+
+ try
+ [data, tout, DataTime] = getpv( 'BPMx', field , varargin{:});
+ catch
+ warning('Problem using getpv. Are the BPMs online?');
+ varargout = nan;
+ return
+ end
+
+ % Put PVs back
+ setfamilydata(origpvnames,'BPMx','Monitor','ChannelNames');
+ else
+ try
+ [data, tout, DataTime] = getpv( 'BPMx', field , varargin{:});
+ catch
+ warning('Problem using getpv. Are the BPMs online?');
+ varargout = nan;
+ return
+ end
+ end
+
+ varargout{1} = data;
+ if nargout > 1
+ varargout{2} = tout;
+ end
+ if nargout > 2
+ varargout{3} = DataTime;
+ end
+end
+
+function status = setfield(field,value,varargin)
+ % data = setfield(field,value,[DeviceList,...])
+ %
+ % Function to return an arbitrary field and is a wrapper for
+ % setpv('BPMx',field,value,[DeviceList,...])
+ if strncmpi(field,'evrx',4) || strncmpi(field,'gdx',4) || strncmpi(field,'box_status',4) || (strncmpi(field,'sync',4) && ~strncmpi(field,'sync_st_m',6))
+ % Change the original SR01BPM01 channel names to SR01IOC41
+ % temporarily then reset the channel names.
+ origpvnames = getfamilydata('BPMx','Monitor','ChannelNames');
+ newpvnames = char(regexprep( regexprep(cellstr(origpvnames),'BPM0[1,2,3,4]','IOC41'), 'BPM0[5,6,7,8]','IOC42'));
+ setfamilydata(newpvnames,'BPMx','Monitor','ChannelNames');
+
+ status = local_setPV( 'BPMx', field , value, varargin{:});
+ % Put PVs back
+ setfamilydata(origpvnames,'BPMx','Monitor','ChannelNames');
+ else
+ status = local_setPV( 'BPMx', field , value, varargin{:});
+ end
+end
+
+
+
diff --git a/machine/ASP/StorageRing/bpm_scripts/srbpm.m b/machine/ASP/StorageRing/bpm_scripts/srbpm.m
new file mode 100644
index 00000000..2861a429
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/srbpm.m
@@ -0,0 +1,1536 @@
+classdef srbpm
+ % SRBPM is an object that contains functions related to the SR BPM
+ % system. Below is a summary of the current functions. See help
+ % srbpm.(method) to get more detail on how to use the function.
+ %
+ % getfield: a function to make it easier to access a particular PV on
+ % all the BPMs. Retrieves any PV where {BPM}:field
+ % setfield: a function to make it easier to set a particular PV on all
+ % the BPMs. Sets the PV where {BPM}:field
+ %
+ % setdefaultconfig: re-sets all the default configuration parameters
+ % for the SR bpms.
+ %
+ % getmaxadc: gets the maximum ADC count (across the 4 channels) from
+ % each of the BPMs
+ % getagc: get the current state of the Auto Gain Control (AGC)
+ % setagc: sets the state of the the Auto Gain Control (AGC).
+ %
+ % getswitches: gets the state of the switches which is AND of two PVs.
+ % SWITCHING_ENABLE_CMD & DSC_COEFF_ADJUST_CMD
+ % setswitches: sets the default state of the switches. This is
+ % actually a combination of parameters that has been set
+ % and defined as "on" and "off".
+ %
+ % ============== TIMING related methods ==================
+ % gettriggerevent: returns the general trigger event (T2) codes that
+ % are used by the Libera EVR.
+ % settriggerevent: sets the general trigger event (T2) codes.
+ % setevrxmode: sets the default EVR mode for MC, T1 and T2 to 'RTC' or
+ % 'External'
+ % trigger: manually sets the SR BPM event trigger on the EVG to a
+ % single trigger, continuous or stop.
+ %
+ % getsyncstate: gets the syncronisation state of the BPMs.
+ % getmclock: returns the state of the machine clock (MC) lock.
+ % reset_pll_status: function to reset the latched PLL status monitor
+ % synchronise: function to synchronise all the active libera
+ % brilliance units using the SR BPM event code (7).
+ %
+ % ============== POST MORTEM related methods ==================
+ % getpmevent: returns the Post Mortem Trigger Event (T1) codes that
+ % are used by the Libera EVR.
+ % setpmevent: sets the Post Mortem Trigger Event (T1) codes
+ % collectpmdata: script gets data from the post mortem buffer and
+ % archives it to /asp/usr/data/bpmpmdata/
+ %
+ % ============== ORBIT related methods ==================
+ % setoffset: sets the offsets on the BPMs
+ % getoffset: returns the offsets from the BPMs
+ % setarchivedoffsets: saves bpm offsets into an archive (.mat file)
+ % getarchivedoffsets: returns the arvhived bpm offsets
+ % getreferenceorbit: returns the reference orbit used by the orbit
+ % feedback system.
+ % setreferenceorbit: sets the reference orbit used by the orbit
+ % feedback system.
+ % stepreferenceorbit: step changes the reference orbit used by the
+ % orbit feedback system.
+ %
+ % ============== PLOTTING related methods ==================
+ % plotadcsynchronisation: plots the synchronisation of the internal
+ % acquistion clocks for fine tuning
+ % TBT_PHASE_OFFSET.
+ % plotadc: plots the raw ADC data from the 4 RF channels to see if
+ % there are problems with the cable or RF input.
+ % plotfillpattern: plot the fill pattern using ADC data
+ % plotbetafunctions: uses TBT data to try and extract the beta
+ % functions.
+ %
+ % printraftemps: returns and prints out a table of the internal sensor
+ % temperaturs for all the bpms.
+ %
+ %
+ % Examples:
+ % >> help srbpm.settriggerevent
+ % >> srbpm.plotadc([12, 1])
+ % >> state = srbpm.getfield('TBT_SR_TBT_ENABLE_STATUS');
+ % >> srbpm.settriggerevent([7 5])
+ %
+ %
+ % See Also: plotpmdata, getliberadata, getliberafadata
+
+ properties (Access=public)
+ sumoffset
+ ks
+ bpmgain
+ fullDeviceList
+ bpmpvnames
+ iocpvnames
+ end
+
+ methods (Static)
+ %% Version and Help functions
+
+ function version(varargin)
+ fprintf("srbpm\n");
+ fprintf("Version 2.1\n");
+ fprintf("Updated to use the new PV's with the updated EPICS base\n\n");
+ end
+
+ %% Get Methods
+ function varargout = getfield(field,varargin)
+ % [data,tout,datatime,errorflag] = getfield(field,[DeviceList,...])
+ %
+ % Function to return an arbitrary field and is a wrapper for
+ % getpv('BPMx',field,[DeviceList,...])
+ if strncmpi(field,'evrx',4) || strncmpi(field,'gdx',4) || strncmpi(field,'box_status',4) || (strncmpi(field,'sync',4) && ~strncmpi(field,'sync_st_m',6))
+ % Change the original SR01BPM01 channel names to SR01IOC41
+ % temporarily then reset the channel names.
+ origpvnames = getfamilydata('BPMx','Monitor','ChannelNames');
+ newpvnames = char(regexprep( regexprep(cellstr(origpvnames),'BPM0[1,2,3,4]','IOC41'), 'BPM0[5,6,7,8]','IOC42'));
+ setfamilydata(newpvnames,'BPMx','Monitor','ChannelNames');
+
+ try
+ [data, tout, DataTime, ErrorFlag] = getpv( 'BPMx', field , varargin{:});
+ catch
+ warning('Problem using getpv. Are the BPMs online?');
+ varargout{1} = nan;
+ varargout{2} = nan;
+ return
+ end
+
+ % Put PVs back
+ setfamilydata(origpvnames,'BPMx','Monitor','ChannelNames');
+ else
+ try
+ [data, tout, DataTime, ErrorFlag] = getpv( 'BPMx', field , varargin{:});
+ catch
+ warning('Problem using getpv. Are the BPMs online?');
+ varargout{1} = nan;
+ varargout{2} = nan;
+ return
+ end
+ end
+
+ varargout{1} = data;
+ if nargout > 1
+ varargout{2} = tout;
+ end
+ if nargout > 2
+ varargout{3} = DataTime;
+ end
+ if nargout > 3
+ varargout{4} = ErrorFlag;
+ end
+ end
+
+ function status = setfield(field,value,varargin)
+ % data = setfield(field,value,[DeviceList,...])
+ %
+ % Function to return an arbitrary field and is a wrapper for
+ % setpv('BPMx',field,value,[DeviceList,...])
+ if strncmpi(field,'evrx',4) || strncmpi(field,'gdx',4) || strncmpi(field,'box_status',4) || (strncmpi(field,'sync',4) && ~strncmpi(field,'sync_st_m',6))
+ % Change the original SR01BPM01 channel names to SR01IOC41
+ % temporarily then reset the channel names.
+ origpvnames = getfamilydata('BPMx','Monitor','ChannelNames');
+ newpvnames = char(regexprep( regexprep(cellstr(origpvnames),'BPM0[1,2,3,4]','IOC41'), 'BPM0[5,6,7,8]','IOC42'));
+ setfamilydata(newpvnames,'BPMx','Monitor','ChannelNames');
+
+ status = local_setPV( 'BPMx', field , value, varargin{:});
+ % Put PVs back
+ setfamilydata(origpvnames,'BPMx','Monitor','ChannelNames');
+ else
+ status = local_setPV( 'BPMx', field , value, varargin{:});
+ end
+ end
+
+ function status = getagc(varargin)
+ % agcstate = getagc([DeviceList]);
+ %
+ % Returns the state of the AGC
+ status = local_getPV('BPMx','AGC_ENABLED_STATUS',varargin{1:end});
+ if isnan(status)
+ fprintf("Failed to get AGC status\n");
+ return;
+ end
+ end
+
+ function maxadc = getmaxadc(varargin)
+ % maxadc = getmaxadc([DeviceList]);
+ %
+ % Returns the MAXADC values
+ maxadc = local_getPV('BPMx','MAXADC_MONITOR',varargin{1:end});
+ if isnan(maxadc)
+ fprintf("Failed to get max adc values\n");
+ return;
+ end
+ end
+
+ function status = getsyncstate(varargin)
+ % Return the synchronisation state of all the BPMs (PV:
+ % SYNC_ST_M_STATUS).
+ % 0:NoSync, 1:tracking, 2:synchronised
+ status = local_getPV('BPMx','SYNC_ST_M_STATUS',varargin{:});
+ if isnan(status)
+ fprintf("Failed to get synchronisation state\n");
+ return;
+ end
+ end
+
+ function eventcode = gettriggerevent(varargin)
+ % eventcode = gettriggerevent
+ %
+ % Get the current T2 (general trigger) event codes
+ eventcode = srbpm.getfield('EVRX_RTC_T2_IN_FUNCTION_MONITOR', varargin{1:end});
+ end
+
+ function eventcode = getpmevent(varargin)
+ % eventcode = getpmevent
+ %
+ % Get the current T1 (post mortem trigger) event codes
+ eventcode = srbpm.getfield('EVRX_RTC_T1_IN_FUNCTION_MONITOR', varargin{1:end});
+ end
+
+ function status = getmclock(varargin)
+ % mclockstate = getmclock([DeviceList]);
+ %
+ % Returns the state of the MC lock (EVRX_PLL_LOCKED)
+ status = srbpm.getfield('EVRX_PLL_LOCKED_STATUS', varargin{1:end});
+ end
+
+ function status = getswitches(varargin)
+ % switchstate = getswitches([DeviceList])
+ %
+ % Returns the state of the switches which is the state of
+ % SWITCHING_ENABLE_CMD & DSC_COEFF_ADJUST_CMD
+
+ sw = logical(local_getPV('BPMx','SWITCHING_ENABLE_CMD',varargin{1:end}));
+ dsc = logical(local_getPV('BPMx','DSC_COEFF_ADJUST_CMD',varargin{1:end}));
+
+ status = double(sw & dsc);
+ end
+
+
+ %% Set Methods
+ function setagc(varargin)
+ % getagc(['on'/1,'off'/0],[DeviceList])
+ %
+ % Set the state of the Auto Gain Control (AGC)
+ if nargin > 0
+ switch varargin{1}
+ case {'on', 1}
+ local_setPV('BPMx','AGC_ENABLED_CMD',1,varargin{2:end});
+ case {'off', 0}
+ local_setPV('BPMx','AGC_ENABLED_CMD',0,varargin{2:end});
+ end
+ end
+ end
+
+ function setswitches(varargin)
+ % setswitches(['on'/1,'off/0],[DeviceList])
+ %
+ % Set the state of the crossbar switches on the Brilliance+
+ % units in conjunction with the digital signal conditioning.
+ if nargin > 0
+ if ischar(varargin{1}); varargin{1} = lower(varargin{1}); end
+ if getpv('SR00OFB01:MODE_STATUS') == 2
+ warning('Changing switching status while orbit feedback is RUNNING is not recommended.');
+ end
+ switch varargin{1}
+ case {'on', 1}
+ local_setPV('BPMx','SWITCHING_ENABLE_CMD',1,varargin{2:end});
+ local_setPV('BPMx','DSC_COEFF_ADJUST_CMD',1,varargin{2:end});
+ local_setPV('BPMx','DSC_COEFF_TYPE_CMD',1,varargin{2:end});
+ case {'off', 0}
+ local_setPV('BPMx','SWITCHING_ENABLE_CMD',0,varargin{2:end});
+ local_setPV('BPMx','DSC_COEFF_ADJUST_CMD',0,varargin{2:end});
+ local_setPV('BPMx','DSC_COEFF_TYPE_CMD',1,varargin{2:end});
+ end
+ end
+ end
+
+ function settriggerevent(eventcode, varargin)
+ % settriggerevent(eventcode, [DeviceList])
+ % Set the current T2 (general trigger) event codes
+ %
+ % 0 = nullevent
+ % 1 = master
+ % 2 = injection
+ % 3 = gun
+ % 4 = extraction without gun
+ % 5 = extraction with gun
+ % 6 = User Event_ bunch by bunch
+ % 7 = User Event_ SR BPM
+ % 8 = User Event_ General purpose (default)
+ % 9 = User Event_ topup warning
+ % 10 = User Event_ beam dump
+ % 11 = User Event_ FFM timing reset
+ % 16 = User Event_ SR Injection
+ % 20 = SROC/N1
+ % 21 = SROC/N2
+ % 22 = SROC/N3
+ %
+ % you can set multiple events to trigger on. Example:
+ %
+ % >> srbpm.settriggerevent([7 8])
+ % >> srbpm.settriggerevent([7 5])
+ if nargin > 1 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+ else
+ deviceList = getlist('BPMx');
+ end
+ eventmaskarr = [repmat(hex2dec('00ff'),length(deviceList),length(eventcode)), repmat(65535,length(deviceList),16-length(eventcode))];
+ eventcodearr = [repmat(eventcode ,length(deviceList),1), repmat(65535,length(deviceList),16-length(eventcode))];
+
+ srbpm.setfield('EVRX_RTC_T2_IN_FUNCTION_SP', eventcodearr);
+ srbpm.setfield('EVRX_RTC_T2_IN_MASK_SP', eventmaskarr);
+ end
+
+ function setpmevent(eventcode, varargin)
+ % setpmevent(eventcode, [DeviceList])
+ % Set the current T1 (Post Mortem trigger) see SETTRIGGEREVENTS
+ % for the event codes. You can set multiple events to trigger
+ % on. Example:
+ %
+ % >> srbpm.setpmevent([10 7])
+ % >> srbpm.setpmevent([10])
+ if nargin > 1 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+ else
+ deviceList = getlist('BPMx');
+ end
+ eventmaskarr = [repmat(hex2dec('00ff'),length(deviceList),length(eventcode)), repmat(65535,length(deviceList),16-length(eventcode))];
+ eventcodearr = [repmat(eventcode ,length(deviceList),1), repmat(65535,length(deviceList),16-length(eventcode))];
+
+ srbpm.setfield('EVRX_RTC_T1_IN_FUNCTION', eventcodearr);
+ srbpm.setfield('EVRX_RTC_T1_IN_MASK', eventmaskarr);
+ end
+
+ function setevrxmode(mode,varargin)
+ % setevrxmode(mode,[DeviceList])
+ % Set EVRx mode for MC, T1 and T2 to 'RTC' or 'External'.
+ switch mode
+ case 'RTC'
+ srbpm.setfield('EVRX_TRIGGERS_MC_SOURCE' , 5, varargin{:});
+ srbpm.setfield('EVRX_TRIGGERS_T0_SOURCE' , 0, varargin{:});
+ srbpm.setfield('EVRX_TRIGGERS_T1_SOURCE' , 5, varargin{:});
+ srbpm.setfield('EVRX_TRIGGERS_T2_SOURCE' , 5, varargin{:});
+ case 'External'
+ srbpm.setfield('EVRX_TRIGGERS_MC_SOURCE' , 1, varargin{:});
+ srbpm.setfield('EVRX_TRIGGERS_T0_SOURCE' , 0, varargin{:});
+ srbpm.setfield('EVRX_TRIGGERS_T1_SOURCE' , 1, varargin{:});
+ srbpm.setfield('EVRX_TRIGGERS_T2_SOURCE' , 1, varargin{:});
+ otherwise
+ disp('Nothing done');
+ end
+ end
+
+
+ %% File I/O
+ function varargout = getoffset(varargin)
+ % [AM, tout, DataTime, ErrorFlag] = srbpm.getoffset - Returns horizontal or
+ % vertical offsets in the liberas.
+ %
+ % offset = srbpm.getoffset(Plane, [DeviceList])
+ %
+ % Plane: 'x' or 'y'
+ % DeviceList: standard MML definition
+
+ if nargin > 0 && ischar(varargin{1})
+ switch lower(varargin{1})
+ case 'x'
+ % [varargout{1} varargout{2} varargout{3} varargout{4}] = getlibera('ENV_X_OFFSET_MONITOR',varargin{2:end}); % AM, tout, DataTime
+ [varargout{1}, varargout{2}, varargout{3}, varargout{4}] = srbpm.getfield('OFF_X_SP',varargin{2:end}); % AM, tout, DataTime
+ case 'y'
+ % [varargout{1} varargout{2} varargout{3} varargout{4}] = getlibera('ENV_Y_OFFSET_MONITOR',varargin{2:end}); % AM, tout, DataTime
+ [varargout{1}, varargout{2}, varargout{3}, varargout{4}] = srbpm.getfield('OFF_Y_SP',varargin{2:end}); % AM, tout, DataTime
+ end
+ else
+ error('Error using srbpm.getoffset')
+ end
+ end
+
+ function varargout = setoffset(varargin)
+ % [AM, tout, DataTime, ErrorFlag] = srbpm.setoffset - Set horizontal or
+ % vertical offsets in the liberas.
+ %
+ % srbpm.setoffset(Plane, Vals, DeviceList)
+ %
+ % where Plane: 'x' or 'y' and DeviceList is the standard MML definition.
+ % In the second option with no parameters at all it will print a list of
+ % the archived offsets and ask the user which set to load.
+ if nargin > 1 && ischar(varargin{1}) && isnumeric(varargin{2})
+ switch lower(varargin{1})
+ case 'x'
+ status = srbpm.setfield('OFF_X_SP',varargin{2:end}); % AM, tout, DataTime
+ case 'y'
+ status = srbpm.setfield('OFF_Y_SP',varargin{2:end}); % AM, tout, DataTime
+ otherwise
+ error('Unknown plane: %s', varargin{1});
+ end
+ elseif nargin == 0
+ printarchivedoffsets;
+ id = str2num(input('Which set of offsets to load? ID number: ','s'));
+
+ if ~isempty(id) && isnumeric(id) && isfinite(id)
+ [xoff yoff] = getarchivedliberaoffsets(id);
+
+ ind = dev2elem('BPMx',getlist('BPMx'));
+ status = srbpm.setfield('OFF_X_SP',xoff(ind),getlist('BPMx'));
+ status = status | srbpm.setfield('OFF_Y_SP',yoff(ind),getlist('BPMx'));
+ else
+ disp('Nothing applied');
+ end
+
+ else
+ error('Error using srbpm.setoffset')
+ end
+
+ if nargout > 0
+ varargout{1} = status;
+ end
+ end
+
+ function [xoff, yoff] = getarchivedoffsets(varargin)
+ % [xoff yoff] = getarchivedoffsets([number],['quiet'])
+ %
+ % will search and extract the offsets from:
+ % ../bpm_scripts/archivedoffsets/archivedoffsets_[num]_[date].mat
+ % Default without a number will return the last set of offsets.
+ % The option of 'quiet' will stop all printout.
+ %
+
+ archivedir = fileparts(mfilename('fullpath'));
+ archivedir = [archivedir filesep 'archivedoffsets'];
+
+ files = dir([archivedir filesep 'archivedoffsets_*.mat']);
+
+ if nargin > 0 && isnumeric(varargin{1})
+ % user specified a specific offset to retrieve
+ filename = files(varargin{1}).name;
+ else
+ % assume that you want the last one if you don't have any
+ % input
+ filename = files(end).name;
+ end
+
+ load(fullfile(archivedir,filename));
+ if ~any(strcmpi(varargin,'quiet'))
+ fprintf('Loading: %s\n',filename);
+ fprintf(' Datestr: %s\n',offsetdata.datatime);
+ fprintf(' Comments: %s\n',offsetdata.comment);
+ end
+
+ % The archived offsets are in meters
+ if strcmpi(getunits('BPMx'),'hardware')
+ scale = 1e9;
+ else
+ scale = 1;
+ end
+
+ if nargout > 0
+ xoff = offsetdata.xoffsets*scale;
+ end
+ if nargout > 1
+ yoff = offsetdata.yoffsets*scale;
+ end
+ end
+
+ function setarchivedoffsets(xoff,xdev,yoff,ydev)
+ % setarchivedoffsets(xoff,xdev,yoff,ydev)
+ %
+ % save the offsets into the archive.
+ %
+ % !!!!!!!!!! NOTE !!!!!!!
+ % offsets are ALWAYs archived in units of METERS.
+ % For the future I should just save the units of the values
+ % so as to avoid confusion. This came about when changing
+ % between units in MML where HW is in units of nm while
+ % Physics units are meters.
+
+ archivedir = fileparts(mfilename('fullpath'));
+ archivedir = [archivedir filesep 'archivedoffsets'];
+ files = dir([archivedir filesep 'archivedoffsets_*.mat']);
+ i = sscanf(files(end).name,'archivedoffsets_%d_%*s.mat');
+
+ % Grab previous list
+ [xoff0, yoff0] = srbpm.getarchivedoffsets('quiet');
+ % Updated with new
+ ind = dev2elem('BPMx',xdev);
+ xoff0(ind) = xoff;
+ ind = dev2elem('BPMx',ydev);
+ yoff0(ind) = yoff;
+
+ % Prompt user to input data
+ prompt = {'Date','Comments'};
+ dlg_title = 'Archive Offsets to file';
+ t = now;
+ def = {datestr(t) ''};
+ answer = inputdlg(prompt, dlg_title,1,def);
+ if isempty(answer)
+ disp('No offsets saved');
+ return
+ end
+
+ offsetdata.xoffsets = xoff0;
+ offsetdata.yoffsets = yoff0;
+ offsetdata.comment = answer{2};
+ offsetdata.datatime = answer{1};
+
+ % Increment the index of the archived datafiles and resave
+ prefix = sprintf('archivedoffsets_%04d',i+1);
+ fname = appendtimestamp(prefix,datevec(t));
+ save(fullfile(archivedir,fname),'offsetdata');
+
+ end
+
+ %% Utilities
+
+ function trigger(varargin)
+ % trigger([triggertype])
+ %
+ % Gets the event generator to transmit a SR BPM event, where
+ % triggertype=0/'stop'
+ % triggertype=1/'single' (default)
+ % triggertype=2/'continuous'/'cont'
+ %
+ if nargin == 0
+ varargin{1} = 1;
+ end
+ switch varargin{1}
+ case {0,'stop'}
+ % set the BPM trigger event on the EVG for a single event.
+ setpv('TS01EVG01:EVENT_02_MODE_CMD',0); % stop
+ case {1,'single'}
+ % set the BPM trigger event on the EVG for a single event.
+ setpv('TS01EVG01:EVENT_02_MODE_CMD',3); % single shot
+ case {2,'continuous','cont'}
+ % set the BPM trigger event on the EVG for a continuous event.
+ setpv('TS01EVG01:EVENT_02_MODE_CMD',1); % continuous shot
+ end
+ end
+
+ function synchronise(varargin)
+ % Synchronise *ALL ACTIVE* Libera Brillinace+ units. Assumes
+ % that Trigger event code is 7 (SR BPM Event).
+
+ % Disable Sync Event
+ % Stop SR BPM trigger: 0=Disabled, 1:Continuous, 2:Active/Single, 3:Armed
+ setpv('TS01EVG01:EVENT_02_MODE_CMD',0);
+ pause(1);
+ % Arm the Liberas to Synchronise
+ % Wait before sending the trigger
+ srbpm.setfield('SYNC_CMD.PROC',1,varargin{:});
+
+ fprintf('Waiting to get into tracking mode: ');
+ while any( srbpm.getfield('SYNC_ST_M_STATUS') ~= 1 )
+ fprintf('.');
+ pause(0.5);
+ end
+ fprintf('\n');
+ pause(0.5);
+
+
+ % Send Single Trigger to Synchronise
+ % Wait for system to synchronise
+ setpv('TS01EVG01:EVENT_02_MODE_CMD',3);
+ end
+
+ function varargout = collectpmdata(varargin)
+ % this script will collect the PM data, collect the interlock statuses,
+ % reset the interlock statuse on the liberas and reset the PM triggering
+ % system.
+ %
+ % All data will be archived to /asp/usr/data/bpmpmdata/
+
+ datenow = datevec(now);
+ if isunix
+ dirname = sprintf('/asp/usr/data/bpmpmdata/');
+ elseif ispc
+ dirname = sprintf('u:\\data\\bpmpmdata\\');
+ end
+ if exist(dirname,'dir') ~= 7
+ mkdir(dirname);
+ end
+
+ fprintf('Collecting PM data...');
+ pm = getliberadata('PM_DDC_SYNTH_SIGNAL');
+ fprintf(' done\n');
+
+ fprintf('Collecting Interlock Status and Offset... ');
+ pm.ilkxstatus = srbpm.getfield('ILK_STATUS_X_STATUS');
+ pm.ilkystatus = srbpm.getfield('ILK_STATUS_Y_STATUS');
+ pm.ilk_mode_status = srbpm.getfield('ILK_ENABLED_STATUS');
+ pm.offset = srbpm.getfield('PM_OFFSET_SP');
+ fprintf(' done\n');
+
+ fprintf('Acknowledging interlock status and resetting PM on the Libera...');
+ srbpm.setfield('ILK_STATUS_RESET_CMD',0);
+ srbpm.setfield('PM_CAPTURE_CMD',1);
+ fprintf(' done\n');
+
+ fprintf('Reseting the PM triggering system...');
+ setpv('TS01EVR11:TTL03_ENABLE_CMD',1);
+ pause(0.2);
+ setpv('TS01EVR11:TTL03_ENABLE_CMD',0);
+ fprintf(' done\n');
+
+ fname = appendtimestamp([dirname 'pmdata']);
+ fprintf('Saving to file: %s.mat\n',fname);
+ save(fname,'pm')
+ if nargout > 0
+ varargout{1} = pm;
+ end
+ end
+
+ function setdefaultconfig(varargin)
+ % setdefaultconfig([DeviceList])
+ %
+ % This function sets the default configuration for the Liberas Brillinace+
+ % in the storage ring. Optional parameters:
+ %
+ % DeviceList A vector of nx2 specifying which devices to configure
+ %
+ % If no parameters are set, the configuration will be applied to all the
+ % liberas that are enabled in middleLayer ("aspinit").
+ %
+ % e.g. >> setliberabconfig
+ % >> setliberabconfig([1 2; 1 3; 1 4; 1 5;])
+
+ if nargin > 0 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+ else
+ deviceList = getlist('BPMx');
+ end
+ el = dev2elem('BPMx',deviceList);
+
+ mysrbpm = srbpm;
+
+ % =======================================================================
+ % EVRX related PVs
+ fprintf('Setting TRIGGER event 5 (extraction with gun) and 7 (SR BPM trigger)\n');
+ mysrbpm.settriggerevent([5 7]);
+
+ % We do not normally change the following and will only do this
+ % if we know the timing settings have changed.
+
+ % Make sure the decoder is turned on
+% mysrbpm.setfield('EVRX_RTC_DECODER_SWITCH_CMD' , 1, varargin{:});
+% % MC to trigger on SROC with a hex value of 0x0200
+% mysrbpm.setfield('EVRX_RTC_MC_IN_MASK_SP' , hex2dec('0210'), varargin{:});
+% mysrbpm.setfield('EVRX_RTC_MC_IN_FUNCTION_SP' , hex2dec('0210'), varargin{:});
+%
+% % Post mortem event is locked in as event code 10 (Beam Dump
+% % Event)
+% mysrbpm.setfield('EVRX_RTC_T1_IN_MASK_SP' , hex2dec('00ff'), varargin{:});
+% mysrbpm.setfield('EVRX_RTC_T1_IN_FUNCTION_SP' , 10 , varargin{:});
+%
+% % Trigger event is defaulted to event code 5 (ext with gun) and 7 (SR BPM Event)
+% mysrbpm.setfield('EVRX_RTC_T2_IN_MASK_SP' , hex2dec('00ff'), varargin{:});
+%
+%
+% % PLL offset tuning
+% fprintf('Setting PLL offset tune to 0 units (0 kHz) and no compensation: \n');
+% mysrbpm.setfield('EVRX_PLL_VCXO_OFFSET_MONITOR' ,0,varargin{:});
+% mysrbpm.setfield('EVRX_PLL_COMPENSATE_OFFSET_STATUS' ,0,varargin{:});
+
+
+ % =======================================================================
+
+
+ % AGC
+ fprintf('Settting AGC to 1 (ENABLED)\n');
+ if isnan(local_setPV('BPMx','AGC_ENABLED_CMD',1,varargin{:}))
+ fprintf("Failed to set PV");
+ return;
+ end
+
+ % Switches
+ fprintf('Setting SWITCHES to 1 (ENABLED)\n');
+ local_setPV('BPMx','SWITCHING_ENABLE_CMD',1,varargin{:});
+ local_setPV('BPMx','SWITCHING_SOURCE_CMD',1,varargin{:});
+ local_setPV('BPMx','SWITCHING_DELAY_SP',0,varargin{:});
+
+ % Digital signal conditioning
+ fprintf('Turning _ON_ DSC\n');
+ local_setPV('BPMx','DSC_COEFF_ADJUST_CMD',1,varargin{:});
+ local_setPV('BPMx','DSC_COEFF_TYPE_CMD',2,varargin{:}); %0-PHASE, 1-AMPLITUDE, 2-ADJUST
+ local_setPV('BPMx','DSC_COEFF_ATT_DEPENDENT_CMD',0,varargin{:});
+
+ % Gain
+ fprintf('Setting GAINS \n');
+ local_setPV('BPMx','KX_SP',14.8e6,varargin{:});
+ local_setPV('BPMx','KY_SP',15.1e6,varargin{:});
+ % local_setPV('BPMx','KS_SP',67108864,varargin{:});
+ local_setPV('BPMx','KS_SP',mysrbpm.ks(el),varargin{:});
+
+ % Libera Offsets
+ [libera_offset_x, libera_offset_y] = mysrbpm.getarchivedoffsets('last');
+ fprintf('Setting Libera Offsets \n');
+ local_setPV('BPMx','OFF_X_SP',libera_offset_x(el),varargin{:});
+ local_setPV('BPMx','OFF_Y_SP',libera_offset_y(el),varargin{:});
+ local_setPV('BPMx','OFF_S_SP',mysrbpm.sumoffset(el),varargin{:});
+
+ % Interlock
+ fprintf('Setting INTERLOCKS \n');
+% gain_threshold = [...
+% -23 -22 -23 -21 -21 -23 -23, ... %
+% -23 -22 -29 -27 -28 -27 -27, ... %
+% -29 -29 -31 -30 -31 -31 -31, ... %
+% -25 -26 -26 -26 -26 -22 -22, ... %
+% -23 -24 -25 -24 -23 -22 -21, ... %
+% -30 -30 -32 -31 -31 -27 -26, ... %
+% -33 -33 -34 -34 -33 -29 -29, ... %
+% -28 -28 -29 -29 -28 -26 -24, ... %
+% -26 -25 -27 -26 -27 -26 -23, ... %
+% -26 -28 -29 -29 -29 -26 -26, ... %
+% -26 -26 -27 -27 -27 -28 -26, ... %
+% -28 -28 -29 -30 -30 -30 -30, ... %
+% -24 -25 -25 -23 -23 -22 -23, ... %
+% -24 -23 -24 -25 -25 -26 -25, ... %
+% ]' + 3 ; gain_threshold(gain_threshold<-32) = -32;
+ % For the new Brilliance+ the gain table is quite coarse and
+ % our 10dB singal range due to cable lengths means that we have
+ % to have a lower threshold
+ gain_threshold = repmat(-32,size(libera_offset_y));
+ local_setPV('BPMx','ILK_LIMITS_MIN_X_SP',-1e6,deviceList);
+ local_setPV('BPMx','ILK_LIMITS_MIN_Y_SP',-1e6,deviceList);
+ local_setPV('BPMx','ILK_LIMITS_MAX_X_SP',+1e6,deviceList);
+ local_setPV('BPMx','ILK_LIMITS_MAX_Y_SP',+1e6,deviceList);
+ local_setPV('BPMx','ILK_GAIN_DEPENDENT_THRESHOLD_SP',gain_threshold(el),deviceList);
+
+ % Index into deviceList for those that need to be interlocked
+ % and those that don't need to
+ ii_ikl = sort([find(deviceList(:,2) == 1 | deviceList(:,2) == 7); findrowindex([2 2; 2 3],getlist('BPMx'))]);
+ ii_noilk = setxor(ii_ikl,1:size(deviceList,1));
+
+ % ILK_GAIN_DEPENDENT_ENABLED_CMD must come first before
+ % ILK_ENABLED_CMD otherwise you risk dumping beam!!
+ local_setPV('BPMx','ILK_GAIN_DEPENDENT_ENABLED_CMD',1,deviceList(ii_ikl,:));
+ local_setPV('BPMx','ILK_ENABLED_CMD',1,deviceList(ii_ikl,:));
+
+ % Disable the interlocks for those that we do not need.
+ local_setPV('BPMx','ILK_ENABLED_CMD',0,deviceList(ii_noilk,:));
+ local_setPV('BPMx','ILK_GAIN_DEPENDENT_ENABLED_CMD',0,deviceList(ii_noilk,:));
+
+ local_setPV('BPMx','ILK_STATUS_RESET_CMD',0,deviceList);
+
+ delay=[
+ 29 102 188 288 356 461 514 545 479 421 354 299 204 134
+ 25 101 189 290 358 462 517 545 479 421 355 300 206 133
+ 27 115 193 294 361 465 518 549 484 424 358 302 203 138
+ 26 113 192 292 360 465 520 550 482 423 358 303 204 137
+ 4 89 169 271 337 447 491 527 459 401 334 282 181 113
+ 7 89 172 261 333 436 494 519 457 396 337 284 180 116
+ 7 90 171 263 333 438 495 521 455 395 339 284 178 117];
+
+ % Commands to easily adjust the libera parameters
+% setpv('BPMx','TRIG_DELAY_SP',delay(:));
+% setpv('BPMx','TBT_PHASE_OFFSET_SP',40);
+
+ local_setPV('BPMx','TRIG_DELAY_SP',delay(el),deviceList); % Send default
+ % SR02BPM01:TBT_TBT_WINDOW.ChannelA --> set offset so that data 1 to 86 is
+ % used for turn 1, 87 to 172 for turn 2, etc.
+ % With an offset of 20, we make sure that injecting in bucket 1
+ % is always within the "turn" integration window.
+ local_setPV('BPMx','TBT_PHASE_OFFSET_SP',20,varargin{:});
+
+
+ % Setting whether to use DDC (0) or TDP (1) tbt data for decimated data
+ local_setPV('BPMx','TBT_DATA_TYPE_CMD',0,varargin{:});
+
+ % After setting the mask it this result can be seen on the TBT_TBT_WINDOW
+ % !!!!!!! Below does not work yet !!!!!!!!!!!!!!!!
+ % setpv('BPMx','TBT_ADC_MASK',ones(98,86)); % zero or one to mask the ADC samples to use to calculate TBT data
+ % setpv('BPMx','TBT_ADC_MASK',repmat([zeros(43,1); ones(43,1)],1,98)');
+
+ % Post mortem
+ %info PM signal arrives ~78.5 SROC after event (6752 ADC Clocks)
+ fprintf('Setting PM \n');
+ local_setPV('BPMx','PM_CAPTURE_CMD',1,varargin{:}); %Enable PM Capture
+ local_setPV('BPMx','PM_SOURCE_SELECT_CMD',0,varargin{:}); %Select external Trigger
+ % Collects data from -20000 turns to trigger point. Therefore
+ % an offset of 2000 means that it collects data from -18000 to
+ % +2000 where 0 is when the trigger occured.
+ local_setPV('BPMx','PM_OFFSET_SP',10000,varargin{:});
+
+ % Disable Spike removal for now ET 5/9/2017
+ % to re-enable we will have to also do a BBA with them enabled.
+ % There is something to be gained by enabling the FA spike
+ % removal as this should further drop the noise floor for the
+ % FA data. HOWEVER we will need to do a BBA or re-calibrate the
+ % offsets immediately after enabling this feature. We can do
+ % this by doing a orbit before and orbit after to calculate the
+ % necessary changes to the offsets.
+ % the spike removal from TBT data however is questionable as
+ % it adds unwanted features in the spectrum when you do an FFT.
+ fprintf('Setting spike removal DISABLE\n');
+ local_setPV('BPMx','TBT_SR_TBT_ENABLE_CMD',0,varargin{:});
+ local_setPV('BPMx','TBT_SR_FA_ENABLE_CMD',0,varargin{:});
+
+ % Set the libera IDs (careful as this will affect the FOFB)
+ fprintf('Setting data BPM unique IDs\n');
+ ids = dev2elem('BPMx',varargin{:});
+ local_setPV('BPMx','ID_SP',ids,varargin{:});
+
+ % configure the statistics gathering
+ fprintf('Settingg the parameters for STATISTICS\n');
+ local_setPV('BPMx','STAT_SA_STEP_SP',10,varargin{:});
+ local_setPV('BPMx','STAT_SA_WINDOW_SP',100,varargin{:});
+ local_setPV('BPMx','STAT_TBT_PERIOD_SP',5,varargin{:});
+ local_setPV('BPMx','STAT_TBT_WINDOW_SP',1000,varargin{:});
+ local_setPV('BPMx','STAT_TBT_MODE_CMD',1,varargin{:});
+
+
+ fprintf('Setting data on demand PVs\n');
+ % ACQM: now (1), Event (2), Stream (3) only for FA and SA
+ % SCAN: passive (0), Event (1-unused), i/O interupt (2), periodic (3-9)
+ % If SCAN==0 then sequence is .PROC --> [trigger] --> caget
+ %
+ % 29/01/2018:tane: as of now you have to set the scan to
+ % passive (0) first before changing the acquisition mode then
+ % resetting the scan mode to your desired scan.
+ fprintf(' - ADC_SIGNAL');
+ local_setPV('BPMx','ADC_SIGNAL.SCAN',0 ,varargin{:});
+ local_setPV('BPMx','ADC_SIGNAL.ACQM',2,varargin{:});
+ local_setPV('BPMx','ADC_SIGNAL.SCAN',2,varargin{:});
+% local_setPV('BPMx','ADC_SIGNAL.SCAN',2,varargin{:});
+
+ fprintf(',TBT_TBT_WINDOW_SIGNAL');
+ % The acqm must be now(1) and scan set to passive(0).
+ local_setPV('BPMx','TBT_TBT_WINDOW_SIGNAL.SCAN',0,varargin{:});
+ local_setPV('BPMx','TBT_TBT_WINDOW_SIGNAL.ACQM',1,varargin{:});
+ local_setPV('BPMx','TBT_TBT_WINDOW_SIGNAL.PROC',0,varargin{:});
+
+ fprintf(',DDC_RAW_SIGNAL');
+ local_setPV('BPMx','DDC_RAW_SIGNAL.SCAN',0,varargin{:});
+ local_setPV('BPMx','DDC_RAW_SIGNAL.ACQM',1,varargin{:});
+ local_setPV('BPMx','DDC_RAW_SIGNAL.OFFS',23198,varargin{:}); % Offset relative to extraction trigger
+
+ fprintf(',DDC_SYNTH_SIGNAL');
+ local_setPV('BPMx','DDC_SYNTH_SIGNAL.SCAN',0,varargin{:});
+ local_setPV('BPMx','DDC_SYNTH_SIGNAL.ACQM',2,varargin{:});
+ local_setPV('BPMx','DDC_SYNTH_SIGNAL.SCAN',2,varargin{:});
+ local_setPV('BPMx','DDC_SYNTH_SIGNAL.OFFS',23198,varargin{:}); % Offset relative to extraction trigger
+
+
+ fprintf(',TDP_SYNTH_SIGNAL');
+ local_setPV('BPMx','TDP_SYNTH_SIGNAL.SCAN',0,varargin{:});
+ local_setPV('BPMx','TDP_SYNTH_SIGNAL.ACQM',2,varargin{:});
+ local_setPV('BPMx','TDP_SYNTH_SIGNAL.SCAN',2,varargin{:});
+ local_setPV('BPMx','TDP_SYNTH_SIGNAL.OFFS',23198,varargin{:}); % Offset relative to extraction trigger
+
+ fprintf(',PM_DDC_SYNTH_SIGNAL');
+ local_setPV('BPMx','PM_DDC_SYNTH_SIGNAL.SCAN',0,varargin{:});
+ local_setPV('BPMx','PM_DDC_SYNTH_SIGNAL.ACQM',2,varargin{:});
+ local_setPV('BPMx','PM_DDC_SYNTH_SIGNAL.SCAN',2,varargin{:});
+ local_setPV('BPMx','PM_DDC_SYNTH_SIGNAL.OFFS',0,varargin{:});
+
+ fprintf(',PM_DDC_RAW_SIGNAL');
+ local_setPV('BPMx','PM_DDC_RAW_SIGNAL.SCAN',0,varargin{:});
+ local_setPV('BPMx','PM_DDC_RAW_SIGNAL.ACQM',2,varargin{:});
+ local_setPV('BPMx','PM_DDC_RAW_SIGNAL.SCAN',2,varargin{:});
+ local_setPV('BPMx','PM_DDC_RAW_SIGNAL.OFFS',0,varargin{:});
+
+ % the proc pv doesn't appear to have a ca_put_callback. By
+ % default setpv in Matlab waits for a callback before returning
+ % therefore this part of the code will hang.
+% local_setPV('BPMx','PM_DDC_SYNTH_MONITOR.PROC',0,varargin{:});
+
+ fprintf(' done.\n');
+
+ fprintf('Resetting MC PLL status monitor\n');
+ mysrbpm.reset_pll_status;
+
+ end
+
+ %% Misc Functions
+
+ function plotadcsynchronisation(varargin)
+ % plotadcsynchronisation
+ %
+ % function to plot the adc channels to see if the TRIG_DELAY
+ % and TBT_PHASE_OFFSET are set correctly.
+ fprintf('Collecting ADC data... ');
+ adc = getliberadata('ADC_SIGNAL');
+ fprintf('TBT_TBT_WINDOW data... ');
+ tbtw = getliberadata('TBT_TBT_WINDOW_SIGNAL');
+ fprintf('done.\n');
+
+ ii = 1:200;
+
+ h = figure(301);
+ set(h,'Position',[1794 44 1147 1124]);
+ clf;
+ subplot(1,2,1);
+ surface(ii,[1:98]/7+1,adc.a(:,ii) + adc.b(:,ii) + adc.c(:,ii) + adc.d(:,ii));
+ shading flat;
+ ylabel('BPM number');
+ xlabel('Time (ADC samples)');
+ title({'Sum ADC values';'Set TRIG_DELAY to align ADCs'},'Interpreter','None');
+ axis tight;
+
+ subplot(2,2,2);
+ plot(adc.a(1,ii),'.-');
+ hold on;
+ plot(tbtw.a(1,ii),'r.-','LineWidth',1.5);
+ a = axis;
+ plot([86 86],[-16000 16000],'r--','LineWidth',1.5);
+ axis(a);
+ title({'BPM 1-1';'Set TBT_PHASE_OFFSET to put';'bunch train (red) within first 86 samples'}','Interpreter','None');
+ legend('ADC','TBT TBT WINDOW');
+ grid on;
+ xlabel('Time (ADC samples)');
+ ylabel('Amplitude (Counts)');
+
+ subplot(2,2,4);
+ plot(adc.a(3,ii),'.-');
+ hold on;
+ plot(tbtw.a(3,ii),'r.-','LineWidth',1.5);
+ a = axis;
+ plot([86 86],[-16000 16000],'r--','LineWidth',1.5);
+ axis(a);
+ title('BPM 1-3');
+ grid on;
+ xlabel('Time (ADC samples)');
+ ylabel('Amplitude (Counts)');
+ end
+
+ function plotadc(DeviceList)
+ % Function to plot the ADC values for a particular BPM
+ % srbpm.plotadc(DeviceList)
+ if nargin < 1
+ error('%s.plotadc: requires a device list or element number as an input parameter',mfilename);
+ end
+ adc = getliberadata('ADC_SIGNAL',DeviceList);
+
+ for i=1:size(adc.a,1)
+ h = figure(301);
+ clf;
+ ax(1) = subplot(2,2,1);
+ plot(adc.a(i,:));
+ title('A'); xlabel('samples'); ylabel('counts'); grid on;
+ ax(2) = subplot(2,2,2);
+ plot(adc.b(i,:));
+ title('B'); xlabel('samples'); ylabel('counts'); grid on;
+ ax(3) = subplot(2,2,3);
+ plot(adc.c(i,:));
+ title('C'); xlabel('samples'); ylabel('counts'); grid on;
+ ax(4) = subplot(2,2,4);
+ plot(adc.d(i,:));
+ title('D'); xlabel('samples'); ylabel('counts'); grid on;
+
+ linkaxes(ax,'x');
+
+ % Create textbox
+ annotation(h,'textbox',...
+ [0.380853983415142 0.946275307747930 0.265826498520414 0.030100333883345],...
+ 'String',{sprintf('BPM [%02d, %02d]',adc.DeviceList(i,:))},...
+ 'HorizontalAlignment','Center','FontSize',11);
+
+ if size(adc.a,1) > 1
+ fprintf('Plotting for BPM [%02d, %02d]. Press any key to plot the next BPM...\n', adc.DeviceList(i,:));
+ pause;
+ end
+ end
+ end
+
+ function plotfillpattern
+ % Use the ADC data from the Libera B+ to extract the fill
+ % pattern. Data will only refresh when there is a trigger.
+ adc = getliberadata('ADC_SIGNAL');
+
+ inter_freq = 360/86 - 4; % expected intermediate freq
+ N2 = length(adc.a)/2;
+ ii = [1:(N2-1*256*2.25), (N2+1*256*2.25):(N2*2)];
+
+ % Quadrature mixing at the IF
+ br = cos(2*pi*inter_freq*(0:length(adc.a)-1));
+ bi = sin(2*pi*inter_freq*(0:length(adc.a)-1));
+
+ mixa = abs(adc.a .* complex(br,bi));
+ % a low pass filter
+ ffta = fftshift(fft(mixa,[],2));
+ ffta(:,ii) = 0;
+ newa = ifft( ifftshift(ffta) ,[],2);
+
+ mixb = abs(adc.b .* complex(br,bi));
+ % a low pass filter
+ fftb = fftshift(fft(mixb,[],2));
+ fftb(:,ii) = 0;
+ newb = ifft( ifftshift(fftb) ,[],2);
+
+ mixc = abs(adc.c .* complex(br,bi));
+ % a low pass filter
+ fftc = fftshift(fft(mixc,[],2));
+ fftc(:,ii) = 0;
+ newc = ifft( ifftshift(fftc) ,[],2);
+
+ mixd = abs(adc.d .* complex(br,bi));
+ % a low pass filter
+ fftd = fftshift(fft(mixd,[],2));
+ fftd(:,ii) = 0;
+ newd = ifft( ifftshift(fftd) ,[],2);
+
+
+
+ dt = 8.377502778920296e-09;
+ t = (0:(N2*2-1))*dt * 1e6;
+ figure(8); clf;
+ plot(t,abs(real(newa(3,:)+newb(3,:)+newc(3,:)+newd(3,:))),'.-');
+ hold on;
+ % Average over multiple revolutions and plot only one fill
+ % pattern.
+% [newt,newtind]=sort(mod(t,0.72046520));
+% plot(newt, abs(real(newa(3,newtind)+newb(3,newtind)+newc(3,newtind)+newd(3,newtind))),'.-');
+% plot(t,abs(real(newb(3,:))),'.-');
+ fpmdata = getfpm * 1.07 * max(ylim);
+ t = (0:359)*0.002 + 0.26;
+ plot(t, fpmdata);
+ xlim([0 1.5]);
+ grid on;
+ xlabel('Time (us)');
+ ylabel('Amplitude (arb)');
+ legend('Channel A+B+C+D','FPM');
+ title('BPM 1-3');
+ end
+
+ function plotbetafunctions(varargin)
+ % Function that uses the TBT data during injection to extract
+ % the beta function. The caveat is that it looks for an
+ % injection event using the horizontal position. Makes the
+ % following analysis
+ % 1. remove DC component, takes the last 100 samples as the
+ % reference/DC component
+ % 2. find first sample where the horizontal orbit exceeds 500
+ % um.
+ % 3. skips the first 10 samples as we assume this contains
+ % the kicker pulse. We only want the residual oscillations
+ % 4. use 200 samples and extract the fundamental spatial
+ % modes using SVD. Plot the amplitude function of the two
+ % modes sqrt( mode1^2 + mode2^2 );
+
+ mysrbpm = srbpm;
+
+ data = getliberadata('TDP_SYNTH_SIGNAL');
+
+ x = data.x - mean(data.x(:,end-100:end),2);
+ y = data.y - mean(data.y(:,end-100:end),2);
+
+ ix = find( abs(x(1,:)) > 500000 , 1, 'first') + 200;
+ iy = find( abs(x(1,:)) > 500000 , 1, 'first') + 30;
+
+ if isempty(ix)
+ fprintf('No TBT betatron oscillations detected. Cannot plot beta functions.\n');
+ return
+ end
+
+ [ux,sx,vx]=svd(x(:,ix:ix+100));
+ sx = diag(sx);
+ [uy,sy,vy]=svd(y(:,iy:iy+100));
+ sy = diag(sy);
+
+ mach = machine_at;
+ bpmind = family2atindex('BPMx');
+
+ figure(121);
+ clf;
+ subplot(2,1,1);
+ measbetax = mysrbpm.bpmgain(:,1).*( (ux(:,1) * sx(1)).^2 + (ux(:,2) * sx(2)).^2 );
+ plot( mach.spos(bpmind), mach.betax(bpmind)/sum(mach.betax(bpmind)) * sum(measbetax) ,'--','LineWidth',2);
+ hold on;
+ plot( getspos('BPMx'), measbetax, '.-');
+ xlabel('S (m)');
+ ylabel('\beta_x (arb)');
+ grid on;
+ xlim([0 216]);
+
+
+ subplot(2,1,2);
+ measbetay = mysrbpm.bpmgain(:,2).*( (uy(:,1) * sy(1)).^2 + (uy(:,2)* sy(2)).^2 );
+ plot( mach.spos(bpmind), mach.betay(bpmind)/sum(mach.betay(bpmind)) * sum(measbetay) ,'--','LineWidth',2);
+ hold on;
+ plot( getspos('BPMx'), measbetay, '.-');
+ xlabel('S (m)');
+ ylabel('\beta_y (arb)');
+ grid on;
+ xlim([0 216]);
+
+ plotelementsat;
+
+ subplot(2,1,2);
+ legend('Model (Normalised)','Extracted from TBT','Location','northoutside','Orientation','Horizontal');
+ end
+
+ function reset_pll_status(varargin)
+ % Function to reset the latched PLL status monitor
+ % srbpm.reset_pll_status([DeviceList])
+ %
+ srbpm.setfield('EVRX_PLL_MAX_ERR_RESET_CMD',0,varargin{:});
+ srbpm.setfield('EVRX_PLL_OS_UNLOCK_TIME_RESET_CMD',0,varargin{:});
+
+ end
+
+ function varargout = printraftemps(varargin)
+ % table plots and/or returns the temperatures for all the BPMs
+ % temptable = printraftemps([DeviceList])
+ if nargin > 0 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+ else
+ deviceList = getlist('BPMx');
+ end
+ for i=1:7
+ raftemps{i} = local_getPV('BPMx', sprintf('ID_%d_VALUE',i), deviceList);
+ temp = char(local_getPV('BPMx',sprintf('ID_%d_NAME',i),deviceList));
+ temp = strrep(temp,'-','_');
+ temp = strrep(temp,'.','_');
+ raftempnames{i} = ['Temp_', temp];
+ end
+ rafrownames = strrep(cellstr(family2channel('BPMx',deviceList)),':SA_X_MONITOR','');
+
+ t = table(raftemps{:},'VariableNames',raftempnames,'RowNames',rafrownames);
+ if nargout > 0
+ varargout{1} = t;
+ end
+
+ end
+
+ function varargout = getreferenceorbit(varargin)
+ % function to return the x and y reference orbits
+ % [xref, yref] = getreferenceorbit([DeviceList])
+ % where xref and yref are the reference orbits that the orbit
+ % feedback system uses to stabilise the orbit. DeviceList
+ % defaults to all BPMs.
+ if nargin > 0 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+ else
+ deviceList = getlist('BPMx');
+ end
+ el = dev2elem('BPMx',deviceList);
+
+ xref = getpv('SR00:X_REFERENCE_ORBIT_SP');
+ yref = getpv('SR00:Y_REFERENCE_ORBIT_SP');
+
+ varargout{1} = xref(el);
+ if nargout > 1
+ varargout{2} = yref(el);
+ end
+
+ end
+
+ function setreferenceorbit(xref, yref, varargin)
+ % function to set the x and y reference orbits
+ % setreferenceorbit(xref, yref, [DeviceList])
+ % where xref and yref are the reference orbits that the orbit
+ % feedback system uses to stabilise the orbit. DeviceList
+ % defaults to all BPMs.
+ if nargin > 2 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+ else
+ deviceList = getlist('BPMx');
+ end
+ el = dev2elem('BPMx',deviceList);
+
+ xref0 = getpv('SR00:X_REFERENCE_ORBIT_SP');
+ yref0 = getpv('SR00:Y_REFERENCE_ORBIT_SP');
+
+ xref0(el) = xref;
+ yref0(el) = yref;
+
+ setpv('SR00:X_REFERENCE_ORBIT_SP',xref0);
+ setpv('SR00:Y_REFERENCE_ORBIT_SP',yref0);
+ % Necessary to ensure that the FOFB updated with the new
+ % reference orbit
+ setpv('SR00FPGA01:X_REF_ORBIT_SP',xref0);
+ setpv('SR00FPGA01:Y_REF_ORBIT_SP',yref0);
+ end
+
+ function stepreferenceorbit(dxref, dyref, varargin)
+ % function to set the x and y reference orbits
+ % stepreferenceorbit(dxref, dyref, [DeviceList])
+ % where dxref and dyref are the incremental change in the
+ % reference orbits that the orbit feedback system uses to
+ % stabilise the orbit. DeviceList defaults to all BPMs.
+ if nargin > 2 && isnumeric(varargin{1})
+ deviceList = varargin{1};
+ else
+ deviceList = getlist('BPMx');
+ end
+ el = dev2elem('BPMx',deviceList);
+
+ xref0 = getpv('SR00:X_REFERENCE_ORBIT_SP');
+ yref0 = getpv('SR00:Y_REFERENCE_ORBIT_SP');
+
+ xref0(el) = xref0(el) + dxref;
+ yref0(el) = yref0(el) + dyref;
+
+ % Necessary to ensure that the FOFB updated with the new
+ % reference orbit
+ setpv('SR00FPGA01:X_REF_ORBIT_SP',xref0);
+ setpv('SR00FPGA01:Y_REF_ORBIT_SP',yref0);
+
+ setpv('SR00:X_REFERENCE_ORBIT_SP',xref0);
+ setpv('SR00:Y_REFERENCE_ORBIT_SP',yref0);
+
+ end
+
+
+ end
+
+ %% Other Methods
+ methods
+ function obj = srbpm
+ obj.fullDeviceList = family2dev('BPMx','',0);
+ obj.bpmpvnames = cellstr(family2channel('BPMx',obj.fullDeviceList));
+ obj.bpmpvnames = regexprep(obj.bpmpvnames,'SA_X_MONITOR','MYCOMMAND');
+ obj.iocpvnames = regexprep(obj.bpmpvnames,'BPM0[1,2,3,4]','IOC41');
+ obj.iocpvnames = regexprep(obj.iocpvnames,'BPM0[5,6,7,8]','IOC42');
+ obj.ks = [
+ 8.853144058638271
+ 8.553306227504132
+ 8.709132643088015
+ 8.477664456962398
+ 8.233688939144534
+ 8.895346739566085
+ 8.721513375075650
+ 9.103217124052739
+ 8.999880217452990
+ 6.606422763758233
+ 6.407833139336645
+ 5.562751575849251
+ 5.413825461056707
+ 5.053280276363035
+ 6.991592129366940
+ 7.481833719548828
+ 8.281085417262730
+ 7.925489448484424
+ 7.914870034764797
+ 8.162522846617552
+ 8.171564386392882
+ 3.660878471680461
+ 3.413765681521329
+ 5.036065454589901
+ 4.815456587262468
+ 4.604935339579755
+ 8.371365821865076
+ 8.651566704317215
+ 9.125604474249256
+ 9.239282285827398
+ 2.671642243071018
+ 9.698171364999478
+ 9.570043697681594
+ 8.242264363336110
+ 8.375851661989921
+ 7.543909697039786
+ 7.629795359470272
+ 8.440516983045685
+ 8.332406374729588
+ 7.791323076737103
+ 4.655329538099621
+ 4.603700490577416
+ 5.372786227190657
+ 5.585528578962895
+ 6.540146185660331
+ 6.553028466806546
+ 5.904565380688806
+ 9.355732822203581
+ 9.367068332590062
+ 6.039076724951013
+ 5.877083820690847
+ 7.119030158217719
+ 6.749281256413786
+ 6.334805091123380
+ 3.236166925518648
+ 3.703253650372533
+ 4.325761779448408
+ 4.211005860626395
+ 5.628944846571070
+ 5.373084728836499
+ 4.910786478512518
+ 2.811053706835495
+ 9.803054080498494
+ 5.867845405424647
+ 5.615183042150490
+ 6.708891187270635
+ 6.786661275722777
+ 6.142381584574993
+ 3.965525957698259
+ 4.006345295554352
+ 4.234393567820267
+ 4.181619441099762
+ 5.118671561855333
+ 5.006864741800872
+ 4.842279664109178
+ 5.409323329157485
+ 6.026071865507837
+ 6.955325231431114
+ 6.613194868350434
+ 7.687788776692916
+ 7.507718094764419
+ 7.105881640403740
+ 7.640416058346170
+ 7.660964783297761
+ 9.790246546623754
+ 3.019178964094080
+ 2.603690545016278
+ 9.559704405793719
+ 9.343961628044473
+ 8.939288350455401
+ 8.865611882508913
+ 9.798036611388095
+ 9.445557552438173
+ 3.343369796160038
+ 9.789639106597445
+ 9.769521857642903
+ 3.144556886316249
+ 3.376069939210053]*1e7;
+ obj.sumoffset = [
+ -37794968
+ -33713000
+ -35837667
+ -32686512
+ -29364150
+ -38373965
+ -36006511
+ -41202651
+ -39796127
+ -7211087
+ -4507444
+ 6995619
+ 9025526
+ 13940586
+ -12486410
+ -19157585
+ -30027606
+ -25184305
+ -25047272
+ -28423461
+ -28529769
+ 32896940
+ 36260764
+ 14181087
+ 17185244
+ 20042584
+ -31235587
+ -35047966
+ -41513719
+ -43063319
+ 46354078
+ -49311153
+ -47570392
+ -29491103
+ -31301076
+ -19963944
+ -21134002
+ -32171762
+ -30700330
+ -23335674
+ 19364488
+ 20070222
+ 9599938
+ 6704088
+ -6294716
+ -6470263
+ 2353816
+ -44638423
+ -44790333
+ 513376
+ 2716546
+ -14186651
+ -9155438
+ -3527839
+ 38646868
+ -56088284
+ 23886219
+ 25445830
+ 6129850
+ 9612204
+ 15898680
+ 44488253
+ -50722387
+ 2846162
+ 6284323
+ -8604653
+ -9660656
+ -880406
+ 28761466
+ 28214592
+ 25066359
+ 25794402
+ 13047079
+ 14572006
+ 16795486
+ 9084446
+ 694647
+ -11958341
+ -7299881
+ -21931451
+ -19483184
+ -14015294
+ -21294123
+ -21564190
+ -50551628
+ 41638356
+ 47290127
+ -47417794
+ -44470947
+ -38961451
+ -37959938
+ -50661637
+ -45861868
+ 37215126
+ -50549385
+ -50266332
+ 39943356
+ -54711490
+ ];
+ obj.bpmgain = [
+ 1.019790109888349 0.949249236697061
+ 1.024345702167348 0.944567780180548
+ 1.028407517410135 0.949971969517302
+ 1.020991304026051 0.949754897634992
+ 1.021849017694516 0.949577106063936
+ 1.025037670416168 0.947907821687370
+ 1.017501470167591 0.947592777966483
+ 1.024632857704001 0.944949791219086
+ 1.022079367144060 0.944685038931816
+ 1.028511008951802 0.950372296240851
+ 1.030136333826651 0.950350485323705
+ 1.020682111166259 0.948336665697476
+ 1.031556858365583 0.944907524436659
+ 1.009291932163525 0.948464064620007
+ 1.001278289551558 0.953965386019827
+ 1.023103845670566 0.946160238296460
+ 1.030402019475276 0.951593430397251
+ 1.024146312673317 0.953414683578349
+ 1.020729066883117 0.949077046775849
+ 1.023846696209035 0.945414799066340
+ 1.018143559950577 0.944143527629333
+ 1.017925418129258 0.944617884435187
+ 1.023412423446008 0.943081823899102
+ 1.031924980084887 0.949018137851589
+ 1.026382021997893 0.949941703778988
+ 1.022458007452477 0.948457253608398
+ 1.027280512177995 0.949214139867137
+ 1.021997143239133 0.944288603523116
+ 1.021074628188609 0.945520163985390
+ 1.021691607862558 0.945829924189481
+ 1.029941389181460 0.951970829792339
+ 1.024481714154421 0.948857280999855
+ 1.017871754557471 0.948878478965569
+ 1.032758752996909 0.944015928733466
+ 1.024448402969096 0.941102863729423
+ 1.029698260057182 0.940474056955320
+ 1.022693771154018 0.945973422540821
+ 1.030544121758183 0.950547633996902
+ 1.026212659683978 0.950647145431741
+ 1.021407530136615 0.944867450035861
+ 1.031619838497942 0.949141416218957
+ 1.021382522307063 0.945342040171411
+ 1.021057527546628 0.943223842692008
+ 1.023746796550166 0.944275805748237
+ 1.027538119417079 0.951558042146971
+ 1.029456301004033 0.948490243940171
+ 1.018177972100218 0.950573185796091
+ 1.034452259395351 0.946740254185632
+ 1.024147881810003 0.942881200945415
+ 1.038325846809106 0.936561741800745
+ 1.022572791412994 0.943006647874190
+ 1.027122655196820 0.958706283595653
+ 1.025506825923074 0.952733083899000
+ 1.016215347893387 0.954396898514942
+ 1.029273031839981 0.949011613738053
+ 1.007064310784053 0.952589983950634
+ 1.016318457809970 0.944735626524407
+ 1.019237109964916 0.943936810762869
+ 1.030792749899852 0.949791147416936
+ 1.026964606033962 0.952633795347244
+ 1.018846527268870 0.949914297621846
+ 1.023960828093981 0.947513016431224
+ 1.020223576489132 0.945300297769261
+ 1.006519198340487 0.950645913942196
+ 1.021513235834946 0.944912992629821
+ 1.031792920092355 0.950142626826064
+ 1.027376776130119 0.950682774407246
+ 1.020884936363761 0.947392195057050
+ 1.028636597037438 0.948004087742045
+ 1.019025182396520 0.943955259689677
+ 1.020545204425863 0.945517066632875
+ 1.022885700217636 0.945411996357065
+ 1.029142102233283 0.953451620100816
+ 1.030005772502432 0.952283871955482
+ 1.017581952880327 0.949416416849636
+ 1.028470983014986 0.947735052660074
+ 1.013344871828959 0.948743169882161
+ 1.013532090189818 0.950370439122627
+ 1.022328613980134 0.946130470255584
+ 1.029026841823260 0.951594758454078
+ 1.026216978697642 0.951406205219404
+ 1.020289851575935 0.953767887022197
+ 1.031488922711221 0.948220981231094
+ 1.020132484357270 0.947084079353503
+ 1.017546520163332 0.944178949835829
+ 1.018594771147928 0.942441745340540
+ 1.028679136500693 0.947776610642991
+ 1.028410765350595 0.951171327672612
+ 1.022751556141560 0.949473473570070
+ 1.035406953996921 0.948267624382191
+ 1.018176205632190 0.947973893186085
+ 1.029789721519192 0.940961615137810
+ 1.025537211988558 0.943228906137280
+ 1.028086681301332 0.950763553589283
+ 1.026763830522217 0.951615684296115
+ 1.020705832577648 0.951536321031235
+ 1.031131510436517 0.949371115034835
+ 1.029865390300549 0.944310705084420];
+ end
+ end
+end
+
+%% Utility Functions
+
+function output = local_getPV(varargin)
+% Wrapper for getpv to try add some error handling.
+ try
+ output = getpv(varargin{:});
+ catch
+ warning('Problem using getpv. Are the BPMs online?');
+ output = nan;
+ end
+end
+
+function output = local_setPV(varargin)
+% Wrapper for setpv to try add some error handling.
+% try
+ output = setpv(varargin{:});
+% catch
+% warning('Problem using setpv. Are the BPMs online?');
+% output = nan;
+% end
+end
+
+
+
+
+
+
diff --git a/machine/ASP/StorageRing/bpm_scripts/tlibera_brilliance_bpm_form_20180720_155855.txt b/machine/ASP/StorageRing/bpm_scripts/tlibera_brilliance_bpm_form_20180720_155855.txt
new file mode 100644
index 00000000..18b4f3c1
--- /dev/null
+++ b/machine/ASP/StorageRing/bpm_scripts/tlibera_brilliance_bpm_form_20180720_155855.txt
@@ -0,0 +1,108 @@
+# TLibera_Brilliance_BPM_Form
+#
+
+SR08BPM01:SA_X_MONITOR
+SR08BPM01:SA_Y_MONITOR
+SR08BPM01:AGC_ATT_MONITOR
+SR08BPM01:AGC_POWER_LEVEL_MONITOR
+SR08BPM01:AGC_ENABLED_STATUS
+SR08BPM01:AGC_ENABLED_CMD
+SR08BPM01:AGC_ATT_SP
+SR08BPM01:AGC_POWER_LEVEL_SP
+SR08BPM01:DSC_COEFF_ADJUST_STATUS
+SR08BPM01:DSC_COEFF_ATT_DEPENDENT_STATUS
+SR08BPM01:SWITCHING_DELAY_MONITOR
+SR08BPM01:SWITCHING_ENABLE_STATUS
+SR08BPM01:SWITCHING_SOURCE_STATUS
+SR08BPM01:DSC_COEFF_TYPE_STATUS
+SR08BPM01:DSC_COEFF_ADJUST_CMD
+SR08BPM01:DSC_COEFF_ADJUST_CMD
+SR08BPM01:DSC_COEFF_ATT_DEPENDENT_CMD
+SR08BPM01:DSC_COEFF_ATT_DEPENDENT_CMD
+SR08BPM01:SWITCHING_ENABLE_CMD
+SR08BPM01:SWITCHING_ENABLE_CMD
+SR08BPM01:SWITCHING_SOURCE_CMD
+SR08BPM01:SWITCHING_SOURCE_CMD
+SR08BPM01:DSC_COEFF_TYPE_CMD
+SR08BPM01:DSC_COEFF_TYPE_CMD
+SR08BPM01:SWITCHING_DELAY_SP
+SR08BPM01:ILK_ENABLED_STATUS
+SR08BPM01:ILK_GAIN_DEPENDENT_ENABLED_STATUS
+SR08BPM01:ILK_GAIN_DEPENDENT_THRESHOLD_MONITOR
+SR08BPM01:ILK_GAIN_DEPENDENT_THRESHOLD_DB_MONITOR
+SR08BPM01:ILK_LIMITS_MIN_X_MONITOR
+SR08BPM01:ILK_LIMITS_MIN_Y_MONITOR
+SR08BPM01:ILK_LIMITS_MAX_X_MONITOR
+SR08BPM01:ILK_LIMITS_MAX_Y_MONITOR
+SR08BPM01:ILK_LIMITS_OVF_THRESHOLD_MONITOR
+SR08BPM01:ILK_LIMITS_OVF_MODE_STATUS
+SR08BPM01:ILK_LIMITS_OVF_DURATION_MONITOR
+SR08BPM01:ILK_STATUS_X_STATUS
+SR08BPM01:ILK_STATUS_RESET_CMD
+SR08BPM01:ILK_STATUS_ATTENUATOR_STATUS
+SR08BPM01:ILK_STATUS_STATUS
+SR08BPM01:ILK_STATUS_Y_STATUS
+SR08BPM01:ILK_LIMITS_MAX_X_SP
+SR08BPM01:ILK_LIMITS_MIN_Y_SP
+SR08BPM01:ILK_LIMITS_MAX_Y_SP
+SR08BPM01:ILK_LIMITS_MIN_X_SP
+SR08BPM01:ILK_STATUS_RESET_CMD
+SR08BPM01:ILK_ENABLED_CMD
+SR08BPM01:ILK_GAIN_DEPENDENT_ENABLED_CMD
+SR08BPM01:ILK_GAIN_DEPENDENT_ENABLED_CMD
+SR08BPM01:ILK_GAIN_DEPENDENT_THRESHOLD_SP
+SR08BPM01:ILK_LIMITS_OVF_DURATION_SP
+SR08BPM01:ILK_LIMITS_OVF_THRESHOLD_SP
+SR08BPM01:KX_MONITOR
+SR08BPM01:KY_MONITOR
+SR08BPM01:OFF_X_MONITOR
+SR08BPM01:OFF_Y_MONITOR
+SR08BPM01:OFF_S_MONITOR
+SR08BPM01:OFF_Q_MONITOR
+SR08BPM01:KS_MONITOR
+SR08BPM01:MAXADC_MONITOR
+SR08BPM01:OFF_S_SP
+SR08BPM01:OFF_Q_SP
+SR08BPM01:OFF_Y_SP
+SR08BPM01:OFF_X_SP
+SR08BPM01:KX_SP
+SR08BPM01:KS_SP
+SR08BPM01:KY_SP
+SR08BPM01:STAT_SA_X_MEAN_MONITOR
+SR08BPM01:STAT_SA_Y_MEAN_MONITOR
+SR08BPM01:STAT_SA_Y_STD_MONITOR
+SR08BPM01:STAT_SA_X_STD_MONITOR
+SR08BPM01:STAT_TBT_Y_MEAN_MONITOR
+SR08BPM01:STAT_TBT_Y_STD_MONITOR
+SR08BPM01:STAT_TBT_X_STD_MONITOR
+SR08BPM01:STAT_TBT_X_MEAN_MONITOR
+SR08BPM01:STAT_TBT_MODE_STATUS
+SR08BPM01:STAT_TBT_PERIOD_MONITOR
+SR08BPM01:STAT_TBT_WINDOW_MONITOR
+SR08BPM01:STAT_TBT_MODE_CMD
+SR08BPM01:STAT_TBT_PERIOD_SP
+SR08BPM01:STAT_TBT_WINDOW_SP
+SR08BPM01:STAT_SA_WINDOW_MONITOR
+SR08BPM01:STAT_SA_STEP_MONITOR
+SR08BPM01:STAT_SA_WINDOW_SP
+SR08BPM01:STAT_SA_STEP_SP
+SR08BPM01:ID_MONITOR
+SR08BPM01:ID_SP
+SR08BPM01:TDP_SYNTH_SIGNAL.X
+SR08BPM01:TDP_SYNTH_SIGNAL.Y
+SR08BPM01:TDP_SYNTH_SIGNAL.Sum
+SR08BPM01:TDP_SYNTH_SIGNAL.Va
+SR08BPM01:TDP_SYNTH_SIGNAL.Vb
+SR08BPM01:TDP_SYNTH_SIGNAL.Vc
+SR08BPM01:TDP_SYNTH_SIGNAL.Vd
+SR08BPM01:TDP_SYNTH_SIGNAL.SCAN
+SR08BPM01:TDP_SYNTH_SIGNAL.ACQM
+SR08BPM01:TDP_SYNTH_SIGNAL.MT
+SR08BPM01:ADC_SIGNAL.SCAN
+SR08BPM01:ADC_SIGNAL.ACQM
+SR08BPM01:ADC_SIGNAL.ChannelB
+SR08BPM01:ADC_SIGNAL.ChannelA
+SR08BPM01:ADC_SIGNAL.ChannelD
+SR08BPM01:ADC_SIGNAL.ChannelC
+
+# end
diff --git a/machine/ASP/StorageRing/changeaspoptics.m b/machine/ASP/StorageRing/changeaspoptics.m
index 1a59904f..34a68ceb 100644
--- a/machine/ASP/StorageRing/changeaspoptics.m
+++ b/machine/ASP/StorageRing/changeaspoptics.m
@@ -1,134 +1,134 @@
-function varargout = changeaspoptics(varargin)
-% RING = CHANGEASPOPTICS([RING or 'model'],[number]) is used to change the
-% optics of RING or if 'model' is specified then it will modify the lattice
-% that is stored in the global variable THERING. If no string parameters
-% are used then a list of options will be displayed for the user to
-% interactively choose.
-
-if nargin >= 1
- usemodel = 0;
- RING = {};
- if iscell(varargin{1})
- RING = varargin{1};
- FAMLIST = buildfamlist(RING);
- elseif strcmpi(varargin{1},'model')
- global THERING FAMLIST
- RING = THERING;
- usemodel = 1;
- end
-else
- fprintf('\nRING not defined. See help below for more info\n\n');
- help changeaspoptics
- return
-end
-
-if nargin >= 2 & isnumeric(varargin{2})
- selection = varargin{2};
-else
- selection = menu('Choose the optics for the ASP SR lattice',...
- '[13.3 5.2] 0.00 disp [0.0 0.0] chrom (+-14)',...
- '[13.3 5.2] 0.10 disp [0.0 0.0] chrom (+-14)',...
- '[13.3 5.2] 0.24 disp [0.0 0.0] chrom (+-14)',...
- '[13.3 5.2] 0.00 disp [1.0 1.0] chrom (+-14)',...
- '[13.3 5.2] 0.10 disp [1.0 1.0] chrom (+-14)',...
- '[13.3 5.2] 0.24 disp [1.0 1.0] chrom (+-14)');
-end
-
-% Make parameter groups for the major magnet families.
-qfa = mkparamgroup(RING,'qfa','K');
-qda = mkparamgroup(RING,'qda','K');
-qfb = mkparamgroup(RING,'qfb','K');
-sfa = mkparamgroup(RING,'sfa','K2');
-sda = mkparamgroup(RING,'sda','K2');
-sdb = mkparamgroup(RING,'sdb','K2');
-sfb = mkparamgroup(RING,'sfb','K2');
-
-
-switch selection
- case 1
- qfaval = 1.7617410683215;
- qdaval = -1.038377057025;
- qfbval = 1.5338016353322;
- sfaval = 1.400000e+001;
- sdaval = -1.400000e+001;
- sdbval = -7.0146346579091;
- sfbval = 7.1893457157312;
- case 2
- qfaval = 1.772006257777;
- qdaval = -1.038979133445;
- qfbval = 1.5282806930542;
- sfaval = 1.400000e+001;
- sdaval = -1.400000e+001;
- sdbval = -7.0943368258914;
- sfbval = 7.0061440937644;
- case 3
- qfaval = 1.788288337253;
- qdaval = -1.040097688513;
- qfbval = 1.5198075294908;
- sfaval = 1.400000e+001;
- sdaval = -1.400000e+001;
- sdbval = -7.719687342473;
- sfbval = 6.9366519209212;
- case 4
- qfaval = 1.7617410683215;
- qdaval = -1.038377057025;
- qfbval = 1.5338016353322;
- sfaval = 1.400000e+001;
- sdaval = -1.400000e+001;
- sdbval = -7.2625874274048;
- sfbval = 7.4301465642566;
- case 5
- qfaval = 1.772006257777;
- qdaval = -1.038979133445;
- qfbval = 1.5282806930542;
- sfaval = 1.400000e+001;
- sdaval = -1.400000e+001;
- sdbval = -7.4114847309303;
- sfbval = 7.3195664597002;
- case 6
- qfaval = 1.788288337253;
- qdaval = -1.040097688513;
- qfbval = 1.5198075294908;
- sfaval = 1.400000e+001;
- sdaval = -1.400000e+001;
- sdbval = -8.2576610441099;
- sfbval = 7.4837072741028;
- otherwise
- disp('Invalid selection!!');
-end
-
-RING = setparamgroup(RING,qfa,qfaval);
-RING = setparamgroup(RING,qda,qdaval);
-RING = setparamgroup(RING,qfb,qfbval);
-RING = setparamgroup(RING,sfa,sfaval);
-RING = setparamgroup(RING,sda,sdaval);
-RING = setparamgroup(RING,sdb,sdbval);
-RING = setparamgroup(RING,sfb,sfbval);
-
-if usemodel
- THERING = RING;
-else
- varargout{1} = RING;
-end
-
-
-
-
-
-function FAMLIST = buildfamlist(RING)
-
-elnames = {};
-elfamilies = {};
-for i=1:length(RING)
- elnames{i} = RING{i}.FamName;
-end
-elfamilies = unique(elnames);
-
-FAMLIST = {};
-for i=1:length(elfamilies)
- FAMLIST{i}.FamName = elfamilies{i};
- FAMLIST{i}.KidsList = findcells(RING,'FamName',elfamilies{i});
- FAMLIST{i}.NumKids = length(FAMLIST{i}.KidsList);
- FAMLIST{i}.ElemData = RING{FAMLIST{i}.KidsList(1)};
-end
-
+function varargout = changeaspoptics(varargin)
+% RING = CHANGEASPOPTICS([RING or 'model'],[number]) is used to change the
+% optics of RING or if 'model' is specified then it will modify the lattice
+% that is stored in the global variable THERING. If no string parameters
+% are used then a list of options will be displayed for the user to
+% interactively choose.
+
+if nargin >= 1
+ usemodel = 0;
+ RING = {};
+ if iscell(varargin{1})
+ RING = varargin{1};
+ FAMLIST = buildfamlist(RING);
+ elseif strcmpi(varargin{1},'model')
+ global THERING FAMLIST
+ RING = THERING;
+ usemodel = 1;
+ end
+else
+ fprintf('\nRING not defined. See help below for more info\n\n');
+ help changeaspoptics
+ return
+end
+
+if nargin >= 2 & isnumeric(varargin{2})
+ selection = varargin{2};
+else
+ selection = menu('Choose the optics for the ASP SR lattice',...
+ '[13.3 5.2] 0.00 disp [0.0 0.0] chrom (+-14)',...
+ '[13.3 5.2] 0.10 disp [0.0 0.0] chrom (+-14)',...
+ '[13.3 5.2] 0.24 disp [0.0 0.0] chrom (+-14)',...
+ '[13.3 5.2] 0.00 disp [1.0 1.0] chrom (+-14)',...
+ '[13.3 5.2] 0.10 disp [1.0 1.0] chrom (+-14)',...
+ '[13.3 5.2] 0.24 disp [1.0 1.0] chrom (+-14)');
+end
+
+% Make parameter groups for the major magnet families.
+qfa = mkparamgroup(RING,'qfa','K');
+qda = mkparamgroup(RING,'qda','K');
+qfb = mkparamgroup(RING,'qfb','K');
+sfa = mkparamgroup(RING,'sfa','K2');
+sda = mkparamgroup(RING,'sda','K2');
+sdb = mkparamgroup(RING,'sdb','K2');
+sfb = mkparamgroup(RING,'sfb','K2');
+
+
+switch selection
+ case 1
+ qfaval = 1.7617410683215;
+ qdaval = -1.038377057025;
+ qfbval = 1.5338016353322;
+ sfaval = 1.400000e+001;
+ sdaval = -1.400000e+001;
+ sdbval = -7.0146346579091;
+ sfbval = 7.1893457157312;
+ case 2
+ qfaval = 1.772006257777;
+ qdaval = -1.038979133445;
+ qfbval = 1.5282806930542;
+ sfaval = 1.400000e+001;
+ sdaval = -1.400000e+001;
+ sdbval = -7.0943368258914;
+ sfbval = 7.0061440937644;
+ case 3
+ qfaval = 1.788288337253;
+ qdaval = -1.040097688513;
+ qfbval = 1.5198075294908;
+ sfaval = 1.400000e+001;
+ sdaval = -1.400000e+001;
+ sdbval = -7.719687342473;
+ sfbval = 6.9366519209212;
+ case 4
+ qfaval = 1.7617410683215;
+ qdaval = -1.038377057025;
+ qfbval = 1.5338016353322;
+ sfaval = 1.400000e+001;
+ sdaval = -1.400000e+001;
+ sdbval = -7.2625874274048;
+ sfbval = 7.4301465642566;
+ case 5
+ qfaval = 1.772006257777;
+ qdaval = -1.038979133445;
+ qfbval = 1.5282806930542;
+ sfaval = 1.400000e+001;
+ sdaval = -1.400000e+001;
+ sdbval = -7.4114847309303;
+ sfbval = 7.3195664597002;
+ case 6
+ qfaval = 1.788288337253;
+ qdaval = -1.040097688513;
+ qfbval = 1.5198075294908;
+ sfaval = 1.400000e+001;
+ sdaval = -1.400000e+001;
+ sdbval = -8.2576610441099;
+ sfbval = 7.4837072741028;
+ otherwise
+ disp('Invalid selection!!');
+end
+
+RING = setparamgroup(RING,qfa,qfaval);
+RING = setparamgroup(RING,qda,qdaval);
+RING = setparamgroup(RING,qfb,qfbval);
+RING = setparamgroup(RING,sfa,sfaval);
+RING = setparamgroup(RING,sda,sdaval);
+RING = setparamgroup(RING,sdb,sdbval);
+RING = setparamgroup(RING,sfb,sfbval);
+
+if usemodel
+ THERING = RING;
+else
+ varargout{1} = RING;
+end
+
+
+
+
+
+function FAMLIST = buildfamlist(RING)
+
+elnames = {};
+elfamilies = {};
+for i=1:length(RING)
+ elnames{i} = RING{i}.FamName;
+end
+elfamilies = unique(elnames);
+
+FAMLIST = {};
+for i=1:length(elfamilies)
+ FAMLIST{i}.FamName = elfamilies{i};
+ FAMLIST{i}.KidsList = findcells(RING,'FamName',elfamilies{i});
+ FAMLIST{i}.NumKids = length(FAMLIST{i}.KidsList);
+ FAMLIST{i}.ElemData = RING{FAMLIST{i}.KidsList(1)};
+end
+
diff --git a/machine/ASP/StorageRing/contattem1.mat b/machine/ASP/StorageRing/contattem1.mat
deleted file mode 100644
index 39b1607f..00000000
Binary files a/machine/ASP/StorageRing/contattem1.mat and /dev/null differ
diff --git a/machine/ASP/StorageRing/energyscale.m b/machine/ASP/StorageRing/energyscale.m
index 75d3a2c4..4a942cfe 100644
--- a/machine/ASP/StorageRing/energyscale.m
+++ b/machine/ASP/StorageRing/energyscale.m
@@ -1,3 +1,4 @@
+
% 17/07/06 Tall fuzzy blobs (3 of them)
% scale = 0.9817;
% scaleQFB = 1.0059;
@@ -53,13 +54,50 @@
% setsp('QFA',136.3032*scaleQFA,'Hardware');
% setsp('QFB',119.8451*scaleQFB,'Hardware');
-scale = 1;
-dipscale = 1;
-scaleQFB = 1;
-scaleQFA = 1;
-scaleQDA = 1;
+% scale = 1;
+% dipscale = 1;
+% scaleQFB = 1;
+% scaleQFA = 1;
+% scaleQDA = 1;
%setsp('BEND',613.3*scale,'Hardware');
%setsp('QDA',80.8725*scale*scaleQDA,'Hardware');
%setsp('QFA',135.7422*scale*scaleQFA,'Hardware');
-%setsp('QFB',118.7201*scale*scaleQFB,'Hardware');
\ No newline at end of file
+%setsp('QFB',118.7201*scale*scaleQFB,'Hardware');
+
+
+
+%
+% qfasp = getsp('QFA');
+% qdasp = getsp('QDA');
+% qfbsp = getsp('QFB');
+% sfasp = getsp('SFA');
+% sdasp = getsp('SDA');
+% sfbsp = getsp('SFB');
+% sdbsp = getsp('SDB');
+% bendsp = getsp('BEND');
+
+dipscale = 1.00;
+scaleQFB = 1.00;
+scaleQFA = 1.00;
+scaleQDA = 1.00;
+scaleSFA = 1;
+scaleSDA = 1;
+scaleSFB = 1;
+scaleSDB = 1;
+
+% scale = 614.968/611.3;
+scale = 0.999;
+
+setsp('BEND',bendsp*scale*dipscale);
+setsp('QDA',qdasp*scale*scaleQDA,'Hardware');
+setsp('QFA',qfasp*scale*scaleQFA,'Hardware');
+setsp('QFB',qfbsp*scale*scaleQFB,'Hardware');
+setsp('SFA',sfasp*scale*scaleSFA,'Hardware');
+setsp('SDA',sdasp*scale*scaleSDA,'Hardware');
+setsp('SFB',sfbsp*scale*scaleSFB,'Hardware');
+setsp('SDB',sdbsp*scale*scaleSDB,'Hardware');
+
+temp= getsp('BEND','physics');
+disp(temp(1))
+
diff --git a/machine/ASP/StorageRing/findcells.m b/machine/ASP/StorageRing/findcells.m
index e2d08e4a..d17dd630 100644
--- a/machine/ASP/StorageRing/findcells.m
+++ b/machine/ASP/StorageRing/findcells.m
@@ -1,57 +1,57 @@
-function index = findcells(CELLARRAY, field, varargin)
-%FINDCELLS performs a search on MATLAB cell arrays of structures
-%
-% INDEX = FINDCELLS(CELLARRAY, 'field')
-% returns indexes of elements that have a field named 'field'
-%
-% INDEX = FINDCELLS(CELLARRAY, 'field', VALUE1, VALUE2, ...)
-% returns indexes of elements whose field 'field'
-% is equal to VALUE1, VALUE2, ... or VALUEN.
-%
-% See also GETCELLSTRUCT, SETCELLSTRUCT,
-
-% Check if the first argument is the cell arrray of tstructures
-if(~iscell(CELLARRAY) | ~isstruct(CELLARRAY{1}) | isempty(CELLARRAY))
- error('The first argument must be a non-empty cell array of structures')
-end
-% Chechk if the second argument is a string
-if(~ischar(field))
- error('The second argument must be a character string')
-end
-% if(nargin > 3)
-% error('Incorrect number of inputs')
-% end
-
-
-
-NE = length(CELLARRAY);
-matchesfound = 0;
-index = zeros(1,NE);
-for I = 1:NE
- if(isfield(CELLARRAY{I},field))
- matchesfound = matchesfound+1;
- index(matchesfound) = I;
- end
-end
-
-index = index(1:matchesfound);
-if(nargin > 2)
- index1 = index;
- matchesfound = 0;
- for I = index
- for j=1:length(varargin)
-% if isequal(getfield(CELLARRAY{I},field),varargin{j})
- if regexpi(getfield(CELLARRAY{I},field),['^' varargin{j} '$'])
- matchesfound = matchesfound+1;
- % since 'matchesfound' counter is <= loop number,
- % it is save to modify elements of 'index' inside the loop
- index(matchesfound) = I;
-
- end
- end
- end
-
- index = index(1:matchesfound);
-end
-
-
+function index = findcells(CELLARRAY, field, varargin)
+%FINDCELLS performs a search on MATLAB cell arrays of structures
+%
+% INDEX = FINDCELLS(CELLARRAY, 'field')
+% returns indexes of elements that have a field named 'field'
+%
+% INDEX = FINDCELLS(CELLARRAY, 'field', VALUE1, VALUE2, ...)
+% returns indexes of elements whose field 'field'
+% is equal to VALUE1, VALUE2, ... or VALUEN.
+%
+% See also GETCELLSTRUCT, SETCELLSTRUCT,
+
+% Check if the first argument is the cell arrray of tstructures
+if(~iscell(CELLARRAY) | ~isstruct(CELLARRAY{1}) | isempty(CELLARRAY))
+ error('The first argument must be a non-empty cell array of structures')
+end
+% Chechk if the second argument is a string
+if(~ischar(field))
+ error('The second argument must be a character string')
+end
+% if(nargin > 3)
+% error('Incorrect number of inputs')
+% end
+
+
+
+NE = length(CELLARRAY);
+matchesfound = 0;
+index = zeros(1,NE);
+for I = 1:NE
+ if(isfield(CELLARRAY{I},field))
+ matchesfound = matchesfound+1;
+ index(matchesfound) = I;
+ end
+end
+
+index = index(1:matchesfound);
+if(nargin > 2)
+ index1 = index;
+ matchesfound = 0;
+ for I = index
+ for j=1:length(varargin)
+% if isequal(getfield(CELLARRAY{I},field),varargin{j})
+ if regexpi(getfield(CELLARRAY{I},field),['^' varargin{j} '$'])
+ matchesfound = matchesfound+1;
+ % since 'matchesfound' counter is <= loop number,
+ % it is save to modify elements of 'index' inside the loop
+ index(matchesfound) = I;
+
+ end
+ end
+ end
+
+ index = index(1:matchesfound);
+end
+
+
diff --git a/machine/ASP/StorageRing/generate_hwinit.m b/machine/ASP/StorageRing/generate_hwinit.m
index f5ce8471..195a06ff 100644
--- a/machine/ASP/StorageRing/generate_hwinit.m
+++ b/machine/ASP/StorageRing/generate_hwinit.m
@@ -1,198 +1,198 @@
-function generate_hwinit(filename)
-
-% This function generates some of the more basic and repetitious aspects of
-% creating an init file.
-%
-% Notes: When generating the string elements in the definitions below, they
-% have to be all the same length. If the actual string is short you have to
-% padd it with spaces.
-%
-% Eugene
-filename = 'hwinit';
-skeleton_filename = 'hwinit_skeleton.m';
-
-if ~exist('filename','var')
- disp('Use: generate_hwinit([filaname]).');
- return
-end
-
-[fin,message]=fopen(skeleton_filename,'r');
-if fin==-1
- disp([' WARNING: Unable to open file :' skeleton_filename]);
- disp(message);
- return
-end
-disp([' Reading skeleton file: ' skeleton_filename]);
-skeleton_dir = fileparts(which(skeleton_filename));
-
-filename = appendtimestamp(filename, now);
-[fid,message]=fopen(fullfile(skeleton_dir,[filename '.m']),'w');
-if fid==-1
- disp([' WARNING: Unable to open file :' filename '.m']);
- disp(message);
- return
-end
-disp([' Writing init file to: ' filename '.m']);
-
-% Define some basic parameters and formatting.
-n_cell = 14;
-zeropad = 3;
-namepad = 8;
-chanpad = 24;
-line = '';
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% ION PUMP CONTROLLERS
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% name channel name status device el
-% vp={
-% '1vp1 ' 'SR-001-VP1 ' 1 [1,1] 1;...
-while isempty(strfind(upper(line),'INSERT IPC HERE'))
- if feof(fin)
- error('Unexpected eof while looking for ''INSERT IPC HERE''')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('IPC\n');
-
-n_percell = 3;
-ionPumpFile = 'ionpumps.csv'; % File where PVs for ion pumps are stored.
-pumpPVs = textread(ionPumpFile,'%s');
-
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- name = [num2str(cell) 'IPC' num2str(el_number)]; name = strpad(name, namepad);
- chname = pumpPVs{(cell-1)*n_percell + i}; chname = strpad(chname, chanpad); % Skip the status pv names
- stat = 1;
- fprintf(fid,'''%s''\t''%s''\t%d\t[%d,%d]\t%d\t; ...\n',...
- name,chname,stat,cell,el_number,i);
-end
-
-while isempty(strfind(upper(line),'INSERT IPC POSITION'))
- if feof(fin)
- error('Unexpected eof while looking for ''INSERT IPC POSITION''')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-
-% The position of VP has to be in a column vector
-% base_ipc_positions_per_cell = [0 1.45 4.7661 6.1822 6.9983 8.6144 10.0305 11.3466 12.6627 13.9788];
-base_ipc_positions_per_cell = [0 6.9983 10.0305];
-fprintf(fid,'AO.IPC.Position = [');
-for i=1:n_cell
- fprintf(fid,'%6.2f ', (i-1)*(216/n_cell) + base_ipc_positions_per_cell);
- if i ~= n_cell
- fprintf(fid,'\t...\n\t\t');
- else
- fprintf(fid,'\t]'';\n');
- end
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% GAUGE CONTROLLERS
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% name channel name status device el
-% vp={
-% '1vp1 ' 'SR-001-VP1 ' 1 [1,1] 1;...
-while isempty(strfind(upper(line),'INSERT GC HERE'))
- if feof(fin)
- error('Unexpected eof while looking for ''INSERT GC HERE''')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('GC\n');
-
-n_percell = 5;
-ionPumpFile = 'gauges.csv'; % File where PVs for ion pumps are stored.
-pumpPVs = textread(ionPumpFile,'%s');
-
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- name = [num2str(cell) 'GC' num2str(el_number)]; name = strpad(name, namepad);
- chname = pumpPVs{(cell-1)*n_percell + i}; chname = strpad(chname, chanpad); % Skip the status pv names
- stat = 1;
- fprintf(fid,'''%s''\t''%s''\t%d\t[%d,%d]\t%d\t; ...\n',...
- name,chname,stat,cell,el_number,i);
-end
-
-while isempty(strfind(upper(line),'INSERT GC POSITION'))
- if feof(fin)
- error('Unexpected eof while looking for ''INSERT GC POSITION''')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-
-% The position of VP has to be in a column vector
-% base_ipc_positions_per_cell = [0 1.45 4.7661 6.1822 6.9983 8.6144 10.0305 11.3466 12.6627 13.9788];
-base_ipc_positions_per_cell = [10.0305-0.1, 10.0305, 10.0305+0.1, 12.6627-0.1, 12.6627];
-fprintf(fid,'AO.GC.Position = [');
-for i=1:n_cell
- fprintf(fid,'%6.2f ', (i-1)*(216/n_cell) + base_ipc_positions_per_cell);
- if i ~= n_cell
- fprintf(fid,'\t...\n\t\t');
- else
- fprintf(fid,'\t]'';\n');
- end
-end
-
-% Continue to the end of the skeleton file
-while ~feof(fin)
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-fprintf(fid,'%s',line);
-
-fclose(fid);
-fclose(fin);
-disp('Finished updating hwinit')
-
-
-%========================================
-function str = padzeros(val, charlen)
-
-numstring = num2str(val);
-diff = charlen - length(numstring);
-temp = ' ';
-temp(1:charlen) = ' ';
-if diff > 0
- temp(1:diff) = '0';
- temp(diff+1:charlen) = numstring;
-elseif diff == 0
- temp = numstring;
-elseif diff < 0
- error(['Increase ''zeropad'' by at least: ' num2str(abs(diff))]);
-end
-
-str = temp;
-
-
-%========================================
-function str = strpad(instring, charlen)
-
-diff = charlen - length(instring);
-temp = ' ';
-temp(1:charlen) = ' ';
-
-if diff > 0
- temp(1:end-diff) = instring;
-elseif diff == 0
- temp = instring;
-elseif diff < 0
- error(['Increase ''space padding'' for names and channel names by at least: ' num2str(abs(diff))]);
-end
-
+function generate_hwinit(filename)
+
+% This function generates some of the more basic and repetitious aspects of
+% creating an init file.
+%
+% Notes: When generating the string elements in the definitions below, they
+% have to be all the same length. If the actual string is short you have to
+% padd it with spaces.
+%
+% Eugene
+filename = 'hwinit';
+skeleton_filename = 'hwinit_skeleton.m';
+
+if ~exist('filename','var')
+ disp('Use: generate_hwinit([filaname]).');
+ return
+end
+
+[fin,message]=fopen(skeleton_filename,'r');
+if fin==-1
+ disp([' WARNING: Unable to open file :' skeleton_filename]);
+ disp(message);
+ return
+end
+disp([' Reading skeleton file: ' skeleton_filename]);
+skeleton_dir = fileparts(which(skeleton_filename));
+
+filename = appendtimestamp(filename, now);
+[fid,message]=fopen(fullfile(skeleton_dir,[filename '.m']),'w');
+if fid==-1
+ disp([' WARNING: Unable to open file :' filename '.m']);
+ disp(message);
+ return
+end
+disp([' Writing init file to: ' filename '.m']);
+
+% Define some basic parameters and formatting.
+n_cell = 14;
+zeropad = 3;
+namepad = 8;
+chanpad = 24;
+line = '';
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% ION PUMP CONTROLLERS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% name channel name status device el
+% vp={
+% '1vp1 ' 'SR-001-VP1 ' 1 [1,1] 1;...
+while isempty(strfind(upper(line),'INSERT IPC HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for ''INSERT IPC HERE''')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('IPC\n');
+
+n_percell = 3;
+ionPumpFile = 'ionpumps.csv'; % File where PVs for ion pumps are stored.
+pumpPVs = textread(ionPumpFile,'%s');
+
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ name = [num2str(cell) 'IPC' num2str(el_number)]; name = strpad(name, namepad);
+ chname = pumpPVs{(cell-1)*n_percell + i}; chname = strpad(chname, chanpad); % Skip the status pv names
+ stat = 1;
+ fprintf(fid,'''%s''\t''%s''\t%d\t[%d,%d]\t%d\t; ...\n',...
+ name,chname,stat,cell,el_number,i);
+end
+
+while isempty(strfind(upper(line),'INSERT IPC POSITION'))
+ if feof(fin)
+ error('Unexpected eof while looking for ''INSERT IPC POSITION''')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+
+% The position of VP has to be in a column vector
+% base_ipc_positions_per_cell = [0 1.45 4.7661 6.1822 6.9983 8.6144 10.0305 11.3466 12.6627 13.9788];
+base_ipc_positions_per_cell = [0 6.9983 10.0305];
+fprintf(fid,'AO.IPC.Position = [');
+for i=1:n_cell
+ fprintf(fid,'%6.2f ', (i-1)*(216/n_cell) + base_ipc_positions_per_cell);
+ if i ~= n_cell
+ fprintf(fid,'\t...\n\t\t');
+ else
+ fprintf(fid,'\t]'';\n');
+ end
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% GAUGE CONTROLLERS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% name channel name status device el
+% vp={
+% '1vp1 ' 'SR-001-VP1 ' 1 [1,1] 1;...
+while isempty(strfind(upper(line),'INSERT GC HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for ''INSERT GC HERE''')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('GC\n');
+
+n_percell = 5;
+ionPumpFile = 'gauges.csv'; % File where PVs for ion pumps are stored.
+pumpPVs = textread(ionPumpFile,'%s');
+
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ name = [num2str(cell) 'GC' num2str(el_number)]; name = strpad(name, namepad);
+ chname = pumpPVs{(cell-1)*n_percell + i}; chname = strpad(chname, chanpad); % Skip the status pv names
+ stat = 1;
+ fprintf(fid,'''%s''\t''%s''\t%d\t[%d,%d]\t%d\t; ...\n',...
+ name,chname,stat,cell,el_number,i);
+end
+
+while isempty(strfind(upper(line),'INSERT GC POSITION'))
+ if feof(fin)
+ error('Unexpected eof while looking for ''INSERT GC POSITION''')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+
+% The position of VP has to be in a column vector
+% base_ipc_positions_per_cell = [0 1.45 4.7661 6.1822 6.9983 8.6144 10.0305 11.3466 12.6627 13.9788];
+base_ipc_positions_per_cell = [10.0305-0.1, 10.0305, 10.0305+0.1, 12.6627-0.1, 12.6627];
+fprintf(fid,'AO.GC.Position = [');
+for i=1:n_cell
+ fprintf(fid,'%6.2f ', (i-1)*(216/n_cell) + base_ipc_positions_per_cell);
+ if i ~= n_cell
+ fprintf(fid,'\t...\n\t\t');
+ else
+ fprintf(fid,'\t]'';\n');
+ end
+end
+
+% Continue to the end of the skeleton file
+while ~feof(fin)
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+fprintf(fid,'%s',line);
+
+fclose(fid);
+fclose(fin);
+disp('Finished updating hwinit')
+
+
+%========================================
+function str = padzeros(val, charlen)
+
+numstring = num2str(val);
+diff = charlen - length(numstring);
+temp = ' ';
+temp(1:charlen) = ' ';
+if diff > 0
+ temp(1:diff) = '0';
+ temp(diff+1:charlen) = numstring;
+elseif diff == 0
+ temp = numstring;
+elseif diff < 0
+ error(['Increase ''zeropad'' by at least: ' num2str(abs(diff))]);
+end
+
+str = temp;
+
+
+%========================================
+function str = strpad(instring, charlen)
+
+diff = charlen - length(instring);
+temp = ' ';
+temp(1:charlen) = ' ';
+
+if diff > 0
+ temp(1:end-diff) = instring;
+elseif diff == 0
+ temp = instring;
+elseif diff < 0
+ error(['Increase ''space padding'' for names and channel names by at least: ' num2str(abs(diff))]);
+end
+
str = temp;
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/generate_init.m b/machine/ASP/StorageRing/generate_init.m
index 40985a3a..0f9c20d3 100644
--- a/machine/ASP/StorageRing/generate_init.m
+++ b/machine/ASP/StorageRing/generate_init.m
@@ -1,503 +1,503 @@
-function generate_init(filename)
-
-% This function generates some of the more basic and repetitious aspects of
-% creating an init file.
-%
-% Notes: When generating the string elements in the definitions below, they
-% have to be all the same length. If the actual string is short you have to
-% padd it with spaces.
-%
-% Eugene
-% ETan 14/12/04 Changed family names to coincide with controls definition
-% of families.
-% ETan 30/09/05 Added skew quads (SQ) and updated fields to be printed for
-% version 4 of the lattice and ao init file. Cleaned up some of the fields
-% to remove some redudent info that was left over from SPEAR that we don't
-% use.
-% ETan 01/06/06 Updating for new naming convention and the addition of
-% other elements such as FTBPM (first turn bpm). Also removed some fields
-% that are generated, eg range. At ASP most ranges are constant so no need
-% for individual assignment. Removed DeltaResp and moved assignment to the
-% end of the AO element definitions. This is for use with version 5 of the
-% init skeleton file.
-
-filename = 'aspinit';
-skeleton_filename = 'aspinit_v5skeleton.m';
-
-if ~exist('filename','var')
- disp('Use: generate_init([filaname]).');
- return
-end
-
-[fin,message]=fopen(skeleton_filename,'r');
-if fin==-1
- disp([' WARNING: Unable to open file :' skeleton_filename]);
- disp(message);
- return
-end
-disp([' Reading skeleton file: ' skeleton_filename]);
-skeleton_dir = fileparts(which(skeleton_filename));
-
-filename = appendtimestamp(filename, now);
-[fid,message]=fopen(fullfile(skeleton_dir,[filename '.m']),'w');
-if fid==-1
- disp([' WARNING: Unable to open file :' filename '.m']);
- disp(message);
- return
-end
-disp([' Writing init file to: ' filename '.m']);
-
-% Some basic parameters
-n_cell = 14; % Number of repeated sectors
-zeropad = 3; % zero padding for numbers works eqally well with %03d
-namepad = 8; % space padding for common names
-chanpad = 25; % space padding for channel names
-
-line = '';
-
-% Read and insert comment line to tell that the init file "parameters" have
-% been generated from which version of the "skeleton" file.
-while isempty(strfind(line,'% === Generated from ==='))
- if feof(fin)
- error('Unexpected eof while looking for "generated by" header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-fprintf(fid,'%s',line);
-fprintf(fid,'%% %s\n',skeleton_filename);
-line = fgets(fin);
-
-% BPM
-% x-name x-chname xstat y-name y-chname ystat DevList Elem
-% bpm={
-% '1BPMx1 ' 'SR01BPM01:H ' 1 '1BPMy1 ' 'SR01BPM01:V ' 1 [1,1] 1; ...
-while isempty(strfind(upper(line),'INSERT BPM HERE'))
- if feof(fin)
- error('Unexpected eof while looking for BPM header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('BPMs\n');
-n_percell = 7;
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- xname = sprintf('%dBPMx%d',cell,el_number); xname = strpad(xname, namepad);
- xchname = sprintf('SR%02dBPM%02d:SA_HPOS_MONITOR',cell,el_number); xchname = strpad(xchname, chanpad);
- yname = sprintf('%dBPMy%d',cell,el_number); yname = strpad(yname, namepad);
- ychname = sprintf('SR%02dBPM%02d:SA_VPOS_MONITOR',cell,el_number); ychname = strpad(ychname, chanpad);
- xstat = 1; ystat = 1;
- fprintf(fid,'''%s''\t''%s''\t%d\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t; ...\n',...
- xname,xchname,xstat,yname,ychname,ystat,cell,el_number,i);
-end
-
-% BPM
-% x-name x-chname xstat y-name y-chname ystat DevList Elem
-% bpm={
-% '1BPMx1 ' 'SR01BPM01:H ' 1 '1BPMy1 ' 'SR01BPM01:V ' 1 [1,1] 1; ...
-while isempty(strfind(upper(line),'INSERT FT HERE'))
- if feof(fin)
- error('Unexpected eof while looking for FT header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('FT BPMs\n');
-n_percell = 7;
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- xname = sprintf('%dFTx%d',cell,el_number); xname = strpad(xname, namepad);
- xchname = sprintf('SR%02dBPM%02d:FT_HPOS_MONITOR',cell,el_number); xchname = strpad(xchname, chanpad);
- yname = sprintf('%dBPMy%d',cell,el_number); yname = strpad(yname, namepad);
- ychname = sprintf('SR%02dBPM%02d:FT_VPOS_MONITOR',cell,el_number); ychname = strpad(ychname, chanpad);
- xstat = 1; ystat = 1;
- fprintf(fid,'''%s''\t''%s''\t%d\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t; ...\n',...
- xname,xchname,xstat,yname,ychname,ystat,cell,el_number,i);
-end
-
-
-% Correctors
-%
-% NOTE: CHANGED THE STRUCTURE OF THE DEFINITION OF THE CORRECTRO MAGNETS.
-% SPEAR USES INDIVIDUAL CORRECTORS THAT CAN BE CONFIGURED TO BE USED AS
-% EITHER HORIZONTAL OR VERTICAL CORRECTORS. ASP CORRECTORS ARE BUILT INTO
-% THE SEXTUPOLES AND ARE EFFICEVELY FIXED. THERE ARE 42 HORIZONTAL
-% CORRECTORS AND 56 VERTICAL CORRECTORS.
-%
-% HW in ampere, Physics in radian. Respmat settings below AO definitions.
-% x-common x-monitor x-setpoint stat devlist elem tol
-% cor={
-% '1CX1 ' 'SR01CPS01:CURRENT_MONITOR' 'SR01CPS01:CURRENT_SP' 1
-% '1CY1 ' 'SR01CPS02:CURRENT_MONITOR' 'SR01CPS02:CURRENT_SP' 1 [1 ,1] 1 0.750 ; ...
-
-while isempty(strfind(upper(line),'INSERT HCM HERE'))
- if feof(fin)
- error('Unexpected eof while looking for HCM header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('HCM\n');
-
-n_percell = 3;
-vec = [1 5 9];
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- xname = [num2str(cell) 'HCM' num2str(el_number)]; xname = strpad(xname, namepad);
- xmon = sprintf('SR%02dCPS%02d:CURRENT_MONITOR',cell, vec(el_number)); xmon = strpad(xmon, chanpad);
- xset = sprintf('SR%02dCPS%02d:CURRENT_SP',cell, vec(el_number)); xset = strpad(xset, chanpad);
- xstat = 1;
- % Range in amps and the response amplitude kicks are in radians.
- tol = 1;
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%5.3f\t; ...\n',...
- xname,xmon,xset,xstat,cell,el_number,i,tol);
-end
-
-while isempty(strfind(upper(line),'INSERT VCM HERE'))
- if feof(fin)
- error('Unexpected eof while looking for VCM header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('VCM\n');
-
-n_percell = 4;
-vec = [2 4 6 7];
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- yname = [num2str(cell) 'VCM' num2str(el_number)]; yname = strpad(yname, namepad);
- ymon = sprintf('SR%02dCPS%02d:CURRENT_MONITOR',cell, vec(el_number)); ymon = strpad(ymon, chanpad);
- yset = sprintf('SR%02dCPS%02d:CURRENT_SP',cell, vec(el_number)); yset = strpad(yset, chanpad);
- ystat = 1;
- % Range in amps and the response amplitude kicks are in radians.
- tol = 1;
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%5.3f\t; ...\n',...
- yname,ymon,yset,ystat,cell,el_number,i,tol);
-end
-
-
-% Magnets
-%common desired monitor setpoint stat devlist elem scalefactor range tol respkick
-% bend={
-% '1BEND1 ' 'SR-BD:CurrSetptDes ' 'SR-BD:Curr ' 'SR-BD:CurrSetpt ' 1 [1 ,1] 1 1.0 [0, 500] 0.050 0.05 ; ...
-while isempty(strfind(upper(line),'INSERT BEND HERE'))
- if feof(fin)
- error('Unexpected eof while looking for BEND header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('BEND\n');
-n_percell = 2;
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- name = [num2str(cell) 'BEND' num2str(el_number)]; name = strpad(name, namepad);
- monitor = 'SR00DPS01:CURRENT_MONITOR'; monitor = strpad(monitor, chanpad);
- setpoint= 'SR00DPS01:CURRENT_SP'; setpoint = strpad(setpoint, chanpad);
- stat = 1;
- scalefactor_tol = '1.0 0.05';
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
- name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
-end
-
-%common desired monitor setpoint stat devlist elem scalefactor range tol respkick
-% qf={
-% '2QF1 ' 'MS1-QF:CurrSetptDes ' 'MS1-QF:Curr ' 'MS1-QF:CurrSetpt ' 1 [2 ,1] 1 qf1to6factor [0, 500] 0.050 0.05; ...
-while isempty(strfind(upper(line),'INSERT QFA HERE'))
- if feof(fin)
- error('Unexpected eof while looking for QFA header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('QFA\n');
-n_percell = 2;
-vec = [1 6];
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- name = [num2str(cell) 'QFA' num2str(el_number)]; name = strpad(name, namepad);
- monitor = sprintf('SR%02dQPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
- setpoint = sprintf('SR%02dQPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
- stat = 1;
- scalefactor_tol = '1.0 0.05';
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
- name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
-end
-while isempty(strfind(upper(line),'INSERT QDA HERE'))
- if feof(fin)
- error('Unexpected eof while looking for QDB header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('QDA\n');
-n_percell = 2;
-vec = [2 5];
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- name = [num2str(cell) 'QDA' num2str(el_number)]; name = strpad(name, namepad);
- monitor = sprintf('SR%02dQPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
- setpoint = sprintf('SR%02dQPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
- stat = 1;
- scalefactor_tol = '1.0 0.05';
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
- name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
-end
-while isempty(strfind(upper(line),'INSERT QFB HERE'))
- if feof(fin)
- error('Unexpected eof while looking for QFB header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('QFB\n');
-n_percell = 2;
-vec = [3 4];
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- name = [num2str(cell) 'QFB' num2str(el_number)]; name = strpad(name, namepad);
- monitor = sprintf('SR%02dQPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
- setpoint = sprintf('SR%02dQPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
- stat = 1;
- scalefactor_tol = '1.0 0.05';
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
- name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
-end
-
-% Sextupole
-while isempty(strfind(upper(line),'INSERT SFA HERE'))
- if feof(fin)
- error('Unexpected eof while looking for SFA header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('SFA\n');
-n_percell = 2;
-vec = [1 7];
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- name = [num2str(cell) 'SFA' num2str(el_number)]; name = strpad(name, namepad);
- monitor = sprintf('SR%02dSPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
- setpoint = sprintf('SR%02dSPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
- stat = 1;
- scalefactor_tol = '1.0 0.05';
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
- name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
-end
-while isempty(strfind(upper(line),'INSERT SDA HERE'))
- if feof(fin)
- error('Unexpected eof while looking for SDA header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('SDA\n');
-n_percell = 2;
-vec = [2 6];
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- name = [num2str(cell) 'SDA' num2str(el_number)]; name = strpad(name, namepad);
- monitor = sprintf('SR%02dSPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
- setpoint = sprintf('SR%02dSPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
- stat = 1;
- scalefactor_tol = '1.0 0.05';
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
- name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
-end
-while isempty(strfind(upper(line),'INSERT SDB HERE'))
- if feof(fin)
- error('Unexpected eof while looking for SDB header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('SDB\n');
-n_percell = 2;
-vec = [3 5];
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- name = [num2str(cell) 'SDB' num2str(el_number)]; name = strpad(name, namepad);
- monitor = sprintf('SR%02dSPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
- setpoint = sprintf('SR%02dSPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
- stat = 1;
- scalefactor_tol = '1.0 0.05';
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
- name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
-end
-while isempty(strfind(upper(line),'INSERT SFB HERE'))
- if feof(fin)
- error('Unexpected eof while looking for SFB header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('SFB\n');
-n_percell = 1;
-vec = [4];
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- name = [num2str(cell) 'SFB' num2str(el_number)]; name = strpad(name, namepad);
- monitor = sprintf('SR%02dSPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
- setpoint = sprintf('SR%02dSPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
- stat = 1;
- scalefactor_tol = '1.0 0.05';
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
- name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
-end
-
-% skew quadrupoles
-while isempty(strfind(upper(line),'INSERT SKQ HERE'))
- if feof(fin)
- error('Unexpected eof while looking for SKQ header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('SKQ\n');
-n_percell = 2;
-vec = [3 8];
-ntotal = n_percell*n_cell;
-for i=1:ntotal
- cell = ceil(i/n_percell);
- el_number = mod(i,n_percell);
- if el_number == 0 el_number = n_percell; end
- yname = [num2str(cell) 'SKQ' num2str(el_number)]; yname = strpad(yname, namepad);
- ymon = sprintf('SR%02dCPS%02d:CURRENT_MONITOR',cell, vec(el_number)); ymon = strpad(ymon, chanpad);
- yset = sprintf('SR%02dCPS%02d:CURRENT_SP',cell, vec(el_number)); yset = strpad(yset, chanpad);
- ystat = 1;
- % Range in amps and the response amplitude kicks are in radians.
- tol = '1';
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
- yname,ymon,yset,ystat,cell,el_number,i,tol);
-end
-
-% Kickers
-%common monitor setpoint stat devlist elem range tol
-% kickeramp={
-% 'KICK1 ' 'SR-014-K1:PulseAmpl ' 'SR-014-K1:PulseAmplSetpt ' 1 [1 ,1] 1 [0 9] 0.10 ; ...
-% 'KICK2 ' 'SR-014-K2:PulseAmpl ' 'SR-014-K2:PulseAmplSetpt ' 1 [1 ,2] 2 [0 9] 0.10 ; ...
-% 'KICK3 ' 'SR-001-K3:PulseAmpl ' 'SR-001-K3:PulseAmplSetpt ' 1 [1 ,3] 3 [0 9] 0.10 ; ...
-% 'KICK4 ' 'SR-001-K4:PulseAmpl ' 'SR-001-K4:PulseAmplSetpt ' 1 [1 ,4] 4 [0 9] 0.10 ; ...
-% };
-while isempty(strfind(upper(line),'INSERT KICKERS HERE'))
- if feof(fin)
- error('Unexpected eof while looking for SFB header.')
- end
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-line = '';
-fprintf('KICKERS\n');
-n_kickers = 4;
-sec = [14 1 1 2];
-vec = [1 1 2 1];
-for i=1:n_kickers
- name = ['KICK' num2str(i)]; name = strpad(name, namepad);
- monitor = sprintf('SR%02dKPS%02d:VOLTAGE_MONITOR',sec(i), vec(i)); monitor = strpad(monitor, chanpad);
- setpoint = sprintf('SR%02dKPS%02d:VOLTAGE_SP',sec(i), vec(i)); setpoint = strpad(setpoint, chanpad);
- stat = 1;
- tol = '0.10';
- fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
- name,monitor,setpoint,stat,1,i,i,tol);
-end
-
-
-% Continue to the end of the skeleton file
-while ~feof(fin)
- fprintf(fid,'%s',line);
- line = fgets(fin);
-end
-fprintf(fid,'%s',line);
-
-fclose(fid);
-fclose(fin);
-disp(['Finished updating ' filename])
-
-
-%========================================
-function str = padzeros(val, charlen)
-
-numstring = num2str(val);
-diff = charlen - length(numstring);
-temp = ' ';
-temp(1:charlen) = ' ';
-if diff > 0
- temp(1:diff) = '0';
- temp(diff+1:charlen) = numstring;
-elseif diff == 0
- temp = numstring;
-elseif diff < 0
- error(['Increase ''zeropad'' by at least: ' num2str(abs(diff))]);
-end
-
-str = temp;
-
-
-%========================================
-function str = strpad(instring, charlen)
-
-diff = charlen - length(instring);
-temp = ' ';
-temp(1:charlen) = ' ';
-
-if diff > 0
- temp(1:end-diff) = instring;
-elseif diff == 0
- temp = instring;
-elseif diff < 0
- error(['Increase ''space padding'' for names and channel names by at least: ' num2str(abs(diff))]);
-end
-
+function generate_init(filename)
+
+% This function generates some of the more basic and repetitious aspects of
+% creating an init file.
+%
+% Notes: When generating the string elements in the definitions below, they
+% have to be all the same length. If the actual string is short you have to
+% padd it with spaces.
+%
+% Eugene
+% ETan 14/12/04 Changed family names to coincide with controls definition
+% of families.
+% ETan 30/09/05 Added skew quads (SQ) and updated fields to be printed for
+% version 4 of the lattice and ao init file. Cleaned up some of the fields
+% to remove some redudent info that was left over from SPEAR that we don't
+% use.
+% ETan 01/06/06 Updating for new naming convention and the addition of
+% other elements such as FTBPM (first turn bpm). Also removed some fields
+% that are generated, eg range. At ASP most ranges are constant so no need
+% for individual assignment. Removed DeltaResp and moved assignment to the
+% end of the AO element definitions. This is for use with version 5 of the
+% init skeleton file.
+
+filename = 'aspinit';
+skeleton_filename = 'aspinit_v5skeleton.m';
+
+if ~exist('filename','var')
+ disp('Use: generate_init([filaname]).');
+ return
+end
+
+[fin,message]=fopen(skeleton_filename,'r');
+if fin==-1
+ disp([' WARNING: Unable to open file :' skeleton_filename]);
+ disp(message);
+ return
+end
+disp([' Reading skeleton file: ' skeleton_filename]);
+skeleton_dir = fileparts(which(skeleton_filename));
+
+filename = appendtimestamp(filename, now);
+[fid,message]=fopen(fullfile(skeleton_dir,[filename '.m']),'w');
+if fid==-1
+ disp([' WARNING: Unable to open file :' filename '.m']);
+ disp(message);
+ return
+end
+disp([' Writing init file to: ' filename '.m']);
+
+% Some basic parameters
+n_cell = 14; % Number of repeated sectors
+zeropad = 3; % zero padding for numbers works eqally well with %03d
+namepad = 8; % space padding for common names
+chanpad = 25; % space padding for channel names
+
+line = '';
+
+% Read and insert comment line to tell that the init file "parameters" have
+% been generated from which version of the "skeleton" file.
+while isempty(strfind(line,'% === Generated from ==='))
+ if feof(fin)
+ error('Unexpected eof while looking for "generated by" header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+fprintf(fid,'%s',line);
+fprintf(fid,'%% %s\n',skeleton_filename);
+line = fgets(fin);
+
+% BPM
+% x-name x-chname xstat y-name y-chname ystat DevList Elem
+% bpm={
+% '1BPMx1 ' 'SR01BPM01:H ' 1 '1BPMy1 ' 'SR01BPM01:V ' 1 [1,1] 1; ...
+while isempty(strfind(upper(line),'INSERT BPM HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for BPM header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('BPMs\n');
+n_percell = 7;
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ xname = sprintf('%dBPMx%d',cell,el_number); xname = strpad(xname, namepad);
+ xchname = sprintf('SR%02dBPM%02d:SA_HPOS_MONITOR',cell,el_number); xchname = strpad(xchname, chanpad);
+ yname = sprintf('%dBPMy%d',cell,el_number); yname = strpad(yname, namepad);
+ ychname = sprintf('SR%02dBPM%02d:SA_VPOS_MONITOR',cell,el_number); ychname = strpad(ychname, chanpad);
+ xstat = 1; ystat = 1;
+ fprintf(fid,'''%s''\t''%s''\t%d\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t; ...\n',...
+ xname,xchname,xstat,yname,ychname,ystat,cell,el_number,i);
+end
+
+% BPM
+% x-name x-chname xstat y-name y-chname ystat DevList Elem
+% bpm={
+% '1BPMx1 ' 'SR01BPM01:H ' 1 '1BPMy1 ' 'SR01BPM01:V ' 1 [1,1] 1; ...
+while isempty(strfind(upper(line),'INSERT FT HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for FT header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('FT BPMs\n');
+n_percell = 7;
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ xname = sprintf('%dFTx%d',cell,el_number); xname = strpad(xname, namepad);
+ xchname = sprintf('SR%02dBPM%02d:FT_HPOS_MONITOR',cell,el_number); xchname = strpad(xchname, chanpad);
+ yname = sprintf('%dBPMy%d',cell,el_number); yname = strpad(yname, namepad);
+ ychname = sprintf('SR%02dBPM%02d:FT_VPOS_MONITOR',cell,el_number); ychname = strpad(ychname, chanpad);
+ xstat = 1; ystat = 1;
+ fprintf(fid,'''%s''\t''%s''\t%d\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t; ...\n',...
+ xname,xchname,xstat,yname,ychname,ystat,cell,el_number,i);
+end
+
+
+% Correctors
+%
+% NOTE: CHANGED THE STRUCTURE OF THE DEFINITION OF THE CORRECTRO MAGNETS.
+% SPEAR USES INDIVIDUAL CORRECTORS THAT CAN BE CONFIGURED TO BE USED AS
+% EITHER HORIZONTAL OR VERTICAL CORRECTORS. ASP CORRECTORS ARE BUILT INTO
+% THE SEXTUPOLES AND ARE EFFICEVELY FIXED. THERE ARE 42 HORIZONTAL
+% CORRECTORS AND 56 VERTICAL CORRECTORS.
+%
+% HW in ampere, Physics in radian. Respmat settings below AO definitions.
+% x-common x-monitor x-setpoint stat devlist elem tol
+% cor={
+% '1CX1 ' 'SR01CPS01:CURRENT_MONITOR' 'SR01CPS01:CURRENT_SP' 1
+% '1CY1 ' 'SR01CPS02:CURRENT_MONITOR' 'SR01CPS02:CURRENT_SP' 1 [1 ,1] 1 0.750 ; ...
+
+while isempty(strfind(upper(line),'INSERT HCM HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for HCM header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('HCM\n');
+
+n_percell = 3;
+vec = [1 5 9];
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ xname = [num2str(cell) 'HCM' num2str(el_number)]; xname = strpad(xname, namepad);
+ xmon = sprintf('SR%02dCPS%02d:CURRENT_MONITOR',cell, vec(el_number)); xmon = strpad(xmon, chanpad);
+ xset = sprintf('SR%02dCPS%02d:CURRENT_SP',cell, vec(el_number)); xset = strpad(xset, chanpad);
+ xstat = 1;
+ % Range in amps and the response amplitude kicks are in radians.
+ tol = 1;
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%5.3f\t; ...\n',...
+ xname,xmon,xset,xstat,cell,el_number,i,tol);
+end
+
+while isempty(strfind(upper(line),'INSERT VCM HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for VCM header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('VCM\n');
+
+n_percell = 4;
+vec = [2 4 6 7];
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ yname = [num2str(cell) 'VCM' num2str(el_number)]; yname = strpad(yname, namepad);
+ ymon = sprintf('SR%02dCPS%02d:CURRENT_MONITOR',cell, vec(el_number)); ymon = strpad(ymon, chanpad);
+ yset = sprintf('SR%02dCPS%02d:CURRENT_SP',cell, vec(el_number)); yset = strpad(yset, chanpad);
+ ystat = 1;
+ % Range in amps and the response amplitude kicks are in radians.
+ tol = 1;
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%5.3f\t; ...\n',...
+ yname,ymon,yset,ystat,cell,el_number,i,tol);
+end
+
+
+% Magnets
+%common desired monitor setpoint stat devlist elem scalefactor range tol respkick
+% bend={
+% '1BEND1 ' 'SR-BD:CurrSetptDes ' 'SR-BD:Curr ' 'SR-BD:CurrSetpt ' 1 [1 ,1] 1 1.0 [0, 500] 0.050 0.05 ; ...
+while isempty(strfind(upper(line),'INSERT BEND HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for BEND header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('BEND\n');
+n_percell = 2;
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ name = [num2str(cell) 'BEND' num2str(el_number)]; name = strpad(name, namepad);
+ monitor = 'SR00DPS01:CURRENT_MONITOR'; monitor = strpad(monitor, chanpad);
+ setpoint= 'SR00DPS01:CURRENT_SP'; setpoint = strpad(setpoint, chanpad);
+ stat = 1;
+ scalefactor_tol = '1.0 0.05';
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
+ name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
+end
+
+%common desired monitor setpoint stat devlist elem scalefactor range tol respkick
+% qf={
+% '2QF1 ' 'MS1-QF:CurrSetptDes ' 'MS1-QF:Curr ' 'MS1-QF:CurrSetpt ' 1 [2 ,1] 1 qf1to6factor [0, 500] 0.050 0.05; ...
+while isempty(strfind(upper(line),'INSERT QFA HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for QFA header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('QFA\n');
+n_percell = 2;
+vec = [1 6];
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ name = [num2str(cell) 'QFA' num2str(el_number)]; name = strpad(name, namepad);
+ monitor = sprintf('SR%02dQPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
+ setpoint = sprintf('SR%02dQPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
+ stat = 1;
+ scalefactor_tol = '1.0 0.05';
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
+ name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
+end
+while isempty(strfind(upper(line),'INSERT QDA HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for QDB header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('QDA\n');
+n_percell = 2;
+vec = [2 5];
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ name = [num2str(cell) 'QDA' num2str(el_number)]; name = strpad(name, namepad);
+ monitor = sprintf('SR%02dQPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
+ setpoint = sprintf('SR%02dQPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
+ stat = 1;
+ scalefactor_tol = '1.0 0.05';
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
+ name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
+end
+while isempty(strfind(upper(line),'INSERT QFB HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for QFB header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('QFB\n');
+n_percell = 2;
+vec = [3 4];
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ name = [num2str(cell) 'QFB' num2str(el_number)]; name = strpad(name, namepad);
+ monitor = sprintf('SR%02dQPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
+ setpoint = sprintf('SR%02dQPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
+ stat = 1;
+ scalefactor_tol = '1.0 0.05';
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
+ name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
+end
+
+% Sextupole
+while isempty(strfind(upper(line),'INSERT SFA HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for SFA header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('SFA\n');
+n_percell = 2;
+vec = [1 7];
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ name = [num2str(cell) 'SFA' num2str(el_number)]; name = strpad(name, namepad);
+ monitor = sprintf('SR%02dSPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
+ setpoint = sprintf('SR%02dSPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
+ stat = 1;
+ scalefactor_tol = '1.0 0.05';
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
+ name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
+end
+while isempty(strfind(upper(line),'INSERT SDA HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for SDA header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('SDA\n');
+n_percell = 2;
+vec = [2 6];
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ name = [num2str(cell) 'SDA' num2str(el_number)]; name = strpad(name, namepad);
+ monitor = sprintf('SR%02dSPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
+ setpoint = sprintf('SR%02dSPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
+ stat = 1;
+ scalefactor_tol = '1.0 0.05';
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
+ name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
+end
+while isempty(strfind(upper(line),'INSERT SDB HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for SDB header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('SDB\n');
+n_percell = 2;
+vec = [3 5];
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ name = [num2str(cell) 'SDB' num2str(el_number)]; name = strpad(name, namepad);
+ monitor = sprintf('SR%02dSPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
+ setpoint = sprintf('SR%02dSPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
+ stat = 1;
+ scalefactor_tol = '1.0 0.05';
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
+ name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
+end
+while isempty(strfind(upper(line),'INSERT SFB HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for SFB header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('SFB\n');
+n_percell = 1;
+vec = [4];
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ name = [num2str(cell) 'SFB' num2str(el_number)]; name = strpad(name, namepad);
+ monitor = sprintf('SR%02dSPS%02d:CURRENT_MONITOR',cell, vec(el_number)); monitor = strpad(monitor, chanpad);
+ setpoint = sprintf('SR%02dSPS%02d:CURRENT_SP',cell, vec(el_number)); setpoint = strpad(setpoint, chanpad);
+ stat = 1;
+ scalefactor_tol = '1.0 0.05';
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
+ name,monitor,setpoint,stat,cell,el_number,i,scalefactor_tol);
+end
+
+% skew quadrupoles
+while isempty(strfind(upper(line),'INSERT SKQ HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for SKQ header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('SKQ\n');
+n_percell = 2;
+vec = [3 8];
+ntotal = n_percell*n_cell;
+for i=1:ntotal
+ cell = ceil(i/n_percell);
+ el_number = mod(i,n_percell);
+ if el_number == 0 el_number = n_percell; end
+ yname = [num2str(cell) 'SKQ' num2str(el_number)]; yname = strpad(yname, namepad);
+ ymon = sprintf('SR%02dCPS%02d:CURRENT_MONITOR',cell, vec(el_number)); ymon = strpad(ymon, chanpad);
+ yset = sprintf('SR%02dCPS%02d:CURRENT_SP',cell, vec(el_number)); yset = strpad(yset, chanpad);
+ ystat = 1;
+ % Range in amps and the response amplitude kicks are in radians.
+ tol = '1';
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
+ yname,ymon,yset,ystat,cell,el_number,i,tol);
+end
+
+% Kickers
+%common monitor setpoint stat devlist elem range tol
+% kickeramp={
+% 'KICK1 ' 'SR-014-K1:PulseAmpl ' 'SR-014-K1:PulseAmplSetpt ' 1 [1 ,1] 1 [0 9] 0.10 ; ...
+% 'KICK2 ' 'SR-014-K2:PulseAmpl ' 'SR-014-K2:PulseAmplSetpt ' 1 [1 ,2] 2 [0 9] 0.10 ; ...
+% 'KICK3 ' 'SR-001-K3:PulseAmpl ' 'SR-001-K3:PulseAmplSetpt ' 1 [1 ,3] 3 [0 9] 0.10 ; ...
+% 'KICK4 ' 'SR-001-K4:PulseAmpl ' 'SR-001-K4:PulseAmplSetpt ' 1 [1 ,4] 4 [0 9] 0.10 ; ...
+% };
+while isempty(strfind(upper(line),'INSERT KICKERS HERE'))
+ if feof(fin)
+ error('Unexpected eof while looking for SFB header.')
+ end
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+line = '';
+fprintf('KICKERS\n');
+n_kickers = 4;
+sec = [14 1 1 2];
+vec = [1 1 2 1];
+for i=1:n_kickers
+ name = ['KICK' num2str(i)]; name = strpad(name, namepad);
+ monitor = sprintf('SR%02dKPS%02d:VOLTAGE_MONITOR',sec(i), vec(i)); monitor = strpad(monitor, chanpad);
+ setpoint = sprintf('SR%02dKPS%02d:VOLTAGE_SP',sec(i), vec(i)); setpoint = strpad(setpoint, chanpad);
+ stat = 1;
+ tol = '0.10';
+ fprintf(fid,'''%s''\t''%s''\t''%s''\t%d\t[%d,%d]\t%d\t%s\t; ...\n',...
+ name,monitor,setpoint,stat,1,i,i,tol);
+end
+
+
+% Continue to the end of the skeleton file
+while ~feof(fin)
+ fprintf(fid,'%s',line);
+ line = fgets(fin);
+end
+fprintf(fid,'%s',line);
+
+fclose(fid);
+fclose(fin);
+disp(['Finished updating ' filename])
+
+
+%========================================
+function str = padzeros(val, charlen)
+
+numstring = num2str(val);
+diff = charlen - length(numstring);
+temp = ' ';
+temp(1:charlen) = ' ';
+if diff > 0
+ temp(1:diff) = '0';
+ temp(diff+1:charlen) = numstring;
+elseif diff == 0
+ temp = numstring;
+elseif diff < 0
+ error(['Increase ''zeropad'' by at least: ' num2str(abs(diff))]);
+end
+
+str = temp;
+
+
+%========================================
+function str = strpad(instring, charlen)
+
+diff = charlen - length(instring);
+temp = ' ';
+temp(1:charlen) = ' ';
+
+if diff > 0
+ temp(1:end-diff) = instring;
+elseif diff == 0
+ temp = instring;
+elseif diff < 0
+ error(['Increase ''space padding'' for names and channel names by at least: ' num2str(abs(diff))]);
+end
+
str = temp;
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/getemit.m b/machine/ASP/StorageRing/getemit.m
index cc729cf2..ec4cedee 100644
--- a/machine/ASP/StorageRing/getemit.m
+++ b/machine/ASP/StorageRing/getemit.m
@@ -1,82 +1,82 @@
-function gemit
-%
-% INPUTS
-% 1. RING = e.g. THERING, or RINGData.Lattice from LOCO file.
-
-%GLOBVAL.E0 = 2.80e9;
-
-global THERING;
-
-THERING1 = THERING;
-
-%Change the integration method for Ohmi calculation
-% BENDINDEX = findcells(THERING1, 'PassMethod', 'BendLinearPass');
-% for i = BENDINDEX
-% THERING1{i}.PassMethod = 'BndMPoleSymplectic4RadPass';
-% THERING1{i}.NumIntSteps = 30;
-% if THERING1{i}.K ~= THERING1{i}.PolynomB(2)
-% THERING1{i}.K = THERING1{i}.PolynomB(2);
-% end
-% end
-%
-% QUADINDEX = findcells(THERING1, 'PassMethod', 'QuadLinearPass');
-% for i = QUADINDEX
-% THERING1{i}.PassMethod = 'StrMPoleSymplectic4RadPass';
-% THERING1{i}.NumIntSteps = 30;
-% if THERING1{i}.K ~= THERING1{i}.PolynomB(2)
-% THERING1{i}.PolynomB(2)= THERING1{i}.K;
-% end
-% end
-%
-% SEXTINDEX = findcells(THERING1,'PassMethod', 'StrMPoleSymplectic4Pass');
-% for i = SEXTINDEX
-% THERING1{i}.PassMethod = 'StrMPoleSymplectic4RadPass';
-% end
-
-BENDINDEX = findcells(THERING1, 'PassMethod', 'BndMPoleSymplectic4Pass');
-THERING1 = setcellstruct(THERING1,'PassMethod',BENDINDEX, 'BndMPoleSymplectic4RadPass');
-THERING1 = setcellstruct(THERING1,'Energy',BENDINDEX, 3e9);
-
-QUADINDEX = findcells(THERING1, 'PassMethod', 'QuadLinearPass');
-THERING1 = setcellstruct(THERING1,'PassMethod',QUADINDEX, 'StrMPoleSymplectic4RadPass');
-THERING1 = setcellstruct(THERING1,'Energy',QUADINDEX, 3e9);
-
-SEXTINDEX = findcells(THERING1,'PassMethod', 'StrMPoleSymplectic4Pass');
-THERING1 = setcellstruct(THERING1,'PassMethod',SEXTINDEX, 'StrMPoleSymplectic4RadPass');
-THERING1 = setcellstruct(THERING1,'Energy',SEXTINDEX, 3e9);
-
-RADELEMINDEX = sort([BENDINDEX QUADINDEX SEXTINDEX]);
-
-[ENV, sigP, DL] = ohmienvelope(THERING1, RADELEMINDEX, 1:length(THERING1)+1)
-sigmas = cat(2, ENV.Sigma); tilt = cat(2, ENV.Tilt);
-spos = findspos(THERING1, 1:length(THERING1)+1);
-
-figure(1);
-plot(spos, tilt*180/pi, '.-');
-title('Beam Ellipse Rotation Angle [degrees]');
-set(gca, 'XLim', [0 spos(end)]);
-xlabel('s-position [m]');
-
-figure(2);
-plot(spos, sigmas(1, :));
-title('Beam Ellipse Principal Axis [m]');
-xlabel('s-position [m]'); ylabel('Beam Size [m]');
-
-% Get emittance from sigmax
-refpts = 1:length(THERING1)+1;
-[TwissData, tune, chrom] = twissring(THERING1, 0, refpts, 'chrom');
-for i = 1:length(refpts)
- betax(i) = TwissData(i).beta(1); etax(i) = TwissData(i).Dispersion(1);
- betay(i) = TwissData(i).beta(2); etay(i) = TwissData(i).Dispersion(2);
-end
-epsx = (sigmas(1,:).^2 - sigP^2.*etax.^2)./betax;
-epsy = (sigmas(2,:).^2 - sigP^2.*etay.^2)./betay;
-figure(3);
-plot(spos, epsx);
-title('Horizontal Emittance vs. s')
-
-figure(4);
-plot(spos, epsy);
-title('Vertical Emittance vs. s')
-
+function gemit
+%
+% INPUTS
+% 1. RING = e.g. THERING, or RINGData.Lattice from LOCO file.
+
+%GLOBVAL.E0 = 2.80e9;
+
+global THERING;
+
+THERING1 = THERING;
+
+%Change the integration method for Ohmi calculation
+% BENDINDEX = findcells(THERING1, 'PassMethod', 'BendLinearPass');
+% for i = BENDINDEX
+% THERING1{i}.PassMethod = 'BndMPoleSymplectic4RadPass';
+% THERING1{i}.NumIntSteps = 30;
+% if THERING1{i}.K ~= THERING1{i}.PolynomB(2)
+% THERING1{i}.K = THERING1{i}.PolynomB(2);
+% end
+% end
+%
+% QUADINDEX = findcells(THERING1, 'PassMethod', 'QuadLinearPass');
+% for i = QUADINDEX
+% THERING1{i}.PassMethod = 'StrMPoleSymplectic4RadPass';
+% THERING1{i}.NumIntSteps = 30;
+% if THERING1{i}.K ~= THERING1{i}.PolynomB(2)
+% THERING1{i}.PolynomB(2)= THERING1{i}.K;
+% end
+% end
+%
+% SEXTINDEX = findcells(THERING1,'PassMethod', 'StrMPoleSymplectic4Pass');
+% for i = SEXTINDEX
+% THERING1{i}.PassMethod = 'StrMPoleSymplectic4RadPass';
+% end
+
+BENDINDEX = findcells(THERING1, 'PassMethod', 'BndMPoleSymplectic4Pass');
+THERING1 = setcellstruct(THERING1,'PassMethod',BENDINDEX, 'BndMPoleSymplectic4RadPass');
+THERING1 = setcellstruct(THERING1,'Energy',BENDINDEX, 3e9);
+
+QUADINDEX = findcells(THERING1, 'PassMethod', 'QuadLinearPass');
+THERING1 = setcellstruct(THERING1,'PassMethod',QUADINDEX, 'StrMPoleSymplectic4RadPass');
+THERING1 = setcellstruct(THERING1,'Energy',QUADINDEX, 3e9);
+
+SEXTINDEX = findcells(THERING1,'PassMethod', 'StrMPoleSymplectic4Pass');
+THERING1 = setcellstruct(THERING1,'PassMethod',SEXTINDEX, 'StrMPoleSymplectic4RadPass');
+THERING1 = setcellstruct(THERING1,'Energy',SEXTINDEX, 3e9);
+
+RADELEMINDEX = sort([BENDINDEX QUADINDEX SEXTINDEX]);
+
+[ENV, sigP, DL] = ohmienvelope(THERING1, RADELEMINDEX, 1:length(THERING1)+1)
+sigmas = cat(2, ENV.Sigma); tilt = cat(2, ENV.Tilt);
+spos = findspos(THERING1, 1:length(THERING1)+1);
+
+figure(1);
+plot(spos, tilt*180/pi, '.-');
+title('Beam Ellipse Rotation Angle [degrees]');
+set(gca, 'XLim', [0 spos(end)]);
+xlabel('s-position [m]');
+
+figure(2);
+plot(spos, sigmas(1, :));
+title('Beam Ellipse Principal Axis [m]');
+xlabel('s-position [m]'); ylabel('Beam Size [m]');
+
+% Get emittance from sigmax
+refpts = 1:length(THERING1)+1;
+[TwissData, tune, chrom] = twissring(THERING1, 0, refpts, 'chrom');
+for i = 1:length(refpts)
+ betax(i) = TwissData(i).beta(1); etax(i) = TwissData(i).Dispersion(1);
+ betay(i) = TwissData(i).beta(2); etay(i) = TwissData(i).Dispersion(2);
+end
+epsx = (sigmas(1,:).^2 - sigP^2.*etax.^2)./betax;
+epsy = (sigmas(2,:).^2 - sigP^2.*etay.^2)./betay;
+figure(3);
+plot(spos, epsx);
+title('Horizontal Emittance vs. s')
+
+figure(4);
+plot(spos, epsy);
+title('Vertical Emittance vs. s')
+
clear THERING1;
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/getkey.m b/machine/ASP/StorageRing/getkey.m
index 6becc445..7055c803 100644
--- a/machine/ASP/StorageRing/getkey.m
+++ b/machine/ASP/StorageRing/getkey.m
@@ -1,62 +1,62 @@
-function ch = getkey(m)
-
-% GETKEY - get a single keypress
-% CH = GETKEY waits for a keypress and returns the ASCII code. Accepts
-% all ascii characters, including backspace (8), space (32), enter (13),
-% etc, that can be typed on the keyboard. CH is a double.
-%
-% CH = GETKEY('non-ascii') uses non-documented matlab 6.5 features to
-% return a string describing the key pressed so keys like ctrl, alt, tab
-% etc. can also be used. CH is a string.
-%
-% This function is kind of a workaround for getch in C. It uses a modal, but
-% non-visible window, which does show up in the taskbar.
-% C-language keywords: KBHIT, KEYPRESS, GETKEY, GETCH
-%
-% Examples:
-%
-% fprintf('\nPress any key: ') ;
-% ch = getkey ;
-% fprintf('%c\n',ch) ;
-%
-% fprintf('\nPress the Ctrl-key: ') ;
-% if strcmp(getkey('non-ascii'),'control'),
-% fprintf('OK\n') ;
-% else
-% fprintf(' ... wrong key ...\n') ;
-% end
-%
-% See also INPUT, CHAR
-
-% (c) 2005 Jos
-% email jos @ jasen .nl
-% Feel free to (ab)use, modify or change this contribution
-
-
-% Determine the callback string to use
-if nargin == 1,
- if strcmp(lower(m),'non-ascii'),
- callstr = ['set(gcbf,''Userdata'',get(gcbf,''Currentkey'')) ; uiresume '] ;
- else
- error('Argument should be the string ''non-ascii''') ;
- end
-else
- callstr = ['set(gcbf,''Userdata'',double(get(gcbf,''Currentcharacter''))) ; uiresume '] ;
-end
-
-% Set up the figure
-% May be the position property should be individually tweaked to avoid visibility
-fh = figure('keypressfcn',callstr, ...
- 'windowstyle','modal',...
- 'position',[0 0 1 1],...
- 'Name','GETKEY', ...
- 'userdata','timeout') ;
-try
- % Wait for something to happen
- uiwait ;
- ch = get(fh,'Userdata') ;
-catch
- % Something went wrong, return and empty matrix.
- ch = [] ;
-end
-close(fh) ;
+function ch = getkey(m)
+
+% GETKEY - get a single keypress
+% CH = GETKEY waits for a keypress and returns the ASCII code. Accepts
+% all ascii characters, including backspace (8), space (32), enter (13),
+% etc, that can be typed on the keyboard. CH is a double.
+%
+% CH = GETKEY('non-ascii') uses non-documented matlab 6.5 features to
+% return a string describing the key pressed so keys like ctrl, alt, tab
+% etc. can also be used. CH is a string.
+%
+% This function is kind of a workaround for getch in C. It uses a modal, but
+% non-visible window, which does show up in the taskbar.
+% C-language keywords: KBHIT, KEYPRESS, GETKEY, GETCH
+%
+% Examples:
+%
+% fprintf('\nPress any key: ') ;
+% ch = getkey ;
+% fprintf('%c\n',ch) ;
+%
+% fprintf('\nPress the Ctrl-key: ') ;
+% if strcmp(getkey('non-ascii'),'control'),
+% fprintf('OK\n') ;
+% else
+% fprintf(' ... wrong key ...\n') ;
+% end
+%
+% See also INPUT, CHAR
+
+% (c) 2005 Jos
+% email jos @ jasen .nl
+% Feel free to (ab)use, modify or change this contribution
+
+
+% Determine the callback string to use
+if nargin == 1,
+ if strcmp(lower(m),'non-ascii'),
+ callstr = ['set(gcbf,''Userdata'',get(gcbf,''Currentkey'')) ; uiresume '] ;
+ else
+ error('Argument should be the string ''non-ascii''') ;
+ end
+else
+ callstr = ['set(gcbf,''Userdata'',double(get(gcbf,''Currentcharacter''))) ; uiresume '] ;
+end
+
+% Set up the figure
+% May be the position property should be individually tweaked to avoid visibility
+fh = figure('keypressfcn',callstr, ...
+ 'windowstyle','modal',...
+ 'position',[0 0 1 1],...
+ 'Name','GETKEY', ...
+ 'userdata','timeout') ;
+try
+ % Wait for something to happen
+ uiwait ;
+ ch = get(fh,'Userdata') ;
+catch
+ % Something went wrong, return and empty matrix.
+ ch = [] ;
+end
+close(fh) ;
diff --git a/machine/ASP/StorageRing/getquad.m b/machine/ASP/StorageRing/getquad.m
index 7a6239da..c03aa619 100644
--- a/machine/ASP/StorageRing/getquad.m
+++ b/machine/ASP/StorageRing/getquad.m
@@ -1,29 +1,18 @@
-function [SP, AM] = getquad(QMS)
-%GETQUAD - Get quadrupole setpoint (used by quadcenter)
-% [SP, AM] = getquad(QMS)
-%
-% See also setquad, quadcenter
-
-
-if nargin == 0
- error('At least 1 input is required');
-end
-
-QuadFamily = QMS.QuadFamily;
-QuadDev = QMS.QuadDev;
-
-Mode = getfamilydata(QuadFamily,'Setpoint','Mode');
-
-if strcmpi(Mode,'Simulator')
- % Simulator
- SP = getsp(QuadFamily, QuadDev);
- if nargout >= 2
- AM = getam(QuadFamily, QuadDev);
- end
-else
- % Online
- SP = getsp(QuadFamily, QuadDev);
- if nargout >= 2
- AM = getam(QuadFamily, QuadDev);
- end
-end
\ No newline at end of file
+function [SP, AM] = getquad(QMS)
+% [SP, AM] = getquad(QMS)
+% Used by quadcenter
+
+
+if nargin < 1
+ QuadFamily = 'QFA';
+ QuadDev = [1 1];
+else
+ QuadFamily = QMS.QuadFamily;
+ QuadDev = QMS.QuadDev;
+end
+
+SP = getsp(QuadFamily, QuadDev);
+
+if nargout >= 2
+ AM = getam(QuadFamily, QuadDev);
+end
diff --git a/machine/ASP/StorageRing/gev2bend.m b/machine/ASP/StorageRing/gev2bend.m
index 0744e5e7..20471cdc 100644
--- a/machine/ASP/StorageRing/gev2bend.m
+++ b/machine/ASP/StorageRing/gev2bend.m
@@ -1,221 +1,221 @@
-function Amps = gev2bend(varargin)
-%GEV2BEND - Compute the energy based on the ramp tables
-% Bend = gev2bend(Family, Field, GeV, DeviceList, BranchFlag)
-%
-% INPUTS
-% 1. Bend - Bend magnet family {Optional}
-% 2. Field - Field {Optional}
-% 3. GeV - Electron beam energy [GeV]
-% 4. DeviceList - Bend magnet device list to reference energy to {Default: BEND(1,1)}
-% 5. BranchFlag - 1 -> Lower branch
-% 2 -> Upper branch {Default}
-% Not working at Spear yet
-%
-% OUTPUTS
-% 1. Bend - Bend magnet current [Amps]
-%
-% Written by Greg Portmann
-
-
-% Default
-Family = '';
-Field = '';
-GeV = [];
-DeviceList = [];
-BranchFlag = [];
-ModeFlag = ''; % model, online, manual
-UnitsFlag = ''; % hardware, physics
-for i = length(varargin):-1:1
- if isstruct(varargin{i})
- % Ignor structures
- elseif iscell(varargin{i})
- % Ignor cells
- elseif strcmpi(varargin{i},'struct')
- varargin(i) = [];
- elseif strcmpi(varargin{i},'numeric')
- varargin(i) = [];
- elseif strcmpi(varargin{i},'physics')
- UnitsFlag = varargin{i};
- varargin(i) = [];
- elseif strcmpi(varargin{i},'hardware')
- UnitsFlag = varargin{i};
- varargin(i) = [];
- elseif strcmpi(varargin{i},'simulator') | strcmpi(varargin{i},'model')
- ModeFlag = varargin{i};
- varargin(i) = [];
- elseif strcmpi(varargin{i},'online')
- ModeFlag = varargin{i};
- varargin(i) = [];
- elseif strcmpi(varargin{i},'manual')
- ModeFlag = varargin{i};
- varargin(i) = [];
- end
-end
-
-
-if length(varargin) >= 1
- if ischar(varargin{1})
- Family = varargin{1};
- varargin(1) = [];
- else
- GeV = varargin{1};
- varargin(1) = [];
- if length(varargin) >= 1
- DeviceList = varargin{1};
- varargin(1) = [];
- end
- if length(varargin) >= 1
- BranchFlag = varargin{1};
- varargin(1:end) = [];
- end
- end
-end
-if length(varargin) >= 1 & ischar(varargin{1})
- Field = varargin{1};
- varargin(1) = [];
-end
-if length(varargin) >= 1
- GeV = varargin{1};
- varargin(1) = [];
-end
-if length(varargin) >= 1
- DeviceList = varargin{1};
- varargin(1) = [];
-end
-if length(varargin) >= 1
- BranchFlag = varargin{1};
- varargin(1) = [];
-end
-
-
-if isempty(Family)
- Family = 'BEND';
-end
-if isempty(Field)
- Field = 'Setpoint';
-end
-
-if isempty(UnitsFlag)
- UnitsFlag = getunits(Family);
-end
-
-if isempty(GeV)
- if isempty(ModeFlag)
- ModeFlag = getmode(Family);
- end
- if strcmpi(ModeFlag,'simulator') | strcmpi(ModeFlag,'model')
- GeV = getenergymodel;
- else
- error('GeV input required');
- end
-end
-
-if isempty(DeviceList)
- DeviceList = family2dev(Family);
- if all(size(GeV)==[1 1])
- DeviceList = DeviceList(1,:);
- end
-end
-if isempty(BranchFlag)
- % Default is upper branch
- BranchFlag = 2;
-end
-
-% End of input checking
-% Machine dependant stuff below
-
-
-for ii = 1:size(DeviceList,1)
- if length(GeV) == 1
- gev1 = GeV;
- else
- gev1 = GeV(ii);
- end
-
- % Convert to BEND current
- temp = getfamilydata(Family, Field, 'HW2PhysicsParams', DeviceList(ii,:));
- C = temp{1};
-
- % The function/curve used here is Energy vs Current and is calculated
- % from tracking studies using a 2D field map.
- splitind = size(C,2)/2;
- I = C(1,1:splitind);
- Energy = C(1,splitind+1:end); % in GeV
- BEND = interp1(Energy,I,gev1,'linear','extrap');
-
- if size(GeV,2) == 1
- Amps(ii,1) = BEND;
- else
- Amps(1,ii) = BEND;
- end
-end
-
-
-if strcmpi(UnitsFlag,'Physics')
- Amps = hw2physics(Family, 'Setpoint', Amps, DeviceList, GeV);
-end
-
-
-
-
-% % k is fixed to be -0.31537858
-% k = 0.31537858;
-%
-% % Convert to BEND angle
-% if any(DeviceList(ii) == [1 9 10 18])
-% K2BendingAngle = 2.54842790129284 * -0.43947079695140; % BendAngle / K
-% else
-% K2BendingAngle = 2.54842790129284 * -0.58596106939159; % BendAngle / K
-% end
-% k = K2BendingAngle * k;
-%
-% bprime = k * brho;
-% b0 = bprime * 0.392348;
-% bl = b0;
-% k = -k;
-%
-%
-% % Solve for roots based on polynomial coefficient (coefficients already divided by Leff)
-% % p = [C(1) C(2) C(3) C(4) C(5) C(6) C(7) C(8) C(9)-bl];
-% % C(9) = 0
-%
-% p = C;
-% p(9) = bl;
-% %p = [c7 c6 c5 c4 c3 c2 c1 c0 -bl];
-%
-%
-% if 0
-% % Real and between 200-800 amps approach
-% r = roots(p);
-%
-% pp = poly(r);
-%
-% for i = 1:8
-% if (imag(r(i))==0. & real(r(i))<800. & real(r(i))>200.);
-% BEND = r(i);
-% end
-% end
-%
-%
-% else
-% % Closest to the linear line approach
-%
-% r1inear = -bl / C(end-1);
-%
-% r = roots(p);
-%
-% % Choose the closest solution to the linear one
-% BEND = inf;
-% for i = 1:length(r)
-% if isreal(r(i))
-% %if r(i)>0 & abs(r(i)) < BEND(j,1) % Smallest, positive
-% if abs(r(i) - r1inear) < abs(BEND - r1inear) % Closest to linear solution
-% BEND = r(i);
-% end
-% end
-% end
-%
-% if isinf(BEND)
-% error(sprintf('Solution for GeV=%.3f not found (all roots are complex)', gev1));
-% end
+function Amps = gev2bend(varargin)
+%GEV2BEND - Compute the energy based on the ramp tables
+% Bend = gev2bend(Family, Field, GeV, DeviceList, BranchFlag)
+%
+% INPUTS
+% 1. Bend - Bend magnet family {Optional}
+% 2. Field - Field {Optional}
+% 3. GeV - Electron beam energy [GeV]
+% 4. DeviceList - Bend magnet device list to reference energy to {Default: BEND(1,1)}
+% 5. BranchFlag - 1 -> Lower branch
+% 2 -> Upper branch {Default}
+% Not working at Spear yet
+%
+% OUTPUTS
+% 1. Bend - Bend magnet current [Amps]
+%
+% Written by Greg Portmann
+
+
+% Default
+Family = '';
+Field = '';
+GeV = [];
+DeviceList = [];
+BranchFlag = [];
+ModeFlag = ''; % model, online, manual
+UnitsFlag = ''; % hardware, physics
+for i = length(varargin):-1:1
+ if isstruct(varargin{i})
+ % Ignor structures
+ elseif iscell(varargin{i})
+ % Ignor cells
+ elseif strcmpi(varargin{i},'struct')
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'numeric')
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'physics')
+ UnitsFlag = varargin{i};
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'hardware')
+ UnitsFlag = varargin{i};
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'simulator') | strcmpi(varargin{i},'model')
+ ModeFlag = varargin{i};
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'online')
+ ModeFlag = varargin{i};
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'manual')
+ ModeFlag = varargin{i};
+ varargin(i) = [];
+ end
+end
+
+
+if length(varargin) >= 1
+ if ischar(varargin{1})
+ Family = varargin{1};
+ varargin(1) = [];
+ else
+ GeV = varargin{1};
+ varargin(1) = [];
+ if length(varargin) >= 1
+ DeviceList = varargin{1};
+ varargin(1) = [];
+ end
+ if length(varargin) >= 1
+ BranchFlag = varargin{1};
+ varargin(1:end) = [];
+ end
+ end
+end
+if length(varargin) >= 1 & ischar(varargin{1})
+ Field = varargin{1};
+ varargin(1) = [];
+end
+if length(varargin) >= 1
+ GeV = varargin{1};
+ varargin(1) = [];
+end
+if length(varargin) >= 1
+ DeviceList = varargin{1};
+ varargin(1) = [];
+end
+if length(varargin) >= 1
+ BranchFlag = varargin{1};
+ varargin(1) = [];
+end
+
+
+if isempty(Family)
+ Family = 'BEND';
+end
+if isempty(Field)
+ Field = 'Setpoint';
+end
+
+if isempty(UnitsFlag)
+ UnitsFlag = getunits(Family);
+end
+
+if isempty(GeV)
+ if isempty(ModeFlag)
+ ModeFlag = getmode(Family);
+ end
+ if strcmpi(ModeFlag,'simulator') | strcmpi(ModeFlag,'model')
+ GeV = getenergymodel;
+ else
+ error('GeV input required');
+ end
+end
+
+if isempty(DeviceList)
+ DeviceList = family2dev(Family);
+ if all(size(GeV)==[1 1])
+ DeviceList = DeviceList(1,:);
+ end
+end
+if isempty(BranchFlag)
+ % Default is upper branch
+ BranchFlag = 2;
+end
+
+% End of input checking
+% Machine dependant stuff below
+
+
+for ii = 1:size(DeviceList,1)
+ if length(GeV) == 1
+ gev1 = GeV;
+ else
+ gev1 = GeV(ii);
+ end
+
+ % Convert to BEND current
+ temp = getfamilydata(Family, Field, 'HW2PhysicsParams', DeviceList(ii,:));
+ C = temp{1};
+
+ % The function/curve used here is Energy vs Current and is calculated
+ % from tracking studies using a 2D field map.
+ splitind = size(C,2)/2;
+ I = C(1,1:splitind);
+ Energy = C(1,splitind+1:end); % in GeV
+ BEND = interp1(Energy,I,gev1,'linear','extrap');
+
+ if size(GeV,2) == 1
+ Amps(ii,1) = BEND;
+ else
+ Amps(1,ii) = BEND;
+ end
+end
+
+
+if strcmpi(UnitsFlag,'Physics')
+ Amps = hw2physics(Family, 'Setpoint', Amps, DeviceList, GeV);
+end
+
+
+
+
+% % k is fixed to be -0.31537858
+% k = 0.31537858;
+%
+% % Convert to BEND angle
+% if any(DeviceList(ii) == [1 9 10 18])
+% K2BendingAngle = 2.54842790129284 * -0.43947079695140; % BendAngle / K
+% else
+% K2BendingAngle = 2.54842790129284 * -0.58596106939159; % BendAngle / K
+% end
+% k = K2BendingAngle * k;
+%
+% bprime = k * brho;
+% b0 = bprime * 0.392348;
+% bl = b0;
+% k = -k;
+%
+%
+% % Solve for roots based on polynomial coefficient (coefficients already divided by Leff)
+% % p = [C(1) C(2) C(3) C(4) C(5) C(6) C(7) C(8) C(9)-bl];
+% % C(9) = 0
+%
+% p = C;
+% p(9) = bl;
+% %p = [c7 c6 c5 c4 c3 c2 c1 c0 -bl];
+%
+%
+% if 0
+% % Real and between 200-800 amps approach
+% r = roots(p);
+%
+% pp = poly(r);
+%
+% for i = 1:8
+% if (imag(r(i))==0. & real(r(i))<800. & real(r(i))>200.);
+% BEND = r(i);
+% end
+% end
+%
+%
+% else
+% % Closest to the linear line approach
+%
+% r1inear = -bl / C(end-1);
+%
+% r = roots(p);
+%
+% % Choose the closest solution to the linear one
+% BEND = inf;
+% for i = 1:length(r)
+% if isreal(r(i))
+% %if r(i)>0 & abs(r(i)) < BEND(j,1) % Smallest, positive
+% if abs(r(i) - r1inear) < abs(BEND - r1inear) % Closest to linear solution
+% BEND = r(i);
+% end
+% end
+% end
+%
+% if isinf(BEND)
+% error(sprintf('Solution for GeV=%.3f not found (all roots are complex)', gev1));
+% end
% end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/insertscw.m b/machine/ASP/StorageRing/insertscw.m
new file mode 100644
index 00000000..5ad25800
--- /dev/null
+++ b/machine/ASP/StorageRing/insertscw.m
@@ -0,0 +1,46 @@
+function varargout = id_insertscw(B)
+
+global THERING
+
+ii = findcells(THERING,'FamName','scw');
+if any(ii)
+ fprintf('SCW alreay in the lattice. Setting the field B = %f T.\n',B);
+ THERING{ii}.Bmax = B;
+ return
+end
+
+lambda = 52e-3;
+
+elemdata.FamName = 'scw';
+elemdata.Length = lambda*63/2;
+elemdata.Lw = lambda;
+elemdata.Bmax = B;
+elemdata.Nstep = 5;
+elemdata.Nmeth = 4; % 2 or 4 for 2nd or 4th order.
+elemdata.NHharm = 0; % Number of harmonics
+elemdata.NVharm = 0;
+elemdata.By = []; % Harmonic data [n C_n kx_n ky_n kz_n phiz_n]
+elemdata.Bx = [];
+elemdata.R1 = eye(6,6);
+elemdata.R2 = eye(6,6);
+elemdata.T1 = zeros(6,1);
+elemdata.T2 = zeros(6,1);
+elemdata.PassMethod = 'GWigSymplecticPass';
+elemdata.Energy = THERING{1}.Energy;
+
+n = 1;
+kw = 2*pi/lambda;
+kx = 10;
+kz = n*kw;
+ky = sqrt(kx^2 + kz^2);
+tz = 0;
+C = 1;
+
+elemdata.NHharm = 1;
+elemdata.By = [1 C kx/kw ky/kw kz/kw tz];
+
+idind = findcells(THERING,'FamName','id');
+
+THERING{idind(8)} = elemdata;
+THERING{idind(8)-1}.Length = THERING{idind(8)-1}.Length - elemdata.Length/2;
+THERING{idind(8)+1}.Length = THERING{idind(8)+1}.Length - elemdata.Length/2;
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/k2amp.m b/machine/ASP/StorageRing/k2amp.m
index a9170723..f483e5b5 100644
--- a/machine/ASP/StorageRing/k2amp.m
+++ b/machine/ASP/StorageRing/k2amp.m
@@ -1,89 +1,89 @@
-function Amps = k2amp(Family, Field, k, DeviceList, Energy, C, K2AmpScaleFactor, varargin)
-%K2AMP - Converts simulator values to amperes
-% Amps = k2amp(Family, Field, k, DeviceList, Energy, Coefficients, K2AmpScaleFactor)
-% or
-% Amps = k2amp(Family, Field, k, DeviceList, Energy, MagnetCoreType, K2AmpScaleFactor)
-%
-% Calculates the current [amperes] from the coefficients (or
-% MagnetCoreType), "K-value", energy, and linear scale factor
-%
-% For dipole: k = B / Brho
-% For quadrupole: k = B'/ Brho
-% For sextupole: k = B"/ Brho / 2 (to be compatible with AT)
-%
-% A curve vector or a MagnetCoreType string (current curves found from
-% magnetcoefficents.m) can be used. Amps and Coefficients must have equal
-% number of rows or one must only have one row.
-%
-% Energy can be anything getenergy accepts, like 'Model' or 'Online'.
-%
-% The K2AmpScaleFactor linearly scales the output current: Amps = K2AmpScaleFactor .* Amps
-%
-% If energy is not an input or empty, then the energy is read from the accelerator data object (AD)
-% This can be used to account for linear calibration errors of the power supply and magnet
-%
-% NOTES
-% 1. If energy is not an input or empty, then the energy is obtained from getenergy.
-% 2. Family and Field inputs are not used but there automatically part of the physics2hw call.
-%
-% Original structure set up using polynomials by M. Yoon 4/8/03
-% Modified for ASP by E. Tan 31/05/2006
-
-if nargin < 4
- error('At least 4 inputs required');
-end
-
-if nargin < 6
- C = [];
-end
-if isempty(C)
- %[CC, Leff, MagnetName] = magnetcoefficients(Family);
- temp = getfamilydata(Family, Field, 'HW2PhysicsParams', DeviceList);
- C = temp{1};
-end
-
-if nargin < 5
- Energy = [];
-end
-if isempty(Energy)
- Energy = getenergy;
-elseif ischar(Energy)
- Energy = getenergy(Energy);
-end
-
-% If k is a row vector make it a column vector
-k = k(:);
-
-brho = getbrho(Energy);
-
-if isstr(C)
- [C, Leff, MagnetName] = magnetcoefficients(C);
-end
-
-if any(size(C,1) ~= length(k))
- if length(k) == 1
- k = ones(size(C,1),1) * k;
- elseif size(C,1) == 1
- % Ok as is
- %C = ones(size(k,1),1) * C;
- else
- error('k and Coefficients must have equal number of rows or one must only have one row');
- end
-end
-
-% Simple interpolation function therefore assuming monotonic function
-% for the magnets (which is reasonable) the it is a simple matter of
-% reversing from B vs I to I vs B.
-splitind = size(C,2)/2;
-for i = 1:length(k)
- if size(C,1) == 1
- Amps(i,1) = interp1(C(1,splitind+1:end),C(1,1:splitind),k(i)*brho,'linear','extrap');
- else
- Amps(i,1) = interp1(C(i,splitind+1:end),C(i,1:splitind),k(i)*brho,'linear','extrap');
- end
-end
-
-% Scale solution if required
-if nargin >= 7
- Amps = Amps .* K2AmpScaleFactor;
+function Amps = k2amp(Family, Field, k, DeviceList, Energy, C, K2AmpScaleFactor, varargin)
+%K2AMP - Converts simulator values to amperes
+% Amps = k2amp(Family, Field, k, DeviceList, Energy, Coefficients, K2AmpScaleFactor)
+% or
+% Amps = k2amp(Family, Field, k, DeviceList, Energy, MagnetCoreType, K2AmpScaleFactor)
+%
+% Calculates the current [amperes] from the coefficients (or
+% MagnetCoreType), "K-value", energy, and linear scale factor
+%
+% For dipole: k = B / Brho
+% For quadrupole: k = B'/ Brho
+% For sextupole: k = B"/ Brho / 2 (to be compatible with AT)
+%
+% A curve vector or a MagnetCoreType string (current curves found from
+% magnetcoefficents.m) can be used. Amps and Coefficients must have equal
+% number of rows or one must only have one row.
+%
+% Energy can be anything getenergy accepts, like 'Model' or 'Online'.
+%
+% The K2AmpScaleFactor linearly scales the output current: Amps = K2AmpScaleFactor .* Amps
+%
+% If energy is not an input or empty, then the energy is read from the accelerator data object (AD)
+% This can be used to account for linear calibration errors of the power supply and magnet
+%
+% NOTES
+% 1. If energy is not an input or empty, then the energy is obtained from getenergy.
+% 2. Family and Field inputs are not used but there automatically part of the physics2hw call.
+%
+% Original structure set up using polynomials by M. Yoon 4/8/03
+% Modified for ASP by E. Tan 31/05/2006
+
+if nargin < 4
+ error('At least 4 inputs required');
+end
+
+if nargin < 6
+ C = [];
+end
+if isempty(C)
+ %[CC, Leff, MagnetName] = magnetcoefficients(Family);
+ temp = getfamilydata(Family, Field, 'HW2PhysicsParams', DeviceList);
+ C = temp{1};
+end
+
+if nargin < 5
+ Energy = [];
+end
+if isempty(Energy)
+ Energy = getenergy;
+elseif ischar(Energy)
+ Energy = getenergy(Energy);
+end
+
+% If k is a row vector make it a column vector
+k = k(:);
+
+brho = getbrho(Energy);
+
+if isstr(C)
+ [C, Leff, MagnetName] = magnetcoefficients(C);
+end
+
+if any(size(C,1) ~= length(k))
+ if length(k) == 1
+ k = ones(size(C,1),1) * k;
+ elseif size(C,1) == 1
+ % Ok as is
+ %C = ones(size(k,1),1) * C;
+ else
+ error('k and Coefficients must have equal number of rows or one must only have one row');
+ end
+end
+
+% Simple interpolation function therefore assuming monotonic function
+% for the magnets (which is reasonable) the it is a simple matter of
+% reversing from B vs I to I vs B.
+splitind = size(C,2)/2;
+for i = 1:length(k)
+ if size(C,1) == 1
+ Amps(i,1) = interp1(C(1,splitind+1:end),C(1,1:splitind),k(i)*brho,'linear','extrap');
+ else
+ Amps(i,1) = interp1(C(i,splitind+1:end),C(i,1:splitind),k(i)*brho,'linear','extrap');
+ end
+end
+
+% Scale solution if required
+if nargin >= 7
+ Amps = Amps ./ K2AmpScaleFactor;
end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/lifetime.m b/machine/ASP/StorageRing/lifetime.m
index 519a612a..bcb7a7dc 100644
--- a/machine/ASP/StorageRing/lifetime.m
+++ b/machine/ASP/StorageRing/lifetime.m
@@ -1,109 +1,219 @@
-function [lifetdcct error] = lifetime(timetaken,varargin);
-%[lifetime error] = lifetime(time taken in seconds,varargin)
-%
-%This function returns the lifetime and error calculated over
-%the time given as an input in seconds
-%
-%It is also possible to specify a process variable to use to find the
-%lifetime
-%
-%If you use 'sum' as the second input then it will sum over a number of
-%BPMs as you edit in the code below.
-%
-%Written by Martin Spencer
-
-
-%bpmsasum(1,:) = 'SR01BPM01:SA_S_MONITOR';
-%bpmsasum(2,:) = 'SR02BPM01:SA_S_MONITOR';
-flag=1;
-if nargin == 1
- monitor = 'SR11BCM01:CURRENT_MONITOR';
-elseif nargin == 2
- if ~strcmp('sum',varargin{1})
- monitor = varargin{1};
- else
- flag =1;
- end
-end
-
-if flag == 1;
- count=1;
- for(i=1:1) %sector numbers to sum over!!!
- for(j=1:1) %bpm numbers to sum over!!!!
- if(0)
- elseif i >= 10
- bpmsasum(count,:) = ['SR' num2str(i) 'BPM0' num2str(j) ':SA_SUM_MONITOR'];
- elseif i<10
- bpmsasum(count,:) = ['SR0' num2str(i) 'BPM0' num2str(j) ':SA_SUM_MONITOR'];
- end
- count = count+1;
- end
- end
-end
-%dcct = 'SR11BCM01:TT_S_MONITOR';
-
-if nargin > 1
- Ns = timetaken*10;
-else
- Ns = timetaken;
-end
-
-a = zeros(2,Ns);
-tic;
-for(i=1:Ns);
-
- if flag == 1
- for(j=1:count-1)
- s(j) = getpv(bpmsasum(j,:));
- end
- d = mean(s);
- else
- d = getpv(monitor);
- end
-
- a(2,i)=d;
- if(nargin > 1)
- pause(0.1)
- else
- pause(1)
- end
-end;
-t=toc;
-
-%a(1,:) = a(1,:)/a(1,end); %normalise
-a(2,:) = a(2,:)/a(2,end); %normalise
-
-figure;
-clf;
-%plot([1:Ns]*0.1,a(1,:),'b*-');
-%hold on;
-plot([1:Ns]*0.1,a(2,:),'r*-');
-hold on;
-
-%p = polyfit([1:Ns]*0.1,a(1,:),1);
-%f = polyval(p,[1:Ns]*0.1);
-%plot([1:Ns]*0.1,f,'b');
-
-[p1 s] = polyfit([1:Ns]*0.1,a(2,:),1);
-[f1 delta] = polyval(p1,[1:Ns]*0.1,s);
-plot([1:Ns]*0.1,f1,'b');
-
-meandelta = mean(delta);
-
-%lifetdcct = -((t)/(3600))/log(f1(end)/f1(1));
-%lifetmax = -((t)/(3600))/log((f1(end)-meandelta)/(f1(1)+meandelta));
-%lifetmin = -((t)/(3600))/log((f1(end)+meandelta)/(f1(1)-meandelta));
-%error = abs(lifetmax-lifetmin)/2;
-
-lifetdcct = (f1(end)/(f1(1)-f1(end)))*(t/3600);
-grad = (f1(1)-f1(end))/(t/3600);
-gradmax = ((f1(1)+meandelta)-(f1(end)-meandelta))/(t/3600);
-gradmin = ((f1(1)-meandelta)-(f1(end)+meandelta))/(t/3600);
-graderror = abs(gradmax-gradmin)/2;
-properror = graderror/grad;
-error = lifetdcct*properror;
-
-temp = ['The lifetime is: ' num2str(lifetdcct) ' hours. With a error of about: ' num2str(error) ' hours. Time taken: ' num2str(t) ' seconds.'];
-disp(temp);
-
-hold off;
\ No newline at end of file
+function [lifetdcct error] = lifetime(timetaken,varargin)
+%[lifetime error] = lifetime(time taken in seconds,varargin)
+%
+%This function returns the lifetime and error calculated over
+%the time given as an input in seconds
+%
+%It is also possible to specify a process variable to use to find the
+%lifetime
+%
+%If you use 'sum' as the second input then it will sum over a number of
+%BPMs as you edit in the code below.
+%
+%Written by Martin Spencer
+% Modified 18-12-2007 ET
+
+if nargin == 1
+ % Default to only using the DCCT
+ monitor = 'SR11BCM01:CURRENT_MONITOR';
+ usebpm = 0;
+elseif nargin == 2
+ % Use the SA data of the BPMs
+ monitor = 'SA_SIGNAL.Sum';
+ usebpm = 1;
+else
+ return
+end
+
+tic
+if usebpm == 1
+ % Select the BPMs of interest here or leave empty and will select all
+ % BPMs.
+ % The measurements seems to indicate that there are some BPMs that are
+ % noisier than others. If you just chose the quiet ones the results are
+ % comparable to the DCCT.
+% deviceList = getlist('BPMx',[1:7:98]');
+ deviceList = getlist('BPMx');
+% [rawdata tout] = getlibera(monitor,deviceList,[1:timetaken]);
+ [rawdata, tout] = srbpm.getfield(monitor,deviceList,[1:0.25:timetaken]);
+
+ rawdata = squeeze(rawdata);
+
+ % Normalise before averaging across all BPMs
+ bpmdata = rawdata./repmat(rawdata(:,end),1,size(rawdata,2));
+ data = mean(bpmdata);
+
+else
+ [data, tout] = getpv(monitor,[1:timetaken]);
+end
+t = toc;
+
+data = squeeze(data/data(end)); %normalise
+
+if usebpm
+ figure(23); clf;
+ set(gcf,'Position',[ 122 656 985 625])
+else
+ figure(22); clf;
+ set(gcf,'Position',[ 122 656 985 625])
+end
+plot(tout,data,'r*-');
+hold on;
+
+%p = polyfit([1:Ns]*0.1,a(1,:),1);
+%f = polyval(p,[1:Ns]*0.1);
+%plot([1:Ns]*0.1,f,'b');
+
+[p1 s] = polyfit(tout,data,1);
+[f1 delta] = polyval(p1,tout,s);
+plot(tout,f1,'b');
+grid on;
+xlabel('Time (s)');
+
+meandelta = mean(delta);
+
+%lifetdcct = -((t)/(3600))/log(f1(end)/f1(1));
+%lifetmax = -((t)/(3600))/log((f1(end)-meandelta)/(f1(1)+meandelta));
+%lifetmin = -((t)/(3600))/log((f1(end)+meandelta)/(f1(1)-meandelta));
+%error = abs(lifetmax-lifetmin)/2;
+
+lifetdcct = (f1(end)/(f1(1)-f1(end)))*(t/3600);
+grad = (f1(1)-f1(end))/(t/3600);
+gradmax = ((f1(1)+meandelta)-(f1(end)-meandelta))/(t/3600);
+gradmin = ((f1(1)-meandelta)-(f1(end)+meandelta))/(t/3600);
+graderror = abs(gradmax-gradmin)/2;
+properror = graderror/grad;
+error = lifetdcct*properror;
+
+
+% temp = ['The lifetime is: ' num2str(lifetdcct) ' hours. With a error of about: ' num2str(error) ' hours. Time taken: ' num2str(t) ' seconds.'];
+
+temp = sprintf('The lifetime is: %5.2f Hr; approx. error: %5.2f Hr. Time taken: %4.1f seconds',...
+ lifetdcct, error, t);
+
+if usebpm
+ ylabel('BPM sum (Normalised)');
+else
+ ylabel('DCCT (Normalised)');
+end
+title(temp);
+disp(temp);
+
+hold off;
+
+
+%% Old Version
+% function [lifetdcct error] = lifetime(timetaken,varargin);
+% %[lifetime error] = lifetime(time taken in seconds,varargin)
+% %
+% %This function returns the lifetime and error calculated over
+% %the time given as an input in seconds
+% %
+% %It is also possible to specify a process variable to use to find the
+% %lifetime
+% %
+% %If you use 'sum' as the second input then it will sum over a number of
+% %BPMs as you edit in the code below.
+% %
+% %Written by Martin Spencer
+%
+%
+% %bpmsasum(1,:) = 'SR01BPM01:SA_S_MONITOR';
+% %bpmsasum(2,:) = 'SR02BPM01:SA_S_MONITOR';
+% flag=0;
+% if nargin == 1
+% monitor = 'SR11BCM01:CURRENT_MONITOR';
+% elseif nargin == 2
+% if ~strcmp('sum',varargin{1})
+% monitor = varargin{1};
+% else
+% flag =1;
+% end
+% end
+%
+% if flag == 1;
+% % Select the BPMs of interest here or leave empty and will select all
+% % BPMs.
+% % deviceList = [];
+% % [data tout] = getlibera('SA_SUM_MONITOR',deviceList,[1:timetaken])
+%
+% count=1;
+% for(i=[1:2 4:10 12:14]) %sector numbers to sum over!!!
+% for(j=1:7) %bpm numbers to sum over!!!!
+% if(0)
+% elseif i >= 10
+% bpmsasum(count,:) = ['SR' num2str(i) 'BPM0' num2str(j) ':SA_SUM_MONITOR'];
+% elseif i<10
+% bpmsasum(count,:) = ['SR0' num2str(i) 'BPM0' num2str(j) ':SA_SUM_MONITOR'];
+% end
+% count = count+1;
+% end
+% end
+% end
+% %dcct = 'SR11BCM01:TT_S_MONITOR';
+%
+% if nargin > 1
+% Ns = timetaken*10;
+% else
+% Ns = timetaken;
+% end
+%
+% a = zeros(2,Ns);
+% tic;
+% for(i=1:Ns);
+%
+% if flag == 1
+% for(j=1:count-1)
+% s(j) = getpv(bpmsasum(j,:));
+% end
+% d = mean(s);
+% else
+% d = getpv(monitor);
+% end
+%
+% a(2,i)=d;
+% if(nargin > 1)
+% pause(0.1)
+% else
+% pause(1)
+% end
+% end;
+% t=toc;
+%
+% %a(1,:) = a(1,:)/a(1,end); %normalise
+% a(2,:) = a(2,:)/a(2,end); %normalise
+%
+% figure(22);
+% clf;
+% %plot([1:Ns]*0.1,a(1,:),'b*-');
+% %hold on;
+% plot([1:Ns]*0.1,a(2,:),'r*-');
+% hold on;
+%
+% %p = polyfit([1:Ns]*0.1,a(1,:),1);
+% %f = polyval(p,[1:Ns]*0.1);
+% %plot([1:Ns]*0.1,f,'b');
+%
+% [p1 s] = polyfit([1:Ns]*0.1,a(2,:),1);
+% [f1 delta] = polyval(p1,[1:Ns]*0.1,s);
+% plot([1:Ns]*0.1,f1,'b');
+%
+% meandelta = mean(delta);
+%
+% %lifetdcct = -((t)/(3600))/log(f1(end)/f1(1));
+% %lifetmax = -((t)/(3600))/log((f1(end)-meandelta)/(f1(1)+meandelta));
+% %lifetmin = -((t)/(3600))/log((f1(end)+meandelta)/(f1(1)-meandelta));
+% %error = abs(lifetmax-lifetmin)/2;
+%
+% lifetdcct = (f1(end)/(f1(1)-f1(end)))*(t/3600);
+% grad = (f1(1)-f1(end))/(t/3600);
+% gradmax = ((f1(1)+meandelta)-(f1(end)-meandelta))/(t/3600);
+% gradmin = ((f1(1)-meandelta)-(f1(end)+meandelta))/(t/3600);
+% graderror = abs(gradmax-gradmin)/2;
+% properror = graderror/grad;
+% error = lifetdcct*properror;
+%
+% temp = ['The lifetime is: ' num2str(lifetdcct) ' hours. With a error of about: ' num2str(error) ' hours. Time taken: ' num2str(t) ' seconds.'];
+% disp(temp);
+%
+% hold off;
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/linear_fit_remove_betabeat.m b/machine/ASP/StorageRing/linear_fit_remove_betabeat.m
index 9fb8891e..e68819a0 100644
--- a/machine/ASP/StorageRing/linear_fit_remove_betabeat.m
+++ b/machine/ASP/StorageRing/linear_fit_remove_betabeat.m
@@ -1,20 +1,57 @@
-initialisations = ['global THERING;',...
+setoperationalmode(2);
+global THERING_NOWIG
+THERING_NOWIG = THERING;
+
+ind = findcells(THERING,'FamName','ID');
+mach_init = machine_at;
+qfai = getsp('QFA','model');
+qdai = getsp('QDA','model');
+qfbi = getsp('QFB','model');
+
+% ID12 Wiggler
+idnum = 12;
+% 18.16 mm
+kx = 0.0003416;
+ky = -0.0210746;
+% 14.6 mm
+% kx = 0.0005088;
+% ky = -0.0281203;
+
+THERING{ind(idnum)}.M66(2,1) = kx;
+THERING{ind(idnum)}.M66(4,3) = ky;
+
+initialisations = ['global THERING THERING_NOWIG;',...
'qfaind = getfamilydata(''QFA'',''AT'',''ATIndex'',[11 2; 12 1]);',...
'qdaind = getfamilydata(''QDA'',''AT'',''ATIndex'',[11 2; 12 1]);',...
- 'sfbind = getfamilydata(''SFB'',''AT'',''ATIndex'');';
+ 'qfbind = getfamilydata(''QFB'',''AT'',''ATIndex'',[11 2; 12 1]);',...
+ 'sfbind = getfamilydata(''SFB'',''AT'',''ATIndex'');'];
varget = {'getcellstruct(THERING,''K'',qfaind)';...
- 'getcellstruct(THERING,''K'',qdaind)'};
+ 'getcellstruct(THERING,''K'',qdaind)';...
+ 'getcellstruct(THERING,''K'',qfbind)'};
-% varset = {'THERING = setcellstruct(THERING,''PolynomB'',qfaind,variable,2); THERING = setcellstruct(THERING,''K'',qfaind,variable);';...
-% 'THERING = setcellstruct(THERING,''PolynomB'',qdaind,variable,2); THERING = setcellstruct(THERING,''K'',qdaind,variable);'};
-varset = {'THERING = setcellstruct(THERING,''K'',qfaind,variable);';...
- 'THERING = setcellstruct(THERING,''K'',qdaind,variable);'};
+varset = {'THERING = setcellstruct(THERING,''PolynomB'',qfaind,variable,2); THERING = setcellstruct(THERING,''K'',qfaind,variable);';...
+ 'THERING = setcellstruct(THERING,''PolynomB'',qdaind,variable,2); THERING = setcellstruct(THERING,''K'',qdaind,variable);';...
+ 'THERING = setcellstruct(THERING,''PolynomB'',qfbind,variable,2); THERING = setcellstruct(THERING,''K'',qfbind,variable);'};
+% varset = {'THERING = setcellstruct(THERING,''K'',qfaind,variable);';...
+% 'THERING = setcellstruct(THERING,''K'',qdaind,variable);'};
-paramget = {'std(machine_at(THERING,0,sfbind,''betax''))';...
- 'std(machine_at(THERING,0,sfbind,''betay''))'};
+paramget = {'std(machine_at(THERING,0,sfbind'',''betax''))';...
+ 'std(machine_at(THERING,0,sfbind'',''betay''))';...
+ 'std(machine_at(THERING,0,sfbind'',''etax'')*10)'};
-goalparam = [0 0];
+goalparam = [0 0 0];
+
+linearfit(varget,varset,paramget,goalparam,initialisations);
+mach_final = machine_at;
+
+% fittunedisp2([mach_init.nux(end) mach_init.nuy(end) mach_init.etax(end)],'QFA','QDA','QFB',1);
+
+qfaf = getsp('QFA','model');
+qdaf = getsp('QDA','model');
+qfbf = getsp('QFB','model');
-linearfit(varget,varset,paramget,goalparam,initialisations);
\ No newline at end of file
+qfa_rel = qfaf./qfai;
+qda_rel = qdaf./qdai;
+qfb_rel = qfbf./qfbi;
diff --git a/machine/ASP/StorageRing/magnetcoefficients.m b/machine/ASP/StorageRing/magnetcoefficients.m
index 38506fa6..7c4af0f9 100644
--- a/machine/ASP/StorageRing/magnetcoefficients.m
+++ b/machine/ASP/StorageRing/magnetcoefficients.m
@@ -1,212 +1,233 @@
-function [C, Leff, MagnetType] = magnetcoefficients(MagnetCoreType)
-% [C, Leff, MagnetType] = magnetcoefficients(MagnetCoreType)
-%
-% C is a curve for the particular magnet and is a 2 column vector. The
-% first column contains the current values at which the magnet was tested
-% and the second colum the measured B, B' or B" values.
-%
-% Unlike Spear3 that use polynomials we will use a simple curve defined
-% over a specific domain. To do the calculations, simple linear
-% interpolation will only be used.
-%
-% The amp2k and k2amp functions convert between the two types of units.
-% amp2k returns B , B' , or B" scaled by Brho.
-%
-% For dipole: k = B / Brho (for AT: KickAngle = BLeff / Brho)
-% For quadrupole: k = B'/ Brho
-% For sextupole: k = B"/ Brho / 2 (to be compatible with AT)
-% (all coefficients all divided by 2 for sextupoles)
-%
-% MagnetCoreType is the magnet measurements name for the magnet core (string, string matrix, or cell)
-% For ASP: BEND
-% QFA, QFB, QDA, SKQ
-% SFA, SFB, SDA, SDB
-% HCM, VCM
-%
-% Leff is the effective length of the magnet. In most cases this will be
-% the same as the model length.
-%
-% Original structure set up using polynomials by M. Yoon 4/8/03
-% Modified for ASP by E. Tan 31/05/2006
-
-% Todo
-% * What to do about Leff and how should it help in this instance?
-
-if nargin < 1
- error('MagnetCoreType input required');
-end
-
-
-% For a string matrix
-if iscell(MagnetCoreType)
- for i = 1:size(MagnetCoreType,1)
- for j = 1:size(MagnetCoreType,2)
- [C{i,j}, Leff{i,j}, MagnetType{i,j}] = magnetcoefficients(MagnetCoreType{i});
- end
- end
- return
-end
-
-% For a string matrix
-if size(MagnetCoreType,1) > 1
- C=[]; Leff=[]; MagnetType=[];
- for i = 1:size(MagnetCoreType,1)
- [C1, Leff1, MagnetType1] = magnetcoefficients(MagnetCoreType(i,:));
- C(i,:) = C1;
- Leff(i,:) = Leff1;
- MagnetType = strvcat(MagnetType, MagnetType1);
- end
- return
-end
-
-
-% Directory containing the magnet calibration curves. At the moment the
-% data is brought from various sources and processed in with the script
-% read_BI_into_mat.m. The script draws data that has been generated from
-% magnetic measurements (for quads, sextupoles and correctors) and tracking
-% studies (for dipoles based on 2D field maps). See script files for more
-% details. Variable saved should be BIdata.
-filepath = fileparts([mfilename('fullpath')]);
-load([filepath filesep 'magnet_calibration_curves' filesep 'B_vs_I_data.mat'])
-
-switch upper(deblank(MagnetCoreType))
-
- case 'BEND'
-
- MagnetType = 'bend';
- Leff=1.726;
-
- I = BIdata.DIP.I;
- Energy = BIdata.DIP.Energy;
-
- C = zeros(1,2*length(I));
- C(1,1:length(I)) = I;
- C(1,length(I)+1:end) = Energy;
-
- case 'QDA'
-
- MagnetType = 'quad';
- Leff=0.18;
- CorrectionFactor = 1.01898761594704;
-
- % The below is negative because defocusing quadrupoles must return
- % negative k values.
- I = BIdata.QD.I_gen;
- B = -BIdata.QD.dBdx/Leff;
-
- C = zeros(1,2*length(I));
- C(1,1:length(I)) = I;
- C(1,length(I)+1:end) = B;
-
- case {'QFA','QFB'}
-
- MagnetType = 'quad';
- Leff=0.355;
-
- I = BIdata.QF.I_gen;
- B = BIdata.QF.dBdx/Leff;
-
- C = zeros(1,2*length(I));
- C(1,1:length(I)) = I;
- C(1,length(I)+1:end) = B;
-
- case {'SFA','SFB'}
-
- MagnetType = 'sext';
- Leff=0.2;
-
- % Power Series Denominator (Factoral) be AT compatible. For
- % sextupole its 2! = 2.
- I = BIdata.SVR.I_gen;
-
- B = BIdata.SVR.d2Bdx2/Leff/2;
-
- C = zeros(1,2*length(I));
- C(1,1:length(I)) = I;
- C(1,length(I)+1:end) = B;
-
- case {'SDA','SDB'}
-
- MagnetType = 'sext';
- Leff=0.2;
-
- % Power Series Denominator (Factoral) be AT compatible. For
- % sextupole its 2! = 2.
- % The B field is negative below because SD magnets should return
- % negative K values.
- I = BIdata.SVR.I_gen;
- B = -BIdata.SVR.d2Bdx2/Leff/2;
-
- C = zeros(1,2*length(I));
- C(1,1:length(I)) = I;
- C(1,length(I)+1:end) = B;
-
- case 'SKQ'
- % There are no magnetic measurment for this configuration on the
- % sextupoles therefore we will use the calculations done by Jack
- % Tanabe in the original design documents M009.doc. The
- % specification was to design a skew gradient field of 0.035 T/m
- % and requires 47.6 AmpTurns. With a coil configuration of 12
- % turns this corresponds to ~4 Amps. Therefore we will assume a
- % linear relationship from zero.
-
- MagnetType = 'quad';
- Leff=0.2;
-
- I = [-8:8];
- B = 0.035/(47.6/12)*I;
-
- C = zeros(1,2*length(I));
- C(1,1:length(I)) = I;
- C(1,length(I)+1:end) = B;
-
- case 'HCM' % horizontal corrector trim coils in SH magnets
- % Magnet Spec: Theta = 1.0e-3 radians @ 3 GeV and 75.3 amps
- % Theta = BLeff / Brho [radians]
- % Therefore,
- % Theta = ((BLeff/Amp)/ Brho) * I
- % BLeff/Amp = 1.0e-3 * getbrho(3) / 30
- % B*Leff = a0 * I => a0 = 1.5e-3 * getbrho(3) / 30
- %
- % The C coefficients are w.r.t B
- % B = c0 + c1*I = (0 + a0*I)/Leff
- % However, AT uses Theta in radians so the A coefficients
- % must be used for correctors with the middle layer with
- % the addition of the DC term
-
- % Find the current from the given polynomial for BLeff and B
- % NOTE: AT used BLeff (A) for correctors
- Leff = 0.2;
- MagnetType = 'COR';
-
- i0 = BIdata.HCM.I;
- BLeff = BIdata.HCM.Bharmon(1);
-
- I = [-90:10:90];
- BL = (BLeff/i0)*I;
-
- C = zeros(1,2*length(I));
- C(1,1:length(I)) = I;
- C(1,length(I)+1:end) = BL;
-
- case 'VCM' % vertical corrector trim coils in SD magnets
- % Magnet Spec: Theta = 1.0e-3 radians @ 3 GeV and 130 amps
- % Find the current from the given polynomial for BLeff and B
- Leff = 0.2;
- MagnetType = 'COR';
-
- i0 = BIdata.VCM.I;
- BLeff = BIdata.VCM.Bharmon(1);
-
- I = [-120:10:120];
- BL = (BLeff/i0)*I;
-
- C = zeros(1,2*length(I));
- C(1,1:length(I)) = I;
- C(1,length(I)+1:end) = BL;
-
- otherwise
- error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
-end
-
-MagnetType = upper(MagnetType);
+function [C, Leff, MagnetType] = magnetcoefficients(MagnetCoreType)
+% [C, Leff, MagnetType] = magnetcoefficients(MagnetCoreType)
+%
+% C is a curve for the particular magnet and is a 2 column vector. The
+% first column contains the current values at which the magnet was tested
+% and the second colum the measured B, B' or B" values.
+%
+% Unlike Spear3 that use polynomials we will use a simple curve defined
+% over a specific domain. To do the calculations, simple linear
+% interpolation will only be used.
+%
+% The amp2k and k2amp functions convert between the two types of units.
+% amp2k returns B , B' , or B" scaled by Brho.
+%
+% For dipole: k = B / Brho (for AT: KickAngle = BLeff / Brho)
+% For quadrupole: k = B'/ Brho
+% For sextupole: k = B"/ Brho / 2 (to be compatible with AT)
+% (all coefficients all divided by 2 for sextupoles)
+%
+% MagnetCoreType is the magnet measurements name for the magnet core (string, string matrix, or cell)
+% For ASP: BEND
+% QFA, QFB, QDA, SKQ
+% SFA, SFB, SDA, SDB
+% HCM, VCM
+%
+% Leff is the effective length of the magnet. In most cases this will be
+% the same as the model length.
+%
+% Original structure set up using polynomials by M. Yoon 4/8/03
+% Modified for ASP by E. Tan 31/05/2006
+% Rohan, Eugene: 10/02/2009: changed sign for SKQ based on measurements.
+
+% Todo
+% * What to do about Leff and how should it help in this instance?
+
+if nargin < 1
+ error('MagnetCoreType input required');
+end
+
+
+% For a string matrix
+if iscell(MagnetCoreType)
+ for i = 1:size(MagnetCoreType,1)
+ for j = 1:size(MagnetCoreType,2)
+ [C{i,j}, Leff{i,j}, MagnetType{i,j}] = magnetcoefficients(MagnetCoreType{i});
+ end
+ end
+ return
+end
+
+% For a string matrix
+if size(MagnetCoreType,1) > 1
+ C=[]; Leff=[]; MagnetType=[];
+ for i = 1:size(MagnetCoreType,1)
+ [C1, Leff1, MagnetType1] = magnetcoefficients(MagnetCoreType(i,:));
+ C(i,:) = C1;
+ Leff(i,:) = Leff1;
+ MagnetType = strvcat(MagnetType, MagnetType1);
+ end
+ return
+end
+
+
+% Directory containing the magnet calibration curves. At the moment the
+% data is brought from various sources and processed in with the script
+% read_BI_into_mat.m. The script draws data that has been generated from
+% magnetic measurements (for quads, sextupoles and correctors) and tracking
+% studies (for dipoles based on 2D field maps). See script files for more
+% details. Variable saved should be BIdata.
+% Path defined in aoinit.m
+load(fullfile(getmmlroot('IgnoreTheAD'),'machine','ASP','StorageRing','magnet_calibration_curves','B_vs_I_data.mat'));
+% load('B_vs_I_data.mat')
+
+switch upper(deblank(MagnetCoreType))
+
+ case 'BEND'
+
+ MagnetType = 'bend';
+ Leff=1.726;
+
+ I = BIdata.DIP.I;
+ Energy = BIdata.DIP.Energy;
+
+ % Scaling used here is based on spin depolarisation measurements
+ % that put the SR energy at 3.0134 GeV when the dipole was set to
+ % 614.968 Amps (RF freq 499 674 670 Hz). 27/07/2010 Eugene
+ C = zeros(1,2*length(I));
+ C(1,1:length(I)) = I;
+ C(1,length(I)+1:end) = Energy*1.024754;
+
+ case 'QDA'
+
+ MagnetType = 'quad';
+ Leff=0.18+0.0084;
+
+ % The below is negative because defocusing quadrupoles must return
+ % negative k values.
+ I = BIdata.QD.I_gen;
+ B = -BIdata.QD.dBdx/Leff;
+
+ % Scaling factor for B empirically determined by comparing model
+ % predictions with measured. Eugene 21-07-2010
+ C = zeros(1,2*length(I));
+ C(1,1:length(I)) = I;
+% C(1,length(I)+1:end) = B*0.995540071082187/0.995537735778454;
+ C(1,length(I)+1:end) = B*0.997549129779699;
+
+ case {'QFA','QFB'}
+
+ MagnetType = 'quad';
+ Leff=0.355+0.0084;
+
+ I = BIdata.QF.I_gen;
+ B = BIdata.QF.dBdx/Leff;
+
+ % Scaling factor for B empirically determined by comparing model
+ % predictions with measured. Eugene 21-07-2010
+ C = zeros(1,2*length(I));
+ C(1,1:length(I)) = I;
+% C(1,length(I)+1:end) = B*1.016228140568382/0.995267695340687;
+ C(1,length(I)+1:end) = B*1.016867410211431;
+
+ case {'SFA','SFB'}
+
+ MagnetType = 'sext';
+ Leff=0.2;
+
+ % Power Series Denominator (Factoral) be AT compatible. For
+ % sextupole its 2! = 2.
+ I = BIdata.SVR.I_gen;
+
+ B = BIdata.SVR.d2Bdx2/Leff/2;
+
+ % Scaling factor for B empirically determined by comparing model
+ % predictions with measured chromaticities. Eugene 21-07-2010
+ C = zeros(1,2*length(I));
+ C(1,1:length(I)) = I;
+ C(1,length(I)+1:end) = B*0.998;0.995;
+
+ case {'SDA','SDB'}
+
+ MagnetType = 'sext';
+ Leff=0.2;
+
+ % Power Series Denominator (Factoral) be AT compatible. For
+ % sextupole its 2! = 2.
+ % The B field is negative below because SD magnets should return
+ % negative K values.
+ I = BIdata.SVR.I_gen;
+ B = -BIdata.SVR.d2Bdx2/Leff/2;
+
+ % Scaling factor for B empirically determined by comparing model
+ % predictions with measured chromaticities. Eugene 21-07-2010
+ C = zeros(1,2*length(I));
+ C(1,1:length(I)) = I;
+ C(1,length(I)+1:end) = B*0.998;0.995;
+
+ case 'SKQ'
+ % There are no magnetic measurment for this configuration on the
+ % sextupoles therefore we will use the calculations done by Jack
+ % Tanabe in the original design documents M009.doc. The
+ % specification was to design a skew gradient field of 0.035 T/m
+ % and requires 47.6 AmpTurns. With a coil configuration of 12
+ % turns this corresponds to ~4 Amps. Therefore we will assume a
+ % linear relationship from zero.
+
+ % Rohan, Eugene 10/02/2009: Changed the sign as a positive current
+ % corresponds to a negative skew component. See operations elog
+ % entries. (eg.
+ % http://asapp01/elog/servlet/XMLlist?file=/operationselog/data/2008/30/26.07&xsl=/elogbook/xsl/elog.xsl&picture=true#2008-07-26T12:00:25)
+ %
+
+ MagnetType = 'quad';
+ Leff=0.2;
+
+ I = [-8:8];
+ %B = 0.035/(47.6/12)*I;
+ B = -0.02*I;
+
+ C = zeros(1,2*length(I));
+ C(1,1:length(I)) = I;
+ C(1,length(I)+1:end) = B;
+
+ case 'HCM' % horizontal corrector trim coils in SH magnets
+ % Magnet Spec: Theta = 1.0e-3 radians @ 3 GeV and 75.3 amps
+ % Theta = BLeff / Brho [radians]
+ % Therefore,
+ % Theta = ((BLeff/Amp)/ Brho) * I
+ % BLeff/Amp = 1.0e-3 * getbrho(3) / 30
+ % B*Leff = a0 * I => a0 = 1.5e-3 * getbrho(3) / 30
+ %
+ % The C coefficients are w.r.t B
+ % B = c0 + c1*I = (0 + a0*I)/Leff
+ % However, AT uses Theta in radians so the A coefficients
+ % must be used for correctors with the middle layer with
+ % the addition of the DC term
+
+ % Find the current from the given polynomial for BLeff and B
+ % NOTE: AT used BLeff (A) for correctors
+ Leff = 0.2;
+ MagnetType = 'COR';
+
+ i0 = BIdata.HCM.I;
+ BLeff = BIdata.HCM.Bharmon(1)*1.1; % 23/11/2009 ET: 1.1 added to fix the gain issues
+
+ I = [-90:10:90];
+ BL = (BLeff/i0)*I;
+
+ C = zeros(1,2*length(I));
+ C(1,1:length(I)) = I;
+ C(1,length(I)+1:end) = BL;
+
+ case 'VCM' % vertical corrector trim coils in SD magnets
+ % Magnet Spec: Theta = 1.0e-3 radians @ 3 GeV and 130 amps
+ % Find the current from the given polynomial for BLeff and B
+ Leff = 0.2;
+ MagnetType = 'COR';
+
+ i0 = BIdata.VCM.I;
+ BLeff = BIdata.VCM.Bharmon(1);
+
+ I = [-120:10:120];
+ BL = (BLeff/i0)*I*1.06; % 23/11/2009 ET: 1.06 added to fix the gain issues
+
+ C = zeros(1,2*length(I));
+ C(1,1:length(I)) = I;
+ C(1,length(I)+1:end) = BL;
+
+ otherwise
+ error(sprintf('MagnetCoreType %s is not unknown', MagnetCoreType));
+end
+
+MagnetType = upper(MagnetType);
diff --git a/machine/ASP/StorageRing/meastune.m b/machine/ASP/StorageRing/meastune.m
index bcfd399c..61eedcf2 100644
--- a/machine/ASP/StorageRing/meastune.m
+++ b/machine/ASP/StorageRing/meastune.m
@@ -1,48 +1,349 @@
function varargout = meastune(varargin)
+% MEASTUNE measures the tune using various possible sources. The default is
+% from Turn-by-Turn (TBT) data from the Liberas. The probram does not turn
+% on or off any magnets.
+%
+% >> tunes = meastune;
+%
+% Eugene
+
t0 = clock;
-% if nargin == 1
- % Mexed version of the tune measurement interface
-
+% Source of tunes
+% 1: From general PVs
+% 2: From TBT data
+% 3: From automated tune measurement system
+% 4: From BbB
+choice = 4;
+
+switch choice
+
+ case 1 % From General PVs
+
tune(1) = getpv('CR01:GENERAL_ANALOG_02_MONITOR');
tune(2) = getpv('CR01:GENERAL_ANALOG_03_MONITOR');
-disp('Tunes from the kicker:')
-disp(tune)
-%
-% printf ("rsib-spa test v2.01\n\n");
-% printf ("Master Oscillator Frequency = %e\n", Master_Oscillator_Frequency);
-% printf ("Centre Frequency = %e\n", Centre_Frequency);
-% printf ("XTune Guess = %e\n", X_Tune_Guess);
-% printf ("XTune Half Span = %e\n", X_Tune_Half_Span);
-% printf ("YTune Guess = %e\n", Y_Tune_Guess);
-% printf ("YTune Half Span = %e\n\n", Y_Tune_Half_Span);
-
- mo = getsp('RF');
- tune = sr11spa01_matlab(mo(1),29.1474444e6,0.29,0.04,0.22,0.04);
-disp('Tunes from the SPA (returned by program):')
-disp(tune')
-% tune = sr11spa01_matlab(mo(1),1.665566720000000e+07,0.3,0.04,0.22,0.04);
+
+ case 2 % Using TBT data
+ % Method
+ % 1: SVD component method with zero padding for frequency interpolation.
+ % 2: FFT with background subtraction
+ method = 2;
+ % Test
+ % 0: No test
+ % 1: Sample dataset
+ % 2: Pure function
+ testsource = 0;
+
+ %Check excitation
+ if sum(getpv('KICK','OFF_ON_STATUS')) == 4
+ warning('You can get better tune measurements with just a single kicker.\n');
+ elseif sum(getpv('KICK','OFF_ON_STATUS')) == 0
+ warning('No kickers turned ON! Data may not be valid.');
+ end
+ % Check septum
+ if getpv('PS-SEI-3:STATUS1') == 1
+ warning('Septum (SEI-3) is turned on. This broadens the tunelines making it harder to measure the vertical tune');
+ end
+ % Check timing. Dependent on the function 'meastunearm'
+ % Events
+ if getpv('TS01EVR01:TTL01_EVENT_CODE_STATUS') ~= 13
+ warning('Timing: BPM trigger event not set to ''Storage Ring BPM''');
+ end
+ if getpv('TS01EVR06:TTL01_EVENT_CODE_STATUS') ~= 13
+ warning('Timing: Kicker 2''s trigger event not set to ''Storage Ring BPM''');
+ end
+ % BPMs must be triggered 85.4 turns (61.528 us) before the kickers. I
+ % presume these are delays in the BPM fanout and/or internal delays in the
+ % Liberas. Calculate time difference in turns relative to +85.4.
+ timedifference = (getpv('TS01EVR06:TTL01_TIME_DELAY_MONITOR') - getpv('TS01EVR01:TTL01_TIME_DELAY_MONITOR'))/720.5e-9 - 85.4;
+ if timedifference < -250 || timedifference > 250
+ warning(sprintf('Timing: BPM delay not set properly. Nominal TS01EVR01:TTL01_TIME_DELAY_SP: %11.9f seconds.',...
+ getpv('TS01EVR06:TTL01_TIME_DELAY_MONITOR') - 85.4*720.5e-9));
+ end
+
+ if method == 1
+ if any(getliberaswitches)
+ warning('Method 1 (SVD) best used with libera switches turned off');
+ end
+ if getpv('SR00SOF01:STATUS') == 2
+ warning('Turn off SOFB before turning switches off');
+ end
+ % Check to see if SOFB it turned on. Ask user to turn off before
+ % continuing. or Cancel
+% while getpv('SR00SOF01:STATUS') == 2 && method == 1 && testsource == 0
+% switch questdlg('Please turn off SOFB before running MEASTUNE.','Slow Orbit Feedback Running','Continue','Exit','Continue')
+% case 'Continue'
+% measure = 1;
+% otherwise
+% measure = 0;
+% end
+% end
+% turnswitches off &;
+% pause(1);
+
+ N = 16384;
+ % turns to evaluate at each BPM to get an accurate measure of the tunes.
+ % Generally 1000 turns is sufficient as the damping of the ring means the
+ % useful data is only if the first 1000 turns (for low amplitude kicks).
+ % For larger amplitude kicks you should select turns at the end as we
+ % probably do not want to include amplitude tuneshifts in our measurement.
+ % The improvement in the accuracy is linear with number of turns.
+ xturns = 30:1000;
+ yturns = 30:1000;
+ %xturns = 1:5000; % DJP
+ %yturns = 1:5000;
+ % Which BPMs to select from. By default based on some trial studies it
+ % seems around 40 BPMs gives a very accurate measurement of the tunes
+ % (horizontally). Adding more BPMs does not seem to help. Strangely
+ % vertical seems not to have this effect and would require all BPMs.
+ nbpm = [1:15];[2 4 5 6 8 9 10 11 12 15 20 25 30 40 50 60 70];
+% nbpm = [2 4];
+ % Component number. Try changing these numbers between 1 and 5 and see
+ % if you can get a better measure for the tune.
+ inum(1) = 1; %2
+ inum(2) = 1; %2
+
+ if testsource == 0
+ dev = elem2dev('BPMx',nbpm(:));
+ tt = getliberatbt('DD3',dev);
+ elseif testsource == 1
+ warning('Running in test mode 1');
+ filestr = '/asp/usr/measurements/bpm/2011_02_28_tbtdataproblem/offsettune_125_tbtdata.mat';
+ load(filestr);
+ tt = data;
+ clear data;
+ elseif testsource == 2
+ warning('Running in test mode 2');
+ fxstr = '500e-6*sin(2*pi*0.290*[1:10000]).*exp(-[1:10000]/1500)+0.5e-6*randn(1,10000)';
+ fystr = '100e-6*sin(2*pi*0.216*[1:10000]).*exp(-[1:10000]/1500)+0.5e-6*randn(1,10000)';
+ tt.tbtx = repmat(eval(fxstr),10,1);
+ tt.tbty = repmat(eval(fystr),10,1);
+ end
+
+% turnswitches on &;
+
+ for plane=1:2
+ if plane==1
+ data = tt.tbtx(:,xturns);
+ else
+ data = tt.tbty(:,yturns);
+ end
+ ndata = size(data,2);
+ % subtract DC
+ data = data - repmat(mean(data,2),1,ndata);
+ % Singular value decomposition. Probably the most time consuming part.
+ [u s v] = svd(data);
+ % Calculate the spectra.
+ vdata(:,plane) = v(:,inum(plane));
+ [powerspectra amplitude f] = getfftspectrum([v(:,inum(plane)); zeros(N-ndata,1)],1,N,0);
+ figure(100+plane);
+ subplot(2,2,1);
+ plot(data(1,:));
+ title('Input data first sample');
+ subplot(2,2,2);
+ semilogy(diag(s),'.-');
+ title('Singular Values');
+ subplot(2,1,2);
+ plot(f(2:end),10*log10(powerspectra(2:end)));
+ title(sprintf('Power spectra in dB for component %d',inum))
+ % Find the frequency peak x
+ % ET: getfftspectrum returns only half the FFT power spectra. So no
+ % need to find the peak in just the lower half. 06/04/2009
+ if plane==1
+ [maxval maxindx] = max(amplitude);
+ diffind = maxindx-2:maxindx+2;
+ diffb = gradient(amplitude(diffind));
+ tune(plane) = interp1(diffb,f(diffind),0);
+ end
+ % Find the frequency peak y using x peak as limiting range -50
+ % points
+ if plane ==2
+ offset_start = 100;
+ [maxval maxindy] = max(amplitude(1+offset_start:maxindx-50));
+ maxindy = maxindy + offset_start;
+ diffind = maxindy-2:maxindy+2;
+ diffb = gradient(amplitude(diffind));
+ tune(plane) = interp1(diffb,f(diffind),0);
+ end
+ end
+ elseif method == 2
+
+ if testsource == 0
+ % use only every 5
+ tt = getliberatbt('DD3',elem2dev('BPMx',sort([2:7:98 6:7:98])));
+ datax = tt.tbtx-repmat(mean(tt.tbtx,2),1,size(tt.tbtx,2)); % remove DC
+ datay = tt.tbty-repmat(mean(tt.tbty,2),1,size(tt.tbty,2));
+ clear tt;
+ elseif testsource == 1
+ warning('Running in test mode 1');
+ filestr = '/asp/usr/measurements/bpm/2011_02_28_tbtdataproblem/offsettune_125_tbtdata.mat';
+ load(filestr);
+ datax = data.tbtx-repmat(mean(data.tbtx,2),1,size(data.tbtx,2));
+ datay = data.tbty-repmat(mean(data.tbty,2),1,size(data.tbty,2));
+ clear data;
+ elseif testsource == 2
+ warning('Running in test mode 2');
+ fxstr = '500e-6*sin(2*pi*0.290*[1:10000]).*exp(-[1:10000]/1500)+0.5e-6*randn(1,10000)';
+ fystr = '100e-6*sin(2*pi*0.216*[1:10000]).*exp(-[1:10000]/1500)+0.5e-6*randn(1,10000)';
+ datax = repmat(eval(fxstr),10,1);
+ datay = repmat(eval(fystr),10,1);
+ end
+
+ % Range where the main betatron oscillations will be. With 5000
+ % samples the resolution is 2e-4;
+ % 06/2011Eugene currently starts at 131 turns as the Liberas seem
+ % to have some issues in the first 100 turns where the data is
+ % corrupted.
+ range = 131:5130;
+ N = length(range);
+ f = (0:N/2) / N;
+
+ t = [1:length(range)];
+ p = 1;
+ kai = ( 2^p*(factorial(p))^2*(1+cos(pi*(2*(t-max(t)/2)/max(t)))).^p/factorial(2*p) );
+ kai = 1;repmat(kai/max(kai),size(datax,1),1)';
+
+ fftdatax1 = fft(kai.*datax(:,range)');
+ fftdatay1 = fft(kai.*datay(:,range)');
+
+ range = 1:430;
+
+ t = [1:length(range)];
+ p = 1;
+ kai = ( 2^p*(factorial(p))^2*(1+cos(pi*(2*(t-max(t)/2)/max(t)))).^p/factorial(2*p) );
+ kai = 1;repmat(kai/max(kai),size(datax,1),1)';
+
+ fftdataysmall = fft(kai.*datay(:,range)');
+ Nsmall = length(range);
+ fsmall = (0:Nsmall/2) / Nsmall;
+
+ % The back end where some damping have occured and use this as a
+ % baseline
+ range = 5001:10000;
+
+ t = [1:length(range)];
+ p = 1;
+ kai = ( 2^p*(factorial(p))^2*(1+cos(pi*(2*(t-max(t)/2)/max(t)))).^p/factorial(2*p) );
+ kai = 1;repmat(kai/max(kai),size(datax,1),1)';
+
+
+ fftdatax2 = fft(kai.*datax(:,range)');
+ fftdatay2 = fft(kai.*datay(:,range)');
+
+ % Calculate the relative amplitude of the signal. Subtract the
+ % baseline spectrum.
+ range = 1:fix(N/2)+1;
+ ampxraw = abs(fftdatax1(range,:))/(N/2);
+ ampxbase = abs(fftdatax2(range,:))/(N/2);
+ ampyraw = abs(fftdatay1(range,:))/(N/2);
+ ampybase = abs(fftdatay2(range,:))/(N/2);
+ ampx = ampxraw - ampxbase;
+ ampy = ampyraw - ampybase;
+
+ % Horizontal Tune
+ [val(1) ind] = max(mean(ampx(500:end,:),2));
+ ind = ind + 500-1;
+ tune(1) = f(ind);
+
+ % Try and remove the horizontal component from the measurement. In
+ % this way relative amplitudes between horizontal and vertical
+ % should not be used as betatron coupling...
+ ampyxcomp = max(mean(ampy'))/max(mean(ampx'))*mean(ampx');
+% ampyxcomp = sum(mean(ampx')/sum(mean(ampx')).*mean(ampy')/sum(mean(ampy')))*mean(ampx');
+
+% Possibly use the smaller FFT to find the peak then search around
+% it however this encounters poblems with the synchrotron tune
+% being stronger and also the horizontal tune. So for now this idea
+% is abandoned. The smaller FFT also has an issue with frequency
+% resolution where if the the resonant peak at the FFT data point
+% will be larger in amplitude than if the resonant peak is between
+% data points. Therefore as the tune drifts its amplitude will go
+% up and down and can swap in maximum amplitude with its sidebands.
+% This may be overcome with max resolution FTT coupled with binning
+% before peak searching.
+ range = 1:fix(Nsmall/2)+1;
+ ampysmall = abs(fftdataysmall(range,:))/(N/2);
+% [tempval tempind] = max(mean(ampysmall'));
+% peaksearchrange = find(f > fsmall(tempind)-0.009 & f < fsmall(tempind)+0.009);
+
+
+ ampy = mean(ampy') - ampyxcomp;
+ ampy = filter([1 1 1 1]/4,1,ampy);
+ [val(2) ind] = max(ampy(:));
+ tune(2) = f(ind);
+
+ figure(104); clf;
+% set(gcf,'Position',[588 431 744 606]);
+ subplot(2,1,1);
+ semilogy(f,abs(mean(ampx,2)));
+ ylabel('X Amplitude (nm) [bg subtraction]');
+ xlabel('Fractional Tune');
+ if testsource == 1;
+ hold on;
+ semilogy(f,mean(ampxraw,2),'r');
+ semilogy(f,mean(ampxbase,2),'k');
+ hold off;
+ title(sprintf('From data saved in: %s (Tune: %7.5f, Amp: %5.1f um)',filestr,tune(1),val(1)*1e-3),'Interpreter','none');
+ elseif testsource == 2
+ hold on;
+ semilogy(f,mean(ampxraw,2),'r');
+ semilogy(f,mean(ampxbase,2),'k');
+ hold off;
+ title(sprintf('Test function: %s (Tune: %7.5f, Amp: %5.1f um)',fxstr,tune(1),val(1)*1e6));
+ end
+
+ subplot(2,1,2);
+ semilogy(f,abs(ampy));
+% plot(f,abs(ampy))
+ ylabel('Y Amplitude (nm) [bg subtraction & H comp. removal]');
+ xlabel('Fractional Tune');
+
+ if testsource == 0
+ hold on;
+ semilogy(fsmall, abs(mean(ampysmall,2)),'r');
+ hold off;
+ %legend('High resolution averaged spectrum','Low resolution averaged spectrum');
+ elseif testsource == 1;
+ hold on;
+ semilogy(f,mean(ampyraw,2),'r');
+ semilogy(f,mean(ampybase,2),'k');
+ semilogy(f,ampyxcomp,'g');
+ hold off;nargout
+ title(sprintf('From data saved in: %s (Tune: %7.5f, Amp: %5.1f um)',filestr,tune(2),val(2)*1e-3),'Interpreter','none');
+ legend('Treated spectrum','Raw Spectrum','Base line spectrum subtraced from raw spectrum','Horizontal compoennt');
+ elseif testsource == 2
+ hold on;
+ semilogy(f,mean(ampyraw,2),'r');
+ semilogy(f,mean(ampybase,2),'k');
+ semilogy(f,ampyxcomp,'g');
+ hold off;
+ title(sprintf('Test function: %s (Tune: %7.5f, Amp: %5.1f um)',fystr,tune(2),val(2)*1e6));
+ legend('Treated spectrum','Raw Spectrum','Base line spectrum subtraced from raw spectrum','Horizontal compoennt');
+ end
+ else
+ tune = [NaN NaN];
+ end
+
+ case 3 % FRom R&S SPA
+
+%TUNES FROM THE SPA
+% mo = getsp('RF');
+% tune = sr11spa01_matlab(mo(1),29.1474444e6,0.29,0.04,0.22,0.04);
+% disp('Tunes from the SPA (returned by program):')
+% disp(tune')
+
+ pause(5);
+ tune(1) = getpv('SR00TUM01:X_TUNE_MONITOR');
+ tune(2) = getpv('SR00TUM01:Y_TUNE_MONITOR');
-% else
+ case 4
+ pause(2);
+ tune(1) = getpv('IGPF:X:SRAM:PEAKTUNE2');
+ tune(2) = getpv('IGPF:Y:SRAM:PEAKTUNE2');
-% directory = pwd;
-%
-% mo = getsp('SR00MOS01:FREQUENCY_MONITOR');
-%
-% cd /asp/usr/middleLayer/machine/asp/spa
-%
-% t0 = clock;
-% temp = ['sr11spa01 ' num2str(mo) ' ' num2str(5550000) ' ' num2str(0.28) ' ' num2str(0.03) ' ' num2str(0.23) ' ' num2str(0.03)];
-%
-% [a tune] = system(temp);
-% tune = str2num(tune);
-%
-% cd(directory);
-% end
-
-if nargout > 0
- varargout{1} = tune(:);
end
+
+varargout{1} = tune(:);
if nargout > 1
% tout
varargout{2} = clock;
@@ -55,6 +356,7 @@
% Error flag
varargout{4} = 0;
end
-
-
-
+if nargout > 4
+ % tune amplitude
+ varargout{5} = 0;
+end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/measureoffsets.m b/machine/ASP/StorageRing/measureoffsets.m
new file mode 100644
index 00000000..1cbd6720
--- /dev/null
+++ b/machine/ASP/StorageRing/measureoffsets.m
@@ -0,0 +1,181 @@
+% Ensure the following are done before carrying out BBA.
+% - Inject to 200 mA with cavities at full voltage
+% - Injection system turned off (minimise noise)
+% - No SOFB program running.
+switch questdlg({'Have the following been done?';...
+ '1. Inject to 200 mA with cavities at full voltage';...
+ '2. Injection system turned off (minimise noise)';...
+ '3. No SOFB program running'},...
+ 'Checklist before starting measuring offsets',...
+ 'Yes','No','No');
+ case 'No'
+ return;
+end
+fprintf('\nStarting BBA...\n');
+
+% Choose which plane
+switch questdlg('Which plane to measure?',...
+ 'Plane selection',...
+ 'Both','Horizontal','Vertical','Both');
+ case 'Both'
+ plane = 0;
+ case 'Horizontal'
+ plane = 1;
+ case 'Vertical'
+ plane = 2;
+ otherwise
+ disp('Unknown selection! Quitting');
+ return
+end
+fprintf('Plane selected (0-both, 1-Horiz, 2-Vert): %d\n',plane);
+
+% Beam based alignment needs to be done in 3 sections to minimise the beam
+% current dependance and get more accurate results.
+switch questdlg('You are about to perform Beam Based Alignment and can take up to 3 hours. Continue?',...
+ 'Final Check',...
+ 'Yes','No','No');
+ case 'No'
+ disp('Bye Bye');
+ return;
+end
+disp('The following measurements will be done in 3 parts as follows:');
+disp(' Sectors 1-4, sectors 5-9 followed by 10-14');
+
+% problem BPMs
+prob_dev = [];
+
+% Beam based alignment needs to be done in 3 sections to minimise the beam
+% current dependance and get more accurate results.
+switch questdlg('Please correct the orbit before continuing.','BBA Sectors 1-4','Done','Cancel','Done');
+ case 'Cancel'
+ disp('Leaving BBA. Bye bye');
+ return
+end
+% Sector number for BPM
+for i=1:4
+ % BPM number within the sector
+ for j=1:7
+
+ BPMDev = [i j];
+ if getfamilydata('BPMx','Status',BPMDev) == 0
+ continue;
+ end
+
+ switch BPMDev(2)
+ case {1 2}
+ quadfam = 'QFA';
+ quaddev = [BPMDev(1) 1];
+ case 3
+ quadfam = 'QDA';
+ quaddev = [BPMDev(1) 1];
+ case 4
+ quadfam = 'QFB';
+ quaddev = [BPMDev(1) 1];
+ case 5
+ quadfam = 'QDA';
+ quaddev = [BPMDev(1) 2];
+ case {6 7}
+ quadfam = 'QFA';
+ quaddev = [BPMDev(1) 2];
+ end
+
+ try
+% quadcenter(quadfam,quaddev,plane,BPMDev);
+ catch
+ prob_dev(end+1,1:2) = BPMDev;
+ end
+ end
+end
+
+% Now do sectors 5-9
+% Beam based alignment needs to be done in 3 sections to minimise the beam
+% current dependance and get more accurate results.
+switch questdlg('Inject to 200 mA and correct the orbit before continuing.','BBA Sectors 5-9','Done','Cancel','Done');
+ case 'Cancel'
+ disp('Leaving BBA. Bye bye');
+ return
+end
+% Sector number for BPM
+for i=5:9
+ % BPM number within the sector
+ for j=1:7
+
+ BPMDev = [i j];
+ if getfamilydata('BPMx','Status',BPMDev) == 0
+ continue;
+ end
+
+ switch BPMDev(2)
+ case {1 2}
+ quadfam = 'QFA';
+ quaddev = [BPMDev(1) 1];
+ case 3
+ quadfam = 'QDA';
+ quaddev = [BPMDev(1) 1];
+ case 4
+ quadfam = 'QFB';
+ quaddev = [BPMDev(1) 1];
+ case 5
+ quadfam = 'QDA';
+ quaddev = [BPMDev(1) 2];
+ case {6 7}
+ quadfam = 'QFA';
+ quaddev = [BPMDev(1) 2];
+ end
+
+ try
+% quadcenter(quadfam,quaddev,plane,BPMDev);
+ catch
+ prob_dev(end+1,1:2) = BPMDev;
+ end
+ end
+end
+
+% Now do sectors 10-14
+% Beam based alignment needs to be done in 3 sections to minimise the beam
+% current dependance and get more accurate results.
+switch questdlg('Inject to 200 mA and correct the orbit before continuing.','BBA Sectors 10-14','Done','Cancel','Done');
+ case 'Cancel'
+ disp('Leaving BBA. Bye bye');
+ return
+end
+% Sector number for BPM
+for i=10:14
+ % BPM number within the sector
+ for j=1:7
+
+ BPMDev = [i j];
+ if getfamilydata('BPMx','Status',BPMDev) == 0
+ continue;
+ end
+
+ switch BPMDev(2)
+ case {1 2}
+ quadfam = 'QFA';
+ quaddev = [BPMDev(1) 1];
+ case 3
+ quadfam = 'QDA';
+ quaddev = [BPMDev(1) 1];
+ case 4
+ quadfam = 'QFB';
+ quaddev = [BPMDev(1) 1];
+ case 5
+ quadfam = 'QDA';
+ quaddev = [BPMDev(1) 2];
+ case {6 7}
+ quadfam = 'QFA';
+ quaddev = [BPMDev(1) 2];
+ end
+
+ try
+% quadcenter(quadfam,quaddev,plane,BPMDev);
+ catch
+ prob_dev(end+1,1:2) = BPMDev;
+ end
+ end
+end
+
+if ~isempty(prob_dev)
+ fprintf('\nSOME PROBLEMS WITH THE FOLLOWING BPMs when doing BBA:\n');
+ fprintf(' %02d %1d\n',prob_dev');
+end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/opticalbpmanalyse.m b/machine/ASP/StorageRing/opticalbpmanalyse.m
deleted file mode 100644
index b7591dfc..00000000
--- a/machine/ASP/StorageRing/opticalbpmanalyse.m
+++ /dev/null
@@ -1,100 +0,0 @@
-
-if 0
- time = 1:3600;
-
- pos = getpv({'SR07BM01PSD01:XPOS_MONITOR' 'SR07BM01PSD01:YPOS_MONITOR' 'SR01BPM07:SA_X_MONITOR' 'SR01BPM07:SA_Y_MONITOR'},time);
- xposopt = cell2mat(pos(1));
- yposopt = cell2mat(pos(2));
- xposlib = cell2mat(pos(3));
- yposlib = cell2mat(pos(4));
-
- now = clock;
- filesave = ['/asp/usr/commissioning/instabilities/' datestr(now,'yyyy-mm-dd') '-' num2str(now(4)) '-' num2str(now(5)) '-' num2str(fix(now(6)))];
- fprintf('Data saved to: %s\n',filesave);
- save(filesave, 'xposopt', 'yposopt', 'xposlib', 'yposlib', 'time');
-end
-
- xpos = xposopt;
- ypos = yposopt;
-
- xpos = xpos - mean(xpos);
- ypos = ypos - mean(ypos);
-
- xpos = xpos/max(xpos);
- ypos = ypos/max(ypos);
-
-% xpos = sin(time);
-% ypos = sin(time).*sin(0.1*time);
-
-xpos_fft = fft(xpos);
-ypos_fft = fft(ypos);
-
-figure;
-
-subplot(2,2,1)
-plot(time,xpos,'b*-')
-title('X position')
-xlabel('seconds')
-ylabel('beam position')
-hold on;
-
-subplot(2,2,3)
-plot(time(1:end/2)/length(time),xpos_fft(1:end/2).*conj(xpos_fft(1:end/2)),'b*-');
-title('FFT of X position')
-xlabel('Hz')
-hold on;
-
-subplot(2,2,2)
-plot(time,ypos,'b*-')
-title('Y position')
-xlabel('seconds')
-ylabel('beam position')
-hold on;
-
-subplot(2,2,4)
-plot(time(1:end/2)/length(time),ypos_fft(1:end/2).*conj(ypos_fft(1:end/2)),'b*-');
-title('FFT of Y position')
-xlabel('Hz')
-hold on;
-
-xpos = xposlib;
-ypos = yposlib;
-
- xpos = xpos - mean(xpos);
- ypos = ypos - mean(ypos);
-
- xpos = xpos/max(xpos);
- ypos = ypos/max(ypos);
-
-% xpos = sin(time);
-% ypos = sin(time).*sin(0.1*time);
-
-xpos_fft = fft(xpos);
-ypos_fft = fft(ypos);
-
-subplot(2,2,1)
-plot(time,xpos,'r*-')
-title('X position')
-xlabel('seconds')
-ylabel('beam position')
-
-
-subplot(2,2,3)
-plot(time(1:end/2)/length(time),xpos_fft(1:end/2).*conj(xpos_fft(1:end/2)),'r*-');
-title('FFT of X position')
-xlabel('Hz')
-
-
-subplot(2,2,2)
-plot(time,ypos,'r*-')
-title('Y position')
-xlabel('seconds')
-ylabel('beam position')
-
-
-subplot(2,2,4)
-plot(time(1:end/2)/length(time),ypos_fft(1:end/2).*conj(ypos_fft(1:end/2)),'r*-');
-title('FFT of Y position')
-xlabel('Hz')
-legend('optical BPM','Button BPM');
-
diff --git a/machine/ASP/StorageRing/orbitdrift.mat b/machine/ASP/StorageRing/orbitdrift.mat
deleted file mode 100644
index cd485c2d..00000000
Binary files a/machine/ASP/StorageRing/orbitdrift.mat and /dev/null differ
diff --git a/machine/ASP/StorageRing/orbitgui.m b/machine/ASP/StorageRing/orbitgui.m
new file mode 100644
index 00000000..a0a9facd
--- /dev/null
+++ b/machine/ASP/StorageRing/orbitgui.m
@@ -0,0 +1,6 @@
+function orbitgui(varargin)
+ warning('orbitgui is deprecated. Please use setorbitgui instead.\nIf you really want to use orbitgui, run orbitgui(1)', '');
+ if nargin
+ run('/asp/usr/middleLayer/applications/orbit/asp/orbitgui.m');
+ end
+end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/plotfamilystartup.m b/machine/ASP/StorageRing/plotfamilystartup.m
index 45a23116..bdecfb62 100644
--- a/machine/ASP/StorageRing/plotfamilystartup.m
+++ b/machine/ASP/StorageRing/plotfamilystartup.m
@@ -1,48 +1,48 @@
-function plotfamilystartup(handles)
-% plotfamilystartup(handles)
-
-
-Menu0 = handles.('LatticeConfiguration');
-
-%MenuAdd = uimenu(Menu0, 'Label','Add an Injection Bump - bumpinj');
-%set(MenuAdd,'Callback', 'bumpinj');
-%set(MenuAdd, 'Separator','Off');
-
-
-
-% Add a sector menu
-Sectors = 14;
-L = getfamilydata('Circumference');
-if ~isempty(L)
- Menu0 = handles.figure1;
- Menu0 = uimenu(Menu0, 'Label', 'Sector');
- set(Menu0, 'Position', 3);
- set(Menu0, 'Separator', 'On');
-
- % Arc sections
- Extra = 4; % meters
- i = 1;
- Menu1 = uimenu(Menu0, 'Label',sprintf('Arc Sector %d',i));
- set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[0 Extra+L/Sectors]+(i-1)*L/Sectors),'],guidata(gcbo))']);
- for i = 2:Sectors-1
- Menu1 = uimenu(Menu0, 'Label',sprintf('Arc Sector %d',i));
- set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[0-Extra Extra+L/Sectors]+(i-1)*L/Sectors),'],guidata(gcbo))']);
- end
- i = Sectors;
- Menu1 = uimenu(Menu0, 'Label',sprintf('Arc Sector %d',i));
- set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[L-L/Sectors-Extra L]),'],guidata(gcbo))']);
-
- % Straight sections
- Extra = 9; % meters
- for i = 1:Sectors-1
- Menu1 = uimenu(Menu0, 'Label',sprintf('Straight Section %d',i));
- %set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[-Extra Extra]+(i-1)*L/Sectors),'],guidata(gcbo))']);
- set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[-Extra Extra]+i*L/Sectors),'],guidata(gcbo))']);
- end
- Menu1 = uimenu(Menu0, 'Label',sprintf('Straight Section %d',14));
- set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[L-Extra L]),'],guidata(gcbo))']);
-end
-
-
-
-drawnow;
+function plotfamilystartup(handles)
+% plotfamilystartup(handles)
+
+
+Menu0 = handles.('LatticeConfiguration');
+
+%MenuAdd = uimenu(Menu0, 'Label','Add an Injection Bump - bumpinj');
+%set(MenuAdd,'Callback', 'bumpinj');
+%set(MenuAdd, 'Separator','Off');
+
+
+
+% Add a sector menu
+Sectors = 14;
+L = getfamilydata('Circumference');
+if ~isempty(L)
+ Menu0 = handles.figure1;
+ Menu0 = uimenu(Menu0, 'Label', 'Sector');
+ set(Menu0, 'Position', 3);
+ set(Menu0, 'Separator', 'On');
+
+ % Arc sections
+ Extra = 4; % meters
+ i = 1;
+ Menu1 = uimenu(Menu0, 'Label',sprintf('Arc Sector %d',i));
+ set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[0 Extra+L/Sectors]+(i-1)*L/Sectors),'],guidata(gcbo))']);
+ for i = 2:Sectors-1
+ Menu1 = uimenu(Menu0, 'Label',sprintf('Arc Sector %d',i));
+ set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[0-Extra Extra+L/Sectors]+(i-1)*L/Sectors),'],guidata(gcbo))']);
+ end
+ i = Sectors;
+ Menu1 = uimenu(Menu0, 'Label',sprintf('Arc Sector %d',i));
+ set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[L-L/Sectors-Extra L]),'],guidata(gcbo))']);
+
+ % Straight sections
+ Extra = 9; % meters
+ for i = 1:Sectors-1
+ Menu1 = uimenu(Menu0, 'Label',sprintf('Straight Section %d',i));
+ %set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[-Extra Extra]+(i-1)*L/Sectors),'],guidata(gcbo))']);
+ set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[-Extra Extra]+i*L/Sectors),'],guidata(gcbo))']);
+ end
+ Menu1 = uimenu(Menu0, 'Label',sprintf('Straight Section %d',14));
+ set(Menu1,'Callback', ['plotfamily(''HorizontalAxisSector_Callback'',gcbo,[',sprintf('%f %f',[L-Extra L]),'],guidata(gcbo))']);
+end
+
+
+
+drawnow;
diff --git a/machine/ASP/StorageRing/plotturnorbit.m b/machine/ASP/StorageRing/plotturnorbit.m
index 76245fbe..1d24ccac 100644
--- a/machine/ASP/StorageRing/plotturnorbit.m
+++ b/machine/ASP/StorageRing/plotturnorbit.m
@@ -20,12 +20,12 @@
% setlibera('TT_READY_STATUS',0,deviceList(ind,:));
% setlibera('TT_ARM_CMD',1,deviceList(ind,:));
-finished_num = getlibera('DD3_FINISHED_MONITOR',deviceList);
-setlibera('DD3_ON_NEXT_TRIG_CMD',1,deviceList);
+finished_num = getlibera('DD3_FINISHED_MONITOR',deviceList(ind,:));
+setlibera('DD3_ON_NEXT_TRIG_CMD',1,deviceList(ind,:));
pause(1);
ii = 0;
-while any(getlibera('DD3_FINISHED_MONITOR',deviceList) == finished_num)
+while any(getlibera('DD3_FINISHED_MONITOR',deviceList(ind,:)) == finished_num)
pause(0.3);
ii = ii + 1;
if ii > 20
@@ -34,6 +34,7 @@
end
end
+% Convert the nm units that is Hardware into meters (physics) or mm (hardware).
if strcmpi(getunits('BPMx'),'Physics')
units_conversion = 1e-9; % in meters
unitsstr = 'm';
@@ -44,20 +45,20 @@
for i=1:length(ind)
% Try to avoid memory problems
- tbtsum(i,:) = getlibera('DD3_SUM_MONITOR',deviceList(ind(i),:));
+% tbtsum(i,:) = getlibera('DD3_SUM_MONITOR',deviceList(ind(i),:));
tbtx(i,:) = getlibera('DD3_X_MONITOR',deviceList(ind(i),:))*units_conversion;
tbty(i,:) = getlibera('DD3_Y_MONITOR',deviceList(ind(i),:))*units_conversion;
end
-
+% Turn offset to try to synchronise the turns
for i=1:length(ind)
switch deviceList(ind(i),1)
case [5 6 7 8 9 10 11 13 14]
- tbtsum(i,:) = circshift(tbtsum(i,:),[0 -1]);
+% tbtsum(i,:) = circshift(tbtsum(i,:),[0 -1]);
tbtx(i,:) = circshift(tbtx(i,:),[0 -1]);
tbty(i,:) = circshift(tbty(i,:),[0 -1]);
case 12
- tbtsum(i,:) = circshift(tbtsum(i,:),[0 -2]);
+% tbtsum(i,:) = circshift(tbtsum(i,:),[0 -2]);
tbtx(i,:) = circshift(tbtx(i,:),[0 -2]);
tbty(i,:) = circshift(tbty(i,:),[0 -2]);
end
@@ -175,5 +176,16 @@
if nargout > 0
varargout{1} = tbtx(:,turnsind);
end
+if nargout > 1
+ varargout{2} = tbty(:,turnsind);
+end
+if nargout > 2
+ tmp.tbtx = tbtx;
+ tmp.tbty = tbty;
+ tmp.closedorbitx = closedorbitx;
+ tmp.closedorbity = closedorbity;
+ varargout{3} = tmp;
+ clear tmp;
+end
clear tbtsum tbtx tbty;
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/quadcenter_all.m b/machine/ASP/StorageRing/quadcenter_all.m
index 18a17ac6..94db95c5 100644
--- a/machine/ASP/StorageRing/quadcenter_all.m
+++ b/machine/ASP/StorageRing/quadcenter_all.m
@@ -1,14 +1,78 @@
-close all
-% 0 = both planes; 1 = x-plane; 2 = y-plane
-plane = 0;
+% This script is designed to run BBA on all BPMs. For manual measurements
+% of BPMs please use QUADCENTER_MANUAL
+%
+% Eugene Tan 09-10-2007
+% Eugene Tan 15-01-2008: Modified to check the DCCT instead of just
+
+% Ensure the following are done before carrying out BBA.
+% - Inject to 200 mA with cavities at full voltage
+% - Injection system turned off (minimise noise)
+% - No SOFB program running.
+% Will assume for now that AGC will not have an adverse effect since we are
+% keeping the beam current to 185 mA and above.
+dcctvalue = 200; % current initally injected to
+tol = 15; % allowable current drop before having to reinject
+
+switch questdlg({'Have the following been done?';...
+ sprintf('1. Inject to %3d mA with cavities at full voltage',dcctvalue);...
+ '2. Injection system turned off (minimise noise)';...
+ '3. No OFB program running';...
+ '4. Run "setliberaconfig" to initialise the BPMs';...
+ '5. Ramped down the SCW';...
+ '6. IDs set correctly';},...
+ 'Checklist before starting measuring offsets',...
+ 'Yes','No','No');
+ case 'No'
+ disp('Bye bye');
+ return;
+end
+fprintf('\nStarting BBA...\n');
+
+% Choose which plane
+switch questdlg('Which plane to measure?',...
+ 'Plane selection',...
+ 'Both','Horizontal','Vertical','Both');
+ case 'Both'
+ plane = 0;
+ case 'Horizontal'
+ plane = 1;
+ case 'Vertical'
+ plane = 2;
+ otherwise
+ disp('Unknown selection! Quitting');
+ return
+end
+fprintf('Plane selected (0-both, 1-Horiz, 2-Vert): %d\n',plane);
+
+% Beam based alignment needs to be done in 3 sections to minimise the beam
+% current dependance and get more accurate results.
+switch questdlg('You are about to perform Beam Based Alignment and can take up to 3 hours. Continue?',...
+ 'Final Check',...
+ 'Yes','No','No');
+ case 'No'
+ disp('Bye Bye');
+ return;
+end
+
+%Commented for Brilliance+ testing, check with Eugene if it is needed for
+%BBA (08/09/2017)
+%fprintf('Turning AGC off on the Liberas before continuing...');
+%setlibera('ENV_AGC_SP',0); pause(1);
+%setlibera('ENV_SET_INTERLOCK_PARAM_CMD',1);
+%fprintf('done!\n');
+
+% disp(' The following measurements will be done in 3 parts as follows:');
+% disp(' Sectors 1-4, sectors 5-9 followed by 10-14');
+
+% problem BPMs
+prob_dev = [];
% Sector number for BPM
for i=1:14
% BPM number within the sector
for j=1:7
- BPMDev = [i j];
-
+ BPMDev = [i j];
if getfamilydata('BPMx','Status',BPMDev) == 0
continue;
end
@@ -31,13 +95,239 @@
quaddev = [BPMDev(1) 2];
end
- QMS = quadcenterinit(quadfam,quaddev,plane,BPMDev);
- quadcenter(QMS);
+ try
+ % Store corrector magnet setpoints incase an error is
+ % encountered which stops quadcenter() from reloading these
+ % setpoints.
+ HCM0 = getsp('HCM');
+ VCM0 = getsp('VCM');
+ QFA0 = getsp('QFA');
+ QDA0 = getsp('QDA');
+ quadcenter(quadfam,quaddev,plane,BPMDev);
+ catch
+ % quadcenter() encountered an error, reload the magnet
+ % setpoints and log which BPMs the error occured for.
+ setsp('HCM',HCM0);
+ setsp('VCM',VCM0);
+ setsp('QFA',QFA0);
+ setsp('QDA',QDA0);
+ prob_dev(end+1,1:2) = BPMDev;
+ end
+
+ %Added to stop window spam (RH - 08/09/17)
+ close all;
end
+
+% fid = fopen('/scratch/mhave/announce/TimeToCorrect5.del','w'); fprintf(fid,'test'); fclose(fid);
+% questdlg('Please correct the orbit.','Orbit correction','Done','Done');
+
+ if getdcct < dcctvalue-tol
+ % if the current drops below the tolerance
+
+ % ---- File name changed
+ %fid = fopen('/scratch/mhave/announce/5mins_to_injection.del','w'); fprintf(fid,'test'); fclose(fid);
+ switch questdlg(sprintf('Please refill to %3d mA and correct the orbit before continuing.',dcctvalue),'Refill ring','Done','Cancel','Done');
+ case 'Cancel'
+ if ~isempty(prob_dev)
+ fprintf('\nSOME PROBLEMS WITH THE FOLLOWING BPMs when doing BBA:\n');
+ fprintf(' %02d %1d\n',prob_dev');
+ end
+ disp('Leaving BBA. Those that have been done have been saved. Bye bye');
+ return
+ end
+ end
+
+end
+
+
+if ~isempty(prob_dev)
+ fprintf('\nSOME PROBLEMS WITH THE FOLLOWING BPMs when doing BBA:\n');
+ fprintf(' %02d %1d\n',prob_dev');
end
return
+%% OLD PROGRAM
+
+% % Beam based alignment needs to be done in 3 sections to minimise the beam
+% % current dependance and get more accurate results.
+% switch questdlg('Please correct the orbit before continuing.','BBA Sectors 1-4','Done','Cancel','Done');
+% case 'Cancel'
+% disp('Leaving BBA. Bye bye');
+% return
+% end
+% % Sector number for BPM
+% for i=1:4
+% % BPM number within the sector
+% for j=1:7
+%
+% BPMDev = [i j];
+% if getfamilydata('BPMx','Status',BPMDev) == 0
+% continue;
+% end
+%
+% switch BPMDev(2)
+% case {1 2}
+% quadfam = 'QFA';
+% quaddev = [BPMDev(1) 1];
+% case 3
+% quadfam = 'QDA';
+% quaddev = [BPMDev(1) 1];
+% case 4
+% quadfam = 'QFB';
+% quaddev = [BPMDev(1) 2];
+% case 5
+% quadfam = 'QDA';
+% quaddev = [BPMDev(1) 2];
+% case {6 7}
+% quadfam = 'QFA';
+% quaddev = [BPMDev(1) 2];
+% end
+%
+% try
+% quadcenter(quadfam,quaddev,plane,BPMDev);
+% catch
+% prob_dev(end+1,1:2) = BPMDev;
+% end
+% end
+% end
+%
+% % Now do sectors 5-9
+% % Beam based alignment needs to be done in 3 sections to minimise the beam
+% % current dependance and get more accurate results.
+% switch questdlg('Inject to 200 mA and correct the orbit before continuing.','BBA Sectors 5-9','Done','Cancel','Done');
+% case 'Cancel'
+% disp('Leaving BBA. Bye bye');
+% return
+% end
+% % Sector number for BPM
+% for i=5:9
+% % BPM number within the sector
+% for j=1:7
+%
+% BPMDev = [i j];
+% if getfamilydata('BPMx','Status',BPMDev) == 0
+% continue;
+% end
+%
+% switch BPMDev(2)
+% case {1 2}
+% quadfam = 'QFA';
+% quaddev = [BPMDev(1) 1];
+% case 3
+% quadfam = 'QDA';
+% quaddev = [BPMDev(1) 1];
+% case 4
+% quadfam = 'QFB';
+% quaddev = [BPMDev(1) 2];
+% case 5
+% quadfam = 'QDA';
+% quaddev = [BPMDev(1) 2];
+% case {6 7}
+% quadfam = 'QFA';
+% quaddev = [BPMDev(1) 2];
+% end
+%
+% try
+% quadcenter(quadfam,quaddev,plane,BPMDev);
+% catch
+% prob_dev(end+1,1:2) = BPMDev;
+% end
+% end
+% end
+%
+% % Now do sectors 10-14
+% % Beam based alignment needs to be done in 3 sections to minimise the beam
+% % current dependance and get more accurate results.
+% switch questdlg('Inject to 200 mA and correct the orbit before continuing.','BBA Sectors 10-14','Done','Cancel','Done');
+% case 'Cancel'
+% disp('Leaving BBA. Bye bye');
+% return
+% end
+% % Sector number for BPM
+% for i=10:14
+% % BPM number within the sector
+% for j=1:7
+%
+% BPMDev = [i j];
+% if getfamilydata('BPMx','Status',BPMDev) == 0
+% continue;
+% end
+%
+% switch BPMDev(2)
+% case {1 2}
+% quadfam = 'QFA';
+% quaddev = [BPMDev(1) 1];
+% case 3
+% quadfam = 'QDA';
+% quaddev = [BPMDev(1) 1];
+% case 4
+% quadfam = 'QFB';
+% quaddev = [BPMDev(1) 2];
+% case 5
+% quadfam = 'QDA';
+% quaddev = [BPMDev(1) 2];
+% case {6 7}
+% quadfam = 'QFA';
+% quaddev = [BPMDev(1) 2];
+% end
+%
+% try
+% quadcenter(quadfam,quaddev,plane,BPMDev);
+% catch
+% prob_dev(end+1,1:2) = BPMDev;
+% end
+% end
+% end
+%
+% if ~isempty(prob_dev)
+% fprintf('\nSOME PROBLEMS WITH THE FOLLOWING BPMs when doing BBA:\n');
+% fprintf(' %02d %1d\n',prob_dev');
+% end
+%
+%
+% return
+%
+% close all
+% % 0 = both planes; 1 = x-plane; 2 = y-plane
+% plane = 0;
+%
+%
+% % Sector number for BPM
+% for i=4
+% % BPM number within the sector
+% for j=3
+%
+% BPMDev = [i j];
+%
+% if getfamilydata('BPMx','Status',BPMDev) == 0
+% continue;
+% end
+%
+% switch BPMDev(2)
+% case {1 2}
+% quadfam = 'QFA';
+% quaddev = [BPMDev(1) 1];
+% case 3
+% quadfam = 'QDA';
+% quaddev = [BPMDev(1) 1];
+% case 4
+% quadfam = 'QFB';
+% quaddev = [BPMDev(1) 1];
+% case 5
+% quadfam = 'QDA';
+% quaddev = [BPMDev(1) 2];
+% case {6 7}
+% quadfam = 'QFA';
+% quaddev = [BPMDev(1) 2];
+% end
+%
+% quadcenter(quadfam,quaddev,plane,BPMDev);
+% end
+% end
+%
+%
+% return
@@ -147,4 +437,4 @@
% voffsets(quadstruct(i).bpmelemind) = qms2;
% end
% end
-% end
+% end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/quadcenter_eugene.m b/machine/ASP/StorageRing/quadcenter_eugene.m
new file mode 100644
index 00000000..d0efc419
--- /dev/null
+++ b/machine/ASP/StorageRing/quadcenter_eugene.m
@@ -0,0 +1,1025 @@
+function [QMS1, QMS2] = quadcenter(QuadFamily, QuadDev, XYPlane, BPMDev, FigureHandle)
+%QUADCENTER - Measure the magnet center of a quadrupole magnet
+% [QMS1, QMS2] = quadcenter(QuadFamily, QuadDev, XYPlane, BPMDev, FigureHandle)
+% or
+% [QMS1, QMS2] = quadcenter(QMSstructure, FigureHandle)
+%
+% Finds the center of an individual quadrupole magnet.
+% The data is automatically appended to quadcenter.log and
+% saved to an individual mat file named by family, sector, and element number
+%
+% INPUTS
+% 1. QuadFamily = Family name
+% 2. QuadDev = Device list for quadrupole family
+% 3. XYPlane = 0 -> both horizontal and vertical {default}
+% 1 -> horizontal only
+% 2 -> vertical only
+% 4. BPMDev = Device list for BPM family (defined in quadcenterinit)
+% 5. FigureHandle can be a figure handle, a vector of 4 axes handles
+% (used by quadplot), or zero for no plots
+%
+% The QuadFamily and QuadDev input get converted to a QMSstructure using quadcenterinit.
+% One can also directly input this data structure.
+% QMSstructure =
+% QuadFamily: Quadrupole family name, like 'QF'
+% QuadDev: Quadrupole device, like [7 1]
+% QuadDelta: Modulation amplitude in the quadrupole, like 1
+% QuadPlane: Horizontal (1) or vertical (2) plane
+% CorrFamily: Corrector magnet family, like 'HCM'
+% CorrDevList: Corrector magnet(s) using to vary the orbit in the quadrupole, like [7 1]
+% CorrDelta: Maximum change in the corrector(s), like 0.5000
+% BPMFamily: BPM family name, like 'BPMx'
+% BPMDev: BPM device next to the quadrupole, like [7 1]
+% BPMDevList: BPM device list used calculate the center and for orbit correction ([nx2 array])
+% ModulationMethod: Method for changing the quadrupole
+% 'bipolar' changes the quadrupole by +/- QuadDelta on each step
+% 'unipolar' changes the quadrupole from 0 to QuadDelta on each step
+% 'sweep' moves the quadrupole by QuadDelta at each step. This allows for
+% staying on a given hysteresis branch.
+% NumberOfPoints: Number of points, like 3
+% DataDirectory: Directory to store the results. Leave this field out or '.' will put the data
+% in the present directory.
+% QuadraticFit: 0 = linear fit, else quadratic fit (used by quadplot)
+% OutlierFactor: if abs(data - fit) > OutlierFactor, then remove that BPM from the center calculation [mm] (used by quadplot)
+% ExtraDelay: Extra delay added before reading the BPMs [seconds] {optional}
+%
+% OUTPUTS
+% The QMSstructure input structure will get the following output fields appended to it.
+% This structure will be output as well as saved to a file which is named based on the
+% sector, quadrupole family name, and device number. A log file will also be updated.
+% QMSstructure =
+% OldCenter: Old quadrupole center (from getoffsetorbit)
+% x1: horizonal data at quadrupole value #1
+% x2: horizonal data at quadrupole value #2
+% y1: vertical data at quadrupole value #1
+% y2: vertical data at quadrupole value #2
+% Xerr: Horizonal BPM starting error
+% Yerr: Vertical BPM starting error
+% TimeStamp: Time stamp as output by clock (6 element vector)
+% CreatedBy: 'quadcenter'
+% QMS.BPMStatus: Status of the BPMs
+% QMS.BPMSTD: Standard deviation of the BPMs (from getsigma)
+% Center: Mean of the BPM center calculations
+% CenterSTD: Standard deviation of the BPM center calculations
+% For two planes, QMS1 is the horizontal and QMS2 is the vertical. When only finding
+% one plane, only the first output is used. For multiple magnets, the output is a column
+% vector containing the quadrupole center.
+%
+% NOTE
+% 1. It is a good idea to have the global orbit reasonable well corrected at the start
+% 2. If the quadrupole modulation system is not a simple device with one family name then
+% edit the setquad function (machine specific).
+% 3. For the new BPM offsets to take effect, they must be loaded into the main AO data structure.
+% 4. This program changes the MML warning level to -2 -> Dialog Box
+% That way the measurement can be salvaged if something goes wrong
+%
+% Machine specific setup:
+% 1. setquad and getquad must exist for setting and getting the quadrupole current.
+% These function are often machine dependent.
+%
+% Written by Greg Portmann
+% 30/03/2007 modified Eugene to add BPMDev
+
+
+
+% Extra delay can be written over by the QMS.ExtraDelay field. If this
+% does not exist, then the value below is used.
+ExtraDelay = 0;
+
+
+% Set the waitflag on power supply setpoints to wait for fresh data from the BPMs
+WaitFlag = -2;
+
+
+% Record the tune at each point.
+% In simulate mode the tunes are always saved unless the TUNE family does not exist.
+GetTuneFlag = 0;
+
+
+% Inputs
+QMS1 = [];
+QMS2 = [];
+if nargin < 1
+ FamilyList = getfamilylist;
+ [tmp,i] = ismemberof(FamilyList,'QUAD');
+ if ~isempty(i)
+ FamilyList = FamilyList(i,:);
+ end
+ if size(FamilyList,1) == 1
+ QuadFamily = deblank(FamilyList);
+ else
+ [i,ok] = listdlg('PromptString', 'Select a quadrupole family:', ...
+ 'SelectionMode', 'single', ...
+ 'ListString', FamilyList);
+ if ok == 0
+ return
+ else
+ QuadFamily = deblank(FamilyList(i,:));
+ end
+ end
+end
+
+if isstruct(QuadFamily)
+ QMS = QuadFamily;
+ XYPlane = QMS.QuadPlane;
+ if QMS.QuadPlane == 1
+ QMS_Horizontal = QMS;
+ QMS_Vertical = quadcenterinit(QMS.QuadFamily, QMS.QuadDev, 2, QMS.BPMDev);
+ QMS_Vertical.CorrectOrbit = QMS.CorrectOrbit;
+ elseif QMS.QuadPlane == 2
+ QMS_Horizontal = quadcenterinit(QMS.QuadFamily, QMS.QuadDev, 1, QMS.BPMDev);
+ QMS_Horizontal.CorrectOrbit = QMS.CorrectOrbit;
+ QMS_Vertical = QMS;
+ else
+ error('QMS.QuadPlane must be 1 or 2 when using a QMS structure input');
+ end
+ if nargin >= 2
+ FigureHandle = QuadDev;
+ else
+ FigureHandle = [];
+ end
+ QuadFamily = QMS.QuadFamily;
+ QuadDev = QMS.QuadDev;
+else
+ if ~isfamily(QuadFamily)
+ error(sprintf('Quadrupole family %s does not exist. Make sure the middle layer had been initialized properly.',QuadFamily));
+ end
+ if nargin < 2
+ QuadDev = editlist(getlist(QuadFamily),QuadFamily,zeros(length(getlist(QuadFamily)),1));
+ end
+ if nargin < 3
+ ButtonNumber = menu('Which Plane?', 'Both','Horizontal Only','Vertical Only','Cancel');
+ drawnow;
+ switch ButtonNumber
+ case 1
+ XYPlane = 0;
+ case 2
+ XYPlane = 1;
+ case 3
+ XYPlane = 2;
+ otherwise
+ fprintf(' quadcenter cancelled\n');
+ return
+ end
+ end
+ if nargin < 5
+ FigureHandle = [];
+ end
+
+ % If QuadDev is a vector
+% if size(QuadDev,1) > 1
+% for i = 1:size(QuadDev,1)
+% if XYPlane == 0
+% [Q1, Q2] = quadcenter(QuadFamily, QuadDev(i,:), XYPlane, BPMDev(i,:), FigureHandle);
+% QMS1(i,1) = Q1.Center;
+% QMS2(i,1) = Q2.Center;
+% else
+% [Q1] = quadcenter(QuadFamily, QuadDev(i,:), XYPlane, BPMDev(i,:), FigureHandle);
+% QMS1(i,1) = Q1.Center;
+% end
+% end
+% return
+% end
+
+
+ % Get QMS structure
+ QMS_Horizontal = quadcenterinit(QuadFamily, QuadDev, 1, BPMDev);
+ QMS_Vertical = quadcenterinit(QuadFamily, QuadDev, 2, BPMDev);
+end
+
+
+% Change the MML warning level to -2 -> Dialog Box
+% That way the measurement can be salvaged if something goes wrong
+ErrorWarningLevel = getfamilydata('ErrorWarningLevel');
+setfamilydata(-2, 'ErrorWarningLevel');
+
+
+% Initialize variables
+HCMFamily = QMS_Horizontal.CorrFamily;
+HCMDev = QMS_Horizontal.CorrDevList;
+DelHCM = QMS_Horizontal.CorrDelta;
+BPMxFamily = QMS_Horizontal.BPMFamily;
+BPMxDev = QMS_Horizontal.BPMDev;
+BPMxDevList= QMS_Horizontal.BPMDevList;
+
+VCMFamily = QMS_Vertical.CorrFamily;
+VCMDev = QMS_Vertical.CorrDevList;
+DelVCM = QMS_Vertical.CorrDelta;
+BPMyFamily = QMS_Vertical.BPMFamily;
+BPMyDev = QMS_Vertical.BPMDev;
+BPMyDevList= QMS_Vertical.BPMDevList;
+
+Xcenter = NaN;
+Ycenter = NaN;
+
+
+% Check status for BPMs next to the quadrupole and correctors used in orbit correction
+HCMStatus = family2status(HCMFamily, HCMDev);
+
+if ~any(isnan(HCMStatus)) && any(HCMStatus==0)
+ error(sprintf('A %s corrector used in finding the center has a bad status', HCMFamily));
+end
+VCMStatus = family2status(VCMFamily, VCMDev);
+if ~any(isnan(VCMStatus)) && any(VCMStatus==0)
+ error(sprintf('A %s corrector used in finding the center has a bad status', VCMFamily));
+end
+BPMxStatus = family2status(BPMxFamily, BPMxDev);
+if ~any(isnan(BPMxStatus)) && any(BPMxStatus==0)
+ error(sprintf('The %s monitor next to the quadrupole has bad status', BPMxFamily));
+end
+BPMyStatus = family2status(BPMxFamily, BPMxDev);
+if ~any(isnan(BPMyStatus)) && any(BPMyStatus==0)
+ error(sprintf('The %s monitor next to the quadrupole has bad status', BPMxFamily));
+end
+
+
+% Record start directory
+DirStart = pwd;
+
+
+% Get the current offset orbit
+Xoffset = getoffset(BPMxFamily, BPMxDev);
+Yoffset = getoffset(BPMyFamily, BPMyDev);
+XoffsetOld = Xoffset;
+YoffsetOld = Yoffset;
+
+% Starting correctors
+HCM00 = getsp(HCMFamily, HCMDev);
+VCM00 = getsp(VCMFamily, VCMDev);
+
+
+% % Global orbit correction
+% CM = getsp('HCM','struct');
+% BPM = getx('struct');
+% BPMWeight = ones(size(BPM.DeviceList,1),1);
+% i = findrowindex(BPMxDev, BPM.DeviceList);
+%
+% x = getoffset('BPMx');
+% x = .1 * BPMWeight;
+% %x(i) = -.2;
+% BPMWeight(i) = 100;
+%
+% setorbit(x, BPM, CM, 3, 20, BPMWeight, 'Display');
+
+
+% Correct orbit to the old offsets first
+if strcmpi(QMS_Horizontal.CorrectOrbit, 'yes')
+ fprintf(' Correcting the orbit to the old horizontal center of %s(%d,%d)\n', QuadFamily, QuadDev); pause(0);
+ if ~isnan(Xoffset)
+ OrbitCorrection(Xoffset, BPMxFamily, BPMxDev, HCMFamily, HCMDev, 4);
+ end
+end
+if strcmpi(QMS_Vertical.CorrectOrbit, 'yes')
+ fprintf(' Correcting the orbit to the old vertical center of %s(%d,%d)\n', QuadFamily, QuadDev); pause(0);
+ if ~isnan(Yoffset)
+ OrbitCorrection(Yoffset, BPMyFamily, BPMyDev, VCMFamily, VCMDev, 4);
+ end
+end
+
+%OrbitCorrection(Xoffset, BPMxFamily, BPMxDev, HCMFamily, HCMDev);
+%OrbitCorrection(Yoffset, BPMyFamily, BPMyDev, VCMFamily, VCMDev);
+
+
+
+% Algorithm
+% 1. Change the horzontal orbit in the quad
+% 2. Correct the vertical orbit
+% 3. Record the orbit
+% 4. Step the quad
+% 5. Record the orbit
+
+
+% FIND HORIZONTAL OFFSET
+if XYPlane==0 || XYPlane==1
+ FigureHandle = 1;
+
+ % BPM processor delay
+ if isfield(QMS_Horizontal, 'ExtraDelay')
+ ExtraDelay = QMS_Horizontal.ExtraDelay;
+ end
+
+ % Get mode
+ Mode = getmode(QMS_Horizontal.QuadFamily);
+
+ % Record starting point
+ QUAD0 = getquad(QMS_Horizontal);
+ HCM0 = getsp(HCMFamily, HCMDev);
+ VCM0 = getsp(VCMFamily, VCMDev);
+ Xerr = getam(BPMxFamily, BPMxDev) - Xoffset;
+ Yerr = getam(BPMyFamily, BPMyDev) - Yoffset;
+ xstart = getam(BPMxFamily, BPMxDevList);
+ ystart = getam(BPMyFamily, BPMyDevList);
+
+ QMS_Horizontal.Orbit0 = getam(BPMxFamily, BPMxDevList, 'Struct');
+
+ [tmp, iNotFound] = findrowindex(BPMxDev, BPMxDevList);
+ if ~isempty(iNotFound)
+ setsp(HCMFamily, HCM00, HCMDev, 0);
+ setsp(VCMFamily, VCM00, VCMDev, 0);
+ error('BPM at the quadrupole not found in the BPM device list');
+ end
+
+ DelQuad = QMS_Horizontal.QuadDelta;
+ N = abs(round(QMS_Horizontal.NumberOfPoints));
+ if N < 1
+ error('The number of points must be 2 or more.');
+ end
+
+
+ fprintf(' Finding horizontal center of %s(%d,%d)\n', QuadFamily, QuadDev);
+ fprintf(' Starting orbit error: %s(%d,%d)=%f , %s(%d,%d)=%f %s\n', BPMxFamily, BPMxDev, Xerr, BPMyFamily, BPMyDev, Yerr, QMS_Horizontal.Orbit0.UnitsString);
+ if strcmpi(QMS_Horizontal.ModulationMethod, 'bipolar')
+ fprintf(' Quadrupole starting current = %.3f, modulate by +/- %.3f\n', getquad(QMS_Horizontal), DelQuad);
+ elseif strcmpi(QMS_Horizontal.ModulationMethod, 'unipolar')
+ fprintf(' Quadrupole starting current = %.3f, modulate by 0 to %.3f\n', getquad(QMS_Horizontal), DelQuad);
+ elseif strcmpi(QMS_Horizontal.ModulationMethod, 'sweep')
+ fprintf(' Quadrupole starting current = %.3f, sweep by %.3f on each step\n', getquad(QMS_Horizontal), DelQuad);
+ else
+ % Reset or error
+ setsp(HCMFamily, HCM00, HCMDev, 0);
+ setsp(VCMFamily, VCM00, VCMDev, 0);
+ setquad(QMS_Horizontal, QUAD0, 0);
+ cd(DirStart);
+ error('Unknown ModulationMethod in the QMS input structure (likely a problem with quadcenterinit)');
+ end
+ pause(0);
+
+ % Establish a hysteresis loop
+ if strcmpi(QMS_Horizontal.ModulationMethod, 'bipolar')
+ fprintf(' Establishing a hysteresis loop on the quadrupole (bi-polar case)\n'); pause(0);
+ setquad(QMS_Horizontal, DelQuad+QUAD0, -1);
+ setquad(QMS_Horizontal,-DelQuad+QUAD0, -1);
+ setquad(QMS_Horizontal, DelQuad+QUAD0, -1);
+ setquad(QMS_Horizontal,-DelQuad+QUAD0, -1);
+ setquad(QMS_Horizontal, QUAD0, -1);
+ elseif strcmpi(QMS_Horizontal.ModulationMethod, 'unipolar')
+ fprintf(' Establishing a hysteresis loop on the quadrupole (uni-polar case)\n'); pause(0);
+ setquad(QMS_Horizontal, DelQuad+QUAD0, -1);
+ setquad(QMS_Horizontal, QUAD0, -1);
+ setquad(QMS_Horizontal, DelQuad+QUAD0, -1);
+ setquad(QMS_Horizontal, QUAD0, -1);
+ end
+
+
+ % Corrector step size
+ CorrStep = 2 * DelHCM / (N-1);
+
+
+ % Start the corrector a little lower first for hysteresis reasons
+ %stepsp(HCMFamily, -1.0*DelHCM, HCMDev, -1);
+ stepsp(HCMFamily, -1.2*DelHCM, HCMDev, -1);
+ stepsp(HCMFamily, .2*DelHCM, HCMDev, WaitFlag);
+
+
+ % Main horizontal data loop
+ clear DCCT
+ for i = 1:N
+ % Step the horizontal orbit
+ if i ~= 1
+ stepsp(HCMFamily, CorrStep, HCMDev, WaitFlag);
+ end
+
+ fprintf(' %d. %s(%d,%d) sp/am = %+.4f/%+.4f, %s(%d,%d) = %+.5f %s\n', i, HCMFamily, HCMDev(1,:), getsp(HCMFamily, HCMDev(1,:)), getam(HCMFamily, HCMDev(1,:)), BPMxFamily, BPMxDev, getam(BPMxFamily, BPMxDev), QMS_Horizontal.Orbit0.UnitsString); pause(0);
+
+ % If correcting the orbit, then recorrect the vertical center now
+ if strcmpi(QMS_Horizontal.CorrectOrbit, 'yes')
+ % Correct the vertical orbit
+ OrbitCorrection(Yoffset, BPMyFamily, BPMyDev, VCMFamily, VCMDev, 4);
+ end
+
+ if strcmpi(QMS_Horizontal.ModulationMethod, 'sweep')
+ % One directional sweep of the quadrupole
+ sleep(ExtraDelay);
+ x1(:,i) = getam(BPMxFamily, BPMxDevList);
+ y1(:,i) = getam(BPMyFamily, BPMyDevList);
+ x0(:,i) = x1(:,i);
+ y0(:,i) = y1(:,i);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Horizontal.Tune1(:,i) = gettune;
+ end
+
+ setquad(QMS_Horizontal, i*DelQuad+QUAD0, WaitFlag);
+ sleep(ExtraDelay);
+
+ % If correcting the orbit, then recorrect the horizontal center now
+ if strcmpi(QMS_Horizontal.CorrectOrbit, 'yes')
+ % Correct the vertical orbit
+ OrbitCorrection(Yoffset, BPMyFamily, BPMyDev, VCMFamily, VCMDev, 4);
+ sleep(ExtraDelay);
+ end
+
+ x2(:,i) = getam(BPMxFamily, BPMxDevList);
+ y2(:,i) = getam(BPMyFamily, BPMyDevList);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Horizontal.Tune2(:,i) = gettune;
+ end
+
+ elseif strcmpi(QMS_Horizontal.ModulationMethod, 'bipolar')
+ % Modulate the quadrupole
+ sleep(ExtraDelay);
+ x0(:,i) = getam(BPMxFamily, BPMxDevList);
+ y0(:,i) = getam(BPMyFamily, BPMyDevList);
+ setquad(QMS_Horizontal, DelQuad+QUAD0, WaitFlag);
+ sleep(ExtraDelay);
+
+ % If correcting the orbit, then recorrect the horizontal center now
+ if strcmpi(QMS_Horizontal.CorrectOrbit, 'yes')
+ % Correct the vertical orbit
+ OrbitCorrection(Yoffset, BPMyFamily, BPMyDev, VCMFamily, VCMDev, 4);
+ sleep(ExtraDelay);
+ end
+
+ x1(:,i) = getam(BPMxFamily, BPMxDevList);
+ y1(:,i) = getam(BPMyFamily, BPMyDevList);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Horizontal.Tune1(:,i) = gettune;
+ end
+
+ setquad(QMS_Horizontal,-DelQuad+QUAD0, WaitFlag);
+ sleep(ExtraDelay);
+
+ % If correcting the orbit, then recorrect the horizontal center now
+ if strcmpi(QMS_Horizontal.CorrectOrbit, 'yes')
+ % Correct the vertical orbit
+ OrbitCorrection(Yoffset, BPMyFamily, BPMyDev, VCMFamily, VCMDev, 4);
+ sleep(ExtraDelay);
+ end
+
+ x2(:,i) = getam(BPMxFamily, BPMxDevList);
+ y2(:,i) = getam(BPMyFamily, BPMyDevList);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Horizontal.Tune2(:,i) = gettune;
+ end
+
+ setquad(QMS_Horizontal, QUAD0, WaitFlag);
+
+ elseif strcmpi(QMS_Horizontal.ModulationMethod, 'unipolar')
+ % Modulate the quadrupole
+ sleep(ExtraDelay);
+ x1(:,i) = getam(BPMxFamily, BPMxDevList);
+ y1(:,i) = getam(BPMyFamily, BPMyDevList);
+ x0(:,i) = x1(:,i);
+ y0(:,i) = y1(:,i);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Horizontal.Tune1(:,i) = gettune;
+ end
+
+ setquad(QMS_Horizontal, DelQuad+QUAD0, WaitFlag);
+ sleep(ExtraDelay);
+
+ % If correcting the orbit, then recorrect the horizontal center now
+ if strcmpi(QMS_Horizontal.CorrectOrbit, 'yes')
+ % Correct the vertical orbit
+ OrbitCorrection(Yoffset, BPMyFamily, BPMyDev, VCMFamily, VCMDev, 4);
+ sleep(ExtraDelay);
+ end
+
+ x2(:,i) = getam(BPMxFamily, BPMxDevList);
+ y2(:,i) = getam(BPMyFamily, BPMyDevList);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Horizontal.Tune2(:,i) = gettune;
+ end
+
+ setquad(QMS_Horizontal, QUAD0, WaitFlag);
+ end
+
+ DCCT(i) = getdcct;
+ end
+
+ % Get the horizontal data filename and save the data
+ % Append data and time
+ FileName = ['s', num2str(QuadDev(1,1)), QuadFamily, num2str(QuadDev(1,2)), 'h1'];
+ FileName = appendtimestamp(FileName, clock);
+
+ % Use a version number
+ %i=1;
+ %FileName = ['s', num2str(QuadDev(1,1)), QuadFamily, num2str(QuadDev(1,2)), 'h', num2str(i)];
+ %while exist([FileName,'.mat'], 'file')
+ % i = i + 1;
+ % FileName = ['s', num2str(QuadDev(1,1)), QuadFamily, num2str(QuadDev(1,2)), 'h', num2str(i)];
+ %end
+
+ QMS = QMS_Horizontal;
+ QMS.QuadPlane = 1;
+
+ QMS.OldCenter = Xoffset;
+ QMS.XOffsetOld = XoffsetOld;
+ QMS.YOffsetOld = YoffsetOld;
+
+ QMS.xstart = xstart;
+ QMS.ystart = ystart;
+
+ QMS.x0 = x0;
+ QMS.x1 = x1;
+ QMS.x2 = x2;
+ QMS.y0 = y0;
+ QMS.y1 = y1;
+ QMS.y2 = y2;
+ QMS.Xerr = Xerr;
+ QMS.Yerr = Yerr;
+ QMS.TimeStamp = clock;
+ QMS.DCCT = DCCT;
+ QMS.DataDescriptor = 'Quadrupole Center';
+ QMS.CreatedBy = 'quadcenter';
+
+ % Get and store the BPM status and standard deviation (to be used by the center calculation routine)
+ QMS.BPMStatus = family2status(BPMxFamily, BPMxDevList);
+ N = getbpmaverages(BPMxDevList);
+ QMS.BPMSTD = getsigma(BPMxFamily, BPMxDevList, N);
+
+ % Set up figures, plot and find horizontal center
+ try
+ if isempty(FigureHandle)
+ QMS = quadplot(QMS);
+ else
+ QMS = quadplot(QMS, FigureHandle);
+ end
+ drawnow;
+ catch
+ fprintf('\n%s\n', lasterr);
+ end
+ QMS1 = QMS;
+
+ % Save the horizontal data
+ if isfield(QMS_Horizontal, 'DataDirectory')
+ [FinalDir, ErrorFlag] = gotodirectory(QMS_Horizontal.DataDirectory);
+ end
+ QMS.DataDirectory = pwd;
+ save(FileName, 'QMS');
+ fprintf(' Data saved to file %s in directory %s\n\n', FileName, QMS.DataDirectory);
+
+ % Output data to file
+ fid1 = fopen('quadcenter.log','at');
+ time=clock;
+ fprintf(fid1, '%s %d:%d:%2.0f \n', date, time(4),time(5),time(6));
+ fprintf(fid1, 'Data saved to file %s (%s)\n', FileName, QMS.DataDirectory);
+ fprintf(fid1, '%s(%d,%d) %s(%d,%d) = %f (+/- %f) [%s]\n\n', QuadFamily, QuadDev, BPMxFamily, BPMxDev, QMS.Center, QMS.CenterSTD, QMS_Horizontal.Orbit0.UnitsString);
+ fclose(fid1);
+ cd(DirStart);
+
+ % Change the offset orbit to the new center so that the vertical plane uses it
+ Xoffset = QMS.Center;
+
+ % Restore magnets their starting points (correctors to values after orbit correction)
+ setsp(HCMFamily, HCM0, HCMDev, WaitFlag);
+ setsp(VCMFamily, VCM0, VCMDev, WaitFlag);
+ setquad(QMS_Horizontal, QUAD0, WaitFlag);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ % Print the tune information
+ fprintf(' Tune and tune difference for the 1st points in the merit function (QMS.Tune1): \n');
+ fprintf(' %8.5f', QMS.Tune1(1,:));
+ fprintf(' Horizontal\n');
+ fprintf(' %8.5f', QMS.Tune1(2,:));
+ fprintf(' Vertical\n');
+ fprintf(' ===================================================\n');
+ fprintf(' %8.5f', diff(QMS.Tune1));
+ fprintf(' Difference \n\n');
+
+ fprintf(' Tune and tune difference for the 2nd points in the merit function (QMS.Tune2): \n');
+ fprintf(' %8.5f', QMS.Tune2(1,:));
+ fprintf(' Horizontal\n');
+ fprintf(' %8.5f', QMS.Tune2(2,:));
+ fprintf(' Vertical\n');
+ fprintf(' ===================================================\n');
+ fprintf(' %8.5f', diff(QMS.Tune2));
+ fprintf(' Difference\n\n');
+
+ dTune1 = diff(QMS.Tune1);
+ dTune2 = diff(QMS.Tune2);
+
+ if any(sign(dTune1/dTune1(1))==-1)
+ fprintf(' Tune change sign!!!\n');
+ end
+
+ if any(abs(dTune1) < .025) || any(abs(dTune2) < .025)
+ fprintf(' Horizontal and vertical tunes seem too close.\n');
+ end
+ end
+end
+
+
+
+% FIND VERTICAL OFFSET
+if XYPlane==0 || XYPlane==2
+ FigureHandle = 1;
+
+ % BPM processor delay
+ if isfield(QMS_Vertical, 'ExtraDelay')
+ ExtraDelay = QMS_Vertical.ExtraDelay;
+ end
+
+ % Get mode
+ Mode = getmode(QMS_Horizontal.QuadFamily);
+
+ % Record starting point
+ QUAD0 = getquad(QMS_Vertical);
+ HCM0 = getsp(HCMFamily, HCMDev);
+ VCM0 = getsp(VCMFamily, VCMDev);
+ Xerr = getam(BPMxFamily, BPMxDev) - Xoffset;
+ Yerr = getam(BPMyFamily, BPMyDev) - Yoffset;
+ xstart = getam(BPMxFamily, BPMxDevList);
+ ystart = getam(BPMyFamily, BPMyDevList);
+
+ QMS_Vertical.Orbit0 = getam(BPMxFamily, BPMxDevList, 'Struct');
+
+ [tmp, iNotFound] = findrowindex(BPMyDev, BPMyDevList);
+ if ~isempty(iNotFound)
+ setsp(HCMFamily, HCM00, HCMDev, 0);
+ setsp(VCMFamily, VCM00, VCMDev, 0);
+ error('BPM at the quadrupole not found in the BPM device list');
+ end
+
+ DelQuad = QMS_Vertical.QuadDelta;
+ N = abs(round(QMS_Vertical.NumberOfPoints));
+ if N < 1
+ error('The number of points must be 2 or more.');
+ end
+
+ fprintf(' Finding vertical center of %s(%d,%d)\n', QuadFamily, QuadDev);
+ fprintf(' Starting orbit error: %s(%d,%d)=%f , %s(%d,%d)=%f %s\n', BPMxFamily, BPMxDev, Xerr, BPMyFamily, BPMyDev, Yerr, QMS_Vertical.Orbit0.UnitsString);
+ if strcmpi(QMS_Vertical.ModulationMethod, 'bipolar')
+ fprintf(' Quadrupole starting current = %.3f, modulate by +/- %.3f\n', getquad(QMS_Vertical), DelQuad);
+ elseif strcmpi(QMS_Vertical.ModulationMethod, 'unipolar')
+ fprintf(' Quadrupole starting current = %.3f, modulate by 0 to %.3f\n', getquad(QMS_Vertical), DelQuad);
+ elseif strcmpi(QMS_Vertical.ModulationMethod, 'sweep')
+ fprintf(' Quadrupole starting current = %.3f, sweep by %.3f on each step\n', getquad(QMS_Vertical), DelQuad);
+ else
+ setsp(HCMFamily, HCM00, HCMDev, 0);
+ setsp(VCMFamily, VCM00, VCMDev, 0);
+ setquad(QMS_Vertical, QUAD0, 0);
+ cd(DirStart);
+ error('Unknown ModulationMethod in the QMS input structure (likely a problem with quadcenterinit)');
+ end
+ pause(0);
+
+
+ % Establish a hysteresis loop (if not already done, or if the horizontal plane was sweep)
+ if XYPlane == 2 || strcmpi(QMS_Horizontal.ModulationMethod, 'sweep')
+ if strcmpi(QMS_Vertical.ModulationMethod, 'bipolar')
+ fprintf(' Establishing a hysteresis loop on the quadrupole (bi-polar case)\n'); pause(0);
+ setquad(QMS_Vertical, DelQuad+QUAD0, -1);
+ setquad(QMS_Vertical,-DelQuad+QUAD0, -1);
+ setquad(QMS_Vertical, DelQuad+QUAD0, -1);
+ setquad(QMS_Vertical,-DelQuad+QUAD0, -1);
+ setquad(QMS_Vertical, QUAD0, -1);
+ elseif strcmpi(QMS_Vertical.ModulationMethod, 'unipolar')
+ fprintf(' Establishing a hysteresis loop on the quadrupole (uni-polar case)\n'); pause(0);
+ setquad(QMS_Vertical, DelQuad+QUAD0, -1);
+ setquad(QMS_Vertical, QUAD0, -1);
+ setquad(QMS_Vertical, DelQuad+QUAD0, -1);
+ setquad(QMS_Vertical, QUAD0, -1);
+ end
+ end
+
+
+ % Corrector step size
+ CorrStep = 2 * DelVCM / (N-1);
+
+
+ % Start the corrector a little lower first for hysteresis reasons
+ stepsp(VCMFamily, -1.2*DelVCM, VCMDev, -1);
+ stepsp(VCMFamily, .2*DelVCM, VCMDev, WaitFlag);
+
+
+% Debug
+% setquad(QMS_Vertical, DelQuad+QUAD0, WaitFlag);
+% QUAD0 = getquad(QMS_Vertical);
+% Xstart = getam(BPMxFamily, BPMxDev)
+
+
+ clear DCCT
+ for i = 1:N
+
+ % Step the vertical orbit
+ if i ~= 1
+ stepsp(VCMFamily, CorrStep, VCMDev, WaitFlag);
+ end
+
+ fprintf(' %d. %s(%d,%d) sp/am = %+.4f/%+.4f, %s(%d,%d) = %+.5f %s\n', i, VCMFamily, VCMDev(1,:), getsp(VCMFamily, VCMDev(1,:)), getam(VCMFamily, VCMDev(1,:)), BPMyFamily, BPMyDev, getam(BPMyFamily, BPMyDev), QMS_Vertical.Orbit0.UnitsString); pause(0);
+
+
+ % If correcting the orbit, then recorrect the horizontal center now
+ if strcmpi(QMS_Vertical.CorrectOrbit, 'yes')
+ % Correct the horizontal orbit
+ OrbitCorrection(Xoffset, BPMxFamily, BPMxDev, HCMFamily, HCMDev, 4);
+ end
+
+
+ if strcmpi(QMS_Vertical.ModulationMethod, 'sweep')
+ % One dimensional sweep of the quadrupole
+ sleep(ExtraDelay);
+ x1(:,i) = getam(BPMxFamily, BPMxDevList);
+ y1(:,i) = getam(BPMyFamily, BPMyDevList);
+ x0(:,i) = x1(:,i);
+ y0(:,i) = y1(:,i);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Vertical.Tune1(:,i) = gettune;
+ end
+
+ setquad(QMS_Vertical, i*DelQuad+QUAD0, WaitFlag);
+ sleep(ExtraDelay);
+
+ % If correcting the orbit, then recorrect the horizontal center now
+ if strcmpi(QMS_Vertical.CorrectOrbit, 'yes')
+ % Correct the horizontal orbit
+ OrbitCorrection(Xoffset, BPMxFamily, BPMxDev, HCMFamily, HCMDev, 4);
+ sleep(ExtraDelay);
+ end
+
+ x2(:,i) = getam(BPMxFamily, BPMxDevList);
+ y2(:,i) = getam(BPMyFamily, BPMyDevList);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Vertical.Tune2(:,i) = gettune;
+ end
+
+ elseif strcmpi(QMS_Vertical.ModulationMethod, 'bipolar')
+ % Modulate the quadrupole
+ sleep(ExtraDelay);
+ x0(:,i) = getam(BPMxFamily, BPMxDevList);
+ y0(:,i) = getam(BPMyFamily, BPMyDevList);
+ setquad(QMS_Vertical, DelQuad+QUAD0, WaitFlag);
+ sleep(ExtraDelay);
+
+ % If correcting the orbit, then recorrect the horizontal center now
+ if strcmpi(QMS_Vertical.CorrectOrbit, 'yes')
+ % Correct the horizontal orbit
+ OrbitCorrection(Xoffset, BPMxFamily, BPMxDev, HCMFamily, HCMDev, 4);
+ sleep(ExtraDelay);
+ end
+
+ x1(:,i) = getam(BPMxFamily, BPMxDevList);
+ y1(:,i) = getam(BPMyFamily, BPMyDevList);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Vertical.Tune1(:,i) = gettune;
+ end
+
+ setquad(QMS_Vertical,-DelQuad+QUAD0, WaitFlag);
+ sleep(ExtraDelay);
+
+ % If correcting the orbit, then recorrect the horizontal center now
+ if strcmpi(QMS_Vertical.CorrectOrbit, 'yes')
+ % Correct the horizontal orbit
+ OrbitCorrection(Xoffset, BPMxFamily, BPMxDev, HCMFamily, HCMDev, 4);
+ sleep(ExtraDelay);
+ end
+
+ x2(:,i) = getam(BPMxFamily, BPMxDevList);
+ y2(:,i) = getam(BPMyFamily, BPMyDevList);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Vertical.Tune2(:,i) = gettune;
+ end
+
+ setquad(QMS_Vertical, QUAD0, WaitFlag);
+
+ elseif strcmpi(QMS_Vertical.ModulationMethod, 'unipolar')
+ % Modulate the quadrupole
+ sleep(ExtraDelay);
+ x1(:,i) = getam(BPMxFamily, BPMxDevList);
+ y1(:,i) = getam(BPMyFamily, BPMyDevList);
+ x0(:,i) = x1(:,i);
+ y0(:,i) = y1(:,i);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Vertical.Tune1(:,i) = gettune;
+ end
+
+ setquad(QMS_Vertical, DelQuad+QUAD0, WaitFlag);
+ sleep(ExtraDelay);
+
+ % If correcting the orbit, then recorrect the horizontal center now
+ if strcmpi(QMS_Vertical.CorrectOrbit, 'yes')
+ % Correct the horizontal orbit
+ OrbitCorrection(Xoffset, BPMxFamily, BPMxDev, HCMFamily, HCMDev, 4);
+ sleep(ExtraDelay);
+ end
+
+ x2(:,i) = getam(BPMxFamily, BPMxDevList);
+ y2(:,i) = getam(BPMyFamily, BPMyDevList);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ QMS_Vertical.Tune2(:,i) = gettune;
+ end
+
+ setquad(QMS_Vertical, QUAD0, WaitFlag);
+ end
+
+ DCCT(i) = getdcct;
+ end
+
+ setsp(VCMFamily, VCM0, VCMDev, -1);
+
+
+ % Get the vertical data filename and save the data
+ % Append data and time
+ FileName = ['s', num2str(QuadDev(1,1)), QuadFamily, num2str(QuadDev(1,2)), 'v1'];
+ FileName = appendtimestamp(FileName, clock);
+
+ %% Append version number
+ %i=1;
+ %FileName = ['s', num2str(QuadDev(1,1)), QuadFamily, num2str(QuadDev(1,2)), 'v', num2str(i)];
+ %while exist([FileName,'.mat'], 'file')
+ % i = i + 1;
+ % FileName = ['s', num2str(QuadDev(1,1)), QuadFamily, num2str(QuadDev(1,2)), 'v', num2str(i)];
+ %end
+
+ QMS = QMS_Vertical;
+ QMS.QuadPlane = 2;
+
+ QMS.OldCenter = Yoffset;
+ QMS.XOffsetOld = XoffsetOld;
+ QMS.YOffsetOld = YoffsetOld;
+
+ QMS.xstart = xstart;
+ QMS.ystart = ystart;
+ QMS.x0 = x0;
+ QMS.x1 = x1;
+ QMS.x2 = x2;
+ QMS.y0 = y0;
+ QMS.y1 = y1;
+ QMS.y2 = y2;
+ QMS.Xerr = Xerr;
+ QMS.Yerr = Yerr;
+ QMS.TimeStamp = clock;
+ QMS.DCCT = DCCT;
+ QMS.DataDescriptor = 'Quadrupole Center';
+ QMS.CreatedBy = 'quadcenter';
+
+ % Get and store the BPM status and standard deviation (to be used by the center calculation routine)
+ QMS.BPMStatus = family2status(BPMyFamily, BPMyDevList);
+ N = getbpmaverages(BPMyDevList);
+ QMS.BPMSTD = getsigma(BPMyFamily, BPMyDevList, N);
+
+
+ % Set up figures, plot and find vertical center
+ if isempty(FigureHandle)
+ QMS = quadplot(QMS);
+ else
+ QMS = quadplot(QMS, FigureHandle);
+ end
+ drawnow;
+
+ if XYPlane==0
+ QMS2 = QMS;
+ else
+ QMS1 = QMS;
+ end
+
+
+ % Save the vertical data
+ if isfield(QMS_Vertical,'DataDirectory')
+ [FinalDir, ErrorFlag] = gotodirectory(QMS_Vertical.DataDirectory);
+ end
+ QMS.DataDirectory = pwd;
+ save(FileName, 'QMS');
+ fprintf(' Data saved to file %s in directory %s\n\n', FileName, QMS.DataDirectory);
+
+ % Output data to log file
+ fid1 = fopen('quadcenter.log','at');
+ time=clock;
+ fprintf(fid1, '%s %d:%d:%2.0f \n', date, time(4),time(5),time(6));
+ fprintf(fid1, 'Data saved to file %s (%s)\n', FileName, QMS.DataDirectory);
+ fprintf(fid1, '%s(%d,%d) %s(%d,%d) = %f (+/- %f) [%s]\n\n', QuadFamily, QuadDev, BPMyFamily, BPMyDev, QMS.Center, QMS.CenterSTD);
+ fclose(fid1);
+ cd(DirStart);
+
+ if (GetTuneFlag || strcmpi(Mode, 'Simulator')) && isfamily('TUNE')
+ % Print the tune information
+ fprintf(' Tune and tune difference for the 1st points in the merit function (QMS.Tune1): \n');
+ fprintf(' %8.5f', QMS.Tune1(1,:));
+ fprintf(' Horizontal\n');
+ fprintf(' %8.5f', QMS.Tune1(2,:));
+ fprintf(' Vertical\n');
+ fprintf(' ===================================================\n');
+ fprintf(' %8.5f', diff(QMS.Tune1));
+ fprintf(' Difference \n\n');
+
+ fprintf(' Tune and tune difference for the 2nd points in the merit function (QMS.Tune2): \n');
+ fprintf(' %8.5f', QMS.Tune2(1,:));
+ fprintf(' Horizontal\n');
+ fprintf(' %8.5f', QMS.Tune2(2,:));
+ fprintf(' Vertical\n');
+ fprintf(' ===================================================\n');
+ fprintf(' %8.5f', diff(QMS.Tune2));
+ fprintf(' Difference\n\n');
+
+ dTune1 = diff(QMS.Tune1);
+ dTune2 = diff(QMS.Tune2);
+
+ if any(sign(dTune1/dTune1(1))==-1)
+ fprintf(' Tune change sign!!!\n');
+ end
+
+ if any(abs(dTune1) < .025) || any(abs(dTune2) < .025)
+ fprintf(' Horizontal and vertical tunes seem too close.\n');
+ end
+ end
+end
+
+
+% Restore magnets their starting points
+setsp(HCMFamily, HCM00, HCMDev, 0);
+setsp(VCMFamily, VCM00, VCMDev, 0);
+setquad(QMS_Horizontal, QUAD0, 0);
+
+
+% Restore the MML error warning level
+setfamilydata(ErrorWarningLevel, 'ErrorWarningLevel');
+
+
+%%%%%%%%%%%%%%%%%%%%%
+% End Main Function %
+%%%%%%%%%%%%%%%%%%%%%
+
+
+
+%%%%%%%%%%%%%%%%%
+% Sub-Functions %
+%%%%%%%%%%%%%%%%%
+
+function OrbitCorrection(GoalOrbit, BPMFamily, BPMDevList, CMFamily, CMDevList, Iter)
+
+WaitFlag = -2;
+
+if nargin < 6
+ Iter = 3;
+end
+
+if size(CMDevList,1) > 1
+ % Pick the corrector based on the most effective corrector in the response matrix
+ % This routine does not handle local bumps at the moment
+ R = getrespmat(BPMFamily, BPMDevList, CMFamily, [], 'Struct', 'Physics');
+ [i, iNotFound] = findrowindex(BPMDevList, R.Monitor.DeviceList);
+ m = R.Data(i,:);
+ [MaxValue, j] = max(abs(m));
+ CMDevList = R.Actuator.DeviceList(j,:);
+end
+
+s = getrespmat(BPMFamily, BPMDevList, CMFamily, CMDevList);
+if any(any(isnan(s)))
+ error('Response matrix has a NaN');
+end
+
+
+for i = 1:Iter
+ x = getam(BPMFamily, BPMDevList) - GoalOrbit;
+
+ CorrectorSP = -(x./s);
+ CorrectorSP = CorrectorSP(:);
+
+ % Check limits
+ MinSP = minsp(CMFamily, CMDevList);
+ MaxSP = maxsp(CMFamily, CMDevList);
+ if any(getsp(CMFamily,CMDevList)+CorrectorSP > MaxSP-5)
+ fprintf(' Orbit not corrected because a maximum power supply limit would have been exceeded!\n');
+ return;
+ end
+ if any(getsp(CMFamily,CMDevList)+CorrectorSP < MinSP+5)
+ fprintf(' Orbit not corrected because a minimum power supply limit would have been exceeded!\n');
+ return;
+ end
+
+ stepsp(CMFamily, CorrectorSP, CMDevList, WaitFlag);
+
+ %x = getam(BPMFamily, BPMDevList) - GoalOrbit
+end
+
+
+
+
+% function AM = getquad(QMS)
+% % AM = getquad(QMS)
+%
+% QuadFamily = QMS.QuadFamily;
+% QuadDev = QMS.QuadDev;
+%
+% % Check operational mode
+% %mode = getfamilydata(QuadFamily, 'Setpoint', 'Mode', QuadDev);
+%
+% AM = getam(QuadFamily, QuadDev);
+
+
+% function setquad(QMS, QuadSetpoint, WaitFlag)
+% % setquad(QMS, QuadSetpoint, WaitFlag)
+%
+% if nargin < 3
+% WaitFlag = -2;
+% end
+%
+% QuadFamily = QMS.QuadFamily;
+% QuadDev = QMS.QuadDev;
+%
+% setsp(QuadFamily, QuadSetpoint, QuadDev, WaitFlag);
+
+
+
diff --git a/machine/ASP/StorageRing/quadcenter_manual.m b/machine/ASP/StorageRing/quadcenter_manual.m
new file mode 100644
index 00000000..d67382c4
--- /dev/null
+++ b/machine/ASP/StorageRing/quadcenter_manual.m
@@ -0,0 +1,79 @@
+% close all
+% 0 = both planes; 1 = x-plane; 2 = y-plane
+plane = 0;
+
+
+sector = [8]; % sector number eg 1:14 or 5
+BPM_num = [1:7]; % BPM number eg 1:7
+
+% Turn on to furn BBA with paired quadrupoles
+paired = 0;
+
+% Sector number for BPM
+for i=sector
+ % BPM number within the sector
+ for j=BPM_num
+
+% if (i == 5 && j == 3) || (i == 11 && j == 5) % Measure BPM's
+
+ %elseif i == 14 && j == 5 % Omit any BPM's that are not working
+
+
+ BPMDev = [i j];
+
+ % if getfamilydata('BPMx','Status',BPMDev) == 0
+ % continue;
+ % end
+
+ switch BPMDev(2)
+ case {1 2}
+ quadfam = 'QFA';
+ if ~paired
+ quaddev = [BPMDev(1) 1];
+ else
+ if BPMDev(1) == 1
+ quaddev = [14 2; BPMDev(1) 1];
+ else
+ quaddev = [BPMDev(1)-1 2; BPMDev(1) 1];
+ end
+ end
+ case 3
+ quadfam = 'QDA';
+ quaddev = [BPMDev(1) 1];
+ case 4
+ quadfam = 'QFB';
+ if ~paired
+ quaddev = [BPMDev(1) 2];
+ else
+ quaddev = [BPMDev(1) 1; BPMDev(1) 2];
+ end
+ case 5
+ quadfam = 'QDA';
+ quaddev = [BPMDev(1) 2];
+ case {6 7}
+ quadfam = 'QFA';
+ if ~paired
+ quaddev = [BPMDev(1) 2];
+ else
+ if BPMDev(1) == 14
+ quaddev = [BPMDev(1) 2; 1 1];
+ else
+ quaddev = [BPMDev(1) 2; BPMDev(1)+1 1];
+ end
+ end
+ end
+
+ if ~paired
+ quadcenter(quadfam,quaddev,plane,BPMDev);
+ else
+ quadcenter_eugene(quadfam,quaddev,plane,BPMDev);
+ end
+
+ end
+end
+
+
+for i = 1:4
+ beep
+ pause(1)
+end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/quadcenter_manual_non_continuous.m b/machine/ASP/StorageRing/quadcenter_manual_non_continuous.m
new file mode 100644
index 00000000..61ef7958
--- /dev/null
+++ b/machine/ASP/StorageRing/quadcenter_manual_non_continuous.m
@@ -0,0 +1,48 @@
+close all
+% 0 = both planes; 1 = x-plane; 2 = y-plane
+plane = 0;
+
+sector = [4 4 5]; % sector number
+BPM_num = [6 7 1]; % BPM number eg 1:7
+
+% Sector number for BPM
+for h=1:length(sector)
+ i=sector(h);
+ % BPM number within the sector
+ %for j=BPM_num
+ j=BPM_num(h);
+ if i == 10 && j == 5
+ continue;
+ else
+ BPMDev = [i j];
+
+ % if getfamilydata('BPMx','Status',BPMDev) == 0
+ % continue;
+ % end
+
+ switch BPMDev(2)
+ case {1 2}
+ quadfam = 'QFA';
+ quaddev = [BPMDev(1) 1];
+ case 3
+ quadfam = 'QDA';
+ quaddev = [BPMDev(1) 1];
+ case 4
+ quadfam = 'QFB';
+ quaddev = [BPMDev(1) 2];
+ case 5
+ quadfam = 'QDA';
+ quaddev = [BPMDev(1) 2];
+ case {6 7}
+ quadfam = 'QFA';
+ quaddev = [BPMDev(1) 2];
+ end
+
+
+ quadcenter(quadfam,quaddev,plane,BPMDev);
+ end
+ %end
+end
+
+beep
+return
diff --git a/machine/ASP/StorageRing/quadcenterinit.m b/machine/ASP/StorageRing/quadcenterinit.m
index c09045d4..85e5e0f8 100644
--- a/machine/ASP/StorageRing/quadcenterinit.m
+++ b/machine/ASP/StorageRing/quadcenterinit.m
@@ -1,225 +1,252 @@
-function QMS = quadcenterinit(QuadFamily, QuadDev, QuadPlane, varargin)
-% QMS = quadcenterinit(Family, Device, QuadPlane, [BPMdev])
-%
-% If BPMDev is not given the the closest BPM to the quadrupole is used.
-%
-% QuadFamily = Quadrupole family
-% QuadDev = Quadrupole device
-% QuadPlane = Plane (1=horizontal {default}, 2=vertical)
-%
-% QMS structure contains fields:
-% QMS.QuadFamily
-% QMS.QuadDev
-% QMS.QuadDelta
-% QMS.QuadPlane
-% QMS.BPMFamily
-% QMS.BPMDev
-% QMS.BPMDevList
-% QMS.CorrFamily
-% QMS.CorrDevList % Often one magnet but bumps or anything else is fine
-% QMS.CorrDelta % Scale factor for each magnet in CorrDevList
-% QMS.DataDirectory % From AD or '.'
-% QMS.QuadraticFit = 1; % 1=quadratic fit, else linear fit
-% QMS.OutlierFactor = 1; % if abs(data - fit) > OutlierFactor * BPMstd, then remove that BPM [mm]
-% QMS.NumberOfPoints = 3;
-% QMS.ModulationMethod = 'bipolar'
-% QMS.CorrectOrbit 'yes' or 'no'
-% QMS.CreatedBy
-
-
-if nargin < 1
- FamilyList = getfamilylist;
- [tmp,i] = ismemberof(FamilyList,'QUAD');
- if ~isempty(i)
- FamilyList = FamilyList(i,:);
- end
- [i,ok] = listdlg('PromptString', 'Select a quadrupole family:', ...
- 'SelectionMode', 'single', ...
- 'ListString', FamilyList);
- if ok == 0
- return
- else
- QuadFamily = deblank(FamilyList(i,:));
- end
-end
-if ~isfamily(QuadFamily)
- error(sprintf('Quadrupole family %s does not exist. Make sure the middle layer had been initialized properly.',QuadFamily));
-end
-if nargin < 2
- QuadDev = editlist(getlist(QuadFamily),QuadFamily,zeros(length(getlist(QuadFamily)),1));
-end
-if nargin < 3
- %QuadPlane = 1; % Horizontal default
- ButtonNumber = menu('Which Plane?', 'Horizontal','Vertical','Cancel');
- switch ButtonNumber
- case 1
- QuadPlane = 1;
- case 2
- QuadPlane = 2;
- otherwise
- fprintf(' quadcenterinit cancelled');
- return
- end
-end
-
-% Initialize the QMS structure
-QMS.QuadPlane = QuadPlane;
-QMS.QuadFamily = QuadFamily;
-QMS.QuadDev = QuadDev;
-QMS.QuadraticFit = 0; % 0 = linear fit, else quadratic fit
-QMS.OutlierFactor = 6; % BPM Outlier: abs(fit - measured data) > OutlierFactor * std(BPM)
-QMS.NumberOfPoints = 5; % 5
-QMS.ModulationMethod = 'bipolar';
-QMS.CorrectOrbit = 'no'; % 'yes' or 'no'; % Only do if the orbit is reasonably close to the offset orbit
-
-
-% Note: DataDirectory must start with the root of the tree and end with filesep or be '.'
-QMSDirectory = [getfamilydata('Directory','DataRoot') 'QMS' filesep];
-if isempty(QMSDirectory)
- QMS.DataDirectory = '.';
-else
- QMS.DataDirectory = QMSDirectory;
-end
-
-
-% Select whether to use the first or second bpm to measure the offset
-% for the QFA magnets.
-bpm_in_short_girder = 2; % first (1) or second (2)
-
-% Default QMS structure
-if QMS.QuadPlane==1
- % Default families
- QMS.BPMFamily = 'BPMx';
- QMS.CorrFamily = 'HCM';
-
- % Quad delta
- spmax = getsp(QMS.QuadFamily, QMS.QuadDev);
- switch QMS.QuadFamily
- case 'QFA'
- %QMS.QuadDelta = .05 * spmax; % in amps
- QMS.QuadDelta = 0.03*spmax;
- case 'QFB'
- %QMS.QuadDelta = .02 * spmax;
- QMS.QuadDelta = 0.03*spmax;
- case 'QDA'
- %QMS.QuadDelta = .02 * spmax;
- QMS.QuadDelta = 0.03*spmax;
- end
-
- if nargin < 4
- % BPM closest to the quad
- QMS.BPMDevList = getlist(QMS.BPMFamily);
- BPMspos = getspos(QMS.BPMFamily);
- Quadspos = getspos(QMS.QuadFamily, QMS.QuadDev);
- i = find(abs(Quadspos-BPMspos)==min(abs(Quadspos-BPMspos)));
- QMS.BPMDev = QMS.BPMDevList(i,:);
- if strcmpi(QMS.QuadFamily,'QFA')
- QMS.BPMDev(2) = QMS.BPMDev(2) + (bpm_in_short_girder-1);
- end
- else
- QMS.BPMDevList = getlist(QMS.BPMFamily);
- QMS.BPMDev = varargin{1};
- end
-
- % Pick the corrector based on the response matrix to pick the most
- % effective corrector.
- R = getbpmresp('Struct','Hardware');
- [i, iNotFound] = findrowindex(QMS.BPMDev, R(1,1).Monitor.DeviceList);
- m = R(1,1).Data(i,:);
- [MaxValue, j] = max(abs(m));
- QMS.CorrDevList = R(1,1).Actuator.DeviceList(j,:);
-
- % Move beam closer to 0 if starting position is greater than +-2 mm.
-% currpos = getam(QMS.BPMFamily,QMS.BPMDev,'Hardware');
-% if abs(currpos) > 2
-% resp_val = m(j);
-% stepcorrval = -currpos./resp_val;
-% stepsp(QMS.CorrFamily,stepcorrval,QMS.CorrDevList);
-% end
-
- % Corrector delta in ampere. m(j) is the response of the bpm of interest due to
- % the corrector of interest and is in units of mm/ampere. Therefore the
- % number that we multiply against below are mm offsets that we want to
- % observe at the BPM.
- switch QMS.BPMDev(2)
- case {1 7}
- QMS.CorrDelta = 2; %abs((1./m(j)) * 1);
- case {2 6}
- QMS.CorrDelta = 2; %abs((1./m(j)) * 1);
- case {4}
- QMS.CorrDelta = 2; %abs((1./m(j)) * 1);
- case {3 5}
- QMS.CorrDelta = 2; %abs((1./m(j)) * 1);
- end
- if strcmpi(getunits(QMS.CorrFamily),'Physics')
- % Calculated values above are in HW units. If the default units are
- % in physics then we have to do a conversion into radians.
- QMS.CorrDelta = hw2physics(QMS.CorrFamily,'Setpoint',QMS.CorrDelta,QMS.CorrDevList);
- end
-
-elseif QMS.QuadPlane==2
- % Default families
- QMS.BPMFamily = 'BPMy';
- QMS.CorrFamily = 'VCM';
-
- % Quad delta
- spmax = getsp(QMS.QuadFamily, QMS.QuadDev);
- switch QMS.QuadFamily
- case 'QFA'
- %QMS.QuadDelta = .05 * spmax; % in amps
- QMS.QuadDelta = 0.03*spmax;
- case 'QFB'
- %QMS.QuadDelta = .02 * spmax;
- QMS.QuadDelta = 0.03*spmax;
- case 'QDA'
- %QMS.QuadDelta = .02 * spmax;
- QMS.QuadDelta = 0.03*spmax;
- end
-
- if nargin < 4
- % BPM closest to the quad
- QMS.BPMDevList = getlist(QMS.BPMFamily);
- BPMspos = getspos(QMS.BPMFamily);
- Quadspos = getspos(QMS.QuadFamily, QMS.QuadDev);
- i = find(abs(Quadspos-BPMspos)==min(abs(Quadspos-BPMspos)));
- QMS.BPMDev = QMS.BPMDevList(i,:);
- if strcmpi(QMS.QuadFamily,'QFA')
- QMS.BPMDev(2) = QMS.BPMDev(2) + (bpm_in_short_girder-1);
- end
- else
- QMS.BPMDevList = getlist(QMS.BPMFamily);
- QMS.BPMDev = varargin{1};
- end
-
- % Pick the corrector based on the response matrix
- R = getbpmresp('Struct','Hardware');
- [i, iNotFound] = findrowindex(QMS.BPMDev, R(2,2).Monitor.DeviceList);
- m = R(2,2).Data(i,:);
- [MaxValue, j] = max(abs(m));
- QMS.CorrDevList = R(2,2).Actuator.DeviceList(j,:);
-
- % Corrector delta in ampere. m(j) is the response of the bpm of interest due to
- % the corrector of interest and is in units of mm/ampere. Therefore the
- % number that we multiply against below are mm offsets that we want to
- % observe at the BPM.
- switch QMS.BPMDev(2)
- case {1 7}
- QMS.CorrDelta = 2; %-abs((1./m(j)) * 0.5);
- case {2 6}
- QMS.CorrDelta = 2; %-abs((1./m(j)) * 0.5);
- case {4}
- QMS.CorrDelta = 2; %-abs((1./m(j)) * 0.5);
- case {3 5}
- QMS.CorrDelta = 2; %-abs((1./m(j)) * 0.5);
- end
- if strcmpi(getunits(QMS.CorrFamily),'Physics')
- % Calculated values above are in HW units. If the default units are
- % in physics then we have to do a conversion into radians.
- QMS.CorrDelta = hw2physics(QMS.CorrFamily,'Setpoint',QMS.CorrDelta,QMS.CorrDevList);
- end
-else
- error('QMS.QuadPlane must be 1 or 2');
-end
-
-QMS.CreatedBy = 'quadcenterinit';
-QMS = orderfields(QMS);
+function QMS = quadcenterinit(QuadFamily, QuadDev, QuadPlane, varargin)
+% QMS = quadcenterinit(Family, Device, QuadPlane, [BPMdev])
+%
+% If BPMDev is not given the the closest BPM to the quadrupole is used.
+%
+% QuadFamily = Quadrupole family
+% QuadDev = Quadrupole device
+% QuadPlane = Plane (1=horizontal {default}, 2=vertical)
+%
+% QMS structure contains fields:
+% QMS.QuadFamily
+% QMS.QuadDev
+% QMS.QuadDelta
+% QMS.QuadPlane
+% QMS.BPMFamily
+% QMS.BPMDev
+% QMS.BPMDevList
+% QMS.CorrFamily
+% QMS.CorrDevList % Often one magnet but bumps or anything else is fine
+% QMS.CorrDelta % Scale factor for each magnet in CorrDevList
+% QMS.DataDirectory % From AD or '.'
+% QMS.QuadraticFit = 1; % 1=quadratic fit, else linear fit
+% QMS.OutlierFactor = 1; % if abs(data - fit) > OutlierFactor * BPMstd, then remove that BPM [mm]
+% QMS.NumberOfPoints = 3;
+% QMS.ModulationMethod = 'bipolar'
+% QMS.CorrectOrbit 'yes' or 'no'
+% QMS.CreatedBy
+
+
+if nargin < 1
+ FamilyList = getfamilylist;
+ [tmp,i] = ismemberof(FamilyList,'QUAD');
+ if ~isempty(i)
+ FamilyList = FamilyList(i,:);
+ end
+ [i,ok] = listdlg('PromptString', 'Select a quadrupole family:', ...
+ 'SelectionMode', 'single', ...
+ 'ListString', FamilyList);
+ if ok == 0
+ return
+ else
+ QuadFamily = deblank(FamilyList(i,:));
+ end
+end
+if ~isfamily(QuadFamily)
+ error(sprintf('Quadrupole family %s does not exist. Make sure the middle layer had been initialized properly.',QuadFamily));
+end
+if nargin < 2
+ QuadDev = editlist(getlist(QuadFamily),QuadFamily,zeros(length(getlist(QuadFamily)),1));
+end
+if nargin < 3
+ %QuadPlane = 1; % Horizontal default
+ ButtonNumber = menu('Which Plane?', 'Horizontal','Vertical','Cancel');
+ switch ButtonNumber
+ case 1
+ QuadPlane = 1;
+ case 2
+ QuadPlane = 2;
+ otherwise
+ fprintf(' quadcenterinit cancelled');
+ return
+ end
+end
+
+% Initialize the QMS structure
+QMS.QuadPlane = QuadPlane;
+QMS.QuadFamily = QuadFamily;
+QMS.QuadDev = QuadDev;
+QMS.QuadraticFit = 0; % 0 = linear fit, else quadratic fit
+QMS.OutlierFactor = 6; % BPM Outlier: abs(fit - measured data) > OutlierFactor * std(BPM)
+QMS.NumberOfPoints = 4; % 5
+QMS.ModulationMethod = 'bipolar';
+QMS.CorrectOrbit = 'no'; % 'yes' or 'no'; % Only do if the orbit is reasonably close to the offset orbit
+
+
+% Note: DataDirectory must start with the root of the tree and end with filesep or be '.'
+QMSDirectory = [getfamilydata('Directory','DataRoot') 'QMS' filesep];
+if isempty(QMSDirectory)
+ QMS.DataDirectory = '.';
+else
+ QMS.DataDirectory = QMSDirectory;
+end
+
+
+% Select whether to use the first or second bpm to measure the offset
+% for the QFA magnets.
+bpm_in_short_girder = 2; % first (1) or second (2)
+
+% Default QMS structure
+if QMS.QuadPlane==1
+ % Default families
+ QMS.BPMFamily = 'BPMx';
+ QMS.CorrFamily = 'HCM';
+
+ % Quad delta. Can actuate more than one quadrupole... so scale
+ % the strength linearly with the number of quads to actuate.
+ spmax = getsp(QMS.QuadFamily, QMS.QuadDev);
+ switch QMS.QuadFamily
+ case 'QFA'
+ %QMS.QuadDelta = .05 * spmax; % in amps
+ QMS.QuadDelta = 0.02*spmax/length(spmax);
+ case 'QFB'
+ %QMS.QuadDelta = .02 * spmax;
+ QMS.QuadDelta = 0.01*spmax/length(spmax);
+ case 'QDA'
+ %QMS.QuadDelta = .02 * spmax;
+ QMS.QuadDelta = 0.03*spmax/length(spmax);
+ case 'SFA'
+ %QMS.QuadDelta = .05 * spmax; % in amps
+ QMS.QuadDelta = 20;
+ case 'SDA'
+ %QMS.QuadDelta = .02 * spmax;
+ QMS.QuadDelta = 20;
+ case 'SDB'
+ %QMS.QuadDelta = .02 * spmax;
+ QMS.QuadDelta = 20;
+ case 'SFB'
+ %QMS.QuadDelta = .02 * spmax;
+ QMS.QuadDelta = 20;
+ end
+
+ if nargin < 4
+ % BPM closest to the quad
+ QMS.BPMDevList = getlist(QMS.BPMFamily);
+ BPMspos = getspos(QMS.BPMFamily);
+ Quadspos = getspos(QMS.QuadFamily, QMS.QuadDev);
+ i = find(abs(Quadspos-BPMspos)==min(abs(Quadspos-BPMspos)));
+ QMS.BPMDev = QMS.BPMDevList(i,:);
+ if strcmpi(QMS.QuadFamily,'QFA')
+ QMS.BPMDev(2) = QMS.BPMDev(2) + (bpm_in_short_girder-1);
+ end
+ else
+ QMS.BPMDevList = getlist(QMS.BPMFamily);
+ QMS.BPMDev = varargin{1};
+ end
+
+ % Pick the corrector based on the response matrix to pick the most
+ % effective corrector.
+ R = getbpmresp('Struct','Hardware');
+ [i, iNotFound] = findrowindex(QMS.BPMDev, R(1,1).Monitor.DeviceList);
+% [i, iNotFound] = findrowindex([3 3], R(1,1).Monitor.DeviceList);
+ m = R(1,1).Data(i,:);
+ [MaxValue, j] = max(abs(m));
+ QMS.CorrDevList = R(1,1).Actuator.DeviceList(j,:);
+
+ % Move beam closer to 0 if starting position is greater than +-2 mm.
+% currpos = getam(QMS.BPMFamily,QMS.BPMDev,'Hardware');
+% if abs(currpos) > 2
+% resp_val = m(j);
+% stepcorrval = -currpos./resp_val;
+% stepsp(QMS.CorrFamily,stepcorrval,QMS.CorrDevList);
+% end
+
+ % Corrector delta in ampere. m(j) is the response of the bpm of interest due to
+ % the corrector of interest and is in units of mm/ampere. Therefore the
+ % number that we multiply against below are mm offsets that we want to
+ % observe at the BPM.
+ switch QMS.BPMDev(2)
+ case {1 7}
+ QMS.CorrDelta = 1; %2; %abs((1./m(j)) * 1);
+ case {2 6}
+ QMS.CorrDelta = 1; %2; %abs((1./m(j)) * 1);
+ case {4}
+ QMS.CorrDelta = 1; %2; %abs((1./m(j)) * 1);
+ case {3 5}
+ QMS.CorrDelta = 2; %3; %abs((1./m(j)) * 1);
+ end
+ if strcmpi(getunits(QMS.CorrFamily),'Physics')
+ % Calculated values above are in HW units. If the default units are
+ % in physics then we have to do a conversion into radians.
+ QMS.CorrDelta = hw2physics(QMS.CorrFamily,'Setpoint',QMS.CorrDelta,QMS.CorrDevList);
+ end
+
+elseif QMS.QuadPlane==2
+ % Default families
+ QMS.BPMFamily = 'BPMy';
+ QMS.CorrFamily = 'VCM';
+
+ % Quad delta
+ spmax = getsp(QMS.QuadFamily, QMS.QuadDev);
+ switch QMS.QuadFamily
+ case 'QFA'
+ %QMS.QuadDelta = .05 * spmax; % in amps
+ QMS.QuadDelta = 0.02*spmax/length(spmax);
+ case 'QFB'
+ %QMS.QuadDelta = .02 * spmax;
+ QMS.QuadDelta = 0.01*spmax/length(spmax);
+ case 'QDA'
+ %QMS.QuadDelta = .02 * spmax;
+ QMS.QuadDelta = 0.03*spmax/length(spmax);
+ case 'SFA'
+ %QMS.QuadDelta = .05 * spmax; % in amps
+ QMS.QuadDelta = 40;
+ case 'SDA'
+ %QMS.QuadDelta = .02 * spmax;
+ QMS.QuadDelta = 40;
+ case 'SDB'
+ %QMS.QuadDelta = .02 * spmax;
+ QMS.QuadDelta = 40;
+ case 'SFB'
+ %QMS.QuadDelta = .02 * spmax;
+ QMS.QuadDelta = 40;
+ end
+
+ if nargin < 4
+ % BPM closest to the quad
+ QMS.BPMDevList = getlist(QMS.BPMFamily);
+ BPMspos = getspos(QMS.BPMFamily);
+ Quadspos = getspos(QMS.QuadFamily, QMS.QuadDev);
+ i = find(abs(Quadspos-BPMspos)==min(abs(Quadspos-BPMspos)));
+ QMS.BPMDev = QMS.BPMDevList(i,:);
+ if strcmpi(QMS.QuadFamily,'QFA')
+ QMS.BPMDev(2) = QMS.BPMDev(2) + (bpm_in_short_girder-1);
+ end
+ else
+ QMS.BPMDevList = getlist(QMS.BPMFamily);
+ QMS.BPMDev = varargin{1};
+ end
+
+ % Pick the corrector based on the response matrix
+ R = getbpmresp('Struct','Hardware');
+ [i, iNotFound] = findrowindex(QMS.BPMDev, R(2,2).Monitor.DeviceList);
+% [i, iNotFound] = findrowindex([3 3], R(2,2).Monitor.DeviceList);
+ m = R(2,2).Data(i,:);
+ [MaxValue, j] = max(abs(m));
+ QMS.CorrDevList = R(2,2).Actuator.DeviceList(j,:);
+
+ % Corrector delta in ampere. m(j) is the response of the bpm of interest due to
+ % the corrector of interest and is in units of mm/ampere. Therefore the
+ % number that we multiply against below are mm offsets that we want to
+ % observe at the BPM.
+ switch QMS.BPMDev(2)
+ case {1 7}
+ QMS.CorrDelta = 1; %-abs((1./m(j)) * 0.5);
+ case {2 6}
+ QMS.CorrDelta = 1; %-abs((1./m(j)) * 0.5);
+ case {4}
+ QMS.CorrDelta = 1; %-abs((1./m(j)) * 0.5);
+ case {3 5}
+ QMS.CorrDelta = 1; %-abs((1./m(j)) * 0.5);
+ end
+ if strcmpi(getunits(QMS.CorrFamily),'Physics')
+ % Calculated values above are in HW units. If the default units are
+ % in physics then we have to do a conversion into radians.
+ QMS.CorrDelta = hw2physics(QMS.CorrFamily,'Setpoint',QMS.CorrDelta,QMS.CorrDevList);
+ end
+else
+ error('QMS.QuadPlane must be 1 or 2');
+end
+
+QMS.CreatedBy = 'quadcenterinit';
+QMS = orderfields(QMS);
diff --git a/machine/ASP/StorageRing/ramp_sext_down.m b/machine/ASP/StorageRing/ramp_sext_down.m
new file mode 100644
index 00000000..37412597
--- /dev/null
+++ b/machine/ASP/StorageRing/ramp_sext_down.m
@@ -0,0 +1,51 @@
+afamily = [
+ 0.95
+ 0.9
+ 0.85
+ 0.8
+ 0.75
+ 0.7
+ 0.6
+ 0.5
+ 0.45
+ 0.4
+ 0.35
+ 0.3
+ 0.25
+ 0.2
+ 0.15
+ 0.10
+ 0];
+bfamily = [
+ 0.95
+ 0.9
+ 0.85
+ 0.8
+ 0.75
+ 0.7
+ 0.65
+ 0.6
+ 0.55
+ 0.5
+ 0.45
+ 0.4
+ 0.35
+ 0.3
+ 0.25
+ 0.2
+ 0.0];
+
+sfa_init = getsp('SFA');
+sda_init = getsp('SDA');
+sfb_init = getsp('SFB');
+sdb_init = getsp('SDB');
+
+for i=1:length(afamily)
+ % The [] means all devices in that family and -1 means that it will
+ % also monitor the readback and only return when the readback reaches
+ % the setpoint.
+ setsp('SFA',sfa_init*afamily,[],-1);
+ setsp('SDA',sda_init*afamily,[],-1);
+ setsp('SFB',sfb_init*bfamily,[],-1);
+ setsp('SDB',sdb_init*bfamily,[],-1);
+end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/scalekickers.m b/machine/ASP/StorageRing/scalekickers.m
index 30c75aef..ef50f33b 100644
--- a/machine/ASP/StorageRing/scalekickers.m
+++ b/machine/ASP/StorageRing/scalekickers.m
@@ -1,22 +1,42 @@
-start_kick = [...
-754.436200;...
-729.816200;...
-778.147200;...
-790.224000;...
- ];
+%
+% start_kick = 1e3*[...
+% 1.0766;...
+% 0.8100;...
+% 0.8505;...
+% 1.0766;...
+% ];
-scale_kick_dc = 1.23;
-scale_kick = scale_kick_dc + [...
- 0;...
- 0;...
- 0;...
- 0;...
+start_kick = 1e3*[...
+ 1.085361125348219
+ 0.777860772891015
+ 0.826628872449025
+ 1.085902123286940
];
-setsp('KICK',start_kick([1 2 3 4]).*scale_kick,'Hardware');
+% 1.62 GeV
+start_kick = [
+ 737.4172
+ 584.0000
+ 582.5500
+ 737.4172];
+%scale_kick_dc = 1.23;
+scale_kick_dc = 0.92;
+scale_kick = scale_kick_dc + [...
+ -0.00;...
+ 0.00;...
+ 0.00;...
+ -0.00;...
+ ];
+setsp('KICK',start_kick([1 2 3 4]).*scale_kick,'Hardware','Online');
+%start_kick = [...
+%754.436200;...
+%729.816200;...
+%778.147200;...
+%790.224000;...
+% ];
% start_kick = [...
diff --git a/machine/ASP/StorageRing/scraper_app.m b/machine/ASP/StorageRing/scraper_app.m
index 09eb7cc2..d5926254 100644
--- a/machine/ASP/StorageRing/scraper_app.m
+++ b/machine/ASP/StorageRing/scraper_app.m
@@ -1,62 +1,187 @@
-function scraper_app(choice)
-
-%funtion is given choice of UPPER or LOWER
-%function returns the lifetime and current at each of a number of scraper positions
-
-steps = 23; %21;
-
-if strcmp(choice,'UPPER') || strcmp(choice,'LOWER')
- data = zeros(4,steps);
- data(1,:) = [6 7 8 9 10 11 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 12 12.1 12.2 12.3 12.4 12.5 13 13.5 ];
-elseif strcmp(choice,'INNER')
- data = zeros(3,21);
- data(1,:) = [6 8 10 12 12.5 13 13.5 14 14.5 14.8 15 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16];
-elseif strcmp(choice,'OUTER')
- data = zeros(3,21);
- data(1,:) = [6 8 10 12 12.5 13 13.5 14 14.5 14.8 15 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16];
-end
-
-time = clock;
-filesave = ['/asp/usr/commissioning/scraperscan/ScraperScan' date '-' num2str(time(4)) '-' num2str(time(5)) '-' num2str(fix(time(6)))];
-fprintf('Data saved to: %s\n',filesave);
-
-
-scrape = ['SR11SCR01:' num2str(choice) '_POSITION_SP'];
-
-for(i=1:steps)
-
- if getpv('SR11BCM01:CURRENT_MONITOR')<=5
- disp('ERROR: CURRENT IS LOW!');
- setpv(scrape,0);
- return
- end
-
- setpv(scrape,data(1,i));
- pause(3);
- disp('gathering lifetime data')
- data(2,i) = lifetime(45);
- data(3,i) = getpv('SR11BCM01:CURRENT_MONITOR')
- data(4,i) = data(2,i) * (data(3,i)/data(3,1));
-
- save(filesave, 'data');
-
-end
-
-setpv(scrape,0);
-save(filesave, 'data');
-
-figure(47)
-plot(data(1,:),data(4,:))
-temp = [choice ' SCRAPER DATA'];
-title(temp)
-xlabel('Scraper position (mm)')
-ylabel('Normalised lifetime (h)')
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+function scraper_app(choice,lifemeas)
+
+%funtion is given choice of UPPER or LOWER
+%function returns the lifetime and current at each of a number of scraper positions
+
+
+% 24/5/2007 curerntly runs both upper and lower scraper in. Will need to
+% edit again to use only one scrper at a time.
+% 04/07/2011 ET updated so single and double move of the scraper blades is
+% possible. filename changes as well so data plots will not be compatible
+% to previous files. Data saved is exactly the same will use the filename
+% as the timestamp.
+
+% +-0.15 is a calibration factor to account for the offset of the
+% scraper relative to the beam center.
+switch lower(choice)
+ case 'upper'
+ data(1,:) = [8:0.25:10 10.1:0.1:11 11.05:0.05:12.5 12.6:.1:14];
+% data(1,:) = [8 10 11 11.5 12 12.5 13 13.5 14 14.01 14.02 14.03 14.04 14.05 14.06 14.07 14.08 14.09 14.1 14.11 14.12 ...
+% 14.13 14.14 14.15 14.16 14.17 14.18 14.19 14.2 14.21 14.22 14.23 14.24 14.25 14.26 14.27 14.28 14.29 14.3 14.31 ...
+% 14.32 14.34 14.35 14.36 14.37 14.38 14.39 14.4 14.41 14.42 14.43 14.44 14.45 14.46 14.47 14.48 14.49 ...
+% 14.5 14.51 14.52 14.53 14.54 14.55 14.56 14.57 14.58 14.59 14.6 14.61 14.62 14.63 14.64 14.65 14.66 ...
+% 14.67 14.68 14.69 14.7 14.71 14.72 14.73 14.74 14.75 14.76 14.77 14.78 14.79 14.8 14.81 14.82 14.83 ...
+% 14.84 14.85 14.86 14.87 14.88 14.89 14.9 14.91 14.92 14.93 14.94 14.95 14.96 14.97 14.98 14.99 15 ];
+% data(1,:) = [8 10 11 11.25 11.5 11.75 12 12.25 12.5 12.75 13 13.25 13.5 13.75 14 14.05 14.1 14.15 14.2 14.25 14.3 14.35 ...
+% 14.4 14.45 14.5 14.55 14.6 14.65 14.7 14.75 14.8 14.81 14.82 14.83 14.85 14.9 14.95 15 15.01 15.02 15.03 15.04 15.05 ...
+% 15.06 15.07 15.08 15.09 15.1 15.11 15.12 15.13 15.14 15.15 15.16 15.17 15.18 15.19 15.2 15.21 15.22 15.23 15.24 15.25 ...
+% 15.26 15.27 15.28 15.29 15.3 15.31 15.32 15.33 15.34 15.35 15.36 15.37 15.38 15.39 15.4 15.41 15.42 15.43 15.44 15.45 ...
+% 15.46 15.47 15.48 15.49 15.5 15.51 15.52 15.53 15.54 15.55 15.56 15.57 15.58 15.59 15.6 15.61 15.62 15.63 15.64 15.65 ...
+% 15.66 15.67 15.68 15.69 15.7 15.71 15.72 15.73 15.74 15.75 15.76 15.77 15.78 15.79 15.8 15.81 15.82 15.83 15.84 15.85 ...
+% 15.86 15.87 15.88 15.89 15.9 15.91 15.92 15.93 15.94 15.95 15.96 15.97 15.98 15.99 16];
+
+
+ pospv = {'SR11SCR01:UPPER_POSITION_SP'};
+ enablepv = {'SR11SCR01:UPPER_ENABLE_CMD'};
+
+ case 'lower'
+ data(1,:) = [8:0.25:10 10.1:0.1:11 11.05:0.05:12.5 12.6:.1:14];
+% data(1,:) = [8 10 11 11.5 12 12.5 13 13.5 14 14.01 14.02 14.03 14.04 14.05 14.06 14.07 14.08 14.09 14.1 14.11 14.12 ...
+% 14.13 14.14 14.15 14.16 14.17 14.18 14.19 14.2 14.21 14.22 14.23 14.24 14.25 14.26 14.27 14.28 14.29 14.3 14.31 ...
+% 14.32 14.34 14.35 14.36 14.37 14.38 14.39 14.4 14.41 14.42 14.43 14.44 14.45 14.46 14.47 14.48 14.49 ...
+% 14.5 14.51 14.52 14.53 14.54 14.55 14.56 14.57 14.58 14.59 14.6 14.61 14.62 14.63 14.64 14.65 14.66 ...
+% 14.67 14.68 14.69 14.7 14.71 14.72 14.73 14.74 14.75 14.76 14.77 14.78 14.79 14.8 14.81 14.82 14.83 ...
+% 14.84 14.85 14.86 14.87 14.88 14.89 14.9 14.91 14.92 14.93 14.94 14.95 14.96 14.97 14.98 14.99 15 ];
+ pospv = {'SR11SCR01:LOWER_POSITION_SP'};
+ enablepv = {'SR11SCR01:LOWER_ENABLE_CMD'};
+
+ case 'inner'
+ data(1,:) = [6 8 10 12 12.25, ...
+ 12.5 12.75 13 13.5 14 14.5 14.8 15 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16];
+ pospv = {'SR11SCR01:INNER_POSITION_SP'};
+ enablepv = {'SR11SCR01:INNER_ENABLE_CMD'};
+ case 'outer'
+ data(1,:) = [6 8 10 12 12.5 13 13.5 14 14.5 14.8 15 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16];
+ pospv = {'SR11SCR01:OUTER_POSITION_SP'};
+ enablepv = {'SR11SCR01:OUTER_ENABLE_CMD'};
+
+ case 'both'
+ data(1,:) = [8:0.25:10 10.1:0.1:11 11.05:0.05:12.5 12.6:.1:14];
+ pospv = {'SR11SCR01:UPPER_POSITION_SP','SR11SCR01:LOWER_POSITION_SP'};
+ enablepv = {'SR11SCR01:UPPER_ENABLE_CMD','SR11SCR01:LOWER_ENABLE_CMD'};
+end
+
+steps = size(data,2);
+
+
+time = clock;
+filesave = ['/asp/usr/measurements/scrapers/' appendtimestamp('ScraperScan')];
+fprintf('Data saved to: %s\n',filesave);
+
+for i=1:steps
+
+ % if there is too little current then stop gathering data, save and
+ % return may have dumped beam.
+ if getpv('SR11BCM01:CURRENT_MONITOR')<=0.1
+ disp('ERROR: CURRENT IS LOW!');
+ % open up the scrapers
+ setpv(pospv,repmat({0},size(pospv)));
+
+ save(filesave, 'data');
+
+ figure(47)
+ plot(data(1,:),data(4,:))
+ temp = ['UPPER & LOWER SCRAPER DATA'];
+ title(temp)
+ xlabel('Scraper position (mm)')
+ ylabel('Normalised lifetime (h)')
+ beep;
+ return
+ end
+
+ setpv(enablepv,repmat({1},size(pospv)));
+ pause(0.3);
+ if strcmpi(choice,'both')
+ setpv(pospv,{data(1,i)+0.15,data(1,i)-0.15});
+ else
+ setpv(pospv,{data(1,i)});
+ end
+ pause(3);
+
+ % disable to improve lifetime measurements
+ setpv(enablepv,repmat({0},size(pospv)));
+ pause(0.3)
+ disp('gathering lifetime data')
+ if i > 1 && data(2,i-1) < data(2,1)/2
+ % attempt to decrease the time required for a lifetime measurement
+ % if the previous results show that the lifetime has already
+ % decreased by 1/3 of the initial lifetime.
+ data(2,i) = lifetime(lifemeas/2);
+ else
+ data(2,i) = lifetime(lifemeas);
+ end
+ data(3,i) = getpv('SR11BCM01:CURRENT_MONITOR');
+ data(4,i) = data(2,i) * (data(3,i)/data(3,1));
+
+
+ save(filesave, 'data');
+
+end
+
+setpv(enablepv,repmat({1},size(pospv)));
+setpv(pospv,repmat({0},size(pospv)));
+pause(6);
+setpv(enablepv,repmat({0},size(pospv)));
+
+save(filesave, 'data');
+
+figure(47)
+plot(data(1,:),data(4,:))
+
+xlabel('Scraper position (mm)')
+ylabel('Normalised lifetime (h)')
+
+beep;
+return
+
+
+%%
+time = clock;
+filesave = ['/asp/usr/measurements/scrapers/ScraperScan' date '-' num2str(time(4)) '-' num2str(time(5)) '-' num2str(fix(time(6)))];
+fprintf('Data saved to: %s\n',filesave);
+
+scrape = ['SR11SCR01:' num2str(choice) '_POSITION_SP'];
+
+for(j=1:steps)
+
+ if getpv('SR11BCM01:CURRENT_MONITOR')<=5
+ disp('ERROR: CURRENT IS LOW!');
+ setpv(scrape,0);
+
+ save(filesave, 'data');
+
+ figure(47)
+ plot(data(1,:),data(4,:))
+ temp = [choice 'SCRAPER DATA'];
+ title(temp)
+ xlabel('Scraper position (mm)')
+ ylabel('Normalised lifetime (h)')
+ beep;
+ return
+ end
+
+ setpv(scrape,data(1,j));
+ pause(3);
+ disp('gathering lifetime data')
+ data(2,j) = lifetime(10);
+ data(3,j) = getpv('SR11BCM01:CURRENT_MONITOR')
+ data(4,j) = data(2,j) * (data(3,j)/data(3,j));
+
+ save(filesave, 'data');
+
+end
+
+setpv(scrape,0);
+save(filesave, 'data');
+
+figure(47)
+plot(data(1,:),data(4,:))
+temp = [choice 'SCRAPER DATA'];
+title(temp)
+xlabel('Scraper position (mm)')
+ylabel('Normalised lifetime (h)')
+
+beep
+
+
+
diff --git a/machine/ASP/StorageRing/setchromaticity.m b/machine/ASP/StorageRing/setchromaticity.m
new file mode 100644
index 00000000..338ecffb
--- /dev/null
+++ b/machine/ASP/StorageRing/setchromaticity.m
@@ -0,0 +1,166 @@
+function varargout = setchromaticity(varargin)
+% SETCHROMATICITY([CHROMX CHROMY],[SFAval SDAval],Mode,'fitonly')
+%
+% Uses the model to determine how to set the sextupolesn (SFB and SDB) to get the desired
+% chromaticity. If SFAval and SDAval is supplies (in PHYSICS units) then
+% these will values will be used in the model and also applied to the
+% machine.
+%
+% CHROMX, CHROMY - horizontal and vertical chromacitity
+% SFAval, SDAval - desired setpoint for SFA and SDA in PHYSICS units (optional)
+% Mode - lattice selection (optional).
+% 'fitonly' - if fit only specified then don't set.
+%
+% Frequency: 499.67163 [MHz]
+% Operational setpoint as of 23/01/2014:
+% setchromaticity ([3.5 13], [15.9 -17.3])
+%
+% ET
+
+fitonly = 0;
+for i=1:nargin
+ if ischar(varargin{i})
+ switch varargin{i}
+ case 'fitonly'
+ fitonly = 1;
+ end
+ end
+end
+if nargin > 0
+ chromx = varargin{1}(1);
+ chromy = varargin{1}(2);
+else
+ error('See usage of SETCHROMATICITY');
+end
+
+if nargin > 1
+ sfa = varargin{2}(1);
+ sda = varargin{2}(2);
+else
+ sfa = getsp('SFA',1,'physics');
+ sda = getsp('SDA',1,'physics');
+end
+
+ModeCell = {'User mode 0.1 m dispersion',
+ 'Low Alpha -0.7 m dispersion'
+ 'Low Alpha -0.88 m dispersion'
+ 'User mode 0.0 m dispersion'
+ 'User mode 0.24 m dispersion'
+ '7-fold lattice'
+ 'Use current THERING'};
+if nargin > 2 && isnumeric(varargin{3})
+ ButtonName = varargin{3};
+ OKFlag = 1;
+else
+ [ButtonName, OKFlag] = listdlg('Name','Set Chromaticity','PromptString','Currently used lattice?', 'SelectionMode','single', 'ListString', ModeCell, 'ListSize', [350 125]);
+ % OKFlag = 1;
+ % ButtonName = 2;
+end
+
+if ~OKFlag
+ disp('Nothing done. Exiting setchromaticity.');
+ return
+else
+ fprintf('Using lattice: %s\n',ModeCell{ButtonName});
+end
+
+global THERING
+OLDTHERING = THERING;
+
+switch ButtonName
+ case 1
+ assr4_modbend;
+% fittunedisp2([13.29 5.216 0.0],'QFA','QDA','QFB',1); % Eugene 16/5/2010 removed to optimise speed for sextupole scan.
+% fittunedisp2([13.29 5.216 0.096],'QFA','QDA','QFB',1); % Eugene
+% 16/5/2010 removed to optimise speed for sextupole scan.
+ ind = findcells(THERING,'FamName','QFA');
+ THERING = setcellstruct(THERING,'PolynomB',ind,1.7712776,2);
+ THERING = setcellstruct(THERING,'K',ind,1.7712776);
+ ind = findcells(THERING,'FamName','QDA');
+ THERING = setcellstruct(THERING,'PolynomB',ind,-1.0565061,2);
+ THERING = setcellstruct(THERING,'K',ind,-1.0565061);
+ ind = findcells(THERING,'FamName','QFB');
+ THERING = setcellstruct(THERING,'PolynomB',ind,1.5324321,2);
+ THERING = setcellstruct(THERING,'K',ind,1.5324321);
+ case 2
+ setoperationalmode(7);
+ fittunedisp2([13.29 5.20 -0.7],'QFA','QDA','QFB',1);
+ case 3
+ setoperationalmode(9);
+ fittunedisp2([13.29 5.216 -0.88],'QFA','QDA','QFB',1);
+ case 4
+ assr4_modbend;
+ fittunedisp2([13.289 5.205 0],'QFA','QDA','QFB',1);
+ case 5
+ assr4_modbend;
+ fittunedisp2([13.29 5.216 0.24],'QFA','QDA','QFB',1);
+ case 6
+ setoperationalmode(10);
+ case 7
+ % do nothing; use current lattice
+
+end
+
+sind(:,1) = findcells(THERING,'FamName','SFA');
+sind(:,2) = findcells(THERING,'FamName','SDA');
+% Hack just to make it a little neater, should not really affect the
+% results. there are 28 other family of sext but for SFB there are only 14.
+sind(:,3) = [findcells(THERING,'FamName','SFB') findcells(THERING,'FamName','SFB')];
+sind(:,4) = findcells(THERING,'FamName','SDB');
+% Set as close to storage ring settings as possible. These numbers 15.6 and
+% -16.6 etc. are taken from the machine using getsp(...,'physics'); So as
+% the machine energy is 1.4% less than the design of 3 GeV the values need
+% to be multiplied by 1.014 before putting it into the model (model is
+% assuming 3 GeV).
+% THERING = setcellstruct(THERING,'PolynomB',sind(:,1),15.6*1.014,3);
+% THERING = setcellstruct(THERING,'PolynomB',sind(:,2),-16.6*1.014,3);
+
+THERING = setcellstruct(THERING,'PolynomB',sind(:,1),sfa*1.014,3);
+THERING = setcellstruct(THERING,'PolynomB',sind(:,2),sda*1.014,3);
+
+THERING = setcellstruct(THERING,'PolynomB',sind(:,3),7.54467314*1.014,3);
+THERING = setcellstruct(THERING,'PolynomB',sind(:,4),-8.21721*1.014,3);
+
+% THERING = setcellstruct(THERING,'PolynomB',sind(:,1),getsp('SFA',[1 1],'physics')*1.014,3);
+% THERING = setcellstruct(THERING,'PolynomB',sind(:,2),getsp('SDA',[1 1],'physics')*1.014,3);
+% THERING = setcellstruct(THERING,'PolynomB',sind(:,3),getsp('SFB',[1 1],'physics')*1.014,3);
+% THERING = setcellstruct(THERING,'PolynomB',sind(:,4),getsp('SDB',[1 1],'physics')*1.014,3);
+
+fitchrom2([chromx chromy],'SFB','SDB');
+
+
+sfaind = findcells(THERING,'FamName','SFA');
+sdaind = findcells(THERING,'FamName','SDA');
+sfbind = findcells(THERING,'FamName','SFB');
+sdbind = findcells(THERING,'FamName','SDB');
+
+modelSFA = physics2hw('SFA','Setpoint',getcellstruct(THERING,'PolynomB',sfaind(1),3)/1.014);
+modelSDA = physics2hw('SDA','Setpoint',getcellstruct(THERING,'PolynomB',sdaind(1),3)/1.014);
+
+modelSFB = physics2hw('SFB','Setpoint',getcellstruct(THERING,'PolynomB',sfbind(1),3)/1.014);
+modelSDB = physics2hw('SDB','Setpoint',getcellstruct(THERING,'PolynomB',sdbind(1),3)/1.014);
+
+
+THERING = OLDTHERING;
+
+if ~fitonly
+ %Slowly ramp up to new setpoint
+ curSFA = getsp('SFA',[1 1],'Hardware');
+ curSDA = getsp('SDA',[1 1],'Hardware');
+ curSFB = getsp('SFB',[1 1],'Hardware');
+ curSDB = getsp('SDB',[1 1],'Hardware');
+
+ for j=1:5
+ setsp('SFA',curSFA + (modelSFA - curSFA)*j/5,'Hardware');
+ setsp('SDA',curSDA + (modelSDA - curSDA)*j/5,'Hardware');
+ setsp('SFB',curSFB + (modelSFB - curSFB)*j/5,'Hardware');
+ setsp('SDB',curSDB + (modelSDB - curSDB)*j/5,'Hardware');
+ % pause(0.2);
+ end
+ disp('Done. Chromaticity set.');
+end
+
+if nargout > 0
+ varargout{1} = [mean(modelSFA) mean(modelSDA) mean(modelSFB) mean(modelSDB)];
+end
+
diff --git a/machine/ASP/StorageRing/setchromaticity_et.m b/machine/ASP/StorageRing/setchromaticity_et.m
new file mode 100644
index 00000000..93083cd9
--- /dev/null
+++ b/machine/ASP/StorageRing/setchromaticity_et.m
@@ -0,0 +1,73 @@
+function varargout = setchromaticity(varargin)
+% SETCHROMATICITY([CHROMX CHROMY])
+
+% disp('Warning: this only applies to zero dispersion lattice');
+% disp('Warning: will also change setoperatioalmode(1)');
+
+if nargin > 0
+ chromx = varargin{1}(1);
+ chromy = varargin{1}(2);
+else
+ error('See usage of SETCHROMATICITY');
+end
+
+ModeCell = {'User mode 0.1 m dispersion',
+ 'Low Alpha -0.5 m dispersion'
+ 'Low Alpha -0.75 m dispersion'};
+[ButtonName, OKFlag] = listdlg('Name','Set Chromaticity','PromptString','Currently used lattice?', 'SelectionMode','single', 'ListString', ModeCell, 'ListSize', [350 125]);
+
+if ~OKFlag
+ disp('Nothing done. Exiting setchromaticity.');
+ return
+else
+ fprintf('Using lattice: %s\n',ModeCell{ButtonName});
+end
+
+switch ButtonName
+ case 1
+ assr4_modbend;
+ fittunedisp2([13.29 5.216 0.096],'QFA','QDA','QFB',1);
+ case 2
+ setoperationalmode(8);
+ fittunedisp2([13.29 5.22 -0.5],'QFA','QDA','QFB',1);
+ case 3
+ setoperationalmode(9);
+ fittunedisp2([13.29 5.22 -0.75],'QFA','QDA','QFB',1);
+end
+
+global THERING
+sind(:,1) = findcells(THERING,'FamName','SFA');
+sind(:,2) = findcells(THERING,'FamName','SDA');
+% Hack just to make it a little neater, should not really affect the
+% results. there are 28 other family of sext but for SFB there are only 14.
+sind(:,3) = [findcells(THERING,'FamName','SFB') findcells(THERING,'FamName','SFB')];
+sind(:,4) = findcells(THERING,'FamName','SDB');
+% Set as close to storage ring settings as possible. These numbers 15.6 and
+% -16.6 etc. are taken from the machine using getsp(...,'physics'); So as
+% the machine energy is 1.4% less than the design of 3 GeV the values need
+% to be multiplied by 1.014 before putting it into the model (model is
+% assuming 3 GeV).
+THERING = setcellstruct(THERING,'PolynomB',sind(:,1),15.6*1.014,3);
+THERING = setcellstruct(THERING,'PolynomB',sind(:,2),-16.9*1.014,3);
+THERING = setcellstruct(THERING,'PolynomB',sind(:,3),7.67314*1.014,3);
+THERING = setcellstruct(THERING,'PolynomB',sind(:,4),-8.21721*1.014,3);
+fitchrom2([chromx chromy],'SFB','SDB');
+
+
+sfbind = findcells(THERING,'FamName','SFB');
+sdbind = findcells(THERING,'FamName','SDB');
+
+modelSFB = physics2hw('SFB','Setpoint',getcellstruct(THERING,'PolynomB',sfbind(1),3)/1.014);
+modelSDB = physics2hw('SDB','Setpoint',getcellstruct(THERING,'PolynomB',sdbind(1),3)/1.014);
+
+
+%Slowly ramp up to new setpoint
+curSFB = getsp('SFB',[1 1],'Online','Hardware');
+curSDB = getsp('SDB',[1 1],'Online','Hardware');
+for j=1:5
+ setsp('SFB',curSFB + (modelSFB - curSFB)*j/5,'Hardware','Online');
+ setsp('SDB',curSDB + (modelSDB - curSDB)*j/5,'Hardware','Online');
+ pause(0.2);
+end
+
+disp('Done. Chromaticity set.');
diff --git a/machine/ASP/StorageRing/setinjectionbump.m b/machine/ASP/StorageRing/setinjectionbump.m
index bc4d19a8..cb138056 100644
--- a/machine/ASP/StorageRing/setinjectionbump.m
+++ b/machine/ASP/StorageRing/setinjectionbump.m
@@ -1,6 +1,6 @@
-function setinjectionbump(injoffset,varargin)
+function varargout=setinjectionbump(injoffset,varargin)
%
-% SETINJECTIONBUMP(INJOFFSET,[angle]) will set the kickers to creates a local
+% SETINJECTIONBUMP(INJOFFSET,[angle in mrad]) will set the kickers to creates a local
% injection bump INJOFFSET mm from the beam axis. This uses the model to
% calculate the beam kicker response matrix in order to set the bumps. The
% angle is optional and defined in mradians.
@@ -18,17 +18,17 @@ function setinjectionbump(injoffset,varargin)
setcavity off;
-bpm = getam('BPMx',elem2dev('BPMx',[1 8:91 98]),'Struct');
+bpm = getam('BPMx',elem2dev('BPMx',[1 8:2:91 98]),'Struct');
bpm.Data(:) = 0;
bpmfamily = 'BPMx';
-bpmdevlist = elem2dev('BPMx',[1 8:91 98]);
+bpmdevlist = elem2dev('BPMx',[1 8:2:91 98]);
% BPMWeight = [1; ones(size(bpm.DeviceList,1)-2,1)*1; 1];
% Select "correctors".
cmfamily = 'KICK';
cmdevlist = getfamilydata('KICK','DeviceList');
cm = getsp('KICK','Struct','Online');
cm.Data(:) = 0;
-Niter = 1;
+Niter = 5;
SVDIndex = 'All';
% Calculate the offsets necessary at each bpm given the offset and angle
@@ -41,8 +41,8 @@ function setinjectionbump(injoffset,varargin)
% Distance between the BPMs in the in the injection straight.
L = 2.3041;
-injoffset_bpm01 = injoffset*1e-3 + L*sin(inangle*1e-3)
-injoffset_bpm98 = injoffset*1e-3 - L*sin(inangle*1e-3)
+injoffset_bpm01 = injoffset*1e-3 + L*sin(inangle*1e-3);
+injoffset_bpm98 = injoffset*1e-3 - L*sin(inangle*1e-3);
% if abs(injoffset) >= 10
% % Take in two steps
@@ -55,5 +55,18 @@ function setinjectionbump(injoffset,varargin)
cc = setorbit(goalorbit, bpm, cm, Niter, SVDIndex, 'ModelResp','ModelDisp','SetSP','Model');
% setsp(physics2hw(cc.CM),'Model');
% end
+data = physics2hw(cc.CM);
+
+if nargout == 0
+ fprintf('Setting Kicker in the model to:\n');
+ fprintf(' Kicker1=%f Volts\n Kicker2=%f Volts\n Kicker3=%f Volts\n Kicker4=%f Volts\n',...
+ data.Data');
+else
+ varargout{1} = data;
+end
+% setsp(data,'model');
+
+switch2hw
+switch2online
+
-% switch2online
diff --git a/machine/ASP/StorageRing/setinjkicks.m b/machine/ASP/StorageRing/setinjkicks.m
index 0c0b92fe..2bfab977 100644
--- a/machine/ASP/StorageRing/setinjkicks.m
+++ b/machine/ASP/StorageRing/setinjkicks.m
@@ -1,55 +1,56 @@
-function setinjkicks(xpos)
-% setinjkicks(xpos)
-%
-% Sets the strengths in the four injection kickers required
-% to make a closed bump in the injection straight
-%
-% xpos - amplitude of the parallel bump used for injection (meters)
-
-global THERING
-
-% read the kicks from file which have been calculated previously
-% IjectionKicks - 21x5 matrix col1=xpos (m) col2=kick1 (rad) col3=kick2
-% (rad) col4=kick3 (rad) col5=kick4 (rad)
-% load injection_kicks.mat InjectionKicks
-InjectionKicks = [...
- 0.00000000000000 0.00000000000000 0.00000000000000 0.00000000000000 0.00000000000000;
- -0.00100000000000 0.00014800000000 -0.00013052060116 -0.00013000000000 0.00014753369343;
- -0.00200000000000 0.00029600000000 -0.00026035436784 -0.00025900000000 0.00029477130201;
- -0.00300000000000 0.00044400000000 -0.00038949631871 -0.00038900000000 0.00044354400860;
- -0.00400000000000 0.00059000000000 -0.00051621109982 -0.00051500000000 0.00058887355431;
- -0.00500000000000 0.00073600000000 -0.00064224513240 -0.00064100000000 0.00073482774839;
- -0.00600000000000 0.00088100000000 -0.00076673956508 -0.00076600000000 0.00088029536904;
- -0.00700000000000 0.00102500000000 -0.00088970655856 -0.00088900000000 0.00102431889887;
- -0.00800000000000 0.00116800000000 -0.00101115901209 -0.00101000000000 0.00116686986828;
- -0.00900000000000 0.00131000000000 -0.00113111053835 -0.00113000000000 0.00130890487737;
- -0.01000000000000 0.00145200000000 -0.00125041333291 -0.00125000000000 0.00145158784082;
- -0.01100000000000 0.00159200000000 -0.00136740207938 -0.00136600000000 0.00159058670747;
- -0.01200000000000 0.00173200000000 -0.00148376374419 -0.00148300000000 0.00173122185276;
- -0.01300000000000 0.00187200000000 -0.00159950129343 -0.00159900000000 0.00187148382025;
- -0.01400000000000 0.00201000000000 -0.00171297835899 -0.00171200000000 0.00200898217080;
- -0.01500000000000 0.00214800000000 -0.00182585721434 -0.00182500000000 0.00214709907931;
- -0.01600000000000 0.00228500000000 -0.00193733166414 -0.00193600000000 0.00228358641690;
- -0.01700000000000 0.00242200000000 -0.00204822792023 -0.00204700000000 0.00242068362261;
- -0.01800000000000 0.00255800000000 -0.00215774973517 -0.00215700000000 0.00255718843470;
- -0.01900000000000 0.00269300000000 -0.00226591717537 -0.00226500000000 0.00269199772944;
- -0.02000000000000 0.00282700000000 -0.00237275076547 -0.00237200000000 0.00282617190946;
- -0.02100000000000 0.00296100000000 -0.00247906292307 -0.00247800000000 0.00295981679006;
- -0.02200000000000 0.00309500000000 -0.00258486374573 -0.00258400000000 0.00309402973700;
-];
-% find the kicks in InjectionKicks table
-row = find(InjectionKicks==xpos);
-
-if (isempty(row))
- disp('xpos not in lookup table (-22e-3 to -2e-3 in steps of 1e-3 m)')
- eval('help setinjkicks')
- return
-end
-
-% get the kick data for xpos
-for i = 1:4
- new_kicks(i) = InjectionKicks(row(1,1),i+1);
-end
-
-setsp('KICK', new_kicks');
-
+function setinjkicks(xpos)
+% setinjkicks(xpos)
+%
+% Sets the strengths in the four injection kickers required
+% to make a closed bump in the injection straight for the ideal lattice.
+% Default being 0.1 dispersion latttice (?)
+%
+% xpos - amplitude of the parallel bump used for injection (meters)
+
+global THERING
+
+% read the kicks from file which have been calculated previously
+% IjectionKicks - 21x5 matrix col1=xpos (m) col2=kick1 (rad) col3=kick2
+% (rad) col4=kick3 (rad) col5=kick4 (rad)
+% load injection_kicks.mat InjectionKicks
+InjectionKicks = [...
+ 0.00000000000000 0.00000000000000 0.00000000000000 0.00000000000000 0.00000000000000;
+ -0.00100000000000 0.00014800000000 -0.00013052060116 -0.00013000000000 0.00014753369343;
+ -0.00200000000000 0.00029600000000 -0.00026035436784 -0.00025900000000 0.00029477130201;
+ -0.00300000000000 0.00044400000000 -0.00038949631871 -0.00038900000000 0.00044354400860;
+ -0.00400000000000 0.00059000000000 -0.00051621109982 -0.00051500000000 0.00058887355431;
+ -0.00500000000000 0.00073600000000 -0.00064224513240 -0.00064100000000 0.00073482774839;
+ -0.00600000000000 0.00088100000000 -0.00076673956508 -0.00076600000000 0.00088029536904;
+ -0.00700000000000 0.00102500000000 -0.00088970655856 -0.00088900000000 0.00102431889887;
+ -0.00800000000000 0.00116800000000 -0.00101115901209 -0.00101000000000 0.00116686986828;
+ -0.00900000000000 0.00131000000000 -0.00113111053835 -0.00113000000000 0.00130890487737;
+ -0.01000000000000 0.00145200000000 -0.00125041333291 -0.00125000000000 0.00145158784082;
+ -0.01100000000000 0.00159200000000 -0.00136740207938 -0.00136600000000 0.00159058670747;
+ -0.01200000000000 0.00173200000000 -0.00148376374419 -0.00148300000000 0.00173122185276;
+ -0.01300000000000 0.00187200000000 -0.00159950129343 -0.00159900000000 0.00187148382025;
+ -0.01400000000000 0.00201000000000 -0.00171297835899 -0.00171200000000 0.00200898217080;
+ -0.01500000000000 0.00214800000000 -0.00182585721434 -0.00182500000000 0.00214709907931;
+ -0.01600000000000 0.00228500000000 -0.00193733166414 -0.00193600000000 0.00228358641690;
+ -0.01700000000000 0.00242200000000 -0.00204822792023 -0.00204700000000 0.00242068362261;
+ -0.01800000000000 0.00255800000000 -0.00215774973517 -0.00215700000000 0.00255718843470;
+ -0.01900000000000 0.00269300000000 -0.00226591717537 -0.00226500000000 0.00269199772944;
+ -0.02000000000000 0.00282700000000 -0.00237275076547 -0.00237200000000 0.00282617190946;
+ -0.02100000000000 0.00296100000000 -0.00247906292307 -0.00247800000000 0.00295981679006;
+ -0.02200000000000 0.00309500000000 -0.00258486374573 -0.00258400000000 0.00309402973700;
+];
+% find the kicks in InjectionKicks table
+row = find(InjectionKicks==xpos);
+
+if (isempty(row))
+ disp('xpos not in lookup table (-22e-3 to -2e-3 in steps of 1e-3 m)')
+ eval('help setinjkicks')
+ return
+end
+
+% get the kick data for xpos
+for i = 1:4
+ new_kicks(i) = InjectionKicks(row(1,1),i+1);
+end
+
+setsp('KICK', new_kicks');
+
diff --git a/machine/ASP/StorageRing/setkicker.m b/machine/ASP/StorageRing/setkicker.m
index ca236864..26539dd3 100644
--- a/machine/ASP/StorageRing/setkicker.m
+++ b/machine/ASP/StorageRing/setkicker.m
@@ -1,66 +1,63 @@
function varargout = setkicker(varargin)
+% SETKICKER('ON'/'OFF',[DeviceList])
+%
+% 15-05-2007 Eugene: Changed from original that used mca to just using
+% setpv and getpv.
+% 11-05-2010 Eugene: Updated and removed SEP and SEI control. Should not be
+% here.
+
if nargin > 0 && ischar(varargin{1})
cmd = varargin{1};
else
error('Usage : setkicker (on/off)');
end
+if nargin > 1 && isnumeric(varargin{2})
+ devlist = varargin{2};
+else
+ devlist = getlist('KICK');
+end
-pvname = {...
- 'SR14KPS01:OFF_ON_CMD';
- 'SR01KPS01:OFF_ON_CMD';
- 'SR01KPS02:OFF_ON_CMD';
- 'SR02KPS01:OFF_ON_CMD';};
+pvname = getfamilydata('KICK','Setpoint','ChannelNames',devlist);
+pvname = strrep(cellstr(pvname),'VOLTAGE_SP','OFF_ON_CMD');
-switch cmd
+% pvname = {...
+% 'SR14KPS01:OFF_ON_CMD';
+% 'SR01KPS01:OFF_ON_CMD';
+% 'SR01KPS02:OFF_ON_CMD';
+% 'SR02KPS01:OFF_ON_CMD';};
+
+switch lower(cmd)
case 'on'
- kval = 2;
+ kval = 2';
+ checkstr = 'off';
case 'off'
kval = 1;
+ checkstr = 'on';
otherwise
error(sprintf('Unknown option: %s',cmd));
end
-% Turn trigger off first before turning on or off the kickers
-trigh = mcaopen('SR00TRG01:INJ_TRIGGER_CMD');
-mcaput(trigh,2);
-% Turn off septum
-seph = mcaopen('PS-SEP-3:OFF_CMD');
-seih = mcaopen('PS-SEI-3:OFF_CMD');
-mcaput(seph,1); pause(0.2); mcaput(seph,0);
-mcaput(seih,1); pause(0.2); mcaput(seih,0);
-pause(0.2);
-mcaclose(seph);
-mcaclose(seih);
+if any(getsp('KICK',devlist) > 200)
+ % Turn trigger off first before turning on or off the kickers
+ oldtrigstate = getpv('TS01EVG01:INJECTION_TRIGGER_ENABLE_CMD');
+ setpv('TS01EVG01:INJECTION_TRIGGER_ENABLE_CMD',0); % 0 to stop and 1 to start
+ pause(2); % wait some time and to make sure that the trigger has stopped
+end
-pause(1.5);
-for i=1:length(pvname)
- hh = mcaopen(pvname{i});
- mcaput(hh,kval); % Doesn't always turn on the kicker at first attempt
- if (hh ~= kval) % but after three attempts its almost always going.
- mcaput(hh,kval);
- end
- if (hh ~= kval)
- mcaput(hh,kval);
- end
- if (hh ~= kval)
- mcaput(hh,kval);
- end
- if (hh ~= kval)
- mcaput(hh,kval);
- end
+try
+ setpv(pvname,kval);
pause(0.2);
- mcaclose(hh);
+ % check if any haven't been turned off/on and reapply the command.
+ % Should not need to do more than twice. 11-05-2010 Eugene
+ if any(strcmpi(lcaGet(strrep(cellstr(pvname),'OFF_ON_CMD','OFF_ON_STATUS')),checkstr))
+ setpv(pvname,kval);
+ end
+catch
+ return
end
-pause(1.5);
-% Turn on septum
-seph = mcaopen('PS-SEP-3:ON_CMD');
-seih = mcaopen('PS-SEI-3:ON_CMD');
-mcaput(seph,1); pause(0.2); mcaput(seph,0);
-mcaput(seih,1); pause(0.2); mcaput(seih,0);
-pause(0.2);
-mcaclose(seph);
-mcaclose(seih);
-pause(3);
-mcaput(trigh,1);
-mcaclose(trigh);
\ No newline at end of file
+
+if any(getsp('KICK',devlist) > 200)
+ pause(1);
+ setpv('TS01EVG01:INJECTION_TRIGGER_ENABLE_CMD',oldtrigstate);
+end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/setlocodata.m b/machine/ASP/StorageRing/setlocodata.m
index fdcd4fdf..f68a1a11 100644
--- a/machine/ASP/StorageRing/setlocodata.m
+++ b/machine/ASP/StorageRing/setlocodata.m
@@ -1,409 +1,410 @@
-function setlocodata(CommandInput, FileName)
-%SETLOCODATA - Applies the LOCO calibration data to both the middle layer & the accelerator
-% setlocodata(CommandInput, FileName)
-%
-% INPUTS
-% 1. CommandInput
-% 'Nominal' - Sets nominal gains (1) / rolls (0) to the model.
-% 'SetGains' - Set gains/coupling from a LOCO file.
-% 'Symmetrize' - Symmetry correction of the lattice based on a LOCO file.
-% 'CorrectCoupling' - Coupling correction of the lattice based on a LOCO file.
-% 'SetModel' - Set the model from a LOCO file. But it only changes
-% the part of the model that does not get corrected
-% in 'Symmetrize' (also does a SetGains).
-% 'LOCO2Model' - Set the model from a LOCO file (also does a 'SetGains').
-% This sets all lattice machines fit in the LOCO run to
-% the model.
-% 2. FileName - LOCO file name {Default: getfamilydata('OpsData', 'LOCOFile')}
-% '' to browse for a file
-%
-% NOTES
-% How one uses this function depends on how LOCO was setup.
-% 1. Use setlocodata('Nominal') if no model calibration information is known.
-% 2. The most typical situation is to apply:
-% setlocodata('Symmetrize') to the accelerator
-% setlocodata('SetModel') to the middle layer (usually done in setoperationalmode)
-% 3. If a LOCO run was done on the present lattice with no changes made to lattice
-% after LOCO run, then setting all the LOCO fits to the model makes sense.
-% setlocodata('LOCO2Model')
-% 4. This function obviously has machine dependent parts.
-%
-% Written by Greg Portmann
-
-
-global THERING
-
-if nargin < 1
- %CommandInput = 'Default';
- ModeCell = {'Nominal - Set Gain=1 & Rolls=0 in the model', 'SetGains - Set gains/rolls from a LOCO file','Symmetrize - Symmetry correction of the lattice', 'CorrectCoupling - Coupling correction of the lattice', 'SetModel - Set the model from a LOCO file','LOCO2Model - Set the model from a LOCO file (also does a SetGains)', 'see "help setlocodata" for more details'};
- [ModeNumber, OKFlag] = listdlg('Name','ASP','PromptString', ...
- 'Select the proper set LOCO data command:', ...
- 'SelectionMode','single', 'ListString', ModeCell, 'ListSize', [500 200]);
- if OKFlag ~= 1
- fprintf(' setlocodata cancelled\n');
- return
- end
- if ModeNumber == 1
- CommandInput = 'Nominal';
- elseif ModeNumber == 2
- CommandInput = 'SetGains';
- elseif ModeNumber == 3
- CommandInput = 'Symmetrize';
- elseif ModeNumber == 4
- CommandInput = 'CorrectCoupling';
- elseif ModeNumber == 5
- CommandInput = 'SetModel';
- elseif ModeNumber == 6
- CommandInput = 'LOCO2Model';
- elseif ModeNumber == 7
- help setlocodata;
- return
- end
-end
-
-if nargin < 2
- % Default (Golden) LOCO file
- % If empty, the user will be prompted if needed.
- FileName = getfamilydata('OpsData','LOCOFile');
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%
-% Initialize Defaults %
-%%%%%%%%%%%%%%%%%%%%%%%
-BPMxFamily = findmemberof('BPMx');
-if isempty(BPMxFamily)
- BPMxFamily = 'BPMx';
-else
- BPMxFamily = BPMxFamily{1};
-end
-
-BPMyFamily = findmemberof('BPMy');
-if isempty(BPMyFamily)
- BPMyFamily = 'BPMy';
-else
- BPMyFamily = BPMyFamily{1};
-end
-
-HCMFamily = findmemberof('HCM');
-if isempty(HCMFamily)
- HCMFamily = 'HCM';
-else
- HCMFamily = HCMFamily{1};
-end
-
-VCMFamily = findmemberof('VCM');
-if isempty(VCMFamily)
- VCMFamily = 'VCM';
-else
- VCMFamily = VCMFamily{1};
-end
-
-
-% Device list for the entire family
-BPMxDeviceListTotal = family2dev(BPMxFamily, 0);
-BPMyDeviceListTotal = family2dev(BPMyFamily, 0);
-HCMDeviceListTotal = family2dev(HCMFamily, 0);
-VCMDeviceListTotal = family2dev(VCMFamily, 0);
-
-% % Active devices
-% BPMxDeviceList = family2dev(BPMxFamily);
-% BPMyDeviceList = family2dev(BPMyFamily);
-% HCMDeviceList = family2dev(HCMFamily);
-% VCMDeviceList = family2dev(VCMFamily);
-
-
-if any(strcmpi(CommandInput, 'Nominal'))
- fprintf(' Using nominal BPM and corrector gains (1) and rolls (0).\n');
-
- % To speed things up, put Gains/Rolls/etc in the AO
- AO = getao;
-
- % Zero or one the gains and rolls
- AO.(BPMxFamily).Gain = ones(size(BPMxDeviceListTotal,1),1);
- AO.(BPMyFamily).Gain = ones(size(BPMyDeviceListTotal,1),1);
- AO.(BPMxFamily).Roll = zeros(size(BPMxDeviceListTotal,1),1);
- AO.(BPMyFamily).Roll = zeros(size(BPMyDeviceListTotal,1),1);
- AO.(BPMxFamily).Crunch = zeros(size(BPMxDeviceListTotal,1),1);
- AO.(BPMyFamily).Crunch = zeros(size(BPMyDeviceListTotal,1),1);
-
- % Set the gain, roll, & crunch to the AT model to be used by getpvmodel, setpvmodel, etc
- setatfield(BPMxFamily, 'GCR', [AO.(BPMxFamily).Gain AO.(BPMyFamily).Gain AO.(BPMxFamily).Crunch AO.(BPMxFamily).Roll], BPMxDeviceListTotal);
-
-
- % Corrector magnet gains/rolls
- AO.(HCMFamily).Gain = ones(size(HCMDeviceListTotal,1),1);
- AO.(VCMFamily).Gain = ones(size(VCMDeviceListTotal,1),1);
- AO.(HCMFamily).Roll = zeros(size(HCMDeviceListTotal,1),1);
- AO.(VCMFamily).Roll = zeros(size(VCMDeviceListTotal,1),1);
-
- % Set the AT model as well since they are used by getpvmodel, setpvmodel, etc
- % Make sure the Roll field is 1x2 even for single plane correctors
- % First set the cross planes to zero
- setatfield(HCMFamily, 'Roll', 0*AO.(HCMFamily).Roll, HCMDeviceListTotal, 1, 2);
- setatfield(VCMFamily, 'Roll', 0*AO.(VCMFamily).Roll, VCMDeviceListTotal, 1, 1);
-
- % Then set the roll field
- setatfield(HCMFamily, 'Roll', AO.(HCMFamily).Roll, HCMDeviceListTotal, 1, 1);
- setatfield(VCMFamily, 'Roll', AO.(VCMFamily).Roll, VCMDeviceListTotal, 1, 2);
-
-
- % Magnet gains set to unity (rolls are set in the AT model) (This is not really needed)
- AO.QFA.Gain = ones(size(family2dev('QFA',0),1),1);
- AO.QDA.Gain = ones(size(family2dev('QDA',0),1),1);
- AO.QFB.Gain = ones(size(family2dev('QFB',0),1),1);
-
- AO.SFA.Gain = ones(size(family2dev('SFA',0),1),1);
- AO.SFB.Gain = ones(size(family2dev('SFB',0),1),1);
- AO.SDA.Gain = ones(size(family2dev('SDA',0),1),1);
- AO.SDB.Gain = ones(size(family2dev('SDB',0),1),1);
-
- setao(AO);
-
-
-elseif any(strcmpi(CommandInput, 'SetGains'))
-
- if isempty(FileName) || strcmp(FileName, '.')
- if isempty(FileName)
- [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?', [getfamilydata('Directory','DataRoot'), 'LOCO', filesep]);
- else
- [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?');
- end
- drawnow;
- if FileName == 0
- fprintf(' setlocodata canceled\n');
- return
- end
- FileName = [DirectoryName FileName];
- end
-
- % Set the model gains
- setlocodata('Nominal');
-
- AO = getao;
-
- % Load the LOCO data
- fprintf(' Setting BPM and corrector gains and rolls based on %s.\n', FileName);
- load(FileName);
-
-
- % Get the device list from the LOCO file
- try
- BPMxDeviceList = LocoMeasData.HBPM.DeviceList;
- BPMyDeviceList = LocoMeasData.VBPM.DeviceList;
- HCMDeviceList = LocoMeasData.HCM.DeviceList;
- VCMDeviceList = LocoMeasData.VCM.DeviceList;
- catch
- % Legacy
- BPMxDeviceList = LocoMeasData.(BPMxFamily).DeviceList;
- BPMyDeviceList = LocoMeasData.(BPMyFamily).DeviceList;
- HCMDeviceList = LocoMeasData.(HCMFamily).DeviceList;
- VCMDeviceList = LocoMeasData.(VCMFamily).DeviceList;
- end
-
-
- % Change to Gain, Roll, Crunch system (Need to add a logic for single view BPMs???)
- i = findrowindex(BPMxDeviceList, BPMxDeviceListTotal);
- for j = 1:length(BPMData(end).HBPMGain)
- MLOCO = [BPMData(end).HBPMGain(j) BPMData(end).HBPMCoupling(j)
- BPMData(end).VBPMCoupling(j) BPMData(end).VBPMGain(j) ];
-
- [AO.(BPMxFamily).Gain(i(j),:), AO.(BPMyFamily).Gain(i(j),:), AO.(BPMxFamily).Crunch(i(j),:), AO.(BPMxFamily).Roll(i(j),:)] = loco2gcr(MLOCO);
- end
- AO.(BPMyFamily).Roll = AO.(BPMxFamily).Roll;
- AO.(BPMyFamily).Crunch = AO.(BPMxFamily).Crunch;
-
- if ~isreal(AO.(BPMxFamily).Gain)
- error('Horizontal BPM gain is complex.');
- end
- if ~isreal(AO.(BPMyFamily).Gain)
- error('Vertical BPM gain is complex.');
- end
- if ~isreal(AO.(BPMxFamily).Crunch)
- error('BPM Crunch is complex.');
- end
- if ~isreal(AO.(BPMxFamily).Roll)
- error('BPM roll is complex.');
- end
-
-
-
- %%%%%%%%%%%%%%
- % Correctors %
- %%%%%%%%%%%%%%
-
- % Kick strength (LOCO is in milliradian)
- % LOCO is run with the original gain in hw2physics (stored in LocoMeasData.VCMGain/LocoMeasData.HCMGain).
- % The new gain must combine the new CM gain and the one used in buildlocoinput.
- % hw2physics: Rad = G * amps (original)
- % LOCO gain: Gloco = KickNew/KickStart
- % New hw2physics gain: Gloco * G
-
- % HCM
- i = findrowindex(HCMDeviceList, HCMDeviceListTotal);
-
- HCMGainOldLOCO = LocoMeasData.HCMGain .* cos(LocoMeasData.HCMRoll);
- HCMGainLOCO = HCMGainOldLOCO .* CMData(end).HCMKicks ./ CMData(1).HCMKicks;
- HCMCouplingLOCO = HCMGainLOCO .* CMData(end).HCMCoupling;
-
- %AO.(HCMFamily).Roll(i) = atan2(-HCMCouplingLOCO, HCMGainLOCO);
- AO.(HCMFamily).Roll(i) = atan(HCMCouplingLOCO ./ abs(HCMGainLOCO));
- AO.(HCMFamily).Gain(i) = sign(HCMGainLOCO) .* sqrt(HCMCouplingLOCO.^2 + HCMGainLOCO.^2);
-
-
- % VCM
- i = findrowindex(VCMDeviceList, VCMDeviceListTotal);
-
- VCMGainOldLOCO = LocoMeasData.VCMGain .* cos(LocoMeasData.VCMRoll);
- VCMGainLOCO = VCMGainOldLOCO .* CMData(end).VCMKicks ./ CMData(1).VCMKicks;
- VCMCouplingLOCO = VCMGainLOCO .* CMData(end).VCMCoupling;
-
- %AO.(VCMFamily).Roll(i) = atan2(-VCMCouplingLOCO, VCMGainLOCO);
- AO.(VCMFamily).Roll(i) = atan(-VCMCouplingLOCO ./ abs(VCMGainLOCO));
- AO.(VCMFamily).Gain(i) = sign(VCMGainLOCO) .* sqrt(VCMCouplingLOCO.^2 + VCMGainLOCO.^2);
-
-
- % Set the roll, crunch to the AT model to be used by getpvmodel, setpvmodel, etc
- setatfield(BPMxFamily, 'GCR', [AO.(BPMxFamily).Gain AO.(BPMyFamily).Gain AO.(BPMxFamily).Crunch AO.(BPMxFamily).Roll], BPMxDeviceListTotal);
-
- % Set the gains to the AT model to be used by getpvmodel, setpvmodel, etc
- % Make sure the Roll field is 1x2 even for single plane correctors
-
- % First set the cross planes to zero
- setatfield(HCMFamily, 'Roll', 0*AO.(HCMFamily).Roll, HCMDeviceListTotal, 1, 2);
- setatfield(VCMFamily, 'Roll', 0*AO.(VCMFamily).Roll, VCMDeviceListTotal, 1, 1);
-
- % Then set the roll field
- setatfield(HCMFamily, 'Roll', AO.(HCMFamily).Roll, HCMDeviceListTotal, 1, 1);
- setatfield(VCMFamily, 'Roll', AO.(VCMFamily).Roll, VCMDeviceListTotal, 1, 2);
-
-
- % If other magnet fits were done (like roll), it should be add to the AT model as well
-
- setao(AO);
-
-
-elseif any(strcmpi(CommandInput, 'SetModel'))
-
- % Some LOCO errors are applied to the accelerator 'Symmetrize' and some
- % go to the model. If errors detected by LOCO are not applied to the accelerator,
- % then include them in the AT and Middle Layer model.
-
- error(' Option not programmed yet');
-
-
-elseif any(strcmpi(CommandInput, 'LOCO2Model'))
-
- % LOCO is usually used to correct the model. If the LOCO fit parameters are
- % not applied to the accelerator, then the entire model needs to be updated.
- % Ie, the machine lattice file is the same as it was when the LOCO data was
- % taken, then put the LOCO output settings in the model.
-
- if isempty(FileName) || strcmp(FileName, '.')
- if isempty(FileName)
- [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?', [getfamilydata('Directory','DataRoot'), 'LOCO', filesep]);
- else
- [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?');
- end
- drawnow;
- if FileName == 0
- fprintf(' setlocodata canceled\n');
- return
- end
- FileName = [DirectoryName FileName];
- end
-
-
- % Load the LOCO data
- load(FileName);
-
-
- % Use loco file for the lattice and the fit parameter
- % Using the loco lattice may not be what you want???
- global THERING
- %RINGData.Lattice = THERING;
- for i = 1:length(FitParameters(end).Params)
- RINGData = locosetlatticeparam(RINGData, FitParameters(end).Params{i}, FitParameters(end).Values(i));
- end
- THERING = RINGData.Lattice;
-
-
- % Since the lattice may have changed
- updateatindex;
-
-
- % Set the model gains (this added GCR field to lattice)
- setlocodata('SetGains', FileName);
-
-
-elseif any(strcmpi(CommandInput, 'CorrectCoupling'))
-
- if isempty(FileName) || strcmp(FileName, '.')
- if isempty(FileName)
- [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?', [getfamilydata('Directory','DataRoot'), 'LOCO', filesep]);
- else
- [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?');
- end
- drawnow;
- if FileName == 0
- fprintf(' setlocodata canceled\n');
- return
- end
- FileName = [DirectoryName FileName];
- end
-
-
-
- error(' Option not programmed yet');
-
-
-
- % Load the LOCO data
- load(FileName);
-
- fprintf(' Correcting the coupling based on LOCO file %s.\n', FileName);
-
- % Find the skew quadrupole fits ???????????
- if length(FitParameters(end).Values) < 83
- error('Did not find the skew quads fit parameters.');
- elseif length(FitParameters(end).Values) > 83
- fprintf(' There are more than 83 fit parameters, hopefully the skew quads fits are still 60:83\n');
- fprintf(' If all 24 skew quadrupoles were fit this function will fail!\n');
- end
-
- SQK = FitParameters(end).Values(60:70); % ??????????
-
- % Starting point for the skew quadrupoles
- MachineConfig = LocoMeasData.MachineConfig;
- setpv(MachineConfig.SQK.Setpoint);
-
- % Since the skew power supplies are wired backwards, just apply the fit directly
- SQSFhw = physics2hw('SQSF', 'Setpoint', SQSF);
-
- % Maximum setpoint check
- if any(abs(MachineConfig.SQK.Setpoint.Data+SQKhw)>maxsp('SQK'))
- error('At least one of the SQSF would go beyond it''s limit ... aborting');
- end
-
-
- % Make the setpoint change
- stepsp('SQK', SQKhw);
-
- % Keep the change?
- CorrectFlag = questdlg('Keep the new skew quadrupole setpoints or return to the old values?','SETLOCOGAINS(''SetCoupling'')','Keep this lattice','Restore Old Lattice','Keep this lattice');
- if strcmpi(CorrectFlag, 'Restore Old Lattice') | isempty(CorrectFlag)
- fprintf(' Changing the skew quadrupole magnets back to the original setpoints.\n');
- stepsp('SQK', -SQKhw);
- end
-
-
-elseif any(strcmpi(CommandInput, 'Symmetrize'))
-
- error(' Option not programmed yet');
-
-else
-
- error(' SETLOCODATA command not known.');
-
-end
-
+function setlocodata(CommandInput, FileName)
+%SETLOCODATA - Applies the LOCO calibration data to both the middle layer & the accelerator
+% setlocodata(CommandInput, FileName)
+%
+% INPUTS
+% 1. CommandInput
+% 'Nominal' - Sets nominal gains (1) / rolls (0) to the model.
+% 'SetGains' - Set gains/coupling from a LOCO file.
+% 'Symmetrize' - Symmetry correction of the lattice based on a LOCO file.
+% 'CorrectCoupling' - Coupling correction of the lattice based on a LOCO file.
+% 'SetModel' - Set the model from a LOCO file. But it only changes
+% the part of the model that does not get corrected
+% in 'Symmetrize' (also does a SetGains).
+% 'LOCO2Model' - Set the model from a LOCO file (also does a 'SetGains').
+% This sets all lattice machines fit in the LOCO run to
+% the model.
+% 2. FileName - LOCO file name {Default: getfamilydata('OpsData', 'LOCOFile')}
+% '' to browse for a file
+%
+% NOTES
+% How one uses this function depends on how LOCO was setup.
+% 1. Use setlocodata('Nominal') if no model calibration information is known.
+% 2. The most typical situation is to apply:
+% setlocodata('Symmetrize') to the accelerator
+% setlocodata('SetModel') to the middle layer (usually done in setoperationalmode)
+% 3. If a LOCO run was done on the present lattice with no changes made to lattice
+% after LOCO run, then setting all the LOCO fits to the model makes sense.
+% setlocodata('LOCO2Model')
+% 4. This function obviously has machine dependent parts.
+%
+% Written by Greg Portmann
+
+
+global THERING
+
+if nargin < 1
+ %CommandInput = 'Default';
+ ModeCell = {'Nominal - Set Gain=1 & Rolls=0 in the model', 'SetGains - Set gains/rolls from a LOCO file','Symmetrize - Symmetry correction of the lattice', 'CorrectCoupling - Coupling correction of the lattice', 'SetModel - Set the model from a LOCO file','LOCO2Model - Set the model from a LOCO file (also does a SetGains)', 'see "help setlocodata" for more details'};
+ [ModeNumber, OKFlag] = listdlg('Name','ASP','PromptString', ...
+ 'Select the proper set LOCO data command:', ...
+ 'SelectionMode','single', 'ListString', ModeCell, 'ListSize', [500 200]);
+ if OKFlag ~= 1
+ fprintf(' setlocodata cancelled\n');
+ return
+ end
+ if ModeNumber == 1
+ CommandInput = 'Nominal';
+ elseif ModeNumber == 2
+ CommandInput = 'SetGains';
+ elseif ModeNumber == 3
+ CommandInput = 'Symmetrize';
+ elseif ModeNumber == 4
+ CommandInput = 'CorrectCoupling';
+ elseif ModeNumber == 5
+ CommandInput = 'SetModel';
+ elseif ModeNumber == 6
+ CommandInput = 'LOCO2Model';
+ elseif ModeNumber == 7
+ help setlocodata;
+ return
+ end
+end
+
+if nargin < 2
+ % Default (Golden) LOCO file
+ % If empty, the user will be prompted if needed.
+ FileName = getfamilydata('OpsData','LOCOFile');
+end
+
+
+%%%%%%%%%%%%%%%%%%%%%%%
+% Initialize Defaults %
+%%%%%%%%%%%%%%%%%%%%%%%
+BPMxFamily = findmemberof('BPMx');
+if isempty(BPMxFamily)
+ BPMxFamily = 'BPMx';
+else
+ BPMxFamily = BPMxFamily{1};
+end
+
+BPMyFamily = findmemberof('BPMy');
+if isempty(BPMyFamily)
+ BPMyFamily = 'BPMy';
+else
+ BPMyFamily = BPMyFamily{1};
+end
+
+HCMFamily = findmemberof('HCM');
+if isempty(HCMFamily)
+ HCMFamily = 'HCM';
+else
+ HCMFamily = HCMFamily{1};
+end
+
+VCMFamily = findmemberof('VCM');
+if isempty(VCMFamily)
+ VCMFamily = 'VCM';
+else
+ VCMFamily = VCMFamily{1};
+end
+
+
+% Device list for the entire family
+BPMxDeviceListTotal = family2dev(BPMxFamily, 0);
+BPMyDeviceListTotal = family2dev(BPMyFamily, 0);
+HCMDeviceListTotal = family2dev(HCMFamily, 0);
+VCMDeviceListTotal = family2dev(VCMFamily, 0);
+
+% % Active devices
+% BPMxDeviceList = family2dev(BPMxFamily);
+% BPMyDeviceList = family2dev(BPMyFamily);
+% HCMDeviceList = family2dev(HCMFamily);
+% VCMDeviceList = family2dev(VCMFamily);
+
+
+if any(strcmpi(CommandInput, 'Nominal'))
+ fprintf(' Using nominal BPM and corrector gains (1) and rolls (0).\n');
+ disp('NOMINAL')
+
+ % To speed things up, put Gains/Rolls/etc in the AO
+ AO = getao;
+
+ % Zero or one the gains and rolls
+ AO.(BPMxFamily).Gain = ones(size(BPMxDeviceListTotal,1),1);
+ AO.(BPMyFamily).Gain = ones(size(BPMyDeviceListTotal,1),1);
+ AO.(BPMxFamily).Roll = zeros(size(BPMxDeviceListTotal,1),1);
+ AO.(BPMyFamily).Roll = zeros(size(BPMyDeviceListTotal,1),1);
+ AO.(BPMxFamily).Crunch = zeros(size(BPMxDeviceListTotal,1),1);
+ AO.(BPMyFamily).Crunch = zeros(size(BPMyDeviceListTotal,1),1);
+
+ % Set the gain, roll, & crunch to the AT model to be used by getpvmodel, setpvmodel, etc
+ setatfield(BPMxFamily, 'GCR', [AO.(BPMxFamily).Gain AO.(BPMyFamily).Gain AO.(BPMxFamily).Crunch AO.(BPMxFamily).Roll], BPMxDeviceListTotal);
+
+
+ % Corrector magnet gains/rolls
+ AO.(HCMFamily).Gain = ones(size(HCMDeviceListTotal,1),1);
+ AO.(VCMFamily).Gain = ones(size(VCMDeviceListTotal,1),1);
+ AO.(HCMFamily).Roll = zeros(size(HCMDeviceListTotal,1),1);
+ AO.(VCMFamily).Roll = zeros(size(VCMDeviceListTotal,1),1);
+
+ % Set the AT model as well since they are used by getpvmodel, setpvmodel, etc
+ % Make sure the Roll field is 1x2 even for single plane correctors
+ % First set the cross planes to zero
+ setatfield(HCMFamily, 'Roll', 0*AO.(HCMFamily).Roll, HCMDeviceListTotal, 1, 2);
+ setatfield(VCMFamily, 'Roll', 0*AO.(VCMFamily).Roll, VCMDeviceListTotal, 1, 1);
+
+ % Then set the roll field
+ setatfield(HCMFamily, 'Roll', AO.(HCMFamily).Roll, HCMDeviceListTotal, 1, 1);
+ setatfield(VCMFamily, 'Roll', AO.(VCMFamily).Roll, VCMDeviceListTotal, 1, 2);
+
+
+ % Magnet gains set to unity (rolls are set in the AT model) (This is not really needed)
+ AO.QFA.Gain = ones(size(family2dev('QFA',0),1),1);
+ AO.QDA.Gain = ones(size(family2dev('QDA',0),1),1);
+ AO.QFB.Gain = ones(size(family2dev('QFB',0),1),1);
+
+ AO.SFA.Gain = ones(size(family2dev('SFA',0),1),1);
+ AO.SFB.Gain = ones(size(family2dev('SFB',0),1),1);
+ AO.SDA.Gain = ones(size(family2dev('SDA',0),1),1);
+ AO.SDB.Gain = ones(size(family2dev('SDB',0),1),1);
+
+ setao(AO);
+
+
+elseif any(strcmpi(CommandInput, 'SetGains'))
+
+ if isempty(FileName) || strcmp(FileName, '.')
+ if isempty(FileName)
+ [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?', [getfamilydata('Directory','DataRoot'), 'LOCO', filesep]);
+ else
+ [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?');
+ end
+ drawnow;
+ if FileName == 0
+ fprintf(' setlocodata canceled\n');
+ return
+ end
+ FileName = [DirectoryName FileName];
+ end
+
+ % Set the model gains
+ setlocodata('Nominal');
+
+ AO = getao;
+
+ % Load the LOCO data
+ fprintf(' Setting BPM and corrector gains and rolls based on %s.\n', FileName);
+ load(FileName);
+
+
+ % Get the device list from the LOCO file
+ try
+ BPMxDeviceList = LocoMeasData.HBPM.DeviceList;
+ BPMyDeviceList = LocoMeasData.VBPM.DeviceList;
+ HCMDeviceList = LocoMeasData.HCM.DeviceList;
+ VCMDeviceList = LocoMeasData.VCM.DeviceList;
+ catch
+ % Legacy
+ BPMxDeviceList = LocoMeasData.(BPMxFamily).DeviceList;
+ BPMyDeviceList = LocoMeasData.(BPMyFamily).DeviceList;
+ HCMDeviceList = LocoMeasData.(HCMFamily).DeviceList;
+ VCMDeviceList = LocoMeasData.(VCMFamily).DeviceList;
+ end
+
+
+ % Change to Gain, Roll, Crunch system (Need to add a logic for single view BPMs???)
+ i = findrowindex(BPMxDeviceList, BPMxDeviceListTotal);
+ for j = 1:length(BPMData(end).HBPMGain)
+ MLOCO = [BPMData(end).HBPMGain(j) BPMData(end).HBPMCoupling(j)
+ BPMData(end).VBPMCoupling(j) BPMData(end).VBPMGain(j) ];
+
+ [AO.(BPMxFamily).Gain(i(j),:), AO.(BPMyFamily).Gain(i(j),:), AO.(BPMxFamily).Crunch(i(j),:), AO.(BPMxFamily).Roll(i(j),:)] = loco2gcr(MLOCO);
+ end
+ AO.(BPMyFamily).Roll = AO.(BPMxFamily).Roll;
+ AO.(BPMyFamily).Crunch = AO.(BPMxFamily).Crunch;
+
+ if ~isreal(AO.(BPMxFamily).Gain)
+ error('Horizontal BPM gain is complex.');
+ end
+ if ~isreal(AO.(BPMyFamily).Gain)
+ error('Vertical BPM gain is complex.');
+ end
+ if ~isreal(AO.(BPMxFamily).Crunch)
+ error('BPM Crunch is complex.');
+ end
+ if ~isreal(AO.(BPMxFamily).Roll)
+ error('BPM roll is complex.');
+ end
+
+
+
+ %%%%%%%%%%%%%%
+ % Correctors %
+ %%%%%%%%%%%%%%
+
+ % Kick strength (LOCO is in milliradian)
+ % LOCO is run with the original gain in hw2physics (stored in LocoMeasData.VCMGain/LocoMeasData.HCMGain).
+ % The new gain must combine the new CM gain and the one used in buildlocoinput.
+ % hw2physics: Rad = G * amps (original)
+ % LOCO gain: Gloco = KickNew/KickStart
+ % New hw2physics gain: Gloco * G
+
+ % HCM
+ i = findrowindex(HCMDeviceList, HCMDeviceListTotal);
+
+ HCMGainOldLOCO = LocoMeasData.HCMGain .* cos(LocoMeasData.HCMRoll);
+ HCMGainLOCO = HCMGainOldLOCO .* CMData(end).HCMKicks ./ CMData(1).HCMKicks;
+ HCMCouplingLOCO = HCMGainLOCO .* CMData(end).HCMCoupling;
+
+ %AO.(HCMFamily).Roll(i) = atan2(-HCMCouplingLOCO, HCMGainLOCO);
+ AO.(HCMFamily).Roll(i) = atan(HCMCouplingLOCO ./ abs(HCMGainLOCO));
+ AO.(HCMFamily).Gain(i) = sign(HCMGainLOCO) .* sqrt(HCMCouplingLOCO.^2 + HCMGainLOCO.^2);
+
+
+ % VCM
+ i = findrowindex(VCMDeviceList, VCMDeviceListTotal);
+
+ VCMGainOldLOCO = LocoMeasData.VCMGain .* cos(LocoMeasData.VCMRoll);
+ VCMGainLOCO = VCMGainOldLOCO .* CMData(end).VCMKicks ./ CMData(1).VCMKicks;
+ VCMCouplingLOCO = VCMGainLOCO .* CMData(end).VCMCoupling;
+
+ %AO.(VCMFamily).Roll(i) = atan2(-VCMCouplingLOCO, VCMGainLOCO);
+ AO.(VCMFamily).Roll(i) = atan(-VCMCouplingLOCO ./ abs(VCMGainLOCO));
+ AO.(VCMFamily).Gain(i) = sign(VCMGainLOCO) .* sqrt(VCMCouplingLOCO.^2 + VCMGainLOCO.^2);
+
+
+ % Set the roll, crunch to the AT model to be used by getpvmodel, setpvmodel, etc
+ setatfield(BPMxFamily, 'GCR', [AO.(BPMxFamily).Gain AO.(BPMyFamily).Gain AO.(BPMxFamily).Crunch AO.(BPMxFamily).Roll], BPMxDeviceListTotal);
+
+ % Set the gains to the AT model to be used by getpvmodel, setpvmodel, etc
+ % Make sure the Roll field is 1x2 even for single plane correctors
+
+ % First set the cross planes to zero
+ setatfield(HCMFamily, 'Roll', 0*AO.(HCMFamily).Roll, HCMDeviceListTotal, 1, 2);
+ setatfield(VCMFamily, 'Roll', 0*AO.(VCMFamily).Roll, VCMDeviceListTotal, 1, 1);
+
+ % Then set the roll field
+ setatfield(HCMFamily, 'Roll', AO.(HCMFamily).Roll, HCMDeviceListTotal, 1, 1);
+ setatfield(VCMFamily, 'Roll', AO.(VCMFamily).Roll, VCMDeviceListTotal, 1, 2);
+
+
+ % If other magnet fits were done (like roll), it should be add to the AT model as well
+
+ setao(AO);
+
+
+elseif any(strcmpi(CommandInput, 'SetModel'))
+
+ % Some LOCO errors are applied to the accelerator 'Symmetrize' and some
+ % go to the model. If errors detected by LOCO are not applied to the accelerator,
+ % then include them in the AT and Middle Layer model.
+
+ error(' Option not programmed yet');
+
+
+elseif any(strcmpi(CommandInput, 'LOCO2Model'))
+
+ % LOCO is usually used to correct the model. If the LOCO fit parameters are
+ % not applied to the accelerator, then the entire model needs to be updated.
+ % Ie, the machine lattice file is the same as it was when the LOCO data was
+ % taken, then put the LOCO output settings in the model.
+
+ if isempty(FileName) || strcmp(FileName, '.')
+ if isempty(FileName)
+ [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?', [getfamilydata('Directory','DataRoot'), 'LOCO', filesep]);
+ else
+ [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?');
+ end
+ drawnow;
+ if FileName == 0
+ fprintf(' setlocodata canceled\n');
+ return
+ end
+ FileName = [DirectoryName FileName];
+ end
+
+
+ % Load the LOCO data
+ load(FileName);
+
+
+ % Use loco file for the lattice and the fit parameter
+ % Using the loco lattice may not be what you want???
+ global THERING
+ %RINGData.Lattice = THERING;
+ for i = 1:length(FitParameters(end).Params)
+ RINGData = locosetlatticeparam(RINGData, FitParameters(end).Params{i}, FitParameters(end).Values(i));
+ end
+ THERING = RINGData.Lattice;
+
+
+ % Since the lattice may have changed
+ updateatindex;
+
+
+ % Set the model gains (this added GCR field to lattice)
+ setlocodata('SetGains', FileName);
+
+
+elseif any(strcmpi(CommandInput, 'CorrectCoupling'))
+
+ if isempty(FileName) || strcmp(FileName, '.')
+ if isempty(FileName)
+ [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?', [getfamilydata('Directory','DataRoot'), 'LOCO', filesep]);
+ else
+ [FileName, DirectoryName] = uigetfile('*.mat', 'LOCO Output File Name?');
+ end
+ drawnow;
+ if FileName == 0
+ fprintf(' setlocodata canceled\n');
+ return
+ end
+ FileName = [DirectoryName FileName];
+ end
+
+
+
+ error(' Option not programmed yet');
+
+
+
+ % Load the LOCO data
+ load(FileName);
+
+ fprintf(' Correcting the coupling based on LOCO file %s.\n', FileName);
+
+ % Find the skew quadrupole fits ???????????
+ if length(FitParameters(end).Values) < 83
+ error('Did not find the skew quads fit parameters.');
+ elseif length(FitParameters(end).Values) > 83
+ fprintf(' There are more than 83 fit parameters, hopefully the skew quads fits are still 60:83\n');
+ fprintf(' If all 24 skew quadrupoles were fit this function will fail!\n');
+ end
+
+ SQK = FitParameters(end).Values(60:70); % ??????????
+
+ % Starting point for the skew quadrupoles
+ MachineConfig = LocoMeasData.MachineConfig;
+ setpv(MachineConfig.SQK.Setpoint);
+
+ % Since the skew power supplies are wired backwards, just apply the fit directly
+ SQSFhw = physics2hw('SQSF', 'Setpoint', SQSF);
+
+ % Maximum setpoint check
+ if any(abs(MachineConfig.SQK.Setpoint.Data+SQKhw)>maxsp('SQK'))
+ error('At least one of the SQSF would go beyond it''s limit ... aborting');
+ end
+
+
+ % Make the setpoint change
+ stepsp('SQK', SQKhw);
+
+ % Keep the change?
+ CorrectFlag = questdlg('Keep the new skew quadrupole setpoints or return to the old values?','SETLOCOGAINS(''SetCoupling'')','Keep this lattice','Restore Old Lattice','Keep this lattice');
+ if strcmpi(CorrectFlag, 'Restore Old Lattice') | isempty(CorrectFlag)
+ fprintf(' Changing the skew quadrupole magnets back to the original setpoints.\n');
+ stepsp('SQK', -SQKhw);
+ end
+
+
+elseif any(strcmpi(CommandInput, 'Symmetrize'))
+
+ error(' Option not programmed yet');
+
+else
+
+ error(' SETLOCODATA command not known.');
+
+end
+
diff --git a/machine/ASP/StorageRing/setmachineconfig.m b/machine/ASP/StorageRing/setmachineconfig.m
new file mode 100644
index 00000000..7d9dd546
--- /dev/null
+++ b/machine/ASP/StorageRing/setmachineconfig.m
@@ -0,0 +1,253 @@
+function [ConfigSetpoint, FileName] = setmachineconfig(varargin)
+%SETMACHINECONFIG - Sets the storage ring setpoints from a file or configuratino data structure
+% [ConfigSetpoint, FileName] = setmachineconfig(FamilyName, FileName, WaitFlag, ExtraInputs ...)
+% [ConfigSetpoint, FileName] = setmachineconfig(FileName, WaitFlag, ExtraInputs ...)
+% [ConfigSetpoint, FileName] = setmachineconfig(ConfigSetpoint, WaitFlag, ExtraInputs ...)
+%
+% INPUTS
+% 1. FamilyName - Name of family/families to set (string, string matrix, cell array of families)
+% {Default: all families (as returned by getfamilylist)}
+% 2. FileName - File name to get setpoint data (if necessary, include full path)
+% 'Production' or 'Golden' will get the lattice from the "golden lattice" which stored in
+% 'Injection' will get the injection lattice stored in
+% {Default: browse for the desired file}
+% or
+% ConfigSetpoint - A configuration structure as returned by getmachineconfig can also be used.
+% 3. WaitFlag - {optional} (see getpv for details)
+% 4. ExtraInputs - Extra inputs get passed to setpv (like 'Online', 'Simulator', 'Display')
+% See >> help setpv for more details
+%
+% OUTPUTS
+% 1. ConfigSetpoint - structure of setpoint structures
+% each field being a family
+% 2. FileName - filename where the data came from (if the data came from a file)
+%
+% EXAMPLES
+% 1. To browse for a configuration to set:
+% >> setmachineconfig;
+% 2. To set to golden configuration:
+% >> setmachineconfig('Golden');
+% 3. To only restore the HCM and VCM corrector families from the golden lattice:
+% >> setmachineconfig('HCM', 'Golden');
+% or
+% >> setmachineconfig({'HCM','VCM'}, 'Golden');
+%
+% See also getmachineconfig
+%
+% Written by Greg Portmann
+
+
+WaitFlag = -1;
+FamilyName = [];
+FileName = '';
+DisplayFlag = 0;
+ConfigSetpoint = [];
+
+
+% Look for keywords on the input line
+InputFlags = {};
+for i = length(varargin):-1:1
+ if isstruct(varargin{i})
+ % Ignor structures
+ elseif iscell(varargin{i})
+ % Ignor cells
+ elseif strcmpi(varargin{i},'struct')
+ % Remove
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'numeric')
+ % Remove
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'Display')
+ DisplayFlag = 1;
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'NoDisplay')
+ DisplayFlag = 0;
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'simulator') | strcmpi(varargin{i},'model')
+ InputFlags = [InputFlags varargin(i)];
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'Online')
+ InputFlags = [InputFlags varargin(i)];
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'Manual')
+ InputFlags = [InputFlags varargin(i)];
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'physics')
+ InputFlags = [InputFlags varargin(i)];
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'hardware')
+ InputFlags = [InputFlags varargin(i)];
+ varargin(i) = [];
+ end
+end
+
+if length(varargin) >= 1
+ if iscell(varargin{1})
+ FamilyName = varargin{1};
+ varargin(1) = [];
+ elseif size(varargin{1},1) > 1 & ischar(varargin{1})
+ FamilyName = varargin{1};
+ varargin(1) = [];
+ elseif isstruct(varargin{1})
+ ConfigSetpoint = varargin{1};
+ varargin(1) = [];
+ elseif isfamily(varargin{1})
+ FamilyName = varargin{1};
+ varargin(1) = [];
+ elseif ischar(varargin{1})
+ FileName = varargin{1};
+ varargin(1) = [];
+ end
+end
+% if length(varargin) >= 1
+% if iscell(varargin{1})
+% FamilyName = varargin{1};
+% varargin(1) = [];
+% elseif size(varargin{1},1) > 1 & ischar(varargin{1})
+% FamilyName = varargin{1};
+% varargin(1) = [];
+% elseif isfamily(varargin{1})
+% FamilyName = varargin{1};
+% varargin(1) = [];
+% elseif isstruct(varargin{1})
+% ConfigSetpoint = varargin{1};
+% varargin(1) = [];
+% elseif ischar(varargin{1})
+% FileName = varargin{1};
+% varargin(1) = [];
+% end
+% end
+
+% WaitFlag
+if length(varargin) >= 1
+ if isnumeric(varargin{1})
+ WaitFlag = varargin{1};
+ varargin(1) = [];
+ end
+end
+
+
+% Get config structure
+if isempty(ConfigSetpoint)
+ AskStartQuestion = 1;
+ try
+ if isempty(FileName)
+ % Default file
+ %FileName = getfamilydata('Default', 'CNFArchiveFile');
+ DirectoryName = getfamilydata('Directory', 'ConfigData');
+ [FileName, DirectoryName] = uigetfile('*.mat', 'Select a configuration file to load', DirectoryName);
+ if FileName == 0
+ fprintf(' No change to lattice (setmachineconfig)\n');
+ return
+ end
+ load([DirectoryName FileName]);
+ FileName = [DirectoryName FileName];
+ AskStartQuestion = 0;
+ elseif any(strcmpi(FileName, {'Golden','Production'}))
+ FileName = getfamilydata('OpsData', 'LatticeFile');
+ DirectoryName = getfamilydata('Directory', 'OpsData');
+ load([DirectoryName FileName]);
+ FileName = [DirectoryName FileName];
+ elseif strcmpi(FileName, 'Injection')
+ FileName = getfamilydata('OpsData', 'InjectionFile');
+ DirectoryName = getfamilydata('Directory', 'OpsData');
+ load([DirectoryName FileName]);
+ FileName = [DirectoryName FileName];
+ else
+ % Input file name
+ load(FileName);
+ end
+ catch
+ fprintf('%s\n', lasterr)
+ fprintf('No change made to lattice (setmachineconfig)\n');
+ return
+ end
+
+ % Query to begin measurement
+ if DisplayFlag & ~isempty(FileName) & AskStartQuestion
+ tmp = questdlg(sprintf('Change the lattice to %s?', FileName),'setmachineconfig','Yes','No','No');
+ if ~strcmpi(tmp,'Yes')
+ fprintf(' No change made to lattice (setmachineconfig)\n');
+ return
+ end
+ end
+end
+
+
+if isempty(FamilyName)
+ FieldNameCell = fieldnames(ConfigSetpoint);
+elseif iscell(FamilyName)
+ FieldNameCell = FamilyName;
+elseif size(FamilyName,1) > 1
+ for i = 1:size(FamilyName,1)
+ FieldNameCell{i} = FamilyName(i,:);
+ end
+else
+ FieldNameCell = {FamilyName};
+end
+
+
+% Build the cell array
+j = 0;
+for i = 1:length(FieldNameCell)
+ FieldNameCell{i} = deblank(FieldNameCell{i});
+ if isfield(ConfigSetpoint, FieldNameCell{i})
+ if isfield(ConfigSetpoint.(FieldNameCell{i}),'Data') & isfield(ConfigSetpoint.(FieldNameCell{i}),'FamilyName')
+ j = j + 1;
+ SPcell{j} = ConfigSetpoint.(FieldNameCell{i});
+ else
+ % Find all the subfields that are data structures
+ SubFieldNameCell = fieldnames(ConfigSetpoint.(FieldNameCell{i}));
+ for ii = 1:length(SubFieldNameCell)
+ if isfield(ConfigSetpoint.(FieldNameCell{i}).(SubFieldNameCell{ii}),'Data') & isfield(ConfigSetpoint.(FieldNameCell{i}).(SubFieldNameCell{ii}),'FamilyName')
+ j = j + 1;
+ SPcell{j} = ConfigSetpoint.(FieldNameCell{i}).(SubFieldNameCell{ii});
+ end
+ end
+ end
+ else
+ fprintf(' %s field does not exist for family, hence ignored (setmachineconfig)\n', deblank(FieldNameCell{i}));
+ end
+end
+
+
+% Make the setpoint change w/o a WaitFlag
+for k = 1:length(SPcell)
+ try
+ if DisplayFlag
+ Time = clock;
+ %fprintf(' Setting family %s (%s %d:%d:%.2f)\n', SPcell{k}.FamilyName, datestr(clock,1), Time(4), Time(5), Time(6));
+ fprintf(' %s %d:%d:%.2f Setting family %s.%s\n', datestr(clock,1), Time(4), Time(5), Time(6), SPcell{k}.FamilyName, SPcell{k}.Field);
+ drawnow;
+ end
+ setpv(SPcell{k}, 0, InputFlags{:});
+ catch
+ fprintf('%s\n', lasterr)
+ fprintf('Trouble with setsp(''%s'',''%s''), hence ignored (setmachineconfig)\n', SPcell{k}.FamilyName, SPcell{k}.Field);
+ end
+end
+
+
+% Make the setpoint change with a WaitFlag
+if WaitFlag ~= 0
+ try
+ if DisplayFlag
+ fprintf(' Waiting for Setpoint-Monitor to be within tolerance\n');
+ drawnow;
+ end
+ for k = 1:length(SPcell)
+ try
+ setpv(SPcell{k}, WaitFlag, InputFlags{:});
+ end
+ end
+ if DisplayFlag
+ Time = clock;
+ fprintf(' %s %d:%d:%.2f Lattice change complete (setmachineconfig)\n\n', datestr(clock,1), Time(4), Time(5), Time(6));
+ drawnow;
+ end
+ catch
+ fprintf('%s\n', lasterr)
+ fprintf('Error occurred waiting for Setpoint-Monitor comparison.\n');
+ fprintf('Lattice is in an unknown state! (setmachineconfig)\n\n');
+ end
+end
diff --git a/machine/ASP/StorageRing/setoperationalmode.m b/machine/ASP/StorageRing/setoperationalmode.m
index 8af9894d..878ff7ed 100644
--- a/machine/ASP/StorageRing/setoperationalmode.m
+++ b/machine/ASP/StorageRing/setoperationalmode.m
@@ -1,324 +1,843 @@
-function setoperationalmode(ModeNumber)
-%SETOPERATIONALMODE - Set all the variables associated with an operational mode
-% setoperationalmode(ModeNumber)
-%
-% ModeNumber = 1. 3.0 GeV, User Mode
-% 2. 3.0 GeV, User Mode with Split Bend in the model
-% 3. 3.0 GeV, Model
-%
-% See also aoinit, updateatindex
-
-global THERING
-
-
-% Check if the AO exists
-checkforao;
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Accelerator Dependent Modes %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-if nargin < 1
- ModeCell = {'Commissioning Mode','User Mode', 'Model', 'Test'};
- [ModeNumber, OKFlag] = listdlg('Name','ASP','PromptString','Select the Operational Mode:', 'SelectionMode','single', 'ListString', ModeCell);
- if OKFlag ~= 1
- fprintf(' Operational mode not changed\n');
- return
- end
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Accelerator Data Structure %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-AD = getad;
-AD.Machine = 'ASP'; % Will already be defined if setpathmml was used
-AD.SubMachine = 'StorageRing'; % Will already be defined if setpathmml was used
-AD.OperationalMode = ''; % Gets filled in later
-AD.Energy = 3.0;
-AD.InjectionEnergy = 3.0;
-AD.HarmonicNumber = 360;
-
-
-% Defaults RF for disperion and chromaticity measurements (must be in Hardware units) ???
-AD.DeltaRFDisp = 2000/4;
-AD.DeltaRFChro = [-2000 -1000 0 1000 2000]/2;
-AD.DeltaRFChro = [0:-500:-4000 -3500:500:0 500:500:4000 3500:-500:0];
-
-
-% SP-AM Error level
-% AD.ErrorWarningLevel = 0 -> SP-AM errors are Matlab errors {Default}
-% -1 -> SP-AM errors are Matlab warnings
-% -2 -> SP-AM errors prompt a dialog box
-% -3 -> SP-AM errors are ignored (ErrorFlag=-1 is returned)
-AD.ErrorWarningLevel = 0;
-
-
-%%%%%%%%%%%%%%%%%%%%%
-% Operational Modes %
-%%%%%%%%%%%%%%%%%%%%%
-
-% Mode setup variables (mostly path and file names)
-% AD.OperationalMode - String used in titles
-% MachineName - String used to build directory structure off DataRoot
-% ModeName - String used for mode directory name off DataRoot/MachineName
-% OpsFileExtension - string add to default file names
-MachineName = 'asp';
-if ModeNumber == 1
- % User mode
- AD.OperationalMode = '3.0 GeV, Prelim Commissioning Mode';
- ModeName = 'Comm';
- OpsFileExtension = '_Comm';
-
- % AT lattice
-% AD.ATModel = 'aspsr_msrf1cav';
-% aspsr_msrf1cav;
- AD.ATModel = 'assr4_splitbends';
- assr4_splitbends cavity4ring;
-
- % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
- AO = getao;
- AO.TUNE.Monitor.Golden = [
- 0.290
- 0.216
- NaN];
- setao(AO);
-
- % Golden chromaticity is in the AD (Physics units)
- AD.Chromaticity.Golden = [1; 1]; % ???
-
- % Tune processor delay: delay required to wait
- % to have a fresh tune measurement after changing
- % a variable like the RF frequency. Setpv will wait
- % 2.2 * TuneDelay to be guaranteed a fresh data point.
- AD.TuneDelay = 2.5;
-
- switch2online;
-% switch2sim;
- switch2hw;
-
-elseif ModeNumber == 2
-
- % User mode - Distributed Dispersion
- AD.OperationalMode = '3.0 GeV, Prelim User Mode';
- ModeName = 'CommUser';
- OpsFileExtension = '_CommUser';
-
- % AT lattice
-% AD.ATModel = 'aspsr_msrf1cav';
-% aspsr_msrf1cav;
- AD.ATModel = 'assr4_disp';
- assr4_disp cavity4ring;
-
- % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
- AO = getao;
- AO.TUNE.Monitor.Golden = [
- 0.290
- 0.216
- NaN];
- setao(AO);
-
- % Golden chromaticity is in the AD (Physics units)
- AD.Chromaticity.Golden = [1; 1]; % ???
-
- % Tune processor delay: delay required to wait
- % to have a fresh tune measurement after changing
- % a variable like the RF frequency. Setpv will wait
- % 2.2 * TuneDelay to be guaranteed a fresh data point.
- AD.TuneDelay = 2.5;
-
- switch2online;
-% switch2sim;
- switch2hw;
-
-
-elseif ModeNumber == 3
- % Model mode
- AD.OperationalMode = '3.0 GeV, Model';
- ModeName = 'Model';
- OpsFileExtension = '';
-
- % AT lattice
-% AD.ATModel = 'aspsr_msrf1cav';
-% aspsr_msrf1cav;
- AD.ATModel = 'assr4';
- assr4;
-
- % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
- AO = getao;
- AO.TUNE.Monitor.Golden = [
- 0.290
- 0.216
- NaN];
- setao(AO);
-
-
- % Golden chromaticity is in the AD (Physics units)
- AD.Chromaticity.Golden = [1; 1]; % ???
-
- % Tune processor delay: delay required to wait
- % to have a fresh tune measurement after changing
- % a variable like the RF frequency. Setpv will wait
- % 2.2 * TuneDelay to be guaranteed a fresh data point.
- AD.TuneDelay = 2.5;
-
- switch2sim;
- switch2hw;
-
-elseif ModeNumber == 4
- % Model mode
- AD.OperationalMode = '3.0 GeV, test';
- ModeName = 'test';
- OpsFileExtension = '';
-
- % AT lattice
-% AD.ATModel = 'aspsr_msrf';
-% aspsr_msrf;
- AD.ATModel = 'assr4_id';
- assr4_wiggler;
-
- % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
- AO = getao;
- AO.TUNE.Monitor.Golden = [
- 0.29
- 0.216
- NaN];
- setao(AO);
-
-
- % Golden chromaticity is in the AD (Physics units)
- AD.Chromaticity.Golden = [1; 1]; % ???
-
- % Tune processor delay: delay required to wait
- % to have a fresh tune measurement after changing
- % a variable like the RF frequency. Setpv will wait
- % 2.2 * TuneDelay to be guaranteed a fresh data point.
- AD.TuneDelay = 0;
-
- switch2sim;
- switch2hw;
-
-else
- error('Operational mode unknown');
-end
-
-
-% Set the AD directory path
-setad(AD);
-MMLROOT = setmmldirectories(AD.Machine, AD.SubMachine, ModeName, OpsFileExtension);
-AD = getad;
-
-%Application Programs WJC Sept 18, 2006
-AD.Directory.Orbit = [MMLROOT, 'applications', filesep, 'orbit', filesep, 'asp', filesep];
-AD.Directory.SOFB = [MMLROOT, 'applications', filesep, 'SOFB', filesep];
-
-
-% Circumference
-AD.Circumference = findspos(THERING,length(THERING)+1);
-
-
-% Updates the AT indices in the MiddleLayer with the present AT lattice
-updateatindex;
-
-
-% Set the model energy
-setenergymodel(AD.Energy);
-
-
-% Cavity and radiation
-setcavity off;
-setradiation off;
-fprintf(' Radiation and Cavities are OFF. Use setcavity/setradiation to modify\n');
-
-% Momentum compaction factor
-MCF = getmcf('Model');
-if isnan(MCF)
- AD.MCF = 0.0020;
- fprintf(' Model alpha calculation failed, middlelayer alpha set to %f\n', AD.MCF);
-else
- AD.MCF = MCF;
- fprintf(' Middlelayer alpha set to %f (AT model).\n', AD.MCF);
-end
-setad(AD);
-
-
-% Final mode changes
-% Note: setlocogains was changed to setlocodata
-if ModeNumber == 1
- % Commissionign Mode
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Add LOCO Parameters to AO and AT-Model %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %LocoFileDirectory = getfamilydata('Directory','OpsData');
- %setlocodata('SetGains',[LocoFileDirectory,'LOCOFilename?']);
- %setlocodata('LOCO2Model',[LocoFileDirectory,'LOCOFilename']);
- setlocodata('Nominal');
-
-elseif ModeNumber == 2
- % User Mode
- setlocodata('Nominal');
- setfamilydata(0,'BPMx','Offset');
- setfamilydata(0,'BPMy','Offset');
- setfamilydata(0,'BPMx','Golden');
- setfamilydata(0,'BPMy','Golden');
-
- setfamilydata(0,'TuneDelay');
-
- %setsp('SQSF', 0, 'Simulator', 'Physics');
- %setsp('SQSD', 0, 'Simulator', 'Physics');
- setsp('HCM', 0, 'Simulator', 'Physics');
- setsp('VCM', 0, 'Simulator', 'Physics');
-
-elseif ModeNumber == 3
- % Model Mode
- setlocodata('Nominal');
- setfamilydata(0,'BPMx','Offset');
- setfamilydata(0,'BPMy','Offset');
- setfamilydata(0,'BPMx','Golden');
- setfamilydata(0,'BPMy','Golden');
-
- setfamilydata(0,'TuneDelay');
-
- %setsp('SQSF', 0, 'Simulator', 'Physics');
- %setsp('SQSD', 0, 'Simulator', 'Physics');
- setsp('HCM', 0, 'Simulator', 'Physics');
- setsp('VCM', 0, 'Simulator', 'Physics');
-end
-
-
-% Change defaults for LabCA if using it
-try
- if exist('lcaSetRetryCount','file')
- % read dummy pv to initialize labca
- % ChannelName = family2channel('BPMx');
- % lcaGet(family2channel(ChannelName(1,:));
-
- % Retry count
- RetryCountNew = 1000; % Default: 599-old labca, 299-labca_2_1_beta
- RetryCount = lcaGetRetryCount;
- lcaSetRetryCount(RetryCountNew);
- if RetryCount ~= RetryCountNew
- fprintf(' Setting LabCA retry count to %d (was %d)\n', RetryCountNew, RetryCount);
- end
-
- % Timeout
- TimeoutNew = .005; % Defaul: .05-old labca, .1-labca_2_1_beta
- Timeout = lcaGetTimeout;
- lcaSetTimeout(TimeoutNew);
- if abs(Timeout - TimeoutNew) > 1e-5
- fprintf(' Setting LabCA TimeOut to %f (was %f)\n', TimeoutNew, Timeout);
- end
-
- % To avoid UDF errors, set the WarnLevel to 4 (Default is 3)
- lcaSetSeverityWarnLevel(4);
- fprintf(' Setting lcaSetSeverityWarnLevel to 4 to avoid annoying UDF errors.\n');
- end
-catch
- fprintf(' LabCA Timeout not set, need to run lcaSetRetryCount(1000), lcaSetTimeout(.01).\n');
-end
-
-
-fprintf(' Middlelayer setup for operational mode: %s\n', AD.OperationalMode);
-
-
+function varargout = setoperationalmode(ModeNumber)
+%SETOPERATIONALMODE - Set all the variables associated with an operational mode
+% STATUS = setoperationalmode(ModeNumber)
+%
+% If STATUS == 1, the mode has been changed.
+% If STATUS == 0, the mode has NOT been changed.
+%
+% See also aoinit, updateatindex
+%
+% Updated:
+% 02/02/2009: ET ModeCell updated to reflect current modes.
+% 10/11/2009: ET Returns the if mode changed or not
+% 24/02/2012: KW added splitbends all IDs model
+
+global THERING
+
+
+% Check if the AO exists
+checkforao;
+
+ModeCell = {...
+ 'Mode 1 - 3.0 GeV User Mode (0.0 m Dispersion)';
+ 'Mode 2 - 3.0 GeV User Mode (0.1 m Dispersion) - SCW @ 0 T';
+ 'Mode 3 - 3.0 GeV User Mode (0.24 m Dispersion)';
+ 'Mode 4 - 3.0 GeV Model, single bend (0.0 m Dispersion)';
+ 'Mode 5 - 3.0 GeV Model, single bend (0.1 m Dispersion)';
+ 'Mode 6 - Low alpha intermediate lattice';
+ 'Mode 7 - Low alpha intermediate lattice (-0.7m dispersion)';
+ 'Mode 8 - 7-fold lattice';
+ 'Mode 9 - Low alpha intermediate lattice (-0.86m dispersion)';
+ 'Mode 10 - 3.0 GeV User Mode, all IDs (0.1m dispersion)';
+ 'Mode 11 - 3.0 GeV User Mode (0.1 m Dispersion) - SCW @ 3 T';
+ 'Mode 12 - 1.6 GeV User Mode (0.1 m Dispersion) - SCW @ 0 T';
+ };
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Accelerator Dependent Modes %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if nargin < 1
+ [ModeNumber, OKFlag] = listdlg('Name','ASP','PromptString','Select the Operational Mode:',...
+ 'SelectionMode','single', 'ListString', ModeCell,'ListSize',[450 300]);
+ if OKFlag ~= 1
+ fprintf(' Operational mode not changed\n');
+ varargout{1} = 0;
+ return
+ end
+end
+varargout{1} = 1;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Accelerator Data Structure %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+AD = getad;
+AD.Machine = 'ASP'; % Will already be defined if setpathmml was used
+AD.SubMachine = 'StorageRing'; % Will already be defined if setpathmml was used
+AD.OperationalMode = ''; % Gets filled in later
+AD.Energy = 3.033; 3.0314; 3.0134; %3.0134 % 19/05/2008 ET machine's energy seems to be ~1.4% lower than the model prediction based on the collective magnetic measurements of quadrupoles and sextupoles.
+AD.InjectionEnergy = 3.0134;
+AD.HarmonicNumber = 360;
+
+% Defaults RF for disperion and chromaticity measurements (must be in Hardware units) ???
+AD.DeltaRFDisp = 2000/4;
+AD.DeltaRFChro = [0 -1000 -2000 -1000 0 1000 2000 1000 0]/2;
+
+
+
+% Tune processor delay: delay required to wait
+% to have a fresh tune measurement after changing
+% a variable like the RF frequency. Setpv will wait
+% 2.2 * TuneDelay to be guaranteed a fresh data point.
+AD.TuneDelay = 1.0;
+
+% SP-AM Error level
+% AD.ErrorWarningLevel = 0 -> SP-AM errors are Matlab errors {Default}
+% -1 -> SP-AM errors are Matlab warnings
+% -2 -> SP-AM errors prompt a dialog box
+% -3 -> SP-AM errors are ignored (ErrorFlag=-1 is returned)
+AD.ErrorWarningLevel = 0;
+
+
+%%%%%%%%%%%%%%%%%%%%%
+% Operational Modes %
+%%%%%%%%%%%%%%%%%%%%%
+
+% Mode setup variables (mostly path and file names)
+% AD.OperationalMode - String used in titles
+% MachineName - String used to build directory structure off DataRoot
+% ModeName - String used for mode directory name off DataRoot/MachineName
+% OpsFileExtension - string add to default file names
+MachineName = 'asp';
+AD.OperationalMode = ModeCell{ModeNumber};
+if ModeNumber == 1
+ % User mode split bends, zero dispersion
+ ModeName = 'User0';
+ OpsFileExtension = '_user0';
+
+ % AT lattice
+ [status,res]=system('hostname -s');
+ switch lower(strtrim(res))
+ case {'cr01opi07'}
+ AD.ATModel = 'assr4_splitbends';
+ assr4_splitbends cavity4ring;
+ otherwise
+ AD.ATModel = 'assr4_splitbends_mod';
+ assr4_splitbends_mod cavity4ring;
+ end
+ % 3 cavity operation
+ fprintf('*** Starting 3 cavity operation (2000 MV) ***\n')
+ cavind = findcells(THERING,'HarmNumber');
+ THERING{cavind(1)}.Voltage = 6.79e5; %6.68e5;
+ THERING{cavind(2)}.Voltage = 6.86e5; %0;
+ THERING{cavind(3)}.Voltage = 0; %6.58e5;
+ THERING{cavind(4)}.Voltage = 6.61e5; %6.48e5;
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+ setao(AO);
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+
+ % Online and hardware units
+ switch2online;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+ % Set the model energy
+ setenergymodel(AD.Energy);
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ % Add LOCO Parameters to AO and AT-Model %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %LocoFileDirectory = getfamilydata('Directory','OpsData');
+ %setlocodata('SetGains',[LocoFileDirectory,'LOCOFilename?']);
+ %setlocodata('LOCO2Model',[LocoFileDirectory,'LOCOFilename']);
+ setlocodata('Nominal');
+
+% fittunedisp2([13.29 5.216 0.0],'QFA','QDA','QFB',1)
+ setsp('QFA', 1.723428335912745,'physics','model');
+ setsp('QDA',-1.021524810038134,'physics','model');
+ setsp('QFB', 1.506832980875907,'physics','model');
+
+ % Set the nominal chromaticity
+ setsp('SFA', 11,'physics','model');
+ setsp('SDA', -12,'physics','model');
+% fitchrom2([1,1],'SFB','SDB'); disp([getsp('SFB',1,'physics','model'),getsp('SDB',1,'physics','model')])
+ setsp('SFB', 7.363955546172189,'physics','model');
+ setsp('SDB', -7.179245538366332,'physics','model');
+
+elseif ModeNumber == 2
+
+ % User mode - Split bends, Distributed Dispersion (0.1)
+ ModeName = 'User1';
+ OpsFileExtension = '_user1';
+
+ % AT lattice
+ [status,res]=system('hostname -s');
+ switch lower(strtrim(res))
+ case {'cr01opi07'}
+ AD.ATModel = 'assr4_splitbends';
+ assr4_splitbends cavity4ring;
+ otherwise
+ AD.ATModel = 'assr4_splitbends_mod';
+ assr4_splitbends_mod cavity4ring;
+ end
+ % 3 cavity operation
+ fprintf('*** Starting 3 cavity operation (2000 MV) ***\n')
+ cavind = findcells(THERING,'HarmNumber');
+ THERING{cavind(1)}.Voltage = 6.79e5; %6.68e5;
+ THERING{cavind(2)}.Voltage = 6.86e5; %0;
+ THERING{cavind(3)}.Voltage = 0; %6.58e5;
+ THERING{cavind(4)}.Voltage = 6.61e5; %6.48e5;
+
+ % Insert super conducting wiggler
+% insertscw(0);
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+ setao(AO);
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+
+ switch2online;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+ % Set the model energy
+ setenergymodel(AD.Energy);
+
+ % Set model parameters
+ setlocodata('Nominal');
+% fittunedisp2([13.29 5.216 0.10],'QFA','QDA','QFB',1)
+ setpv('QFA', +1.733644317160764,'physics','model');
+ setpv('QDA', -1.022026077359464,'physics','model');
+ setpv('QFB', +1.501323674315535,'physics','model');
+
+ % In order to get the right chromaticity
+ % operations changed to low chromaticity for BBB operation
+ setsp('SFA', 11,'physics','model');
+ setsp('SDA', -12,'physics','model');
+% fitchrom2([1,1],'SFB','SDB'); disp([getsp('SFB',1,'physics','model'),getsp('SDB',1,'physics','model')])
+ setsp('SFB', 7.758558385071983,'physics','model');
+ setsp('SDB', -7.578367804452122,'physics','model');
+
+elseif ModeNumber == 3
+
+ % User mode - Split bends, Distributed Dispersion (0.24)
+ ModeName = 'User2';
+ OpsFileExtension = '_user2';
+
+ % AT lattice
+ [status,res]=system('hostname -s');
+ switch lower(strtrim(res))
+ case {'cr01opi07'}
+ AD.ATModel = 'assr4_splitbends';
+ assr4_splitbends cavity4ring;
+ otherwise
+ AD.ATModel = 'assr4_splitbends_mod';
+ assr4_splitbends_mod cavity4ring;
+ end
+ % 3 cavity operation
+ fprintf('*** Starting 3 cavity operation (1900 MV) ***')
+ cavind = findcells(THERING,'HarmNumber');
+ THERING{cavind(1)}.Voltage = 6.68e5;
+ THERING{cavind(2)}.Voltage =6.68e5;
+ THERING{cavind(3)}.Voltage = 6.58e5;
+ THERING{cavind(4)}.Voltage = 6.48e5;
+
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+ setao(AO);
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+
+ switch2online;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+ % Set the model energy
+ setenergymodel(AD.Energy);
+
+ setlocodata('Nominal');
+% fittunedisp2([13.29 5.216 0.24],'QFA','QDA','QFB',1)
+ setpv('QFA', +1.749877620130296,'physics','model');
+ setpv('QDA', -1.022984475040535,'physics','model');
+ setpv('QFB', +1.492855475998011,'physics','model');
+
+ % Set the nominal chromaticity
+ setsp('SFA', 11,'physics','model');
+ setsp('SDA', -12,'physics','model');
+% fitchrom2([1,1],'SFB','SDB'); disp([getsp('SFB',1,'physics','model'),getsp('SDB',1,'physics','model')])
+ setsp('SFB', 9.397721020313263,'physics','model');
+ setsp('SDB', -9.152478741386210,'physics','model');
+
+elseif ModeNumber == 4
+ % single bends with zero-dispersion
+ ModeName = 'Model';
+ OpsFileExtension = '';
+
+ % AT lattice
+ AD.ATModel = 'assr4';
+ assr4;
+ % 3 cavity operation
+ fprintf('*** Starting 3 cavity operation (1900 MV) ***')
+ cavind = findcells(THERING,'HarmNumber');
+ THERING{cavind(1)}.Voltage = 6.68e5;
+ THERING{cavind(2)}.Voltage = 0;
+ THERING{cavind(3)}.Voltage = 6.58e5;
+ THERING{cavind(4)}.Voltage = 6.48e5;
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+ setao(AO);
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+
+ switch2sim;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+ % Set the model energy
+ setenergymodel(AD.Energy);
+
+ setlocodata('Nominal');
+% fittunedisp2([13.29 5.216 0.0],'QFA','QDA','QFB',1)
+ setsp('QFA', 1.721721539410648,'physics','model');
+ setsp('QDA',-1.018590780985194,'physics','model');
+ setsp('QFB', 1.505499577114660,'physics','model');
+
+ % Set the nominal chromaticity
+ setsp('SFA', 11,'physics','model');
+ setsp('SDA', -12,'physics','model');
+% fitchrom2([1,1],'SFB','SDB'); disp([getsp('SFB',1,'physics','model'),getsp('SDB',1,'physics','model')])
+ setsp('SFB', 7.376336647962120,'physics','model');
+ setsp('SDB', -7.127633424850286,'physics','model');
+
+elseif ModeNumber == 5
+ % Model mode, single bends with distributed dispersion (0.1)
+ ModeName = 'Model';
+ OpsFileExtension = '';
+
+ % AT lattice
+ AD.ATModel = 'assr4';
+ assr4 cavity4ring;
+ % 3 cavity operation
+ fprintf('*** Starting 3 cavity operation (1900 MV) ***')
+ cavind = findcells(THERING,'HarmNumber');
+ THERING{cavind(1)}.Voltage = 6.68e5;
+ THERING{cavind(2)}.Voltage = 0;
+ THERING{cavind(3)}.Voltage = 6.58e5;
+ THERING{cavind(4)}.Voltage = 6.48e5;
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+ setao(AO);
+
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+
+ % Tune processor delay: delay required to wait
+ % to have a fresh tune measurement after changing
+ % a variable like the RF frequency. Setpv will wait
+ % 2.2 * TuneDelay to be guaranteed a fresh data point.
+ AD.TuneDelay = 0;
+
+ switch2sim;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+ % Set the model energy
+ setenergymodel(AD.Energy);
+
+% fittunedisp2([13.29 5.216 0.10],'QFA','QDA','QFB',1)
+ setpv('QFA', +1.731975160162291,'physics','model');
+ setpv('QDA', -1.019100405961120,'physics','model');
+ setpv('QFB', +1.499963551732084,'physics','model');
+
+ % In order to get the right chromaticity
+ % operations changed to low chromaticity for BBB operation
+ setsp('SFA', 11,'physics','model');
+ setsp('SDA', -12,'physics','model');
+% fitchrom2([1,1],'SFB','SDB'); disp([getsp('SFB',1,'physics','model'),getsp('SDB',1,'physics','model')])
+ setsp('SFB', 7.770807107941121,'physics','model');
+ setsp('SDB', -7.502482318683351,'physics','model');
+
+elseif ModeNumber == 6
+
+ % Low alpha intermediate lattice with -0.5 meter dispersion
+ ModeName = 'Alpha_intermediate';
+ OpsFileExtension = '_alpha_int';
+
+ % AT lattice using new assr4 with modified bends.
+ AD.ATModel = 'assr4_modbend';
+ assr4_modbend;
+
+ AD.DeltaRFChro = AD.DeltaRFChro/2;
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+ setao(AO);
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+
+ switch2online;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+ % Set the model energy
+ setenergymodel(AD.Energy);
+
+ setlocodata('Nominal');
+ setsp('QFA', 1.717973104075701,'physics','model');
+ setsp('QDA', -1.071945364781163,'physics','model');
+ setsp('QFB', 1.565332600016605,'physics','model');
+
+elseif ModeNumber == 7
+
+ % Low alpha intermediate lattice with -0.70 meter dispersion
+ ModeName = 'Alpha_intermediate2';
+ OpsFileExtension = '_alpha_int2';
+
+ % AT lattice using new assr4 with modified bends.
+ AD.ATModel = 'assr4_splitbends_mod';
+% assr4_modbend;
+ assr4_splitbends_mod;
+ % 3 cavity operation
+ fprintf('*** Starting 3 cavity operation (1900 MV) ***')
+ cavind = findcells(THERING,'HarmNumber');
+ THERING{cavind(1)}.Voltage = 6.68e5;
+ THERING{cavind(2)}.Voltage = 0;
+ THERING{cavind(3)}.Voltage = 6.58e5;
+ THERING{cavind(4)}.Voltage = 6.48e5;
+
+
+ % Momentum compaction factor reduced by factor 10. So requires RF
+ % change also scales by factor 10.
+ AD.DeltaRFDisp = 250/10;
+ AD.DeltaRFChro = AD.DeltaRFChro/10*3;
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+ setao(AO);
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+
+ switch2online;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+ % Set the model energy
+ setenergymodel(AD.Energy);
+
+ setlocodata('Nominal');
+% setsp('QFA', 1.701360482677673,'physics','model');
+% setsp('QDA', -1.072306322936900 ,'physics','model');
+% setsp('QFB', 1.576013680596304,'physics','model');
+% setsp('QFA', 1.702923622325624 ,'physics','model');
+% setsp('QDA', -1.048908889625475 ,'physics','model');
+% setsp('QFB', 1.571570870143046,'physics','model');
+ % Modbend model for -0.75 m dispersion
+% setsp('QFA', 1.667596906749336 ,'physics','model');
+% setsp('QDA', -1.022625725276466 ,'physics','model');
+% setsp('QFB', 1.528329348576760,'physics','model');
+ % for -0.7 meter dispersion
+% setsp('QFA', 1.672129504597714 ,'physics','model');
+% setsp('QDA', -1.024920210424092 ,'physics','model');
+% setsp('QFB', 1.539699300919924,'physics','model');
+ fittunedisp2([13.29 5.216 -0.7],'QFA','QDA','QFB',1);
+
+elseif ModeNumber == 8
+
+ % 7-fold lattice for custom straigth section betas and beam sizes.
+ ModeName = 'SevenFold_Lattice';
+ OpsFileExtension = '_7fold';
+
+ % AT lattice using new assr4 with modified bends.
+ AD.ATModel = 'assr4';
+ assr4_splitbends;
+
+ % Momentum compaction factor reduced by factor 10. So requires RF
+ % change also scales by factor 10.
+ AD.DeltaRFDisp = 250;
+ AD.DeltaRFChro = AD.DeltaRFChro;
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+ setao(AO);
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+
+ switch2online;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+ % Set the model energy
+ setenergymodel(AD.Energy);
+
+ setlocodata('Nominal');
+ q1 = [];
+ q2 = [];
+ for i=1:7
+ q1 = [q1 ([1 4]+(i-1)*4)];
+ q2 = [q2 ([2 3]+(i-1)*4)];
+ end
+ % 0.1 disp and 1.5 meter betay in first straight
+ setsp('QFA', 1.606767660323437,elem2dev('QFA',q2),'physics','model');
+ setsp('QFA', 1.933334650614699,elem2dev('QFA',q1),'physics','model');
+ setsp('QDA', -1.131939477770982,elem2dev('QDA',q2),'physics','model');
+ setsp('QDA', -0.920134397770982,elem2dev('QDA',q1),'physics','model');
+ setsp('QFB', 1.448641081159739,elem2dev('QFB',q2),'physics','model');
+ setsp('QFB', 1.542221081159739,elem2dev('QFB',q1),'physics','model');
+
+ % In order to get the right chromaticity
+ setsp('SFA', 16.89,'physics','model');
+ setsp('SDA', -16.49,'physics','model');
+ fitchrom2([3.2 13],'SFB','SDB')
+
+elseif ModeNumber == 9
+ % Low alpha intermediate lattice with -0.86 meter dispersion
+ ModeName = 'Alpha_intermediate3';
+ OpsFileExtension = '_alpha_int3';
+
+ % AT lattice using new assr4 with modified bends.
+ AD.ATModel = 'assr4_splitbends_mod';
+% assr4_modbend;
+ assr4_splitbends_mod;
+ % 3 cavity operation
+ fprintf('*** Starting 3 cavity operation (1900 MV) ***')
+ cavind = findcells(THERING,'HarmNumber');
+ THERING{cavind(1)}.Voltage = 6.68e5;
+ THERING{cavind(2)}.Voltage = 0;
+ THERING{cavind(3)}.Voltage = 6.58e5;
+ THERING{cavind(4)}.Voltage = 6.48e5;
+
+ fittunedisp2([13.29 5.216 -0.86],'QFA','QDA','QFB',1);
+
+ % Momentum compaction factor reduced by factor 10. So requires RF
+ % change also scales by factor 10.
+ AD.DeltaRFDisp = 250/10;
+ AD.DeltaRFChro = AD.DeltaRFChro/10;
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+ setao(AO);
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+ % In order to get the right chromaticity
+ setsp('SFA', 11,'physics','model');
+ setsp('SDA', -10.4,'physics','model');
+ fitchrom2([1 1],'SFB','SDB')
+
+ switch2online;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+ % Set the model energy
+ setenergymodel(AD.Energy);
+
+elseif ModeNumber == 10
+
+ % User mode - Split bends, Distributed Dispersion (0.1)
+ ModeName = 'User1';
+ OpsFileExtension = '_user1';
+
+ % AT lattice
+ AD.ATModel = 'assr4_splitbends_kent';
+ assr4_splitbends_kent cavity4ringkent;
+
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+ setao(AO);
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+
+ switch2online;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+ % Set the model energy
+ setenergymodel(AD.Energy);
+
+ % Set model parameters
+ setlocodata('Nominal');
+
+% fittunedisp2([13.29 5.214 0.10],'QFA','QDA','QFB',1)
+
+ setsp('QFA', 1.735450634682162,'physics','model');
+ setsp('QDA',-1.026232260610199,'physics','model');
+ setsp('QFB', 1.502798566761560,'physics','model');
+
+ % In order to get the right chromaticity
+ setsp('SFA', 17,'physics','model');
+ setsp('SDA', -16.6,'physics','model');
+ fitchrom2([3.2 13],'SFB','SDB')
+
+% idind = findcells(THERING,'FamName','ID');
+% kx = 0.0003416;
+% ky = -0.0210746;
+% THERING{idind(12)}.M66(2,1) = kx;
+% THERING{idind(12)}.M66(4,3) = ky;
+elseif ModeNumber == 11
+
+ % User mode - Split bends, Distributed Dispersion (0.1)
+ ModeName = 'User1';
+ OpsFileExtension = '_user1';
+
+ % AT lattice
+ AD.ATModel = 'assr4_splitbends';
+ assr4_splitbends cavity4ring;
+
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+ setao(AO);
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+
+ switch2online;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+ % Set the model energy
+ setenergymodel(AD.Energy);
+
+ % Set model parameters
+ setlocodata('Nominal');
+
+% fittunedisp2([13.29 5.214 0.10],'QFA','QDA','QFB',1)
+
+ setsp('QFA', 1.735450634682162,'physics','model');
+ setsp('QDA',-1.026232260610199,'physics','model');
+ setsp('QFB', 1.502798566761560,'physics','model');
+
+ % In order to get the right chromaticity
+ setsp('SFA', 17,'physics','model');
+ setsp('SDA', -16.6,'physics','model');
+ fitchrom2([3.2 13],'SFB','SDB')
+
+ % SCW at 4.3T
+% global THERING
+% idind = findcells(THERING,'FamName','ID');
+% kx = [ 0.0026];
+% ky = [-0.1219];
+% THERING{idind(8)}.M66(2,1) = kx;
+% THERING{idind(8)}.M66(4,3) = ky;
+
+ % SCW at 3.0 T
+ global THERING
+ idind = findcells(THERING,'FamName','ID');
+
+ % Measured with increasing field strength
+ ii = 2;
+ gaps = [3 2 1.4 1.0 0.2 0];
+ kx = [-0.000831772685971 -0.000292523070982 -0.000583821679539 0.000059901469698 0 0];
+ ky = [-0.071186619313300 -0.034495700926302 -0.019418887097436 -0.011923601576230 0 0];
+ measdate = '20.12.2014';
+ load /asp/usr/scripts/insertiondevice/feedforward/WIG_08_SCW/SR08ID01_SCW_QuadFF_2014-12-20_18-41-43-upramp
+
+% kx = [-0.0012];
+% ky = [-0.0369];
+% load /asp/usr/scripts/insertiondevice/feedforward/WIG_08_SCW/SR08ID01_SCW_QuadFF_2013-01-25_16-09-11.mat
+
+% kx = [0.0098];
+% ky = [-0.0551];
+% load /asp/usr/scripts/insertiondevice/feedforward/WIG_08_SCW/SR08ID01_SCW_QuadFF_2013-01-25_20-20-45.mat
+%
+% kx = -0.001269426242865;
+% ky = -0.064681552652870;
+% load /asp/usr/scripts/insertiondevice/feedforward/WIG_08_SCW/SR08ID01_SCW_QuadFF_2013-01-25_22-27-26.mat
+
+ THERING{idind(8)}.M66(2,1) = kx(ii);
+ THERING{idind(8)}.M66(4,3) = ky(ii);
+
+ stepsp('QFA',idcorrection.qfasd(:,ii),'model','hardware');
+ stepsp('QDA',idcorrection.qdasd(:,ii),'model','hardware');
+ stepsp('QFB',idcorrection.qfbsd(:,ii),'model','hardware');
+
+elseif ModeNumber == 12
+
+ % User mode - Split bends, Distributed Dispersion (0.1)
+ ModeName = 'Lowenergy';
+ OpsFileExtension = '_lowenergy';
+
+ % Set the ring energy
+ AD.Energy = 1.62;
+ AD.InjectionEnergy = 1.62;
+
+ % AT lattice
+ AD.ATModel = 'assr4_splitbends';
+ assr4_splitbends cavity4ring;
+ % 3 cavity operation
+ fprintf('*** Starting 3 cavity operation (1900 MV) ***')
+ cavind = findcells(THERING,'HarmNumber');
+ THERING{cavind(1)}.Voltage = 2.5e5; 6.68e5;
+ THERING{cavind(2)}.Voltage = 2.5e5; 0;
+ THERING{cavind(3)}.Voltage = 0; 6.58e5;
+ THERING{cavind(4)}.Voltage = 2.5e5; 6.48e5;
+
+ % Set the model energy
+ setenergymodel(1.62);
+
+ % Golden TUNE is with the TUNE family (This could have been in aspphysdata) % ???
+ AO = getao;
+ AO.TUNE.Monitor.Golden = [
+ 0.290
+ 0.216
+ NaN];
+
+ % Reset the deltarespmat because the default is in HW units and for 3
+ % GeV.
+ AO.HCM.Setpoint.DeltaRespMat = physics2hw('HCM', 'Setpoint', 1.8e-5*AD.Energy/3.03, AO.HCM.DeviceList);
+ AO.VCM.Setpoint.DeltaRespMat = physics2hw('VCM', 'Setpoint', 0.9e-5*AD.Energy/3.03, AO.VCM.DeviceList);
+
+ setao(AO);
+
+ % Golden chromaticity is in the AD (Physics units)
+ AD.Chromaticity.Golden = [1; 1]; % ???
+
+ switch2online;
+ switch2hw;
+
+ % Updates the AT indices in the MiddleLayer with the present AT lattice
+ updateatindex;
+
+ % Set model parameters
+ setlocodata('Nominal');
+
+% fittunedisp2([13.29 5.214 0.10],'QFA','QDA','QFB',1)
+
+ % 0.1 m disp
+% setpv('QFA', +1.735451639222026,'physics','model');
+% setpv('QDA', -1.026238981593949,'physics','model');
+% setpv('QFB', +1.502800258212542,'physics','model');
+
+ % 0.24 m disp
+ setpv('QFA', +1.751424202841732,'physics','model');
+ setpv('QDA', -1.026976173811566,'physics','model');
+ setpv('QFB', +1.494479036840916,'physics','model');
+
+
+ % In order to get the right chromaticity
+ setsp('SFA', 17,'physics','model');
+ setsp('SDA', -16.6,'physics','model');
+ fitchrom2([3.2 13],'SFB','SDB');
+
+else
+ error('Operational mode unknown');
+end
+
+
+% Set the AD directory path
+setad(AD);
+MMLROOT = setmmldirectories(AD.Machine, AD.SubMachine, ModeName, OpsFileExtension);
+AD = getad;
+
+%Application Programs WJC Sept 18, 2006
+AD.Directory.Orbit = [MMLROOT, 'applications', filesep, 'orbit', filesep, 'asp', filesep];
+AD.Directory.SOFB = [MMLROOT, 'applications', filesep, 'SOFB', filesep];
+
+% Circumference
+AD.Circumference = findspos(THERING,length(THERING)+1);
+
+
+% Cavity and radiation
+setcavity off; % Needed for tune
+setradiation off; % ???
+fprintf(' Radiation and Cavities are OFF. Use setcavity/setradiation to modify\n');
+
+% Momentum compaction factor
+MCF = getmcf('Model');
+if isnan(MCF)
+ AD.MCF = 0.0020;
+ fprintf(' Model alpha calculation failed, middlelayer alpha set to %f\n', AD.MCF);
+else
+ AD.MCF = MCF;
+ fprintf(' Middlelayer alpha set to %f (AT model).\n', AD.MCF);
+end
+setad(AD);
+
+% Change defaults for LabCA if using it
+try
+ if exist('lcaSetRetryCount','file')
+ % read dummy pv to initialize labca
+ % ChannelName = family2channel('BPMx');
+ % lcaGet(family2channel(ChannelName(1,:));
+
+ % Retry count
+ % 5/4/2017 Eugene: set to 100 so the total timeout is only 0.5s
+ % rather than 10 seconds!
+ RetryCountNew = 100; % Default: 599-old labca, 299-labca_2_1_beta,
+ RetryCount = lcaGetRetryCount;
+ lcaSetRetryCount(RetryCountNew);
+ if RetryCount ~= RetryCountNew
+ fprintf(' Setting LabCA retry count to %d (was %d)\n', RetryCountNew, RetryCount);
+ end
+
+ % Timeout
+ TimeoutNew = 0.1; % Defaul: .05-old labca, .1-labca_2_1_beta
+ Timeout = lcaGetTimeout;
+ lcaSetTimeout(TimeoutNew);
+ if abs(Timeout - TimeoutNew) > 1e-5
+ fprintf(' Setting LabCA TimeOut to %f (was %f)\n', TimeoutNew, Timeout);
+ end
+
+ % To avoid UDF errors, set the WarnLevel to 4 (Default is 3)
+ lcaSetSeverityWarnLevel(4);
+ fprintf(' Setting lcaSetSeverityWarnLevel to 4 to avoid annoying UDF errors.\n');
+ end
+catch
+ fprintf(' LabCA Timeout not set, need to run lcaSetRetryCount(200), lcaSetTimeout(.01).\n');
+end
+
+fprintf(' Middlelayer setup for operational mode: %s\n', AD.OperationalMode);
+
+
diff --git a/machine/ASP/StorageRing/setorbitdefault.m b/machine/ASP/StorageRing/setorbitdefault.m
index b864260d..8737ec45 100644
--- a/machine/ASP/StorageRing/setorbitdefault.m
+++ b/machine/ASP/StorageRing/setorbitdefault.m
@@ -1,166 +1,166 @@
-function setorbitdefault(varargin)
-% setorbitdefault(Evectors {1e-4}, Iters {1}, RemoveBPMDeviceList, RemoveHCMDeviceList, RemoveVCMDeviceList)
-
-
-% Defaults
-PlaneFlag = 0; % Both planes
-ItersDefault = 1;
-EvectorsDefault = 1e-3;
-RemoveBPMDeviceList = [];
-RemoveHCMDeviceList = [];
-RemoveVCMDeviceList = [];
-DisplayFlag = 'Display';
-
-% Input parsing
-Evectors = [];
-Iters = [];
-for i = length(varargin):-1:1
- if isstruct(varargin{i})
- % Just remove
- varargin(i) = [];
- elseif iscell(varargin{i})
- % Just remove
- varargin(i) = [];
- elseif strcmpi(varargin{i},'struct')
- % Just remove
- varargin(i) = [];
- elseif strcmpi(varargin{i},'numeric')
- % Just remove
- varargin(i) = [];
- elseif strcmpi(varargin{i},'Display')
- DisplayFlag = 'Display';
- varargin(i) = [];
- elseif strcmpi(varargin{i},'NoDisplay')
- DisplayFlag = 'NoDisplay';
- varargin(i) = [];
- elseif any(strcmpi(varargin{i},{'x','Horizontal'}))
- PlaneFlag = 1;
- varargin(i) = [];
- elseif any(strcmpi(varargin{i},{'y','Vertical'}))
- PlaneFlag = 2;
- varargin(i) = [];
- end
-end
-
-
-if length(varargin) >= 1
- if isnumeric(varargin{1})
- Evectors = varargin{1};
- varargin(i) = [];
- end
-end
-if isempty(Evectors)
- if PlaneFlag == 0
- Evectors = EvectorsDefault;
- elseif PlaneFlag == 1
- Evectors = EvectorsDefault;
- elseif PlaneFlag == 2
- Evectors = EvectorsDefault;
- end
-end
-
-if length(varargin) >= 1
- if isnumeric(varargin{1})
- Iters = varargin{1};
- varargin(i) = [];
- end
-end
-if isempty(Iters)
- Iters = ItersDefault;
-end
-
-if length(varargin) >= 1
- if isnumeric(varargin{1})
- RemoveBPMDeviceList = varargin{1};
- varargin(i) = [];
- end
-end
-
-
-
-if PlaneFlag == 0
- % Get BPM and CM structures
- CM = {getsp('HCM','struct'),getsp('VCM','struct')};
- BPM = {getx('struct'), gety('struct')};
-
-
- % Remove devices
-
- % HCM
- i = findrowindex(RemoveHCMDeviceList, CM{1}.DeviceList);
- CM{1}.DeviceList(i,:) = [];
- CM{1}.Data(i,:) = [];
- CM{1}.Status(i,:) = [];
-
- % VCM
- i = findrowindex(RemoveVCMDeviceList, CM{2}.DeviceList);
- CM{2}.DeviceList(i,:) = [];
- CM{2}.Data(i,:) = [];
- CM{2}.Status(i,:) = [];
-
- % BPMx and BPMy
- i = findrowindex(RemoveBPMDeviceList, BPM{1}.DeviceList);
- BPM{1}.DeviceList(i,:) = [];
- BPM{1}.Data(i,:) = [];
- BPM{1}.Status(i,:) = [];
-
- i = findrowindex(RemoveBPMDeviceList, BPM{2}.DeviceList);
- BPM{2}.DeviceList(i,:) = [];
- BPM{2}.Data(i,:) = [];
- BPM{2}.Status(i,:) = [];
-
-
- % Corrector orbit
- setorbit('Golden', BPM, CM, Iters, Evectors, DisplayFlag, varargin{:});
-
-elseif PlaneFlag == 1
-
- % Get BPM and CM structures
- CM = getsp('HCM','struct');
- BPM = getx('struct');
-
-
- % Remove devices
-
- % HCM
- i = findrowindex(RemoveHCMDeviceList, CM.DeviceList);
- CM.DeviceList(i,:) = [];
- CM.Data(i,:) = [];
- CM.Status(i,:) = [];
-
- % BPMx
- i = findrowindex(RemoveBPMDeviceList, BPM.DeviceList);
- BPM.DeviceList(i,:) = [];
- BPM.Data(i,:) = [];
- BPM.Status(i,:) = [];
-
-
- % Corrector orbit
- setorbit('Golden', BPM, CM, Iters, Evectors, DisplayFlag, varargin{:});
-
-elseif PlaneFlag == 2
-
- % Get BPM and CM structures
- CM = getsp('VCM','struct');
- BPM = gety('struct');
-
-
- % Remove devices
-
- % VCM
- i = findrowindex(RemoveVCMDeviceList, CM.DeviceList);
- CM.DeviceList(i,:) = [];
- CM.Data(i,:) = [];
- CM.Status(i,:) = [];
-
- % BPMy
- i = findrowindex(RemoveBPMDeviceList, BPM.DeviceList);
- BPM.DeviceList(i,:) = [];
- BPM.Data(i,:) = [];
- BPM.Status(i,:) = [];
-
-
- % Corrector orbit
- setorbit('Golden', BPM, CM, Iters, Evectors, DisplayFlag, varargin{:});
-end
-
+function setorbitdefault(varargin)
+% setorbitdefault(Evectors {1e-4}, Iters {1}, RemoveBPMDeviceList, RemoveHCMDeviceList, RemoveVCMDeviceList)
+
+
+% Defaults
+PlaneFlag = 0; % Both planes
+ItersDefault = 1;
+EvectorsDefault = 1e-3;
+RemoveBPMDeviceList = [];
+RemoveHCMDeviceList = [];
+RemoveVCMDeviceList = [];
+DisplayFlag = 'Display';
+
+% Input parsing
+Evectors = [];
+Iters = [];
+for i = length(varargin):-1:1
+ if isstruct(varargin{i})
+ % Just remove
+ varargin(i) = [];
+ elseif iscell(varargin{i})
+ % Just remove
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'struct')
+ % Just remove
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'numeric')
+ % Just remove
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'Display')
+ DisplayFlag = 'Display';
+ varargin(i) = [];
+ elseif strcmpi(varargin{i},'NoDisplay')
+ DisplayFlag = 'NoDisplay';
+ varargin(i) = [];
+ elseif any(strcmpi(varargin{i},{'x','Horizontal'}))
+ PlaneFlag = 1;
+ varargin(i) = [];
+ elseif any(strcmpi(varargin{i},{'y','Vertical'}))
+ PlaneFlag = 2;
+ varargin(i) = [];
+ end
+end
+
+
+if length(varargin) >= 1
+ if isnumeric(varargin{1})
+ Evectors = varargin{1};
+ varargin(i) = [];
+ end
+end
+if isempty(Evectors)
+ if PlaneFlag == 0
+ Evectors = EvectorsDefault;
+ elseif PlaneFlag == 1
+ Evectors = EvectorsDefault;
+ elseif PlaneFlag == 2
+ Evectors = EvectorsDefault;
+ end
+end
+
+if length(varargin) >= 1
+ if isnumeric(varargin{1})
+ Iters = varargin{1};
+ varargin(i) = [];
+ end
+end
+if isempty(Iters)
+ Iters = ItersDefault;
+end
+
+if length(varargin) >= 1
+ if isnumeric(varargin{1})
+ RemoveBPMDeviceList = varargin{1};
+ varargin(i) = [];
+ end
+end
+
+
+
+if PlaneFlag == 0
+ % Get BPM and CM structures
+ CM = {getsp('HCM','struct'),getsp('VCM','struct')};
+ BPM = {getx('struct'), gety('struct')};
+
+
+ % Remove devices
+
+ % HCM
+ i = findrowindex(RemoveHCMDeviceList, CM{1}.DeviceList);
+ CM{1}.DeviceList(i,:) = [];
+ CM{1}.Data(i,:) = [];
+ CM{1}.Status(i,:) = [];
+
+ % VCM
+ i = findrowindex(RemoveVCMDeviceList, CM{2}.DeviceList);
+ CM{2}.DeviceList(i,:) = [];
+ CM{2}.Data(i,:) = [];
+ CM{2}.Status(i,:) = [];
+
+ % BPMx and BPMy
+ i = findrowindex(RemoveBPMDeviceList, BPM{1}.DeviceList);
+ BPM{1}.DeviceList(i,:) = [];
+ BPM{1}.Data(i,:) = [];
+ BPM{1}.Status(i,:) = [];
+
+ i = findrowindex(RemoveBPMDeviceList, BPM{2}.DeviceList);
+ BPM{2}.DeviceList(i,:) = [];
+ BPM{2}.Data(i,:) = [];
+ BPM{2}.Status(i,:) = [];
+
+
+ % Corrector orbit
+ setorbit('Golden', BPM, CM, Iters, Evectors, DisplayFlag, varargin{:});
+
+elseif PlaneFlag == 1
+
+ % Get BPM and CM structures
+ CM = getsp('HCM','struct');
+ BPM = getx('struct');
+
+
+ % Remove devices
+
+ % HCM
+ i = findrowindex(RemoveHCMDeviceList, CM.DeviceList);
+ CM.DeviceList(i,:) = [];
+ CM.Data(i,:) = [];
+ CM.Status(i,:) = [];
+
+ % BPMx
+ i = findrowindex(RemoveBPMDeviceList, BPM.DeviceList);
+ BPM.DeviceList(i,:) = [];
+ BPM.Data(i,:) = [];
+ BPM.Status(i,:) = [];
+
+
+ % Corrector orbit
+ setorbit('Golden', BPM, CM, Iters, Evectors, DisplayFlag, varargin{:});
+
+elseif PlaneFlag == 2
+
+ % Get BPM and CM structures
+ CM = getsp('VCM','struct');
+ BPM = gety('struct');
+
+
+ % Remove devices
+
+ % VCM
+ i = findrowindex(RemoveVCMDeviceList, CM.DeviceList);
+ CM.DeviceList(i,:) = [];
+ CM.Data(i,:) = [];
+ CM.Status(i,:) = [];
+
+ % BPMy
+ i = findrowindex(RemoveBPMDeviceList, BPM.DeviceList);
+ BPM.DeviceList(i,:) = [];
+ BPM.Data(i,:) = [];
+ BPM.Status(i,:) = [];
+
+
+ % Corrector orbit
+ setorbit('Golden', BPM, CM, Iters, Evectors, DisplayFlag, varargin{:});
+end
+
diff --git a/machine/ASP/StorageRing/setquad.m b/machine/ASP/StorageRing/setquad.m
index 6d990670..817e2bdc 100644
--- a/machine/ASP/StorageRing/setquad.m
+++ b/machine/ASP/StorageRing/setquad.m
@@ -1,26 +1,20 @@
-function setquad(QMS, QuadSetpoint, WaitFlag)
-%SETQUAD - Set quadrupole setpoint (used by quadcenter)
-% setquad(QMS, QuadSetpoint, WaitFlag)
-%
-% See also getquad, quadcenter
-
-
-if nargin < 2
- error('At least 2 inputs required');
-end
-if nargin < 3
- WaitFlag = -2;
-end
-
-QuadFamily = QMS.QuadFamily;
-QuadDev = QMS.QuadDev;
-
-Mode = getfamilydata(QuadFamily,'Setpoint','Mode');
-
-if strcmpi(Mode,'Simulator')
- % Simulator
- setsp(QuadFamily, QuadSetpoint, QuadDev, WaitFlag);
-else
- % Online
- setsp(QuadFamily, QuadSetpoint, QuadDev, WaitFlag);
-end
+function setquad(QMS, QuadSetpoint, WaitFlag)
+% setquad(QMS, QuadSetpoint, WaitFlag)
+% Used by quadcenter
+
+if nargin < 2
+ error('At least 2 inputs required');
+end
+if nargin < 3
+ WaitFlag = -2;
+end
+
+QuadFamily = QMS.QuadFamily;
+QuadDev = QMS.QuadDev;
+
+% if strcmpi(QuadFamily,'QFB')
+% del = QuadSetpoint-getsp(QuadFamily,QuadDev);
+% setsp(QuadFamily, getsp(QuadFamily,[QuadDev(1) 1; QuadDev(1) 2]) + del, [QuadDev(1) 1; QuadDev(1) 2], WaitFlag);
+% else
+ setsp(QuadFamily, QuadSetpoint, QuadDev, WaitFlag);
+% end
diff --git a/machine/ASP/StorageRing/sextcenter_manual.m b/machine/ASP/StorageRing/sextcenter_manual.m
new file mode 100644
index 00000000..0d7f3a1e
--- /dev/null
+++ b/machine/ASP/StorageRing/sextcenter_manual.m
@@ -0,0 +1,46 @@
+close all
+% 0 = both planes; 1 = x-plane; 2 = y-plane
+plane = 2;
+
+
+% Sector number for BPM
+for i=3
+ % BPM number within the sector
+ for j=3
+
+ BPMDev = [i j];
+
+% if getfamilydata('BPMx','Status',BPMDev) == 0
+% continue;
+% end
+
+ switch BPMDev(2)
+ case 1
+ quadfam = 'SFA';
+ quaddev = [BPMDev(1) 1];
+ case 2
+ quadfam = 'SDA';
+ quaddev = [BPMDev(1) 1];
+ case 3
+ quadfam = 'SDB';
+ quaddev = [BPMDev(1) 1];
+ case 4
+ quadfam = 'SFB';
+ quaddev = [BPMDev(1) 1];
+ case 5
+ quadfam = 'SDB';
+ quaddev = [BPMDev(1) 2];
+ case 6
+ quadfam = 'SDA';
+ quaddev = [BPMDev(1) 2];
+ case 7
+ quadfam = 'SFA';
+ quaddev = [BPMDev(1) 2];
+ end
+
+ quadcenter(quadfam,quaddev,plane,BPMDev);
+ end
+end
+
+beep
+return
diff --git a/machine/ASP/StorageRing/snap.m b/machine/ASP/StorageRing/snap.m
index 360f95ad..e39e569b 100644
--- a/machine/ASP/StorageRing/snap.m
+++ b/machine/ASP/StorageRing/snap.m
@@ -1,9 +1,12 @@
function [image_out] = snap(cam_name,varargin)
+
+error('snap is deprecated. Use getcameradata instead.');
+
% SNAP
%
-% Snaps an image from a CCD camera
-
-%function [cam_name] = snap(c)
+% Snaps an image from a CCD camera, specified by string c
+%
+%function [image] = snap(cam_name)
if nargin > 1 && strcmpi(varargin{1},'plot')
plotimage = 1;
@@ -17,65 +20,67 @@
-disp('starting snap')
+% disp('starting snap')
% open CA to camera PVs
-h1 = mcaopen([cam_name ':HEIGHT_MONITOR']);
-h2 = mcaopen([cam_name ':WIDTH_MONITOR']);
-h3 = mcaopen([cam_name ':DATA_MONITOR']);
-h4 = mcaopen([cam_name ':EUID_MONITOR']);
-h5 = mcaopen([cam_name ':ISO_STATUS']);
-h6 = mcaopen([cam_name ':COUNTER_MONITOR']);
-h7 = mcaopen([cam_name ':BPP_MONITOR']);
-h8 = mcaopen([cam_name ':TRIGGER_MODE_STATUS']);
-h9 = mcaopen([cam_name ':TRIGGER_ON_OFF_STATUS']);
-h10 = mcaopen([cam_name ':TRIGGER_DELAY_MONITOR']);
-h11 = mcaopen([cam_name ':FRAMERATE_STATUS']);
-h12 = mcaopen([cam_name ':MODE_STATUS']);
-h13 = mcaopen([cam_name ':SHUTTER_MONITOR']);
-h14 = mcaopen([cam_name ':SHUTTER_MODE_STATUS']);
-h15 = mcaopen([cam_name ':EXPOSURE_MONITOR']);
-h16 = mcaopen([cam_name ':EXPOSURE_MODE_STATUS']);
-h17 = mcaopen([cam_name ':GAIN_MONITOR']);
-h18 = mcaopen([cam_name ':GAIN_MODE_STATUS']);
-h19 = mcaopen([cam_name ':WOFFSET_MONITOR']);
-h20 = mcaopen([cam_name ':HOFFSET_MONITOR']);
-h21 = mcaopen([cam_name ':BRIGHTNESS_MONITOR']);
-h22 = mcaopen([cam_name ':BRIGHTNESS_MODE_STATUS']);
-%h23 = mcaopen([cam_name ':XP_MONITOR']);
-%h24 = mcaopen([cam_name ':YP_MONITOR']);
+h1 = getpv([cam_name ':HEIGHT_MONITOR']);
+h2 = getpv([cam_name ':WIDTH_MONITOR']);
+h3 = getpv([cam_name ':DATA_MONITOR']);
+h4 = getpv([cam_name ':EUID_MONITOR']);
+h5 = getpv([cam_name ':ISO_STATUS']);
+h6 = getpv([cam_name ':COUNTER_MONITOR']);
+h7 = getpv([cam_name ':BPP_MONITOR']);
+h8 = getpv([cam_name ':TRIGGER_MODE_STATUS']);
+h9 = getpv([cam_name ':TRIGGER_ON_OFF_STATUS']);
+h10 = getpv([cam_name ':TRIGGER_DELAY_MONITOR']);
+h11 = getpv([cam_name ':FRAMERATE_STATUS']);
+h12 = getpv([cam_name ':MODE_STATUS']);
+h13 = getpv([cam_name ':SHUTTER_MONITOR']);
+h14 = getpv([cam_name ':SHUTTER_MODE_STATUS']);
+h15 = getpv([cam_name ':EXPOSURE_MONITOR']);
+h16 = getpv([cam_name ':EXPOSURE_MODE_STATUS']);
+h17 = getpv([cam_name ':GAIN_MONITOR']);
+h18 = getpv([cam_name ':GAIN_MODE_STATUS']);
+h19 = getpv([cam_name ':WOFFSET_MONITOR']);
+h20 = getpv([cam_name ':HOFFSET_MONITOR']);
+h21 = getpv([cam_name ':BRIGHTNESS_MONITOR']);
+h22 = getpv([cam_name ':BRIGHTNESS_MODE_STATUS']);
+%h23 = getpv([cam_name ':XP_MONITOR']);
+%h24 = getpv([cam_name ':YP_MONITOR']);
% get the PV through CA
-height = mcaget(h1);
-width = mcaget(h2);
-iso_status = mcaget(h5);
+height = (h1);
+width = (h2);
+iso_status = (h5);
+% pre allocate memory
+data = zeros(1,786432);
if iso_status == 0
- mcaput(h5,1);
- data = mcaget(h3);
- mcaput(h5,0);
+ setpv([cam_name ':ISO_STATUS'],1);
+ data = h3;
+ setpv([cam_name ':ISO_STATUS'],0);
else
- data =mcaget(h3);
+ data =h3;
end
-euid = mcaget(h4);
-
-counter = mcaget(h6);
-BPP = mcaget(h7);
-trigger_mode = mcaget(h8);
-trigger_on_off = mcaget(h9);
-trigger_delay = mcaget(h10);
-framerate_status = mcaget(h11);
-mode1 = mcaget(h12);
-shutter_monitor = mcaget(h13);
-shutter_mode = mcaget(h14);
-exposure_monitor = mcaget(h15);
-exposure_mode = mcaget(h16);
-gain_monitor = mcaget(h17);
-gain_mode = mcaget(h18);
-WOFFSET = mcaget(h19);
-HOFFSET = mcaget(h20);
-brightness_monitor = mcaget(h21);
-brightness_mode = mcaget(h22);
-% XP = mcaget(h23);
-% YP = mcaget(h24);
+euid = h4;
+
+counter = h6;
+BPP = h7;
+trigger_mode = h8;
+trigger_on_off = h9;
+trigger_delay = h10;
+framerate_status = h11;
+mode1 = h12;
+shutter_monitor = h13;
+shutter_mode = h14;
+exposure_monitor = h15;
+exposure_mode = h16;
+gain_monitor = h17;
+gain_mode = h18;
+WOFFSET = h19;
+HOFFSET = h20;
+brightness_monitor = h21;
+brightness_mode = h22;
+% XP = h23;
+% YP = h24;
@@ -87,38 +92,13 @@
if plotimage
% intensity of RGB high
- figure(666);
+ figure(61);
% imagesc(x);
imagesc(x');
colormap gray;
end
-% close CA
-mcaclose(h1)
-mcaclose(h2)
-mcaclose(h3)
-mcaclose(h4)
-mcaclose(h5)
-mcaclose(h6)
-mcaclose(h7)
-mcaclose(h8)
-mcaclose(h9)
-mcaclose(h10)
-mcaclose(h11)
-mcaclose(h12)
-mcaclose(h13)
-mcaclose(h14)
-mcaclose(h15)
-mcaclose(h16)
-mcaclose(h17)
-mcaclose(h18)
-mcaclose(h19)
-mcaclose(h20)
-mcaclose(h21)
-mcaclose(h22)
-% mcaclose(h23)
-% mcaclose(h24)
@@ -162,4 +142,4 @@
% fprintf('***** Don''t believe everything you read. NaN. *****\n');
%end
-disp('snap finished')
+% disp('snap finished')
diff --git a/machine/ASP/StorageRing/srcycle.m b/machine/ASP/StorageRing/srcycle.m
deleted file mode 100644
index ec64613d..00000000
--- a/machine/ASP/StorageRing/srcycle.m
+++ /dev/null
@@ -1,271 +0,0 @@
-function srcycle(LatticeFile, DisplayFlag)
-%SRCYCLE - Standardize the storage ring magnets to the golden lattice
-%
-% INPUTS
-% 1. LatticeFile - No input - cycle to the present lattice {Default}
-% 'Golden' - cycle to the golden lattice
-% LatticeFilename - cycle to the ConfigSetpoint in that file
-% 2. 'Display' or 'NoDisplay' - to varify before standardizing and display results (or not)
-%
-% Written by Greg Portmann
-
-
-disp('!!! Do not use yet !!!');
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Input parsing and checking %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-LatticeFileDefault = 'Present'; % was 'Golden';
-if nargin < 1
- LatticeFile = LatticeFileDefault;
-end
-if nargin < 2
- DisplayFlag = 'Display';
-end
-if strcmpi(LatticeFile, 'Display') | strcmpi(LatticeFile, 'NoDisplay')
- DisplayFlag = LatticeFile;
- LatticeFile = LatticeFileDefault;
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get the proper lattice %
-%%%%%%%%%%%%%%%%%%%%%%%%%%
-if isempty(LatticeFile)
- [FileName, DirectoryName, FilterIndex] = uigetfile('*.mat', 'Select a Machine Configuration File for Standardization', getfamilydata('Directory', 'DataRoot'));
- if FilterIndex == 0
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Storage ring standardization cancelled\n');
- end
- return
- end
- try
- load([DirectoryName FileName]);
- Lattice = ConfigSetpoint;
- catch
- error(sprintf('Problem getting data from machine configuration file\n%s',lasterr));
- end
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the lattice file %s\n', [DirectoryName FileName]);
- end
-elseif strcmpi(LatticeFile, 'Present')
- % Present lattice
- Lattice = getmachineconfig;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the present lattice\n');
- end
-elseif strcmpi(LatticeFile, 'Golden')
- % Golden lattice
- FileName = getfamilydata('OpsData', 'LatticeFile');
- DirectoryName = getfamilydata('Directory', 'OpsData');
- load([DirectoryName FileName]);
-
- Lattice = ConfigSetpoint;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the golden lattice %s\n', [DirectoryName FileName]);
- end
-elseif ischar(LatticeFile)
- load(LatticeFile);
- Lattice = ConfigSetpoint;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to lattice file %s\n', LatticeFile);
- end
-else
- error('Not sure what lattice to cycle to!');
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Query to begin measurement %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-if strcmpi(DisplayFlag, 'Display')
- tmp = questdlg('Begin storage ring standardization?','SRCYCLE','Yes','No','No');
- if strcmpi(tmp,'No')
- fprintf(' Lattice standardization cancelled\n');
- return
- end
-end
-
-% Number of cycles
-N = 2;
-
-% Set everything to zero
-% famlist = {'BEND','QFA','QFB','QDA','SFA','SDA','SFB','SDB'};
-% famlist = {'QDA','QFA','QFB'};
-famlist = {};
-
-for i=1:length(famlist)
- range = getfamilydata(famlist{i},'Setpoint','Range');
-
- uppersetpoint.(famlist{i}) = Lattice.(famlist{i});
- uppersetpoint.(famlist{i}).Setpoint.Data = range(:,2);
-
- lowersetpoint.(famlist{i}) = Lattice.(famlist{i});
- lowersetpoint.(famlist{i}).Setpoint.Data(:) = range(:,1);
-
- nominal.(famlist{i}) = Lattice.(famlist{i});
-end
-
-% Different for BEND, need to set to upper limit and turn on and off
-% the supply to cycle the magent. Will have to montior the readback to
-% see if it has reached the maximum and if its turned completely off.
-
-% Dipole on off command handle
-dipole_handle = mcaopen('SR00DPS01:OFF_ON_CMD');
-
-% Nominal
-dipole_nomsp = Lattice.BEND.Setpoint.Data(1,1);
-
-% Get dipole upper setpoint
-temp = getfamilydata('BEND','Setpoint','Range',[1 1]);
-dipole_uppersp = temp(2);
-
-try
- % Turn off the dipole and check its off.
- dipolewaitoff(dipole_handle);
-
- % Wait flag of -1 will wait for the ramp to complete.
- for j=1:N
- disp('Turning ON dipole');
- dipoleturnon(dipole_handle, dipole_uppersp);
- if exist('lowersetpoint','var')
- disp('Turning ON all other multipoles');
- setmachineconfig(lowersetpoint, -1);
- end
- pause(1);
-
- disp('Turning OFF dipole');
- dipolewaitoff(dipole_handle);
- if exist('lowersetpoint','var')
- disp('Turning OFF all other multipoles');
- setmachineconfig(uppersetpoint, -1);
- end
- pause(1);
- end
-
-
- % Make sure all the setpoints are there
- dipoleturnon(dipole_handle, dipole_nomsp);
- if exist('nominal','var')
- setmachineconfig(nominal, -1);
- end
-
-catch
- disp(lasterr)
- disp('Error');
- mcaclose(dipole_handle);
- return
-end
-
-mcaclose(dipole_handle);
-
-if strcmpi(DisplayFlag, 'Display')
- fprintf(' Storage ring standardization complete\n');
-end
-
-
-
-function dipolewaitoff(dipole_handle)
-% Two step process go to 50 amps first then wait before going to 0.1 amps.
-DEBUG = 1;
-
-% Generate normalised curve with 101 points
-% curve =[ 0.0000000 0.0004501 0.0009766 0.0015905 0.0023039 ...
-% 0.0031305 0.0040851 0.0051840 0.0064449 0.0078871 ...
-% 0.0095315 0.0114004 0.0135176 0.0159085 0.0185999 ...
-% 0.0216197 0.0249973 0.0287631 0.0329482 0.0375843 ...
-% 0.0427039 0.0483391 0.0545222 0.0612847 0.0686573 ...
-% 0.0766694 0.0853485 0.0947203 0.1048077 0.1156307 ...
-% 0.1272057 0.1395455 0.1526587 0.1665491 0.1812159 ...
-% 0.1966530 0.2128489 0.2297867 0.2474438 0.2657919 ...
-% 0.2847972 0.3044203 0.3246166 0.3453365 0.3665256 ...
-% 0.3881254 0.4100734 0.4323042 0.4547493 0.4773384 ...
-% 0.5000000 0.5226616 0.5452507 0.5676958 0.5899266 ...
-% 0.6118746 0.6334744 0.6546635 0.6753834 0.6955797 ...
-% 0.7152028 0.7342081 0.7525562 0.7702133 0.7871511 ...
-% 0.8033470 0.8187841 0.8334509 0.8473413 0.8604545 ...
-% 0.8727943 0.8843693 0.8951923 0.9052797 0.9146515 ...
-% 0.9233306 0.9313427 0.9387153 0.9454778 0.9516609 ...
-% 0.9572961 0.9624157 0.9670518 0.9712369 0.9750027 ...
-% 0.9783803 0.9814001 0.9840915 0.9864824 0.9885996 ...
-% 0.9904685 0.9921129 0.9935551 0.9948160 0.9959149 ...
-% 0.9968695 0.9976961 0.9984095 0.9990234 0.9995499 1.0000000];
-x = 0:0.01:1;
-curve = (erf(3*x-1.5)/max(abs(erf(3*x-1.5))) + 1)./2;
-offcurve = curve(end:-1:1);
-
-% Current dipvalue
-dipval = getam('BEND',[1,1]);
-% Dipole PS tolerance
-tol = 0.2; %getfamilydata('BEND','Setpoint','Tolerance',[1 1]);
-
-if DEBUG; saveval = []; end
-
-setvals = offcurve.*dipval;
-j = 1; j_previous = 1;
-for i=1:length(setvals)
- setsp('BEND',setvals(i),[1,1]);
-
- % 10 Second limit
- while abs(dipval - setvals(i)) > tol && j < j_previous + 20
- pause(0.5);
- dipval = getam('BEND',[1,1]);
-
- if DEBUG; saveval(j) = dipval; end
-
- j = j + 1;
-% if j > 21 && std(saveval(end-20)) < 0.0
-% if DEBUG; figure; plot(saveval); end;
-% error('Dipole didn'' seem to reach desired current!');
-% end
- end
- j_previous = j;
-end
-% Additional wait of 2 seconds to wait till current regulates to final
-% value.
-pause(2);
-
-if DEBUG; figure; plot(saveval); end;
-
-
-
-function dipoleturnon(dipole_handle, val)
-DEBUG = 1;
-
-x = 0:0.01:1;
-curve = (erf(3*x-1.5)/max(abs(erf(3*x-1.5))) + 1)./2;
-
-tol = 0.3; %getfamilydata('BEND','Setpoint','Tolerance',[1,1]);
-dipval = getam('BEND',[1,1]);
-
-if DEBUG; saveval = []; end
-
-setvals = curve.*val;
-temp = find(setvals > dipval);
-starti = (1);
-
-
-j = 1; j_previous = 1;
-for i=starti:length(setvals)
- setsp('BEND',setvals(i),[1,1]);
-
- while abs(dipval - setvals(i)) > tol && j < j_previous+20
- pause(0.5);
- dipval = getam('BEND',[1,1]);
-
- if DEBUG; saveval(j) = dipval; end
-
- j = j + 1;
-% if j > 20 && std(saveval(end-20)) < 0.0
-% if DEBUG; figure; plot(saveval); end;
-% error('Dipole didn'' seem to reach desired current!');
-% end
- end
- j_previous = j;
-end
-% Additional wait of 2 seconds to wait till current regulates to final
-% value.
-pause(2);
-
-if DEBUG; figure; plot(saveval); end;
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/srcycle_qda.m b/machine/ASP/StorageRing/srcycle_qda.m
deleted file mode 100644
index 06fbe446..00000000
--- a/machine/ASP/StorageRing/srcycle_qda.m
+++ /dev/null
@@ -1,145 +0,0 @@
-function srcycle(LatticeFile, DisplayFlag)
-%SRCYCLE - Standardize the storage ring magnets to the golden lattice
-%
-% INPUTS
-% 1. LatticeFile - No input - cycle to the present lattice {Default}
-% 'Golden' - cycle to the golden lattice
-% LatticeFilename - cycle to the ConfigSetpoint in that file
-% 2. 'Display' or 'NoDisplay' - to varify before standardizing and display results (or not)
-%
-% Written by Greg Portmann
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Input parsing and checking %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-LatticeFileDefault = 'Present'; % was 'Golden';
-if nargin < 1
- LatticeFile = LatticeFileDefault;
-end
-if nargin < 2
- DisplayFlag = 'Display';
-end
-if strcmpi(LatticeFile, 'Display') | strcmpi(LatticeFile, 'NoDisplay')
- DisplayFlag = LatticeFile;
- LatticeFile = LatticeFileDefault;
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get the proper lattice %
-%%%%%%%%%%%%%%%%%%%%%%%%%%
-if isempty(LatticeFile)
- [FileName, DirectoryName, FilterIndex] = uigetfile('*.mat', 'Select a Machine Configuration File for Standardization', getfamilydata('Directory', 'DataRoot'));
- if FilterIndex == 0
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Storage ring standardization cancelled\n');
- end
- return
- end
- try
- load([DirectoryName FileName]);
- Lattice = ConfigSetpoint;
- catch
- error(sprintf('Problem getting data from machine configuration file\n%s',lasterr));
- end
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the lattice file %s\n', [DirectoryName FileName]);
- end
-elseif strcmpi(LatticeFile, 'Present')
- % Present lattice
- Lattice = getmachineconfig;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the present lattice\n');
- end
-elseif strcmpi(LatticeFile, 'Golden')
- % Golden lattice
- FileName = getfamilydata('OpsData', 'LatticeFile');
- DirectoryName = getfamilydata('Directory', 'OpsData');
- load([DirectoryName FileName]);
-
- Lattice = ConfigSetpoint;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the golden lattice %s\n', [DirectoryName FileName]);
- end
-elseif ischar(LatticeFile)
- load(LatticeFile);
- Lattice = ConfigSetpoint;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to lattice file %s\n', LatticeFile);
- end
-else
- error('Not sure what lattice to cycle to!');
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Query to begin measurement %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-if strcmpi(DisplayFlag, 'Display')
- tmp = questdlg('Begin storage ring standardization?','SRCYCLE','Yes','No','No');
- if strcmpi(tmp,'No')
- fprintf(' Lattice standardization cancelled\n');
- return
- end
-end
-
-% Number of cycles
-N = 1;
-
-% Set everything to zero
-% famlist = {'BEND','QFA','QFB','QDA','SFA','SDA','SFB','SDB'};
-% famlist = {'QDA','QFA','QFB'};
-famlist = {'QDA'};
-
-for i=1:length(famlist)
- range = getfamilydata(famlist{i},'Setpoint','Range');
-
- uppersetpoint.(famlist{i}) = Lattice.(famlist{i});
- switch uppersetpoint.(famlist{i}).Setpoint.Units
- case 'Physics'
- uppersetpoint.(famlist{i}).Setpoint.Data = hw2physics(famlist{i},'Setpoint',range(:,2),uppersetpoint.(famlist{i}).Setpoint.DeviceList);
- case 'Hardware'
- uppersetpoint.(famlist{i}).Setpoint.Data = range(:,2);
- end
-
- lowersetpoint.(famlist{i}) = Lattice.(famlist{i});
- switch lowersetpoint.(famlist{i}).Setpoint.Units
- case 'Physics'
- lowersetpoint.(famlist{i}).Setpoint.Data = hw2physics(famlist{i},'Setpoint',range(:,1),uppersetpoint.(famlist{i}).Setpoint.DeviceList);
- case 'Hardware'
- lowersetpoint.(famlist{i}).Setpoint.Data = range(:,1);
- end
-
- nominal.(famlist{i}) = Lattice.(famlist{i});
-end
-
-try
- % Wait flag of -1 will wait for the ramp to complete.
- for j=1:N
- if exist('lowersetpoint','var')
- disp('Turning ON all other multipoles');
- setmachineconfig(lowersetpoint, -1);
- end
- pause(10);
-
- if exist('lowersetpoint','var')
- disp('Turning OFF all other multipoles');
- setmachineconfig(uppersetpoint, -1);
- end
- pause(20);
- end
-
- if exist('nominal','var')
- setmachineconfig(nominal, -1);
- end
-
-catch
- disp(lasterr)
- disp('Error');
- return
-end
-
-if strcmpi(DisplayFlag, 'Display')
- fprintf(' Storage ring standardization complete\n');
-end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/srcycle_qfa.m b/machine/ASP/StorageRing/srcycle_qfa.m
deleted file mode 100644
index d6dd74ed..00000000
--- a/machine/ASP/StorageRing/srcycle_qfa.m
+++ /dev/null
@@ -1,145 +0,0 @@
-function srcycle(LatticeFile, DisplayFlag)
-%SRCYCLE - Standardize the storage ring magnets to the golden lattice
-%
-% INPUTS
-% 1. LatticeFile - No input - cycle to the present lattice {Default}
-% 'Golden' - cycle to the golden lattice
-% LatticeFilename - cycle to the ConfigSetpoint in that file
-% 2. 'Display' or 'NoDisplay' - to varify before standardizing and display results (or not)
-%
-% Written by Greg Portmann
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Input parsing and checking %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-LatticeFileDefault = 'Present'; % was 'Golden';
-if nargin < 1
- LatticeFile = LatticeFileDefault;
-end
-if nargin < 2
- DisplayFlag = 'Display';
-end
-if strcmpi(LatticeFile, 'Display') | strcmpi(LatticeFile, 'NoDisplay')
- DisplayFlag = LatticeFile;
- LatticeFile = LatticeFileDefault;
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get the proper lattice %
-%%%%%%%%%%%%%%%%%%%%%%%%%%
-if isempty(LatticeFile)
- [FileName, DirectoryName, FilterIndex] = uigetfile('*.mat', 'Select a Machine Configuration File for Standardization', getfamilydata('Directory', 'DataRoot'));
- if FilterIndex == 0
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Storage ring standardization cancelled\n');
- end
- return
- end
- try
- load([DirectoryName FileName]);
- Lattice = ConfigSetpoint;
- catch
- error(sprintf('Problem getting data from machine configuration file\n%s',lasterr));
- end
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the lattice file %s\n', [DirectoryName FileName]);
- end
-elseif strcmpi(LatticeFile, 'Present')
- % Present lattice
- Lattice = getmachineconfig;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the present lattice\n');
- end
-elseif strcmpi(LatticeFile, 'Golden')
- % Golden lattice
- FileName = getfamilydata('OpsData', 'LatticeFile');
- DirectoryName = getfamilydata('Directory', 'OpsData');
- load([DirectoryName FileName]);
-
- Lattice = ConfigSetpoint;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the golden lattice %s\n', [DirectoryName FileName]);
- end
-elseif ischar(LatticeFile)
- load(LatticeFile);
- Lattice = ConfigSetpoint;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to lattice file %s\n', LatticeFile);
- end
-else
- error('Not sure what lattice to cycle to!');
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Query to begin measurement %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-if strcmpi(DisplayFlag, 'Display')
- tmp = questdlg('Begin storage ring standardization?','SRCYCLE','Yes','No','No');
- if strcmpi(tmp,'No')
- fprintf(' Lattice standardization cancelled\n');
- return
- end
-end
-
-% Number of cycles
-N = 1;
-
-% Set everything to zero
-% famlist = {'BEND','QFA','QFB','QDA','SFA','SDA','SFB','SDB'};
-% famlist = {'QDA','QFA','QFB'};
-famlist = {'QFA'};
-
-for i=1:length(famlist)
- range = getfamilydata(famlist{i},'Setpoint','Range');
-
- uppersetpoint.(famlist{i}) = Lattice.(famlist{i});
- switch uppersetpoint.(famlist{i}).Setpoint.Units
- case 'Physics'
- uppersetpoint.(famlist{i}).Setpoint.Data = hw2physics(famlist{i},'Setpoint',range(:,2),uppersetpoint.(famlist{i}).Setpoint.DeviceList);
- case 'Hardware'
- uppersetpoint.(famlist{i}).Setpoint.Data = range(:,2);
- end
-
- lowersetpoint.(famlist{i}) = Lattice.(famlist{i});
- switch lowersetpoint.(famlist{i}).Setpoint.Units
- case 'Physics'
- lowersetpoint.(famlist{i}).Setpoint.Data = hw2physics(famlist{i},'Setpoint',range(:,1),uppersetpoint.(famlist{i}).Setpoint.DeviceList);
- case 'Hardware'
- lowersetpoint.(famlist{i}).Setpoint.Data = range(:,1);
- end
-
- nominal.(famlist{i}) = Lattice.(famlist{i});
-end
-
-try
- % Wait flag of -1 will wait for the ramp to complete.
- for j=1:N
- if exist('lowersetpoint','var')
- disp('Turning ON all other multipoles');
- setmachineconfig(lowersetpoint, -1);
- end
- pause(10);
-
- if exist('lowersetpoint','var')
- disp('Turning OFF all other multipoles');
- setmachineconfig(uppersetpoint, -1);
- end
- pause(20);
- end
-
- if exist('nominal','var')
- setmachineconfig(nominal, -1);
- end
-
-catch
- disp(lasterr)
- disp('Error');
- return
-end
-
-if strcmpi(DisplayFlag, 'Display')
- fprintf(' Storage ring standardization complete\n');
-end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/srcycle_qfb.m b/machine/ASP/StorageRing/srcycle_qfb.m
deleted file mode 100644
index 54e462d6..00000000
--- a/machine/ASP/StorageRing/srcycle_qfb.m
+++ /dev/null
@@ -1,145 +0,0 @@
-function srcycle(LatticeFile, DisplayFlag)
-%SRCYCLE - Standardize the storage ring magnets to the golden lattice
-%
-% INPUTS
-% 1. LatticeFile - No input - cycle to the present lattice {Default}
-% 'Golden' - cycle to the golden lattice
-% LatticeFilename - cycle to the ConfigSetpoint in that file
-% 2. 'Display' or 'NoDisplay' - to varify before standardizing and display results (or not)
-%
-% Written by Greg Portmann
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Input parsing and checking %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-LatticeFileDefault = 'Present'; % was 'Golden';
-if nargin < 1
- LatticeFile = LatticeFileDefault;
-end
-if nargin < 2
- DisplayFlag = 'Display';
-end
-if strcmpi(LatticeFile, 'Display') | strcmpi(LatticeFile, 'NoDisplay')
- DisplayFlag = LatticeFile;
- LatticeFile = LatticeFileDefault;
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get the proper lattice %
-%%%%%%%%%%%%%%%%%%%%%%%%%%
-if isempty(LatticeFile)
- [FileName, DirectoryName, FilterIndex] = uigetfile('*.mat', 'Select a Machine Configuration File for Standardization', getfamilydata('Directory', 'DataRoot'));
- if FilterIndex == 0
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Storage ring standardization cancelled\n');
- end
- return
- end
- try
- load([DirectoryName FileName]);
- Lattice = ConfigSetpoint;
- catch
- error(sprintf('Problem getting data from machine configuration file\n%s',lasterr));
- end
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the lattice file %s\n', [DirectoryName FileName]);
- end
-elseif strcmpi(LatticeFile, 'Present')
- % Present lattice
- Lattice = getmachineconfig;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the present lattice\n');
- end
-elseif strcmpi(LatticeFile, 'Golden')
- % Golden lattice
- FileName = getfamilydata('OpsData', 'LatticeFile');
- DirectoryName = getfamilydata('Directory', 'OpsData');
- load([DirectoryName FileName]);
-
- Lattice = ConfigSetpoint;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the golden lattice %s\n', [DirectoryName FileName]);
- end
-elseif ischar(LatticeFile)
- load(LatticeFile);
- Lattice = ConfigSetpoint;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to lattice file %s\n', LatticeFile);
- end
-else
- error('Not sure what lattice to cycle to!');
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Query to begin measurement %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-if strcmpi(DisplayFlag, 'Display')
- tmp = questdlg('Begin storage ring standardization?','SRCYCLE','Yes','No','No');
- if strcmpi(tmp,'No')
- fprintf(' Lattice standardization cancelled\n');
- return
- end
-end
-
-% Number of cycles
-N = 1;
-
-% Set everything to zero
-% famlist = {'BEND','QFA','QFB','QDA','SFA','SDA','SFB','SDB'};
-% famlist = {'QDA','QFA','QFB'};
-famlist = {'QFB'};
-
-for i=1:length(famlist)
- range = getfamilydata(famlist{i},'Setpoint','Range');
-
- uppersetpoint.(famlist{i}) = Lattice.(famlist{i});
- switch uppersetpoint.(famlist{i}).Setpoint.Units
- case 'Physics'
- uppersetpoint.(famlist{i}).Setpoint.Data = hw2physics(famlist{i},'Setpoint',range(:,2),uppersetpoint.(famlist{i}).Setpoint.DeviceList);
- case 'Hardware'
- uppersetpoint.(famlist{i}).Setpoint.Data = range(:,2);
- end
-
- lowersetpoint.(famlist{i}) = Lattice.(famlist{i});
- switch lowersetpoint.(famlist{i}).Setpoint.Units
- case 'Physics'
- lowersetpoint.(famlist{i}).Setpoint.Data = hw2physics(famlist{i},'Setpoint',range(:,1),uppersetpoint.(famlist{i}).Setpoint.DeviceList);
- case 'Hardware'
- lowersetpoint.(famlist{i}).Setpoint.Data = range(:,1);
- end
-
- nominal.(famlist{i}) = Lattice.(famlist{i});
-end
-
-try
- % Wait flag of -1 will wait for the ramp to complete.
- for j=1:N
- if exist('lowersetpoint','var')
- disp('Turning ON all other multipoles');
- setmachineconfig(lowersetpoint, -1);
- end
- pause(10);
-
- if exist('lowersetpoint','var')
- disp('Turning OFF all other multipoles');
- setmachineconfig(uppersetpoint, -1);
- end
- pause(20);
- end
-
- if exist('nominal','var')
- setmachineconfig(nominal, -1);
- end
-
-catch
- disp(lasterr)
- disp('Error');
- return
-end
-
-if strcmpi(DisplayFlag, 'Display')
- fprintf(' Storage ring standardization complete\n');
-end
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/srcycle_quads.m b/machine/ASP/StorageRing/srcycle_quads.m
deleted file mode 100644
index 0f186bee..00000000
--- a/machine/ASP/StorageRing/srcycle_quads.m
+++ /dev/null
@@ -1,211 +0,0 @@
-function srcycle(LatticeFile, DisplayFlag)
-%SRCYCLE - Standardize the storage ring magnets to the golden lattice
-%
-% INPUTS
-% 1. LatticeFile - No input - cycle to the present lattice {Default}
-% 'Golden' - cycle to the golden lattice
-% LatticeFilename - cycle to the ConfigSetpoint in that file
-% 2. 'Display' or 'NoDisplay' - to varify before standardizing and display results (or not)
-%
-% Written by Greg Portmann
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Input parsing and checking %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-LatticeFileDefault = 'Present'; % was 'Golden';
-if nargin < 1
- LatticeFile = LatticeFileDefault;
-end
-if nargin < 2
- DisplayFlag = 'Display';
-end
-if strcmpi(LatticeFile, 'Display') | strcmpi(LatticeFile, 'NoDisplay')
- DisplayFlag = LatticeFile;
- LatticeFile = LatticeFileDefault;
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get the proper lattice %
-%%%%%%%%%%%%%%%%%%%%%%%%%%
-if isempty(LatticeFile)
- [FileName, DirectoryName, FilterIndex] = uigetfile('*.mat', 'Select a Machine Configuration File for Standardization', getfamilydata('Directory', 'DataRoot'));
- if FilterIndex == 0
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Storage ring standardization cancelled\n');
- end
- return
- end
- try
- load([DirectoryName FileName]);
- Lattice = ConfigSetpoint;
- catch
- error(sprintf('Problem getting data from machine configuration file\n%s',lasterr));
- end
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the lattice file %s\n', [DirectoryName FileName]);
- end
-elseif strcmpi(LatticeFile, 'Present')
- % Present lattice
- Lattice = getmachineconfig;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the present lattice\n');
- end
-elseif strcmpi(LatticeFile, 'Golden')
- % Golden lattice
- FileName = getfamilydata('OpsData', 'LatticeFile');
- DirectoryName = getfamilydata('Directory', 'OpsData');
- load([DirectoryName FileName]);
-
- Lattice = ConfigSetpoint;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to the golden lattice %s\n', [DirectoryName FileName]);
- end
-elseif ischar(LatticeFile)
- load(LatticeFile);
- Lattice = ConfigSetpoint;
- if strcmpi(DisplayFlag, 'Display')
- fprintf(' Standardizing to lattice file %s\n', LatticeFile);
- end
-else
- error('Not sure what lattice to cycle to!');
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Query to begin measurement %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-if strcmpi(DisplayFlag, 'Display')
- tmp = questdlg('Begin storage ring standardization?','SRCYCLE','Yes','No','No');
- if strcmpi(tmp,'No')
- fprintf(' Lattice standardization cancelled\n');
- return
- end
-end
-
-% Number of cycles
-N = 2;
-
-% Set everything to zero
-% famlist = {'BEND','QFA','QFB','QDA','SFA','SDA','SFB','SDB'};
-% famlist = {'QDA','QFA','QFB'};
-famlist = {'QDA','QFA', 'QFB','SFA','SDA','SFB','SDB'};
-
-for i=1:length(famlist)
- range = getfamilydata(famlist{i},'Setpoint','Range',getlist(famlist{i}));
-
- uppersetpoint.(famlist{i}) = Lattice.(famlist{i});
- switch uppersetpoint.(famlist{i}).Setpoint.Units
- case 'Physics'
- uppersetpoint.(famlist{i}).Setpoint.Data = hw2physics(famlist{i},'Setpoint',range(:,2),uppersetpoint.(famlist{i}).Setpoint.DeviceList);
- case 'Hardware'
- uppersetpoint.(famlist{i}).Setpoint.Data = range(:,2);
- end
-
- lowersetpoint.(famlist{i}) = Lattice.(famlist{i});
- switch lowersetpoint.(famlist{i}).Setpoint.Units
- case 'Physics'
- lowersetpoint.(famlist{i}).Setpoint.Data = hw2physics(famlist{i},'Setpoint',range(:,1),uppersetpoint.(famlist{i}).Setpoint.DeviceList);
- case 'Hardware'
- lowersetpoint.(famlist{i}).Setpoint.Data = range(:,1);
- end
-
- nominal.(famlist{i}) = Lattice.(famlist{i});
-end
-
-try
- % Wait flag of -1 will wait for the ramp to complete.
- for j=1:N
- if exist('lowersetpoint','var')
- disp('Setting lower setpoint');
- if local_setmachineconfig(lowersetpoint, 25)
- % error occured
- break;
- end
- end
- pause(5);
-
- if exist('lowersetpoint','var')
- disp('Setting upper setpoint');
- if local_setmachineconfig(uppersetpoint, 40)
- % error occured
- break;
- end
- end
- pause(5);
- end
-
- if exist('nominal','var')
- disp('Setting NOMINAL');
- local_setmachineconfig(nominal, 5);
- end
-
-catch
- disp(lasterr)
- disp('Error');
- return
-end
-
-if strcmpi(DisplayFlag, 'Display')
- fprintf(' Storage ring standardization complete\n');
-end
-
-
-
-function err = local_setmachineconfig(config, varargin)
-
-err = 0;
-WaitFlag = 0;
-Time = 10; % Default of 10 seconds to achieve goal
-N = 2;
-
-if nargin > 1
- Time = varargin{1};
-end
-
-if nargin > 2
- WaitFlag = varargin{2};
-end
-
-
-families = fieldnames(config)';
-
-for i=1:length(families)
- units = config.(families{i}).Setpoint.Units;
-
- % getcurrent values Assuming setpoint available
- if isfield(config.(families{i}),'Setpoint')
- devicelists{1,i} = config.(families{i}).Setpoint.DeviceList;
-
- curr = getpv(config.(families{i}).Setpoint);
- delta = config.(families{i}).Setpoint.Data - curr.Data;
- for j=1:N
- data(j).newvals{1,i} = curr.Data + delta.*(j/N);
- end
- else
- fprintf('Warning: No setpoint field found for family %s\n',families{i});
- return;
- end
-end
-
-for j=1:N
- try
- setpv(families,'Setpoint',data(j).newvals,devicelists,units,-1);
- catch
- disp(lasterr);
- disp('Will try again...');
- try
- % Wait some time before trying again.
- pause(10);
- setpv(families,'Setpoint',data(j).newvals,devicelists,units,-1);
- disp('... successful second attempt');
- catch
- disp(lasterr);
- disp('Still did not work... maybe something wrong. Will put setpoints back to initial values.');
- err = 1;
- end
- end
-end
-
-pause(0);
\ No newline at end of file
diff --git a/machine/ASP/StorageRing/storagering_inject_store.m b/machine/ASP/StorageRing/storagering_inject_store.m
index 0ea1657f..c0097a7e 100644
--- a/machine/ASP/StorageRing/storagering_inject_store.m
+++ b/machine/ASP/StorageRing/storagering_inject_store.m
@@ -1,12 +1,15 @@
% A simple method to set the sextupoles in the storage ring for injecting
% or storing beam. To inject select "i" and to store select "s". Easy.
-
+% Update: just press 'y' and 'y' to change state
+disp('THIS IS NO LONGER NECESSARY')
+return;
disp(' ');
disp('You are about to Change Sextupoles for Storing or Injecting.');
disp('ARE YOU SURE THAT YOU WANT TO CONTINUE?? ');
answer = input('[y/n]: ','s');
+answer = 'n';
if ~strcmp(answer,'y')
error('... , goodbye.');
return
diff --git a/machine/ASP/StorageRing/track_tunes.m b/machine/ASP/StorageRing/track_tunes.m
index 0cc96310..3d8d5c38 100644
--- a/machine/ASP/StorageRing/track_tunes.m
+++ b/machine/ASP/StorageRing/track_tunes.m
@@ -1,9 +1,24 @@
function track_tunes(current_tunes,fixtunes2,varargin)
-
+% track_tunes([curr_tunes curr_disp],[want_tunes want_disp],[calc_J,'increment'])
+%
+% Example: track_tunes([0.31 0.24 0.1],[0.290 0.216 0.1])
+% track_tunes([0.31 0.24 0.1],[0.290 0.216 0.1],1,'increment');
+%
+% The value calc_J asks track_tunes to calculate the jacobian from the
+% loaded model. Default is to calculate.
+
+calc_from_model = 1;
increment = 0;
-if nargin > 2 && ischar(varargin{1}) && strcmpi(varargin{1},'increment')
+if nargin > 3 && ischar(varargin{2}) && strcmpi(varargin{2},'increment')
increment = 1;
end
+if nargin > 2 && isnumeric(varargin{1})
+ calc_from_model = varargin{1};
+end
+
+if length(current_tunes) ~= 3 && length(fixtunes2) ~= 3
+ error('TRACK_TUNES requires 3 values [xtune ytune disp]');
+end
% xtune_pv = 'CR01:GENERAL_ANALOG_02_MONITOR';
% xtune_handle = mcacheckopen(xtune_pv);
@@ -21,26 +36,117 @@ function track_tunes(current_tunes,fixtunes2,varargin)
% current_tunes = [mcaget(xtune_handle) mcaget(ytune_handle) 0];
% current_tunes = [0.2913 0.2145 0.00];
% current_tunes = [getam('TUNE')' 0];
-delta_nu = fixtunes2 - current_tunes;
-delta_nu(3) = 0;
+delta_nu = fixtunes2(1:2) - current_tunes(1:2);
+delta_nu(3) = fixtunes2(3) - current_tunes(3);
% fprintf('\n Current fractional tunes are: [%6.3f %6.3f] dispersion = %6.7f\n', current_tunes);
% fprintf(' Delta fractional tunes are: [%6.3f %6.3f] dispersion = %6.7f\n', delta_nu);
-% Inverse Jacobian measured using the model.
-Jinv = [...
- 0.130094898781898,0.000379003570963,0.100529311940219;...
- -0.105532343683691,-0.139777190998969,-0.004112213885454;...
- 0.022078330803986,0.029242080859334,-0.054916466546098;];
-
-% Order QFA QDA QFB
-initk = [1.7619022 -1.0859714 1.5444376]';
+if calc_from_model
+ global THERING;
+ delta = 1e-6;
+ quadfam1 = 'QFA';
+ quadfam2 = 'QDA';
+ quadfam3 = 'QFB';
+ % Fit the model
+ fittunedisp2(current_tunes+[13 5 0],'QFA','QDA','QFB',1)
+
+ % find indexes of the 2 quadrupole families use for fitting
+ Q1I = findcells(THERING,'FamName',quadfam1);
+ if isempty(Q1I); fprintf('Cannot find quadfamily: %s\n',quadfam1); return; end;
+ Q2I = findcells(THERING,'FamName',quadfam2);
+ if isempty(Q2I); fprintf('Cannot find quadfamily: %s\n',quadfam2); return; end;
+ Q3I = findcells(THERING,'FamName',quadfam3);
+ if isempty(Q3I); fprintf('Cannot find quadfamily: %s\n',quadfam3); return; end;
+
+
+ InitialK1 = getcellstruct(THERING,'K',Q1I);
+ InitialK2 = getcellstruct(THERING,'K',Q2I);
+ InitialK3 = getcellstruct(THERING,'K',Q3I);
+ InitialPolB1 = getcellstruct(THERING,'PolynomB',Q1I,2);
+ InitialPolB2 = getcellstruct(THERING,'PolynomB',Q2I,2);
+ InitialPolB3 = getcellstruct(THERING,'PolynomB',Q3I,2);
+
+ % Compute initial tunes before fitting
+ % [ LD, InitialTunes] = linopt(THERING,0);
+ mach = machine_at;
+ TempTunes = [mach.nux(end);mach.nuy(end)];
+ TempDisp = mach.etax(1);
+ TempK1 = InitialK1;
+ TempK2 = InitialK2;
+ TempK3 = InitialK3;
+ TempPolB1 = InitialPolB1;
+ TempPolB2 = InitialPolB2;
+ TempPolB3 = InitialPolB3;
+
+ disp('Calculating Jacobian from current model');
+ fprintf('Tunes and Dispersion: %14.10f (H) %14.10f (V) %14.10f (D)\n',...
+ TempTunes(1),TempTunes(2),TempDisp);
+
+ % Take Derivative
+ THERING = setcellstruct(THERING,'K',Q1I,TempK1+delta);
+ THERING = setcellstruct(THERING,'PolynomB',Q1I,TempPolB1+delta,2);
+ mach = machine_at;
+ Tunes_dK1 = [mach.nux(end);mach.nuy(end)];
+ Disp_dK1 = mach.etax(1);
+ THERING = setcellstruct(THERING,'K',Q1I,TempK1);
+ THERING = setcellstruct(THERING,'PolynomB',Q1I,TempPolB1,2);
+
+ THERING = setcellstruct(THERING,'K',Q2I,TempK2+delta);
+ THERING = setcellstruct(THERING,'PolynomB',Q2I,TempPolB2+delta,2);
+ mach = machine_at;
+ Tunes_dK2 = [mach.nux(end);mach.nuy(end)];
+ Disp_dK2 = mach.etax(1);
+ THERING = setcellstruct(THERING,'K',Q2I,TempK2);
+ THERING = setcellstruct(THERING,'PolynomB',Q2I,TempPolB2,2);
+
+ THERING = setcellstruct(THERING,'K',Q3I,TempK3+delta);
+ THERING = setcellstruct(THERING,'PolynomB',Q3I,TempPolB3+delta,2);
+ mach = machine_at;
+ Tunes_dK3 = [mach.nux(end);mach.nuy(end)];
+ Disp_dK3 = mach.etax(1);
+ THERING = setcellstruct(THERING,'K',Q3I,TempK3);
+ THERING = setcellstruct(THERING,'PolynomB',Q3I,TempPolB3,2);
+
+
+ %Construct the Jacobian
+ change_dK = zeros(3);
+ tempTunesDisp = zeros(3);
+
+ change_dK(:,1) = [Tunes_dK1(1); Tunes_dK1(2); Disp_dK1];
+ change_dK(:,2) = [Tunes_dK2(1); Tunes_dK2(2); Disp_dK2];
+ change_dK(:,3) = [Tunes_dK3(1); Tunes_dK3(2); Disp_dK3];
+ tempTunesDisp(:,1) = [TempTunes(1); TempTunes(2); TempDisp];
+ tempTunesDisp(:,2) = [TempTunes(1); TempTunes(2); TempDisp];
+ tempTunesDisp(:,3) = [TempTunes(1); TempTunes(2); TempDisp];
+
+
+ J = (change_dK - tempTunesDisp)/delta;
+ Jinv = inv(J);
+ initk = [InitialK1(1) InitialK2(1) InitialK3(1)]';
+else
+ % Inverse Jacobian measured using the model.
+ Jinv = [...
+ 0.130094898781898,0.000379003570963,0.100529311940219;...
+ -0.105532343683691,-0.139777190998969,-0.004112213885454;...
+ 0.022078330803986,0.029242080859334,-0.054916466546098;];
+ % Order QFA QDA QFB
+ initk = [1.7619022 -1.0859714 1.5444376]';
+
+ % -0.75 dispersion (9ps)
+ % Jinv = [...
+ % 0.220177508545285 0.000615853133914 0.062397330857094
+ % -0.083404182378964 -0.148030962548666 0.002243208844560
+ % -0.059742956049518 0.030032260554950 -0.041325062084519];
+ % % % Order QFA QDA QFB
+ % initk = [1.701360482635349 -1.072306322947120 1.576013680632028]';
+end
% Fit the tunes but don't change the dispersion, therefore the last element
% is zero.
deltak = Jinv*[delta_nu]';
-percentage_change = deltak./initk;
+percentage_change = deltak./initk
% Read current setpoints
currentquads = [];
@@ -55,8 +161,10 @@ function track_tunes(current_tunes,fixtunes2,varargin)
if max(percentage_change) > 0.05
% If greater than 5% change then ask for confirmation
- switch questdlg('Change in quads > 5%%. Are you sure?','Tune Tracking Question',...
+ switch questdlg('Change in quads > 5%%. Will force increment. Are you sure?','Tune Tracking Question',...
'Yes','No','Yes');
+ case 'Yes'
+ increment = 1;
case 'No'
disp('No changes made. goodbye');
return
@@ -73,7 +181,7 @@ function track_tunes(current_tunes,fixtunes2,varargin)
setsp('QFA',currentquads(:,1) + deltacurrentquads(:,1)*(i/10),'Hardware');
setsp('QDA',currentquads(:,2) + deltacurrentquads(:,2)*(i/10),'Hardware');
setsp('QFB',currentquads(:,3) + deltacurrentquads(:,3)*(i/10),'Hardware');
- switch questdlg(sprintf('Continue with tracking tunes? Step %d/10',i),'Tune Tracking Question',...
+ switch questdlg(sprintf('Continue with tracking tunes? Applied %d/10',i),'Tune Tracking Question',...
'Continue','Backstep','Finished','Continue');
case 'Continue'
i = i + 1;
@@ -82,6 +190,8 @@ function track_tunes(current_tunes,fixtunes2,varargin)
case 'Finished'
finished = 1;
end
+% t = getliberatbt('DD1',[1 4]);
+% getfftspectrum(t.tbtx(1,:),499671948/360/64);
end
else
% switch questdlg('Apply new tunes?','Tune Tracking Question',...
@@ -102,6 +212,8 @@ function track_tunes(current_tunes,fixtunes2,varargin)
setsp('QDA',currentquads(:,2) + deltacurrentquads(:,2),'Hardware');
setsp('QFB',currentquads(:,3) + deltacurrentquads(:,3),'Hardware');
end
+fprintf('(%s): Tunes adjusted\n',datestr(now));
+
% otherwise
% disp('Not applying changes. Goodbye');
% end
diff --git a/machine/ASP/StorageRing/track_tunes_modified.m b/machine/ASP/StorageRing/track_tunes_modified.m
new file mode 100644
index 00000000..c2f1fce2
--- /dev/null
+++ b/machine/ASP/StorageRing/track_tunes_modified.m
@@ -0,0 +1,240 @@
+function track_tunes_modified(current_tunes,fixtunes2,varargin)
+%%%%%%%%%%%%%%% This file has been modified for headless run by
+%%%%%%%%%%%%%%% Paul Bennetto. It no longer prompts for a 5% change
+%%%%%%%%%%%%%%% in quads, instead it throws an error.
+% track_tunes([curr_tunes curr_disp],[want_tunes want_disp],[calc_J,'increment'])
+%
+% Example: track_tunes([0.31 0.24 0.1],[0.290 0.216 0.1])
+% track_tunes([0.31 0.24 0.1],[0.290 0.216 0.1],1,'increment');
+%
+% The value calc_J asks track_tunes to calculate the jacobian from the
+% loaded model. Default is to calculate.
+
+calc_from_model = 1;
+increment = 0;
+if nargin > 3 && ischar(varargin{2}) && strcmpi(varargin{2},'increment')
+ increment = 1;
+end
+if nargin > 2 && isnumeric(varargin{1})
+ calc_from_model = varargin{1};
+end
+
+if length(current_tunes) ~= 3 && length(fixtunes2) ~= 3
+ error('TRACK_TUNES requires 3 values [xtune ytune disp]');
+end
+
+% xtune_pv = 'CR01:GENERAL_ANALOG_02_MONITOR';
+% xtune_handle = mcacheckopen(xtune_pv);
+% ytune_pv = 'CR01:GENERAL_ANALOG_03_MONITOR';
+% ytune_handle = mcacheckopen(ytune_pv);
+% if xtune_handle == 0
+% error('Cant open channel to xtune');
+% end
+% if ytune_handle == 0
+% error('Cant open channel to xtune');
+% end
+
+
+% fixtunes2 = [0.29 0.216 0];
+% current_tunes = [mcaget(xtune_handle) mcaget(ytune_handle) 0];
+% current_tunes = [0.2913 0.2145 0.00];
+% current_tunes = [getam('TUNE')' 0];
+delta_nu = fixtunes2(1:2) - current_tunes(1:2);
+delta_nu(3) = fixtunes2(3) - current_tunes(3);
+
+% fprintf('\n Current fractional tunes are: [%6.3f %6.3f] dispersion = %6.7f\n', current_tunes);
+% fprintf(' Delta fractional tunes are: [%6.3f %6.3f] dispersion = %6.7f\n', delta_nu);
+
+if calc_from_model
+ global THERING;
+ delta = 1e-6;
+ quadfam1 = 'QFA';
+ quadfam2 = 'QDA';
+ quadfam3 = 'QFB';
+ % Fit the model
+ fittunedisp2(current_tunes+[13 5 0],'QFA','QDA','QFB',1)
+
+ % find indexes of the 2 quadrupole families use for fitting
+ Q1I = findcells(THERING,'FamName',quadfam1);
+ if isempty(Q1I); fprintf('Cannot find quadfamily: %s\n',quadfam1); return; end;
+ Q2I = findcells(THERING,'FamName',quadfam2);
+ if isempty(Q2I); fprintf('Cannot find quadfamily: %s\n',quadfam2); return; end;
+ Q3I = findcells(THERING,'FamName',quadfam3);
+ if isempty(Q3I); fprintf('Cannot find quadfamily: %s\n',quadfam3); return; end;
+
+
+ InitialK1 = getcellstruct(THERING,'K',Q1I);
+ InitialK2 = getcellstruct(THERING,'K',Q2I);
+ InitialK3 = getcellstruct(THERING,'K',Q3I);
+ InitialPolB1 = getcellstruct(THERING,'PolynomB',Q1I,2);
+ InitialPolB2 = getcellstruct(THERING,'PolynomB',Q2I,2);
+ InitialPolB3 = getcellstruct(THERING,'PolynomB',Q3I,2);
+
+ % Compute initial tunes before fitting
+ % [ LD, InitialTunes] = linopt(THERING,0);
+ mach = machine_at;
+ TempTunes = [mach.nux(end);mach.nuy(end)];
+ TempDisp = mach.etax(1);
+ TempK1 = InitialK1;
+ TempK2 = InitialK2;
+ TempK3 = InitialK3;
+ TempPolB1 = InitialPolB1;
+ TempPolB2 = InitialPolB2;
+ TempPolB3 = InitialPolB3;
+
+ disp('Calculating Jacobian from current model');
+ fprintf('Tunes and Dispersion: %14.10f (H) %14.10f (V) %14.10f (D)\n',...
+ TempTunes(1),TempTunes(2),TempDisp);
+
+ % Take Derivative
+ THERING = setcellstruct(THERING,'K',Q1I,TempK1+delta);
+ THERING = setcellstruct(THERING,'PolynomB',Q1I,TempPolB1+delta,2);
+ mach = machine_at;
+ Tunes_dK1 = [mach.nux(end);mach.nuy(end)];
+ Disp_dK1 = mach.etax(1);
+ THERING = setcellstruct(THERING,'K',Q1I,TempK1);
+ THERING = setcellstruct(THERING,'PolynomB',Q1I,TempPolB1,2);
+
+ THERING = setcellstruct(THERING,'K',Q2I,TempK2+delta);
+ THERING = setcellstruct(THERING,'PolynomB',Q2I,TempPolB2+delta,2);
+ mach = machine_at;
+ Tunes_dK2 = [mach.nux(end);mach.nuy(end)];
+ Disp_dK2 = mach.etax(1);
+ THERING = setcellstruct(THERING,'K',Q2I,TempK2);
+ THERING = setcellstruct(THERING,'PolynomB',Q2I,TempPolB2,2);
+
+ THERING = setcellstruct(THERING,'K',Q3I,TempK3+delta);
+ THERING = setcellstruct(THERING,'PolynomB',Q3I,TempPolB3+delta,2);
+ mach = machine_at;
+ Tunes_dK3 = [mach.nux(end);mach.nuy(end)];
+ Disp_dK3 = mach.etax(1);
+ THERING = setcellstruct(THERING,'K',Q3I,TempK3);
+ THERING = setcellstruct(THERING,'PolynomB',Q3I,TempPolB3,2);
+
+
+ %Construct the Jacobian
+ change_dK = zeros(3);
+ tempTunesDisp = zeros(3);
+
+ change_dK(:,1) = [Tunes_dK1(1); Tunes_dK1(2); Disp_dK1];
+ change_dK(:,2) = [Tunes_dK2(1); Tunes_dK2(2); Disp_dK2];
+ change_dK(:,3) = [Tunes_dK3(1); Tunes_dK3(2); Disp_dK3];
+ tempTunesDisp(:,1) = [TempTunes(1); TempTunes(2); TempDisp];
+ tempTunesDisp(:,2) = [TempTunes(1); TempTunes(2); TempDisp];
+ tempTunesDisp(:,3) = [TempTunes(1); TempTunes(2); TempDisp];
+
+
+ J = (change_dK - tempTunesDisp)/delta;
+ Jinv = inv(J);
+ initk = [InitialK1(1) InitialK2(1) InitialK3(1)]';
+else
+ % Inverse Jacobian measured using the model.
+ Jinv = [...
+ 0.130094898781898,0.000379003570963,0.100529311940219;...
+ -0.105532343683691,-0.139777190998969,-0.004112213885454;...
+ 0.022078330803986,0.029242080859334,-0.054916466546098;];
+ % Order QFA QDA QFB
+ initk = [1.7619022 -1.0859714 1.5444376]';
+
+ % -0.75 dispersion (9ps)
+ % Jinv = [...
+ % 0.220177508545285 0.000615853133914 0.062397330857094
+ % -0.083404182378964 -0.148030962548666 0.002243208844560
+ % -0.059742956049518 0.030032260554950 -0.041325062084519];
+ % % % Order QFA QDA QFB
+ % initk = [1.701360482635349 -1.072306322947120 1.576013680632028]';
+end
+
+% Fit the tunes but don't change the dispersion, therefore the last element
+% is zero.
+deltak = Jinv*[delta_nu]';
+
+percentage_change = deltak./initk;
+
+% Read current setpoints
+currentquads = [];
+currentquads(:,1) = getsp('QFA','Hardware');
+currentquads(:,2) = getsp('QDA','Hardware');
+currentquads(:,3) = getsp('QFB','Hardware');
+
+% Calculate percentage changes
+deltacurrentquads(:,1) = percentage_change(1).*currentquads(:,1);
+deltacurrentquads(:,2) = percentage_change(2).*currentquads(:,2);
+deltacurrentquads(:,3) = percentage_change(3).*currentquads(:,3);
+
+if max(percentage_change) > 0.05
+ % If greater than 5% break
+ error('Out by 5%');
+
+end
+% fprintf(' Change in currents are: %6.3f (QFA) %6.3f (QDA) %6.3f (QFB)\n',...
+% deltacurrentquads(1,:));
+
+if increment
+ % In 10 incremental steps
+ finished = 0;
+ i = 0;
+ while ~finished
+ setsp('QFA',currentquads(:,1) + deltacurrentquads(:,1)*(i/10),'Hardware');
+ setsp('QDA',currentquads(:,2) + deltacurrentquads(:,2)*(i/10),'Hardware');
+ setsp('QFB',currentquads(:,3) + deltacurrentquads(:,3)*(i/10),'Hardware');
+ switch questdlg(sprintf('Continue with tracking tunes? Applied %d/10',i),'Tune Tracking Question',...
+ 'Continue','Backstep','Finished','Continue');
+ case 'Continue'
+ i = i + 1;
+ case 'Backstep'
+ i = i - 1;
+ case 'Finished'
+ finished = 1;
+ end
+% t = getliberatbt('DD1',[1 4]);
+% getfftspectrum(t.tbtx(1,:),499671948/360/64);
+ end
+else
+% switch questdlg('Apply new tunes?','Tune Tracking Question',...
+% 'Yes','No','No');
+% case 'Yes'
+% Apply quad values completely
+if max(percentage_change) > 0.05
+ % Do in two steps
+ setsp('QFA',currentquads(:,1) + deltacurrentquads(:,1)*0.5,'Hardware');
+ setsp('QDA',currentquads(:,2) + deltacurrentquads(:,2)*0.5,'Hardware');
+ setsp('QFB',currentquads(:,3) + deltacurrentquads(:,3)*0.5,'Hardware');
+ pause(1);
+ setsp('QFA',currentquads(:,1) + deltacurrentquads(:,1),'Hardware');
+ setsp('QDA',currentquads(:,2) + deltacurrentquads(:,2),'Hardware');
+ setsp('QFB',currentquads(:,3) + deltacurrentquads(:,3),'Hardware');
+else
+ setsp('QFA',currentquads(:,1) + deltacurrentquads(:,1),'Hardware');
+ setsp('QDA',currentquads(:,2) + deltacurrentquads(:,2),'Hardware');
+ setsp('QFB',currentquads(:,3) + deltacurrentquads(:,3),'Hardware');
+end
+fprintf('(%s): Tunes adjusted\n',datestr(now));
+
+% otherwise
+% disp('Not applying changes. Goodbye');
+% end
+end
+
+return
+
+
+
+% Some measurements taken on the 11/10/06
+mf = 1387.866895;
+Initatunes = [407.4654 286.44708]./mf;
+Finaltunes = [400.8038 289.77786]./mf;
+% Delta Tune due to QFA
+J(1:2,1) = ([492.95544 223.16226]-[325.3061 350.8421])./mf;
+% Delta Dispersion due to QFA
+J(3,1) = -0.003501+0.003327;
+
+% Delta Tune due to QDA
+J(1:2,2) = ([384.14996 354.1729] - [425.2295 225.3827])./mf;
+% Delta Dispersion due to QDA
+J(3,2) = 0.01104+0.02191;
+
+% Delta Tune due to QFB
+J(1:2,3) = ([548.800 190.400] - [277.7620 385.5622])./mf;
+% Delta Dispersion due to QFB
+J(3,3) = -0.1851-0.08853;
diff --git a/machine/ASP/StorageRing/updateatindex.m b/machine/ASP/StorageRing/updateatindex.m
index 45f909b8..ab910c29 100644
--- a/machine/ASP/StorageRing/updateatindex.m
+++ b/machine/ASP/StorageRing/updateatindex.m
@@ -1,114 +1,130 @@
-function updateatindex
-%UPDATEATINDEX - Updates the AT indices in the MiddleLayer with the present AT lattice (THERING)
-
-
-global THERING
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Append Accelerator Toolbox information %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-% Since changes in the AT model could change the AT indexes, etc,
-% It's best to regenerate all the model indices whenever a model is loaded
-
-% Sort by family first (findcells is linear and slow)
-Indices = atindex(THERING);
-
-AO = getao;
-
-AOelements = fieldnames(AO);
-
-for aoElement = AOelements'
- aoElement = aoElement{1};
- switch aoElement
- case {'BPMx' 'FTx' 'FTsum'}
- ATType = 'X';
- ATIndex = Indices.BPM(:);
- case {'BPMy' 'FTy'}
- ATType = 'Y';
- ATIndex = Indices.BPM(:);
- case 'HCM'
- ATType = 'HCM';
-% ATIndex = Indices.HCM(:);%union(Indices.SFA, Indices.SFB);
- ATIndex = union(Indices.SFA, Indices.SFB);
- case 'VCM'
- ATType = 'VCM';
-% ATIndex = Indices.VCM(:);%union(Indices.SDA, Indices.SDB);
- ATIndex = union(Indices.SDA, Indices.SDB);
- case 'QFA'
- ATType = 'QUAD';
- ATIndex = Indices.(aoElement)(:);
- case 'QFB'
- ATType = 'QUAD';
- ATIndex = Indices.(aoElement)(:);
- case 'QDA'
- ATType = 'QUAD';
- ATIndex = Indices.(aoElement)(:);
- case 'SFA'
- ATType = 'SEXT';
- ATIndex = Indices.(aoElement)(:);
- case 'SFB'
- ATType = 'SEXT';
- ATIndex = Indices.(aoElement)(:);
- case 'SDA'
- ATType = 'SEXT';
- ATIndex = Indices.(aoElement)(:);
- case 'SDB'
- ATType = 'SEXT';
- ATIndex = Indices.(aoElement)(:);
- case 'RF'
- ATType = 'RF';
- ATIndex = Indices.(aoElement)(:);
- case 'SKQ'
- ATType = 'SkewQuad';
- ATIndex = Indices.SDA(:);
- case {'KICK' 'Kicker'}
- ATType = 'Kicker';
- if isfield(Indices,'KICK')
- ATIndex = Indices.(aoElement)([3 4 1 2]);
- else
- ATIndex = [Indices.KICK1 Indices.KICK2 Indices.KICK3 Indices.KICK4];
- end
- case 'BEND'
- if isfield(Indices,'BEND')
- ATType = 'BEND';
- ATIndex = Indices.(aoElement)(:);
- elseif isfield(Indices,'b_left01')
- ATType = 'BEND';
- tempmat = [];
- i=1;
- while isfield(Indices,sprintf('b_left%02d',i))
- tempmat = [tempmat; Indices.(sprintf('b_left%02d',i))(:)];
- i = i + 1;
- end
- i=1;
- while isfield(Indices,sprintf('b_centre%02d',i))
- tempmat = [tempmat; Indices.(sprintf('b_left%02d',i))(:)];
- i = i + 1;
- end
- i=1;
- while isfield(Indices,sprintf('b_right%02d',i))
- tempmat = [tempmat; Indices.(sprintf('b_left%02d',i))(:)];
- i = i + 1;
- end
- ATIndex = tempmat(:);
- end
- otherwise
- ATType = '';
- end
-
- if ~isempty(ATType)
- AO.(aoElement).AT.ATType = ATType;
- AO.(aoElement).AT.ATIndex = buildatindex(AO.(aoElement).FamilyName, ATIndex);
- end
-end
-
-
-% SEPTUM
-% AO.Septum.AT.ATType = 'Septum';
-% AO.Septum.AT.ATIndex = Indices.SEPTUM(:);
-% AO.Septum.Position = s(AO.Septum.AT.ATIndex);
-
-
-setao(AO);
\ No newline at end of file
+function updateatindex
+%UPDATEATINDEX - Updates the AT indices in the MiddleLayer with the present AT lattice (THERING)
+
+
+global THERING
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Append Accelerator Toolbox information %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Since changes in the AT model could change the AT indexes, etc,
+% It's best to regenerate all the model indices whenever a model is loaded
+
+% Sort by family first (findcells is linear and slow)
+Indices = atindex(THERING);
+
+AO = getao;
+
+AOelements = fieldnames(AO);
+
+for aoElement = AOelements'
+ aoElement = aoElement{1};
+ switch aoElement
+ case {'BPMx' 'FTx' 'FTsum'}
+ ATType = 'X';
+ ATIndex = [Indices.BPM(:); 1];
+ case {'BPMy' 'FTy'}
+ ATType = 'Y';
+ ATIndex = [Indices.BPM(:); 1];
+ % test swap of the BPMs to see if its obvious eugene 29/08/2007
+% ttt = ATIndex(4);
+% ATIndex(4) = ATIndex(3);
+% ATIndex(3) = ttt;
+ case 'HCM'
+ ATType = 'HCM';
+% ATIndex = Indices.HCM(:);%union(Indices.SFA, Indices.SFB);
+ ATIndex = union(Indices.SFA, Indices.SFB);
+ case 'VCM'
+ ATType = 'VCM';
+% ATIndex = Indices.VCM(:);%union(Indices.SDA, Indices.SDB);
+ ATIndex = union(Indices.SDA, Indices.SDB);
+ case 'HFC'
+ ATType = 'HCM';
+ ATIndex = union(Indices.SDA, Indices.SDB(1:2:end)); % Only the first SDB is wired in every arc as a HFC
+ case 'VFC'
+ ATType = 'VCM';
+ ATIndex = union(Indices.SFA, Indices.SFB);
+ case 'QFA'
+ ATType = 'QUAD';
+ ATIndex = Indices.(aoElement)(:);
+ case 'QFB'
+ ATType = 'QUAD';
+ ATIndex = Indices.(aoElement)(:);
+ case 'QDA'
+ ATType = 'QUAD';
+ ATIndex = Indices.(aoElement)(:);
+ case 'SFA'
+ ATType = 'SEXT';
+ ATIndex = Indices.(aoElement)(:);
+ case 'SFB'
+ ATType = 'SEXT';
+ ATIndex = Indices.(aoElement)(:);
+ case 'SDA'
+ ATType = 'SEXT';
+ ATIndex = Indices.(aoElement)(:);
+ case 'SDB'
+ ATType = 'SEXT';
+ ATIndex = Indices.(aoElement)(:);
+ case 'RF'
+ ATType = 'RF';
+ if isfield(Indices,'RF')
+ ATIndex = Indices.(aoElement)(:);
+ else
+ ATIndex = [];
+ end
+ case 'SKQ'
+ ATType = 'SkewQuad';
+ ATIndex = Indices.SDA(:);
+ case {'KICK' 'Kicker'}
+ ATType = 'Kicker';
+ if isfield(Indices,'KICK')
+ ATIndex = Indices.(aoElement)([3 4 1 2]);
+ elseif isfield(Indices,'KICK1')
+ ATIndex = [Indices.KICK1 Indices.KICK2 Indices.KICK3 Indices.KICK4];
+ else
+ ATIndex = [];
+ end
+ case 'BEND'
+ if isfield(Indices,'BEND')
+ ATType = 'BEND';
+ ATIndex = Indices.(aoElement)(:);
+ elseif isfield(Indices,'b_left01')
+ ATType = 'BEND';
+ tempmat = [];
+ i=1;
+ while isfield(Indices,sprintf('b_left%02d',i))
+ tempmat = [tempmat Indices.(sprintf('b_left%02d',i))(:)];
+ i = i + 1;
+ end
+ i=1;
+ while isfield(Indices,sprintf('b_centre%02d',i))
+ tempmat = [tempmat Indices.(sprintf('b_centre%02d',i))(:)];
+ i = i + 1;
+ end
+ i=1;
+ while isfield(Indices,sprintf('b_right%02d',i))
+ tempmat = [tempmat Indices.(sprintf('b_right%02d',i))(:)];
+ i = i + 1;
+ end
+ ATIndex = tempmat';
+ end
+ otherwise
+ ATType = '';
+ end
+
+ if ~isempty(ATType) && ~isempty(ATIndex)
+ AO.(aoElement).AT.ATType = ATType;
+ AO.(aoElement).AT.ATIndex = buildatindex(AO.(aoElement).FamilyName, ATIndex);
+ end
+end
+
+
+% SEPTUM
+% AO.Septum.AT.ATType = 'Septum';
+% AO.Septum.AT.ATIndex = Indices.SEPTUM(:);
+% AO.Septum.Position = s(AO.Septum.AT.ATIndex);
+
+
+setao(AO);
diff --git a/mml/gotoat.m b/mml/gotoat.m
index 738f805b..f00768d4 100644
--- a/mml/gotoat.m
+++ b/mml/gotoat.m
@@ -12,6 +12,7 @@
ATPATHDirectory = '';
ATVersion = [];
+ATVersionDefault = 1.4;
while length(varargin) > 0
if isstruct(varargin{1}) || iscell(varargin{1})
@@ -36,10 +37,10 @@
if ismac || ispc % Not linking properly on Linux yet!!!
ATVersion = 2.0;
else
- ATVersion = 1.3;
+ ATVersion = ATVersionDefault;
end
else
- ATVersion = 1.3;
+ ATVersion = ATVersionDefault;
end
end
diff --git a/mml/setpathasp.m b/mml/setpathasp.m
index 7e8bab82..44bc9197 100644
--- a/mml/setpathasp.m
+++ b/mml/setpathasp.m
@@ -44,11 +44,13 @@
if isempty(LinkFlag)
if strncmp(computer,'PC',2)
- LinkFlag = 'MCA_ASP';
- elseif isunix
- LinkFlag = 'LABCA';
+ LinkFlag = 'LabCA';
+ elseif strncmp(computer,'GLNX86',6)
+ LinkFlag = 'LabCA';
+ elseif strncmp(computer,'GLNXA64',6)
+ LinkFlag = 'LabCA';
else
- LinkFlag = 'LABCA';
+ LinkFlag = 'LabCA';
end
end
@@ -77,7 +79,9 @@
if any(strcmpi(SubMachineName, {'Storage Ring','Ring'}))
SubMachineName = 'StorageRing';
end
-
+if any(strcmpi(SubMachineName, {'Booster Ring','BoosterRing'}))
+ SubMachineName = 'BoosterRing';
+end
if strcmpi(SubMachineName,'StorageRing')
[MachineName, SubMachineName, LinkFlag, MMLROOT] = setpathmml(Machine, 'StorageRing', 'StorageRing', LinkFlag);
@@ -89,4 +93,4 @@
[MachineName, SubMachineName, LinkFlag, MMLROOT] = setpathmml(Machine, 'BTS', 'Transport', LinkFlag);
elseif strcmpi(SubMachineName,'Injector')
[MachineName, SubMachineName, LinkFlag, MMLROOT] = setpathmml(Machine, 'Injector', 'Booster', LinkFlag);
-end
+end
\ No newline at end of file
diff --git a/simulators/at1.4.1/atintegrators/mexpassmethod.m b/simulators/at1.4.1/atintegrators/mexpassmethod.m
index a6574653..d5620442 100644
--- a/simulators/at1.4.1/atintegrators/mexpassmethod.m
+++ b/simulators/at1.4.1/atintegrators/mexpassmethod.m
@@ -53,7 +53,7 @@ function mexpassmethod(PASSMETHODS, varargin)
ldf=regexprep(mex.getCompilerConfigurations('C').Details.LinkerFlags,['(' exportarg '\s?)([^\s,]+)'],['$1',fullfile(pdir,'%s')]);
EXPORT=[' LDFLAGS=''',strrep(ldf,'$','\\$'),''' '];
else
- EXPORT=[' LINKEXPORT=''',exportarg,fullfile(pdir,'%s'),''' '];
+ EXPORT=[' LINKEXPORTVER=''',exportarg,fullfile(pdir,'%s'),''' '];
end
end