states
Module¶
This module contains the state machine for the communication class.
Click on this image to go to the states from the diagram:
-
class
AYABInterface.communication.states.
State
(communication)[source]¶ Bases:
object
The base class for states.
-
__init__
(communication)[source]¶ Create a new state.
Please use the subclasses of this.
Parameters: communication¶ (AYABInterface.communication.Communication) – the communication object which is in this state
-
__weakref__
¶ list of weak references to the object (if defined)
-
enter
()[source]¶ Called when the state is entered.
The
AYABInterface.communication.Communication.state
is set to this state.
-
exit
()[source]¶ Called when this state is left.
The
AYABInterface.communication.Communication.state
is set to this state.
-
is_before_knitting
()[source]¶ Whether the knitting should start soon.
Return type: bool Returns: False
-
is_initial_handshake
()[source]¶ Whether the communication object is in the intial handshake.
Return type: bool Returns: False
-
is_initializing_machine
()[source]¶ Whether the machine is currently being initialized.
Return type: bool Returns: False
-
is_knitting
()[source]¶ Whether the machine ready to knit or knitting.
Return type: bool Returns: False
-
is_knitting_started
()[source]¶ Whether the machine ready to knit the first line.
Return type: bool Returns: false
-
is_starting_to_knit
()[source]¶ Whether the machine initialized and knitting starts.
Return type: bool Returns: False
-
is_unsupported_api_version
()[source]¶ Whether the API version of communcation and controller do not match.
Return type: bool Returns: False
-
is_waiting_for_start
()[source]¶ Whether this state is waiting for the start.
Return type: bool Returns: False
-
is_waiting_for_the_communication_to_start
()[source]¶ Whether the communication can be started.
When this is
True
, you call callAYABInterface.communication.Communication.start()
to leave the state.Return type: bool Returns: False
-
receive_connection_closed
(message)[source]¶ Receive a ConnectionClosed message.
Parameters: message¶ – a ConnectionClosed
messageIf the is called, the communication object transits into the
ConnectionClosed
.
-
receive_debug
(message)[source]¶ Receive a Debug message.
Parameters: message¶ – a Debug
messageThis logs the debug message.
-
receive_information_confirmation
(message)[source]¶ Receive a InformationConfirmation message.
Parameters: message¶ – a InformationConfirmation
message
-
receive_line_request
(message)[source]¶ Receive a LineRequest message.
Parameters: message¶ – a LineRequest
message
-
receive_message
(message)[source]¶ Receive a message from the controller.
Parameters: message¶ (AYABInterface.communication.hardware_messages.Message) – the message to receive This method calls
message.received_by
which dispatches the call to thereceive_*
methods.
-
receive_start_confirmation
(message)[source]¶ Receive a StartConfirmation message.
Parameters: message¶ – a StartConfirmation
message
-
receive_state_indication
(message)[source]¶ Receive a StateIndication message.
Parameters: message¶ – a StateIndication
message
-
receive_test_confirmation
(message)[source]¶ Receive a TestConfirmation message.
Parameters: message¶ – a TestConfirmation
message
-
receive_unknown
(message)[source]¶ Receive a UnknownMessage message.
Parameters: message¶ – a UnknownMessage
message
-
-
class
AYABInterface.communication.states.
ConnectionClosed
(communication)[source]¶ Bases:
AYABInterface.communication.states.FinalState
The connection is closed.
-
class
AYABInterface.communication.states.
WaitingForStart
(communication)[source]¶ Bases:
AYABInterface.communication.states.State
Waiting for the start() method to be called.
This is the initial state of a
AYABInterface.communication.Communication
.-
communication_started
()[source]¶ Call when the communication starts.
The communication object transits into
InitialHandshake
.
-
-
class
AYABInterface.communication.states.
InitialHandshake
(communication)[source]¶ Bases:
AYABInterface.communication.states.State
The communication has started.
-
enter
()[source]¶ This starts the handshake.
A
AYABInterface.communication.host_messages.InformationRequest
is sent to the controller.
-
is_initial_handshake
()[source]¶ Whether the communication object is in the intial handshake.
Return type: bool Returns: True
-
receive_information_confirmation
(message)[source]¶ A InformationConfirmation is received.
If
the api version is supported
, the communication object transitions into aInitializingMachine
, if unsupported, into aUnsupportedApiVersion
-
-
class
AYABInterface.communication.states.
UnsupportedApiVersion
(communication)[source]¶ Bases:
AYABInterface.communication.states.FinalState
The api version of the controller is not supported.
-
class
AYABInterface.communication.states.
InitializingMachine
(communication)[source]¶ Bases:
AYABInterface.communication.states.State
The machine is currently being intialized.
-
is_initializing_machine
()[source]¶ Whether the machine is currently being initialized.
Return type: bool Returns: True
-
is_waiting_for_carriage_to_pass_the_left_turn_mark
()[source]¶ The carriage should be moved over the left turn mark.
Return type: bool Returns: True
-
receive_state_indication
(message)[source]¶ Receive a StateIndication message.
Parameters: message¶ – a StateIndication
messageIf the message says that the controller is
is ready to knit
, there is a transition toStartingToKnit
or else the messages are ignored because they come from The reqTest Message.
-
-
class
AYABInterface.communication.states.
StartingToKnit
(communication)[source]¶ Bases:
AYABInterface.communication.states.State
The cnfStart Message is sent and we wait for an answer.
-
is_starting_to_knit
()[source]¶ The machine initialized and knitting starts.
Return type: bool Returns: True
-
receive_start_confirmation
(message)[source]¶ Receive a StartConfirmation message.
Parameters: message¶ – a StartConfirmation
messageIf the message indicates success, the communication object transitions into
KnittingStarted
or else, intoStartingFailed
.
-
-
class
AYABInterface.communication.states.
StartingFailed
(communication)[source]¶ Bases:
AYABInterface.communication.states.FinalState
The starting process has failed.
-
class
AYABInterface.communication.states.
KnittingStarted
(communication)[source]¶ Bases:
AYABInterface.communication.states.State
The knitting started and we are ready to receive The reqLine Message.
-
is_knitting_started
()[source]¶ The machine ready to knit the first line.
Return type: bool Returns: True
-
receive_line_request
(message)[source]¶ Receive a LineRequest message.
Parameters: message¶ – a LineRequest
messageThe communicaion transisitions into a
KnittingLine
.
-
-
class
AYABInterface.communication.states.
KnittingLine
(communication, line_number)[source]¶ Bases:
AYABInterface.communication.states.State
The machine is currently knitting a line.
-
enter
()[source]¶ Send a LineConfirmation to the controller.
When this state is entered, a
AYABInterface.communication.host_messages.LineConfirmation
is sent to the controller. Also, thelast line requested
is set.
-
receive_line_request
(message)[source]¶ Receive a LineRequest message.
Parameters: message¶ – a LineRequest
messageThe communicaion transisitions into a
KnittingLine
.
-