Class cern.lhcias.csgui.Drivers.SocketDriver

java.lang.Object
   |
   +----cern.lhcias.csgui.Drivers.SocketDriver

public class SocketDriver
extends Object
implements Runnable,DataServer

This class is a socket based network driver. It implements
the interface DataServer. It works either on a pooling base or
in an event driven way. By default it works on an event driven way.
The protocol used is the following:
1/To get the values of tags, the following command is sent
GET tagname1,tagname2,...\r\n
The driver will then wait for the value. The returned string is
assumed to have the following format:
tagname1=value1,tagname2=value2...
2/To subscribe to some tags in an event driven way, the following
command is sent
SUB tagname1,tagname2,...\r\n
It then wait for any changes on the data. The server has the
responsibilty to send the changes.
Whenever the subscription tags' list has changed, a new list is sent which
replaces the previous one.
3/To end the subscritpion mechanism, the following command is sent:
UNS
4/To set tags' values, the following command is sent
SET tagname1=value1,tagname2=value2...\r\n

It is assumed that the server can process in parallel a subscription mechanism
and atomic commands like GET or SET.
Changing one of the property while a connection is established
doesn't automatically close the connection. Thus it is the responsibility
of the calling class to close and reopen a connection if needed.

See Also:
DataServer

Variable Index

 o driverType
 
 o ONCHANGE
 
 o POLLING
 

Constructor Index

 o SocketDriver()
 
 o SocketDriver(String, int)
 
 o SocketDriver(String, String)
 

Method Index

 o addAlarmListener(AlarmListener)
 
 o close()
Stop an eventual running thread and close the socket channel.
 o closeConnection()
 
 o disable()
 
 o doYouImplement(String)
 
 o enable()
If the connexion is not already opened, then it will be opened.
 o finalize()
 
 o getDriverProtocol()
 
 o getMask()
 
 o getParameter(String)
 
 o getPassword()
 
 o getPoolingInterval()
 
 o getPossibleProtocols()
 
 o getProcessName()
 
 o getReadHost()
 
 o getReadPort()
 
 o getTagsSubscription()
 
 o getType()
 
 o getUser()
 
 o getWriteHost()
 
 o getWritePort()
 
 o isActive()
 
 o listen()
 
 o newTags()
 
 o open()
 
 o read()
get through the network the values of the tags listed in TagArrays which are linked to this DataServer.
 o read(String)
get through the network the value of the tag named name and returns it.
 o read(Vector)
get through the network the values of the tags listed in Vector names.
 o removeAlarmListener(AlarmListener)
 
 o run()
 
 o sendCommand(String)
sends the command cmd to the server through the socket channel and waits for the returned string.
 o sendCommandNoReturn(String)
sends the command cmd to the server through the socket channel and returns immediately.
 o sendSubscribeCommand()
Sends a subscription request to the remote server for all the Tags listed in TagArrays which are linked to this DataServer.
 o setConfig(String)
Config is in the following format ProcessName;Protocol;Type;ReadHost;ReadPort;WriteHost;WritePort; PoolFrequency;subscriptionMode[;param1=val1[;...]]
 o setMask(boolean)
if Mask is on, then the modifications to the Tags won't be sent to TagArrays
 o setParameter(String, String)
 
 o setPassword(String)
 
 o setPoolingInterval(long)
 
 o setProcessName(String)
 
 o setReadHost(String)
 
 o setReadPort(int)
 
 o setTagArrays(TagArrays)
 
 o setTagsSubscription(boolean)
 
 o setType(String)
 
 o setup(String, int)
Stop an eventual running thread and open the socket channel.
 o setUser(String)
 
 o setWriteHost(String)
 
 o setWritePort(int)
 
 o toString()
The returned string is in the following format ProcessName;Protocol;Type;ReadHost;ReadPort;WriteHost;WritePort; PoolFrequency;subscriptionMode[;param1=val1[;...]]
 o write(String, String)
sends the command "SET name=stringValue" to the server through the socket channel and returns immediately.

Variables

 o driverType

 public static final String driverType

 o ONCHANGE

 public static final String ONCHANGE

 o POLLING

 public static final String POLLING

Constructors

 o SocketDriver

 public SocketDriver()

 o SocketDriver

 public SocketDriver(String Host,
                     int Port)

 o SocketDriver

 public SocketDriver(String Host,
                     String portString)

