Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kludge in unpackModblock #416

Open
3 tasks
AntoineGautier opened this issue Dec 11, 2024 · 0 comments
Open
3 tasks

Fix kludge in unpackModblock #416

AntoineGautier opened this issue Dec 11, 2024 · 0 comments

Comments

@AntoineGautier
Copy link
Collaborator

AntoineGautier commented Dec 11, 2024

In the function unpackModblock of server/src/parser/modification.ts we have:

        if (declaration?.modification) {
          mods = getModificationList(
            declaration.modification as mj.ClassMod,
            basePath,
            value,
          );
          // TODO: getModificationList should handle redeclares but it is not
          // correctly unpacking nested modifiers - this is a bug
          // kludge: remove nested modifiers
          mods.forEach((m) => (m.mods = []));
          console.log(mods);
        }

There are 2 potential issues with this.

  1. One affects the existing configuration workflow. If a choice includes class modifications, those modifications will be voided. This can lead to a parameter dialog that does not align with the Modelica implementation for such a choice.
  2. The other affects the backward translation from the UI schema to Modelica. Since the choice modifications are not stored in templates.json there is no means to generate correct Modelica code from the user selections.
    This issue is potentially of high impact since it may call for revising the UI schema, or at least the data stored in templates.json.

Additionally, choices may include constraining-clause which is also to be taken into account.

TODO list with this ticket:

  • Investigate the existing behavior for non-trivial choices annotations with redeclare, class modifications, replaceable and constraining clauses.
  • Refactor the function unpackModblock so that it can handle such constructs in alignment with MLS.
  • Implement the required changes to templates.json and to the UI schema to support backward translation to Modelica, given user selections that include complex choices annotations.

Example of choices annotation not properly handled:

      choice(
        redeclare replaceable Buildings.Templates.Components.Coils.WaterBasedHeating coiHeaPre(
          redeclare final package MediumHeaWat=MediumHeaWat,
          redeclare final Buildings.Templates.Components.Valves.TwoWayModulating val)
        "Hot water coil with two-way valve"),
@AntoineGautier AntoineGautier changed the title Fix kludge in Fix kludge in unpackModblock Dec 11, 2024
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

No branches or pull requests

1 participant