Exemple #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));
  }
Exemple #2
0
  /**
   * Update the data based on the information provided by the data provider.
   *
   * @param adaptor The adaptor from which to update the data
   */
  public void update(final DataAdaptor adaptor) {
    if (_correctorSupplyMap != null) {
      final List<DataAdaptor> supplyAdaptors = adaptor.childAdaptors("supply");
      for (final DataAdaptor supplyAdaptor : supplyAdaptors) {
        final String supplyID = supplyAdaptor.stringValue("id");
        final CorrectorSupply supply = _correctorSupplyMap.get(supplyID);
        if (supply != null) {
          if (supplyAdaptor.hasAttribute("enable")) {
            final boolean enable = supplyAdaptor.booleanValue("enable");
            supply.setEnabled(enable);
          }

          if (supplyAdaptor.hasAttribute("lowerFieldLimit")) {
            supply.setLowerFieldLimit(supplyAdaptor.doubleValue("lowerFieldLimit"));
          }

          if (supplyAdaptor.hasAttribute("upperFieldLimit")) {
            supply.setUpperFieldLimit(supplyAdaptor.doubleValue("upperFieldLimit"));
          }
        }
      }
    }

    final List<DataAdaptor> bpmAdaptors = adaptor.childAdaptors("bpm");
    if (bpmAdaptors != null && bpmAdaptors.size() > 0 && _bpmAgents != null) {
      // cache all our bpms so we can access them by ID
      final Map<String, BpmAgent> bpmAgentMap = new HashMap<String, BpmAgent>(_bpmAgents.size());
      for (final BpmAgent bpmAgent : _bpmAgents) {
        bpmAgentMap.put(bpmAgent.getID(), bpmAgent);
      }

      for (final DataAdaptor bpmAdaptor : bpmAdaptors) {
        final String bpmID = bpmAdaptor.stringValue("id");
        final BpmAgent bpmAgent = bpmAgentMap.get(bpmID);
        if (bpmAgent != null) {
          if (bpmAdaptor.hasAttribute("flattenEnable")) {
            bpmAgent.setFlattenEnabled(bpmAdaptor.booleanValue("flattenEnable"));
          }
        }
      }
    }

    final DataAdaptor flattenerAdaptor = adaptor.childAdaptor(Flattener.DATA_LABEL);
    if (flattenerAdaptor != null) {
      getFlattener().update(flattenerAdaptor);
    }

    final List<DataAdaptor> orbitSourceAdaptors = adaptor.childAdaptors(OrbitSource.DATA_LABEL);
    for (DataAdaptor orbitSourceAdaptor : orbitSourceAdaptors) {
      final String type = orbitSourceAdaptor.stringValue("type");
      if (type.equals("snapshot")) {
        final SnapshotOrbitSource orbitSource =
            SnapshotOrbitSource.getInstance(orbitSourceAdaptor, _sequence, _bpmAgents);
        addOrbitSource(orbitSource);
      }
    }
  }
Exemple #3
0
 /**
  * Get the list of horizontal corrector supplies.
  *
  * @return the list of horizontal corrector supplies
  */
 public List<CorrectorSupply> getHorizontalCorrectorSupplies() {
   final List<CorrectorSupply> horizontalSupplies =
       new ArrayList<CorrectorSupply>(_correctorSupplies.size());
   for (CorrectorSupply supply : _correctorSupplies) {
     if (supply.isHorizontal()) {
       horizontalSupplies.add(supply);
     }
   }
   return horizontalSupplies;
 }
Exemple #4
0
 /**
  * Get the list of vertical corrector supplies.
  *
  * @return the list of vertical corrector supplies
  */
 public List<CorrectorSupply> getVerticalCorrectorSupplies() {
   final List<CorrectorSupply> verticalSupplies =
       new ArrayList<CorrectorSupply>(_correctorSupplies.size());
   for (CorrectorSupply supply : _correctorSupplies) {
     if (supply.isVertical()) {
       verticalSupplies.add(supply);
     }
   }
   return verticalSupplies;
 }
Exemple #5
0
 /**
  * Get the list of horizontal corrector agents
  *
  * @return the list of horizontal corrector agents
  */
 public List<CorrectorAgent> getHorizontalCorrectorAgents() {
   final List<CorrectorAgent> horizontalCorrectorAgents =
       new ArrayList<CorrectorAgent>(_correctorAgents.size());
   for (CorrectorAgent corrector : _correctorAgents) {
     if (corrector.isHorizontal()) {
       horizontalCorrectorAgents.add(corrector);
     }
   }
   return horizontalCorrectorAgents;
 }
Exemple #6
0
 /**
  * Get the list of vertical corrector agents
  *
  * @return the list of vertical corrector agents
  */
 public List<CorrectorAgent> getVerticalCorrectorAgents() {
   final List<CorrectorAgent> verticalCorrectorAgents =
       new ArrayList<CorrectorAgent>(_correctorAgents.size());
   for (CorrectorAgent corrector : _correctorAgents) {
     if (corrector.isVertical()) {
       verticalCorrectorAgents.add(corrector);
     }
   }
   return verticalCorrectorAgents;
 }
Exemple #7
0
  /**
   * Add a new OrbitSource to this model's orbit sources.
   *
   * @param orbitSource the new orbit source to add
   */
  public void addOrbitSource(final OrbitSource orbitSource) {
    synchronized (_orbitSources) {
      if (!_orbitSources.contains(orbitSource)) {
        orbitSource.setSequence(_sequence, _bpmAgents);
        _orbitSources.add(orbitSource);
        EVENT_PROXY.orbitSourceAdded(this, orbitSource);
      }
    }

    postModification();
  }
Exemple #8
0
  /**
   * Remove an OrbitSource from this model's orbit sources.
   *
   * @param orbitSource the orbit source to remove.
   */
  public void removeOrbitSource(final OrbitSource orbitSource) {
    synchronized (_orbitSources) {
      _orbitSources.remove(orbitSource);
      EVENT_PROXY.orbitSourceRemoved(this, orbitSource);
    }

    postModification();
  }
Exemple #9
0
 /** Dispose of this model's resources */
 public void dispose() {
   setSequence(null);
   _orbitSources = null;
   MESSAGE_CENTER.removeSource(this, OrbitModelListener.class);
   _bpmAgents = null;
   AVAILABLE_BPM_AGENTS.clear();
   _correctorAgents = null;
 }
Exemple #10
0
  /** refresh enabled BPMs */
  protected void refreshEnabledBPMs(final boolean postChange) {
    final List<BpmAgent> bpmAgents = new ArrayList<BpmAgent>(AVAILABLE_BPM_AGENTS.size());

    for (final BpmAgent bpmAgent : AVAILABLE_BPM_AGENTS) {
      if (bpmAgent.isEnabled()) {
        bpmAgents.add(bpmAgent);
      }
    }
    _bpmAgents = new ArrayList<BpmAgent>();
    _bpmAgents.addAll(bpmAgents);

    if (postChange) {
      for (final OrbitSource source : _orbitSources) {
        source.setSequence(_sequence, _bpmAgents);
      }
      EVENT_PROXY.enabledBPMsChanged(this, _bpmAgents);
    }
  }
Exemple #11
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);
    }
  }