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

Final keyword disregarded #360

Open
AntoineGautier opened this issue Sep 28, 2023 · 3 comments
Open

Final keyword disregarded #360

AntoineGautier opened this issue Sep 28, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@AntoineGautier
Copy link
Collaborator

AntoineGautier commented Sep 28, 2023

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
Copy link
Collaborator Author

AntoineGautier commented Oct 20, 2023

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
Copy link
Collaborator

@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
Copy link
Collaborator Author

AntoineGautier commented Oct 25, 2023

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 lbl-srg/modelica-buildings@30fd0f3...master#diff-cf424f8df0b9ff39c6a6b4986c14a10c865ee3b5ae1fa3e3956e630aaa0bbb34R12-R27.

What is currently visible on the staging branch is the other occurrence of this issue, described at #360 (comment).
In this case, the workaround proposed in #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.

@AntoineGautier AntoineGautier self-assigned this Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants