Skip to content

Commit

Permalink
fixup! Support for user plugins with table containing references
Browse files Browse the repository at this point in the history
  • Loading branch information
prusse-martin committed Jan 8, 2025
1 parent 3e77586 commit 2a91b23
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Binary file modified docs/source/_static/images/api/table_field_example_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 17 additions & 13 deletions src/alfasim_sdk/_internal/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,12 +680,12 @@ class Table(BaseField):
.. code-block:: python
@data_model(caption="Wolf")
class Wolf:
name = String(value="Wolf", caption="Name")
@data_model(caption="Flow Type")
class FlowType:
name = String(value="Flow", caption="Name")
@container_model(caption="The Pack", model=Wolf, icon="")
class Pack:
@container_model(caption="Flow Types", model=FlowType, icon="")
class FlowTypeContainer:
pass
@data_model(icon="", caption="My Model")
Expand All @@ -709,19 +709,17 @@ class MyModel:
),
),
TableColumn(
id="tracer",
value=Refence(
ref_type=Wolf,
container_type="Pack",
caption="Wolf Column Caption",
id="flow_type",
value=Reference(
ref_type=FlowType,
container_type="FlowTypeContainer",
caption="Flow Type Column Caption",
),
),
],
caption="Table Field",
)
TODO: ASIM-5862: update docs table_field_example_1.png image!
The image above illustrates the output from the example above.
.. image:: /_static/images/api/table_field_example_1.png
Expand All @@ -738,7 +736,13 @@ class MyModel:
.. rubric:: **Accessing Table Field from Plugin**:
In order to access this field from inside the plugin implementation, in C/C++, you need to use :cpp:func:`get_plugin_input_data_table_quantity`
To access this field from inside the plugin implementation, in C/C++, it is possible to access:
* all the values from a :class:`Quantity` column using :cpp:func:`get_plugin_input_data_table_quantity`;
* individual entries from a :class:`Quantity` column using :cpp:func:`get_plugin_input_data_quantity` and a `var_name` argument like `"MyModel.table_field[0,temperature]"` (the first item in the "temperature" column);
* individual entries from a :class:`Reference` column with the ususal functions listed at :ref:`plugin_input_data` and `var_name` arguments like `"MyModel.table_field[1,flow_type]->name"` (the "name" of the second item in the "flow_type" column);
.. rubric:: **Accessing Table Field from Context**:
Expand Down

0 comments on commit 2a91b23

Please sign in to comment.