/** * Creates the pv such that writes are synchronous 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> synchWriteAndMaxReadRate(Duration period) { PVReader<R> pvReader = pvReaderConfiguration.maxRate(period); PVWriter<W> pvWriter = pvWriterConfiguration.sync(); return new PV<R, W>(pvReader, pvWriter); }
public void b5_readAndWrite() { // A PV is both a PVReader and a PVWriter PV<Object, Object> pv = PVManager.readAndWrite(channel("channelName")) .readListener(new PVReaderListener<Object>() { @Override public void pvChanged(PVReaderEvent<Object> event) { // Do something with each value Object newValue = event.getPvReader().getValue(); System.out.println(newValue); } }) .asynchWriteAndMaxReadRate(ofMillis(10)); pv.write("New value"); // Remember to close pv.close(); }
public void m3_readWriteMultipleChannels() { // Read and write a map to the channels named "one", "two" and "three" PV<Map<String, Object>, Map<String, Object>> pv = PVManager .readAndWrite(mapOf(latestValueOf(channels("one", "two", "three")))) .asynchWriteAndMaxReadRate(ofMillis(100)); // Do something // ... // Remember to close pv.close(); }
public void v1_readNumericType() { // Let's statically import so the code looks cleaner // import static org.epics.pvmanager.data.ExpressionLanguage.*; // Read and Write a vNumber // Note that the read type is different form the write type final PV<VNumber, Number> pv = PVManager.readAndWrite(vNumber("currentRB")) .readListener(new PVReaderListener<VNumber>() { @Override public void pvChanged(PVReaderEvent<VNumber> event) { VNumber value = event.getPvReader().getValue(); if (value != null) { System.out.println(value.getValue() + " " + value.getAlarmSeverity()); } } }) .asynchWriteAndMaxReadRate(ofMillis(10)); pv.write(1.0); // Remember to close pv.close(); // For a full list of types, refer to org.epics.pvmanager.data.ExpressionLanguage }
/** * 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; }