/** * Sets a timeout for both reader and writer. * * @param timeout duration of the timeout * @return this expression */ @Override public PVConfiguration<R, W> timeout(Duration timeout) { pvReaderConfiguration.timeout(timeout); pvWriterConfiguration.timeout(timeout); return this; }
/** * Sets a timeout with the given message for both read and writer. * * @param timeout duration of the timeout * @param timeoutMessage message for the timeout * @return this expression */ @Override public PVConfiguration<R, W> timeout(Duration timeout, String timeoutMessage) { pvReaderConfiguration.timeout(timeout, timeoutMessage); pvWriterConfiguration.timeout(timeout, timeoutMessage); return this; }
/** * Specifies a timeout, with a different message for the read and the write. * * @param timeout time before notification * @param readMessage exception message for the read timeout * @param writeMessage exception message for the write timeout * @return this */ public PVConfiguration<R, W> timeout(Duration timeout, String readMessage, String writeMessage) { pvReaderConfiguration.timeout(timeout, readMessage); pvWriterConfiguration.timeout(timeout, writeMessage); return this; }
startTime = System.currentTimeMillis(); pv = PVManager.read(formula(pvName.getText())) .timeout(ofSeconds(5)) .readListener(new PVReaderListener<Object>() { @Override
public void b8_readTimeout() { // If after 5 seconds no new value comes (i.e. pvReader.getValue() == null) // then a timeout is sent. PVManager will _still_ try to connect, // until pvReader.close() is called. // The timeout will be notified only on the first connection. final PVReader<Object> pvReader = PVManager.read(channel("channelName")) .timeout(ofSeconds(5)) .readListener(new PVReaderListener<Object>() { @Override public void pvChanged(PVReaderEvent<Object> event) { // Timeout are passed as exceptions. This allows you to // treat them as any other error conditions. Exception ex = event.getPvReader().lastException(); if (ex instanceof TimeoutException) { System.out.println("Didn't connected after 5 seconds"); } } }) .maxRate(ofMillis(100)); } }