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

Run modelica-fmt v0.2-pr.1 #2

Closed
wants to merge 1 commit into from
Closed

Run modelica-fmt v0.2-pr.1 #2

wants to merge 1 commit into from

Conversation

AntoineGautier
Copy link
Owner

Temporary branch testing modelica-fmt v0.2-pr.1 on Fluid and Experimental.DHC packages only.
Opening a draft PR to comment on the code.
Branch and PR shall be closed and deleted without merging when the test is done.

On Fluid and Experimental.DHC only
@AntoineGautier
Copy link
Owner Author

@macintoshpie I am pinging you on this dummy PR to share some inline comments that I have on the Modelica code after running modelic-fmt on a few packages.

@@ -13,8 +13,7 @@ model PartialParallel
nPorts_aChiWat=1,
nPorts_bHeaWat=1,
nPorts_aHeaWat=1);
parameter EnergyTransferStations.Types.ConnectionConfiguration conCon=
EnergyTransferStations.Types.ConnectionConfiguration.Pump
parameter EnergyTransferStations.Types.ConnectionConfiguration conCon=EnergyTransferStations.Types.ConnectionConfiguration.Pump
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format on the master was better.
Is it possible to enforce a line break to limit the line length at around 80 characters?

extent={{30.0,60.0},{30.0,110.0}},
textString="%name")}),
Documentation(info="<html>
annotation (defaultComponentName="y",Icon(coordinateSystem(preserveAspectRatio=true,extent={{-100.0,-100.0},{100.0,100.0}}),graphics={Polygon(lineColor={0,127,0},fillColor={255,255,255},fillPattern=FillPattern.Solid,points={{-100.0,100.0},{100.0,0.0},{-100.0,-100.0}})}),Diagram(coordinateSystem(preserveAspectRatio=true,extent={{-100.0,-100.0},{100.0,100.0}}),graphics={Polygon(lineColor={0,127,0},fillColor={255,255,255},fillPattern=FillPattern.Solid,points={{-100.0,50.0},{0.0,0.0},{-100.0,-50.0}}),Text(lineColor={0,0,127},extent={{30.0,60.0},{30.0,110.0}},textString="%name")}),Documentation(info="<html>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotation should be broken down with a constraint on line length.

parameter Boolean allowFlowReversal = true
replaceable package Medium=Modelica.Media.Interfaces.PartialMedium
"Medium in the component"
annotation (choices(choice(redeclare package Medium=Buildings.Media.Air "Moist air"),choice(redeclare package Medium=Buildings.Media.Water "Water"),choice(redeclare package Medium=Buildings.Media.Antifreeze.PropyleneGlycolWater(property_T=293.15,X_a=0.40) "Propylene glycol water, 40% mass fraction")));
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotation format on the master is better.
See also how Dymola renders it.
Screen Shot 2021-02-03 at 3 15 28 PM

res41(
linearized=true),
res42(
linearized=true));
Copy link
Owner Author

@AntoineGautier AntoineGautier Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could think of a rule to allow one-line class modifications (per the definition of a class-modification in https://specification.modelica.org/maint/3.5/modelica-concrete-syntax.html) if they do not yield a line length > 80 characters, otherwise break the line before 80 characters and after the last character matching "," | "=" | "(" | " ".
We could then apply this rule to declaration annotations (an annotation being syntactically defined by annotation class-modification). That would avoid expanding all annotations, while keeping the line length manageable.

@macintoshpie
Copy link

Thanks for the feedback Antoine! I will spend some time thinking about this and get back to you soon.

@macintoshpie
Copy link

@AntoineGautier I've created a (semi-hacky) implementation of the line break. It's not perfect, but it does break up lines 80+ characters. Please test the branch of this PR and let me know if this is any improvement: urbanopt/modelica-fmt#24

It breaks after "," | "=" | "{" | "(". It doesn't currently break on whitespace, but I can add that as well if this general implementation seems helpful.

AntoineGautier pushed a commit that referenced this pull request Dec 9, 2021
AntoineGautier pushed a commit that referenced this pull request Jan 21, 2022
created G36 package and updated trim/respond
AntoineGautier added a commit that referenced this pull request May 23, 2023
- Use a signed variable for cap and assign -/+ abs(cap) to Q_flow.
- Add simulation parameters to components.
- Add icons to template classes.
- Fix URI.
- Add validation models.
@AntoineGautier AntoineGautier deleted the tmp_testFMT branch September 6, 2023 12:13
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

Successfully merging this pull request may close these issues.

2 participants