gov.sns.tools.pvlogger
Class ChannelWrapper

java.lang.Object
  |
  +--gov.sns.tools.pvlogger.ChannelWrapper

public class ChannelWrapper
extends java.lang.Object

ChannelWrapper is a wrapper for a Channel that handles connecting to the channel and setting up a monitor when its channel is connected. Cache the latest channel record that has been found by the monitor.


Nested Class Summary
protected  class ChannelWrapper.ConnectionHandler
          Connection handler is a class whose instance listens for connection events of the wrapped channel.
 
Field Summary
protected  Channel _channel
          The channel to wrap
protected  ChannelWrapper.ConnectionHandler _connectionHandler
          The handler handles channel connection events
protected  Monitor _monitor
          The monitor for the channel
protected  ChannelTimeRecord _record
          The latest channel record found by the monitor
 
Constructor Summary
ChannelWrapper(java.lang.String pv)
          ChannelWrapper constructor
 
Method Summary
 void addConnectionListener(ConnectionListener listener)
          Add the specified object as a listener of channel connection events of the channel that is wrapped.
 void dispose()
          Dispose of the channel resources: Shutdown the monitor if a monitor is active.
 Channel getChannel()
          Get the wrapped channel.
 java.lang.String getPV()
          Get the PV for the channel being wrapped.
 ChannelTimeRecord getRecord()
          Get the latest channel record cached.
protected  void makeMonitor()
          Create a monitor to listen for new channel records.
 void removeConnectionListener(ConnectionListener listener)
          Remove the specified object from being a listener of channel connection events of the channel that is wrapped.
protected  void requestConnection()
          Request that the channel be connected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_channel

protected Channel _channel
The channel to wrap


_monitor

protected Monitor _monitor
The monitor for the channel


_record

protected ChannelTimeRecord _record
The latest channel record found by the monitor


_connectionHandler

protected ChannelWrapper.ConnectionHandler _connectionHandler
The handler handles channel connection events

Constructor Detail

ChannelWrapper

public ChannelWrapper(java.lang.String pv)
ChannelWrapper constructor

Parameters:
pv - The PV for which to create a channel.
Method Detail

dispose

public void dispose()
Dispose of the channel resources: Shutdown the monitor if a monitor is active. Remove the connection handler as a connection listener of the channel.


addConnectionListener

public void addConnectionListener(ConnectionListener listener)
Add the specified object as a listener of channel connection events of the channel that is wrapped.

Parameters:
listener - the object to add as a connection listener.

removeConnectionListener

public void removeConnectionListener(ConnectionListener listener)
Remove the specified object from being a listener of channel connection events of the channel that is wrapped.

Parameters:
listener - the object to remove from being a connection listener

requestConnection

protected void requestConnection()
Request that the channel be connected. When the channel connection occurs, create a monitor. If a channel is dropped then clear the record.


makeMonitor

protected void makeMonitor()
Create a monitor to listen for new channel records. An instance of an internal anonymous class is the listener of the monitor events and caches the latest channel record.


getPV

public java.lang.String getPV()
Get the PV for the channel being wrapped.

Returns:
the PV

getChannel

public Channel getChannel()
Get the wrapped channel.

Returns:
the wrapped channel

getRecord

public ChannelTimeRecord getRecord()
Get the latest channel record cached.

Returns:
the latest channel record cached.