Example #1
0
  /** {@inheritDoc} */
  @Override
  protected void doSetValueAsynchronously(
      Object value, final IProcessVariableWriteListener listener) throws Exception {
    if (waitTillConnected(3000)) {
      if (_dalProperty.isSettable()) {
        Object convertedValue;
        try {
          convertedValue = ConverterUtil.convert(value, getValueType());

          _dalProperty.setAsynchronous(
              convertedValue,
              new ResponseListener() {

                public void responseReceived(ResponseEvent event) {
                  if (listener != null) {
                    listener.success();
                  }
                  LOG.debug(event.getResponse().toString());
                }

                public void responseError(ResponseEvent event) {
                  if (listener != null) {
                    listener.error(event.getResponse().getError());
                  }
                  LOG.error(event.getResponse().getError().toString());
                }
              });

        } catch (NumberFormatException nfe) {
          // Do nothing! Is a invalid value format!
          LOG.warn("Invalid value format. (" + value + ") is not set to " + getName());
          return;
        }
      } else {
        throw new Exception("Property " + _dalProperty.getUniqueName() + " is not settable");
      }
    } else {
      throw new Exception("Property not available");
    }
  }
Example #2
0
  /** {@inheritDoc} */
  @Override
  protected Object doGetCharacteristicSynchronously(String characteristicId, ValueType valueType)
      throws Exception {

    Object result = null;

    // ... try to read the value
    if (waitTillConnected(CONNECTION_TIMEOUT)) {
      if (characteristicId.equals(CharacteristicInfo.C_SEVERITY.getName())) {
        result = EpicsUtil.toEPICSFlavorSeverity(_dalProperty.getCondition());
      } else if (characteristicId.equals(CharacteristicInfo.C_STATUS.getName())) {
        result = EpicsUtil.extratStatus(_dalProperty.getCondition());
      } else if (characteristicId.equals(CharacteristicInfo.C_TIMESTAMP.getName())) {
        result = _dalProperty.getCondition().getTimestamp();
      } else {
        Object tmp = _dalProperty.getCharacteristic(characteristicId);
        result = valueType != null ? ConverterUtil.convert(tmp, valueType) : tmp;
      }
    }

    return result;
  }
Example #3
0
  /** {@inheritDoc} */
  @Override
  protected boolean doSetValueSynchronously(Object value) {
    boolean success = false;

    if (waitTillConnected(CONNECTION_TIMEOUT)) {
      if (_dalProperty.isSettable()) {
        try {
          _dalProperty.setValue(ConverterUtil.convert(value, getValueType()));
          success = true;
        } catch (NumberFormatException nfe) {
          LOG.warn("Invalid value format. (" + value + ") is not set to" + getName());
        } catch (DataExchangeException e) {
          LOG.error(e.toString());
        }
      } else {
        printDebugInfo("Property not settable");
      }
    } else {
      printDebugInfo("Property not available");
    }
    return success;
  }