Skip to content

Commit a3fcd4e

Browse files
committed
parse Event Indicator Dependencies
1 parent 8001d8b commit a3fcd4e

File tree

1 file changed

+5
-35
lines changed

1 file changed

+5
-35
lines changed

src/FMI3/md.jl

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function fmi3LoadModelDescription(pathToModellDescription::String)
4848
md.inputValueReferences = Array{fmi3ValueReference}(undef, 0)
4949
md.stateValueReferences = Array{fmi3ValueReference}(undef, 0)
5050
md.derivativeValueReferences = Array{fmi3ValueReference}(undef, 0)
51+
md.eventIndicatorValueReferences = Array{fmi3ValueReference}(undef, 0)
5152
md.intermediateUpdateValueReferences = Array{fmi3ValueReference}(undef, 0)
5253
md.numberOfEventIndicators = 0
5354

@@ -415,8 +416,10 @@ function parseModelStructure(md::fmi3ModelDescription, nodes::EzXML.Node)
415416
push!(md.modelStructure.initialUnknowns, varDep)
416417
elseif node.name == "EventIndicator"
417418
md.numberOfEventIndicators += 1
418-
push!(md.modelStructure.eventIndicators)
419-
# [TODO] parse valueReferences to another array
419+
varDep = parseDependencies(md, node)
420+
push!(md.modelStructure.eventIndicators, varDep)
421+
eIvalueRef = parseNode(node, "valueReference", fmi3ValueReference)
422+
push!(md.eventIndicatorValueReferences, eIvalueRef)
420423
elseif node.name == "ContinuousStateDerivative"
421424

422425
# find states and derivatives
@@ -483,36 +486,3 @@ function parseDependencies(md::fmi3ModelDescription, node::EzXML.Node)
483486

484487
return varDep
485488
end
486-
487-
function parseContinuousStateDerivative(md::fmi3ModelDescription, nodes::EzXML.Node)
488-
@assert (nodes.name == "ContinuousStateDerivative") "Wrong element name."
489-
md.modelStructure.derivatives = []
490-
for node in eachelement(nodes)
491-
if node.name == "InitialUnknown"
492-
if haskey(node, "index")
493-
varDep = parseUnknwon(md, node)
494-
495-
# find states and derivatives
496-
derSV = md.modelVariables[varDep.index]
497-
derVR = derSV.valueReference
498-
stateVR = md.modelVariables[derSV.derivative].valueReference
499-
500-
if stateVR md.stateValueReferences
501-
push!(md.stateValueReferences, stateVR)
502-
end
503-
if derVR md.derivativeValueReferences
504-
push!(md.derivativeValueReferences, derVR)
505-
end
506-
507-
push!(md.modelStructure.derivatives, varDep)
508-
else
509-
@warn "Invalid entry for node `Unknown` in `ModelStructure`, missing entry `index`."
510-
end
511-
elseif node.name == "EventIndicator"
512-
md.numberOfEventIndicators += 1
513-
# TODO parse valueReferences to another array
514-
else
515-
@warn "Unknown entry in `ModelStructure.Derivatives` named `$(node.name)`."
516-
end
517-
end
518-
end

0 commit comments

Comments
 (0)