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

driverType
public static final String driverType

ONCHANGE
public static final String ONCHANGE

POLLING
public static final String POLLING

SocketDriver
public SocketDriver()

SocketDriver
public SocketDriver(String Host,
int Port)

SocketDriver
public SocketDriver(String Host,
String portString)

addAlarmListener
public void addAlarmListener(AlarmListener listener)

removeAlarmListener
public void removeAlarmListener(AlarmListener listener)

setTagArrays
public void setTagArrays(TagArrays tc)

setReadHost
public void setReadHost(String Host)

getReadHost
public String getReadHost()

setReadPort
public void setReadPort(int communicationReadPort)

getReadPort
public int getReadPort()

setWriteHost
public void setWriteHost(String host_url)

getWriteHost
public String getWriteHost()

setWritePort
public void setWritePort(int communicationWritePort)

getWritePort
public int getWritePort()

setPoolingInterval
public void setPoolingInterval(long Interval)

getPoolingInterval
public long getPoolingInterval()

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

getType
public String getType()

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

getMask
public boolean getMask()

setUser
public void setUser(String User)

setPassword
public void setPassword(String Password)

getUser
public String getUser()

getPassword
public String getPassword()

setParameter
public void setParameter(String parameter,
String value)

getParameter
public String getParameter(String parameter)

isActive
public boolean isActive()

setTagsSubscription
public void setTagsSubscription(boolean subMode)

getTagsSubscription
public boolean getTagsSubscription()

setProcessName
public void setProcessName(String processname)

getProcessName
public String getProcessName()

doYouImplement
public boolean doYouImplement(String type)

getPossibleProtocols
public Vector getPossibleProtocols()

getDriverProtocol
public String getDriverProtocol()

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

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

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.

open
public void open()

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

disable
public void disable()

closeConnection
public void closeConnection()

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

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.

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.

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.

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.

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.

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.

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.

newTags
public boolean newTags()

run
public void run()

listen
public void listen()

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