Skip to content

Declaration-level choices annotation disregarded #552

@AntoineGautier

Description

@AntoineGautier

Issue

When instantiating an enumeration type with a choices annotation as below, the choices annotation is not parsed and templates.json is populated with all the elements from the enumeration, yielding an incorrect list in the parameter dialog.

  parameter Buildings.Templates.Plants.HeatPumps.Types.Distribution typDis_select1(
    start=Buildings.Templates.Plants.HeatPumps.Types.Distribution.Constant1Variable2)=
    Buildings.Templates.Plants.HeatPumps.Types.Distribution.Constant1Variable2
    "Type of distribution system"
    annotation (Evaluate=true,
    Dialog(group="Configuration",
    enable=typ==Buildings.Templates.Components.Types.HeatPump.AirToWater),
    choices(
      choice=Buildings.Templates.Plants.HeatPumps.Types.Distribution.Variable1Only
      "Variable primary-only",
      choice=Buildings.Templates.Plants.HeatPumps.Types.Distribution.Constant1Variable2
      "Constant primary - Variable secondary centralized"));

is parsed as follows.

    {
      "modelicaPath": "Buildings.Templates.Plants.HeatPumps.Interfaces.PartialHeatPumpPlant.typDis_select1",
      "type": "Buildings.Templates.Plants.HeatPumps.Types.Distribution",
      "options": [  // Options should be limited to the ones specified by the choices annotation
        "Buildings.Templates.Plants.HeatPumps.Types.Distribution.Constant1Only",
        "Buildings.Templates.Plants.HeatPumps.Types.Distribution.Variable1Only",
        "Buildings.Templates.Plants.HeatPumps.Types.Distribution.Constant1Variable2",
        "Buildings.Templates.Plants.HeatPumps.Types.Distribution.Variable1And2"
      ],
      //...
    }

Root Cause

In Component.getInputs(), when a non-replaceable parameter has a choices annotation, the annotation is parsed and stored in this.annotation, but it's never used when building childInputs. Instead, all enumeration values from the type's definition are used.

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