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

Fix ModelStructure and Python 3.9 specific code #4

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion fmutool/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def fmutool():

parser = argparse.ArgumentParser(prog='fmutool',
description="Manipulate a FMU by modifying its 'modelDescription.xml'",
formatter_class=make_wide(argparse.ArgumentDefaultsHelpFormatter),
formatter_class=make_wide(argparse.HelpFormatter),
add_help=False,
epilog="see: https://github.com/grouperenault/fmutool/blob/main/README.md")

Expand Down Expand Up @@ -156,6 +156,8 @@ def fmucontainer():
epilog="see: https://github.com/grouperenault/fmutool/blob/main/"
"container/README.md")

parser.add_argument('-h', '-help', action="help")

parser.add_argument("-fmu-directory", action="store", dest="fmu_directory", required=True,
help="Directory containing initial FMU’s and used to generate containers.")

Expand Down
15 changes: 14 additions & 1 deletion fmutool/fmu_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def xml(self, vr: int, name=None, causality=None, start=None):
"name": name,
"valueReference": vr,
"causality": causality
} | self.attrs
}
scalar_attrs.update(self.attrs)

scalar_attrs_str = " ".join([f'{key}="{value}"' for (key, value) in scalar_attrs.items()])

Expand Down Expand Up @@ -436,6 +437,18 @@ def make_fmu_xml(self, xml_file, step_size):
xml_file.write(""" </ModelVariables>

<ModelStructure>
<Outputs>
""")

index_offset = len(self.locals) + len(self.inputs) + 1
for i, _ in enumerate(self.outputs.keys()):
print(f' <Unknown index="{index_offset+i}"/>', file=xml_file)
xml_file.write(""" </Outputs>
<InitialUnknowns>
""")
for i, _ in enumerate(self.outputs.keys()):
print(f' <Unknown index="{index_offset+i}"/>', file=xml_file)
xml_file.write(""" </InitialUnknowns>
</ModelStructure>

</fmiModelDescription>
Expand Down
Loading