Beispiel #1
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;
  }
Beispiel #2
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));
  }