Skip to content

Commit

Permalink
Different (correct) handling of dependencies="" (ThummeTo#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)

0 comments on commit 7339fea

Please sign in to comment.