Package eu.ess.lt.parser
Class ComponentFactory
java.lang.Object
eu.ess.lt.parser.ComponentFactory
A factory that generates BLED entities. If the factory can connect to the
BLED database, it will first attempt to retrieve the entity instance from the
database. This will prevent problems when saving the changes, since there
will be no attempts to duplicate entities.
- Author:
- Jakob Battelino Prelog
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAperture
(String name, double dx, double dy, BeamlineElement.ApertureType apertureType, Integer previousSubsystem) Returns an existingAperture
identified by its name, or creates a new one.getBeamline
(String name, String description, Integer previousSubsystem) Returns an existing beam line identified by its name, or creates a new one.getBend
(String name, String entranceEdgeName, String exitEdgeName, double bendAngle, double curvatureRadius, int gradientIndex, double aperture, Bend.Orientation orientation, double gap, double entranceAngle, double entranceCurvature, double exitAngle, double exitCurvature, Integer previousSubsystem) Returns an existingBend
identified by its name, or creates a new one.Returns an existingBPM
identified by its name, or creates a new one.getCorrector
(String name, boolean insideNext, double fx, double fy, Double fmax, boolean electric, Double c1, Double c2, Double aperture, Integer previousSubsystem) Returns an existingCorrector
identified by its name, or creates a new one.Returns an existingDrift
identified by its name, or creates a new one.getDTLCell
(String name, double length, double quadLength1, double quadLength2, double cellCenter, double fieldGradient1, double fieldGradient2, double gapVoltage, double rfPhase, double aperture, boolean isPhaseAbsolute, double beta, double transitTimeFactor, double kT, double kkT, Integer previousSubsystem) Returns an existingDTLCell
identified by its name, or creates a new one.getElectrostaticAcceleration
(String name, double length, double voltage, double defocal, double aperture, Integer previousSubsystem) Returns an existingElectrostaticAcceleration
identified by its name, or creates a new one.getElectrostaticBend
(String name, double bendAngle, double curvatureRadius, ElectrostaticBend.BendType bendType, double aperture, boolean horizVert, Integer previousSubsystem) Returns an existingElectrostaticBend
identified by its name, or creates a new one.getElectrostaticQuadrupole
(String name, double length, double voltage, double apertureRadius, double skewAngle, double sextupoleVoltage, double octupoleVoltage, double decapoleVoltage, double dodecapoleVoltage, Integer previousSubsystem) Returns an existingElectrostaticQuadropole
identified by its name, or creates a new one.getFieldMap
(String name, double length, int geom, double rfPhase, double aperture, double magneticIntensityFactor, double electricIntensityFactor, double spaceChargeCompensationFactor, int apertureFlag, String fileName, Integer previousSubsystem) Returns an existingFieldMap
identified by its name, or creates a new one.getLatticeCommand
(String name, String value, Integer previousSubsystem) Returns an existingMarker
identified by its name, or creates a new one.getMultipoleFieldMap
(String name, double length, MultipoleMagnet.MagnetType magnetType, int numberOfSteps, double magneticField, double aperture, double solenoidLength, int solenoidStepNumber, Integer previousSubsystem) Returns an existingMultipoleMagnet
identified by its name, or creates a new one.getNCell
(String name, double length, int mode, int numberOfCells, double geometricBeta, double gapVoltage, double rfPhase, double aperture, boolean isPhaseAbsolute, double inputFieldCorrection, double outputFieldCorrection, double gapDisplacement1, double gapDisplacement2, double beta, double ttfMiddleGaps, double kTMiddleGaps, double kktMiddleGaps, double ttfInputGaps, double kTInputGaps, double kkTInputGaps, double ttfOutputGaps, double kTOutputGaps, double kkTOutputGaps, Integer previousSubsystem) Returns an existingNCell
identified by its name, or creates a new one.getQuadrupole
(String name, double length, double quadrupoleGradient, double aperture, double skewAngle, double sextupoleGradient, double octupoleGradient, double decapoleGradient, double dodecapoleGradient, Integer previousSubsystem) Returns an existingMultipoleMagnet
of quadruple type identified by its name, or creates a new one.getRFCavity
(String name, double gapVoltage, double rfPhase, double apertureRadius, boolean isPhaseAbsolute, double beta, double transitTimeFactor, double kT, double kkT, double kS, double kkS, RFCavity.CavityType cavityType, Integer previousSubsystem) Returns an existingRFCavity
identified by its name, or creates a new one.getRFCavity
(String name, double length, int cellNumber, double averageAccField, double phaseAtEntrance, double aperture, boolean isPhaseAbsolute, RFCavity.CavityType cavityType, Integer previousSubsystem) Returns an existingRFCavity
identified by its name, or creates a new one.getRFQCell
(String name, double length, double gapVoltage, double vaneRadius, double accParameter, double modulation, double rfPhase, String type, double curvature, double focusing, Integer previousSubsystem) Returns an existingRFQCell
identified by its name, or creates a new one.Returns an existing slot identified by its name, or creates a new one.getSolenoid
(String name, double length, double magneticField, double aperture, Integer previousSubsystem) Returns an existingSolenoid
identified by its name, or creates a new one.getSpaceChargeCompensation
(String name, double factor, Integer previousSubsystem) Returns an existingSpaceChargeCompensation
identified by its name, or creates a new one.getThinLens
(String name, double focalLengthX, double focalLengthY, double aperture, Integer previousSubsystem) Returns an existingThinLens
identified by its name, or creates a new one.void
setBasePath
(String basePath) void
setFieldmapPath
(String fieldmapPath) validateFields
(Subsystem subsystem)
-
Constructor Details
-
ComponentFactory
public ComponentFactory()
-
-
Method Details
-
getAperture
public Aperture getAperture(String name, double dx, double dy, BeamlineElement.ApertureType apertureType, Integer previousSubsystem) Returns an existingAperture
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the aperture.dx
-double
aperture's X position.dy
-double
aperture's Y position.apertureType
-BeamlineElement.ApertureType
type of the aperture.previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
Aperture
with the specified field values.
-
getBend
public Bend getBend(String name, String entranceEdgeName, String exitEdgeName, double bendAngle, double curvatureRadius, int gradientIndex, double aperture, Bend.Orientation orientation, double gap, double entranceAngle, double entranceCurvature, double exitAngle, double exitCurvature, Integer previousSubsystem) Returns an existingBend
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the bending magnet.entranceEdgeName
-exitEdgeName
-bendAngle
-double
angle of bending.curvatureRadius
-double
radius of the trajectory curve.gradientIndex
-int
gradient index.aperture
-double
aperture size.orientation
-Bend.Orientation
orientation of the bending magnet.gap
-double
total gap of the magnet.entranceAngle
-double
angle of the incoming beam.entranceCurvature
-double
curvature of the incoming beam.exitAngle
-double
angle of the outgoing beam.exitCurvature
-double
curvature of the outgoing beam.previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
Bend
with the specified field values.
-
getRFCavity
public RFCavity getRFCavity(String name, double gapVoltage, double rfPhase, double apertureRadius, boolean isPhaseAbsolute, double beta, double transitTimeFactor, double kT, double kkT, double kS, double kkS, RFCavity.CavityType cavityType, Integer previousSubsystem) Returns an existingRFCavity
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the RF cavity.gapVoltage
-double
effective gap voltage.rfPhase
-double
RF phase.apertureRadius
-double
aperture size.isPhaseAbsolute
-boolean
1 if phase is absolute, 0 if it's relative.beta
-double
transitTimeFactor
-double
transit time factor.kT
-double
transit time factor coefficient.kkT
-double
transit time factor coefficient.kS
-double
transit time factor coefficient.kkS
-double
transit time factor coefficient.cavityType
-RFCavity.CavityType
type of the cavity.previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
RFCavity
with the specified field values.
-
getDrift
public Drift getDrift(String name, double length, double aperture, double apertureY, Integer previousSubsystem) Returns an existingDrift
identified by its name, or creates a new one. The returned entity has its fields set to the specified values. -
getDTLCell
public DTLCell getDTLCell(String name, double length, double quadLength1, double quadLength2, double cellCenter, double fieldGradient1, double fieldGradient2, double gapVoltage, double rfPhase, double aperture, boolean isPhaseAbsolute, double beta, double transitTimeFactor, double kT, double kkT, Integer previousSubsystem) Returns an existingDTLCell
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the DTL cell.length
-double
length of the DTL cell.quadLength1
-double
first 1/2 quadrupole length.quadLength2
-double
second 1/2 quadrupole length.cellCenter
-double
cell center.fieldGradient1
-double
first magnetic field gradient.fieldGradient2
-double
second magnetic field gradient.gapVoltage
-double
effective gap voltage.rfPhase
-double
RF phase.aperture
-double
aperture size.isPhaseAbsolute
-boolean
1 if phase is absolute, 0 if it's relative.beta
-double
particle reduced velocity.transitTimeFactor
-double
transit time factor.kT
-double
transit time factor coefficient.kkT
-double
transit time factor coefficient.previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
DTLCell
with the specified field values.
-
getElectrostaticAcceleration
public ElectrostaticAcceleration getElectrostaticAcceleration(String name, double length, double voltage, double defocal, double aperture, Integer previousSubsystem) Returns an existingElectrostaticAcceleration
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the electrostatic acceleration element.length
-double
length of the electrostatic acceleration element.voltage
-double
voltage.defocal
-double
transverse defocal.aperture
-double
aperture size.previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
ElectrostaticAcceleration
with the specified field values.
-
getElectrostaticQuadrupole
public ElectrostaticQuadropole getElectrostaticQuadrupole(String name, double length, double voltage, double apertureRadius, double skewAngle, double sextupoleVoltage, double octupoleVoltage, double decapoleVoltage, double dodecapoleVoltage, Integer previousSubsystem) Returns an existingElectrostaticQuadropole
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the electrostatic quadrupole.length
-double
length of the electrostatic quadrupole.voltage
-double
voltage between electrodes.apertureRadius
-double
aperture size.skewAngle
-double
skew angle.sextupoleVoltage
-double
sextupole voltage component.octupoleVoltage
-double
octupole voltage component.decapoleVoltage
-double
decapole voltage component.dodecapoleVoltage
-double
dodecapole voltage component.previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
ElectrostaticQuadropole
with the specified field values.
-
getFieldMap
public FieldMap getFieldMap(String name, double length, int geom, double rfPhase, double aperture, double magneticIntensityFactor, double electricIntensityFactor, double spaceChargeCompensationFactor, int apertureFlag, String fileName, Integer previousSubsystem) Returns an existingFieldMap
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the field map.length
-double
length of the field map element.geom
-int
field map type.rfPhase
-double
RF phase.aperture
-double
aperture size.magneticIntensityFactor
-double
magnetic field intensity factor.electricIntensityFactor
-double
electric field intensity factor.spaceChargeCompensationFactor
-double
space charge compensation factor.apertureFlag
-int
aperture flag.fileName
-String
file name without extension.previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
FieldMap
with the specified field values.
-
getMultipoleFieldMap
public MultipoleMagnet getMultipoleFieldMap(String name, double length, MultipoleMagnet.MagnetType magnetType, int numberOfSteps, double magneticField, double aperture, double solenoidLength, int solenoidStepNumber, Integer previousSubsystem) Returns an existingMultipoleMagnet
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the multipole magnet.length
-double
length of the multipole magnet.magnetType
-MultipoleMagnet.MagnetType
magnet type.numberOfSteps
-int
number of steps along x and y directions.magneticField
-double
magnetic field on pole.aperture
-double
aperture size.solenoidLength
-double
physical length of solenoid.solenoidStepNumber
-int
step number of solenoid case.previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
MultipoleMagnet
with the specified field values.- See Also:
-
getQuadrupole
public Quadrupole getQuadrupole(String name, double length, double quadrupoleGradient, double aperture, double skewAngle, double sextupoleGradient, double octupoleGradient, double decapoleGradient, double dodecapoleGradient, Integer previousSubsystem) Returns an existingMultipoleMagnet
of quadruple type identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the quadrupole magnet.length
-double
length of the quadrupole magnet.quadrupoleGradient
-double
magnetic field gradient (T/m)aperture
-double
apertureskewAngle
-double
skew angle (degrees)sextupoleGradient
-double
sextupole gradient (T/m2)octupoleGradient
-double
octupole gradient (T/m3)decapoleGradient
-double
decapole gradient (T/m4)dodecapoleGradient
-double
dodecapole gradient (T/m5)previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
MultipoleMagnet
with the specified field values.
-
getNCell
public NCell getNCell(String name, double length, int mode, int numberOfCells, double geometricBeta, double gapVoltage, double rfPhase, double aperture, boolean isPhaseAbsolute, double inputFieldCorrection, double outputFieldCorrection, double gapDisplacement1, double gapDisplacement2, double beta, double ttfMiddleGaps, double kTMiddleGaps, double kktMiddleGaps, double ttfInputGaps, double kTInputGaps, double kkTInputGaps, double ttfOutputGaps, double kTOutputGaps, double kkTOutputGaps, Integer previousSubsystem) Returns an existingNCell
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the NCell element.length
-String
length of the NCell element.mode
-int
mode.numberOfCells
-int
number of cells.geometricBeta
-double
geometric beta.gapVoltage
-double
effective gap voltage.rfPhase
-double
RF phase.aperture
-double
aperture size.isPhaseAbsolute
-boolean
1 if phase is absolute, 0 if it's relative.inputFieldCorrection
-double
input field correction.outputFieldCorrection
-double
output field correction.gapDisplacement1
-double
first gap displacement.gapDisplacement2
-double
second gap displacement.beta
-double
particle reduced velocity.ttfMiddleGaps
-double
transit time factor for the middle gaps.kTMiddleGaps
-double
transit time factor coefficient for the middle gaps.kktMiddleGaps
-double
transit time factor coefficient for the middle gaps.ttfInputGaps
-double
transit time factor for the input gaps.kTInputGaps
-double
transit time factor coefficient for the input gaps.kkTInputGaps
-double
transit time factor coefficient for the input gaps.ttfOutputGaps
-double
transit time factor for the output gaps.kTOutputGaps
-double
transit time factor coefficient for the output gaps.kkTOutputGaps
-double
transit time factor coefficient for the output gaps.previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
NCell
with the specified field values.
-
getRFQCell
public RFQCell getRFQCell(String name, double length, double gapVoltage, double vaneRadius, double accParameter, double modulation, double rfPhase, String type, double curvature, double focusing, Integer previousSubsystem) Returns an existingRFQCell
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the RFQ cell.length
-double
length of the RFQ cell.gapVoltage
-double
effective gap voltage.vaneRadius
-double
vane radius.accParameter
-double
acceleration parameter.modulation
-double
modulation.rfPhase
-double
RF phase.type
-String
type of RF cell.curvature
-double
transverse curvature.focusing
-double
transverse focusing.previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
RFQCell
with the specified field values.
-
getRFCavity
public RFCavity getRFCavity(String name, double length, int cellNumber, double averageAccField, double phaseAtEntrance, double aperture, boolean isPhaseAbsolute, RFCavity.CavityType cavityType, Integer previousSubsystem) Returns an existingRFCavity
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the RF cavity.length
-double
length of the RF cavity.cellNumber
-int
cell number.averageAccField
-double
average accelerating field.phaseAtEntrance
-double
phase of the synchronous particle at the entrance.aperture
-double
aperture size.isPhaseAbsolute
-boolean
1 if phase is absolute, 0 if it's relative.cavityType
-RFCavity.CavityType
type of the cavity.previousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
RFCavity
with the specified field values.
-
getSolenoid
public Solenoid getSolenoid(String name, double length, double magneticField, double aperture, Integer previousSubsystem) Returns an existingSolenoid
identified by its name, or creates a new one. The returned entity has its fields set to the specified values. -
getThinLens
public ThinLens getThinLens(String name, double focalLengthX, double focalLengthY, double aperture, Integer previousSubsystem) Returns an existingThinLens
identified by its name, or creates a new one. The returned entity has its fields set to the specified values. -
getCorrector
public Corrector getCorrector(String name, boolean insideNext, double fx, double fy, Double fmax, boolean electric, Double c1, Double c2, Double aperture, Integer previousSubsystem) Returns an existingCorrector
identified by its name, or creates a new one. The returned entity has its fields set to the specified values. -
getBPM
Returns an existingBPM
identified by its name, or creates a new one. The returned entity has its fields set to the specified values. -
getSlot
Returns an existing slot identified by its name, or creates a new one. The returned entity has its fields set to the specified values. Slots are not virtual subsystems. -
getBeamline
Returns an existing beam line identified by its name, or creates a new one. The returned entity has its fields set to the specified values. Beam lines are virtual subsystems. -
getMarker
Returns an existingMarker
identified by its name, or creates a new one. The returned entity has its fields set to the specified values. -
getElectrostaticBend
public ElectrostaticBend getElectrostaticBend(String name, double bendAngle, double curvatureRadius, ElectrostaticBend.BendType bendType, double aperture, boolean horizVert, Integer previousSubsystem) Returns an existingElectrostaticBend
identified by its name, or creates a new one. The returned entity has its fields set to the specified values.- Parameters:
name
-String
name of the electrostatic bend.bendAngle
-double
bend angle in the rotation plane (deg)curvatureRadius
-double
curvature radius of central trajectory (mm)bendType
-ElectrostaticBend.BendType
CYLINDRICAL, SPHERICAL or TOROIDALaperture
-double
aperture (mm)horizVert
-false
horizontal,true
verticalpreviousSubsystem
-Subsystem
subsystem positioned previously in the lattice.- Returns:
-
getSpaceChargeCompensation
public SpaceChargeCompensation getSpaceChargeCompensation(String name, double factor, Integer previousSubsystem) Returns an existingSpaceChargeCompensation
identified by its name, or creates a new one. The returned entity has its fields set to the specified values. -
getLatticeCommand
-
validateFields
-
setFieldmapPath
-
setBasePath
-