Skip to content

Commit

Permalink
different handling for dependencies="" and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
halentin committed Oct 1, 2024
1 parent 467e259 commit eddf166
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
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 eddf166

Please sign in to comment.