org.epics.pvmanager
Class PV<R,W>

java.lang.Object
  extended by org.epics.pvmanager.PV<R,W>
Type Parameters:
R - type of the read payload
W - type of the write payload
All Implemented Interfaces:
PVReader<R>, PVWriter<W>

public class PV<R,W>
extends java.lang.Object
implements PVReader<R>, PVWriter<W>

A PV that can be both read and written. In general, the read payload will be different from the write payload.

Author:
carcassi

Method Summary
 void addPVReaderListener(java.lang.Class<?> clazz, PVReaderListener listener)
          Adds a listener to the value, which is notified only if the value is of a given type.
 void addPVReaderListener(PVReaderListener listener)
          Adds a listener to the value.
 void addPVWriterListener(PVWriterListener listener)
          Adds a listener to the value.
 void close()
          De-registers all listeners, stops all notifications and closes all connections from the data sources needed by this.
 java.lang.String getName()
          Returns the name of the PVReader.
 R getValue()
          Returns the value of the PVReader.
 boolean isClosed()
          True if no more notifications are going to be sent for this PVReader.
 boolean isConnected()
          True if the reader is connected.
 boolean isPaused()
          Whether the reader is paused.
 java.lang.Exception lastException()
          Returns the last exception that was generated preparing the value for this PVReader and clears it (subsequent call will return null).
 java.lang.Exception lastWriteException()
          Returns the last exception that was generated by write operations and clears it (subsequent call will return null).
 void removePVReaderListener(PVReaderListener listener)
          Removes a listener to the value.
 void removePVWriterListener(PVWriterListener listener)
          Removes a listener to the value.
 void setPaused(boolean paused)
          Pauses or resumes the reader notifications.
 void write(W newValue)
          Writes a new value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addPVWriterListener

public void addPVWriterListener(PVWriterListener listener)
Description copied from interface: PVWriter
Adds a listener to the value. This method is thread safe.

Specified by:
addPVWriterListener in interface PVWriter<W>
Parameters:
listener - a new listener

removePVWriterListener

public void removePVWriterListener(PVWriterListener listener)
Description copied from interface: PVWriter
Removes a listener to the value. This method is thread safe.

Specified by:
removePVWriterListener in interface PVWriter<W>
Parameters:
listener - the old listener

write

public void write(W newValue)
Description copied from interface: PVWriter
Writes a new value. This method can be synchronous or synchronous depending on how the PV was created.

Specified by:
write in interface PVWriter<W>

lastWriteException

public java.lang.Exception lastWriteException()
Description copied from interface: PVWriter
Returns the last exception that was generated by write operations and clears it (subsequent call will return null).

Specified by:
lastWriteException in interface PVWriter<W>
Returns:
the last generated exception or null

addPVReaderListener

public void addPVReaderListener(PVReaderListener listener)
Description copied from interface: PVReader
Adds a listener to the value. This method is thread safe.

Specified by:
addPVReaderListener in interface PVReader<R>
Parameters:
listener - a new listener

addPVReaderListener

public void addPVReaderListener(java.lang.Class<?> clazz,
                                PVReaderListener listener)
Description copied from interface: PVReader
Adds a listener to the value, which is notified only if the value is of a given type. This method is thread safe.

Specified by:
addPVReaderListener in interface PVReader<R>
Parameters:
clazz - type to filter notifications for
listener - a new listener

removePVReaderListener

public void removePVReaderListener(PVReaderListener listener)
Description copied from interface: PVReader
Removes a listener to the value. This method is thread safe.

Specified by:
removePVReaderListener in interface PVReader<R>
Parameters:
listener - the old listener

getName

public java.lang.String getName()
Description copied from interface: PVReader
Returns the name of the PVReader. This method is thread safe.

Specified by:
getName in interface PVReader<R>
Returns:
the value of name

getValue

public R getValue()
Description copied from interface: PVReader
Returns the value of the PVReader. Not thread safe: can be safely accessed only as part of the PVReaderListener.

Specified by:
getValue in interface PVReader<R>
Returns:
the value of value

close

public void close()
Description copied from interface: PVReader
De-registers all listeners, stops all notifications and closes all connections from the data sources needed by this. Once the PVReader is closed, it can't be re-opened. Subsequent calls to close do not do anything.

Specified by:
close in interface PVReader<R>
Specified by:
close in interface PVWriter<W>

isClosed

public boolean isClosed()
Description copied from interface: PVReader
True if no more notifications are going to be sent for this PVReader.

Specified by:
isClosed in interface PVReader<R>
Specified by:
isClosed in interface PVWriter<W>
Returns:
true if closed

lastException

public java.lang.Exception lastException()
Description copied from interface: PVReader
Returns the last exception that was generated preparing the value for this PVReader and clears it (subsequent call will return null).

Specified by:
lastException in interface PVReader<R>
Returns:
the last generated exception or null

isPaused

public boolean isPaused()
Description copied from interface: PVReader
Whether the reader is paused. If a reader is paused, all the notifications are skipped. While the channels remains open, and data is still being collected, the computation after the collectors is suspended, which saves computation resources.

Specified by:
isPaused in interface PVReader<R>
Returns:
true if it is paused

setPaused

public void setPaused(boolean paused)
Description copied from interface: PVReader
Pauses or resumes the reader notifications.

Note that since notifications may still be in flight, you may receive notifications after setting the pause state to on. The paused flag on the reader, though, is changed immediately.

Specified by:
setPaused in interface PVReader<R>
Parameters:
paused - whether the reader should be paused or not

isConnected

public boolean isConnected()
Description copied from interface: PVReader
True if the reader is connected. Do not use this method to display connection status if using vTypes defined in org.epics.pvmanager.data.

Currently, a reader is defined as connected if all the channels are connected. This means that you still may get updates even if this method returns false. You can use this method to determine whether your notification comes from a complete set.

When using VTypes, you should use the Alarm interface to get the connection status. This scales when you get aggregates, such as lists or maps of channels. This method does obviously not scale functionally since, in an aggregate, it can't tell you which channel of the set is connected or not.

Specified by:
isConnected in interface PVReader<R>
Returns: