Example #1
0
  /**
   * Load the correctors of the specified type, construct the corresponding corrector agents and
   * populate the corrector agent list.
   *
   * @param correctorAgents the list to which the corrector agents should be added
   * @param nodeType the type of corrector nodes to fetch
   */
  public void loadCorrectors(final List<CorrectorAgent> correctorAgents, final String nodeType) {
    final Map<String, CorrectorSupply> supplyMap = new HashMap<String, CorrectorSupply>();
    final List<Dipole> allCorrectors = _sequence.getAllNodesOfType(nodeType);
    final List<Dipole> correctors = AcceleratorSeq.filterNodesByStatus(allCorrectors, true);

    final Iterator<Dipole> correctorIter = correctors.iterator();
    while (correctorIter.hasNext()) {
      final Dipole corrector = correctorIter.next();
      final MagnetMainSupply supply = corrector.getMainSupply();
      if (supply != null) {
        final String supplyID = supply.getId();
        if (!supplyMap.containsKey(supplyID)) {
          supplyMap.put(supplyID, new CorrectorSupply(supply));
        }
        final CorrectorSupply supplyAgent = supplyMap.get(supplyID);
        final CorrectorAgent correctorAgent = new CorrectorAgent(corrector);
        supplyAgent.addCorrector(correctorAgent);
        _correctorAgents.add(correctorAgent);
      }
    }

    _correctorSupplyMap = supplyMap;
    _correctorSupplies = new ArrayList<CorrectorSupply>(supplyMap.values());
    Collections.sort(
        _correctorSupplies, CorrectorSupply.getFirstCorrectorPositionComparator(_sequence));
  }
Example #2
0
  public void acceleratorChanged() {
    ArrayList<AcceleratorSeq> sclSeqs = new ArrayList<AcceleratorSeq>();
    List<AcceleratorSeq> scl;
    if (accelerator != null) {
      sclSeqs.add(accelerator.getSequence("SCLMed"));
      sclSeqs.add(accelerator.getSequence("SCLHigh"));

      scl = AcceleratorSeq.orderSequences(sclSeqs);

      setSelectedSequence(AcceleratorSeqCombo.getInstance("scl", scl));

      rfCavs = getSelectedSequence().getAllNodesOfType("SCLCavity");

      if (myWindow() != null) myWindow().createRFPane();

      // setHasChanges(true);

      if (snapAction != null) snapAction.setEnabled(true);
    }

    // initialize PVLogger
    ConnectionDictionary dict = PVLogger.newLoggingConnectionDictionary();
    if (dict != null) {
      pvLogger = new PVLogger(dict);
    } else {
      ConnectionPreferenceController.displayPathPreferenceSelector();
      dict = PVLogger.newLoggingConnectionDictionary();
      pvLogger = new PVLogger(dict);
    }
  }
Example #3
0
  /** determine the best matching target beam position vector (x, y) */
  public BeamPosition getMatchingTargetBeamPosition(
      final List<BpmAgent> xBpmAgents, final List<BpmAgent> yBpmAgents) throws Exception {
    // TODO: much has changed since the original code was written. X and Y should be abstracted to
    // avoid code duplication.
    final TransferMapProbe probe = getProbe(SEQUENCE);
    final Scenario scenario = getScenario(SEQUENCE, probe);
    scenario.resync();
    scenario.run();
    final Trajectory<TransferMapState> trajectory = scenario.getTrajectory();
    final AcceleratorNode targetNode = SEQUENCE.getNodesOfType("Tgt").get(0);

    //		@SuppressWarnings("unchecked")
    //        final double[] xTargetBeamPositionAndError =
    // X_BEAM_POSITION_MATCHER.getMatchingTargetBeamPositionAndError( targetNode, xBpmAgents,
    // (Trajectory<TransferMapState>)trajectory );
    final double[] xTargetBeamPositionAndError =
        X_BEAM_POSITION_MATCHER.getMatchingTargetBeamPositionAndError(
            targetNode, xBpmAgents, trajectory);
    final double xTargetPosition = xTargetBeamPositionAndError[0];
    final double xTargetPositionError = xTargetBeamPositionAndError[1];

    //		@SuppressWarnings("unchecked")
    //        final double[] yTargetBeamPositionAndError =
    // Y_BEAM_POSITION_MATCHER.getMatchingTargetBeamPositionAndError( targetNode, yBpmAgents,
    // (Trajectory<TransferMapState>)trajectory );
    final double[] yTargetBeamPositionAndError =
        Y_BEAM_POSITION_MATCHER.getMatchingTargetBeamPositionAndError(
            targetNode, yBpmAgents, trajectory);
    final double yTargetPosition = yTargetBeamPositionAndError[0];
    final double yTargetPositionError = yTargetBeamPositionAndError[1];

    return new BeamPosition(
        xTargetPosition, xTargetPositionError, yTargetPosition, yTargetPositionError);
  }
