lbl-srg / ctrl-flow-dev

ctrl-flow development
Other
0 stars 0 forks source link

Final keyword disregarded #360

Open AntoineGautier opened 7 months ago

AntoineGautier commented 7 months ago

Using commit 30fd0f3d1f of MBL, the final keyword in the following bindings is disregarded.

partial model PartialOutdoorSectionDedicatedDampers
  "Base class for modeling separate dampers for ventilation and economizer"
  extends 
    Buildings.Templates.AirHandlersFans.Components.Interfaces.PartialOutdoorSection(
    final typDamOut=damOut.typ,
    final typDamOutMin=damOutMin.typ);

When running the app, we get the following input fields for the OA dampers, that should be disabled due to the final keyword.

Capture d’écran 2023-09-28 à 17 07 32

This is surprising because this pattern is used elsewhere. For example, the type of an equipment is declared in the interface class, e.g.

partial model PartialOutdoorSection "Interface class for outdoor air section"
  parameter Buildings.Controls.OBC.ASHRAE.G36.Types.OutdoorAirSection typ
    "Outdoor air section type"
    annotation (Evaluate=true, Dialog(group="Configuration"));

and assigned with the final keyword in the derived class, e.g.

model DedicatedDampersAirflow
  "Separate dampers for ventilation and economizer, with airflow measurement station"
  extends Buildings.Templates.AirHandlersFans.Components.Interfaces.PartialOutdoorSectionDedicatedDampers(
    final typ=Buildings.Controls.OBC.ASHRAE.G36.Types.OutdoorAirSection.DedicatedDampersAirflow);

And in this case, the app does not generate an input field for the equipment type, which is as expected.

A propable cause is that in the case of typDamOut*, the final assignment is made in an intermediary child class.

Workaround

Use __ctrlFlow(enable=false) annotation. Or make final assignments for typDamOut and typDamOutMin within the interface class if possible.

AntoineGautier commented 7 months ago

Another occurrence of this issue appears with commit 6036d14d2d3a12376dab886a62a40d3f475f68ab of MBL and the following declaration within Buildings.Templates.AirHandlersFans.VAVMultiZone.

  inner replaceable Buildings.Templates.AirHandlersFans.Components.OutdoorReliefReturnSection.MixedAirWithDamper
    secOutRel(
    redeclare final package MediumAir = MediumAir,
    final typCtlFanRet=ctl.typCtlFanRet,
    final typCtlEco=ctl.typCtlEco,

The input fields for typCtlFanRet and typCtlEco are enabled in the configuration dialog despite the final keyword. Here, adding a constraining clause with the class that contains the original declarations of typCtlFanRet and typCtlEco solves the issue, i.e.

  inner replaceable Buildings.Templates.AirHandlersFans.Components.OutdoorReliefReturnSection.MixedAirWithDamper
    secOutRel constrainedby Buildings.Templates.AirHandlersFans.Components.Interfaces.PartialOutdoorReliefReturnSection(
    redeclare final package MediumAir = MediumAir,
    final typCtlFanRet=ctl.typCtlFanRet,
    final typCtlEco=ctl.typCtlEco,
JayHuLBL commented 6 months ago

@AntoineGautier when running the app in staging.ctrl-flow.lbl.gov, I cannot see the entry for the outdoor air section. See below the screenshot in the ctrl-flow.lbl.gov:

Screenshot 2023-10-24 at 12 09 26 PM

How can I see the screenshot as you are showing here?

AntoineGautier commented 6 months ago

To see the screenshot from above with the incorrect entries for the OA section, you have to locally rebuild the server app with the referenced MBL commit 30fd0f3d1f. In more recent MBL commits (such as the one currently used on the staging branch), a workaround was implemented where final assignments for typDamOut and typDamOutMin are made within the interface class (as opposed to the derived class as above). See the diff at https://github.com/lbl-srg/modelica-buildings/compare/30fd0f3d1f004812b9b468b547d27d120db2bb14...master#diff-cf424f8df0b9ff39c6a6b4986c14a10c865ee3b5ae1fa3e3956e630aaa0bbb34R12-R27.

What is currently visible on the staging branch is the other occurrence of this issue, described at https://github.com/lbl-srg/ctrl-flow-dev/issues/360#issuecomment-1772326895. In this case, the workaround proposed in https://github.com/lbl-srg/ctrl-flow-dev/pull/369 uses __ctrlFlow(enable=false) annotation.

Note that the current issue shall remain open as these two workarounds do not solve the original problem, which is that ctrl-flow disregards some final assignments for some specific constructs.