Skip to content

Commit

Permalink
Merge pull request #4 from grouperenault/dev
Browse files Browse the repository at this point in the history
Fix ModelStructure and Python 3.9 specific code
  • Loading branch information
nl78 authored Oct 4, 2024
2 parents d258982 + 7044193 commit a7bcf6c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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

0 comments on commit a7bcf6c

Please sign in to comment.