Example #4
0
 /** Use setpoints for electromagnets. */
 public void useSetpoints(final AcceleratorSeq sequence) {
   if (sequence != null) {
     final List<AcceleratorNode> magnets = sequence.getNodesOfType(Electromagnet.s_strType, true);
     for (AcceleratorNode node : magnets) {
       ((Electromagnet) node).setUseFieldReadback(false);
     }
   }
 }
Example #5
0
 /**
  * use the field setpoints for the online model analysis otherwise the model produces ridiculous
  * answers
  */
 protected void useFieldSetpoint() {
   final List<AcceleratorNode> magnets =
       RTBT_SEQUENCE.getNodesOfType(Electromagnet.s_strType, true);
   for (final AcceleratorNode magnet : magnets) {
     if (magnet instanceof Electromagnet) {
       ((Electromagnet) magnet).setUseFieldReadback(false);
     }
   }
 }
Example #6
0
  /** Constructor */
  public TargetOrbitAnalysis(final PlaneAdaptor planeAdaptor, final AcceleratorSeq sequence) {
    PLANE_ADAPTOR = planeAdaptor;
    SEQUENCE = sequence;

    TARGET = sequence.getNodesOfType("Tgt").get(0);

    _scale = planeAdaptor.getDefaultScale();
    _offset = planeAdaptor.getDefaultOffset();
    _rmsError = Double.NaN;
  }
 /**
  * Sets the accelerator sequence
  *
  * @param accSeq The new accelSeq value
  */
 public void setAccelSeq(AcceleratorSeq accSeq) {
   java.util.List<AcceleratorNode> accNodes = accSeq.getNodesOfType(Electromagnet.s_strType);
   java.util.Iterator<AcceleratorNode> itr = accNodes.iterator();
   while (itr.hasNext()) {
     Electromagnet emg = (Electromagnet) itr.next();
     if (emg.getStatus()) {
       emg.setUseFieldReadback(false);
     }
   }
   ringFoilPosCorr.setAccelSeq(accSeq);
 }
Example #8
0
  /**
   * Applies the configuration represented in this data structure to the device in the given
   * accelerator sequence with the same device ID. If there is no such device then the method
   * returns false.
   *
   * @param smfSeq this data structure instance should contain the configuration information for a
   *     device in this accelerator sequence, a device with the proper ID
   * @return <code>true</code> if the target device was found and its configuration updated, <code>
   *     false</code> otherwise
   * @throws BadStructException data structure fields are ill-defined/incompatible
   * @throws ConnectionException unable to connect to PV channel
   * @throws PutException general put exception (unable to set all parameter values)
   * @author Christopher K. Allen
   * @since May 1, 2012
   */
  public boolean appyConfigurationById(AcceleratorSeq smfSeq)
      throws BadStructException, ConnectionException, PutException {
    AcceleratorNode smfDev = smfSeq.getNodeWithId(this.strDevId);

    if (smfDev == null) return false;

    if (!(smfDev instanceof ProfileDevice)) return false;

    ProfileDevice smfDevPrf = (ProfileDevice) smfDev;

    this.applyConfiguration(smfDevPrf);

    return true;
  }
Example #9
0
  /** Load the bpms from the selected sequence and construct the BPM agents. */
  public void loadBPMs() {
    if (_sequence == null) {
      AVAILABLE_BPM_AGENTS.clear();
      _bpmAgents = new ArrayList<BpmAgent>();
      BEAM_EXCURSION_ORBIT_ADAPTOR.setBPMAgents(_bpmAgents);
    } else {
      final List<BPM> allBPMs = _sequence.getAllNodesOfType(BPM.s_strType);
      final List<BPM> bpms = AcceleratorSeq.filterNodesByStatus(allBPMs, true);
      final Iterator<BPM> bpmIter = bpms.iterator();
      final List<BpmAgent> bpmAgents = new ArrayList<BpmAgent>(bpms.size());
      while (bpmIter.hasNext()) {
        final BPM bpm = bpmIter.next();
        if (bpm.getValid()) {
          bpmAgents.add(new BpmAgent(bpm));
        }
      }
      Collections.sort(bpmAgents, new BPMComparator(_sequence));
      BEAM_EXCURSION_ORBIT_ADAPTOR.setBPMAgents(bpmAgents);

      AVAILABLE_BPM_AGENTS.clear();
      AVAILABLE_BPM_AGENTS.addAll(bpmAgents);
      refreshEnabledBPMs(false);
    }
  }
Example #10
0
 /**
  * Get the position of the first corrector relative to the start of the specified sequence.
  *
  * @param sequence The sequence relative to which the corrector's position is measured
  * @return the position of this supply's first corrector relative to the sequence in meters
  */
 public double getFirstCorrectorPositionIn(AcceleratorSeq sequence) {
   return sequence.getPosition(_correctors.get(0).getCorrector());
 }
Example #11
0
 /** Get the position of the BPM */
 public double getPosition() {
   return sequence.getPosition(bpmNode);
 }