ochra.common.equipment package

device

class ochra.common.equipment.device.CircularRangeInput(unitname, min, max, step, variable_binding='')

Bases: HTMLInput

Specialized HTMLInput for inputs that are represented as circular range sliders.

Initializes a CircularRangeInput. :param unitname: The label or name of the unit. :type unitname: str :param min: The minimum value of the range. :param max: The maximum value of the range. :param step: The step size for the range. :param variable_binding: The variable binding associated with the input element. Defaults to “”. :type variable_binding: str, optional

Parameters:
  • unitname (str)

  • variable_binding (str)

pydantic model ochra.common.equipment.device.Device

Bases: DataModel

Base class for all devices, providing common attributes. Instruments and robots are considered devices in our framework.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Fields:
field inventory: Inventory = None

Associated inventory object.

field name: str [Required]

Device name.

field owner_station: UUID = None

Station ID to which the device belongs.

field status: ActivityStatus = ActivityStatus.IDLE

Current operational status of the device (e.g., idle, busy), defaults to IDLE.

model_post_init(context, /)

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
  • self (BaseModel)

  • context (Any)

Return type:

None

to_html()

Converts the device instance into an HTML representation. :returns: The HTML string representing the device. :rtype: str

Return type:

str

class ochra.common.equipment.device.HTMLAttribute(label, element, **attrs)

Bases: object

Meta class for annotating variables to generate HTML attributes in UI rendering on the web app. Use as metadata in Annotated type hints to describe how a field should appear in the UI.

Initialize an HTMLAttribute instance.

Parameters:
  • label (str) – Human-readable label for the UI element.

  • element (str) – Type of HTML element (e.g., ‘input’, ‘div’, ‘select’).

  • **attrs – Additional HTML attributes (e.g., placeholder, class, style).

class ochra.common.equipment.device.HTMLForm(call, method, action='')

Bases: object

Decorator class to annotate methods as HTML forms for UI rendering on the web app.

Initialize an HTMLForm instance. :param call: The endpoint or action to call when the form is submitted. :type call: str :param method: The HTTP method to use (e.g., ‘POST’, ‘GET’). :type method: str :param action: Optional action URL for the form submission. Defaults to “”. :type action: str, optional

Parameters:
  • call (str)

  • method (str)

  • action (str)

class ochra.common.equipment.device.HTMLInput(label, type, variable_binding='', **attrs)

Bases: object

Meta class for annotating function arguments to generate HTML inputs in UI rendering on the web app. Use as metadata in Annotated type hints to describe how a field should appear in the UI.

Initialize an HTMLInput instance.

Parameters:
  • label (str) – The label for the input element.

  • type (str) – The type of the input element (e.g., ‘text’, ‘number’).

  • variable_binding (str, optional) – The variable binding associated with the input element. Defaults to “”.

  • **attrs – Additional HTML attributes for the input element.

class ochra.common.equipment.device.HypermediaBuilder(device)

Bases: object

Builds HTML representation of a Device instance using Jinja2 templates.

Initializes the HypermediaBuilder with a Device instance.

Parameters:

device (Device) – The device instance to render.

build()

Renders the HTML representation of the device using Jinja2 templates. :returns: The rendered HTML string. :rtype: str

Return type:

str

mobile_robot

pydantic model ochra.common.equipment.mobile_robot.MobileRobot

Bases: Robot

Abstract class to represent a mobile robot that can move.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Fields:
field state: MobileRobotState = MobileRobotState.AVAILABLE

State of the mobile robot. Defaults to AVAILABLE

go_to(args)

Move the mobile platform to a specified location using given args.

Parameters:

args (Dict[str, Any]) – Argument needed for robot navigation to the target location.

Returns:

True if the platform successfully moved to the location

Return type:

bool

model_post_init(context, /)

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
  • self (BaseModel)

  • context (Any)

Return type:

None

operation

pydantic model ochra.common.equipment.operation.Operation

Bases: DataModel

Represents an operation executed by a device.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Fields:
field args: Dict[str, Any] [Required]

Arguments passed to the method.

field caller_id: str [Required]

Unique identifier of the caller initiating the operation.

field end_timestamp: datetime = None

Timestamp when the operation ended.

field entity_id: UUID [Required]

Unique identifier of the target entity.

field entity_type: str [Required]

Type of the entity (e.g., ‘device’, ‘station’).

field method: str [Required]

Name of the method invoked.

field result: OperationResult = None

Result of the operation.

field start_timestamp: datetime = None

Timestamp when the operation started.

field status: OperationStatus = OperationStatus.CREATED

Current status of the operation. Defaults to CREATED.

model_post_init(context, /)

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
  • self (BaseModel)

  • context (Any)

Return type:

None

operation_result

pydantic model ochra.common.equipment.operation_result.OperationResult

Bases: DataModel

Represents the outcome of an equipment operation, including its status and any associated data.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Fields:
field data_file_name: str = ''

Name of the file containing the result data, including its extension. Leave empty if not applicable.

field data_status: ResultDataStatus = ResultDataStatus.UNAVAILABLE

Current availability status of the result data. Defaults to UNAVAILABLE.

field data_type: str = ''

Type or format of the result data (e.g., “image”, “text”, “json”).

field error: str = ''

Description of the error if the operation failed; empty if successful.

field result_data: Any = None

The data produced by the operation, if any.

field success: bool [Required]

True if the operation completed successfully; otherwise, False.

get_data()

Retrieve the processed data from the result.

Returns:

The processed data.

Return type:

Any

model_post_init(context, /)

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
  • self (BaseModel)

  • context (Any)

Return type:

None

put_data()

Converts the data into bytestring and uploads the results

Returns:

True if the data is converted and uploaded

Return type:

bool

save_data(path=None)

Gets the data from the server and saves it to path. If path is not provided, saves it using the original name at the current directory

Parameters:

path (str) – The path to save the data to. If None, saves it to the current directory using original name.

Returns:

True if the data is saved.

Return type:

bool

robot

pydantic model ochra.common.equipment.robot.Robot

Bases: Device

Abstract class to represent a generic robot.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Fields:
field available_tasks: List[str] [Required]

A list of tasks available for execution by the robot.

execute(task_name, args)

Executes a specified task on the robot.

Parameters:
  • task_name (str) – The name of the task to execute.

  • args (Dict[str, Any]) – Arguments required for the task execution.

Returns:

True if the task was executed successfully, False otherwise.

Return type:

bool

model_post_init(context, /)

We need to both initialize private attributes and call the user-defined model_post_init method.

Parameters:
  • self (BaseModel)

  • context (Any)

Return type:

None