simpleCommunicator

This machine manages communications using a "stop and wait" protocol. Only one message is allowed to be outstanding.

PlantUML diagram separately generated.
  SEND_MESSAGE ACK
IDLE sendMessage
returns:
  • noEvent

transition : AWAITING_ACK

Since we're idle, we can simply send the message. Transitioning to the AWAITING_ACK state ensures that any other messages we're asked to send will be queued.

 
transition : none
AWAITING_ACK queueMessage
returns:
  • noEvent

transition : none

Since we're busy, we must queue the message for later sending. The queue will be checked when the ACK is received.

checkQueue
returns:
  • SEND_MESSAGE
  • noEvent

transition : IDLE

We've received our ACK for the previous message. It is time to check for any others.

Events
SEND_MESSAGE  
ACK  
States
IDLE  
AWAITING_ACK  
Actions
sendMessage sendMessage sends a message from the queue. The message is expected to be there, since checkQueue will have been previously called.

Returns:
  • noEvent
queueMessage queueMessage adds a message to the queue

Returns:
  • noEvent
checkQueue checkQueue only checks; it does not dequeue; that is done by sendMessage. Return SEND_MESSAGE when the queue is not empty.

Returns:
  • SEND_MESSAGE
  • noEvent