Ir al contenido principal

raydriver.driver

The common driver base class and its typed metadata.

Every protocol driver is a subclass of Driver: the uniform surface (connection lifecycle, job streaming, machine control, probing and settings) is declared here once, with strict types, and inherited by every driver class. Operations a protocol cannot perform raise NotImplementedError.

Constants​

drivers​

list[type[Driver]]

Driver​

The base class of every raydriver driver.

Declares the uniform surface once: connection lifecycle, job streaming, machine control, probing and settings. Operations a protocol cannot perform raise NotImplementedError; the method is still present on every driver.

buffer_count​

buffer_count: int

Bytes currently occupying the device's RX buffer.

info​

info: DriverInfo

The driver's typed identity and capabilities.

job_running​

job_running: bool

True while a job is running or held.

pending_commands​

pending_commands: list[str]

Commands sent but not yet acknowledged.

resource_uri​

resource_uri: Optional[str]

Identifier of the physical resource, or None.

rx_buffer_size​

rx_buffer_size: int

The device's RX buffer size in bytes, or 0 when unknown.

state​

state: types.DeviceState

Current snapshot of the device state.

cancel()​

cancel(emergency: bool = False) -> Awaitable[None]

Cancel the running job.

ParameterTypeDescription
emergencybool = False
ReturnsAwaitable[None]

clear_alarm()​

clear_alarm() -> Awaitable[None]

Clear a device alarm.

ParameterTypeDescription
ReturnsAwaitable[None]

connect()​

connect() -> Awaitable[None]

Open the connection and keep it up until disconnect.

ParameterTypeDescription
ReturnsAwaitable[None]

detect_unit_system()​

detect_unit_system() -> Awaitable[Optional[str]]

Detect the device's unit system ("metric" or "imperial"), or None when unknown.

ParameterTypeDescription
ReturnsAwaitable[Optional[str]]

disconnect()​

disconnect() -> Awaitable[None]

Stop all background tasks and close the connection.

ParameterTypeDescription
ReturnsAwaitable[None]

execute_command()​

execute_command(command: str) -> Awaitable[list[str]]

Send one command and return its response lines.

ParameterTypeDescription
commandstr
ReturnsAwaitable[list[str]]

execute_interactive_command()​

execute_interactive_command(command: str) -> Awaitable[list[str]]

Send one interactive command and return its response lines.

ParameterTypeDescription
commandstr
ReturnsAwaitable[list[str]]

home()​

home(
axes: Optional[Sequence[str]] = None,
active_wcs: Optional[str] = None,
) -> Awaitable[None]

Home all axes or the given axes.

ParameterTypeDescription
axesOptional[Sequence[str]] = None
active_wcsOptional[str] = None
ReturnsAwaitable[None]

jog()​

jog(
speed: float,
deltas: Optional[Sequence[tuple[str, float]]] = None,
) -> Awaitable[None]

Relative jog by per-axis distances.

ParameterTypeDescription
speedfloat
deltasOptional[Sequence[tuple[str, float]]] = None
ReturnsAwaitable[None]

move_to()​

move_to(
speed: float,
x: float,
y: float,
z: Optional[float] = None,
) -> Awaitable[None]

Absolute move in the machine's current coordinate frame.

ParameterTypeDescription
speedfloat
xfloat
yfloat
zOptional[float] = None
ReturnsAwaitable[None]

read_parser_state()​

read_parser_state() -> Awaitable[Optional[str]]

Read the G-code parser state.

ParameterTypeDescription
ReturnsAwaitable[Optional[str]]

read_settings()​

read_settings() -> Awaitable[list[tuple[str, str]]]

Read the device's firmware settings.

ParameterTypeDescription
ReturnsAwaitable[list[tuple[str, str]]]

read_wcs_offsets()​

read_wcs_offsets() -> Awaitable[dict[str, tuple[float, float, float]]]

Read the work-coordinate-system offsets.

ParameterTypeDescription
ReturnsAwaitable[dict[str, tuple[float, float, float]]]

run()​

run(
gcode: str,
op_line_map: Optional[Mapping[int, int]] = None,
op_estimates: Optional[Sequence[float]] = None,
progress_callback: Optional[Callable[[int], object]] = None,
) -> Awaitable[None]

Stream a G-code job.

