Class ComponentFactory

java.lang.Object
eu.ess.lt.parser.ComponentFactory

public class ComponentFactory extends Object
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 Details

    • ComponentFactory

      public ComponentFactory()
  • Method Details

    • getAperture

      public Aperture getAperture(String name, double dx, double dy, BeamlineElement.ApertureType apertureType, Integer previousSubsystem)
      Returns an existing Aperture 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 existing Bend 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 existing RFCavity 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 existing Drift 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 drift element.
      length - double length of the drift.
      aperture - double aperture size.
      apertureY - double aperture position.
      previousSubsystem - Subsystem subsystem positioned previously in the lattice.
      Returns:
      Drift with the specified field 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 existing DTLCell 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 existing ElectrostaticAcceleration 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 existing ElectrostaticQuadropole 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 existing FieldMap 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 existing MultipoleMagnet 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 existing MultipoleMagnet 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 aperture
      skewAngle - 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 existing NCell 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 existing RFQCell 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 existing RFCavity 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 existing Solenoid 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 solenoid.
      length - double length of the solenoid.
      magneticField - double magnetic field.
      aperture - double aperture size.
      previousSubsystem - Subsystem subsystem positioned previously in the lattice.
      Returns:
      Solenoid with the specified field values.
    • getThinLens

      public ThinLens getThinLens(String name, double focalLengthX, double focalLengthY, double aperture, Integer previousSubsystem)
      Returns an existing ThinLens 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 thin lens.
      focalLengthX - double focal length.
      focalLengthY - double focal length.
      aperture - double size of aperture.
      previousSubsystem - Subsystem subsystem positioned previously in the lattice.
      Returns:
      ThinLens with the specified field 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 existing Corrector identified by its name, or creates a new one. The returned entity has its fields set to the specified values.
      Parameters:
      previousSubsystem - Subsystem subsystem positioned previously in the lattice.
      Returns:
      Corrector with the specified field values.
    • getBPM

      public BPM getBPM(String name, Integer previousSubsystem)
      Returns an existing BPM identified by its name, or creates a new one. The returned entity has its fields set to the specified values.
      Parameters:
      previousSubsystem - Subsystem subsystem positioned previously in the lattice.
      Returns:
      BPM with the specified field values.
    • getSlot

      public Subsystem getSlot(String name, String description, Integer previousSubsystem)
      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.
      Parameters:
      name - String name of the slot.
      description - String description of the slot.
      Returns:
      Subsystem slot with the specified field values.
    • getBeamline

      public Subsystem getBeamline(String name, String description, Integer previousSubsystem)
      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.
      Parameters:
      name - String name of the beamline.
      description - String description of the beamline.
      Returns:
      Subsystem beam line with the specified field values.
    • getMarker

      public Marker getMarker(String name, Integer previousSubsystem)
      Returns an existing Marker 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 marker.
      previousSubsystem - Subsystem subsystem positioned previously in the lattice.
      Returns:
      Marker with the specified field values.
    • getElectrostaticBend

      public ElectrostaticBend getElectrostaticBend(String name, double bendAngle, double curvatureRadius, ElectrostaticBend.BendType bendType, double aperture, boolean horizVert, Integer previousSubsystem)
      Returns an existing ElectrostaticBend 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 TOROIDAL
      aperture - double aperture (mm)
      horizVert - false horizontal, true vertical
      previousSubsystem - Subsystem subsystem positioned previously in the lattice.
      Returns:
    • getSpaceChargeCompensation

      public SpaceChargeCompensation getSpaceChargeCompensation(String name, double factor, Integer previousSubsystem)
      Returns an existing SpaceChargeCompensation 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 space charge compensation.
      factor - double beam current is compensated by a factor
      previousSubsystem - Subsystem subsystem positioned previously in the lattice.
      Returns:
    • getLatticeCommand

      public LatticeCommand getLatticeCommand(String name, String value, Integer previousSubsystem)
    • validateFields

      public ValidationResult validateFields(Subsystem subsystem)
    • setFieldmapPath

      public void setFieldmapPath(String fieldmapPath)
    • setBasePath

      public void setBasePath(String basePath)