Skip to content

Machines Models

Models for persisting State Machine configurations and their relationships with tags.

class automation.dbmodels.machines.Machines(*args, **kwargs)

Database model for State Machines configuration.

create(identifier, name, interval, description, classification, buffer_size, buffer_roll_type, criticity, priority, threshold=None, on_delay=None)

Creates a new Machine record.

Parameters:

  • identifier (str): Unique identifier.
  • name (str): Machine name.
  • interval (int): Execution interval.
  • description (str): Description.
  • classification (str): Machine type.
  • buffer_size (int): Data buffer size.
  • buffer_roll_type (str): Buffer roll strategy.
  • criticity (int): Criticity level.
  • priority (int): Priority level.

Returns:

  • dict: Result status and data.
read_by_name(name)

Retrieves a machine by name.

read_config()

Retrieves configuration for all machines.

Returns:

  • dict: Map of Machine Name -> Configuration.
name_exist(name)

Checks if a machine name exists.

get_tags(self)

Returns related tags.

serialize(self)

Serializes the machine record.

class automation.dbmodels.machines.TagsMachines(*args, **kwargs)

Many-to-Many relationship between Tags and Machines.

create(tag_name, machine_name, default_tag_name=None)

Links a Tag to a Machine.

Parameters:

  • tag_name (str): Name of the tag.
  • machine_name (str): Name of the machine.
  • default_tag_name (str, optional): Alias for the tag within the machine context.
serialize(self)

Serializes the relationship.