void setValue(T value) { synchronized(lock) { this.value = value; valueToNotify = true; } firePvValueChanged(); }
/** * Adds a listener to the value. This method is thread safe. * * @param listener a new listener */ @Override public void addPVReaderListener(PVReaderListener<? super T> listener) { if (isClosed()) throw new IllegalStateException("Can't add listeners to a closed PV"); @SuppressWarnings("unchecked") PVReaderListener<T> convertedListener = (PVReaderListener<T>) listener; pvReaderListeners.add(convertedListener); }
pv.setConnected(connected); if (lastException != null) { if (lastException instanceof TimeoutException && pv.setLastException(lastException); NotificationSupport.notification(pv.getValue(), finalValue); pv.setValue(notification.getNewValue()); } else if (pv.isLastExceptionToNotify() || pv.isReadConnectionToNotify()) { pv.firePvValueChanged(); if (pv.isLastExceptionToNotify() || pv.isReadConnectionToNotify()) { pv.firePvValueChanged();
void preparePvReader() { pv = new PVReaderImpl<>(aggregatedPVExpression.getName(), localThread() == notificationExecutor); for (PVReaderListener<T> pVReaderListener : readListeners) { pv.addPVReaderListener(pVReaderListener); } aggregatedFunction = aggregatedPVExpression.getFunction(); } }
/** * Creates the pv such that writes are asynchronous and read notifications * comes at most at the rate specified. * * @param period minimum time between read notifications * @return a new PV */ public PV<R, W> asynchWriteAndMaxReadRate(Duration period) { PVReader<R> pvReader = pvReaderConfiguration.maxRate(period); PVWriter<W> pvWriter = pvWriterConfiguration.async(); PV<R, W> pv = new PV<R, W>(pvReader, pvWriter); // XXX: This should really be set before the scanning starts PVReaderImpl.implOf(pvReader).setReaderForNotification(pv); PVWriterImpl.implOf(pvWriter).setWriterForNotification(pv); return pv; }
/** * Posts a readTimeout exception in the exception queue. * * @param timeoutMessage the message for the readTimeout */ private void processReadTimeout(String timeoutMessage) { PVReaderImpl<T> pv = pvReaderRef.get(); if (pv != null && !pv.isSentFirsEvent()) { readExceptionCollector.writeValue(new TimeoutException(timeoutMessage)); } }
/** * Adds a listener to the value, which is notified only if the value is * of a given type. This method is thread safe. * * @param listener a new listener */ @Override public void addPVReaderListener(final Class<?> clazz, final PVReaderListener listener) { if (isClosed()) throw new IllegalStateException("Can't add listeners to a closed PV"); pvReaderListeners.add(new ListenerDelegate<T>(clazz, listener)); }