Skip to content

Commit

Permalink
preparation for FMIBase.jl (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThummeTo authored Jun 17, 2024
1 parent 9c2db79 commit d31c32a
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 52 deletions.
10 changes: 3 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
name = "FMIBuild"
uuid = "226f0e26-6dd6-4589-ada7-1d32f6e1d800"
authors = ["TT <tobias.thummerer@informatik.uni-augsburg.de>", "LM <lars.mikelsons@informatik.uni-augsburg.de>"]
version = "0.2.2"
version = "0.3.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
FMICore = "8af89139-c281-408e-bce2-3005eb87462f"
FMIBase = "900ee838-d029-460e-b485-d98a826ceef2"
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"

[compat]
Dates = "1"
EzXML = "1.1.0"
FMICore = "0.18.0 - 0.20"
FMIBase = "1.0.0"
PackageCompiler = "2.1.9"
Pkg = "1"
ZipFile = "0.9, 0.10"
julia = "1.6"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
## What FMI.jl-Library should I use?
![FMI.jl Family](https://github.com/ThummeTo/FMI.jl/blob/main/docs/src/assets/FMI_JL_family.png?raw=true "FMI.jl Family")
To keep dependencies nice and clean, the original package *FMI.jl* had been split into new packages:

- [*FMI.jl*](https://github.com/ThummeTo/FMI.jl): High level loading, manipulating, saving or building entire FMUs from scratch
- [*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
- [*FMIBase.jl*](https://github.com/ThummeTo/FMIBase.jl): Common concepts for import and export of FMUs
- [*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)
- [*FMIFlux.jl*](https://github.com/ThummeTo/FMIFlux.jl): Machine Learning with FMUs
- [*FMIZoo.jl*](https://github.com/ThummeTo/FMIZoo.jl): A collection of testing and example FMUs

## What Platforms are supported?
Expand Down
28 changes: 15 additions & 13 deletions src/FMIBuild.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@

module FMIBuild

using FMICore: FMU2, FMU2Component, fmi2ModelDescription, fmi2ValueReference, fmi2Component, fmi2ComponentEnvironment, fmi2Status, fmi2EventInfo
using FMICore: fmi2Type, fmi2TypeModelExchange, fmi2TypeCoSimulation
using FMICore: fmi2True, fmi2False
using FMICore: fmi2ModelDescriptionModelExchange, fmi2ModelDescriptionCoSimulation, fmi2VariableNamingConventionStructured
using FMICore: fmi2CausalityToString, fmi2VariabilityToString, fmi2InitialToString, fmi2DependencyKindToString
using FMICore: fmi2RealAttributes, fmi2IntegerAttributes, fmi2BooleanAttributes, fmi2StringAttributes, fmi2EnumerationAttributes
using FMICore: fmi2RealAttributesExt, fmi2IntegerAttributesExt, fmi2BooleanAttributesExt, fmi2StringAttributesExt, fmi2EnumerationAttributesExt
using FMIBase

#using FMICore: FMU2, FMU2Component, fmi2ModelDescription, fmi2ValueReference, fmi2Component, fmi2ComponentEnvironment, fmi2Status, fmi2EventInfo
#using FMICore: fmi2Type, fmi2TypeModelExchange, fmi2TypeCoSimulation
#using FMICore: fmi2True, fmi2False
#using FMICore: fmi2ModelDescriptionModelExchange, fmi2ModelDescriptionCoSimulation, fmi2VariableNamingConventionStructured
#using FMICore: fmi2CausalityToString, fmi2VariabilityToString, fmi2InitialToString, fmi2DependencyKindToString
#using FMICore: fmi2RealAttributes, fmi2IntegerAttributes, fmi2BooleanAttributes, fmi2StringAttributes, fmi2EnumerationAttributes
#using FMICore: fmi2RealAttributesExt, fmi2IntegerAttributesExt, fmi2BooleanAttributesExt, fmi2StringAttributesExt, fmi2EnumerationAttributesExt
#using FMIExport: fmi2SaveModelDescription

import PackageCompiler
import Pkg
import ZipFile
using EzXML
import FMIBase.ZipFile
using FMIBase.EzXML
import Dates

# exports
export fmi2Save
export saveFMU

# returns the path for a given package name (`nothing` if not installed)
function packagePath(pkg; )
Expand Down Expand Up @@ -67,7 +69,7 @@ The current package is detected, duplicated and extended by the FMI-functions. T
- `debug` compiles the FMU in debug mode, including full exception handling for all FMI functions. Exception stack is printed through the FMI callback pipeline. This is extremly useful during FMU development, but slows down the FMU's simulation performance (defaul=false)
- `surpressWarnings::Bool` an indicator wheater warnings should be surpressed (default=false)
"""
function fmi2Save(fmu::FMU2, fmu_path::String, fmu_src_file::Union{Nothing, String}=nothing;
function saveFMU(fmu::FMU2, fmu_path::String, fmu_src_file::Union{Nothing, String}=nothing;
standalone=true,
compress=true,
cleanup=true,
Expand Down Expand Up @@ -254,8 +256,8 @@ function fmi2Save(fmu::FMU2, fmu_path::String, fmu_src_file::Union{Nothing, Stri
end
end

# redirect FMIExport.jl package in case the active environment (the env the installer is called from)
# has a *more recent* version of FMIExport.jl than the registry (necessary for Github-CI to use the current version from a PR)
# [note] redirect FMIExport.jl package in case the active environment (the env the installer is called from)
# has a *more recent* version of FMIExport.jl than the registry (necessary for Github-CI to use the current version from a PR)
if isnothing(default_fmiexportPath) # the environemnt the exporter is called from *has no* FMIExport.jl installed
@info "[Build FMU] > Default environment `$(defaultEnv)` has no dependency on `FMIExport`."
else # the environemnt the exporter is called from *has* FMIExport.jl installed
Expand Down
5 changes: 2 additions & 3 deletions template/ME/FMU2/src/FMU2_content.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
# Licensed under the MIT license. See LICENSE file in the project root for details.
#

import FMICore

using FMICore
using FMICore: fmi2CallbackFunctions, fmi2Component, fmi2ComponentEnvironment, fmi2EventInfo, fmi2ValueReference
using FMICore: fmi2Real, fmi2Integer, fmi2Boolean, fmi2String, fmi2True, fmi2False, fmi2StatusOK, fmi2StatusWarning, fmi2StatusError, fmi2StatusFatal
using FMICore: fmi2Status, fmi2Type, fmi2StatusToString
using FMICore: fmi2Status, fmi2Type
using FMICore: FMU2Component
import FMICore: logInfo, logWarning, logError

Expand Down
53 changes: 26 additions & 27 deletions template/ME/FMU2/src/FMU2_content_debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
# Licensed under the MIT license. See LICENSE file in the project root for details.
#

import FMICore

using FMICore
using FMICore: fmi2CallbackFunctions, fmi2Component, fmi2ComponentEnvironment, fmi2EventInfo, fmi2ValueReference
using FMICore: fmi2Real, fmi2Integer, fmi2Boolean, fmi2String, fmi2True, fmi2False, fmi2StatusOK, fmi2StatusWarning, fmi2StatusError, fmi2StatusFatal
using FMICore: fmi2Status, fmi2Type, fmi2StatusToString
using FMICore: fmi2Status, fmi2Type
using FMICore: FMU2Component
import FMICore: logInfo, logWarning, logError

Expand Down Expand Up @@ -129,7 +128,7 @@ Base.@ccallable function fmi2SetDebugLogging(_component::fmi2Component, loggingO
end
status = FMICore.fmi2SetDebugLogging(FMIBUILD_FMU.cSetDebugLogging, _component, loggingOn, nCategories, categories)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -149,7 +148,7 @@ Base.@ccallable function fmi2SetupExperiment(_component::fmi2Component, toleranc
end
status = FMICore.fmi2SetupExperiment(FMIBUILD_FMU.cSetupExperiment, _component, toleranceDefined, tolerance, startTime, stopTimeDefined, stopTime)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -169,7 +168,7 @@ Base.@ccallable function fmi2EnterInitializationMode(_component::fmi2Component):
end
status = FMICore.fmi2EnterInitializationMode(FMIBUILD_FMU.cEnterInitializationMode, _component)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -189,7 +188,7 @@ Base.@ccallable function fmi2ExitInitializationMode(_component::fmi2Component)::
end
status = FMICore.fmi2ExitInitializationMode(FMIBUILD_FMU.cExitInitializationMode, _component)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -209,7 +208,7 @@ Base.@ccallable function fmi2Terminate(_component::fmi2Component)::fmi2Status
end
status = FMICore.fmi2Terminate(FMIBUILD_FMU.cTerminate, _component)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -229,7 +228,7 @@ Base.@ccallable function fmi2Reset(_component::fmi2Component)::fmi2Status
end
status = FMICore.fmi2Reset(FMIBUILD_FMU.cReset, _component)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: fmi2Reset($(_component))\n\tMessage: $(e)\n\tStack:")
Expand All @@ -248,7 +247,7 @@ Base.@ccallable function fmi2GetReal(_component::fmi2Component, _vr::Ptr{fmi2Val
end
status = FMICore.fmi2GetReal!(FMIBUILD_FMU.cGetReal, _component, _vr, nvr, _value)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: fmi2GetReal($(_component), $(_vr), $(nvr), $(_value))\n\tMessage: $(e)\n\tStack:")
Expand All @@ -267,7 +266,7 @@ Base.@ccallable function fmi2GetInteger(_component::fmi2Component, _vr::Ptr{fmi2
end
status = FMICore.fmi2GetInteger!(FMIBUILD_FMU.cGetInteger, _component, _vr, nvr, _value)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -287,7 +286,7 @@ Base.@ccallable function fmi2GetBoolean(_component::fmi2Component, _vr::Ptr{fmi2
end
status = FMICore.fmi2GetBoolean!(FMIBUILD_FMU.cGetBoolean, _component, _vr, nvr, _value)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -307,7 +306,7 @@ Base.@ccallable function fmi2GetString(_component::fmi2Component, _vr::Ptr{fmi2V
end
status = FMICore.fmi2GetString!(FMIBUILD_FMU.cGetString, _component, _vr, nvr, _value)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -327,7 +326,7 @@ Base.@ccallable function fmi2SetReal(_component::fmi2Component, _vr::Ptr{fmi2Val
end
status = FMICore.fmi2SetReal(FMIBUILD_FMU.cSetReal, _component, _vr, nvr, _value)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -347,7 +346,7 @@ Base.@ccallable function fmi2SetInteger(_component::fmi2Component, _vr::Ptr{fmi2
end
status = FMICore.fmi2SetInteger(FMIBUILD_FMU.cSetInteger, _component, _vr, nvr, _value)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -367,7 +366,7 @@ Base.@ccallable function fmi2SetBoolean(_component::fmi2Component, _vr::Ptr{fmi2
end
status = FMICore.fmi2SetBoolean(FMIBUILD_FMU.cSetBoolean, _component, _vr, nvr, _value)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -387,7 +386,7 @@ Base.@ccallable function fmi2SetString(_component::fmi2Component, _vr::Ptr{fmi2V
end
status = FMICore.fmi2SetString(FMIBUILD_FMU.cSetString, _component, _vr, nvr, _value)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -407,7 +406,7 @@ Base.@ccallable function fmi2SetTime(_component::fmi2Component, time::fmi2Real):
end
status = FMICore.fmi2SetTime(FMIBUILD_FMU.cSetTime, _component, time)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -427,7 +426,7 @@ Base.@ccallable function fmi2SetContinuousStates(_component::fmi2Component, _x::
end
status = FMICore.fmi2SetContinuousStates(FMIBUILD_FMU.cSetContinuousStates, _component, _x, nx)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -447,7 +446,7 @@ Base.@ccallable function fmi2EnterEventMode(_component::fmi2Component)::fmi2Stat
end
status = FMICore.fmi2EnterEventMode(FMIBUILD_FMU.cEnterEventMode, _component)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -467,7 +466,7 @@ Base.@ccallable function fmi2NewDiscreteStates(_component::fmi2Component, _fmi2e
end
status = FMICore.fmi2NewDiscreteStates!(FMIBUILD_FMU.cNewDiscreteStates, _component, _fmi2eventInfo)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -487,7 +486,7 @@ Base.@ccallable function fmi2EnterContinuousTimeMode(_component::fmi2Component):
end
status = FMICore.fmi2EnterContinuousTimeMode(FMIBUILD_FMU.cEnterContinuousTimeMode, _component)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -507,7 +506,7 @@ Base.@ccallable function fmi2CompletedIntegratorStep(_component::fmi2Component,
end
status = FMICore.fmi2CompletedIntegratorStep!(FMIBUILD_FMU.cCompletedIntegratorStep, _component, noSetFMUStatePriorToCurrentPoint, enterEventMode, terminateSimulation)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -527,7 +526,7 @@ Base.@ccallable function fmi2GetDerivatives(_component::fmi2Component, _derivati
end
status = FMICore.fmi2GetDerivatives!(FMIBUILD_FMU.cGetDerivatives, _component, _derivatives, nx)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: fmi2GetDerivatives($(_component), $(_derivatives), $(nx))\n\tMessage: $(e)\n\tStack:")
Expand All @@ -547,7 +546,7 @@ Base.@ccallable function fmi2GetEventIndicators(_component::fmi2Component, _even
end
status = FMICore.fmi2GetEventIndicators!(FMIBUILD_FMU.cGetEventIndicators, _component, _eventIndicators, ni)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -567,7 +566,7 @@ Base.@ccallable function fmi2GetContinuousStates(_component::fmi2Component, _x::
end
status = FMICore.fmi2GetContinuousStates!(FMIBUILD_FMU.cGetContinuousStates, _component, _x, nx)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand All @@ -587,7 +586,7 @@ Base.@ccallable function fmi2GetNominalsOfContinuousStates(_component::fmi2Compo
end
status = FMICore.fmi2GetNominalsOfContinuousStates!(FMIBUILD_FMU.cGetNominalsOfContinuousStates, _component, _x_nominal, nx)
if FMIBUILD_LOGGING
logInfo(_component, "\t-> $(status) [$(fmi2StatusToString(status))]")
logInfo(_component, "\t-> $(status) [$(statusToString(status))]")
end
catch e
logError(_component, "Exception thrown:\tIn function: ...\n\tMessage: $(e)\n\tStack:")
Expand Down

2 comments on commit d31c32a

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

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>" d31c32abd4edb875adee11cb27685a94c9eb9574
git push origin v0.3.0

Please sign in to comment.