org.epics.pvmanager
Interface PVReader<T>

Type Parameters:
T - the type of the PVReader.
All Known Implementing Classes:
PV

public interface PVReader<T>

An object representing the PVReader. It contains all elements that are common to all PVs of all type. The payload is specified by the generic type, and is returned by getValue(). Changes in values are notified through the PVReaderListener. Listeners can be registered from any thread. The value can only be accessed on the thread on which the listeners is called.

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 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.
 T 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).
 void removePVReaderListener(PVReaderListener listener)
          Removes a listener to the value.
 void setPaused(boolean paused)
          Pauses or resumes the reader notifications.
 

Method Detail

addPVReaderListener

void addPVReaderListener(PVReaderListener listener)
Adds a listener to the value. This method is thread safe.

Parameters:
listener - a new listener

addPVReaderListener

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. This method is thread safe.

Parameters:
clazz - type to filter notifications for
listener - a new listener

removePVReaderListener

void removePVReaderListener(PVReaderListener listener)
Removes a listener to the value. This method is thread safe.

Parameters:
listener - the old listener

getName

java.lang.String getName()
Returns the name of the PVReader. This method is thread safe.

Returns:
the value of name

getValue

T getValue()
Returns the value of the PVReader. Not thread safe: can be safely accessed only as part of the PVReaderListener.

Returns:
the value of value

close

void close()
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.


isClosed

boolean isClosed()
True if no more notifications are going to be sent for this PVReader.

Returns:
true if closed

lastException

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).

Returns:
the last generated exception or null

setPaused

void setPaused(boolean paused)
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.

Parameters:
paused - whether the reader should be paused or not

isPaused

boolean isPaused()
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.

Returns:
true if it is paused

isConnected

boolean isConnected()
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.

Returns: