Пример #1
0
  @Override
  public int match(ValueCache<?> cache, JCAConnectionPayload connPayload) {
    Channel channel = connPayload.getChannel();

    // If the generated type can't be put in the cache, no match
    if (!cache.getType().isAssignableFrom(typeClass)) return 0;

    // If the type of the channel does not match, no match
    if (!dbrTypeMatch(epicsValueType, connPayload.getFieldType())) return 0;

    // If processes array, but count is 1, no match
    if (array != null && array && channel.getElementCount() == 1) return 0;

    // If processes scalar, but the count is not 1, no match
    if (array != null && !array && channel.getElementCount() != 1) return 0;

    // Everything matches
    return 1;
  }
Пример #2
0
  @Override
  @SuppressWarnings("unchecked")
  public boolean updateCache(
      ValueCache cache, JCAConnectionPayload connPayload, JCAMessagePayload message) {
    Channel channel = connPayload.getChannel();

    // If metadata is required and not present, no update
    if (epicsMetaType != null && message.getMetadata() == null) return false;

    // If value is not present, no update
    if (message.getEvent() == null) return false;

    Object value = createValue(message.getEvent().getDBR(), message.getMetadata(), connPayload);
    cache.writeValue(value);
    return true;
  }