예제 #1
0
  /** {@inheritDoc} */
  @Override
  protected void doDispose() {
    printDebugInfo("DISPOSE");

    DynamicValueProperty property = _dalProperty;

    setDalProperty(null);

    if (property != null && !property.isDestroyed()) {
      // remove link listener
      property.removeLinkListener(this);

      // remove value listeners
      property.removeDynamicValueListener(this);

      // remove response listeners
      property.removeResponseListener(this);

      // try to dispose the DAL property
      PropertyFactory factory =
          DALPropertyFactoriesProvider.getInstance()
              .getPropertyFactory(getProcessVariableAddress().getControlSystem());

      // if the property is not used anymore by other connectors,
      // destroy it
      if (property.getDynamicValueListeners().length <= 1
          && property.getResponseListeners().length <= 0) {

        printDebugInfo("DESTROY");

        factory.getPropertyFamily().destroy(property);

        // <**** Workarround (FIXME: Remove, when DAL is fixed) ***
        // DAL caches a reference to a former ResponseListener
        // via its latestResponse and latestRequest fields on
        // DynamicValuePropertyImpl.class
        // ********************************************************
        /*
         * try { Object e = property.getLatestResponse();
         *
         * property.getAsynchronous(null);
         *
         * while (e == property.getLatestResponse()) { Thread.sleep(1);
         * } } catch (DataExchangeException e) { e.printStackTrace(); }
         * catch (InterruptedException e) { e.printStackTrace(); }
         */
        // **** Workarround (Remove, when DAL is fixed)************>
        assert !factory.getPropertyFamily().contains(property)
            : "!getPropertyFactory().getPropertyFamily().contains(property)";
      }
    }
  }
예제 #2
0
  /** {@inheritDoc} */
  protected void doInit() {
    // get or create a real DAL property
    DynamicValueProperty property = null;

    try {
      RemoteInfo ri = getProcessVariableAddress().toDalRemoteInfo();

      PropertyFactory factory =
          DALPropertyFactoriesProvider.getInstance()
              .getPropertyFactory(getProcessVariableAddress().getControlSystem());

      switch (getValueType()) {
        case OBJECT:
          property = factory.getProperty(ri);
          break;
        case STRING:
          /*
           * swende: 2010-03-06: this is a dirty quickfix which is related
           * to problems with SDS displays that specifiy
           * "pv[severity], String" as pv address / please remove if it
           * does not work as expected or when all current SDS files at
           * DESY have been propertly changed
           */
          String characteristic = getProcessVariableAddress().getCharacteristic();
          // If connection is made as pv[severity] or just pv, than ignore everything
          // and go to default. In all other cases (e.g. pv[graphMin}, string), create
          // a default property.
          if (characteristic != null
              && !CharacteristicInfo.C_SEVERITY.getName().equals(characteristic)) {
            property = factory.getProperty(ri);
            break;
          }
        default:
          property = factory.getProperty(ri, getValueType().getDalType(), null);
          break;
      }

      if (property != null) {
        setDalProperty(property);
      }
    } catch (Throwable e) {
      forwardError(e.getLocalizedMessage());
    }
  }