AYAB API¶
Main AYAB GUI module¶
Provides an Interface for users to operate AYAB using a GUI.
- class ayab.ayab.GenericThread(function, *args, **kwargs)[source]¶
A generic thread wrapper for functions on threads.
- class ayab.ayab.GuiMain[source]¶
GuiMain is the main object that handles the instance of AYAB’s GUI from ayab_gui.UiForm .
GuiMain inherits from QMainWindow and instanciates a window with the form components form ayab_gui.UiForm.
- apply_image_transform(transform_type, *args)[source]¶
Executes an image transform specified by key and args.
Calls a function from transform_dict, forwarding args and the image, and replaces the QtImage on scene.
- load_image_from_string(image_str)[source]¶
Loads an image into self.ui.image_pattern_view using a temporary QGraphicsScene
- load_pil_image_on_scene(image_obj)[source]¶
Loads the PIL image on a QtScene and sets it as the current scene on the Image View.
Knitting Plugin API¶
- class ayab.plugins.knitting_plugin.KnittingPlugin(callbacks_dict)[source]¶
A generic plugin implementing a state machine for knitting.
Subclasses inherit the basic State Machine defined in __init__.
- get_configuration_from_ui(ui)[source]¶
Loads options dict with a given parent QtGui object. Required for save-load functionality.
Returns: A dict with configuration. Return type: dict
- onconfigure(e)[source]¶
Callback when state machine executes configure(parent_ui = parent, options={})
This state gets called to configure the plugin for knitting. It can either be called when first configuring the plugin, when an error had happened and reset is necessary. The parent ui is expected to hold an object with properties.
Parameters: parent_ui – An object having already been set up by setup_ui.
- onfinish(e)[source]¶
Callback when state machine executes finish().
When finish() gets called, the plugin is expected to be able to restore it’s state back when configure() gets called. Finish should trigger a Process Completed notification so the user can operate accordingly.
- onknit(e)[source]¶
Callback when state machine executes knit().
Starts the knitting process, this is the only function call that can block indefinitely, as it is called from an instance of QThread, allowing for processes that require timing and/or blocking behaviour.
- setup_ui(parent_ui)[source]¶
Sets up UI, usually as a child of parent_ui.ui.knitting_options_dock.
While the whole parent_ui object is available for the plugin to modify, plugins authors are strongly encouraged to only manipulate the knitting_options_dock, plugins have full access to the parent UI as a way to fully customize the GUI experience.
Parameters: parent_ui – A PyQt.QMainWindow with the property parent_ui.ui.knitting_options_dock, an instance of QDockWidget to hold the plugin’s UI.
AYAB Control Plugin¶
Handles the serial communication protocol.
This module handles serial communication, currently works in a synchronous way. AyabCommunication uses an internal PySerial.Serial object to connect to the device. The initializer can also be overriden with a dummy serial object.
- class ayab.plugins.ayab_plugin.ayab_communication.AyabCommunication(serial=None)[source]¶
Class Handling the serial communication protocol.
- cnf_line(lineNumber, lineData, flags, crc8)[source]¶
Sends a line of data via the serial port.
Sends a line of data to the serial port, all arguments are mandatory. The data sent here is parsed by the Arduino controller which sets the knitting needles accordingly.
Parameters: - lineNumber (int) – The line number to be sent.
- lineData (bytes) – The bytearray to be sent to needles.
- flags (bytes) – The flags sent to the controller.
- crc8 (bytes, optional) – The CRC-8 checksum for transmission.