# needle_positions Module¶

This module provides the interface to the AYAB shield.

class AYABInterface.needle_positions.NeedlePositions(rows, machine)[source]

Bases: object

An interface that just focusses on the needle positions.

__init__(rows, machine)[source]

Create a needle interface.

Parameters: rows¶ (list) – a list of lists of needle positions Machine¶ – the machine type to use ValueError – if the arguments are not valid, see check()
__weakref__

list of weak references to the object (if defined)

check()[source]

Check for validity.

Raises: ValueError – if not all lines are as long as the number of needles if the contents of the rows are not needle positions
completed_row_indices

The indices of the completed rows.

Return type: list

When a row was completed, the index of the row turns up here. The order is preserved, entries may occur duplicated.

get_row(index, default=None)[source]

Return the row at the given index or the default value.

machine

The machine these positions are on.

on_row_completed(callable)[source]

Add an observer for completed rows.

Parameters: callable¶ – a callable that is called with the row index as first argument

When row_completed() was called, this callable is called with the row index as first argument. Call this method several times to register more observers.

row_completed(index)[source]

Mark the row at index as completed.

This method notifies the obsevrers from on_row_completed().