Skip to content

Commit

Permalink
FMI3 Beta Merge (#16) (#17)
Browse files Browse the repository at this point in the history
* Fmi3 beta (#16)

* modified executionConfig

* Refactor fmi3 (#12)

* added conversions for causality, initial,...

* Added TODOs

* Refactor Model Description parsing

* copy ccalls, replace return value with fmi3Status

* replace Ptr{Nothing} with fmi3Instance

* Update FMI3_c.jl

* added more conversion methods

* Update FMI3_c.jl

* expand export list

* add instantiation functions

* add Instance State

* Apply changes lost in merge

* WIP: works until simulation

* Update FMI3_c.jl

* added missing functions

* more refactoring

* fix merge problems

* Update FMI3.jl

* Update FMI3.jl

* add internal state

refactor to new package version

* merged executionConfigs

* fix

* fixed project.toml

* minor fix

Co-authored-by: JoKircher <[email protected]>

* FMU_Execution_config

* minor fixes

* minor fix

* minor fixes

* minor fix

Co-authored-by: JoKircher <[email protected]>
  • Loading branch information
ThummeTo and JoKircher authored Jun 7, 2022
1 parent 7b8c722 commit 800bfb3
Show file tree
Hide file tree
Showing 6 changed files with 2,110 additions and 160 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FMICore"
uuid = "8af89139-c281-408e-bce2-3005eb87462f"
authors = ["TT <[email protected]>", "LM <[email protected]>", "JK <[email protected]>"]
version = "0.8.4"
version = "0.9.0"

[compat]
julia = "^1.5"
40 changes: 21 additions & 19 deletions src/FMI2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ FMU states: $(c.x)"
)

"""
=======
A mutable struct representing the excution configuration of a FMU.
For FMUs that have issues with calls like `fmi2Reset` or `fmi2FreeInstance`, this is pretty useful.
"""
mutable struct FMU2ExecutionConfiguration
mutable struct FMU2ExecutionConfiguration <: FMUExecutionConfig
terminate::Bool # call fmi2Terminate before every training step / simulation
reset::Bool # call fmi2Reset before every training step / simulation
setup::Bool # call setup functions before every training step / simulation
Expand Down Expand Up @@ -217,30 +218,30 @@ mutable struct FMU2ExecutionConfiguration
end

# default for a "healthy" FMU - this is the fastetst
FMU_EXECUTION_CONFIGURATION_RESET = FMU2ExecutionConfiguration()
FMU_EXECUTION_CONFIGURATION_RESET.terminate = true
FMU_EXECUTION_CONFIGURATION_RESET.reset = true
FMU_EXECUTION_CONFIGURATION_RESET.instantiate = false
FMU_EXECUTION_CONFIGURATION_RESET.freeInstance = false
FMU2_EXECUTION_CONFIGURATION_RESET = FMU2ExecutionConfiguration()
FMU2_EXECUTION_CONFIGURATION_RESET.terminate = true
FMU2_EXECUTION_CONFIGURATION_RESET.reset = true
FMU2_EXECUTION_CONFIGURATION_RESET.instantiate = false
FMU2_EXECUTION_CONFIGURATION_RESET.freeInstance = false

# if your FMU has a problem with "fmi2Reset" - this is default
FMU_EXECUTION_CONFIGURATION_NO_RESET = FMU2ExecutionConfiguration()
FMU_EXECUTION_CONFIGURATION_NO_RESET.terminate = false
FMU_EXECUTION_CONFIGURATION_NO_RESET.reset = false
FMU_EXECUTION_CONFIGURATION_NO_RESET.instantiate = true
FMU_EXECUTION_CONFIGURATION_NO_RESET.freeInstance = true
FMU2_EXECUTION_CONFIGURATION_NO_RESET = FMU2ExecutionConfiguration()
FMU2_EXECUTION_CONFIGURATION_NO_RESET.terminate = false
FMU2_EXECUTION_CONFIGURATION_NO_RESET.reset = false
FMU2_EXECUTION_CONFIGURATION_NO_RESET.instantiate = true
FMU2_EXECUTION_CONFIGURATION_NO_RESET.freeInstance = true

# if your FMU has a problem with "fmi2Reset" and "fmi2FreeInstance" - this is for weak FMUs (but slower)
FMU_EXECUTION_CONFIGURATION_NO_FREEING = FMU2ExecutionConfiguration()
FMU_EXECUTION_CONFIGURATION_NO_FREEING.terminate = false
FMU_EXECUTION_CONFIGURATION_NO_FREEING.reset = false
FMU_EXECUTION_CONFIGURATION_NO_FREEING.instantiate = true
FMU_EXECUTION_CONFIGURATION_NO_FREEING.freeInstance = false
FMU2_EXECUTION_CONFIGURATION_NO_FREEING = FMU2ExecutionConfiguration()
FMU2_EXECUTION_CONFIGURATION_NO_FREEING.terminate = false
FMU2_EXECUTION_CONFIGURATION_NO_FREEING.reset = false
FMU2_EXECUTION_CONFIGURATION_NO_FREEING.instantiate = true
FMU2_EXECUTION_CONFIGURATION_NO_FREEING.freeInstance = false

"""
ToDo
"""
struct FMU2Event
struct FMU2Event <: FMUEvent
t::Union{Float32, Float64}
indicator::UInt

Expand Down Expand Up @@ -407,7 +408,7 @@ mutable struct FMU2 <: FMU

# execution configuration
executionConfig::FMU2ExecutionConfiguration
hasStateEvents::Union{Bool, Nothing}
hasStateEvents::Union{Bool, Nothing}
hasTimeEvents::Union{Bool, Nothing}

# c-libraries
Expand All @@ -427,11 +428,12 @@ mutable struct FMU2 <: FMU
inst = new()
inst.components = []
inst.callbackLibHandle = C_NULL
inst.modelName = ""

inst.hasStateEvents = nothing
inst.hasTimeEvents = nothing

inst.executionConfig = FMU_EXECUTION_CONFIGURATION_NO_RESET
inst.executionConfig = FMU2_EXECUTION_CONFIGURATION_NO_RESET

return inst
end
Expand Down
2 changes: 1 addition & 1 deletion src/FMI2_c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const fmi2TypeCoSimulation = Cuint(1)
mutable struct fmi2ModelDescriptionReal
# mandatory
# (nothing)

# optional
declaredType::Union{String, Nothing}
quantity::Union{String, Nothing}
Expand Down
Loading

2 comments on commit 800bfb3

@ThummeTo
Copy link
Owner Author

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/61886

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 v0.9.0 -m "<description of version>" 800bfb3ea76d2f135a4696892237eeba9d59392a
git push origin v0.9.0

Please sign in to comment.