ParameterTypeDescription
gcodestr
op_line_mapOptional[Mapping[int, int]] = None
op_estimatesOptional[Sequence[float]] = None
progress_callbackOptional[Callable[[int], object]] = None
ReturnsAwaitable[None]

run_probe_cycle()​

run_probe_cycle(
axis_letter: str,
max_travel: float,
feed_rate: float,
) -> Awaitable[Optional[tuple[float, float, float]]]

Run a probe cycle; None = no trigger reported.

ParameterTypeDescription
axis_letterstr
max_travelfloat
feed_ratefloat
ReturnsAwaitable[Optional[tuple[float, float, float]]]

run_raw()​

run_raw(machine_code: str) -> Awaitable[None]

Execute pre-rendered machine code.

ParameterTypeDescription
machine_codestr
ReturnsAwaitable[None]

select_tool()​

select_tool(tool_number: int) -> Awaitable[None]

Select a tool.

ParameterTypeDescription
tool_numberint
ReturnsAwaitable[None]

set_focus_power()​

set_focus_power(power: Optional[float] = None) -> Awaitable[None]

Set the laser power used while focusing.

ParameterTypeDescription
powerOptional[float] = None
ReturnsAwaitable[None]

set_hold()​

set_hold(hold: bool = True) -> Awaitable[None]

Pause or resume the running job.

ParameterTypeDescription
holdbool = True
ReturnsAwaitable[None]

set_power()​

set_power(power: Optional[float] = None) -> Awaitable[None]

Set the laser/spindle power; None disables the tool.

ParameterTypeDescription
powerOptional[float] = None
ReturnsAwaitable[None]

set_wcs_offset()​

set_wcs_offset(
wcs_slot: str,
x: float,
y: float,
z: Optional[float] = None,
) -> Awaitable[None]

Write a work-coordinate-system offset.

ParameterTypeDescription
wcs_slotstr
xfloat
yfloat
zOptional[float] = None
ReturnsAwaitable[None]

update_dialect()​

update_dialect(dialect: dict) -> None

Replace the command templates.

ParameterTypeDescription
dialectdict
ReturnsNone

write_setting()​

write_setting(key: str, value: str) -> Awaitable[None]

Write one firmware setting.

ParameterTypeDescription
keystr
valuestr
ReturnsAwaitable[None]

DriverInfo​

Typed identity and capabilities of one driver class.

capabilities​

capabilities: dict[str, bool]

The capability flags.

config_keys​

config_keys: list[str]

The connection config keys the driver accepts.

connection​

connection: str

The physical connection the driver dials.

machine_space_wcs​

machine_space_wcs: str

The WCS id that denotes machine space.

maturity​

maturity: str

The maturity level (stable, untested, ...).

name​

name: str

The class name, which is also the persisted driver name.

setup​

setup: list[SetupField]

The typed connection-setup form.

supported_wcs​

supported_wcs: list[str]

The selectable work-coordinate systems.

uses_gcode​

uses_gcode: bool

Whether the protocol speaks G-code.

to_dict()​

to_dict() -> dict

The wire form served by driver/list.

ParameterTypeDescription
Returnsdict

SetupField​

One connection-setup field a driver accepts.

choices​

choices: list[str]

The allowed values for a choice field.

default​

default: Optional[str]

The default value, if any.

key​

key: str

The config key.

kind​

kind: str

The value kind (serial_port, hostname, port, ...).

max​

max: Optional[float]

The maximum value for numeric fields.

min​

min: Optional[float]

The minimum value for numeric fields.

required​

required: bool

Whether the field must be configured.

to_dict()​

to_dict() -> dict

The mapping form.

ParameterTypeDescription
Returnsdict

Functions​

driver_info()​

driver_info(name: str) -> DriverInfo

Look up a built-in driver's typed metadata by class name.

ParameterTypeDescription
namestr
ReturnsDriverInfo

get_driver_cls()​

get_driver_cls(name: str, default: Optional[Any] = None) -> type[Driver]

Resolve a persisted driver name.

ParameterTypeDescription
namestr
defaultOptional[Any] = None
Returnstype[Driver]

register_driver()​

register_driver(driver: type[Driver]) -> None

Register an addon driver class.

ParameterTypeDescription
drivertype[Driver]
ReturnsNone