@Override @SuppressWarnings("unchecked") public boolean updateCache(ValueCache cache, Object connection, Object message) { Object oldValue = cache.readValue(); cache.writeValue(message); if ((message == oldValue) || (message != null && message.equals(oldValue))) return false; return true; } };
@Override public void writeValue(T newValue) { synchronized(forwardFunction) { valueCache.writeValue(newValue); R forwardValue = forwardFunction.readValue(); forwardWriter.writeValue(forwardValue); } }
/** * Creates a constant expression that always return that object, with the * given name for the expression. * This is useful to test expressions or to introduce data that is available * at connection time at that will not change. * * @param <T> type of the value * @param value the actual value * @param name the name of the expression * @return an expression that is always going to return the given value */ public static <T> DesiredRateExpression<T> constant(T value, String name) { Class<?> clazz = Object.class; if (value != null) clazz = value.getClass(); @SuppressWarnings("unchecked") ValueCache<T> cache = (ValueCache<T>) new ValueCacheImpl(clazz); if (value != null) cache.writeValue(value); return new DesiredRateExpressionImpl<T>(new DesiredRateExpressionListImpl<T>(), cache, name); }
@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; }
@Override @SuppressWarnings("unchecked") public boolean updateCache(@SuppressWarnings("rawtypes") ValueCache cache, PVAChannelHandler channel, PVStructure message) { PVField valueField = null; String extractFieldName = channel.getExtractFieldName(); if (extractFieldName != null) { if (channel.getChannelType().getType() == Type.structure) message = message.getStructureField(extractFieldName); else // this avoids problem when scalars/scalar arrays needs to be passed as PVStructure message valueField = message.getSubField(extractFieldName); } Object value = createValue(message, valueField, !channel.isConnected()); cache.writeValue(value); return true; }