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:
objectThe 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.stateis set to this state.
-
exit()[source]¶ Called when this state is left.
The
AYABInterface.communication.Communication.stateis 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 ConnectionClosedmessageIf the is called, the communication object transits into the
ConnectionClosed.
-
receive_debug(message)[source]¶ Receive a Debug message.
Parameters: message¶ – a DebugmessageThis logs the debug message.
-
receive_information_confirmation(message)[source]¶ Receive a InformationConfirmation message.
Parameters: message¶ – a InformationConfirmationmessage
-
receive_line_request(message)[source]¶ Receive a LineRequest message.
Parameters: message¶ – a LineRequestmessage
-
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_bywhich dispatches the call to thereceive_*methods.
-
receive_start_confirmation(message)[source]¶ Receive a StartConfirmation message.
Parameters: message¶ – a StartConfirmationmessage
-
receive_state_indication(message)[source]¶ Receive a StateIndication message.
Parameters: message¶ – a StateIndicationmessage
-
receive_test_confirmation(message)[source]¶ Receive a TestConfirmation message.
Parameters: message¶ – a TestConfirmationmessage
-
receive_unknown(message)[source]¶ Receive a UnknownMessage message.
Parameters: message¶ – a UnknownMessagemessage
-
-
class
AYABInterface.communication.states.ConnectionClosed(communication)[source]¶ Bases:
AYABInterface.communication.states.FinalStateThe connection is closed.
-
class
AYABInterface.communication.states.WaitingForStart(communication)[source]¶ Bases:
AYABInterface.communication.states.StateWaiting 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.StateThe communication has started.
-
enter()[source]¶ This starts the handshake.
A
AYABInterface.communication.host_messages.InformationRequestis 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.FinalStateThe api version of the controller is not supported.
-
class
AYABInterface.communication.states.InitializingMachine(communication)[source]¶ Bases:
AYABInterface.communication.states.StateThe 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 StateIndicationmessageIf the message says that the controller is
is ready to knit, there is a transition toStartingToKnitor else the messages are ignored because they come from The reqTest Message.
-
-
class
AYABInterface.communication.states.StartingToKnit(communication)[source]¶ Bases:
AYABInterface.communication.states.StateThe 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 StartConfirmationmessageIf the message indicates success, the communication object transitions into
KnittingStartedor else, intoStartingFailed.
-
-
class
AYABInterface.communication.states.StartingFailed(communication)[source]¶ Bases:
AYABInterface.communication.states.FinalStateThe starting process has failed.
-
class
AYABInterface.communication.states.KnittingStarted(communication)[source]¶ Bases:
AYABInterface.communication.states.StateThe 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 LineRequestmessageThe communicaion transisitions into a
KnittingLine.
-
-
class
AYABInterface.communication.states.KnittingLine(communication, line_number)[source]¶ Bases:
AYABInterface.communication.states.StateThe machine is currently knitting a line.
-
enter()[source]¶ Send a LineConfirmation to the controller.
When this state is entered, a
AYABInterface.communication.host_messages.LineConfirmationis sent to the controller. Also, thelast line requestedis set.
-
receive_line_request(message)[source]¶ Receive a LineRequest message.
Parameters: message¶ – a LineRequestmessageThe communicaion transisitions into a
KnittingLine.
-