Skip to content

Parse type as type and value as value #495

@AntoineGautier

Description

@AntoineGautier

Context

Currently replaceable elements are parsed by assigning the replaceable type to both the type and the value property.

    {
      "modelicaPath": "Buildings.Templates.AirHandlersFans.VAVMultiZone.secOutRel",
      "type": "Buildings.Templates.AirHandlersFans.Components.OutdoorReliefReturnSection.MixedAirWithDamper",
      "value": "Buildings.Templates.AirHandlersFans.Components.OutdoorReliefReturnSection.MixedAirWithDamper",
      "replaceable": true,

Class modifications with redeclare are then parsed by assigning the redeclared type to the expression property and using "redeclare": true.

        "Buildings.Fluid.BaseClasses.PartialThreeWayResistance.res2": {
          "expression": {
            "operator": "none",
            "operands": [
              "Buildings.Fluid.FixedResistances.PressureDrop"
            ]
          },
          "redeclare": true

This design choice raises an issue for record types that can be both (re)declared and assigned a new (composite) value.

replaceable RecordType rec = localRecordInstance;
// or 
extends Model(
  redeclare NewRecordType rec=localRecordInstance);

Proposition

To support such constructs it makes sense to revisit the parser schema and use

  • type property to store the actual type
  • value property to store the actual assignment (if any)
  • undefined instead of "" for the value property if there's no assignment
  • redeclare property to store the redeclared type – the redeclare property would become a string instead of a boolean

Short Class Definitions

Short class definitions raise a question because in that case the aliased type is "assigned" to the short class.

  model ShortClass = Aliased.Type;

For consistency with the redesigned schema, we'll stick to the type property to store Aliased.Type and use the modelicaPath property to store the short class name, appended to the fully qualified class name containing the definition.

    {
      "modelicaPath": "Fully.Qualified.Enclosing.Class.Name.ShortClass",
      "type": "Aliased.Type"

Selection Schema

⚠️ The selection schema remains flat (single field) and only stores a single "value" for any class mod:

  "Buildings.Templates.AirHandlersFans.VAVMultiZone.have_senPreBui-have_senPreBui": [
    true // <--- Assignment
  ],
  "Buildings.Templates.AirHandlersFans.VAVMultiZone.secOutRel-secOutRel": [
    "Buildings.Templates.AirHandlersFans.Components.OutdoorReliefReturnSection.MixedAirWithDamper" // <--- Redeclare
  ],

This is not problematic because:

  • Users only select one thing at a time - either a type or a value
  • The context (which option is being configured) indicates which kind of selection it is

Metadata

Metadata

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