lewis.examples.example_motor

Members

DefaultMovingState

ExampleMotorStreamInterface

TCP-stream based example motor interface

SimulatedExampleMotor

class lewis.examples.example_motor.DefaultMovingState[source]

Bases: State

in_state(dt) None[source]

Handle in-state event.

Raised repeatedly, once per cycle, while idling in this state. Exactly one in-state event occurs per cycle for every StateMachine. This is always the last event of the cycle.

Parameters:

dt – Delta T since last cycle.

class lewis.examples.example_motor.ExampleMotorStreamInterface[source]

Bases: StreamInterface

TCP-stream based example motor interface

This motor simulation can be controlled via telnet:

$ telnet host port

Where the host and port-parameter are part of the dynamically created documentation for a concrete device instance.

The motor starts moving immediately when a new target position is set. Once it’s moving, it has to be stopped to receive a new target, otherwise an error is generated.

get_position()[source]

Returns the current position in mm.

get_status()[source]

Returns the status of the device, which is one of ‘idle’ or ‘moving’.

get_target()[source]

Returns the current target in mm.

set_target(new_target)[source]

Sets the new target in mm, the movement starts immediately. If the value is outside the interval [0, 250] or the motor is already moving, an error is returned, otherwise the new target is returned.

class lewis.examples.example_motor.SimulatedExampleMotor(override_states: dict[str, State] | None = None, override_transitions: dict[tuple[State, State], Callable[[], bool]] | None = None, override_initial_state: State | None = None, override_initial_data: dict[str, float] | None = None)[source]

Bases: StateMachineDevice

stop()[source]

Stops the motor and returns the new target and position, which are equal