|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectFourMS.MessageListener
public class MessageListener
This class is a threaded class which will be used to monitor the input port which will be responsible for piping into an application data that is coming from an input stream from for example, a 4MS simulator or from the 4MS itself. It will also be responsible for delagating incoming messages to a message handler which will not only parse the message for correctness, but also then pass the message on to the appropriate object which can then ascertain the messages semantics.
It should be noted that this class is used by both the 4MS instrument controller tasks and the simulation tasks as well
Field Summary | |
---|---|
private int |
BufferSize
This is the default size of the incoming message buffer |
(package private) java.net.Socket |
clientSocket
This is a connection to a simulator if there we are in simulation mode |
private FourMSMessageHandler |
ER412MessageHandler
This object will be informed when a message comes in and it will be it's responsibility to handle the message and ultimately pass it on to another object which will have the responsibility of processing the message |
private boolean |
FourMSTransceiverClient
Signifies if this is a 4MS transceiver client |
private java.io.BufferedReader |
inputStream
These will be used for sending and receiving from the 4MS simulator |
private java.io.InputStreamReader |
portServerInputStream
This will be used for sending data back to the |
private java.lang.String |
PortServerPort
This is the name of the port on the local machine which we will open in order to communicate with the port server should be running with a portserver. |
private char[] |
readBuffer
This is a buffer into which data will be read from the portserver and then stored. |
private java.lang.Thread |
Runner
This object runs within it's own thread |
(package private) javax.comm.SerialPort |
serialPort
If we are connected to a port server then this is the file handle through which we can send and receive data |
private int |
SocketNumber
In the case that we are using a standard TCP/IP socket to connect to the ER412 transmitter, we need to know the port number of the listening socket which we need to open |
private int |
SocketType
This is the type of socket which is being used. |
private MessageHandler |
SyslogMessageHandler
This is a syslog object which will be used to report errors etc |
(package private) java.net.ServerSocket |
TCPIPServerSocket
This holds the TCP/IP server socket which will be used for communication should we be using normal TCP/IP for communication with the ER412 transmitter |
private long |
TimeOfLast4MSComms
This is used to get the time of the last comms from the 4MS which is attached |
Constructor Summary | |
---|---|
MessageListener(boolean FourMSTransceiverClient,
int SocketNumber,
int BufferSize,
FourMSMessageHandler ER412MessageHandler,
MessageHandler SyslogMessageHandler)
This is the constructor for the class which will be used to define an object that will use a TCP/IP socket for input. |
|
MessageListener(java.lang.String PortServerPort,
FourMSMessageHandler ER412MessageHandler,
MessageHandler SyslogMessageHandler)
This is the constructor which will be used to set up th message listener so that it will talk to FourMS instrument through a port portserver. |
Method Summary | |
---|---|
long |
getTimeOfLast4MSComms()
This will return the time of the last communications with the 4MS module |
void |
listenForInput()
When called it starts the listening thread which will result in the object listening for input from the simulator if we are in simulation mode or alternatively, from the 4MS portserver. |
void |
run()
This satifies the requirement of the runnable interface as this object has it's own thread This method is called and results in the object going into a wait state waiting for input from the transmitter and subsequently sending the incoming data onto the message handler. |
void |
serialEvent(javax.comm.SerialPortEvent event)
This is the event handler which will be called when there is an event on the portserver serial port file descriptor . |
void |
setupPortServerPort()
This will be used to open up the serial port which goes out to the portserver and subsequently out to the 4MS. |
void |
shutdownConnections()
Closes down the connection to the portserver or the simulator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
java.net.Socket clientSocket
javax.comm.SerialPort serialPort
private char[] readBuffer
private java.io.BufferedReader inputStream
private java.io.InputStreamReader portServerInputStream
private int BufferSize
private int SocketType
private int SocketNumber
private boolean FourMSTransceiverClient
private FourMSMessageHandler ER412MessageHandler
private java.lang.Thread Runner
private long TimeOfLast4MSComms
private java.lang.String PortServerPort
private MessageHandler SyslogMessageHandler
java.net.ServerSocket TCPIPServerSocket
Constructor Detail |
---|
public MessageListener(java.lang.String PortServerPort, FourMSMessageHandler ER412MessageHandler, MessageHandler SyslogMessageHandler)
PortServerPort
- This is the name of the device which will
be used to communicate with the portserver
ER412MessageHandler
- This will be used for parsing and
delagating incoming messages from the 4MS to other objects for
assigning semantic actions to the messages
SyslogMessageHandler
- This will be used for reporting errorspublic MessageListener(boolean FourMSTransceiverClient, int SocketNumber, int BufferSize, FourMSMessageHandler ER412MessageHandler, MessageHandler SyslogMessageHandler)
FourMSTransceiverClient
- If this is true then we consider ourselves to be a ER412 client.SocketNumber
- - This is the socket number to open a
listening socket upon in the case that we will be using
standard TCP/IP sockets in order to connect to the 4MS
controller software from the simulatorBufferSize
- This is the size of the input buffer which is
to be used by the objectER412MessageHandler
- This will be used by the class when
handing over incoming messages to another object for processingSyslogMessageHandler
- This is the syslog handler which
will be used for reporting errors when they occurMethod Detail |
---|
public long getTimeOfLast4MSComms()
public void setupPortServerPort()
The transmission characteristics for the 4MS modules and the portserver are set to the following;
Characteristic | Setting |
---|---|
Baud | 9600 |
Stop bits | 1 |
Parity | Even |
Data bits | 7 |
XON/XOFF | On |
public void listenForInput()
public void run()
Note that in the case that we are connected to a portserver
using the javax.comm API, events on that port will come into
the application (such as incoming data) and
processed through the SerialPortEventListener
method.
run
in interface java.lang.Runnable
public void serialEvent(javax.comm.SerialPortEvent event)
This method is not used when the software is running in simulation mode.
serialEvent
in interface javax.comm.SerialPortEventListener
event
- This contains the details of the event on the serial port.public void shutdownConnections()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |