@Override public void write(W newValue) { writer.write(newValue); }
@Override @SuppressWarnings("unchecked") public void setValueAt(Object aValue, int rowIndex, int columnIndex) { if (columnIndex > 2) { throw new RuntimeException(); } if (columnIndex == 1) { writePvValues.set(rowIndex, aValue.toString()); pvWriters.get(rowIndex).write(aValue.toString()); } else { String name = aValue.toString(); try { if (rowIndex == writePvNames.size()) { pvWriters.add(PVManager.write(channel(name)).async()); writePvNames.add(name); writePvValues.add(""); } else { pvWriters.set(rowIndex, PVManager.write(channel(name)).async()); writePvNames.set(rowIndex, name); writePvValues.set(rowIndex, ""); } fireTableDataChanged(); } catch (Exception ex) { JOptionPane.showMessageDialog(MockDynamicTablePVFrame.this, ex.getMessage(), "Can't open pv", JOptionPane.ERROR_MESSAGE); } } }
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 b4_synchronousWrite() { PVWriter<Object> pvWriter = PVManager.write(channel("channelName")).sync(); // This will block until the write is done pvWriter.write("New value"); System.out.println("Write finished"); // Remember to close pvWriter.close(); }
public void b3_asynchronousWrite() { PVWriter<Object> pvWriter = PVManager.write(channel("channelName")) .writeListener(new PVWriterListener<Object>() { public void pvChanged(PVWriterEvent<Object> event) { if (event.isWriteSucceeded()) { System.out.println("Write finished"); } } }) .async(); // This will return right away, and the notification will be sent // on the listener pvWriter.write("New value"); // Remember to close pvWriter.close(); }