Skip to content

Commit

Permalink
Different (correct) handling of dependencies="" (#130)
Browse files Browse the repository at this point in the history
* different handling for dependencies="" and tests

* Update Project.toml

---------

Co-authored-by: ThummeTo <[email protected]>
  • Loading branch information
halentin and ThummeTo authored Oct 11, 2024
1 parent 467e259 commit 7339fea
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FMIImport"
uuid = "9fcbc62e-52a0-44e9-a616-1359a0008194"
authors = ["TT <[email protected]>", "LM <[email protected]>", "JK <[email protected]>"]
version = "1.0.7"
version = "1.0.8"

[deps]
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Expand Down
4 changes: 4 additions & 0 deletions src/FMI2/md.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ function parseUnknown(md::fmi2ModelDescription, node::EzXML.Node)
if length(dependenciesSplit) > 0
varDep.dependencies = collect(parse(UInt, e) for e in dependenciesSplit)
end
else
varDep.dependencies = UInt[]
end
end

Expand All @@ -419,6 +421,8 @@ function parseUnknown(md::fmi2ModelDescription, node::EzXML.Node)
stringToDependencyKind(md, e) for e in dependenciesKindSplit
)
end
else
varDep.dependenciesKind = fmi2DependencyKind[]
end
end

Expand Down
4 changes: 4 additions & 0 deletions src/FMI3/md.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ function parseDependencies(md::fmi3ModelDescription, node::EzXML.Node)
if length(dependenciesSplit) > 0
varDep.dependencies = collect(parse(UInt, e) for e in dependenciesSplit)
end
else
varDep.dependencies = UInt[]
end
end

Expand All @@ -475,6 +477,8 @@ function parseDependencies(md::fmi3ModelDescription, node::EzXML.Node)
varDep.dependenciesKind =
collect(stringToDependencyKind(md, e) for e in dependenciesKindSplit)
end
else
varDep.dependenciesKind = fmi3DependencyKind[]
end
end

Expand Down
14 changes: 14 additions & 0 deletions test/FMI2/model_description.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,17 @@ for sv in myFMU.modelDescription.modelVariables
end

unloadFMU(myFMU)

myFMU = loadFMU("BouncingBall", "ModelicaReferenceFMUs", "0.0.30", "2.0")
@test isnothing(myFMU.modelDescription.modelStructure.derivatives[1].dependencies)

info(myFMU) # check if there is an error thrown

unloadFMU(myFMU)

myFMU = loadFMU("Dahlquist", "ModelicaReferenceFMUs", "0.0.30", "2.0")
@test !isnothing(myFMU.modelDescription.modelStructure.outputs[1].dependencies)

info(myFMU) # check if there is an error thrown

unloadFMU(myFMU)
10 changes: 10 additions & 0 deletions test/FMI3/model_description.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ myFMU = loadFMU("BouncingBall", "ModelicaReferenceFMUs", "0.0.30", "3.0")
@test myFMU.modelDescription.eventIndicatorValueReferences == [1]
@test typeof(myFMU.modelDescription.modelStructure.eventIndicators[1]) == fmi3VariableDependency

@test isnothing(myFMU.modelDescription.modelStructure.continuousStateDerivatives[1].dependencies)


info(myFMU) # check if there is an error thrown

unloadFMU(myFMU)

# Sadly there are no FMI3-Reference-FMUs with dependencies=""
# myFMU = loadFMU("Dahlquist", "ModelicaReferenceFMUs", "0.0.30", "3.0")
# @test !isnothing(myFMU.modelDescription.modelStructure.outputs[1].dependencies)

# info(myFMU) # check if there is an error thrown

# unloadFMU(myFMU)

2 comments on commit 7339fea

@ThummeTo
Copy link
Owner

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/117072

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.8 -m "<description of version>" 7339feabab03913b97dc0cf70f6653723d204284
git push origin v1.0.8

Please sign in to comment.