@Override public void write(W newValue) { writer.write(newValue); }
@Override public void addPVWriterListener(PVWriterListener<? extends W> listener) { writer.addPVWriterListener(listener); }
/** * Determines whether the notifier is active or not. * <p> * The notifier becomes inactive if the PVWriter is closed or is garbage collected. * The first time this function determines that the notifier is inactive, * it will ask the data source to close all channels relative to the * pv. * * @return true if new notification should be performed */ boolean isActive() { // Making sure to get the reference once for thread safety final PVWriter<T> pv = pvRef.get(); if (pv != null && !pv.isClosed()) { return true; } else { return false; } }
@Override public void close() { reader.close(); writer.close(); }
@Override public boolean isWriteConnected() { return writer.isWriteConnected(); }
@Override public void removePVWriterListener(PVWriterListener<? extends W> listener) { writer.removePVWriterListener(listener); }
@Override public Exception lastWriteException() { return writer.lastWriteException(); }
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 m5_writeOrdering() { // Write a map to the channels named "one", "two" and "three" // Write "two" after "one" and write "three" after "two" PVWriter<Map<String, Object>> pvWriter = PVManager.write( mapOf(channel("one") .and(channel("two").after("one")) .and(channel("three").after("two")))).async(); // Do something // ... // 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(); }
@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); } } }