@Override @SuppressWarnings("unchecked") public void fillReadRecipe(PVDirector director, ReadRecipeBuilder builder) { synchronized(lock) { this.director = director; for (Map.Entry<String, DesiredRateExpression<T>> entry : expressions.entrySet()) { DesiredRateExpression<T> readExpression = entry.getValue(); director.connectReadExpression(readExpression); } } }
/** * Close and disconnects all the child expressions. */ private void disconnect() { synchronized(lock) { while (!readRecipies.isEmpty()) { DesiredRateExpression<?> expression = readRecipies.keySet().iterator().next(); disconnectReadExpression(expression); } } }
static <T> PVDirector<T> prepareDirector(PVReaderConfiguration<T> readConfiguration) { PVDirector<T> director = new PVDirector<>(readConfiguration.pv, readConfiguration.aggregatedFunction, PVManager.getReadScannerExecutorService(), readConfiguration.notificationExecutor, readConfiguration.dataSource, readConfiguration.exceptionHandler); if (readConfiguration.timeout != null) { if (readConfiguration.timeoutMessage == null) readConfiguration.timeoutMessage = "Read timeout"; director.readTimeout(readConfiguration.timeout, readConfiguration.timeoutMessage); } return director; }
getDirector().disconnectReadExpression(desiredRateExpression); if (newNames.get(i) != null && newExpressions.get(i) == null) { DesiredRateExpression<?> newExpression = channel(newNames.get(i), Object.class); getDirector().connectReadExpression(newExpression); newExpressions.set(i, newExpression);
static <T> void prepareDecoupler(PVDirector<T> director, PVReaderConfiguration<T> readConfiguration) { ScannerParameters scannerParameters = new ScannerParameters() .readerDirector(director) .scannerExecutor(PVManager.getReadScannerExecutorService()) .maxDuration(readConfiguration.maxRate); if (readConfiguration.aggregatedFunction instanceof Collector || readConfiguration.aggregatedFunction instanceof ValueCache) { scannerParameters.type(ScannerParameters.Type.PASSIVE); } else { scannerParameters.type(ScannerParameters.Type.ACTIVE); } SourceDesiredRateDecoupler rateDecoupler = scannerParameters.build(); readConfiguration.pv.setDirector(director); director.setScanner(rateDecoupler); director.connectReadExpression(readConfiguration.aggregatedPVExpression); rateDecoupler.start(); }
@Override public void desiredRateEvent(DesiredRateEvent event) { if (isActive()) { notifyPv(); } else { close(); } }
void close() { closed = true; disconnect(); }
public ScannerParameters readerDirector(PVDirector readerDirector) { this.listener = readerDirector.getDesiredRateEventListener(); return this; }
@Override public void fillReadRecipe(PVDirector director, ReadRecipeBuilder builder) { super.fillReadRecipe(director, builder); //To change body of generated methods, choose Tools | Templates. director.connectStaticRead(error, false, getName()); }
@Override @SuppressWarnings("unchecked") public void fillReadRecipe(PVDirector director, ReadRecipeBuilder builder) { if (function instanceof Collector) { director.registerCollector((Collector) function); } if (sourceRateChild != null) { sourceRateChild.getSourceRateExpressionImpl().fillDataRecipe(director, (Collector) function, builder); } else if (desiredRateChildren != null) { for (DesiredRateExpression<?> desiredRateExpression : desiredRateChildren.getDesiredRateExpressions()) { desiredRateExpression.fillReadRecipe(director, builder); } } }
@Override public Object calculate(final List<Object> args) { // Retrieve the new name VString value = (VString) args.get(0); String newName = null; if (value != null) { newName = value.getValue(); } // If the name does not match, disconnect and connect if (!Objects.equals(newName, previousName)) { // Disconnect previous if (currentExpression != null) { getDirector().disconnectReadExpression(currentExpression); currentExpression = null; } // Connect new if (newName != null) { currentExpression = channel(newName, Object.class); getDirector().connectReadExpression(currentExpression); } previousName = newName; } // Return value if (newName == null) { return null; } return currentExpression.getFunction().readValue(); }
/** * De-registers all listeners, stops all notifications and closes all * connections from the data sources needed by this. Once the PVReader * is closed, it can't be re-opened. Subsequent calls to close do not * do anything. */ @Override public void close() { pvReaderListeners.clear(); synchronized(lock) { director.close(); closed = true; } }
@Override public void dispose() { // Disconnect everything on dispose if (currentExpression != null) { getDirector().disconnectReadExpression(currentExpression); } currentExpression = null; }
/** * Adds the expression to the map. * * @param expression the expression to be added * @return this expression */ public ReadMap<T> add(DesiredRateExpression<T> expression) { synchronized(lock) { if (expression.getName() == null) { throw new NullPointerException("Expression has a null name"); } if (expressions.containsKey(expression.getName())) { throw new IllegalArgumentException("MapExpression already contain an expression named '" + expression.getName() + "'"); } getMapOfFunction().getMapUpdateCollector().writeValue(MapUpdate.addReadFunction(expression.getName(), expression.getFunction())); expressions.put(expression.getName(), expression); if (director != null) { director.connectReadExpression(expression); } return this; } }
@Override public void dispose() { // Disconnect everything on dispose if (currentExpressions != null) { for (DesiredRateExpression<?> desiredRateExpression : new HashSet<>(currentExpressions)) { getDirector().disconnectReadExpression(desiredRateExpression); } } currentExpressions = null; previousName = null; }
@Override public void dispose() { // Disconnect everything on dispose if (currentExpressions != null) { for (DesiredRateExpression<?> desiredRateExpression : new HashSet<>(currentExpressions)) { getDirector().disconnectReadExpression(desiredRateExpression); } } currentExpressions = null; previousNames = null; }
/** * Removes the expression with the given name. * * @param name the name of the expression to remove * @return this expression */ public ReadMap<T> remove(String name) { synchronized(lock) { if (!expressions.containsKey(name)) { throw new IllegalArgumentException("MapExpression does not contain an expression named '" + name + "'"); } getMapOfFunction().getMapUpdateCollector().writeValue(MapUpdate.<T>removeFunction(name)); DesiredRateExpression<T> expression = expressions.remove(name); if (director != null) { director.disconnectReadExpression(expression); } return this; } }
/** * Removes all the expressions currently in the map. * * @return this expression */ public ReadMap<T> clear() { synchronized(lock) { getMapOfFunction().getMapUpdateCollector().writeValue(MapUpdate.<T>clear()); if (director != null) { for (DesiredRateExpression<T> desiredRateExpression : expressions.values()) { director.disconnectReadExpression(desiredRateExpression); } } expressions.clear(); return this; } }
for (DesiredRateExpression<?> desiredRateExpression : currentExpressions) { if (desiredRateExpression != null) { getDirector().disconnectReadExpression(desiredRateExpression); getDirector().disconnectReadExpression(newExpression); newExpressions.set(0, newExpression); newExpression = channel(newName + ".LLIM", Object.class); getDirector().disconnectReadExpression(newExpression); newExpressions.set(1, newExpression); newExpression = channel(newName + ".ULIM", Object.class); getDirector().disconnectReadExpression(newExpression); newExpressions.set(2, newExpression);