org.csstudio.utility.pv
Interface PV


public interface PV

A control system PV.

When 'start'ed, the PV will attempt to connect or do whatever is needed to obtain the meta information like units, precision, ... Then it will subscribe to updates of the current value.

While the PVListener might receive events on a non-UI thread, all the calls to the PV should come from the UI thread to prevent possible deadlocks. (The JNI CA client has deadlocked when both UI and non-UI threads called into it at the 'same' time).

Author:
Kay Kasemir

Method Summary
 void addListener(PVListener listener)
          Add a new listener.
 java.lang.String getName()
           
 java.lang.String getStateInfo()
          Internal state information on the PV.
 IValue getValue()
          Get the value.
 IValue getValue(double timeout_seconds)
          Synchronous 'get'.
 boolean isConnected()
           
 boolean isRunning()
           
 boolean isWriteAllowed()
           
 void removeListener(PVListener listener)
          Remove a listener.
 void setValue(java.lang.Object new_value)
          Set PV to given value.
 void start()
          Start the PV: connect, get meta data, subscribe to updates, invoke PVListener for incoming values, ...
 void stop()
          Stop the PV: disconnect, ...
 

Method Detail

getName

java.lang.String getName()
Returns:
Returns the name.

getValue

IValue getValue(double timeout_seconds)
                throws java.lang.Exception
Synchronous 'get'.

Attempts to get a value within the given timeout. Either returns a value within the timeout, or throws an exception at the timeout.

When called for a new channel, i.e. on a channel where neither get nor start have been called, it will also perform the connection attempt, and leave the channel connected after getting a value. To force a disconnect, call stop.

Parameters:
timeout_seconds - Timeout in seconds.
Returns:
Value
Throws:
java.lang.Exception - on error

addListener

void addListener(PVListener listener)
Add a new listener.

See Also:
PVListener

removeListener

void removeListener(PVListener listener)
Remove a listener.


start

void start()
           throws java.lang.Exception
Start the PV: connect, get meta data, subscribe to updates, invoke PVListener for incoming values, ...

Throws:
java.lang.Exception
See Also:
addListener(PVListener), stop()

isRunning

boolean isRunning()
Returns:
Returns true between start() and stop().

isConnected

boolean isConnected()
Returns:
Returns true when connected. While isRunning, we are subscribed for value updates, but we might still be disconnected, at least temporarily.

isWriteAllowed

boolean isWriteAllowed()
Returns:
true if we have write access to the PV

getStateInfo

java.lang.String getStateInfo()
Internal state information on the PV.

Especially when isConnected() is false, this information might help to diagnose the problem: Did the PV never connect? Was it once connected, but some error occurred?

Returns:
Some human readable state info

stop

void stop()
Stop the PV: disconnect, ... When the PV is no longer needed, one should 'stop' it to release resources.


getValue

IValue getValue()
Get the value.

This is the most recent value. Check isConnected() to see if this is valid, or use inside a PV listener's value update.

Returns:
Returns the most recent value, or null if there is none.
See Also:
PVListener, isConnected()

setValue

void setValue(java.lang.Object new_value)
              throws java.lang.Exception
Set PV to given value. Should accept Double, Double[], Integer, String, maybe more.

Parameters:
new_value - Value to write to PV
Throws:
java.lang.Exception - on error