Skip to content

Feat: Link Ressources while template generation #33

Closed

Description

@pfannkuch3n

Problem description

Some modelica models, like demand models, use external tables as an input. Current mako generation handles it like other variables:

    %if fileNameHeat is not None:
    fileNameHeat = ${str(round(fileNameHeat, 4))},
    %endif

To automatically link demand tables to demand modelica models it should look like:

    %if fileNameHeat is not None:
    fileNameHeat = Modelica.Utilities.Files.loadResource(
      "modelica://${package_name}/Resources/Inputs/demand_${str(name)}_heat.txt"
    ),
    %endif

Problem background

In script uesgraphs/systemmodels/templates.py lines 273 to 278 identified model parameters get treated based on type:

for modelica_name, parameter in parameters.items():
            python_name = check_variable_name(modelica_name)
            if parameter.type == "Boolean":
                param_str = f"{modelica_name} = ${{str({python_name}).lower()}}"
            else:
                param_str = f"{modelica_name} = ${{str(round({python_name}, 4))}}"

So currently only "Boolean" values get treated differently. That should be revised as well, since sometimes boolean parameters inherit from other classes like "XXX.YYY.Boolean" what is not classified as Boolean parameter right now.

Main problem regarding this issue is that inputFile-Variables are treated as numbers

Suggested solution

Identify unique type of InputFile variables and implement routine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions