Skip to content

Commit

Permalink
V0.3.0 (#33)
Browse files Browse the repository at this point in the history
* restored compatibility with FMICore

* reintegrated tests, ready for FMISensitivity

* minor adjustments

* test all tests

* removed FMIExport depnedncy in examples
  • Loading branch information
ThummeTo authored Nov 6, 2023
1 parent 16ef45f commit d983ed9
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 40 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FMIExport"
uuid = "31b88311-cab6-44ed-ba9c-fe5a9abbd67a"
authors = ["TT <[email protected]>", "LM <[email protected]>"]
version = "0.2.1"
version = "0.3.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand All @@ -10,6 +10,7 @@ FMICore = "8af89139-c281-408e-bce2-3005eb87462f"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
Dates = "1"
EzXML = "1.1.0"
FMICore = "0.17.1"
FMICore = "0.18.0 - 0.19.0"
julia = "1.6"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ To keep dependencies nice and clean, the original package [*FMI.jl*](https://git
- [*FMIImport.jl*](https://github.com/ThummeTo/FMIImport.jl): Importing FMUs into Julia
- [*FMIExport.jl*](https://github.com/ThummeTo/FMIExport.jl): Exporting stand-alone FMUs from Julia Code
- [*FMICore.jl*](https://github.com/ThummeTo/FMICore.jl): C-code wrapper for the FMI-standard
- [*FMISensitivity.jl*](https://github.com/ThummeTo/FMISensitivity.jl): Static and dynamic sensitivities over FMUs
- [*FMIBuild.jl*](https://github.com/ThummeTo/FMIBuild.jl): Compiler/Compilation dependencies for FMIExport.jl
- [*FMIFlux.jl*](https://github.com/ThummeTo/FMIFlux.jl): Machine Learning with FMUs (differentiation over FMUs)
- [*FMIZoo.jl*](https://github.com/ThummeTo/FMIZoo.jl): A collection of testing and example FMUs
Expand Down
3 changes: 1 addition & 2 deletions examples/FMI2/BouncingBall/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ FMIBuild = "226f0e26-6dd6-4589-ada7-1d32f6e1d800"
FMIExport = "31b88311-cab6-44ed-ba9c-fe5a9abbd67a"

[compat]
FMIBuild = "0.1.15"
FMIExport = "0.2.0"
FMIBuild = "0.2.0"
julia = "1.6"
4 changes: 2 additions & 2 deletions examples/FMI2/BouncingBall/src/BouncingBall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ tmpDir = mktempdir(; prefix="fmibuildjl_test_", cleanup=false)
fmu_save_path = joinpath(tmpDir, "BouncingBall.fmu")

fmu = FMIBUILD_CONSTRUCTOR()
using FMIBuild: fmi2Save # <= this must be excluded during export, because FMIBuild cannot execute itself (but it is able to build)
fmi2Save(fmu, fmu_save_path) # <= this must be excluded during export, because fmi2Save would start an infinte build loop with itself
using FMIBuild: fmi2Save # <= this must be excluded during export, because FMIBuild cannot execute itself (but it is able to build)
fmi2Save(fmu, fmu_save_path; debug=true) # <= this must be excluded during export, because fmi2Save would start an infinte build loop with itself (debug=true allows debug messages, but is slow during execution!)

### some tests ###
# using FMI
Expand Down
3 changes: 1 addition & 2 deletions examples/FMI2/Manipulation/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ FMIImport = "9fcbc62e-52a0-44e9-a616-1359a0008194"
FMIZoo = "724179cf-c260-40a9-bd27-cccc6fe2f195"

[compat]
FMIBuild = "0.1.15"
FMIExport = "0.2.0"
FMIBuild = "0.2.0"
julia = "1.6"
3 changes: 1 addition & 2 deletions examples/FMI2/NeuralFMU/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ FMIImport = "9fcbc62e-52a0-44e9-a616-1359a0008194"
FMIZoo = "724179cf-c260-40a9-bd27-cccc6fe2f195"

[compat]
FMIBuild = "0.1.15"
FMIExport = "0.2.0"
FMIBuild = "0.2.0"
julia = "1.6"
2 changes: 1 addition & 1 deletion examples/FMI2/NeuralFMU/src/NeuralFMU.jl
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ fmu_save_path = joinpath(tmpDir, "NeuralFMU.fmu")
sourceFMU = FMIZoo.get_model_filename("SpringDamperPendulum1D", "Dymola", "2022x")
fmu = FMIBUILD_CONSTRUCTOR(dirname(sourceFMU))
import FMIBuild:fmi2Save # <= this must be excluded during export, because FMIBuild cannot execute itself (but it is able to build)
fmi2Save(fmu, fmu_save_path; compress=true, resources=Dict(sourceFMU=>"SpringDamperPendulum1D.fmu")) # <= this must be excluded during export, because fmi2Save would start an infinte build loop with itself
fmi2Save(fmu, fmu_save_path; compress=false, debug=true, resources=Dict(sourceFMU=>"SpringDamperPendulum1D.fmu")) # <= this must be excluded during export, because fmi2Save would start an infinte build loop with itself

### some tests ###
# using FMI
Expand Down
33 changes: 9 additions & 24 deletions src/FMI2_simple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,6 @@ function dereferenceInstance(address::fmi2Component)
return nothing
end

function logInfo(_component::fmi2Component, message, status::fmi2Status=fmi2StatusOK)
component = dereferenceInstance(_component)
logInfo(component, message, status)
end

function logWarning(_component::fmi2Component, message, status::fmi2Status=fmi2StatusWarning)
component = dereferenceInstance(_component)
logWarning(component, message, status)
end

function logError(_component::fmi2Component, message, status::fmi2Status=fmi2StatusError)
component = dereferenceInstance(_component)
logError(component, message, status)
end

##############

function reset(_component::fmi2Component)
Expand Down Expand Up @@ -77,10 +62,10 @@ function evaluate(_component::fmi2Component, eventMode=false)
xd = tmp_xd
else
if xc != tmp_xc
logError(_component, "FMU_FCT_EVALUATE changes the systems continuous state while not being in event-mode, this is not allowed!")
logError(component, "FMU_FCT_EVALUATE changes the systems continuous state while not being in event-mode, this is not allowed!")
end
if xd != tmp_xd
logError(_component, "FMU_FCT_EVALUATE changes the systems discrete state while not being in event-mode, this is not allowed!")
logError(component, "FMU_FCT_EVALUATE changes the systems discrete state while not being in event-mode, this is not allowed!")
end
end

Expand Down Expand Up @@ -309,7 +294,7 @@ function simple_fmi2GetReal(_component::fmi2Component, _vr::Ptr{fmi2ValueReferen
try
value[i] = component.values[valueRef]
catch e
logError(component.compAddr, "fmi2SetReal: Unknown value reference $(valueRef).")
logError(component, "fmi2SetReal: Unknown value reference $(valueRef).")
return fmi2StatusError
end
end
Expand Down Expand Up @@ -353,7 +338,7 @@ function simple_fmi2SetReal(_component::fmi2Component, _vr::Ptr{fmi2ValueReferen
try
component.values[valueRef] = value[i]
catch e
logError(component.compAddr, "fmi2SetReal: Unknown value reference $(valueRef).")
logError(component, "fmi2SetReal: Unknown value reference $(valueRef).")
return fmi2StatusError
end
end
Expand Down Expand Up @@ -401,7 +386,7 @@ function simple_fmi2SetContinuousStates(_component::fmi2Component, _x::Ptr{fmi2R
component = dereferenceInstance(_component)

if nx != length(component.fmu.modelDescription.stateValueReferences)
logWarning(component.compAddr, "fmi2SetContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).")
logWarning(component, "fmi2SetContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).")
end

x = unsafe_wrap(Array{fmi2Real}, _x, nx)
Expand Down Expand Up @@ -462,7 +447,7 @@ function simple_fmi2GetDerivatives(_component::fmi2Component, _derivatives::Ptr{
component = dereferenceInstance(_component)

if nx != length(component.fmu.modelDescription.derivativeValueReferences)
logWarning(component.compAddr, "fmi2GetDerivatives: Model has $(length(component.fmu.modelDescription.derivativeValueReferences)) states, but `nx`=$(nx).")
logWarning(component, "fmi2GetDerivatives: Model has $(length(component.fmu.modelDescription.derivativeValueReferences)) states, but `nx`=$(nx).")
end

derivatives = unsafe_wrap(Array{fmi2Real}, _derivatives, nx)
Expand All @@ -479,7 +464,7 @@ function simple_fmi2GetEventIndicators(_component::fmi2Component, _eventIndicato
component = dereferenceInstance(_component)

if ni != length(component.fmu.modelDescription.numberOfEventIndicators)
logWarning(component.compAddr, "fmi2GetEventIndicators: Model has $(length(component.eventIndicators)) states, but `ni`=$(ni).")
logWarning(component, "fmi2GetEventIndicators: Model has $(length(component.eventIndicators)) states, but `ni`=$(ni).")
end

eventIndicators = unsafe_wrap(Array{fmi2Real}, _eventIndicators, ni)
Expand All @@ -497,7 +482,7 @@ function simple_fmi2GetContinuousStates(_component::fmi2Component, _x::Ptr{fmi2R
component = dereferenceInstance(_component)

if nx != length(component.fmu.modelDescription.stateValueReferences)
logWarning(component.compAddr, "fmi2GetContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).")
logWarning(component, "fmi2GetContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).")
end

x = unsafe_wrap(Array{fmi2Real}, _x, nx)
Expand All @@ -514,7 +499,7 @@ function simple_fmi2GetNominalsOfContinuousStates(_component::fmi2Component, _x_
component = dereferenceInstance(_component)

if nx != length(component.fmu.modelDescription.stateValueReferences)
logWarning(component.compAddr, "fmi2GetNominalsOfContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).")
logWarning(component, "fmi2GetNominalsOfContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).")
end

x_nominal = unsafe_wrap(Array{fmi2Real}, _x_nominal, nx)
Expand Down
2 changes: 1 addition & 1 deletion src/FMIExport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using FMICore: fmi2RealAttributesExt, fmi2IntegerAttributesExt, fmi2BooleanAttri
using FMICore: fmi2VariableDependency, fmi2Unknown, fmi2DependencyKind
using FMICore: fmi2VariableNamingConventionStructured
using FMICore: fmi2CausalityToString, fmi2VariabilityToString, fmi2InitialToString
using FMICore: fmi2String, fmi2Boolean, fmi2Integer, fmi2Real, fmi2Enum
using FMICore: fmi2String, fmi2Boolean, fmi2Integer, fmi2Real
using FMICore: fmi2Type, fmi2TypeModelExchange, fmi2TypeCoSimulation
using FMICore: fmi2CallbackFunctions
using FMICore: fmi2StatusOK, fmi2StatusWarning, fmi2StatusError
Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ function runtests()
end

@testset "FMU Manipulation" begin
@warn "This test is currently excluded because of insufficient ressources in GitHub-Actions."
#include("manipulation.jl")
#@warn "The test `FMU Manipulation` is currently excluded because of insufficient ressources in GitHub-Actions."
include("manipulation.jl")
end

@testset "NeuralFMU" begin
@warn "This test is currently excluded because of insufficient ressources in GitHub-Actions."
#include("neuralFMU.jl")
#@warn "The test `NeuralFMU` is currently excluded because of insufficient ressources in GitHub-Actions."
include("neuralFMU.jl")
end
end

Expand Down

2 comments on commit d983ed9

@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/94835

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 v0.3.0 -m "<description of version>" d983ed95a1741af191028b249d4ec49557bbad3b
git push origin v0.3.0

Please sign in to comment.