public class CommunicationCycle extends Object
ACK string. In GRE-KIS-NOT-0014.pdf it is stated
that each command will trigger exactely two replies, but I think this
is only true if the command was accepted, i.e. if the first ACK has an
error-code ok 0, see #ACK0.
The second reply is sent when the command has been completed. It carries
an error code of 0 if everything went ok, a positive error code for
severe errors and a negative number for warnings (but continuation should be
possible). If the reply should carry data, it is attached after the error
code and a single spc, further values are added with further whitespaces.
The doc also indicates that binary data may follow, but gives no clear
indication whether this means that the first space is still there or
suppresed. Anyhow, within the automatization of GREGOR, only ascii-replies
are envisioned. Note that replies without a single return value
carry the FIN string instead.
The general use of these objects would start with constructing the cycle
with one of the constructors, in this way specifying the proper return
ID of the original command. The acknowledge and done reply are issued
both in replyReceived by the message listener of the communication
handler. To wait for the end of the communication cycle, syn on the
lately created CommunicationCycle object and trigger a wait (optionally
query the #getMaximumComplete) for a wait timeout. Once you are
notified, query the outcome on the communication cycle.
| Modifier and Type | Field and Description |
|---|---|
static String |
ACK
The string denoting an acknowledge reply.
|
private int |
aexit
The exit code of the acknowledge reply.
|
private int |
belonging
From the originating message, we only store the id.
|
private boolean |
binary
If the second reply carries binary data.
|
private int |
dexit
The exit code of the done reply.
|
private long |
dtack
The time-delay until first acknowledge was received, -1=not received.
|
private long |
dtdone
The time-delay until second reply was received, -1=not received.
|
static String |
FIN
The string denoting a done reply without data
|
private List<String> |
outcome
On the second reply, we can query the ascii-outcome.
|
private long |
t0
The creation time in ms.
|
| Constructor and Description |
|---|
CommunicationCycle(CommandMessage m)
Communication cycle with default acknowledge and done timeouts.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
completeWithoutErrors()
Returns true, if the done return code is negative.
|
int |
getAckExit()
Returns the acknowledge exit code.
|
int |
getDoneExit()
Returns the done exit code.
|
List<String> |
getOutcome()
Returns the result of the command cycle, only trustworthy if either
successfully completed or completed without errors.
|
int |
hashCode()
Hash code is the ID of the original message.
|
boolean |
isAckAccepted()
Returns true, if the acknowledge return code was zero and an acknowledge
was received.
|
boolean |
isAcknowledged()
Returns true, if the first reply has been received.
|
boolean |
isCompleted()
Returns true, if the second reply has been received.
|
boolean |
isSuccessfullyCompleted()
Returns true, if the done return code was zero and the second reply
was also received.
|
boolean |
replyReceived(Message m)
This method is called whenever a reply is received.
|
public static final String ACK
public static final String FIN
private int belonging
private boolean binary
private long t0
private long dtack
private int aexit
private int dexit
private long dtdone
public CommunicationCycle(CommandMessage m)
public int hashCode()
public boolean replyReceived(Message m)
public boolean isAcknowledged()
public boolean isCompleted()
public int getAckExit()
@isAcknowledged.public int getDoneExit()
@isCompleted.public boolean isAckAccepted()
public boolean isSuccessfullyCompleted()
public boolean completeWithoutErrors()