org.epics.pvmanager
Class PVManager

java.lang.Object
  extended by org.epics.pvmanager.PVManager

public class PVManager
extends java.lang.Object

Entry point for the library, manages the defaults and allows to create PVReader, PVWriter and PV from an read or write expression.

NotificationExecutor - This is used for all notifications. By default this uses Executors.localThread() so that the notification are done on whatever current thread needs to notify. This means that new read notifications are run on threads managed by the ReadScannerExecutorService, write notifications are run on threads managed by the DataSource and exceptions notification are run on the thread where the exception is done. This can be changed to make all notifications routed to single threaded sub-systems, such as UI environments like SWING, SWT or similar. This can be changed on a PV by PV basis.

AsynchWriteExecutor - This is used for asynchronous writes, to return right away, and for running timeouts on each write. By default this uses the internal PVManager work pool. The work submitted here is the calculation of the corresponding WriteExpression and submission to the DataSource. The DataSource itself typically has asynchronous work, which is executed in the DataSource specific threads. Changing this to Executors.localThread() will make that preparation task on the thread that calls PVWriter.write(java.lang.Object) but it will not transform the call in a synchronous call.

ReadScannerExecutorService - This is used to run the periodic scan for new values. By default this uses the internal PVManager work pool. The work submitted here is the calculation of the corresponding DesiredRateExpression and submission to the NotificationExecutor.

Author:
carcassi

Constructor Summary
PVManager()
           
 
Method Summary
static java.util.concurrent.ScheduledExecutorService getAsyncWriteExecutor()
          Returns the current executor on which the asynchronous calls are executed.
static DataSource getDefaultDataSource()
          Returns the current default data source.
static java.util.concurrent.Executor getDefaultNotificationExecutor()
          Returns the current default executor that will execute all notifications.
static java.util.concurrent.ScheduledExecutorService getReadScannerExecutorService()
          Returns the executor service used to schedule and run the periodic reading scan for new values.
static
<T> PVReaderConfiguration<T>
read(DesiredRateExpression<T> pvExpression)
          Reads the given expression, and returns an object to configure the parameters for the read.
static
<T> PVReaderConfiguration<T>
read(SourceRateExpression<T> pvExpression)
          Reads the given expression, and returns an object to configure the parameters for the read.
static
<R,W> PVConfiguration<R,W>
readAndWrite(DesiredRateReadWriteExpression<R,W> readWriteExpression)
          Both reads and writes the given expression, and returns an object to configure the parameters for the both read and write.
static
<R,W> PVConfiguration<R,W>
readAndWrite(SourceRateReadWriteExpression<R,W> readWriteExpression)
          Both reads and writes the given expression, and returns an object to configure the parameters for the both read and write.
static void setAsyncWriteExecutor(java.util.concurrent.ScheduledExecutorService asyncWriteExecutor)
          Changes the executor used for the asynchronous write calls.
static void setDefaultDataSource(DataSource dataSource)
          Changes the default source for data.
static void setDefaultNotificationExecutor(java.util.concurrent.Executor notificationExecutor)
          Changes the default executor on which all notifications are going to be posted.
static void setReadScannerExecutorService(java.util.concurrent.ScheduledExecutorService readScannerExecutorService)
          Changes the executor service to use for executing the periodic read scan.
static
<T> PVWriterConfiguration<T>
write(WriteExpression<T> writeExpression)
          Writes the given expression, and returns an object to configure the parameters for the write.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PVManager

public PVManager()
Method Detail

setDefaultNotificationExecutor

public static void setDefaultNotificationExecutor(java.util.concurrent.Executor notificationExecutor)
Changes the default executor on which all notifications are going to be posted.

Parameters:
notificationExecutor - the new notification executor

getDefaultNotificationExecutor

public static java.util.concurrent.Executor getDefaultNotificationExecutor()
Returns the current default executor that will execute all notifications.

Returns:
the default executor

setDefaultDataSource

public static void setDefaultDataSource(DataSource dataSource)
Changes the default source for data.

Parameters:
dataSource - the data source

getDefaultDataSource

public static DataSource getDefaultDataSource()
Returns the current default data source.

Returns:
a data source or null if it was not set

read

public static <T> PVReaderConfiguration<T> read(SourceRateExpression<T> pvExpression)
Reads the given expression, and returns an object to configure the parameters for the read. At each notification it will return the latest value, even if more had been received from the last notification.

Type Parameters:
T - type of the read payload
Parameters:
pvExpression - the expression to read
Returns:
the read configuration

read

public static <T> PVReaderConfiguration<T> read(DesiredRateExpression<T> pvExpression)
Reads the given expression, and returns an object to configure the parameters for the read.

Type Parameters:
T - type of the read payload
Parameters:
pvExpression - the expression to read
Returns:
the read configuration

write

public static <T> PVWriterConfiguration<T> write(WriteExpression<T> writeExpression)
Writes the given expression, and returns an object to configure the parameters for the write.

Type Parameters:
T - type of the write payload
Parameters:
writeExpression - the expression to write
Returns:
the write configuration

readAndWrite

public static <R,W> PVConfiguration<R,W> readAndWrite(SourceRateReadWriteExpression<R,W> readWriteExpression)
Both reads and writes the given expression, and returns an object to configure the parameters for the both read and write. It's similar to use both read(org.epics.pvmanager.expression.SourceRateExpression) and write(org.epics.pvmanager.expression.WriteExpression) at the same time.

Type Parameters:
R - type of the read payload
W - type of the write payload
Parameters:
readWriteExpression - the expression to read and write
Returns:
the read and write configuration

readAndWrite

public static <R,W> PVConfiguration<R,W> readAndWrite(DesiredRateReadWriteExpression<R,W> readWriteExpression)
Both reads and writes the given expression, and returns an object to configure the parameters for the both read and write. It's similar to use both read(org.epics.pvmanager.expression.SourceRateExpression) and write(org.epics.pvmanager.expression.WriteExpression) at the same time.

Type Parameters:
R - type of the read payload
W - type of the write payload
Parameters:
readWriteExpression - the expression to read and write
Returns:
the read and write configuration

getAsyncWriteExecutor

public static java.util.concurrent.ScheduledExecutorService getAsyncWriteExecutor()
Returns the current executor on which the asynchronous calls are executed.

Returns:
the current executor

setAsyncWriteExecutor

public static void setAsyncWriteExecutor(java.util.concurrent.ScheduledExecutorService asyncWriteExecutor)
Changes the executor used for the asynchronous write calls.

Parameters:
asyncWriteExecutor - the new executor

getReadScannerExecutorService

public static java.util.concurrent.ScheduledExecutorService getReadScannerExecutorService()
Returns the executor service used to schedule and run the periodic reading scan for new values.

Returns:
the service for the read operations

setReadScannerExecutorService

public static void setReadScannerExecutorService(java.util.concurrent.ScheduledExecutorService readScannerExecutorService)
Changes the executor service to use for executing the periodic read scan.

Parameters:
readScannerExecutorService - the new service for the read operations