/** * A list of channels with the given names, all of type VNumber. * * @param names the channel names; can't be null * @return a list of expressions representing the channels */ public static ChannelExpressionList<VNumber, Number> vNumbers(Collection<String> names) { return channels(names, VNumber.class, Number.class); }
/** * A list of channels with the given names of any type. This expression can be * used both in a read and a write expression. * * @param names the channel names; can't be null * @return an list of expressions representing the channels */ public static ChannelExpressionList<Object, Object> channels(Collection<String> names) { return channels(names, Object.class, Object.class); }
/** * A list of channels with the given names that return any of the value types. * * @param names the channel names; can't be null * @return a list of expressions representing the channels */ public static ChannelExpressionList<VType, Object> vTypes(Collection<String> names) { return channels(names, VType.class, Object.class); }
/** * A list of channels with the given names, all of type VDouble. * * @param names the channel names; can't be null * @return a list of expressions representing the channels */ public static ChannelExpressionList<VDouble, Double> vDoubles(Collection<String> names) { return channels(names, VDouble.class, Double.class); }
/** * A list of channels with the given names of any type. This expression can be * used both in a read and a write expression. * * @param names the channel names; can't be null * @return an list of expressions representing the channels */ public static ChannelExpressionList<Object, Object> channels(String... names) { return channels(Arrays.asList(names), Object.class, Object.class); }
public void m2_readMultipleChannels() { // Write a map to the channels named "one", "two" and "three" PVWriter<Map<String, Object>> pvWriter = PVManager .write(mapOf(channels("one", "two", "three"))) .async(); // Prepare the 3 values Map<String, Object> values = new HashMap<String, Object>(); values.put("one", 1.0); values.put("two", 2.0); values.put("three", "run"); // Write pvWriter.write(values); // Remember to close pvWriter.close(); // Note that when using a composite datasource, the channels can be //from different sources (e.g. "sim://noise" and "ca://mypv"). }
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 m1_readMultipleChannels() { // Read a map with the channels named "one", "two" and "three" PVReader<Map<String, Object>> pvReader = PVManager .read(mapOf(latestValueOf(channels("one", "two", "three")))) .readListener(new PVReaderListener<Map<String, Object>>() { @Override public void pvChanged(PVReaderEvent<Map<String, Object>> event) { // Print the values if any Map<String, Object> map = event.getPvReader().getValue(); if (map != null) { System.out.println("one: " + map.get("one") + " - two: " + map.get("two") + " - three: " + map.get("three")); } } }) .maxRate(ofMillis(100)); // Remember to close pvReader.close(); // Note that when using a composite datasource, the channels can be //from different sources (e.g. "sim://noise" and "ca://mypv"). }
public void v6_assemblingTables() { // You can assemble a table by giving a desired rate expression for each cell, // organizing them by column. You can use constant expressions for // labels or values that do not change. List<String> names = Arrays.asList("one", "two", "trhee"); PVReader<VTable> pvReader = PVManager .read(vTable(column("Names", vStringConstants(names)), column("Values", latestValueOf(channels(names))))) .readListener(new PVReaderListener<VTable>() { @Override public void pvChanged(PVReaderEvent<VTable> pvReader) { VTable vTable = pvReader.getPvReader().getValue(); // First column is the names @SuppressWarnings("unchecked") List<String> names = (List<String>) vTable.getColumnData(0); // Second column is the values ListDouble values = (ListDouble) vTable.getColumnData(1); // ... } }) .maxRate(ofMillis(100)); } }