Material and Tray#

Material#

class automatic_warehouse.status_warehouse.material.Material(barcode: str, name: str, height: int, length: int, width: int)#

Class that represents a material that can be found inside a tray.

Parameters:
  • barcode (str) – unique ID of a material.

  • name (str) – name of a material.

  • height (int) – height of a material.

  • length (int) – length of a material.

  • width (int) – width of a material.

Raises:

ValueError – if the specified height is greater than the maximum height of the tray (config value).

get_barcode() str#

Get the barcode of the material.

Return type:

str

Returns:

the barcode of the material.

get_height() int#

Get the height of the material.

Return type:

int

Returns:

the height of the material.

get_length() int#

Get the length of the material.

Return type:

int

Returns:

the length of the material.

get_name() str#

Get the name of the material.

Return type:

str

Returns:

the name of the material.

get_width() int#

Get the width of the material.

Return type:

int

Returns:

the width of the material.

automatic_warehouse.status_warehouse.material.gen_rand_material(min_height: int = 25, max_height: int = 50, name: str | None = None) Material#

Static method to generate a random material.

Return type:

Material

Parameters:
  • min_height (int) – the minimum height (lower limit) of the material.

  • max_height (int) – the maximum height (upper limit) of the material.

  • name (str | None) – name of the random material to be generated, otherwise the name will be taken from the random_name_materials variable.

Returns:

the material generated.

automatic_warehouse.status_warehouse.material.gen_rand_materials(how_many: int, min_height: int = 25, max_height: int = 50) list[Material]#

Static method to generate random materials.

Return type:

list[Material]

Parameters:
  • how_many (int) – how many materials to generate.

  • min_height (int) – the minimum height (lower limit) of the materials.

  • max_height (int) – the maximum height (upper limit) of the materials.

Returns:

the generated materials list.

automatic_warehouse.status_warehouse.material.random_name_materials = ['Shirt', 'Screwdriver', 'Bottle', 'Tablet', 'Helmet', 'GPU', 'CPU']#

A list of random materials used by the library when generating random materials.

Tray#

class automatic_warehouse.status_warehouse.tray.Tray(info: TrayConfiguration | None = None, items: list[Material] | None = None)#

Representation of the tray (or tray) inside the warehouse. It contains all the information about the tray and the methods for add/remove a material, and so on.

Parameters:
  • info (TrayConfiguration | None) – configure the tray, leave None if you want to set the default (config) value.

  • items (list[Material] | None) – list of items to be added to the tray.

add_material(material: Material)#

Add a material to the tray.

Note: The material to be added should respect the following rules:

  1. width smaller than the width of the tray;

  2. height less than the maximum height of the tray (maximum_height field in the configuration);

  3. length less than the length of the tray.

Parameters:

material (Material) – material to be added to the tray.

Raises:

ValueError – if the material it is too large.

add_materials(materials: list[Material])#

Add materials to the tray.

Note: Each material to be added should respect the following rules:

  1. width smaller than the width of the tray;

  2. height less than the maximum height of the tray (maximum_height field in the configuration);

  3. length less than the length of the tray.

Parameters:

materials (list[Material]) – materials to be added to the tray.

Raises:

ValueError – if the materials are too large.

get_best_offset_x() int#

Get the best offset x of the tray.

Return type:

int

Returns:

the best offset x of the tray.

get_best_y() int#

Get the best y of the tray.

Return type:

int

Returns:

the best y of the tray.

get_first_tray_entry()#

Get the first tray entry (object) inside the warehouse.

Return type:

TrayEntry

Returns:

first tray entry (object) inside the warehouse.

get_height_limit() int#

Get the height limit of the tray.

Return type:

int

Returns:

the height limit of the tray.

get_items() list[Material]#

Returns all the items inside the tray.

Return type:

list[Material]

Returns:

the list of items inside the tray.

get_length() int#

Get the length of the tray.

Return type:

int

Returns:

the length of the tray.

get_max_height() int#

Get the maximum height of the tray.

Return type:

int

Returns:

maximum height of a material inside tray.

get_num_materials() int#

Get the number of materials.

Return type:

int

Returns:

the number of materials.

get_num_space_occupied() int#

Get the number of occupied spaces in the warehouse.

Return type:

int

Returns:

number of occupied spaces in the warehouse.

get_width() int#

Get the width of the tray.

Return type:

int

Returns:

the width of the tray.

remove_material(material: Material)#

Remove a material from the tray.

Parameters:

material (Material) – material to be removed from the tray.

remove_materials(materials: list[Material])#

Remove materials from the tray.

Parameters:

materials (list[Material]) – materials to be removed from the tray.

set_best_offset_x(offset_x: int)#

Set the best offset x of the tray.

Parameters:

offset_x (int) – offset x of the tray.

set_best_y(pos_y: int)#

Set the best offset y of the tray.

Parameters:

pos_y (int) – offset y of the tray.

set_first_tray_entry(tray_entry)#

Set the first tray entry (object).

It is a pointer to the first entry in the tray, used in a clever way to avoid iterating over the list.

Parameters:

tray_entry (TrayEntry) – the first tray entry pointer.

automatic_warehouse.status_warehouse.tray.gen_rand_tray(info: TrayConfiguration = None, material_to_insert: Material = None) Tray#

Static method to generate a random tray.

Return type:

Tray

Parameters:
  • info (TrayConfiguration) – the tray configuration, leave None if you want to set the default (config) value.

  • material_to_insert (Material) – a material to insert.

Returns:

the generated tray.

automatic_warehouse.status_warehouse.tray.gen_rand_trays(how_many: int, materials_to_insert: list[Material], info: TrayConfiguration | None = None) list[Tray]#

Static method to generate random trays.

Return type:

list[Tray]

Parameters:
  • how_many (int) – how many trays to generate.

  • materials_to_insert (list[Material]) – a list of materials to insert.

  • info (TrayConfiguration | None) – information about the tray, leave None if you want to set the default (config) value.

Returns:

the generated trays list.