Methods

 o addAlarmListener

 public void addAlarmListener(AlarmListener listener)

 o removeAlarmListener

 public void removeAlarmListener(AlarmListener listener)

 o setTagArrays

 public void setTagArrays(TagArrays tc)

 o setReadHost

 public void setReadHost(String Host)

 o getReadHost

 public String getReadHost()

 o setReadPort

 public void setReadPort(int communicationReadPort)

 o getReadPort

 public int getReadPort()

 o setWriteHost

 public void setWriteHost(String host_url)

 o getWriteHost

 public String getWriteHost()

 o setWritePort

 public void setWritePort(int communicationWritePort)

 o getWritePort

 public int getWritePort()

 o setPoolingInterval

 public void setPoolingInterval(long Interval)

 o getPoolingInterval

 public long getPoolingInterval()

 o setType

 public void setType(String Type)
Parameters:
communication_type - ONCHANGE or POOLING

 o getType

 public String getType()

 o setMask

 public void setMask(boolean Mask)
if Mask is on, then the modifications to the Tags won't be sent to TagArrays

 o getMask

 public boolean getMask()

 o setUser

 public void setUser(String User)

 o setPassword

 public void setPassword(String Password)

 o getUser

 public String getUser()

 o getPassword

 public String getPassword()

 o setParameter

 public void setParameter(String parameter,
                          String value)

 o getParameter

 public String getParameter(String parameter)

 o isActive

 public boolean isActive()

 o setTagsSubscription

 public void setTagsSubscription(boolean subMode)

 o getTagsSubscription

 public boolean getTagsSubscription()

 o setProcessName

 public void setProcessName(String processname)

 o getProcessName

 public String getProcessName()

 o doYouImplement

 public boolean doYouImplement(String type)

 o getPossibleProtocols

 public Vector getPossibleProtocols()

 o getDriverProtocol

 public String getDriverProtocol()

 o setConfig

 public void setConfig(String config)
Config is in the following format ProcessName;Protocol;Type;ReadHost;ReadPort;WriteHost;WritePort; PoolFrequency;subscriptionMode[;param1=val1[;...]]

 o toString

 public String toString()
The returned string is in the following format ProcessName;Protocol;Type;ReadHost;ReadPort;WriteHost;WritePort; PoolFrequency;subscriptionMode[;param1=val1[;...]]
Overrides:
toString in class Object

 o enable

 public void enable()
If the connexion is not already opened, then it will be opened. A thread will then be created either on POLLING or ONCHANGE mode, even if the mask is on. However no change will be sent to TagArrays if mask is on.

 o open

 public void open()

 o setup

 public void setup(String host,
                   int port)
Stop an eventual running thread and open the socket channel.

 o disable

 public void disable()

 o closeConnection

 public void closeConnection()

 o close

 public void close()
Stop an eventual running thread and close the socket channel.

 o sendCommand

 public String sendCommand(String cmd)
sends the command cmd to the server through the socket channel and waits for the returned string. This string is returned back. If mask is on, nothing happens and an empty String is returned. If a thread is already listening to messages from the remote server (ONCHANGE mode) then the method is not waiting for the answer ("" is returned). The answer is assumed to be received by the listening thread.

 o sendCommandNoReturn

 public void sendCommandNoReturn(String cmd)
sends the command cmd to the server through the socket channel and returns immediately. If mask is on, nothing happens.

 o write

 public void write(String name,
                   String stringValue)
sends the command "SET name=stringValue" to the server through the socket channel and returns immediately. If mask is on, nothing happens.

 o read

 public String read(String name)
get through the network the value of the tag named name and returns it. If mask is on, nothing happens and an empty String is returned. If a thread is already listening to messages from the remote server (ONCHANGE mode) then the method is not waiting for the answer ("" is returned). The answer is assumed to be received by the listening thread.

 o read

 public boolean read(Vector names)
get through the network the values of the tags listed in Vector names. The values are sent to TagArrays. If mask is on, nothing happens and false is returned.

 o read

 public void read()
get through the network the values of the tags listed in TagArrays which are linked to this DataServer. The values are sent to TagArrays. If mask is on, nothing happens.

 o sendSubscribeCommand

 public void sendSubscribeCommand()
Sends a subscription request to the remote server for all the Tags listed in TagArrays which are linked to this DataServer. If mask is on, nothing happens.

 o newTags

 public boolean newTags()

 o run

 public void run()

 o listen

 public void listen()

 o finalize

 public synchronized void finalize()
Overrides:
finalize in class Object