/** * Both reads and writes the given expression, and returns an object to configure the parameters * for the both read and write. It's similar to use both {@link #read(org.diirt.datasource.expression.SourceRateExpression) } * and {@link #write(org.diirt.datasource.expression.WriteExpression) } at the same time. * * @param <R> type of the read payload * @param <W> type of the write payload * @param readWriteExpression the expression to read and write * @return the read and write configuration */ public static <R, W> PVConfiguration<R, W> readAndWrite(SourceRateReadWriteExpression<R, W> readWriteExpression) { return readAndWrite(ExpressionLanguage.latestValueOf(readWriteExpression)); }
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 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 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 }