Knitlib Plugin API

Base Knitting Plugin

class knitlib.plugins.knitting_plugin.BaseKnittingPlugin(callbacks_dict=None, interactive_callbacks=None)[source]

A generic plugin implementing a state machine for knitting.

Subclasses inherit the basic State Machine defined in __init__.

onconfigure(e)[source]

Callback when state machine executes configure(conf={})

This state gets called to configure the plugin for knitting. It can either be called when first configuring the plugin, when an error happened and a reset is necessary.

Parameters:e – An event object holding a conf dict.
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 an individual Thread, allowing for processes that require timing and/or blocking behaviour.

register_interactive_callbacks(callbacks=None)[source]

Serves to register a dict of callbacks that require interaction by the User,

Interactive callbacks serve to block operation until a human acts on them. Interactive callbacks can include physical operations (set needles, move knob, flip switch), decisions (yes/no or cancel), or simply human acknowledgement.

Parameters:callbacks – keys can be info, warning, progress, error.
set_port(portname)[source]

Sets a port name before configuration method.

static supported_config_features()[source]

Returns a JSON schema dict with the available features for the given machine plugin.