Skip to content

Commit f8b9874

Browse files
authored
v1.0.0 (#63)
* refactoring for FMIBase.jl * PkgEval test * WIP
1 parent 8c266ef commit f8b9874

26 files changed

+369
-3142
lines changed

Project.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
name = "FMICore"
22
uuid = "8af89139-c281-408e-bce2-3005eb87462f"
33
authors = ["TT <tobias.thummerer@informatik.uni-augsburg.de>", "LM <lars.mikelsons@informatik.uni-augsburg.de>", "JK <josef.kircher@student.uni-augsburg.de>"]
4-
version = "0.20.1"
4+
version = "1.0.0"
55

66
[deps]
7-
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
87
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
9-
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
108

119
[compat]
12-
ChainRulesCore = "1.16"
1310
Dates = "1"
14-
Requires = "1.3.0"
1511
julia = "1.6"

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
## What is FMICore.jl?
55
[*FMICore.jl*](https://github.com/ThummeTo/FMICore.jl) implements the low-level equivalents of the C-functions and C-data types of the FMI-standard ([fmi-standard.org](http://fmi-standard.org/)) for the Julia programming language.
6-
[*FMICore.jl*](https://github.com/ThummeTo/FMICore.jl) provides the foundation for the Julia packages [*FMIImport.jl*](https://github.com/ThummeTo/FMIImport.jl) and [*FMIExport.jl*](https://github.com/ThummeTo/FMIExport.jl).
76

87
[![Dev Docs](https://img.shields.io/badge/docs-dev-blue.svg)](https://ThummeTo.github.io/FMI.jl/dev)
98
[![Run Tests](https://github.com/ThummeTo/FMICore.jl/actions/workflows/Test.yml/badge.svg)](https://github.com/ThummeTo/FMICore.jl/actions/workflows/Test.yml)
@@ -31,14 +30,15 @@ To keep dependencies nice and clean, the original package [*FMI.jl*](https://git
3130
- [*FMI.jl*](https://github.com/ThummeTo/FMI.jl): High level loading, manipulating, saving or building entire FMUs from scratch
3231
- [*FMIImport.jl*](https://github.com/ThummeTo/FMIImport.jl): Importing FMUs into Julia
3332
- [*FMIExport.jl*](https://github.com/ThummeTo/FMIExport.jl): Exporting stand-alone FMUs from Julia Code
33+
- [*FMIBase.jl*](https://github.com/ThummeTo/FMIBase.jl): Common concepts for import and export of FMUs
3434
- [*FMICore.jl*](https://github.com/ThummeTo/FMICore.jl): C-code wrapper for the FMI-standard
3535
- [*FMISensitivity.jl*](https://github.com/ThummeTo/FMISensitivity.jl): Static and dynamic sensitivities over FMUs
3636
- [*FMIBuild.jl*](https://github.com/ThummeTo/FMIBuild.jl): Compiler/Compilation dependencies for FMIExport.jl
37-
- [*FMIFlux.jl*](https://github.com/ThummeTo/FMIFlux.jl): Machine Learning with FMUs (differentiation over FMUs)
37+
- [*FMIFlux.jl*](https://github.com/ThummeTo/FMIFlux.jl): Machine Learning with FMUs
3838
- [*FMIZoo.jl*](https://github.com/ThummeTo/FMIZoo.jl): A collection of testing and example FMUs
3939

4040
## What Platforms are supported?
41-
[*FMICore.jl*](https://github.com/ThummeTo/FMICore.jl) is tested (and testing) under Julia Versions *v1.6 LTS* and *v1 latest* on Windows *latest*, Ubuntu *latest* and MacOS *latest*. `x64` and `x86` architectures are tested.
41+
[*FMICore.jl*](https://github.com/ThummeTo/FMICore.jl) is tested (and testing) under Julia Versions *v1.6 LTS* and *v1 latest* on Windows *latest* (`x64` and `x86`) and Ubuntu *latest* (`x64`). MacOS is not CI-tested but should work with Mac-FMUs.
4242

4343
## How to cite?
4444
Tobias Thummerer, Lars Mikelsons and Josef Kircher. 2021. **NeuralFMU: towards structural integration of FMUs into neural networks.** Martin Sjölund, Lena Buffoni, Adrian Pop and Lennart Ochel (Ed.). Proceedings of 14th Modelica Conference 2021, Linköping, Sweden, September 20-24, 2021. Linköping University Electronic Press, Linköping (Linköping Electronic Conference Proceedings ; 181), 297-306. [DOI: 10.3384/ecp21181297](https://doi.org/10.3384/ecp21181297)

src/FMI2/cconst.jl

+20-37
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ const fmi2Component = Ptr{Cvoid}
3232
const fmi2ComponentEnvironment = Ptr{Cvoid}
3333
export fmi2Char, fmi2String, fmi2Boolean, fmi2Real, fmi2Integer, fmi2Byte, fmi2ValueReference, fmi2FMUstate, fmi2Component, fmi2ComponentEnvironment
3434

35-
# wildcards for how a user can pass a fmi2ValueReference
36-
fmi2ValueReferenceFormat = Union{Nothing, String, AbstractArray{String,1}, fmi2ValueReference, AbstractArray{fmi2ValueReference,1}, Int64, AbstractArray{Int64,1}, Symbol}
37-
export fmi2ValueReferenceFormat
38-
39-
const fmi2Status = Cuint
40-
const fmi2StatusOK = Cuint(0)
41-
const fmi2StatusWarning = Cuint(1)
42-
const fmi2StatusDiscard = Cuint(2)
43-
const fmi2StatusError = Cuint(3)
44-
const fmi2StatusFatal = Cuint(4)
45-
const fmi2StatusPending = Cuint(5)
46-
4735
"""
4836
Source: FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
4937
@@ -60,7 +48,13 @@ This can be done if the capability flag canGetAndSetFMUstate is true and fmi2Get
6048
- fmi2Fatal – the model computations are irreparably corrupted for all FMU instances. [For example, due to a run-time exception such as access violation or integer division by zero during the execution of an fmi function]. Function “logger” was called in the FMU (see below), and it is expected that this function has shown the prepared information message to the user. It is not possible to call any other function for any of the FMU instances.
6149
- fmi2Pending – this status is returned only from the co-simulation interface, if the slave executes the function in an asynchronous way. That means the slave starts to compute but returns immediately. The master has to call fmi2GetStatus(..., fmi2DoStepStatus) to determine if the slave has finished the computation. Can be returned only by fmi2DoStep and by fmi2GetStatus (see section 4.2.3).
6250
"""
63-
fmi2Status, fmi2StatusOK, fmi2StatusWarning, fmi2StatusDiscard, fmi2StatusError, fmi2StatusFatal, fmi2StatusPending
51+
const fmi2Status = Cuint
52+
const fmi2StatusOK = Cuint(0)
53+
const fmi2StatusWarning = Cuint(1)
54+
const fmi2StatusDiscard = Cuint(2)
55+
const fmi2StatusError = Cuint(3)
56+
const fmi2StatusFatal = Cuint(4)
57+
const fmi2StatusPending = Cuint(5)
6458
export fmi2Status, fmi2StatusOK, fmi2StatusWarning, fmi2StatusDiscard, fmi2StatusError, fmi2StatusFatal, fmi2StatusPending
6559

6660
"""
@@ -126,17 +120,24 @@ const fmi2InitialApprox = Cuint(1)
126120
const fmi2InitialCalculated = Cuint(2)
127121
export fmi2Initial, fmi2InitialExact, fmi2InitialApprox, fmi2InitialCalculated
128122

129-
const fmi2True = fmi2Boolean(true)
130-
const fmi2False = fmi2Boolean(false)
131123
"""
132124
Source: FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
133125
134126
To simplify porting, no C types are used in the function interfaces, but the alias types are defined in this section.
135127
All definitions in this section are provided in the header file “fmi2TypesPlatform.h”.
136128
"""
137-
fmi2True, fmi2False
129+
const fmi2True = fmi2Boolean(true)
130+
const fmi2False = fmi2Boolean(false)
138131
export fmi2True, fmi2False
139132

133+
"""
134+
ToDo
135+
"""
136+
const fmi2VariableNamingConvention = Cuint
137+
const fmi2VariableNamingConventionFlat = Cuint(0)
138+
const fmi2VariableNamingConventionStructured = Cuint(1)
139+
export fmi2VariableNamingConvention, fmi2VariableNamingConventionFlat, fmi2VariableNamingConventionStructured
140+
140141
"""
141142
Source: FMISpec2.0.2[p.19]: 2.1.5 Creation, Destruction and Logging of FMU Instances
142143
@@ -161,14 +162,14 @@ const fmi2StatusKindLastSuccessfulTime = Cuint(2)
161162
const fmi2StatusKindTerminated = Cuint(3)
162163
export fmi2StatusKind, fmi2StatusKindDoStepStatus, fmi2StatusKindPendingStatus, fmi2StatusKindLastSuccessfulTime, fmi2StatusKindTerminated
163164

164-
# Custom helper, not part of the FMI-Spec.
165165
"""
166166
Types of dependency:
167167
168168
- `fmi2DependencyKindDependent`: no particular structure, f(v)
169169
- `fmi2DependencyKindConstant`: constant factor, c*v (for Real valued variables only)
170170
- `fmi2DependencyKindFixed`: tunable factor, p*v (for Real valued variables only)
171-
- `fmi2DependencyKindDependent`: discrete factor, d*v (for Real valued variables only)
171+
- `fmi2DependencyKindTunable` [ToDo]
172+
- `fmi2DependencyKindDiscrete` [ToDo]
172173
173174
Source: FMI2.0.3 Spec for fmi2VariableDependency [p.60]
174175
"""
@@ -178,22 +179,4 @@ const fmi2DependencyKindConstant = Cuint(1)
178179
const fmi2DependencyKindFixed = Cuint(2)
179180
const fmi2DependencyKindTunable = Cuint(3)
180181
const fmi2DependencyKindDiscrete = Cuint(4)
181-
export fmi2DependencyKind, fmi2DependencyKindDependent, fmi2DependencyKindConstant, fmi2DependencyKindFixed, fmi2DependencyKindTunable, fmi2DependencyKindDiscrete
182-
183-
# Custom helper, not part of the FMI-Spec.
184-
const fmi2VariableNamingConvention = Cuint
185-
const fmi2VariableNamingConventionFlat = Cuint(0)
186-
const fmi2VariableNamingConventionStructured = Cuint(1)
187-
export fmi2VariableNamingConvention, fmi2VariableNamingConventionFlat, fmi2VariableNamingConventionStructured
188-
189-
# this is a custom type to catch the internal mode of the component
190-
const fmi2ComponentState = Cuint
191-
const fmi2ComponentStateInstantiated = Cuint(0) # after instantiation
192-
const fmi2ComponentStateInitializationMode = Cuint(1) # after finishing initialization
193-
const fmi2ComponentStateEventMode = Cuint(2)
194-
const fmi2ComponentStateContinuousTimeMode = Cuint(3)
195-
const fmi2ComponentStateTerminated = Cuint(4)
196-
const fmi2ComponentStateError = Cuint(5)
197-
const fmi2ComponentStateFatal = Cuint(6)
198-
export fmi2ComponentState, fmi2ComponentStateInstantiated, fmi2ComponentStateInitializationMode, fmi2ComponentStateEventMode, fmi2ComponentStateContinuousTimeMode, fmi2ComponentStateTerminated, fmi2ComponentStateError, fmi2ComponentStateFatal
199-
182+
export fmi2DependencyKind, fmi2DependencyKindDependent, fmi2DependencyKindConstant, fmi2DependencyKindFixed, fmi2DependencyKindTunable, fmi2DependencyKindDiscrete

src/FMI2/cfunc.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ If a null pointer is provided for “c”, the function call is ignored (does no
3535
3636
Removes the component from the FMUs component list.
3737
"""
38-
function fmi2FreeInstance!(cfunc::Ptr{Cvoid}, c::fmi2Component)
38+
function fmi2FreeInstance(cfunc::Ptr{Cvoid}, c::fmi2Component)
3939

4040
ccall(cfunc, Cvoid, (fmi2Component,), c)
4141
@debug "fmi2FreeInstance(c: $(c)) → [nothing]"
4242
return nothing
4343
end
44-
export fmi2FreeInstance!
44+
export fmi2FreeInstance
4545

4646
"""
4747
Source: FMISpec2.0.2[p.22]: 2.1.4 Inquire Platform and Version Number of Header Files
@@ -320,15 +320,15 @@ Source: FMISpec2.0.2[p.26]: 2.1.8 Getting and setting the complete FMU state
320320
321321
fmi2FreeFMUstate frees all memory and other resources allocated with the fmi2GetFMUstate call for this FMUstate.
322322
"""
323-
function fmi2FreeFMUstate!(cfunc::Ptr{Cvoid}, c::fmi2Component, FMUstate::Ref{fmi2FMUstate})
323+
function fmi2FreeFMUstate(cfunc::Ptr{Cvoid}, c::fmi2Component, FMUstate::Ref{fmi2FMUstate})
324324
status = ccall(cfunc,
325325
fmi2Status,
326326
(fmi2Component, Ptr{fmi2FMUstate}),
327327
c, FMUstate)
328-
@debug "fmi2FreeFMUstate!(c: $(c), FMUstate: $(FMUstate)) → $(status)"
328+
@debug "fmi2FreeFMUstate(c: $(c), FMUstate: $(FMUstate)) → $(status)"
329329
return status
330330
end
331-
export fmi2FreeFMUstate!
331+
export fmi2FreeFMUstate
332332

333333
"""
334334
Source: FMISpec2.0.2[p.26]: 2.1.8 Getting and Setting the Complete FMU State

src/FMI2/cfunc_unload.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,5 @@ function unload_fmi2GetNominalsOfContinuousStates(_component::fmi2Component, _x_
153153
return fmi2StatusFatal
154154
end
155155

156-
# ToDo: Add CS functions!
156+
# ToDo: Add CS functions!
157+
# ToDo: This shoudl be doable with a macro like @unloaded_version fmi2GetContinuousStates

0 commit comments

Comments
 (0)