|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.TimerTask
FourMS.MessagePoster
public class MessagePoster
Describes a single message which is sent from software/simulator controller and includes methods which will be used to verify the correct acknowledgments are received, timeouts are executed and retries are made. This class is responsible for sending the actual message to the 4MS down the wire via the Port Server. Once the ACK is received for this message then the object can be used to deliver another message should the parent need to.
Field Summary | |
---|---|
private java.io.OutputStream |
ControllerFD
This is the file descriptor of the connection on the port server that corresponds to the 4MS which is being used. |
private i4MSMessageSender |
MessageOriginator
This is a reference to the object that sent the message in the first instance which will be informed when the message has either been delivered or not delivered |
private static java.util.Timer |
MessagePosterTimer
This is a timer object which will be used for scheduling actions on the message posters. |
private int |
MessageSequenceNumber
This is the message sequence number that is associated with the message that we sent in the first instance |
private int |
MessageState
This is the current state of the message, this should be one of the following from the fourMSConstants class. |
private byte[] |
PostedMessage
This is the original message which was to be delivered by this message poster |
private int |
SecsLeftBeforeResend
The amount of seconds left before we attempt to resend the message |
private int |
SendRetryCount
This is the number of times that we will attempt to send the message before we give up completely |
private MessageHandler |
SyslogHandler
This is a reference to a syslog handler which will be used to report errors etc. |
Constructor Summary | |
---|---|
MessagePoster(java.io.OutputStream ControllerFD,
MessageHandler SyslogHandler)
This is the constructor for the class. |
Method Summary | |
---|---|
boolean |
checkForAck(FourMSMessage FourMSReply)
This method will be called when there is an incoming message from the 4MS and will check if the ACK received corresponds to the message that was sent from by this message poster. |
void |
deliverMessage(byte[] MessageToSend,
i4MSMessageSender MessageInitiator,
int MessageSeqNo)
The purpose of this method is to send the string which represents a well formed 4MS message, to the 4MS microprocessor via the Port Server. |
int |
getMessageState()
Returns the delivery status of the message which has been sent to the 4MS transmitter |
static void |
main(java.lang.String[] argv)
This is for testing the class to ensure that it is working ok |
void |
run()
This method represents the obligation of the class to implement the abstract interface of the TimerTask superclass which it extends. |
private void |
setMessageState(int State)
This method allows the current state of the message to be set. |
void |
setOutputDevice(java.io.OutputStream ControllerFD)
This will be used to set the output file descriptor which will be used when sending messages. |
Methods inherited from class java.util.TimerTask |
---|
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int MessageSequenceNumber
private int MessageState
private byte[] PostedMessage
private int SendRetryCount
private int SecsLeftBeforeResend
private static final java.util.Timer MessagePosterTimer
private java.io.OutputStream ControllerFD
private i4MSMessageSender MessageOriginator
private MessageHandler SyslogHandler
Constructor Detail |
---|
public MessagePoster(java.io.OutputStream ControllerFD, MessageHandler SyslogHandler)
ControllerFD
- - This will be used when transmitting
a message back to a 4MS transmitter.SyslogHandler
- This will be used to report errors that arise in the
transmission of the messages to the receiver.Method Detail |
---|
public void deliverMessage(byte[] MessageToSend, i4MSMessageSender MessageInitiator, int MessageSeqNo) throws UnableToCommunicateWith4MSException
MessageToSend
- - This is the well formatted message to be
delivered to the 4MS. All conversion should have been done at
this point and the string should be exactly as it should be in
order to be sent to the 4MS.MessageInitiator
- This is a reference to the oject that sent the message in the first placeMessageSeqNo
- We must record the number of the message
that we sent so that when ACKs come in we can check to see if
they were for the message that we sent
UnableToCommunicateWith4MSException
public boolean checkForAck(FourMSMessage FourMSReply)
FourMSReply
- This is the message that came back from the 4MS.
private void setMessageState(int State)
State
- - This is the new state of the message.public void run()
run
in interface java.lang.Runnable
run
in class java.util.TimerTask
public int getMessageState()
public static void main(java.lang.String[] argv)
argv
- public void setOutputDevice(java.io.OutputStream ControllerFD)
ControllerFD
- - This is the output stream associated with the controller
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |