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
  /**
   * Wrap the corrector's channel corresponding to the specified handle.
   *
   * @param handle Description of the Parameter
   * @return Description of the Return Value
   */
  protected ChannelWrapper wrapChannel(final String handle) {
    Channel channel = _powerSupply.getChannel(handle);
    ChannelWrapper wrapper = new ChannelWrapper(channel);

    wrapper.addChannelEventListener(
        new ChannelEventListener() {
          /**
           * The PV's monitored value has changed.
           *
           * @param channel the channel whose value has changed
           * @param record The channel time record of the new value
           */
          public void valueChanged(Channel channel, ChannelTimeRecord record) {
            _latestField = record.doubleValue();
            EVENT_PROXY.fieldChanged(CorrectorSupply.this, record, _latestField);
          }

          /**
           * The channel's connection has changed. Either it has established a new connection or the
           * existing connection has dropped.
           *
           * @param channel The channel whose connection has changed.
           * @param connected The channel's new connection state
           */
          public void connectionChanged(Channel channel, boolean connected) {
            _latestField = Double.NaN;
            EVENT_PROXY.connectionChanged(CorrectorSupply.this, connected);
          }
        });

    wrapper.requestConnection();

    return wrapper;
  }
Example #3
0
 /**
  * Set the field to the value specified.
  *
  * @param field the field in Tesla
  */
 public void setField(final double field) {
   try {
     _powerSupply.setField(field);
   } catch (Exception exception) {
     throw new RuntimeException("Field setting exception.", exception);
   }
 }
Example #4
0
  /** Constructor */
  public CorrectorSupply(final MagnetMainSupply powerSupply) {
    PUT_HANDLER = new PutHandler();

    _powerSupply = powerSupply;

    _correctors = new ArrayList<CorrectorAgent>();
    _latestField = Double.NaN;
    _lowerFieldLimit = Double.NaN;
    _upperFieldLimit = Double.NaN;

    MESSAGE_CENTER = new MessageCenter();
    EVENT_PROXY = MESSAGE_CENTER.registerSource(this, CorrectorSupplyListener.class);

    wrapChannels();
    LIMITS_HANDLER = new LimitsHandler(powerSupply.getChannel(MagnetMainSupply.FIELD_SET_HANDLE));
  }
Example #5
0
 /**
  * Read the field set point.
  *
  * @return the current field set point
  */
 public double getFieldSetting() throws xal.ca.ConnectionException, xal.ca.GetException {
   return _powerSupply.getFieldSetting();
 }
Example #6
0
 /**
  * Get the unique corrector ID.
  *
  * @return the supply's unique ID
  */
 public String getID() {
   return _powerSupply.getId();
 }