Skip to content

Conversation

@polfeliu
Copy link
Contributor

@polfeliu polfeliu commented Dec 5, 2025

Description

Created table object with useful api to interact with elements of the table.
The previous element DictionaryTable is only used for parsing. With this new element you can boot up the API that also contains the servo object. This will be used in the future for loading and saving xcfs, as well as potentially showing table editing on motionlab.
As explained the virtual drive meeting, I had to put a full fledged dictionary instead of minimal to be able to do tests with virtual drive, this is something that we can improve on the future.

Type of change

Please add a description and delete options that are not relevant.

  • Add table object api

Tests

  • Verified tests are being run to correct setups:
  • tests/test_table.py::test_table_set_and_get_value[real] on fsoe phase 1 and 2
  • tests/test_table.py::test_table_set_and_get_value[virtual] as unit tests on windows and linux

Please describe the manual tests that you ran to verify your changes if it applies.

Documentation

Please update the documentation.

  • Update docstrings of every function, method or class that change.
  • Build documentation locally to verify changes.
  • Add the changes at the [Unreleased] section of the CHANGELOG.

@polfeliu polfeliu force-pushed the INGK-1193-create-table-object-api branch from 4b8f9f4 to 804250b Compare December 7, 2025 17:40
@polfeliu polfeliu force-pushed the INGK-1194-add-table-element-attribute-to-xdf-3-1 branch from 5aadf99 to a665f9d Compare December 9, 2025 17:20
@polfeliu polfeliu requested a review from Copilot December 9, 2025 17:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a table object API for both virtual and real drives, enabling indexed access to table data stored in drive memory. The implementation provides a high-level API for reading and writing table values through index/value register pairs.

Key changes:

  • Added VTable class for virtual drive table simulation with signal-based index/value access
  • Implemented Table API class providing bracket notation, iteration, and bulk read/write operations
  • Extended dictionary parsing to support table definitions with axis specifications
  • Added comprehensive test coverage for both virtual and real servo scenarios

Reviewed changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
virtual_drive/resources/table.py New VTable class for virtual drive table implementation with signal watchers
virtual_drive/core.py Integrated user memory table (256 depth) with signal registration
ingenialink/table.py New Table API class with read/write, iteration, and bracket notation support
ingenialink/dictionary.py Added axis support to DictionaryTable, implemented get_table method and table merging
ingenialink/servo.py Added get_table method to retrieve Table objects from dictionary
tests/test_table.py Comprehensive test suite for both virtual and real servos with table operations
tests/test_dictionary.py Tests for table parsing, retrieval, and dictionary merging
tests/resources/dictionary_with_tables_minimal.xdf3 Updated table definitions to include axis attribute
tests/resources/init.py Renamed constant and added new dictionary resource reference
pyproject.toml Updated summit-testing-framework dependency version
poetry.lock Updated lock file for new dependency version
ingenialink/utils/_utils.py Refactored type alias for register values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1614 to 1620
axis = int(_axis) if _axis is not None else 0
id_index = str(table_element.attrib.get(self.__TABLE_ID_INDEX_ATTR))
id_value = str(table_element.attrib.get(self.__TABLE_ID_VALUE_ATTR))

table = DictionaryTable(
id=str(uid),
id_index=str(id_index),
id_value=str(id_value),
id=uid,
axis=axis if _axis is not None else None,
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Inconsistency in axis handling: When _axis is None, the code sets axis = 0 for storage purposes (line 1614) but then sets axis = None in the DictionaryTable object (line 1620). This creates a mismatch between the storage location (axis 0) and the table's actual axis value (None). The logic should consistently use either 0 or None for non-axis-specific tables. Based on the test expectations, tables without an axis attribute should be stored at axis 0 but have axis=None in their DictionaryTable object, which is what the current code does. However, this could be confusing for future maintainers.

Copilot uses AI. Check for mistakes.
KeyError: if the specified axis does not exist.
KeyError: if the table is not present in the specified axis.
ValueError: if the table is not found in any axis, if axis is not provided.
ValueError: if the table is found in multiple axis, if axis is provided.
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error description is misleading: "if the table is found in multiple axis, if axis is provided" should be "if the table is found in multiple axes, if axis is not provided". When axis IS provided, the method returns the table from that specific axis or raises a KeyError. The ValueError for multiple matches only occurs when axis is None.

Suggested change
ValueError: if the table is found in multiple axis, if axis is provided.
ValueError: if the table is found in multiple axes, if axis is not provided.

Copilot uses AI. Check for mistakes.
@polfeliu polfeliu force-pushed the INGK-1193-create-table-object-api branch from dd53fe3 to 0fb1c21 Compare December 10, 2025 13:20
Pol Feliu added 3 commits December 10, 2025 17:34
…3-1' into INGK-1193-create-table-object-api

# Conflicts:
#	poetry.lock
#	pyproject.toml
@polfeliu polfeliu force-pushed the INGK-1193-create-table-object-api branch from d72c7ca to 2955352 Compare December 11, 2025 09:22
@polfeliu polfeliu marked this pull request as ready for review December 11, 2025 13:38
Base automatically changed from INGK-1194-add-table-element-attribute-to-xdf-3-1 to develop December 17, 2025 17:32
if not isinstance(min_index, int) or not isinstance(max_index, int):
raise ValueError("Index register must have integer range.")

if min_index < 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a possibility?
A non-checked max_index out of bounds that makes anything (or some things) to crash?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually min index is -1. This value is used to avoid write in the table.

…3-create-table-object-api

# Conflicts:
#	poetry.lock
@polfeliu polfeliu merged commit 33a6aa4 into develop Dec 22, 2025
1 check passed
@polfeliu polfeliu deleted the INGK-1193-create-table-object-api branch December 22, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants