diff --git a/.github/workflows/Formatter.yml b/.github/workflows/Formatter.yml new file mode 100644 index 0000000..0155d9b --- /dev/null +++ b/.github/workflows/Formatter.yml @@ -0,0 +1,14 @@ +name: Format suggestions +on: + pull_request: + # this argument is not required if you don't use the `suggestion-label` input + types: [ opened, reopened, synchronize, labeled, unlabeled ] +jobs: + code-style: + runs-on: ubuntu-latest + steps: + - uses: julia-actions/julia-format@v3 + with: + version: '1' # Set `version` to '1.0.54' if you need to use JuliaFormatter.jl v1.0.54 (default: '1') + suggestion-label: 'format-suggest' # leave this unset or empty to show suggestions for all PRs + diff --git a/.gitignore b/.gitignore index ca74586..1e9a7d5 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ Manifest.toml # Custom .vscode +tmp/ diff --git a/Project.toml b/Project.toml index d3e1bb5..4ef1791 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FMICore" uuid = "8af89139-c281-408e-bce2-3005eb87462f" authors = ["TT ", "LM ", "JK "] -version = "1.0.1" +version = "1.0.2" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/FMI2/cconst.jl b/src/FMI2/cconst.jl index 13f16bd..d732d81 100644 --- a/src/FMI2/cconst.jl +++ b/src/FMI2/cconst.jl @@ -30,7 +30,16 @@ Source: FMI2.0.3 Spec [p.17]; See also section 2.1.8 const fmi2FMUstate = Ptr{Cvoid} const fmi2Component = Ptr{Cvoid} const fmi2ComponentEnvironment = Ptr{Cvoid} -export fmi2Char, fmi2String, fmi2Boolean, fmi2Real, fmi2Integer, fmi2Byte, fmi2ValueReference, fmi2FMUstate, fmi2Component, fmi2ComponentEnvironment +export fmi2Char, + fmi2String, + fmi2Boolean, + fmi2Real, + fmi2Integer, + fmi2Byte, + fmi2ValueReference, + fmi2FMUstate, + fmi2Component, + fmi2ComponentEnvironment """ Source: FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions @@ -49,13 +58,19 @@ This can be done if the capability flag canGetAndSetFMUstate is true and fmi2Get - 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). """ const fmi2Status = Cuint -const fmi2StatusOK = Cuint(0) +const fmi2StatusOK = Cuint(0) const fmi2StatusWarning = Cuint(1) const fmi2StatusDiscard = Cuint(2) -const fmi2StatusError = Cuint(3) -const fmi2StatusFatal = Cuint(4) +const fmi2StatusError = Cuint(3) +const fmi2StatusFatal = Cuint(4) const fmi2StatusPending = Cuint(5) -export fmi2Status, fmi2StatusOK, fmi2StatusWarning, fmi2StatusDiscard, fmi2StatusError, fmi2StatusFatal, fmi2StatusPending +export fmi2Status, + fmi2StatusOK, + fmi2StatusWarning, + fmi2StatusDiscard, + fmi2StatusError, + fmi2StatusFatal, + fmi2StatusPending """ Source: FMISpec2.0.2[p.48]: 2.2.7 Definition of Model Variables (ModelVariables) @@ -73,13 +88,19 @@ The default of causality is “local”. A continuous-time state must have causa Added prefix "fmi2" to help with redefinition of constans in enums. """ const fmi2Causality = Cuint -const fmi2CausalityParameter = Cuint(0) -const fmi2CausalityCalculatedParameter = Cuint(1) -const fmi2CausalityInput = Cuint(2) -const fmi2CausalityOutput = Cuint(3) -const fmi2CausalityLocal = Cuint(4) -const fmi2CausalityIndependent = Cuint(5) -export fmi2Causality, fmi2CausalityParameter, fmi2CausalityCalculatedParameter, fmi2CausalityInput, fmi2CausalityOutput, fmi2CausalityLocal, fmi2CausalityIndependent +const fmi2CausalityParameter = Cuint(0) +const fmi2CausalityCalculatedParameter = Cuint(1) +const fmi2CausalityInput = Cuint(2) +const fmi2CausalityOutput = Cuint(3) +const fmi2CausalityLocal = Cuint(4) +const fmi2CausalityIndependent = Cuint(5) +export fmi2Causality, + fmi2CausalityParameter, + fmi2CausalityCalculatedParameter, + fmi2CausalityInput, + fmi2CausalityOutput, + fmi2CausalityLocal, + fmi2CausalityIndependent """ Source: FMISpec2.0.2[p.49]: 2.2.7 Definition of Model Variables (ModelVariables) @@ -95,12 +116,17 @@ The default is “continuous”. Added prefix "fmi2" to help with redefinition of constans in enums. """ const fmi2Variability = Cuint -const fmi2VariabilityConstant = Cuint(0) -const fmi2VariabilityFixed = Cuint(1) -const fmi2VariabilityTunable = Cuint(2) -const fmi2VariabilityDiscrete = Cuint(3) +const fmi2VariabilityConstant = Cuint(0) +const fmi2VariabilityFixed = Cuint(1) +const fmi2VariabilityTunable = Cuint(2) +const fmi2VariabilityDiscrete = Cuint(3) const fmi2VariabilityContinuous = Cuint(4) -export fmi2Variability, fmi2VariabilityConstant, fmi2VariabilityFixed, fmi2VariabilityTunable, fmi2VariabilityDiscrete, fmi2VariabilityContinuous +export fmi2Variability, + fmi2VariabilityConstant, + fmi2VariabilityFixed, + fmi2VariabilityTunable, + fmi2VariabilityDiscrete, + fmi2VariabilityContinuous """ Source: FMISpec2.0.2[p.48]: 2.2.7 Definition of Model Variables (ModelVariables) @@ -115,8 +141,8 @@ If fmiSetXXX is not called on a variable with causality = ″input″, then the Added prefix "fmi2" to help with redefinition of constans in enums. """ const fmi2Initial = Cuint -const fmi2InitialExact = Cuint(0) -const fmi2InitialApprox = Cuint(1) +const fmi2InitialExact = Cuint(0) +const fmi2InitialApprox = Cuint(1) const fmi2InitialCalculated = Cuint(2) export fmi2Initial, fmi2InitialExact, fmi2InitialApprox, fmi2InitialCalculated @@ -136,7 +162,8 @@ ToDo const fmi2VariableNamingConvention = Cuint const fmi2VariableNamingConventionFlat = Cuint(0) const fmi2VariableNamingConventionStructured = Cuint(1) -export fmi2VariableNamingConvention, fmi2VariableNamingConventionFlat, fmi2VariableNamingConventionStructured +export fmi2VariableNamingConvention, + fmi2VariableNamingConventionFlat, fmi2VariableNamingConventionStructured """ Source: FMISpec2.0.2[p.19]: 2.1.5 Creation, Destruction and Logging of FMU Instances @@ -147,7 +174,7 @@ Argument fmuType defines the type of the FMU: """ const fmi2Type = Cuint const fmi2TypeModelExchange = Cuint(0) -const fmi2TypeCoSimulation = Cuint(1) +const fmi2TypeCoSimulation = Cuint(1) export fmi2Type, fmi2TypeModelExchange, fmi2TypeCoSimulation """ @@ -156,11 +183,15 @@ Source: FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave CoSimulation specific Enum representing state of FMU after fmi2DoStep returned fmi2Pending. """ const fmi2StatusKind = Cuint -const fmi2StatusKindDoStepStatus = Cuint(0) -const fmi2StatusKindPendingStatus = Cuint(1) -const fmi2StatusKindLastSuccessfulTime = Cuint(2) -const fmi2StatusKindTerminated = Cuint(3) -export fmi2StatusKind, fmi2StatusKindDoStepStatus, fmi2StatusKindPendingStatus, fmi2StatusKindLastSuccessfulTime, fmi2StatusKindTerminated +const fmi2StatusKindDoStepStatus = Cuint(0) +const fmi2StatusKindPendingStatus = Cuint(1) +const fmi2StatusKindLastSuccessfulTime = Cuint(2) +const fmi2StatusKindTerminated = Cuint(3) +export fmi2StatusKind, + fmi2StatusKindDoStepStatus, + fmi2StatusKindPendingStatus, + fmi2StatusKindLastSuccessfulTime, + fmi2StatusKindTerminated """ Types of dependency: @@ -173,10 +204,15 @@ Types of dependency: Source: FMI2.0.3 Spec for fmi2VariableDependency [p.60] """ -const fmi2DependencyKind = Cuint -const fmi2DependencyKindDependent = Cuint(0) -const fmi2DependencyKindConstant = Cuint(1) -const fmi2DependencyKindFixed = Cuint(2) -const fmi2DependencyKindTunable = Cuint(3) -const fmi2DependencyKindDiscrete = Cuint(4) -export fmi2DependencyKind, fmi2DependencyKindDependent, fmi2DependencyKindConstant, fmi2DependencyKindFixed, fmi2DependencyKindTunable, fmi2DependencyKindDiscrete \ No newline at end of file +const fmi2DependencyKind = Cuint +const fmi2DependencyKindDependent = Cuint(0) +const fmi2DependencyKindConstant = Cuint(1) +const fmi2DependencyKindFixed = Cuint(2) +const fmi2DependencyKindTunable = Cuint(3) +const fmi2DependencyKindDiscrete = Cuint(4) +export fmi2DependencyKind, + fmi2DependencyKindDependent, + fmi2DependencyKindConstant, + fmi2DependencyKindFixed, + fmi2DependencyKindTunable, + fmi2DependencyKindDiscrete diff --git a/src/FMI2/cfunc.jl b/src/FMI2/cfunc.jl index 66c8bee..b1eb004 100644 --- a/src/FMI2/cfunc.jl +++ b/src/FMI2/cfunc.jl @@ -8,22 +8,40 @@ Source: FMISpec2.0.2[p.19]: 2.1.5 Creation, Destruction and Logging of FMU Insta The function returns a new instance of an FMU. """ -function fmi2Instantiate(cfunc::Ptr{Cvoid}, - instanceName::fmi2String, - fmuType::fmi2Type, - fmuGUID::fmi2String, - fmuResourceLocation::fmi2String, - functions::Ptr{fmi2CallbackFunctions}, - visible::fmi2Boolean, - loggingOn::fmi2Boolean) - - status = ccall(cfunc, - Ptr{Cvoid}, - (fmi2String, fmi2Type, fmi2String, fmi2String, Ptr{Cvoid}, fmi2Boolean, fmi2Boolean), - instanceName, fmuType, fmuGUID, fmuResourceLocation, functions, visible, loggingOn) - - @debug "fmi2Instantiate(instanceName: $(instanceName), fmuType: $(fmuType), fmuGUID: $(fmuGUID), fmuResourceLocation: $(fmuResourceLocation), functions: $(functions), visible: $(visible), loggingOn: $(loggingOn)) → $(status)" - return status +function fmi2Instantiate( + cfunc::Ptr{Cvoid}, + instanceName::fmi2String, + fmuType::fmi2Type, + fmuGUID::fmi2String, + fmuResourceLocation::fmi2String, + functions::Ptr{fmi2CallbackFunctions}, + visible::fmi2Boolean, + loggingOn::fmi2Boolean, +)::fmi2Component + + comp = ccall( + cfunc, + fmi2Component, + ( + fmi2String, + fmi2Type, + fmi2String, + fmi2String, + Ptr{Cvoid}, + fmi2Boolean, + fmi2Boolean, + ), + instanceName, + fmuType, + fmuGUID, + fmuResourceLocation, + functions, + visible, + loggingOn, + ) + + @debug "fmi2Instantiate(instanceName: $(instanceName), fmuType: $(fmuType), fmuGUID: $(fmuGUID), fmuResourceLocation: $(fmuResourceLocation), functions: $(functions), visible: $(visible), loggingOn: $(loggingOn)) → $(comp)" + return comp end export fmi2Instantiate @@ -35,7 +53,7 @@ If a null pointer is provided for “c”, the function call is ignored (does no Removes the component from the FMUs component list. """ -function fmi2FreeInstance(cfunc::Ptr{Cvoid}, c::fmi2Component) +function fmi2FreeInstance(cfunc::Ptr{Cvoid}, c::fmi2Component)::Nothing ccall(cfunc, Cvoid, (fmi2Component,), c) @debug "fmi2FreeInstance(c: $(c)) → [nothing]" @@ -49,7 +67,7 @@ Source: FMISpec2.0.2[p.22]: 2.1.4 Inquire Platform and Version Number of Header Returns the string to uniquely identify the “fmi2TypesPlatform.h” header file used for compilation of the functions of the FMU. The standard header file, as documented in this specification, has fmi2TypesPlatform set to “default” (so this function usually returns “default”). """ -function fmi2GetTypesPlatform(cfunc::Ptr{Cvoid}) +function fmi2GetTypesPlatform(cfunc::Ptr{Cvoid})::fmi2String str = ccall(cfunc, fmi2String, ()) @debug "fmi2GetTypesPlatform() → $(str)" return str @@ -61,7 +79,7 @@ Source: FMISpec2.0.2[p.22]: 2.1.4 Inquire Platform and Version Number of Header Returns the version of the “fmi2Functions.h” header file which was used to compile the functions of the FMU. The function returns “fmiVersion” which is defined in this header file. The standard header file as documented in this specification has version “2.0” """ -function fmi2GetVersion(cfunc::Ptr{Cvoid}) +function fmi2GetVersion(cfunc::Ptr{Cvoid})::fmi2String str = ccall(cfunc, fmi2String, ()) @debug "fmi2GetVersion() → $(str)" return str @@ -73,11 +91,22 @@ Source: FMISpec2.0.2[p.22]: 2.1.5 Creation, Destruction and Logging of FMU Insta The function controls debug logging that is output via the logger function callback. If loggingOn = fmi2True, debug logging is enabled, otherwise it is switched off. """ -function fmi2SetDebugLogging(cfunc::Ptr{Cvoid}, c::fmi2Component, logginOn::fmi2Boolean, nCategories::Csize_t, categories::Union{Ptr{fmi2String}, AbstractArray{fmi2String}}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2Boolean, Csize_t, Ptr{fmi2String}), - c, logginOn, nCategories, categories) +function fmi2SetDebugLogging( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + logginOn::fmi2Boolean, + nCategories::Csize_t, + categories::Union{Ptr{fmi2String},AbstractArray{fmi2String}}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, fmi2Boolean, Csize_t, Ptr{fmi2String}), + c, + logginOn, + nCategories, + categories, + ) @debug "fmi2SetDebugLogging(c: $(c), logginOn: $(loggingOn), nCategories: $(nCategories), categories: $(categories)) → $(status)" return status end @@ -88,18 +117,27 @@ Source: FMISpec2.0.2[p.23]: 2.1.6 Initialization, Termination, and Resetting an Informs the FMU to setup the experiment. This function must be called after fmi2Instantiate and before fmi2EnterInitializationMode is called.The function controls debug logging that is output via the logger function callback. If loggingOn = fmi2True, debug logging is enabled, otherwise it is switched off. """ -function fmi2SetupExperiment(cfunc::Ptr{Cvoid}, - c::fmi2Component, - toleranceDefined::fmi2Boolean, - tolerance::fmi2Real, - startTime::fmi2Real, - stopTimeDefined::fmi2Boolean, - stopTime::fmi2Real) - - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2Boolean, fmi2Real, fmi2Real, fmi2Boolean, fmi2Real), - c, toleranceDefined, tolerance, startTime, stopTimeDefined, stopTime) +function fmi2SetupExperiment( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + toleranceDefined::fmi2Boolean, + tolerance::fmi2Real, + startTime::fmi2Real, + stopTimeDefined::fmi2Boolean, + stopTime::fmi2Real, +)::fmi2Status + + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, fmi2Boolean, fmi2Real, fmi2Real, fmi2Boolean, fmi2Real), + c, + toleranceDefined, + tolerance, + startTime, + stopTimeDefined, + stopTime, + ) @debug "fmi2SetupExperiment(c: $(c), toleranceDefined: $(toleranceDefined), tolerance: $(tolerance), startTime: $(startTime), stopTimeDefined: $(stopTimeDefined), stopTime: $(stopTime)) → $(status)" return status end @@ -111,11 +149,8 @@ Source: FMISpec2.0.2[p.23]: 2.1.6 Initialization, Termination, and Resetting an Informs the FMU to enter Initialization Mode. Before calling this function, all variables with attribute can be set with the “fmi2SetXXX” functions (the ScalarVariable attributes are defined in the Model Description File, see section 2.2.7). Setting other variables is not allowed. Furthermore, fmi2SetupExperiment must be called at least once before calling fmi2EnterInitializationMode, in order that startTime is defined. """ function fmi2EnterInitializationMode(cfunc::Ptr{Cvoid}, c::fmi2Component) - status = ccall(cfunc, - fmi2Status, - (fmi2Component,), - c) - @debug "fmi2EnterInitializationMode(c: $(c)) → $(status)" + status = ccall(cfunc, fmi2Status, (fmi2Component,), c)::fmi2Status + @debug "fmi2EnterInitializationMode(c: $(c)) → $(status)" return status end export fmi2EnterInitializationMode @@ -126,11 +161,8 @@ Source: FMISpec2.0.2[p.23]: 2.1.6 Initialization, Termination, and Resetting an Informs the FMU to exit Initialization Mode. """ function fmi2ExitInitializationMode(cfunc::Ptr{Cvoid}, c::fmi2Component) - status = ccall(cfunc, - fmi2Status, - (fmi2Component,), - c) - @debug "fmi2ExitInitializationMode(c: $(c)) → $(status)" + status = ccall(cfunc, fmi2Status, (fmi2Component,), c)::fmi2Status + @debug "fmi2ExitInitializationMode(c: $(c)) → $(status)" return status end export fmi2ExitInitializationMode @@ -141,11 +173,8 @@ Source: FMISpec2.0.2[p.24]: 2.1.6 Initialization, Termination, and Resetting an Informs the FMU that the simulation run is terminated. """ function fmi2Terminate(cfunc::Ptr{Cvoid}, c::fmi2Component) - status = ccall(cfunc, - fmi2Status, - (fmi2Component,), - c) - @debug "fmi2Terminate(c: $(c)) → $(status)" + status = ccall(cfunc, fmi2Status, (fmi2Component,), c)::fmi2Status + @debug "fmi2Terminate(c: $(c)) → $(status)" return status end export fmi2Terminate @@ -156,11 +185,8 @@ Source: FMISpec2.0.2[p.24]: 2.1.6 Initialization, Termination, and Resetting an Is called by the environment to reset the FMU after a simulation run. The FMU goes into the same state as if fmi2Instantiate would have been called. """ function fmi2Reset(cfunc::Ptr{Cvoid}, c::fmi2Component) - status = ccall(cfunc, - fmi2Status, - (fmi2Component,), - c) - @debug "fmi2Reset(c: $(c)) → $(status)" + status = ccall(cfunc, fmi2Status, (fmi2Component,), c)::fmi2Status + @debug "fmi2Reset(c: $(c)) → $(status)" return status end export fmi2Reset @@ -170,12 +196,23 @@ Source: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values Functions to get and set values of variables idetified by their valueReference """ -function fmi2GetReal!(cfunc::Ptr{Cvoid}, c::fmi2Component, vr::Union{AbstractArray{fmi2ValueReference}, Ptr{fmi2ValueReference}}, nvr::Csize_t, value::Union{AbstractArray{fmi2Real}, Ptr{fmi2Real}}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Real}), - c, vr, nvr, value) - @debug "fmi2GetReal(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value)) → $(status)" +function fmi2GetReal!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + vr::Union{AbstractArray{fmi2ValueReference},Ptr{fmi2ValueReference}}, + nvr::Csize_t, + value::Union{AbstractArray{fmi2Real},Ptr{fmi2Real}}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Real}), + c, + vr, + nvr, + value, + ) + @debug "fmi2GetReal(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value)) → $(status)" return status end export fmi2GetReal! @@ -185,11 +222,22 @@ Source: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values Functions to get and set values of variables idetified by their valueReference """ -function fmi2SetReal(cfunc::Ptr{Cvoid}, c::fmi2Component, vr::Union{AbstractArray{fmi2ValueReference}, Ptr{fmi2ValueReference}}, nvr::Csize_t, value::Union{AbstractArray{fmi2Real}, Ptr{fmi2Real}}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Real}), - c, vr, nvr, value) +function fmi2SetReal( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + vr::Union{AbstractArray{fmi2ValueReference},Ptr{fmi2ValueReference}}, + nvr::Csize_t, + value::Union{AbstractArray{fmi2Real},Ptr{fmi2Real}}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Real}), + c, + vr, + nvr, + value, + ) @debug "fmi2SetReal(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value))" return status end @@ -200,11 +248,22 @@ Source: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values Functions to get and set values of variables idetified by their valueReference """ -function fmi2GetInteger!(cfunc::Ptr{Cvoid}, c::fmi2Component, vr::Union{AbstractArray{fmi2ValueReference}, Ptr{fmi2ValueReference}}, nvr::Csize_t, value::Union{AbstractArray{fmi2Integer}, Ptr{fmi2Integer}}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Integer}), - c, vr, nvr, value) +function fmi2GetInteger!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + vr::Union{AbstractArray{fmi2ValueReference},Ptr{fmi2ValueReference}}, + nvr::Csize_t, + value::Union{AbstractArray{fmi2Integer},Ptr{fmi2Integer}}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Integer}), + c, + vr, + nvr, + value, + ) @debug "fmi2GetInteger(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value)) → $(status)" return status end @@ -215,11 +274,22 @@ Source: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values Functions to get and set values of variables idetified by their valueReference """ -function fmi2SetInteger(cfunc::Ptr{Cvoid}, c::fmi2Component, vr::Union{AbstractArray{fmi2ValueReference}, Ptr{fmi2ValueReference}}, nvr::Csize_t, value::Union{AbstractArray{fmi2Integer}, Ptr{fmi2Integer}}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Integer}), - c, vr, nvr, value) +function fmi2SetInteger( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + vr::Union{AbstractArray{fmi2ValueReference},Ptr{fmi2ValueReference}}, + nvr::Csize_t, + value::Union{AbstractArray{fmi2Integer},Ptr{fmi2Integer}}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Integer}), + c, + vr, + nvr, + value, + ) @debug "fmi2SetInteger(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value)) → $(status)" return status end @@ -230,11 +300,22 @@ Source: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values Functions to get and set values of variables idetified by their valueReference """ -function fmi2GetBoolean!(cfunc::Ptr{Cvoid}, c::fmi2Component, vr::Union{AbstractArray{fmi2ValueReference}, Ptr{fmi2ValueReference}}, nvr::Csize_t, value::Union{AbstractArray{fmi2Boolean}, Ptr{fmi2Boolean}}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Boolean}), - c, vr, nvr, value) +function fmi2GetBoolean!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + vr::Union{AbstractArray{fmi2ValueReference},Ptr{fmi2ValueReference}}, + nvr::Csize_t, + value::Union{AbstractArray{fmi2Boolean},Ptr{fmi2Boolean}}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Boolean}), + c, + vr, + nvr, + value, + ) @debug "fmi2GetBoolean(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value)) → $(status)" return status end @@ -245,11 +326,22 @@ Source: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values Functions to get and set values of variables idetified by their valueReference """ -function fmi2SetBoolean(cfunc::Ptr{Cvoid}, c::fmi2Component, vr::Union{AbstractArray{fmi2ValueReference}, Ptr{fmi2ValueReference}}, nvr::Csize_t, value::Union{AbstractArray{fmi2Boolean}, Ptr{fmi2Boolean}}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Boolean}), - c, vr, nvr, value) +function fmi2SetBoolean( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + vr::Union{AbstractArray{fmi2ValueReference},Ptr{fmi2ValueReference}}, + nvr::Csize_t, + value::Union{AbstractArray{fmi2Boolean},Ptr{fmi2Boolean}}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Boolean}), + c, + vr, + nvr, + value, + ) @debug "fmi2SetBoolean(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value)) → $(status)" return status end @@ -260,11 +352,22 @@ Source: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values Functions to get and set values of variables idetified by their valueReference """ -function fmi2GetString!(cfunc::Ptr{Cvoid}, c::fmi2Component, vr::Union{AbstractArray{fmi2ValueReference}, Ptr{fmi2ValueReference}}, nvr::Csize_t, value::Union{AbstractArray{fmi2String}, Ptr{fmi2String}}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2String}), - c, vr, nvr, value) +function fmi2GetString!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + vr::Union{AbstractArray{fmi2ValueReference},Ptr{fmi2ValueReference}}, + nvr::Csize_t, + value::Union{AbstractArray{fmi2String},Ptr{fmi2String}}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2String}), + c, + vr, + nvr, + value, + ) @debug "fmi2GetString(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value)) → $(status)" return status end @@ -275,11 +378,22 @@ Source: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values Functions to get and set values of variables idetified by their valueReference """ -function fmi2SetString(cfunc::Ptr{Cvoid}, c::fmi2Component, vr::Union{AbstractArray{fmi2ValueReference}, Ptr{fmi2ValueReference}}, nvr::Csize_t, value::Union{AbstractArray{fmi2String}, Ptr{fmi2String}}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2String}), - c, vr, nvr, value) +function fmi2SetString( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + vr::Union{AbstractArray{fmi2ValueReference},Ptr{fmi2ValueReference}}, + nvr::Csize_t, + value::Union{AbstractArray{fmi2String},Ptr{fmi2String}}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2String}), + c, + vr, + nvr, + value, + ) @debug "fmi2SetString(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value)) → $(status)" return status end @@ -290,11 +404,12 @@ Source: FMISpec2.0.2[p.26]: 2.1.8 Getting and Setting the Complete FMU State fmi2GetFMUstate makes a copy of the internal FMU state and returns a pointer to this copy """ -function fmi2GetFMUstate!(cfunc::Ptr{Cvoid}, c::fmi2Component, FMUstate::Ref{fmi2FMUstate}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2FMUstate}), - c, FMUstate) +function fmi2GetFMUstate!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + FMUstate::Ref{fmi2FMUstate}, +)::fmi2Status + status = ccall(cfunc, fmi2Status, (fmi2Component, Ptr{fmi2FMUstate}), c, FMUstate) @debug "fmi2GetFMUstate!(c: $(c), FMUstate: $(FMUstate)) → $(status)" return status end @@ -305,11 +420,12 @@ Source: FMISpec2.0.2[p.26]: 2.1.8 Getting and Setting the Complete FMU State fmi2SetFMUstate copies the content of the previously copied FMUstate back and uses it as actual new FMU state. """ -function fmi2SetFMUstate(cfunc::Ptr{Cvoid}, c::fmi2Component, FMUstate::fmi2FMUstate) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2FMUstate), - c, FMUstate) +function fmi2SetFMUstate( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + FMUstate::fmi2FMUstate, +)::fmi2Status + status = ccall(cfunc, fmi2Status, (fmi2Component, fmi2FMUstate), c, FMUstate) @debug "fmi2SetFMUstate(c: $(c), FMUstate: $(FMUstate)) → $(status)" return status end @@ -320,11 +436,12 @@ Source: FMISpec2.0.2[p.26]: 2.1.8 Getting and setting the complete FMU state fmi2FreeFMUstate frees all memory and other resources allocated with the fmi2GetFMUstate call for this FMUstate. """ -function fmi2FreeFMUstate(cfunc::Ptr{Cvoid}, c::fmi2Component, FMUstate::Ref{fmi2FMUstate}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2FMUstate}), - c, FMUstate) +function fmi2FreeFMUstate( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + FMUstate::Ref{fmi2FMUstate}, +)::fmi2Status + status = ccall(cfunc, fmi2Status, (fmi2Component, Ptr{fmi2FMUstate}), c, FMUstate) @debug "fmi2FreeFMUstate(c: $(c), FMUstate: $(FMUstate)) → $(status)" return status end @@ -335,11 +452,20 @@ Source: FMISpec2.0.2[p.26]: 2.1.8 Getting and Setting the Complete FMU State fmi2SerializedFMUstateSize returns the size of the byte vector, in order that FMUstate can be stored in it. """ -function fmi2SerializedFMUstateSize!(cfunc::Ptr{Cvoid}, c::fmi2Component, FMUstate::fmi2FMUstate, size::Ref{Csize_t}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2FMUstate, Ptr{Csize_t}), - c, FMUstate, size) +function fmi2SerializedFMUstateSize!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + FMUstate::fmi2FMUstate, + size::Ref{Csize_t}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, fmi2FMUstate, Ptr{Csize_t}), + c, + FMUstate, + size, + ) @debug "fmi2SerializedFMUstateSize(c: $(c), FMUstate: $(FMUstate), size: $(size)) → $(status)" return status end @@ -350,11 +476,22 @@ Source: FMISpec2.0.2[p.26]: 2.1.8 Getting and Setting the Complete FMU State fmi2SerializeFMUstate serializes the data which is referenced by pointer FMUstate and copies this data in to the byte vector serializedState of length size """ -function fmi2SerializeFMUstate!(cfunc::Ptr{Cvoid}, c::fmi2Component, FMUstate::fmi2FMUstate, serialzedState::AbstractArray{fmi2Byte}, size::Csize_t) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2FMUstate, Ptr{fmi2Byte}, Csize_t), - c, FMUstate, serialzedState, size) +function fmi2SerializeFMUstate!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + FMUstate::fmi2FMUstate, + serialzedState::AbstractArray{fmi2Byte}, + size::Csize_t, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, fmi2FMUstate, Ptr{fmi2Byte}, Csize_t), + c, + FMUstate, + serialzedState, + size, + ) @debug "fmi2SerializeFMUstate(c: $(c), FMUstate: $(FMUstate), serialzedState: $(serializedState), size: $(size)) → $(status)" return status end @@ -365,11 +502,22 @@ Source: FMISpec2.0.2[p.26]: 2.1.8 Getting and Setting the Complete FMU State fmi2DeSerializeFMUstate deserializes the byte vector serializedState of length size, constructs a copy of the FMU state and returns FMUstate, the pointer to this copy. """ -function fmi2DeSerializeFMUstate!(cfunc::Ptr{Cvoid}, c::fmi2Component, serializedState::AbstractArray{fmi2Byte}, size::Csize_t, FMUstate::Ref{fmi2FMUstate}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2Byte}, Csize_t, Ptr{fmi2FMUstate}), - c, serializedState, size, FMUstate) +function fmi2DeSerializeFMUstate!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + serializedState::AbstractArray{fmi2Byte}, + size::Csize_t, + FMUstate::Ref{fmi2FMUstate}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2Byte}, Csize_t, Ptr{fmi2FMUstate}), + c, + serializedState, + size, + FMUstate, + ) @debug "fmi2DeSerializeFMUstate(c: $(c), serializedState: $(serializedState), size: $(size), FMUstate: $(FMUstate)) → $(status)" return status end @@ -382,18 +530,36 @@ This function computes the directional derivatives of an FMU. ΔvUnknown = ∂h / ∂vKnown ⋅ ΔvKnown """ -function fmi2GetDirectionalDerivative!(cfunc::Ptr{Cvoid}, - c::fmi2Component, - vUnknown_ref::AbstractArray{fmi2ValueReference}, - nUnknown::Csize_t, - vKnown_ref::AbstractArray{fmi2ValueReference}, - nKnown::Csize_t, - ΔvKnown::AbstractArray{fmi2Real}, - ΔvUnknown::AbstractArray{fmi2Real}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Real}, Ptr{fmi2Real}), - c, vUnknown_ref, nUnknown, vKnown_ref, nKnown, ΔvKnown, ΔvUnknown) +function fmi2GetDirectionalDerivative!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + vUnknown_ref::AbstractArray{fmi2ValueReference}, + nUnknown::Csize_t, + vKnown_ref::AbstractArray{fmi2ValueReference}, + nKnown::Csize_t, + ΔvKnown::AbstractArray{fmi2Real}, + ΔvUnknown::AbstractArray{fmi2Real}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + ( + fmi2Component, + Ptr{fmi2ValueReference}, + Csize_t, + Ptr{fmi2ValueReference}, + Csize_t, + Ptr{fmi2Real}, + Ptr{fmi2Real}, + ), + c, + vUnknown_ref, + nUnknown, + vKnown_ref, + nKnown, + ΔvKnown, + ΔvUnknown, + ) @debug "fmi2GetDirectionalDerivative(c: $(c), vUnknown_ref: $(vUnknown_ref), nUnknown: $(nUnknown), vKnown_ref: $(vKnown_ref), nKnown: $(nKnown), ΔvKnown: $(ΔvKnown), ΔvUnknown: $(ΔvUnknown)) → $(status)" return status end @@ -408,11 +574,24 @@ Sets the n-th time derivative of real input variables. vr defines the value references of the variables the array order specifies the corresponding order of derivation of the variables """ -function fmi2SetRealInputDerivatives(cfunc::Ptr{Cvoid}, c::fmi2Component, vr::AbstractArray{fmi2ValueReference}, nvr::Csize_t, order::AbstractArray{fmi2Integer}, value::AbstractArray{fmi2Real}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Integer}, Ptr{fmi2Real}), - c, vr, nvr, order, value) +function fmi2SetRealInputDerivatives( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + vr::AbstractArray{fmi2ValueReference}, + nvr::Csize_t, + order::AbstractArray{fmi2Integer}, + value::AbstractArray{fmi2Real}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Integer}, Ptr{fmi2Real}), + c, + vr, + nvr, + order, + value, + ) @debug "fmi2SetRealInputDerivatives(c: $(c), vr: $(vr), nvr: $(nvr), order: $(order), value: $(value)) → $(status)" return status end @@ -425,11 +604,24 @@ Retrieves the n-th derivative of output values. vr defines the value references of the variables the array order specifies the corresponding order of derivation of the variables """ -function fmi2GetRealOutputDerivatives!(cfunc::Ptr{Cvoid}, c::fmi2Component, vr::AbstractArray{fmi2ValueReference}, nvr::Csize_t, order::AbstractArray{fmi2Integer}, value::AbstractArray{fmi2Real}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Integer}, Ptr{fmi2Real}), - c, vr, nvr, order, value) +function fmi2GetRealOutputDerivatives!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + vr::AbstractArray{fmi2ValueReference}, + nvr::Csize_t, + order::AbstractArray{fmi2Integer}, + value::AbstractArray{fmi2Real}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2ValueReference}, Csize_t, Ptr{fmi2Integer}, Ptr{fmi2Real}), + c, + vr, + nvr, + order, + value, + ) @debug "fmi2GetRealOutputDerivatives(c: $(c), vr: $(vr), nvr: $(nvr), order: $(order), value: $(value)) → $(status)" return status end @@ -440,10 +632,22 @@ Source: FMISpec2.0.2[p.104]: 4.2.2 Computation The computation of a time step is started. """ -function fmi2DoStep(cfunc::Ptr{Cvoid}, c::fmi2Component, currentCommunicationPoint::fmi2Real, communicationStepSize::fmi2Real, noSetFMUStatePriorToCurrentPoint::fmi2Boolean) - status = ccall(cfunc, fmi2Status, - (fmi2Component, fmi2Real, fmi2Real, fmi2Boolean), - c, currentCommunicationPoint, communicationStepSize, noSetFMUStatePriorToCurrentPoint) +function fmi2DoStep( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + currentCommunicationPoint::fmi2Real, + communicationStepSize::fmi2Real, + noSetFMUStatePriorToCurrentPoint::fmi2Boolean, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, fmi2Real, fmi2Real, fmi2Boolean), + c, + currentCommunicationPoint, + communicationStepSize, + noSetFMUStatePriorToCurrentPoint, + ) @debug "fmi2DoStep(c: $(c), currentCommunicationPoint: $(currentCommunicationPoint), communicationStepSize: $(communicationStepSize), noSetFMUStatePriorToCurrentPoint: $(noSetFMUStatePriorToCurrentPoint)) → $(status)" return status end @@ -454,11 +658,8 @@ Source: FMISpec2.0.2[p.105]: 4.2.2 Computation Can be called if fmi2DoStep returned fmi2Pending in order to stop the current asynchronous execution. """ -function fmi2CancelStep(cfunc::Ptr{Cvoid}, c::fmi2Component) - status = ccall(cfunc, - fmi2Status, - (fmi2Component,), - c) +function fmi2CancelStep(cfunc::Ptr{Cvoid}, c::fmi2Component)::fmi2Status + status = ccall(cfunc, fmi2Status, (fmi2Component,), c) @debug "fmi2CancelStep(c: $(c)) → $(status)" return status end @@ -469,11 +670,20 @@ Source: FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind. """ -function fmi2GetStatus!(cfunc::Ptr{Cvoid}, c::fmi2Component, s::fmi2StatusKind, value::Ptr{fmi2Status}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2StatusKind, Ptr{fmi2Status}), - c, s, value) +function fmi2GetStatus!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + s::fmi2StatusKind, + value::Ptr{fmi2Status}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, fmi2StatusKind, Ptr{fmi2Status}), + c, + s, + value, + ) @debug "fmi2GetStatus(c: $(c), s: $(s), value: $(value)) → $(status)" return status end @@ -484,11 +694,20 @@ Source: FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind. """ -function fmi2GetRealStatus!(cfunc::Ptr{Cvoid}, c::fmi2Component, s::fmi2StatusKind, value::Ptr{fmi2Real}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2StatusKind, Ptr{fmi2Real}), - c, s, value) +function fmi2GetRealStatus!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + s::fmi2StatusKind, + value::Ptr{fmi2Real}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, fmi2StatusKind, Ptr{fmi2Real}), + c, + s, + value, + ) @debug "fmi2GetRealStatus(c: $(c), s: $(s), value: $(value)) → $(status)" return status end @@ -499,11 +718,20 @@ Source: FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind. """ -function fmi2GetIntegerStatus!(cfunc::Ptr{Cvoid}, c::fmi2Component, s::fmi2StatusKind, value::Ptr{fmi2Integer}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2StatusKind, Ptr{fmi2Integer}), - c, s, value) +function fmi2GetIntegerStatus!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + s::fmi2StatusKind, + value::Ptr{fmi2Integer}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, fmi2StatusKind, Ptr{fmi2Integer}), + c, + s, + value, + ) @debug "fmi2GetIntegerStatus(c: $(c), s: $(s), value: $(value)) → $(status)" return status end @@ -514,11 +742,20 @@ Source: FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind. """ -function fmi2GetBooleanStatus!(cfunc::Ptr{Cvoid}, c::fmi2Component, s::fmi2StatusKind, value::Ptr{fmi2Boolean}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2StatusKind, Ptr{fmi2Boolean}), - c, s, value) +function fmi2GetBooleanStatus!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + s::fmi2StatusKind, + value::Ptr{fmi2Boolean}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, fmi2StatusKind, Ptr{fmi2Boolean}), + c, + s, + value, + ) @debug "fmi2GetBooleanStatus(c: $(c), s: $(s), value: $(value)) → $(status)" return status end @@ -529,11 +766,20 @@ Source: FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind. """ -function fmi2GetStringStatus!(cfunc::Ptr{Cvoid}, c::fmi2Component, s::fmi2StatusKind, value::Ptr{fmi2String}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2StatusKind, Ptr{fmi2String}), - c, s, value) +function fmi2GetStringStatus!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + s::fmi2StatusKind, + value::Ptr{fmi2String}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, fmi2StatusKind, Ptr{fmi2String}), + c, + s, + value, + ) @debug "fmi2GetStringStatus(c: $(c), s: $(s), value: $(value)) → $(status)" return status end @@ -546,11 +792,8 @@ Source: FMISpec2.0.2[p.83]: 3.2.1 Providing Independent Variables and Re-initial Set a new time instant and re-initialize caching of variables that depend on time, provided the newly provided time value is different to the previously set time value (variables that depend solely on constants or parameters need not to be newly computed in the sequel, but the previously computed values can be reused). """ -function fmi2SetTime(cfunc::Ptr{Cvoid}, c::fmi2Component, time::fmi2Real) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2Real), - c, time) +function fmi2SetTime(cfunc::Ptr{Cvoid}, c::fmi2Component, time::fmi2Real)::fmi2Status + status = ccall(cfunc, fmi2Status, (fmi2Component, fmi2Real), c, time) @debug "fmi2SetTime(c: $(c), time: $(time)) → $(status)" return status end @@ -561,11 +804,13 @@ Source: FMISpec2.0.2[p.83]: 3.2.1 Providing Independent Variables and Re-initial Set a new (continuous) state vector and re-initialize caching of variables that depend on the states. Argument nx is the length of vector x and is provided for checking purposes """ -function fmi2SetContinuousStates(cfunc::Ptr{Cvoid}, c::fmi2Component, x::Union{AbstractArray{fmi2Real}, Ptr{fmi2Real}}, nx::Csize_t) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2Real}, Csize_t), - c, x, nx) +function fmi2SetContinuousStates( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + x::Union{AbstractArray{fmi2Real},Ptr{fmi2Real}}, + nx::Csize_t, +)::fmi2Status + status = ccall(cfunc, fmi2Status, (fmi2Component, Ptr{fmi2Real}, Csize_t), c, x, nx) @debug "fmi2SetContinuousStates(c: $(c), x: $(x), nx: $(nx)) → $(status)" return status end @@ -576,11 +821,8 @@ Source: FMISpec2.0.2[p.84]: 3.2.2 Evaluation of Model Equations The model enters Event Mode from the Continuous-Time Mode and discrete-time equations may become active (and relations are not “frozen”). """ -function fmi2EnterEventMode(cfunc::Ptr{Cvoid}, c::fmi2Component) - status = ccall(cfunc, - fmi2Status, - (fmi2Component,), - c) +function fmi2EnterEventMode(cfunc::Ptr{Cvoid}, c::fmi2Component)::fmi2Status + status = ccall(cfunc, fmi2Status, (fmi2Component,), c) @debug "fmi2EnterEventMode(c: $(c)) → $(status)" return status end @@ -591,11 +833,12 @@ Source: FMISpec2.0.2[p.84]: 3.2.2 Evaluation of Model Equations The FMU is in Event Mode and the super dense time is incremented by this call. """ -function fmi2NewDiscreteStates!(cfunc::Ptr{Cvoid}, c::fmi2Component, eventInfo::Ptr{fmi2EventInfo}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2EventInfo}), - c, eventInfo) +function fmi2NewDiscreteStates!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + eventInfo::Ptr{fmi2EventInfo}, +)::fmi2Status + status = ccall(cfunc, fmi2Status, (fmi2Component, Ptr{fmi2EventInfo}), c, eventInfo) @debug "fmi2NewDiscreteStates(c: $(c), eventInfo: $(eventInfo)) → $(status)" return status end @@ -607,11 +850,8 @@ Source: FMISpec2.0.2[p.85]: 3.2.2 Evaluation of Model Equations The model enters Continuous-Time Mode and all discrete-time equations become inactive and all relations are “frozen”. This function has to be called when changing from Event Mode (after the global event iteration in Event Mode over all involved FMUs and other models has converged) into Continuous-Time Mode. """ -function fmi2EnterContinuousTimeMode(cfunc::Ptr{Cvoid}, c::fmi2Component) - status = ccall(cfunc, - fmi2Status, - (fmi2Component,), - c) +function fmi2EnterContinuousTimeMode(cfunc::Ptr{Cvoid}, c::fmi2Component)::fmi2Status + status = ccall(cfunc, fmi2Status, (fmi2Component,), c) @debug "fmi2EnterContinuousTimeMode(c: $(c)) → $(status)" return status end @@ -624,15 +864,22 @@ This function must be called by the environment after every completed step of th If enterEventMode == fmi2True, the event mode must be entered If terminateSimulation == fmi2True, the simulation shall be terminated """ -function fmi2CompletedIntegratorStep!(cfunc::Ptr{Cvoid}, - c::fmi2Component, - noSetFMUStatePriorToCurrentPoint::fmi2Boolean, - enterEventMode::Ptr{fmi2Boolean}, - terminateSimulation::Ptr{fmi2Boolean}) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, fmi2Boolean, Ptr{fmi2Boolean}, Ptr{fmi2Boolean}), - c, noSetFMUStatePriorToCurrentPoint, enterEventMode, terminateSimulation) +function fmi2CompletedIntegratorStep!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + noSetFMUStatePriorToCurrentPoint::fmi2Boolean, + enterEventMode::Ptr{fmi2Boolean}, + terminateSimulation::Ptr{fmi2Boolean}, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, fmi2Boolean, Ptr{fmi2Boolean}, Ptr{fmi2Boolean}), + c, + noSetFMUStatePriorToCurrentPoint, + enterEventMode, + terminateSimulation, + ) @debug "fmi2CompletedIntegratorStep(c: $(c), noSetFMUStatePriorToCurrentPoint: $(noSetFMUStatePriorToCurrentPoint), enterEventMode: $(enterEventMode), terminateSimulation: $(terminateSimulation)) → $(status)" return status end @@ -643,14 +890,20 @@ Source: FMISpec2.0.2[p.86]: 3.2.2 Evaluation of Model Equations Compute state derivatives at the current time instant and for the current states. """ -function fmi2GetDerivatives!(cfunc::Ptr{Cvoid}, - c::fmi2Component, - derivatives::Union{Array{fmi2Real}, Ptr{fmi2Real}}, - nx::Csize_t) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2Real}, Csize_t), - c, derivatives, nx) +function fmi2GetDerivatives!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + derivatives::Union{Array{fmi2Real},Ptr{fmi2Real}}, + nx::Csize_t, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2Real}, Csize_t), + c, + derivatives, + nx, + ) @debug "fmi2GetDerivatives(c: $(c), derivatives: $(derivatives), nx: $(nx)) → $(status)" return status end @@ -661,11 +914,20 @@ Source: FMISpec2.0.2[p.86]: 3.2.2 Evaluation of Model Equations Compute event indicators at the current time instant and for the current states. """ -function fmi2GetEventIndicators!(cfunc::Ptr{Cvoid}, c::fmi2Component, eventIndicators::Union{AbstractArray{fmi2Real}, Ptr{fmi2Real}}, ni::Csize_t) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2Real}, Csize_t), - c, eventIndicators, ni) +function fmi2GetEventIndicators!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + eventIndicators::Union{AbstractArray{fmi2Real},Ptr{fmi2Real}}, + ni::Csize_t, +)::fmi2Status + status = ccall( + cfunc, + fmi2Status, + (fmi2Component, Ptr{fmi2Real}, Csize_t), + c, + eventIndicators, + ni, + ) @debug "fmi2GetEventIndicators(c: $(c), eventIndicators: $(eventIndicators), ni: $(ni)) → $(status)" return status end @@ -676,13 +938,13 @@ Source: FMISpec2.0.2[p.86]: 3.2.2 Evaluation of Model Equations Return the new (continuous) state vector x. """ -function fmi2GetContinuousStates!(cfunc::Ptr{Cvoid}, c::fmi2Component, - x::Union{AbstractArray{fmi2Real}, Ptr{fmi2Real}}, - nx::Csize_t) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2Real}, Csize_t), - c, x, nx) +function fmi2GetContinuousStates!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + x::Union{AbstractArray{fmi2Real},Ptr{fmi2Real}}, + nx::Csize_t, +)::fmi2Status + status = ccall(cfunc, fmi2Status, (fmi2Component, Ptr{fmi2Real}, Csize_t), c, x, nx) @debug "fmi2GetContinuousStates(c: $(c), x: $(x), nx: $(nx)) → $(status)" return status end @@ -693,12 +955,15 @@ Source: FMISpec2.0.2[p.86]: 3.2.2 Evaluation of Model Equations Return the nominal values of the continuous states. """ -function fmi2GetNominalsOfContinuousStates!(cfunc::Ptr{Cvoid}, c::fmi2Component, x_nominal::Union{AbstractArray{fmi2Real}, Ptr{fmi2Real}}, nx::Csize_t) - status = ccall(cfunc, - fmi2Status, - (fmi2Component, Ptr{fmi2Real}, Csize_t), - c, x_nominal, nx) +function fmi2GetNominalsOfContinuousStates!( + cfunc::Ptr{Cvoid}, + c::fmi2Component, + x_nominal::Union{AbstractArray{fmi2Real},Ptr{fmi2Real}}, + nx::Csize_t, +)::fmi2Status + status = + ccall(cfunc, fmi2Status, (fmi2Component, Ptr{fmi2Real}, Csize_t), c, x_nominal, nx) @debug "fmi2GetNominalsOfContinuousStates(c: $(c), x_nominal: $(x_nominal), nx: $(nx)) → $(status)" return status end -export fmi2GetNominalsOfContinuousStates! \ No newline at end of file +export fmi2GetNominalsOfContinuousStates! diff --git a/src/FMI2/cfunc_unload.jl b/src/FMI2/cfunc_unload.jl index fd24fd3..9f74ba1 100644 --- a/src/FMI2/cfunc_unload.jl +++ b/src/FMI2/cfunc_unload.jl @@ -3,155 +3,237 @@ # Licensed under the MIT license. See LICENSE file in the project root for details. # -function unload_fmi2GetTypesPlatform() +function unload_fmi2GetTypesPlatform()::fmi2String @assert false "The function `fmi2GetTypesPlatform` is not callable anymore, because the FMU is unloaded!" - str = "" + str = "" return pointer(str) end -function unload_fmi2GetVersion() +function unload_fmi2GetVersion()::fmi2String @assert false "The function `fmi2GetVersion()` is not callable anymore, because the FMU is unloaded!" - str = "" + str = "" return pointer(str) end # 2.1.5 -function unload_fmi2Instantiate(_instanceName::fmi2String, - fmuType::fmi2Type, - _fmuGUID::fmi2String, - _fmuResourceLocation::fmi2String, - _functions::Ptr{fmi2CallbackFunctions}, - visible::fmi2Boolean, - loggingOn::fmi2Boolean) - +function unload_fmi2Instantiate( + _instanceName::fmi2String, + fmuType::fmi2Type, + _fmuGUID::fmi2String, + _fmuResourceLocation::fmi2String, + _functions::Ptr{fmi2CallbackFunctions}, + visible::fmi2Boolean, + loggingOn::fmi2Boolean, +)::fmi2Component + @assert false "The function `fmi2Instantiate` is not callable anymore, because the FMU is unloaded!" return C_NULL end -function unload_fmi2FreeInstance(_component::fmi2Component) +function unload_fmi2FreeInstance(_component::fmi2Component)::Nothing @assert false "The function `fmi2FreeInstance` is not callable anymore, because the FMU is unloaded!" return nothing end -function unload_fmi2SetDebugLogging(_component::fmi2Component, loggingOn::fmi2Boolean, nCategories::Csize_t, categories::Ptr{fmi2String}) +function unload_fmi2SetDebugLogging( + _component::fmi2Component, + loggingOn::fmi2Boolean, + nCategories::Csize_t, + categories::Ptr{fmi2String}, +)::fmi2Status @assert false "The function `fmi2SetDebugLogging` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2SetupExperiment(_component::fmi2Component, toleranceDefined::fmi2Boolean, tolerance::fmi2Real, startTime::fmi2Real, stopTimeDefined::fmi2Boolean, stopTime::fmi2Real) +function unload_fmi2SetupExperiment( + _component::fmi2Component, + toleranceDefined::fmi2Boolean, + tolerance::fmi2Real, + startTime::fmi2Real, + stopTimeDefined::fmi2Boolean, + stopTime::fmi2Real, +)::fmi2Status @assert false "The function `fmi2SetupExperiment` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2EnterInitializationMode(_component::fmi2Component) +function unload_fmi2EnterInitializationMode(_component::fmi2Component)::fmi2Status @assert false "The function `fmi2EnterInitializationMode` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2ExitInitializationMode(_component::fmi2Component) +function unload_fmi2ExitInitializationMode(_component::fmi2Component)::fmi2Status @assert false "The function `fmi2ExitInitializationMod` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2Terminate(_component::fmi2Component) +function unload_fmi2Terminate(_component::fmi2Component)::fmi2Status @assert false "The function `fmi2Terminate` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2Reset(_component::fmi2Component) +function unload_fmi2Reset(_component::fmi2Component)::fmi2Status @assert false "The function `fmi2Reset` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2GetReal(_component::fmi2Component, _vr::Ptr{fmi2ValueReference}, nvr::Csize_t, _value::Ptr{fmi2Real}) +function unload_fmi2GetReal( + _component::fmi2Component, + _vr::Ptr{fmi2ValueReference}, + nvr::Csize_t, + _value::Ptr{fmi2Real}, +)::fmi2Status @assert false "The function `fmi2GetReal` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2GetInteger(_component::fmi2Component, _vr::Ptr{fmi2ValueReference}, nvr::Csize_t, _value::Ptr{fmi2Integer}) +function unload_fmi2GetInteger( + _component::fmi2Component, + _vr::Ptr{fmi2ValueReference}, + nvr::Csize_t, + _value::Ptr{fmi2Integer}, +)::fmi2Status @assert false "The function `fmi2GetInteger` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2GetBoolean(_component::fmi2Component, _vr::Ptr{fmi2ValueReference}, nvr::Csize_t, _value::Ptr{fmi2Boolean}) +function unload_fmi2GetBoolean( + _component::fmi2Component, + _vr::Ptr{fmi2ValueReference}, + nvr::Csize_t, + _value::Ptr{fmi2Boolean}, +)::fmi2Status @assert false "The function `fmi2GetBoolean` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2GetString(_component::fmi2Component, _vr::Ptr{fmi2ValueReference}, nvr::Csize_t, _value::Ptr{fmi2String}) +function unload_fmi2GetString( + _component::fmi2Component, + _vr::Ptr{fmi2ValueReference}, + nvr::Csize_t, + _value::Ptr{fmi2String}, +)::fmi2Status @assert false "The function `fmi2GetString` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2SetReal(_component::fmi2Component, _vr::Ptr{fmi2ValueReference}, nvr::Csize_t, _value::Ptr{fmi2Real}) +function unload_fmi2SetReal( + _component::fmi2Component, + _vr::Ptr{fmi2ValueReference}, + nvr::Csize_t, + _value::Ptr{fmi2Real}, +)::fmi2Status @assert false "The function `fmi2SetReal` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2SetInteger(_component::fmi2Component, _vr::Ptr{fmi2ValueReference}, nvr::Csize_t, _value::Ptr{fmi2Integer}) +function unload_fmi2SetInteger( + _component::fmi2Component, + _vr::Ptr{fmi2ValueReference}, + nvr::Csize_t, + _value::Ptr{fmi2Integer}, +)::fmi2Status @assert false "The function `fmi2SetInteger` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2SetBoolean(_component::fmi2Component, _vr::Ptr{fmi2ValueReference}, nvr::Csize_t, _value::Ptr{fmi2Boolean}) +function unload_fmi2SetBoolean( + _component::fmi2Component, + _vr::Ptr{fmi2ValueReference}, + nvr::Csize_t, + _value::Ptr{fmi2Boolean}, +)::fmi2Status @assert false "The function `fmi2SetBoolean` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2SetString(_component::fmi2Component, _vr::Ptr{fmi2ValueReference}, nvr::Csize_t, _value::Ptr{fmi2String}) +function unload_fmi2SetString( + _component::fmi2Component, + _vr::Ptr{fmi2ValueReference}, + nvr::Csize_t, + _value::Ptr{fmi2String}, +)::fmi2Status @assert false "The function `fmi2SetString` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2SetTime(_component::fmi2Component, time::fmi2Real) +function unload_fmi2SetTime(_component::fmi2Component, time::fmi2Real)::fmi2Status @assert false "The function `fmi2SetTime` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2SetContinuousStates(_component::fmi2Component, _x::Ptr{fmi2Real}, nx::Csize_t) +function unload_fmi2SetContinuousStates( + _component::fmi2Component, + _x::Ptr{fmi2Real}, + nx::Csize_t, +)::fmi2Status @assert false "The function `fmi2SetContinuousStates` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2EnterEventMode(_component::fmi2Component) +function unload_fmi2EnterEventMode(_component::fmi2Component)::fmi2Status @assert false "The function `fmi2EnterEventMode` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2NewDiscreteStates(_component::fmi2Component, _fmi2eventInfo::Ptr{fmi2EventInfo}) +function unload_fmi2NewDiscreteStates( + _component::fmi2Component, + _fmi2eventInfo::Ptr{fmi2EventInfo}, +)::fmi2Status @assert false "The function `fmi2NewDiscreteStates` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2EnterContinuousTimeMode(_component::fmi2Component) +function unload_fmi2EnterContinuousTimeMode(_component::fmi2Component)::fmi2Status @assert false "The function `fmi2EnterContinuousTimeMode` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2CompletedIntegratorStep(_component::fmi2Component, noSetFMUStatePriorToCurrentPoint::fmi2Boolean, enterEventMode::Ptr{fmi2Boolean}, terminateSimulation::Ptr{fmi2Boolean}) +function unload_fmi2CompletedIntegratorStep( + _component::fmi2Component, + noSetFMUStatePriorToCurrentPoint::fmi2Boolean, + enterEventMode::Ptr{fmi2Boolean}, + terminateSimulation::Ptr{fmi2Boolean}, +)::fmi2Status @assert false "The function `fmi2CompletedIntegratorStep` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2GetDerivatives(_component::fmi2Component, _derivatives::Ptr{fmi2Real}, nx::Csize_t) +function unload_fmi2GetDerivatives( + _component::fmi2Component, + _derivatives::Ptr{fmi2Real}, + nx::Csize_t, +)::fmi2Status @assert false "The function `fmi2GetDerivatives` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2GetEventIndicators(_component::fmi2Component, _eventIndicators::Ptr{fmi2Real}, ni::Csize_t) +function unload_fmi2GetEventIndicators( + _component::fmi2Component, + _eventIndicators::Ptr{fmi2Real}, + ni::Csize_t, +)::fmi2Status @assert false "The function `fmi2GetEventIndicators` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2GetContinuousStates(_component::fmi2Component, _x::Ptr{fmi2Real}, nx::Csize_t) +function unload_fmi2GetContinuousStates( + _component::fmi2Component, + _x::Ptr{fmi2Real}, + nx::Csize_t, +)::fmi2Status @assert false "The function `fmi2GetContinuousStates` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end -function unload_fmi2GetNominalsOfContinuousStates(_component::fmi2Component, _x_nominal::Ptr{fmi2Real}, nx::Csize_t) +function unload_fmi2GetNominalsOfContinuousStates( + _component::fmi2Component, + _x_nominal::Ptr{fmi2Real}, + nx::Csize_t, +)::fmi2Status @assert false "The function `fmi2GetNominalsOfContinuousStates` is not callable anymore, because the FMU is unloaded!" return fmi2StatusFatal end # ToDo: Add CS functions! -# ToDo: This shoudl be doable with a macro like @unloaded_version fmi2GetContinuousStates \ No newline at end of file +# ToDo: This should be doable with a macro like @unloaded_version fmi2GetContinuousStates diff --git a/src/FMI2/ctype.jl b/src/FMI2/ctype.jl index bcde73d..010b77b 100644 --- a/src/FMI2/ctype.jl +++ b/src/FMI2/ctype.jl @@ -26,7 +26,7 @@ mutable struct fmi2EventInfo nextEventTime::fmi2Real # constructor - function fmi2EventInfo() + function fmi2EventInfo() inst = new() inst.newDiscreteStatesNeeded = fmi2False inst.terminateSimulation = fmi2False @@ -71,8 +71,8 @@ mutable struct fmi2VariableDependency index::UInt # optional - dependencies::Union{Array{UInt, 1}, Nothing} - dependenciesKind::Union{Array{fmi2DependencyKind, 1}, Nothing} + dependencies::Union{Array{UInt,1},Nothing} + dependenciesKind::Union{Array{fmi2DependencyKind,1},Nothing} # Constructor function fmi2VariableDependency(index) @@ -97,23 +97,23 @@ abstract type fmi2AttributesExt end # extended version of the Attributes used in ToDo. Source: 2.2.3 Definition of Types (TypeDefinitions) -""" +""" mutable struct fmi2RealAttributes <: fmi2Attributes # mandatory # (nothing) # optional - quantity::Union{String, Nothing} - unit::Union{String, Nothing} - displayUnit::Union{String, Nothing} - relativeQuantity::Union{Bool, Nothing} - min::Union{Real, Nothing} - max::Union{Real, Nothing} - nominal::Union{Real, Nothing} - unbounded::Union{Bool, Nothing} - + quantity::Union{String,Nothing} + unit::Union{String,Nothing} + displayUnit::Union{String,Nothing} + relativeQuantity::Union{Bool,Nothing} + min::Union{Real,Nothing} + max::Union{Real,Nothing} + nominal::Union{Real,Nothing} + unbounded::Union{Bool,Nothing} + # constructor - function fmi2RealAttributes() + function fmi2RealAttributes() inst = new() inst.quantity = nothing @@ -125,7 +125,7 @@ mutable struct fmi2RealAttributes <: fmi2Attributes inst.nominal = nothing inst.unbounded = nothing - return inst + return inst end end @@ -133,22 +133,22 @@ end ToDo. Source: 2.2.3 Definition of Types (TypeDefinitions) -""" +""" mutable struct fmi2RealAttributesExt <: fmi2AttributesExt # mandatory # (nothing) # optional - declaredType::Union{String, Nothing} - start::Union{Real, Nothing} - derivative::Union{UInt, Nothing} - reinit::Union{Bool, Nothing} + declaredType::Union{String,Nothing} + start::Union{Real,Nothing} + derivative::Union{UInt,Nothing} + reinit::Union{Bool,Nothing} # helper attributes::fmi2RealAttributes # constructor - function fmi2RealAttributesExt() + function fmi2RealAttributesExt() inst = new() inst.declaredType = nothing @@ -158,7 +158,7 @@ mutable struct fmi2RealAttributesExt <: fmi2AttributesExt inst.attributes = fmi2RealAttributes() - return inst + return inst end end @@ -166,12 +166,12 @@ end ToDo. Source: 2.2.3 Definition of Types (TypeDefinitions) -""" +""" mutable struct fmi2IntegerAttributes <: fmi2Attributes # optional - quantity::Union{String, Nothing} - min::Union{Integer, Nothing} - max::Union{Integer, Nothing} + quantity::Union{String,Nothing} + min::Union{Integer,Nothing} + max::Union{Integer,Nothing} # constructor function fmi2IntegerAttributes() @@ -181,7 +181,7 @@ mutable struct fmi2IntegerAttributes <: fmi2Attributes inst.min = nothing inst.max = nothing - return inst + return inst end end @@ -189,23 +189,23 @@ end ToDo. Source: 2.2.3 Definition of Types (TypeDefinitions) -""" +""" mutable struct fmi2IntegerAttributesExt <: fmi2AttributesExt # optional - start::Union{fmi2Integer, Nothing} - declaredType::Union{String, Nothing} + start::Union{fmi2Integer,Nothing} + declaredType::Union{String,Nothing} attributes::fmi2IntegerAttributes - + # constructor function fmi2IntegerAttributesExt() inst = new() - inst.start = nothing + inst.start = nothing inst.declaredType = nothing inst.attributes = fmi2IntegerAttributes() - return inst + return inst end end @@ -213,22 +213,22 @@ end ToDo. Source: 2.2.3 Definition of Types (TypeDefinitions) -""" -mutable struct fmi2BooleanAttributesExt <: fmi2AttributesExt +""" +mutable struct fmi2BooleanAttributesExt <: fmi2AttributesExt # optional - start::Union{fmi2Boolean, Nothing} - declaredType::Union{String, Nothing} + start::Union{fmi2Boolean,Nothing} + declaredType::Union{String,Nothing} # no `attributes` element, because the FMI-spec does not define one! - + # constructor function fmi2BooleanAttributesExt() inst = new() - inst.start = nothing + inst.start = nothing inst.declaredType = nothing - return inst + return inst end end @@ -236,7 +236,7 @@ end ToDo. Source: 2.2.3 Definition of Types (TypeDefinitions) -""" +""" mutable struct fmi2BooleanAttributes <: fmi2Attributes # this struct has no content and is only defined for consistency reasons! end @@ -245,22 +245,22 @@ end ToDo. Source: 2.2.3 Definition of Types (TypeDefinitions) -""" +""" mutable struct fmi2StringAttributesExt <: fmi2AttributesExt # optional - start::Union{String, Nothing} - declaredType::Union{String, Nothing} + start::Union{String,Nothing} + declaredType::Union{String,Nothing} # no `attributes` element, because the FMI-spec does not define one! - + # constructor function fmi2StringAttributesExt() inst = new() - inst.start = nothing + inst.start = nothing inst.declaredType = nothing - return inst + return inst end end @@ -268,7 +268,7 @@ end ToDo. Source: 2.2.3 Definition of Types (TypeDefinitions) -""" +""" mutable struct fmi2StringAttributes <: fmi2Attributes # this struct has no content and is only defined for consistency reasons! end @@ -277,29 +277,29 @@ end ToDo. Source: 2.2.3 Definition of Types (TypeDefinitions) -""" +""" mutable struct fmi2EnumerationAttributesExt <: fmi2AttributesExt # mandatory - declaredType::Union{String, Nothing} + declaredType::Union{String,Nothing} # optional - quantity::Union{String, Nothing} - min::Union{Integer, Nothing} - max::Union{Integer, Nothing} - start::Union{Integer, Nothing} - + quantity::Union{String,Nothing} + min::Union{Integer,Nothing} + max::Union{Integer,Nothing} + start::Union{Integer,Nothing} + # constructor - function fmi2EnumerationAttributesExt() + function fmi2EnumerationAttributesExt() inst = new() inst.declaredType = nothing inst.quantity = nothing - inst.min = nothing + inst.min = nothing inst.max = nothing - inst.start = nothing + inst.start = nothing - return inst + return inst end end @@ -307,7 +307,7 @@ end Custom helper, not part of the FMI-Spec. Source: 2.2.3 Definition of Types (TypeDefinitions) -""" +""" mutable struct fmi2ModelDescriptionEnumerationItem # mandatory @@ -316,7 +316,7 @@ mutable struct fmi2ModelDescriptionEnumerationItem # optional description::Union{String,Nothing} - + # Constructor function fmi2ModelDescriptionEnumerationItem() inst = new() @@ -324,7 +324,7 @@ mutable struct fmi2ModelDescriptionEnumerationItem inst.value = nothing inst.description = nothing - + return inst end end @@ -333,24 +333,24 @@ end ToDo. Source: 2.2.3 Definition of Types (TypeDefinitions) -""" +""" mutable struct fmi2EnumerationAttributes <: fmi2Attributes # optional - quantity::Union{String, Nothing} + quantity::Union{String,Nothing} # mandatory (invisible) - items::Array{fmi2ModelDescriptionEnumerationItem,1} - + items::Array{fmi2ModelDescriptionEnumerationItem,1} + # constructor - function fmi2EnumerationAttributes() + function fmi2EnumerationAttributes() inst = new() - inst.quantity = nothing + inst.quantity = nothing inst.items = [] - return inst + return inst end end -import Base.push! +import Base.push! function push!(attr::fmi2EnumerationAttributes, items...) push!(attr.items, items...) end @@ -366,17 +366,21 @@ function length(attr::fmi2EnumerationAttributes) end # mimic existence of properties of `fmi2RealAttributes` in `fmi2RealAttributesExt` (inheritance is not available in Julia, so it is simulated) -function Base.setproperty!(var::Union{fmi2RealAttributesExt, fmi2IntegerAttributesExt}, sym::Symbol, value) +function Base.setproperty!( + var::Union{fmi2RealAttributesExt,fmi2IntegerAttributesExt}, + sym::Symbol, + value, +) - if Base.invoke(Base.hasproperty, Tuple{Any, Symbol}, var, sym) - return invoke(Base.setproperty!, Tuple{Any, Symbol, Any}, var, sym, value) - end - - var_attributes = invoke(Base.getproperty, Tuple{Any, Symbol}, var, :attributes) + if Base.invoke(Base.hasproperty, Tuple{Any,Symbol}, var, sym) + return invoke(Base.setproperty!, Tuple{Any,Symbol,Any}, var, sym, value) + end + + var_attributes = invoke(Base.getproperty, Tuple{Any,Symbol}, var, :attributes) if hasproperty(var_attributes, sym) return Base.setfield!(var_attributes, sym, value) - end + end @assert false "Unknown property: $(sym)" @@ -384,13 +388,16 @@ function Base.setproperty!(var::Union{fmi2RealAttributesExt, fmi2IntegerAttribut end # mimic existence of properties of `fmi2RealAttributes` in `fmi2RealAttributesExt` (inheritance is not available in Julia, so it is simulated) -function Base.getproperty(var::Union{fmi2RealAttributesExt, fmi2IntegerAttributesExt}, sym::Symbol) - - if Base.invoke(Base.hasproperty, Tuple{Any, Symbol}, var, sym) - return Base.invoke(Base.getproperty, Tuple{Any, Symbol}, var, sym) - end +function Base.getproperty( + var::Union{fmi2RealAttributesExt,fmi2IntegerAttributesExt}, + sym::Symbol, +) - var_attributes = invoke(Base.getproperty, Tuple{Any, Symbol}, var, :attributes) + if Base.invoke(Base.hasproperty, Tuple{Any,Symbol}, var, sym) + return Base.invoke(Base.getproperty, Tuple{Any,Symbol}, var, sym) + end + + var_attributes = invoke(Base.getproperty, Tuple{Any,Symbol}, var, :attributes) if Base.hasproperty(var_attributes, sym) return Base.getproperty(var_attributes, sym) @@ -402,13 +409,16 @@ function Base.getproperty(var::Union{fmi2RealAttributesExt, fmi2IntegerAttribute end # mimic existence of properties of `fmi2RealAttributes` in `fmi2RealAttributesExt` (inheritance is not available in Julia, so it is simulated) -function Base.hasproperty(var::Union{fmi2RealAttributesExt, fmi2IntegerAttributesExt}, sym::Symbol) - - if Base.invoke(Base.hasproperty, Tuple{Any, Symbol}, var, sym) +function Base.hasproperty( + var::Union{fmi2RealAttributesExt,fmi2IntegerAttributesExt}, + sym::Symbol, +) + + if Base.invoke(Base.hasproperty, Tuple{Any,Symbol}, var, sym) return true end - var_attributes = invoke(Base.getproperty, Tuple{Any, Symbol}, var, :attributes) + var_attributes = invoke(Base.getproperty, Tuple{Any,Symbol}, var, :attributes) return Base.hasproperty(var_attribute, sym) end @@ -418,16 +428,16 @@ const FMI2_SCALAR_VARIABLE_ATTRIBUTE_STRUCT = Union{ fmi2IntegerAttributesExt, fmi2BooleanAttributesExt, fmi2StringAttributesExt, - fmi2EnumerationAttributesExt + fmi2EnumerationAttributesExt, } # Constant definition of union for the (not extended) attributes (used in fmi2SimpleTypes) const FMI2_SIMPLE_TYPE_ATTRIBUTE_STRUCT = Union{ - fmi2RealAttributes, - fmi2IntegerAttributes, - fmi2StringAttributes, - fmi2BooleanAttributes, - fmi2EnumerationAttributes + fmi2RealAttributes, + fmi2IntegerAttributes, + fmi2StringAttributes, + fmi2BooleanAttributes, + fmi2EnumerationAttributes, } # Custom helper, not part of the FMI-Spec. @@ -450,9 +460,9 @@ end # Custom helper, not part of the FMI-Spec. mutable struct fmi2ModelDescriptionModelStructure - outputs::Union{Array{fmi2VariableDependency, 1}, Nothing} - derivatives::Union{Array{fmi2VariableDependency, 1}, Nothing} - initialUnknowns::Union{Array{fmi2Unknown, 1}, Nothing} + outputs::Union{Array{fmi2VariableDependency,1},Nothing} + derivatives::Union{Array{fmi2VariableDependency,1},Nothing} + initialUnknowns::Union{Array{fmi2Unknown,1},Nothing} # Constructor function fmi2ModelDescriptionModelStructure() @@ -470,22 +480,22 @@ mutable struct fmi2ModelDescriptionModelExchange modelIdentifier::String # optional - canGetAndSetFMUstate::Union{Bool, Nothing} - canSerializeFMUstate::Union{Bool, Nothing} - providesDirectionalDerivative::Union{Bool, Nothing} + canGetAndSetFMUstate::Union{Bool,Nothing} + canSerializeFMUstate::Union{Bool,Nothing} + providesDirectionalDerivative::Union{Bool,Nothing} # ToDo: Further attributes 3.3.1 # constructor - function fmi2ModelDescriptionModelExchange() + function fmi2ModelDescriptionModelExchange() inst = new() - return inst + return inst end - function fmi2ModelDescriptionModelExchange(modelIdentifier::String) - inst = fmi2ModelDescriptionModelExchange() + function fmi2ModelDescriptionModelExchange(modelIdentifier::String) + inst = fmi2ModelDescriptionModelExchange() inst.modelIdentifier = modelIdentifier - return inst + return inst end end @@ -495,25 +505,25 @@ mutable struct fmi2ModelDescriptionCoSimulation modelIdentifier::String # optional - canHandleVariableCommunicationStepSize::Union{Bool, Nothing} - canInterpolateInputs::Union{Bool, Nothing} - maxOutputDerivativeOrder::Union{UInt, Nothing} - canGetAndSetFMUstate::Union{Bool, Nothing} - canSerializeFMUstate::Union{Bool, Nothing} - providesDirectionalDerivative::Union{Bool, Nothing} + canHandleVariableCommunicationStepSize::Union{Bool,Nothing} + canInterpolateInputs::Union{Bool,Nothing} + maxOutputDerivativeOrder::Union{UInt,Nothing} + canGetAndSetFMUstate::Union{Bool,Nothing} + canSerializeFMUstate::Union{Bool,Nothing} + providesDirectionalDerivative::Union{Bool,Nothing} # ToDo: Further attributes 4.3.1 # constructor - function fmi2ModelDescriptionCoSimulation() + function fmi2ModelDescriptionCoSimulation() inst = new() - return inst + return inst end - function fmi2ModelDescriptionCoSimulation(modelIdentifier::String) + function fmi2ModelDescriptionCoSimulation(modelIdentifier::String) inst = fmi2ModelDescriptionCoSimulation() inst.modelIdentifier = modelIdentifier - return inst + return inst end end @@ -526,24 +536,30 @@ mutable struct fmi2ScalarVariable # attributes (mandatory) name::String valueReference::fmi2ValueReference - + # attributes (optional) - description::Union{String, Nothing} - causality::Union{fmi2Causality, Nothing} - variability::Union{fmi2Variability, Nothing} - initial::Union{fmi2Initial, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi2Boolean, Nothing} - annotations::Union{fmi2Annotation, Nothing} + description::Union{String,Nothing} + causality::Union{fmi2Causality,Nothing} + variability::Union{fmi2Variability,Nothing} + initial::Union{fmi2Initial,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi2Boolean,Nothing} + annotations::Union{fmi2Annotation,Nothing} # custom - attribute::Union{FMI2_SCALAR_VARIABLE_ATTRIBUTE_STRUCT, Nothing} + attribute::Union{FMI2_SCALAR_VARIABLE_ATTRIBUTE_STRUCT,Nothing} # Constructor for not further specified ScalarVariables - function fmi2ScalarVariable(name::String, valueReference::fmi2ValueReference, causality::Union{fmi2Causality, Nothing}, variability::Union{fmi2Variability, Nothing}, initial::Union{fmi2Initial, Nothing}) + function fmi2ScalarVariable( + name::String, + valueReference::fmi2ValueReference, + causality::Union{fmi2Causality,Nothing}, + variability::Union{fmi2Variability,Nothing}, + initial::Union{fmi2Initial,Nothing}, + ) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference - inst.description = nothing + inst.description = nothing inst.causality = causality inst.variability = variability inst.initial = initial @@ -557,7 +573,7 @@ end export fmi2ScalarVariable function getAttributes(sv::fmi2ScalarVariable) - + causality = sv.causality variability = sv.variability initial = sv.initial @@ -567,26 +583,29 @@ function getAttributes(sv::fmi2ScalarVariable) end if isnothing(variability) - variability = fmi2VariabilityContinuous # this is the default according FMI-spec p. 49 + variability = fmi2VariabilityContinuous # this is the default according FMI-spec p. 49 end if isnothing(initial) # setting default value for initial according FMI-spec p. 51 if causality != nothing && variability != nothing if causality == fmi2CausalityParameter - if variability == fmi2VariabilityFixed || variability == fmi2VariabilityTunable + if variability == fmi2VariabilityFixed || + variability == fmi2VariabilityTunable initial = fmi2InitialExact else @warn "Causality: $(fmi2CausalityToString(causality)) Variability: $(fmi2VariabilityToString(variability)) This combination is not allowed." end elseif causality == fmi2CausalityCalculatedParameter - if variability == fmi2VariabilityFixed || variability == fmi2VariabilityTunable + if variability == fmi2VariabilityFixed || + variability == fmi2VariabilityTunable initial = fmi2InitialCalculated else @warn "Causality: $(fmi2CausalityToString(causality)) Variability: $(fmi2VariabilityToString(variability)) This combination is not allowed." end elseif causality == fmi2CausalityInput - if variability == fmi2VariabilityDiscrete || variability == fmi2VariabilityContinuous + if variability == fmi2VariabilityDiscrete || + variability == fmi2VariabilityContinuous # everything allright, it's not allowed to define `initial` in this case else @warn "Causality: $(fmi2CausalityToString(causality)) Variability: $(fmi2VariabilityToString(variability)) This combination is not allowed." @@ -594,7 +613,8 @@ function getAttributes(sv::fmi2ScalarVariable) elseif causality == fmi2CausalityOutput if variability == fmi2VariabilityConstant initial = fmi2InitialExact - elseif variability == fmi2VariabilityDiscrete || variability == fmi2VariabilityContinuous + elseif variability == fmi2VariabilityDiscrete || + variability == fmi2VariabilityContinuous initial = fmi2InitialCalculated else @warn "Causality: $(fmi2CausalityToString(causality)) Variability: $(fmi2VariabilityToString(variability)) This combination is not allowed." @@ -602,9 +622,11 @@ function getAttributes(sv::fmi2ScalarVariable) elseif causality == fmi2CausalityLocal if variability == fmi2VariabilityConstant initial = fmi2InitialExact - elseif variability == fmi2VariabilityFixed || variability == fmi2VariabilityTunable + elseif variability == fmi2VariabilityFixed || + variability == fmi2VariabilityTunable initial = fmi2InitialCalculated - elseif variability == fmi2VariabilityDiscrete || variability == fmi2VariabilityContinuous + elseif variability == fmi2VariabilityDiscrete || + variability == fmi2VariabilityContinuous initial = fmi2InitialCalculated else @warn "Causality: $(fmi2CausalityToString(causality)) Variability: $(fmi2VariabilityToString(variability)) This combination is not allowed." @@ -627,9 +649,9 @@ end """ Overload the Base.show() function for custom printing of the fmi2ScalarVariable. """ -function Base.show(io::IO, var::fmi2ScalarVariable) +function Base.show(io::IO, var::fmi2ScalarVariable) print(io, "Name: '$(var.name)' (reference: $(var.valueReference))") -end +end """ Source: FMISpec2.0.3[p.40]: 2.2.3 Definition of Types (TypeDefinitions) @@ -638,20 +660,20 @@ The fmi2SimpleType describes the attributes of a type definition. """ mutable struct fmi2SimpleType # mandatory - name::Union{String, Nothing} + name::Union{String,Nothing} # optional - description::Union{String, Nothing} + description::Union{String,Nothing} # helper - attribute::Union{FMI2_SIMPLE_TYPE_ATTRIBUTE_STRUCT, Nothing} + attribute::Union{FMI2_SIMPLE_TYPE_ATTRIBUTE_STRUCT,Nothing} function fmi2SimpleType() inst = new() - inst.name = nothing + inst.name = nothing inst.description = nothing - inst.attribute = nothing + inst.attribute = nothing return inst end @@ -662,51 +684,61 @@ export fmi2SimpleType # overwrite `getproperty` and `hasproperty` to mimic existence of properties # `Real`, `Integer`, `Boolean`, `String`, 'Enumeration' -function Base.hasproperty(var::Union{fmi2ScalarVariable, fmi2SimpleType}, sym::Symbol) +function Base.hasproperty(var::Union{fmi2ScalarVariable,fmi2SimpleType}, sym::Symbol) if sym in (:Real, :Integer, :Boolean, :String, :Enumeration) - var_attribute = Base.invoke(Base.getproperty, Tuple{Any, Symbol}, var, :attribute) - - if sym == :Real - return isa(var_attribute, fmi2RealAttributesExt) || isa(var_attribute, fmi2RealAttributes) + var_attribute = Base.invoke(Base.getproperty, Tuple{Any,Symbol}, var, :attribute) + + if sym == :Real + return isa(var_attribute, fmi2RealAttributesExt) || + isa(var_attribute, fmi2RealAttributes) elseif sym == :Integer - return isa(var_attribute, fmi2IntegerAttributesExt) || isa(var_attribute, fmi2IntegerAttributes) + return isa(var_attribute, fmi2IntegerAttributesExt) || + isa(var_attribute, fmi2IntegerAttributes) elseif sym == :Boolean - return isa(var_attribute, fmi2BooleanAttributesExt) || isa(var_attribute, fmi2BooleanAttributes) + return isa(var_attribute, fmi2BooleanAttributesExt) || + isa(var_attribute, fmi2BooleanAttributes) elseif sym == :String - return isa(var_attribute, fmi2StringAttributesExt) || isa(var_attribute, fmi2StringAttributes) + return isa(var_attribute, fmi2StringAttributesExt) || + isa(var_attribute, fmi2StringAttributes) elseif sym == :Enumeration - return isa(var_attribute, fmi2EnumerationAttributesExt) || isa(var_attribute, fmi2EnumerationAttributes) + return isa(var_attribute, fmi2EnumerationAttributesExt) || + isa(var_attribute, fmi2EnumerationAttributes) end return false end - return Base.invoke(Base.hasproperty, Tuple{Any, Symbol}, var, sym) + return Base.invoke(Base.hasproperty, Tuple{Any,Symbol}, var, sym) end -function Base.getproperty(var::Union{fmi2ScalarVariable, fmi2SimpleType}, sym::Symbol) - +function Base.getproperty(var::Union{fmi2ScalarVariable,fmi2SimpleType}, sym::Symbol) + if sym in (:Real, :Integer, :Boolean, :String, :Enumeration) - var_attribute = Base.invoke(Base.getproperty, Tuple{Any, Symbol}, var, :attribute) - - if sym == :Real - if isa(var_attribute, fmi2RealAttributesExt) || isa(var_attribute, fmi2RealAttributes) + var_attribute = Base.invoke(Base.getproperty, Tuple{Any,Symbol}, var, :attribute) + + if sym == :Real + if isa(var_attribute, fmi2RealAttributesExt) || + isa(var_attribute, fmi2RealAttributes) return var_attribute end elseif sym == :Integer - if isa(var_attribute, fmi2IntegerAttributesExt) || isa(var_attribute, fmi2IntegerAttributes) + if isa(var_attribute, fmi2IntegerAttributesExt) || + isa(var_attribute, fmi2IntegerAttributes) return var_attribute end elseif sym == :Boolean - if isa(var_attribute, fmi2BooleanAttributesExt) || isa(var_attribute, fmi2BooleanAttributes) + if isa(var_attribute, fmi2BooleanAttributesExt) || + isa(var_attribute, fmi2BooleanAttributes) return var_attribute end elseif sym == :String - if isa(var_attribute, fmi2StringAttributesExt) || isa(var_attribute, fmi2StringAttributes) + if isa(var_attribute, fmi2StringAttributesExt) || + isa(var_attribute, fmi2StringAttributes) return var_attribute end elseif sym == :Enumeration - if isa(var_attribute, fmi2EnumerationAttributesExt) || isa(var_attribute, fmi2EnumerationAttributes) + if isa(var_attribute, fmi2EnumerationAttributesExt) || + isa(var_attribute, fmi2EnumerationAttributes) return var_attribute end end @@ -714,16 +746,20 @@ function Base.getproperty(var::Union{fmi2ScalarVariable, fmi2SimpleType}, sym::S return nothing end - return invoke(Base.getproperty, Tuple{Any, Symbol}, var, sym) + return invoke(Base.getproperty, Tuple{Any,Symbol}, var, sym) end # overwrite `setproperty!` to mimic existence of properties `Real`, `Integer`, `Boolean`, `String`, 'Enumeration' -function Base.setproperty!(var::Union{fmi2ScalarVariable, fmi2SimpleType}, sym::Symbol, value) +function Base.setproperty!( + var::Union{fmi2ScalarVariable,fmi2SimpleType}, + sym::Symbol, + value, +) if sym ∈ (:Real, :Integer, :Boolean, :String, :Enumeration) - return invoke(Base.setproperty!, Tuple{Any, Symbol, Any}, var, :attribute, value) - else - return invoke(Base.setproperty!, Tuple{Any, Symbol, Any}, var, sym, value) - end + return invoke(Base.setproperty!, Tuple{Any,Symbol,Any}, var, :attribute, value) + else + return invoke(Base.setproperty!, Tuple{Any,Symbol,Any}, var, sym, value) + end end # ToDo: This is not a compliant docString. @@ -737,29 +773,31 @@ Type for the optional “BaseUnit” field of an `fmi2Unit`. """ mutable struct fmi2BaseUnit # exponents of SI units - kg::Union{Integer, Nothing} # kilogram - m::Union{Integer, Nothing} # meter - s::Union{Integer, Nothing} # second - A::Union{Integer, Nothing} # Ampere - K::Union{Integer, Nothing} # Kelvin - mol::Union{Integer, Nothing} # mol - cd::Union{Integer, Nothing} # candela - rad::Union{Integer, Nothing} # radians - - factor::Union{Real, Nothing} - offset::Union{Real, Nothing} - - function fmi2BaseUnit(kg::Union{Integer, Nothing}=nothing, - m::Union{Integer, Nothing}=nothing, - s::Union{Integer, Nothing}=nothing, - A::Union{Integer, Nothing}=nothing, - K::Union{Integer, Nothing}=nothing, - mol::Union{Integer, Nothing}=nothing, - cd::Union{Integer, Nothing}=nothing, - rad::Union{Integer, Nothing}=nothing, - factor::Union{Real, Nothing}=nothing, - offset::Union{Real, Nothing}=nothing) - + kg::Union{Integer,Nothing} # kilogram + m::Union{Integer,Nothing} # meter + s::Union{Integer,Nothing} # second + A::Union{Integer,Nothing} # Ampere + K::Union{Integer,Nothing} # Kelvin + mol::Union{Integer,Nothing} # mol + cd::Union{Integer,Nothing} # candela + rad::Union{Integer,Nothing} # radians + + factor::Union{Real,Nothing} + offset::Union{Real,Nothing} + + function fmi2BaseUnit( + kg::Union{Integer,Nothing} = nothing, + m::Union{Integer,Nothing} = nothing, + s::Union{Integer,Nothing} = nothing, + A::Union{Integer,Nothing} = nothing, + K::Union{Integer,Nothing} = nothing, + mol::Union{Integer,Nothing} = nothing, + cd::Union{Integer,Nothing} = nothing, + rad::Union{Integer,Nothing} = nothing, + factor::Union{Real,Nothing} = nothing, + offset::Union{Real,Nothing} = nothing, + ) + return new(kg, m, s, A, K, mol, cd, rad, factor, offset) end end @@ -768,8 +806,8 @@ export fmi2BaseUnit function Base.show(io::IO, unit::fmi2BaseUnit) if get(io, :compact, false) print(io, "BaseUnit") - else - + else + for siUnit in SI_UNITS expon = unit.siUnit if !iszero(expon) @@ -796,7 +834,7 @@ mutable struct fmi2DisplayUnit factor::Real offset::Real - function fmi2DisplayUnit(name::String, factor::Real=1.0, offset::Real=0.0) + function fmi2DisplayUnit(name::String, factor::Real = 1.0, offset::Real = 0.0) return new(name, factor, offset) end end @@ -814,7 +852,11 @@ mutable struct fmi2Unit baseUnit::Union{fmi2BaseUnit,Nothing} displayUnits::Union{Vector{fmi2DisplayUnit},Nothing} - function fmi2Unit(name::String, baseUnit::Union{fmi2BaseUnit,Nothing}=nothing, displayUnits::Union{Vector{fmi2DisplayUnit},Nothing}=nothing) + function fmi2Unit( + name::String, + baseUnit::Union{fmi2BaseUnit,Nothing} = nothing, + displayUnits::Union{Vector{fmi2DisplayUnit},Nothing} = nothing, + ) return new(name, baseUnit, displayUnits) end end @@ -829,29 +871,29 @@ mutable struct fmi2ModelDescription <: fmiModelDescription # attributes (mandatory) fmiVersion::String modelName::String - guid::Union{String, Base.UUID} + guid::Union{String,Base.UUID} # attributes (optional) - description::Union{String, Nothing} - author::Union{String, Nothing} - version::Union{String, Nothing} - copyright::Union{String, Nothing} - license::Union{String, Nothing} - generationTool::Union{String, Nothing} - generationDateAndTime::Union{DateTime, String, Nothing} - variableNamingConvention::Union{fmi2VariableNamingConvention, Nothing} - numberOfEventIndicators::Union{UInt, Nothing} - - unitDefinitions::Union{Array{fmi2Unit, 1}, Nothing} - typeDefinitions::Union{Array{fmi2SimpleType, 1}, Nothing} - logCategories::Union{Array, Nothing} # ToDo: Array type - - defaultExperiment::Union{fmi2ModelDescriptionDefaultExperiment, Nothing} - modelExchange::Union{fmi2ModelDescriptionModelExchange, Nothing} - coSimulation::Union{fmi2ModelDescriptionCoSimulation, Nothing} - - vendorAnnotations::Union{Array, Nothing} # ToDo: Array type - modelVariables::Array{fmi2ScalarVariable, 1} + description::Union{String,Nothing} + author::Union{String,Nothing} + version::Union{String,Nothing} + copyright::Union{String,Nothing} + license::Union{String,Nothing} + generationTool::Union{String,Nothing} + generationDateAndTime::Union{DateTime,String,Nothing} + variableNamingConvention::Union{fmi2VariableNamingConvention,Nothing} + numberOfEventIndicators::Union{UInt,Nothing} + + unitDefinitions::Union{Array{fmi2Unit,1},Nothing} + typeDefinitions::Union{Array{fmi2SimpleType,1},Nothing} + logCategories::Union{Array,Nothing} # ToDo: Array type + + defaultExperiment::Union{fmi2ModelDescriptionDefaultExperiment,Nothing} + modelExchange::Union{fmi2ModelDescriptionModelExchange,Nothing} + coSimulation::Union{fmi2ModelDescriptionCoSimulation,Nothing} + + vendorAnnotations::Union{Array,Nothing} # ToDo: Array type + modelVariables::Array{fmi2ScalarVariable,1} modelStructure::fmi2ModelDescriptionModelStructure # additionals @@ -864,8 +906,8 @@ mutable struct fmi2ModelDescription <: fmiModelDescription parameterValueReferences::Array{fmi2ValueReference} # additional fields (non-FMI-specific) - stringValueReferences::Dict{String, fmi2ValueReference} # String-ValueReference pairs of MD - valueReferenceIndicies::Dict{UInt, UInt} + stringValueReferences::Dict{String,fmi2ValueReference} # String-ValueReference pairs of MD + valueReferenceIndicies::Dict{UInt,UInt} # Constructor for uninitialized struct function fmi2ModelDescription() @@ -875,26 +917,26 @@ mutable struct fmi2ModelDescription <: fmiModelDescription inst.modelName = "" inst.guid = "" - inst.description = nothing - inst.author = nothing - inst.version = nothing - inst.copyright = nothing - inst.license = nothing - inst.generationTool = nothing - inst.generationDateAndTime = nothing - inst.variableNamingConvention = nothing - inst.numberOfEventIndicators = nothing - - inst.unitDefinitions = nothing - inst.typeDefinitions = nothing - inst.logCategories = nothing + inst.description = nothing + inst.author = nothing + inst.version = nothing + inst.copyright = nothing + inst.license = nothing + inst.generationTool = nothing + inst.generationDateAndTime = nothing + inst.variableNamingConvention = nothing + inst.numberOfEventIndicators = nothing + + inst.unitDefinitions = nothing + inst.typeDefinitions = nothing + inst.logCategories = nothing inst.defaultExperiment = nothing - inst.modelExchange = nothing + inst.modelExchange = nothing inst.coSimulation = nothing - + inst.vendorAnnotations = nothing - inst.modelVariables = Array{fmi2ScalarVariable, 1}() + inst.modelVariables = Array{fmi2ScalarVariable,1}() inst.modelStructure = fmi2ModelDescriptionModelStructure() inst.valueReferences = [] @@ -905,21 +947,22 @@ mutable struct fmi2ModelDescription <: fmiModelDescription inst.derivativeValueReferences = [] inst.parameterValueReferences = [] - inst.stringValueReferences = Dict{String, fmi2ValueReference}() - inst.valueReferenceIndicies = Dict{UInt, UInt}() + inst.stringValueReferences = Dict{String,fmi2ValueReference}() + inst.valueReferenceIndicies = Dict{UInt,UInt}() - return inst + return inst end end -export fmi2ModelDescription +export fmi2ModelDescription """ Overload the Base.show() function for custom printing of the fmi2ModelDescription. """ -Base.show(io::IO, desc::fmi2ModelDescription) = print(io, -"Model name: $(desc.modelName) -FMI version: $(desc.fmiVersion) -GUID: $(desc.guid) -Description: $(desc.description) -Model variables: [$(length(desc.modelVariables))]" +Base.show(io::IO, desc::fmi2ModelDescription) = print( + io, + "Model name: $(desc.modelName) + FMI version: $(desc.fmiVersion) + GUID: $(desc.guid) + Description: $(desc.description) + Model variables: [$(length(desc.modelVariables))]", ) diff --git a/src/FMI3/cconst.jl b/src/FMI3/cconst.jl index 1071b93..08ecbd5 100644 --- a/src/FMI3/cconst.jl +++ b/src/FMI3/cconst.jl @@ -194,8 +194,8 @@ fmi3Warning: A non-critical problem was detected, but the computation can contin Source: FMISpec3.0, Version D5ef1c1: 2.2.3. Status Returned by Functions """ -const fmi3StatusWarning = Cuint(1) -export fmi3StatusWarning +const fmi3StatusWarning = Cuint(1) +export fmi3StatusWarning """ fmi3Discard: The call was not successful and the FMU is in the same state as before the call. The output argument values are not defined, but the computation can continue. Function logMessage should be called by the FMU with further information before returning this status, respecting the current logging settings. Advanced simulation algorithms can try alternative approaches to drive the simulation by calling the function with different arguments or calling another function. Otherwise the simulation algorithm has to treat this return code like fmi3Error and has to terminate the simulation. @@ -337,13 +337,18 @@ For variables of type Clock and clocked variables the variability is always disc Added prefix "fmi3" to help with redefinition of constans in enums. """ -const fmi3Variability = Cuint -const fmi3VariabilityConstant = Cuint(0) -const fmi3VariabilityFixed = Cuint(1) -const fmi3VariabilityTunable = Cuint(2) -const fmi3VariabilityDiscrete = Cuint(3) -const fmi3VariabilityContinuous = Cuint(4) -export fmi3Variability, fmi3VariabilityConstant, fmi3VariabilityFixed, fmi3VariabilityTunable, fmi3VariabilityDiscrete, fmi3VariabilityContinuous +const fmi3Variability = Cuint +const fmi3VariabilityConstant = Cuint(0) +const fmi3VariabilityFixed = Cuint(1) +const fmi3VariabilityTunable = Cuint(2) +const fmi3VariabilityDiscrete = Cuint(3) +const fmi3VariabilityContinuous = Cuint(4) +export fmi3Variability, + fmi3VariabilityConstant, + fmi3VariabilityFixed, + fmi3VariabilityTunable, + fmi3VariabilityDiscrete, + fmi3VariabilityContinuous # [ToDo] refactor custom doc-strings for every element """ @@ -367,9 +372,9 @@ If fmi3Set{VariableType} is not called on a variable with causality = input, the Added prefix "fmi3" to help with redefinition of constans in enums. """ -const fmi3Initial = Cuint -const fmi3InitialExact = Cuint(0) -const fmi3InitialApprox = Cuint(1) +const fmi3Initial = Cuint +const fmi3InitialExact = Cuint(0) +const fmi3InitialApprox = Cuint(1) const fmi3InitialCalculated = Cuint(2) export fmi3Initial, fmi3InitialExact, fmi3InitialApprox, fmi3InitialCalculated @@ -402,10 +407,10 @@ Argument fmuType defines the type of the FMU: - fmi3CoSimulation: Black box interface for co-simulation. - fmi3ScheduledExecution: Concurrent computation of model partitions on a single computational resource (e.g. CPU-core) """ -const fmi3Type = Cuint -const fmi3TypeModelExchange = Cuint(0) -const fmi3TypeCoSimulation = Cuint(1) -const fmi3TypeScheduledExecution = Cuint(2) +const fmi3Type = Cuint +const fmi3TypeModelExchange = Cuint(0) +const fmi3TypeCoSimulation = Cuint(1) +const fmi3TypeScheduledExecution = Cuint(2) export fmi3Type, fmi3TypeModelExchange, fmi3TypeCoSimulation, fmi3TypeScheduledExecution # [ToDo] refactor custom doc-strings for every element @@ -418,11 +423,14 @@ fmi3IntervalUnchanged - is returned if a previous call to fmi3GetInterval alread fmi3IntervalChanged - is returned to indicate that the value for the interval has changed for this Clock. Any previously returned intervals (if any) are overwritten with the current value. The new Clock interval is relative to the time of the current Event Mode or Clock Update Mode in contrast to the interval of a periodic Clock, where the interval is defined as the time between consecutive Clock ticks. In Scheduled Execution this means that the corresponding model partition has to be scheduled or re-scheduled (if a previous call to fmi3GetInterval returned fmi3IntervalChanged). """ -const fmi3IntervalQualifier = Cuint -const fmi3IntervalQualifierIntervalNotYetKnown = Cuint(0) -const fmi3IntervalQualifierIntervalUnchanged = Cuint(1) -const fmi3IntervalQualifierIntervalChanged = Cuint(2) -export fmi3IntervalQualifier, fmi3IntervalQualifierIntervalNotYetKnown, fmi3IntervalQualifierIntervalUnchanged, fmi3IntervalQualifierIntervalChanged +const fmi3IntervalQualifier = Cuint +const fmi3IntervalQualifierIntervalNotYetKnown = Cuint(0) +const fmi3IntervalQualifierIntervalUnchanged = Cuint(1) +const fmi3IntervalQualifierIntervalChanged = Cuint(2) +export fmi3IntervalQualifier, + fmi3IntervalQualifierIntervalNotYetKnown, + fmi3IntervalQualifierIntervalUnchanged, + fmi3IntervalQualifierIntervalChanged """ [TODO] @@ -467,12 +475,18 @@ tunable - tunable factor, p⋅v_{known,i} where p is an expression that is evalu discrete - discrete factor, d⋅v_{known,i} where d is an expression that is evaluated before fmi3ExitInitializationMode is called and in Event Mode due to an external or internal event or at a communication point (CS and SE). """ -const fmi3DependencyKind = Cuint +const fmi3DependencyKind = Cuint const fmi3DependencyKindIndependent = Cuint(0) -const fmi3DependencyKindConstant = Cuint(1) -const fmi3DependencyKindFixed = Cuint(2) -const fmi3DependencyKindTunable = Cuint(3) -const fmi3DependencyKindDiscrete = Cuint(4) -const fmi3DependencyKindDependent = Cuint(5) -export fmi3DependencyKind, fmi3DependencyKindIndependent, fmi3DependencyKindConstant, fmi3DependencyKindFixed, fmi3DependencyKindTunable, fmi3DependencyKindDiscrete, fmi3DependencyKindDependent +const fmi3DependencyKindConstant = Cuint(1) +const fmi3DependencyKindFixed = Cuint(2) +const fmi3DependencyKindTunable = Cuint(3) +const fmi3DependencyKindDiscrete = Cuint(4) +const fmi3DependencyKindDependent = Cuint(5) +export fmi3DependencyKind, + fmi3DependencyKindIndependent, + fmi3DependencyKindConstant, + fmi3DependencyKindFixed, + fmi3DependencyKindTunable, + fmi3DependencyKindDiscrete, + fmi3DependencyKindDependent diff --git a/src/FMI3/cfunc.jl b/src/FMI3/cfunc.jl index 256ea5a..3f1b4b1 100644 --- a/src/FMI3/cfunc.jl +++ b/src/FMI3/cfunc.jl @@ -8,24 +8,32 @@ Source: FMISpec3.0, Version D5ef1c1:: 2.3.1. Super State: FMU State Setable This function instantiates a Model Exchange FMU (see Section 3). It is allowed to call this function only if modelDescription.xml includes a element. """ -function fmi3InstantiateModelExchange(cfunc::Ptr{Nothing}, - instanceName::fmi3String, - fmuInstantiationToken::fmi3String, - fmuResourceLocation::fmi3String, - visible::fmi3Boolean, - loggingOn::fmi3Boolean, - instanceEnvironment::fmi3InstanceEnvironment, - logMessage::Ptr{Cvoid}) - - status = ccall(cfunc, - Ptr{Cvoid}, - (Cstring, Cstring, Cstring, - Cuint, Cuint, Ptr{Cvoid}, Ptr{Cvoid}), - instanceName, fmuInstantiationToken, fmuResourceLocation, - visible, loggingOn, instanceEnvironment, logMessage) - - @debug "fmi3InstantiateModelExchange(instanceName: $(instanceName), fmuInstantiationToken: $(fmuInstantiationToken), fmuResourceLocation: $(fmuResourceLocation), visible: $(visible), loggingOn: $(loggingOn)) → $(status)" - return status +function fmi3InstantiateModelExchange( + cfunc::Ptr{Nothing}, + instanceName::fmi3String, + fmuInstantiationToken::fmi3String, + fmuResourceLocation::fmi3String, + visible::fmi3Boolean, + loggingOn::fmi3Boolean, + instanceEnvironment::fmi3InstanceEnvironment, + logMessage::Ptr{Cvoid}, +)::fmi3Instance + + inst = ccall( + cfunc, + fmi3Instance, + (Cstring, Cstring, Cstring, Cuint, Cuint, Ptr{Cvoid}, Ptr{Cvoid}), + instanceName, + fmuInstantiationToken, + fmuResourceLocation, + visible, + loggingOn, + instanceEnvironment, + logMessage, + ) + + @debug "fmi3InstantiateModelExchange(instanceName: $(instanceName), fmuInstantiationToken: $(fmuInstantiationToken), fmuResourceLocation: $(fmuResourceLocation), visible: $(visible), loggingOn: $(loggingOn)) → $(inst)" + return inst end export fmi3InstantiateModelExchange @@ -34,7 +42,8 @@ Source: FMISpec3.0, Version D5ef1c1:: 2.3.1. Super State: FMU State Setable This function instantiates a Co-Simulation FMU (see Section 4). It is allowed to call this function only if modelDescription.xml includes a element. """ -function fmi3InstantiateCoSimulation(cfunc::Ptr{Nothing}, +function fmi3InstantiateCoSimulation( + cfunc::Ptr{Nothing}, instanceName::fmi3String, instantiationToken::fmi3String, resourcePath::fmi3String, @@ -46,18 +55,42 @@ function fmi3InstantiateCoSimulation(cfunc::Ptr{Nothing}, nRequiredIntermediateVariables::Csize_t, instanceEnvironment::fmi3InstanceEnvironment, logMessage::Ptr{Cvoid}, - intermediateUpdate::Ptr{Cvoid}) - - status = ccall(cfunc, - Ptr{Cvoid}, - (Cstring, Cstring, Cstring, - Cint, Cint, Cint, Cint, Ptr{fmi3ValueReference}, Csize_t, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), - instanceName, instantiationToken, resourcePath, - visible, loggingOn, eventModeUsed, earlyReturnAllowed, requiredIntermediateVariables, - nRequiredIntermediateVariables, instanceEnvironment, logMessage, intermediateUpdate) - - @debug "fmi3InstantiateCoSimulation(instanceName: $(instanceName), fmuInstantiationToken: $(fmuInstantiationToken), fmuResourceLocation: $(fmuResourceLocation), visible: $(visible), loggingOn: $(loggingOn)) → $(status)" - return status + intermediateUpdate::Ptr{Cvoid}, +)::fmi3Instance + + inst = ccall( + cfunc, + fmi3Instance, + ( + Cstring, + Cstring, + Cstring, + Cint, + Cint, + Cint, + Cint, + Ptr{fmi3ValueReference}, + Csize_t, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + instanceName, + instantiationToken, + resourcePath, + visible, + loggingOn, + eventModeUsed, + earlyReturnAllowed, + requiredIntermediateVariables, + nRequiredIntermediateVariables, + instanceEnvironment, + logMessage, + intermediateUpdate, + ) + + @debug "fmi3InstantiateCoSimulation(instanceName: $(instanceName), fmuInstantiationToken: $(fmuInstantiationToken), fmuResourceLocation: $(fmuResourceLocation), visible: $(visible), loggingOn: $(loggingOn)) → $(inst)" + return inst end export fmi3InstantiateCoSimulation @@ -67,7 +100,8 @@ Source: FMISpec3.0, Version D5ef1c1:: 2.3.1. Super State: FMU State Setable This function instantiates a Scheduled Execution FMU (see Section 4). It is allowed to call this function only if modelDescription.xml includes a element. """ -function fmi3InstantiateScheduledExecution(cfunc::Ptr{Nothing}, +function fmi3InstantiateScheduledExecution( + cfunc::Ptr{Nothing}, instanceName::fmi3String, instantiationToken::fmi3String, resourcePath::fmi3String, @@ -77,19 +111,46 @@ function fmi3InstantiateScheduledExecution(cfunc::Ptr{Nothing}, logMessage::Ptr{Cvoid}, clockUpdate::Ptr{Cvoid}, lockPreemption::Ptr{Cvoid}, - unlockPreemption::Ptr{Cvoid}) - @assert false "Not tested!" - - status = ccall(cfunc, - Ptr{Cvoid}, - (Cstring, Cstring, Cstring, - Cint, Cint, Cint, Cint, Ptr{fmi3ValueReference}, Csize_t, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}), - instanceName, instantiationToken, resourcePath, - visible, loggingOn, eventModeUsed, earlyReturnAllowed, requiredIntermediateVariables, - nRequiredIntermediateVariables, instanceEnvironment, logMessage, clockUpdate, lockPreemption, unlockPreemption) - - @debug "fmi3InstantiateScheduledExecution(instanceName: $(instanceName), fmuInstantiationToken: $(fmuInstantiationToken), fmuResourceLocation: $(fmuResourceLocation), visible: $(visible), loggingOn: $(loggingOn)) → $(status)" - return status + unlockPreemption::Ptr{Cvoid}, +)::fmi3Instance + + inst = ccall( + cfunc, + fmi3Instance, + ( + Cstring, + Cstring, + Cstring, + Cint, + Cint, + Cint, + Cint, + Ptr{fmi3ValueReference}, + Csize_t, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + Ptr{Cvoid}, + ), + instanceName, + instantiationToken, + resourcePath, + visible, + loggingOn, + eventModeUsed, + earlyReturnAllowed, + requiredIntermediateVariables, + nRequiredIntermediateVariables, + instanceEnvironment, + logMessage, + clockUpdate, + lockPreemption, + unlockPreemption, + ) + + @debug "fmi3InstantiateScheduledExecution(instanceName: $(instanceName), fmuInstantiationToken: $(fmuInstantiationToken), fmuResourceLocation: $(fmuResourceLocation), visible: $(visible), loggingOn: $(loggingOn)) → $(inst)" + return inst end export fmi3InstantiateScheduledExecution @@ -100,7 +161,7 @@ This function returns fmi3Version of the fmi3Functions.h header file which was u The standard header file as documented in this specification has version "3.0-beta.2", so this function returns "3.0-beta.2". """ -function fmi3GetVersion(cfunc::Ptr{Nothing}) +function fmi3GetVersion(cfunc::Ptr{Nothing})::fmi3String str = ccall(cfunc, fmi3String, ()) @debug "fmi3GetVersion() → $(str)" return str @@ -112,7 +173,7 @@ Source: FMISpec3.0, Version D5ef1c1: 2.3.1. Super State: FMU State Setable Disposes the given instance, unloads the loaded model, and frees all the allocated memory and other resources that have been allocated by the functions of the FMU interface. If a NULL pointer is provided for argument instance, the function call is ignored (does not have an effect). """ -function fmi3FreeInstance(cfunc::Ptr{Nothing}, c::fmi3Instance) +function fmi3FreeInstance(cfunc::Ptr{Nothing}, c::fmi3Instance)::Nothing ccall(cfunc, Cvoid, (Ptr{Cvoid},), c) @debug "fmi3FreeInstance(c: $(c)) → [nothing]" @@ -125,11 +186,22 @@ Source: FMISpec3.0, Version D5ef1c1: 2.3.1. Super State: FMU State Setable The function controls debug logging that is output via the logger function callback. If loggingOn = fmi3True, debug logging is enabled, otherwise it is switched off. """ -function fmi3SetDebugLogging(cfunc::Ptr{Nothing}, c::fmi3Instance, logginOn::fmi3Boolean, nCategories::UInt, categories::Ptr{Nothing}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Cint, Csize_t, Ptr{Nothing}), - c, logginOn, nCategories, categories) +function fmi3SetDebugLogging( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + logginOn::fmi3Boolean, + nCategories::UInt, + categories::Ptr{Nothing}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Cint, Csize_t, Ptr{Nothing}), + c, + logginOn, + nCategories, + categories, + ) @debug "fmi3SetDebugLogging(c: $(c), logginOn: $(loggingOn), nCategories: $(nCategories), categories: $(categories)) → $(status)" return status end @@ -141,17 +213,28 @@ Source: FMISpec3.0, Version D5ef1c1: 2.3.2. State: Instantiated Informs the FMU to enter Initialization Mode. Before calling this function, all variables with attribute can be set with the “fmi3SetXXX” functions (the ScalarVariable attributes are defined in the Model Description File, see section 2.4.7). Setting other variables is not allowed. Also sets the simulation start and stop time. """ -function fmi3EnterInitializationMode(cfunc::Ptr{Nothing}, c::fmi3Instance, toleranceDefined::fmi3Boolean, +function fmi3EnterInitializationMode( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + toleranceDefined::fmi3Boolean, tolerance::fmi3Float64, startTime::fmi3Float64, stopTimeDefined::fmi3Boolean, - stopTime::fmi3Float64) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, fmi3Boolean, fmi3Float64, fmi3Float64, fmi3Boolean, fmi3Float64), - c, toleranceDefined, tolerance, startTime, stopTimeDefined, stopTime) - - @debug "fmi3EnterInitializationMode(c: $(c), toleranceDefined: $(toleranceDefined), tolerance: $(tolerance), startTime: $(startTime), stopTimeDefined: $(stopTimeDefined), stopTime: $(stopTime)) → $(status)" + stopTime::fmi3Float64, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, fmi3Boolean, fmi3Float64, fmi3Float64, fmi3Boolean, fmi3Float64), + c, + toleranceDefined, + tolerance, + startTime, + stopTimeDefined, + stopTime, + ) + + @debug "fmi3EnterInitializationMode(c: $(c), toleranceDefined: $(toleranceDefined), tolerance: $(tolerance), startTime: $(startTime), stopTimeDefined: $(stopTimeDefined), stopTime: $(stopTime)) → $(status)" return status end export fmi3EnterInitializationMode @@ -161,13 +244,10 @@ Source: FMISpec3.0, Version D5ef1c1: 2.3.3. State: Initialization Mode Informs the FMU to exit Initialization Mode. """ -function fmi3ExitInitializationMode(cfunc::Ptr{Nothing}, c::fmi3Instance) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,), - c) - - @debug "fmi3ExitInitializationMode(c: $(c)) → $(status)" +function fmi3ExitInitializationMode(cfunc::Ptr{Nothing}, c::fmi3Instance)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance,), c) + + @debug "fmi3ExitInitializationMode(c: $(c)) → $(status)" return status end export fmi3ExitInitializationMode @@ -177,9 +257,9 @@ Source: FMISpec3.0, Version D5ef1c1: 2.3.4. Super State: Initialized Informs the FMU that the simulation run is terminated. """ -function fmi3Terminate(cfunc::Ptr{Nothing}, c::fmi3Instance) +function fmi3Terminate(cfunc::Ptr{Nothing}, c::fmi3Instance)::fmi3Status status = ccall(cfunc, fmi3Status, (fmi3Instance,), c) - @debug "fmi3Terminate(c: $(c)) → $(status)" + @debug "fmi3Terminate(c: $(c)) → $(status)" return status end export fmi3Terminate @@ -189,9 +269,9 @@ Source: FMISpec3.0, Version D5ef1c1: 2.3.1. Super State: FMU State Setable Is called by the environment to reset the FMU after a simulation run. The FMU goes into the same state as if fmi3InstantiateXXX would have been called. """ -function fmi3Reset(cfunc::Ptr{Nothing}, c::fmi3Instance) +function fmi3Reset(cfunc::Ptr{Nothing}, c::fmi3Instance)::fmi3Status status = ccall(cfunc, fmi3Status, (fmi3Instance,), c) - @debug "fmi3Reset(c: $(c)) → $(status)" + @debug "fmi3Reset(c: $(c)) → $(status)" return status end export fmi3Reset @@ -204,12 +284,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetFloat32!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Float32}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float32}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetFloat32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetFloat32!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Float32}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float32}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetFloat32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetFloat32! @@ -221,12 +314,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetFloat32(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Float32}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float32}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetFloat32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetFloat32( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Float32}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float32}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetFloat32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetFloat32 @@ -238,12 +344,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetFloat64!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Float64}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float64}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetFloat64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetFloat64!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Float64}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float64}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetFloat64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetFloat64! @@ -255,12 +374,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetFloat64(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Float64}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float64}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetFloat64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetFloat64( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Float64}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float64}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetFloat64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetFloat64 @@ -273,12 +405,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetInt8!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Int8}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int8}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetInt8(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetInt8!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Int8}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int8}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetInt8(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetInt8! @@ -290,12 +435,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetInt8(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Int8}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int8}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetInt8(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetInt8( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Int8}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int8}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetInt8(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetInt8 @@ -308,12 +466,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetUInt8!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3UInt8}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt8}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetUInt8(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetUInt8!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3UInt8}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt8}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetUInt8(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetUInt8! @@ -325,12 +496,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetUInt8(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3UInt8}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt8}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetUInt8(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetUInt8( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3UInt8}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt8}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetUInt8(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetUInt8 @@ -343,12 +527,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetInt16!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Int16}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int16}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetInt16(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetInt16!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Int16}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int16}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetInt16(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetInt16! @@ -360,12 +557,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetInt16(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Int16}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int16}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetInt16(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetInt16( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Int16}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int16}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetInt16(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetInt16 @@ -378,12 +588,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetUInt16!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3UInt16}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt16}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetUInt16(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetUInt16!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3UInt16}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt16}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetUInt16(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetUInt16! @@ -395,12 +618,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetUInt16(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3UInt16}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt16}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetUInt16(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetUInt16( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3UInt16}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt16}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetUInt16(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetUInt16 @@ -412,12 +648,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetInt32!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Int32}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int32}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetInt32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetInt32!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Int32}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int32}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetInt32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetInt32! @@ -429,12 +678,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetInt32(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Int32}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int32}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetInt32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetInt32( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Int32}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int32}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetInt32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetInt32 @@ -447,12 +709,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetUInt32!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3UInt32}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt32}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetUInt32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetUInt32!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3UInt32}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt32}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetUInt32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetUInt32! @@ -464,12 +739,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetUInt32(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3UInt32}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt32}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetUInt32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetUInt32( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3UInt32}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt32}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetUInt32(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetUInt32 @@ -482,12 +770,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetInt64!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Int64}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int64}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetInt64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetInt64!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Int64}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int64}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetInt64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetInt64! @@ -499,12 +800,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetInt64(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Int64}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int64}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetInt64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetInt64( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Int64}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int64}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetInt64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetInt64 @@ -517,12 +831,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetUInt64!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3UInt64}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt64}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetUInt64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetUInt64!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3UInt64}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt64}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetUInt64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetUInt64! @@ -534,12 +861,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetUInt64(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3UInt64}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt64}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetUInt64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetUInt64( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3UInt64}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt64}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetUInt64(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetUInt64 @@ -551,12 +891,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetBoolean!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Boolean}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Boolean}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetBoolean(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetBoolean!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Boolean}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Boolean}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetBoolean(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetBoolean! @@ -568,12 +921,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetBoolean(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Boolean}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Boolean}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetBoolean(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetBoolean( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Boolean}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Boolean}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetBoolean(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetBoolean @@ -586,12 +952,25 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetString!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{Ptr{Cchar}}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{Cchar}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3GetString(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetString!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{Ptr{Cchar}}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{Cchar}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3GetString(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetString! @@ -602,13 +981,26 @@ Source: FMISpec3.0, Version D5ef1c1: 2.2.6.2. Getting and Setting Variable Value Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. -""" -function fmi3SetString(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::Union{AbstractArray{Ptr{Cchar}}, AbstractArray{Ptr{UInt8}}}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{Cchar}, Csize_t), - c, vr, nvr, value, nvalue) - @debug "fmi3SetString(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +""" +function fmi3SetString( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::Union{AbstractArray{Ptr{Cchar}},AbstractArray{Ptr{UInt8}}}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{Cchar}, Csize_t), + c, + vr, + nvr, + value, + nvalue, + ) + @debug "fmi3SetString(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetString @@ -620,12 +1012,34 @@ Functions to get and set values of variables idetified by their valueReference. nValues - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetBinary!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, valueSizes::AbstractArray{Csize_t}, value::AbstractArray{fmi3Binary}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{Csize_t}, Ptr{fmi3Binary}, Csize_t), - c, vr, nvr, valueSizes, value, nvalue) - @debug "fmi3GetBinary(c: $(c), vr: $(vr), nvr: $(nvr), valueSizes: $(valueSizes), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetBinary!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + valueSizes::AbstractArray{Csize_t}, + value::AbstractArray{fmi3Binary}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + ( + fmi3Instance, + Ptr{fmi3ValueReference}, + Csize_t, + Ptr{Csize_t}, + Ptr{fmi3Binary}, + Csize_t, + ), + c, + vr, + nvr, + valueSizes, + value, + nvalue, + ) + @debug "fmi3GetBinary(c: $(c), vr: $(vr), nvr: $(nvr), valueSizes: $(valueSizes), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetBinary! @@ -637,12 +1051,34 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetBinary(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, valueSizes::AbstractArray{Csize_t}, value::AbstractArray{fmi3Binary}, nvalue::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{Csize_t}, Ptr{fmi3Binary}, Csize_t), - c, vr, nvr, valueSizes, value, nvalue) - @debug "fmi3SetBinary(c: $(c), vr: $(vr), nvr: $(nvr), valueSizes: $(valueSizes), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetBinary( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + valueSizes::AbstractArray{Csize_t}, + value::AbstractArray{fmi3Binary}, + nvalue::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + ( + fmi3Instance, + Ptr{fmi3ValueReference}, + Csize_t, + Ptr{Csize_t}, + Ptr{fmi3Binary}, + Csize_t, + ), + c, + vr, + nvr, + valueSizes, + value, + nvalue, + ) + @debug "fmi3SetBinary(c: $(c), vr: $(vr), nvr: $(nvr), valueSizes: $(valueSizes), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetBinary @@ -655,12 +1091,23 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3GetClock!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Clock}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Clock}), - c, vr, nvr, value) - @debug "fmi3GetClock(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3GetClock!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Clock}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Clock}), + c, + vr, + nvr, + value, + ) + @debug "fmi3GetClock(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3GetClock! @@ -672,12 +1119,23 @@ Functions to get and set values of variables idetified by their valueReference. nValue - is different from nvr if the value reference represents an array and therefore are more values tied to a single value reference. """ -function fmi3SetClock(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Clock}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Clock}), - c, vr, nvr, value) - @debug "fmi3SetClock(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" +function fmi3SetClock( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + value::AbstractArray{fmi3Clock}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Clock}), + c, + vr, + nvr, + value, + ) + @debug "fmi3SetClock(c: $(c), vr: $(vr), nvr: $(nvr), value: $(value), nvalue: $(nvalue)) → $(status)" return status end export fmi3SetClock @@ -687,11 +1145,12 @@ Source: FMISpec3.0, Version D5ef1c1: 2.2.6.4. Getting and Setting the Complete F fmi3GetFMUstate makes a copy of the internal FMU state and returns a pointer to this copy """ -function fmi3GetFMUState!(cfunc::Ptr{Nothing}, c::fmi3Instance, FMUstate::Ref{fmi3FMUState}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3FMUState}), - c, FMUstate) +function fmi3GetFMUState!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + FMUstate::Ref{fmi3FMUState}, +)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance, Ptr{fmi3FMUState}), c, FMUstate) @debug "fmi3GetFMUState!(c: $(c), FMUstate: $(FMUstate)) → $(status)" return status end @@ -702,11 +1161,12 @@ Source: FMISpec3.0, Version D5ef1c1: 2.2.6.4. Getting and Setting the Complete F fmi3SetFMUstate copies the content of the previously copied FMUstate back and uses it as actual new FMU state. """ -function fmi3SetFMUState(cfunc::Ptr{Nothing}, c::fmi3Instance, FMUstate::fmi3FMUState) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, fmi3FMUState), - c, FMUstate) +function fmi3SetFMUState( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + FMUstate::fmi3FMUState, +)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance, fmi3FMUState), c, FMUstate) @debug "fmi3SetFMUState!(c: $(c), FMUstate: $(FMUstate)) → $(status)" return status end @@ -717,11 +1177,12 @@ Source: FMISpec3.0, Version D5ef1c1: 2.2.6.4. Getting and Setting the Complete F fmi3FreeFMUstate frees all memory and other resources allocated with the fmi3GetFMUstate call for this FMUstate. """ -function fmi3FreeFMUState(cfunc::Ptr{Nothing}, c::fmi3Instance, FMUstate::Ref{fmi3FMUState}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3FMUState}), - c, FMUstate) +function fmi3FreeFMUState( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + FMUstate::Ref{fmi3FMUState}, +)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance, Ptr{fmi3FMUState}), c, FMUstate) @debug "fmi3FreeFMUState!(c: $(c), FMUstate: $(FMUstate)) → $(status)" return status end @@ -732,11 +1193,20 @@ Source: FMISpec3.0, Version D5ef1c1: 2.2.6.4. Getting and Setting the Complete F fmi3SerializedFMUstateSize returns the size of the byte vector which is needed to store FMUstate in it. """ -function fmi3SerializedFMUStateSize!(cfunc::Ptr{Nothing}, c::fmi3Instance, FMUstate::fmi3FMUState, size::Ref{Csize_t}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{Cvoid}, Ptr{Csize_t}), - c, FMUstate, size) +function fmi3SerializedFMUStateSize!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + FMUstate::fmi3FMUState, + size::Ref{Csize_t}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{Cvoid}, Ptr{Csize_t}), + c, + FMUstate, + size, + ) @debug "fmi3SerializedFMUStateSize(c: $(c), FMUstate: $(FMUstate), size: $(size)) → $(status)" return status end @@ -747,11 +1217,22 @@ Source: FMISpec3.0, Version D5ef1c1: 2.2.6.4. Getting and Setting the Complete F fmi3SerializeFMUstate serializes the data which is referenced by pointer FMUstate and copies this data in to the byte vector serializedState of length size """ -function fmi3SerializeFMUState!(cfunc::Ptr{Nothing}, c::fmi3Instance, FMUstate::fmi3FMUState, serialzedState::AbstractArray{fmi3Byte}, size::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{Cvoid}, Ptr{Cchar}, Csize_t), - c, FMUstate, serialzedState, size) +function fmi3SerializeFMUState!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + FMUstate::fmi3FMUState, + serialzedState::AbstractArray{fmi3Byte}, + size::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{Cvoid}, Ptr{Cchar}, Csize_t), + c, + FMUstate, + serialzedState, + size, + ) @debug "fmi3SerializeFMUState(c: $(c), FMUstate: $(FMUstate), serialzedState: $(serializedState), size: $(size)) → $(status)" return status end @@ -762,11 +1243,22 @@ Source: FMISpec3.0, Version D5ef1c1: 2.2.6.4. Getting and Setting the Complete F fmi3DeSerializeFMUstate deserializes the byte vector serializedState of length size, constructs a copy of the FMU state and returns FMUstate, the pointer to this copy. """ -function fmi3DeSerializeFMUState!(cfunc::Ptr{Nothing}, c::fmi3Instance, serialzedState::AbstractArray{fmi3Byte}, size::Csize_t, FMUstate::Ref{fmi3FMUState}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{Cchar}, Csize_t, Ptr{fmi3FMUState}), - c, serialzedState, size, FMUstate) +function fmi3DeSerializeFMUState!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + serialzedState::AbstractArray{fmi3Byte}, + size::Csize_t, + FMUstate::Ref{fmi3FMUState}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{Cchar}, Csize_t, Ptr{fmi3FMUState}), + c, + serialzedState, + size, + FMUstate, + ) @debug "fmi3DeSerializeFMUState(c: $(c), serializedState: $(serializedState), size: $(size), FMUstate: $(FMUstate)) → $(status)" return status end @@ -779,11 +1271,22 @@ fmi3SetIntervalDecimal sets the interval until the next clock tick """ # TODO: Clocks and dependencies functions # ToDo: Function is untested! -function fmi3SetIntervalDecimal(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, intervals::AbstractArray{fmi3Float64}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float64}), - c, vr, nvr, intervals) +function fmi3SetIntervalDecimal( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + intervals::AbstractArray{fmi3Float64}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float64}), + c, + vr, + nvr, + intervals, + ) @debug "fmi3SetIntervalDecimal(c: $(c), vr: $(vr), nvr: $(nvr), intervals: $(intervals)) → $(status)" return status end @@ -796,11 +1299,24 @@ fmi3SetIntervalFraction sets the interval until the next clock tick Only allowed if the attribute 'supportsFraction' is set. """ # ToDo: Function is untested! -function fmi3SetIntervalFraction(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, intervalCounters::AbstractArray{fmi3UInt64}, resolutions::AbstractArray{fmi3UInt64}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt64}, Ptr{fmi3UInt64}), - c, vr, nvr, intervalCounters, resolutions) +function fmi3SetIntervalFraction( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + intervalCounters::AbstractArray{fmi3UInt64}, + resolutions::AbstractArray{fmi3UInt64}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt64}, Ptr{fmi3UInt64}), + c, + vr, + nvr, + intervalCounters, + resolutions, + ) @debug "fmi3SetIntervalFraction(c: $(c), vr: $(vr), nvr: $(nvr), intervalCounters: $(intervalCounters), resolutions: $(resolutions)) → $(status)" return status end @@ -818,11 +1334,30 @@ Clock intervals are computed in fmi3UpdateDiscreteStates (at the latest), theref For information about fmi3IntervalQualifiers, call ?fmi3IntervalQualifier """ # ToDo: Function is untested! -function fmi3GetIntervalDecimal!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, intervals::AbstractArray{fmi3Float64}, qualifiers::fmi3IntervalQualifier) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float64}, Ptr{fmi3IntervalQualifier}), - c, vr, nvr, intervals, qualifiers) +function fmi3GetIntervalDecimal!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + intervals::AbstractArray{fmi3Float64}, + qualifiers::fmi3IntervalQualifier, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + ( + fmi3Instance, + Ptr{fmi3ValueReference}, + Csize_t, + Ptr{fmi3Float64}, + Ptr{fmi3IntervalQualifier}, + ), + c, + vr, + nvr, + intervals, + qualifiers, + ) @debug "fmi3GetIntervalDecimal(c: $(c), vr: $(vr), nvr: $(nvr), intervals: $(intervals), qualifiers: $(qualifiers)) → $(status)" return status end @@ -840,11 +1375,33 @@ Clock intervals are computed in fmi3UpdateDiscreteStates (at the latest), theref For information about fmi3IntervalQualifiers, call ?fmi3IntervalQualifier """ # ToDo: Function is untested! -function fmi3GetIntervalFraction!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, intervalCounters::AbstractArray{fmi3UInt64}, resolutions::AbstractArray{fmi3UInt64}, qualifiers::fmi3IntervalQualifier) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt64}, Ptr{fmi3UInt64}, Ptr{fmi3IntervalQualifier}), - c, vr, nvr, intervalCounters, resolutions, qualifiers) +function fmi3GetIntervalFraction!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + intervalCounters::AbstractArray{fmi3UInt64}, + resolutions::AbstractArray{fmi3UInt64}, + qualifiers::fmi3IntervalQualifier, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + ( + fmi3Instance, + Ptr{fmi3ValueReference}, + Csize_t, + Ptr{fmi3UInt64}, + Ptr{fmi3UInt64}, + Ptr{fmi3IntervalQualifier}, + ), + c, + vr, + nvr, + intervalCounters, + resolutions, + qualifiers, + ) @debug "fmi3GetIntervalFraction(c: $(c), vr: $(vr), nvr: $(nvr), intervalCounters: $(intervalCounters), resolutions: $(resolutions), qualifiers: $(qualifiers)) → $(status)" return status end @@ -856,11 +1413,22 @@ Source: FMISpec3.0, Version D5ef1c1: 2.2.9. Clocks fmi3GetShiftDecimal retrieves the delay to the first Clock tick from the FMU. """ # ToDo: Function is untested! -function fmi3GetShiftDecimal!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, shifts::AbstractArray{fmi3Float64}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float64}), - c, vr, nvr, shifts) +function fmi3GetShiftDecimal!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + shifts::AbstractArray{fmi3Float64}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float64}), + c, + vr, + nvr, + shifts, + ) @debug "fmi3GetShiftDecimal(c: $(c), vr: $(vr), nvr: $(nvr), shifts: $(shifts)) → $(status)" return status end @@ -872,11 +1440,24 @@ Source: FMISpec3.0, Version D5ef1c1: 2.2.9. Clocks fmi3GetShiftFraction retrieves the delay to the first Clock tick from the FMU. """ # ToDo: Function is untested! -function fmi3GetShiftFraction!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, shiftCounters::AbstractArray{fmi3UInt64}, resolutions::AbstractArray{fmi3UInt64}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt64}, Ptr{fmi3UInt64}), - c, vr, nvr, shiftCounters, resolutions) +function fmi3GetShiftFraction!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nvr::Csize_t, + shiftCounters::AbstractArray{fmi3UInt64}, + resolutions::AbstractArray{fmi3UInt64}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3UInt64}, Ptr{fmi3UInt64}), + c, + vr, + nvr, + shiftCounters, + resolutions, + ) @debug "fmi3GetShiftFraction(c: $(c), vr: $(vr), nvr: $(nvr), shiftCounters: $(shiftCounters), resolutions: $(resolutions)) → $(status)" return status end @@ -890,11 +1471,20 @@ During Clock Activation Mode (see 5.2.2.) after fmi3ActivateModelPartition has b Each fmi3ActivateModelPartition call is associated with the computation of an exposed model partition of the FMU and therefore to an input Clock. """ # ToDo: Function is untested! -function fmi3ActivateModelPartition(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::fmi3ValueReference, activationTime::AbstractArray{fmi3Float64}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, fmi3ValueReference, Ptr{fmi3Float64}), - c, vr, activationTime) +function fmi3ActivateModelPartition( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::fmi3ValueReference, + activationTime::AbstractArray{fmi3Float64}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, fmi3ValueReference, Ptr{fmi3Float64}), + c, + vr, + activationTime, + ) @debug "fmi3ActiveModelPartition(c: $(c), vr: $(vr), activationTime $(activationTime)) → $(status)" return status end @@ -908,11 +1498,20 @@ The number of dependencies of a given variable, which may change if structural p This information can only be retrieved if the 'providesPerElementDependencies' tag in the ModelDescription is set. """ # ToDo: Function is untested! -function fmi3GetNumberOfVariableDependencies!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::fmi3ValueReference, nvr::Ref{Csize_t}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, fmi3ValueReference, Ptr{Csize_t}), - c, vr, nvr) +function fmi3GetNumberOfVariableDependencies!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::fmi3ValueReference, + nvr::Ref{Csize_t}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, fmi3ValueReference, Ptr{Csize_t}), + c, + vr, + nvr, + ) @debug "fmi3GetNumberOfVariableDependencies(c: $(c), vr: $(vr), nvr: $(nvr)) → $(status)" return status end @@ -946,11 +1545,36 @@ The retrieved dependency information of one variable becomes invalid as soon as This information can only be retrieved if the 'providesPerElementDependencies' tag in the ModelDescription is set. """ # ToDo: Function is untested! -function fmi3GetVariableDependencies!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::fmi3ValueReference, elementIndiceOfDependents::AbstractArray{Csize_t}, independents::AbstractArray{fmi3ValueReference}, elementIndiceOfInpendents::AbstractArray{Csize_t}, dependencyKind::AbstractArray{fmi3DependencyKind}, ndependencies::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, fmi3ValueReference, Ptr{Csize_t}, Ptr{fmi3ValueReference}, Ptr{Csize_t}, Ptr{fmi3DependencyKind}, Csize_t), - c, vr, elementIndiceOfDependents, independents, elementIndiceOfInpendents, dependencyKind, ndependencies) +function fmi3GetVariableDependencies!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::fmi3ValueReference, + elementIndiceOfDependents::AbstractArray{Csize_t}, + independents::AbstractArray{fmi3ValueReference}, + elementIndiceOfInpendents::AbstractArray{Csize_t}, + dependencyKind::AbstractArray{fmi3DependencyKind}, + ndependencies::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + ( + fmi3Instance, + fmi3ValueReference, + Ptr{Csize_t}, + Ptr{fmi3ValueReference}, + Ptr{Csize_t}, + Ptr{fmi3DependencyKind}, + Csize_t, + ), + c, + vr, + elementIndiceOfDependents, + independents, + elementIndiceOfInpendents, + dependencyKind, + ndependencies, + ) @debug "fmi3GetVariableDependencies(c: $(c), vr: $(vr), elementIndiceOfDependets: $(elementIndiceOfDependets), independents: $(independents), elementIndiceOfInpendents: $(elementIndiceOfInpendents), dependencyKind: $(dependencyKind), ndependencies: $(ndependencies)) → $(status)" return status end @@ -980,20 +1604,43 @@ nSensitivity - contains the length of sensitivity. This function can only be called if the 'ProvidesDirectionalDerivatives' tag in the ModelDescription is set. """ -function fmi3GetDirectionalDerivative!(cfunc::Ptr{Nothing}, c::fmi3Instance, - unknowns::AbstractArray{fmi3ValueReference}, - nUnknowns::Csize_t, - knowns::AbstractArray{fmi3ValueReference}, - nKnowns::Csize_t, - seed::AbstractArray{fmi3Float64}, - nSeed::Csize_t, - sensitivity::AbstractArray{fmi3Float64}, - nSensitivity::Csize_t) - - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float64}, Csize_t, Ptr{fmi3Float64}, Csize_t), - c, unknowns, nUnknowns, knowns, nKnowns, seed, nSeed, sensitivity, nSensitivity) +function fmi3GetDirectionalDerivative!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + unknowns::AbstractArray{fmi3ValueReference}, + nUnknowns::Csize_t, + knowns::AbstractArray{fmi3ValueReference}, + nKnowns::Csize_t, + seed::AbstractArray{fmi3Float64}, + nSeed::Csize_t, + sensitivity::AbstractArray{fmi3Float64}, + nSensitivity::Csize_t, +)::fmi3Status + + status = ccall( + cfunc, + fmi3Status, + ( + fmi3Instance, + Ptr{fmi3ValueReference}, + Csize_t, + Ptr{fmi3ValueReference}, + Csize_t, + Ptr{fmi3Float64}, + Csize_t, + Ptr{fmi3Float64}, + Csize_t, + ), + c, + unknowns, + nUnknowns, + knowns, + nKnowns, + seed, + nSeed, + sensitivity, + nSensitivity, + ) @debug "fmi3GetDirectionalDerivative(c: $(c), unknowns: $(unknowns), nUnknowns: $(nUnknowns), knowns: $(knowns), nKnowns: $(nKnowns), seed: $(seed), nSeed: $(nSeed), sensitivity: $(sensitivity), nSensitivity: $(nSensitivity)) → $(status)" return status end @@ -1023,20 +1670,45 @@ nSensitivity - contains the length of sensitivity. This function can only be called if the 'ProvidesAdjointDerivatives' tag in the ModelDescription is set. """ -function fmi3GetAdjointDerivative!(cfunc::Ptr{Nothing}, c::fmi3Instance, - unknowns::AbstractArray{fmi3ValueReference}, - nUnknowns::Csize_t, - knowns::AbstractArray{fmi3ValueReference}, - nKnowns::Csize_t, - seed::AbstractArray{fmi3Float64}, - nSeed::Csize_t, - sensitivity::AbstractArray{fmi3Float64}, - nSensitivity::Csize_t) - @assert fmi3ProvidesAdjointDerivatives(c.fmu) ["fmi3GetAdjointDerivative!(...): This FMU does not support build-in adjoint derivatives!"] - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Float64}, Csize_t, Ptr{fmi3Float64}, Csize_t), - c, unknowns, nUnknowns, knowns, nKnowns, seed, nSeed, sensitivity, nSensitivity) +function fmi3GetAdjointDerivative!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + unknowns::AbstractArray{fmi3ValueReference}, + nUnknowns::Csize_t, + knowns::AbstractArray{fmi3ValueReference}, + nKnowns::Csize_t, + seed::AbstractArray{fmi3Float64}, + nSeed::Csize_t, + sensitivity::AbstractArray{fmi3Float64}, + nSensitivity::Csize_t, +)::fmi3Status + @assert fmi3ProvidesAdjointDerivatives(c.fmu) [ + "fmi3GetAdjointDerivative!(...): This FMU does not support build-in adjoint derivatives!", + ] + status = ccall( + cfunc, + fmi3Status, + ( + fmi3Instance, + Ptr{fmi3ValueReference}, + Csize_t, + Ptr{fmi3ValueReference}, + Csize_t, + Ptr{fmi3Float64}, + Csize_t, + Ptr{fmi3Float64}, + Csize_t, + ), + c, + unknowns, + nUnknowns, + knowns, + nKnowns, + seed, + nSeed, + sensitivity, + nSensitivity, + ) @debug "fmi3GetAdjointDerivative(c: $(c), unknowns: $(unknowns), nUnknowns: $(nUnknowns), knowns: $(knowns), nKnowns: $(nKnowns), seed: $(seed), nSeed: $(nSeed), sensitivity: $(sensitivity), nSensitivity: $(nSensitivity)) → $(status)" return status end @@ -1059,11 +1731,33 @@ values - is a vector with the values of the derivatives. The order of the values nValues - is the size of the argument values. nValues only equals nValueReferences if all corresponding output variables are scalar variables. """ -function fmi3GetOutputDerivatives!(cfunc::Ptr{Nothing}, c::fmi3Instance, vr::AbstractArray{fmi3ValueReference}, nValueReferences::Csize_t, order::AbstractArray{fmi3Int32}, values::AbstractArray{fmi3Float64}, nValues::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3ValueReference}, Csize_t, Ptr{fmi3Int32}, Ptr{fmi3Float64}, Csize_t), - c, vr, nValueReferences, order, values, nValues) +function fmi3GetOutputDerivatives!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + vr::AbstractArray{fmi3ValueReference}, + nValueReferences::Csize_t, + order::AbstractArray{fmi3Int32}, + values::AbstractArray{fmi3Float64}, + nValues::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + ( + fmi3Instance, + Ptr{fmi3ValueReference}, + Csize_t, + Ptr{fmi3Int32}, + Ptr{fmi3Float64}, + Csize_t, + ), + c, + vr, + nValueReferences, + order, + values, + nValues, + ) @debug "fmi3GetOutputDerivatives(c: $(c), vr: $(vr), nValueReferences: $(nValueReferences), order: $(order), value: $(value), nValues: $(nValues)) → $(status)" return status end @@ -1074,11 +1768,8 @@ Source: FMISpec3.0, Version D5ef1c1: 2.3.2. State: Instantiated If the importer needs to change structural parameters, it must move the FMU into Configuration Mode using fmi3EnterConfigurationMode. """ -function fmi3EnterConfigurationMode(cfunc::Ptr{Nothing}, c::fmi3Instance) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,), - c) +function fmi3EnterConfigurationMode(cfunc::Ptr{Nothing}, c::fmi3Instance)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance,), c) @debug "fmi3EnterConfigurationMode(c: $(c)) → $(status)" return status end @@ -1089,11 +1780,8 @@ Source: FMISpec3.0, Version D5ef1c1: 2.3.6. State: Configuration Mode Exits the Configuration Mode and returns to state Instantiated. """ -function fmi3ExitConfigurationMode(cfunc::Ptr{Nothing}, c::fmi3Instance) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,), - c) +function fmi3ExitConfigurationMode(cfunc::Ptr{Nothing}, c::fmi3Instance)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance,), c) @debug "fmi3ExitConfigurationMode(c: $(c)) → $(status)" return status end @@ -1107,11 +1795,12 @@ This function can only be called in Model Exchange. fmi3GetNumberOfContinuousStates must be called after a structural parameter is changed. As long as no structural parameters changed, the number of states is given in the modelDescription.xml, alleviating the need to call this function. """ -function fmi3GetNumberOfContinuousStates!(cfunc::Ptr{Nothing}, c::fmi3Instance, nContinuousStates::Ref{Csize_t}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{Csize_t}), - c, nContinuousStates) +function fmi3GetNumberOfContinuousStates!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + nContinuousStates::Ref{Csize_t}, +)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance, Ptr{Csize_t}), c, nContinuousStates) @debug "fmi3GetNumberOfContinuousStates(c: $(c), nContinuousStates: $(nContinuousStates)) → $(status)" return status end @@ -1125,11 +1814,12 @@ This function can only be called in Model Exchange. fmi3GetNumberOfEventIndicators must be called after a structural parameter is changed. As long as no structural parameters changed, the number of states is given in the modelDescription.xml, alleviating the need to call this function. """ -function fmi3GetNumberOfEventIndicators!(cfunc::Ptr{Nothing}, c::fmi3Instance, nEventIndicators::Ref{Csize_t}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{Csize_t}), - c, nEventIndicators) +function fmi3GetNumberOfEventIndicators!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + nEventIndicators::Ref{Csize_t}, +)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance, Ptr{Csize_t}), c, nEventIndicators) @debug "fmi3GetNumberOfEventIndicators(c: $(c), nEventIndicators: $(nEventIndicators)) → $(status)" return status end @@ -1142,11 +1832,20 @@ Return the states at the current time instant. This function must be called if fmi3UpdateDiscreteStates returned with valuesOfContinuousStatesChanged == fmi3True. Not allowed in Co-Simulation and Scheduled Execution. """ -function fmi3GetContinuousStates!(cfunc::Ptr{Nothing}, c::fmi3Instance, nominals::AbstractArray{fmi3Float64}, nContinuousStates::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3Float64}, Csize_t), - c, nominals, nContinuousStates) +function fmi3GetContinuousStates!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + nominals::AbstractArray{fmi3Float64}, + nContinuousStates::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3Float64}, Csize_t), + c, + nominals, + nContinuousStates, + ) @debug "fmi3GetContinuousStates(c: $(c), nominals: $(nominals), nContinuousStates: $(nContinuousStates)) → $(status)" return status end @@ -1160,11 +1859,20 @@ Return the nominal values of the continuous states. If fmi3UpdateDiscreteStates returned with nominalsOfContinuousStatesChanged == fmi3True, then at least one nominal value of the states has changed and can be inquired with fmi3GetNominalsOfContinuousStates. Not allowed in Co-Simulation and Scheduled Execution. """ -function fmi3GetNominalsOfContinuousStates!(cfunc::Ptr{Nothing}, c::fmi3Instance, x_nominal::AbstractArray{fmi3Float64}, nx::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3Float64}, Csize_t), - c, x_nominal, nx) +function fmi3GetNominalsOfContinuousStates!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + x_nominal::AbstractArray{fmi3Float64}, + nx::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3Float64}, Csize_t), + c, + x_nominal, + nx, + ) @debug "fmi3GetNominalsOfContinuousStates(c: $(c), x_nominal: $(x_nominal), nx: $(nx)) → $(status)" return status end @@ -1177,11 +1885,8 @@ Source: FMISpec3.0, Version D5ef1c1: 2.3.3. State: Initialization Mode This function is called to trigger the evaluation of fdisc to compute the current values of discrete states from previous values. The FMU signals the support of fmi3EvaluateDiscreteStates via the capability flag providesEvaluateDiscreteStates. """ -function fmi3EvaluateDiscreteStates(cfunc::Ptr{Nothing}, c::fmi3Instance) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,), - c) +function fmi3EvaluateDiscreteStates(cfunc::Ptr{Nothing}, c::fmi3Instance)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance,), c) @debug "fmi3EvaluateDiscreteStates(c: $(c)) → $(status)" return status end @@ -1192,13 +1897,36 @@ Source: FMISpec3.0, Version D5ef1c1: 2.3.5. State: Event Mode This function is called to signal a converged solution at the current super-dense time instant. fmi3UpdateDiscreteStates must be called at least once per super-dense time instant. """ -function fmi3UpdateDiscreteStates(cfunc::Ptr{Nothing}, c::fmi3Instance, discreteStatesNeedUpdate::Ref{fmi3Boolean}, terminateSimulation::Ref{fmi3Boolean}, - nominalsOfContinuousStatesChanged::Ref{fmi3Boolean}, valuesOfContinuousStatesChanged::Ref{fmi3Boolean}, - nextEventTimeDefined::Ref{fmi3Boolean}, nextEventTime::Ref{fmi3Float64}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3Boolean}, Ptr{fmi3Boolean}, Ptr{fmi3Boolean}, Ptr{fmi3Boolean}, Ptr{fmi3Boolean}, Ptr{fmi3Float64}), - c, discreteStatesNeedUpdate, terminateSimulation, nominalsOfContinuousStatesChanged, valuesOfContinuousStatesChanged, nextEventTimeDefined, nextEventTime) +function fmi3UpdateDiscreteStates( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + discreteStatesNeedUpdate::Ref{fmi3Boolean}, + terminateSimulation::Ref{fmi3Boolean}, + nominalsOfContinuousStatesChanged::Ref{fmi3Boolean}, + valuesOfContinuousStatesChanged::Ref{fmi3Boolean}, + nextEventTimeDefined::Ref{fmi3Boolean}, + nextEventTime::Ref{fmi3Float64}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + ( + fmi3Instance, + Ptr{fmi3Boolean}, + Ptr{fmi3Boolean}, + Ptr{fmi3Boolean}, + Ptr{fmi3Boolean}, + Ptr{fmi3Boolean}, + Ptr{fmi3Float64}, + ), + c, + discreteStatesNeedUpdate, + terminateSimulation, + nominalsOfContinuousStatesChanged, + valuesOfContinuousStatesChanged, + nextEventTimeDefined, + nextEventTime, + ) @debug "fmi3UpdateDiscreteStates(c: $(c), discreteStatesNeedUpdate: $(discreteStatesNeedUpdate), terminateSimulation: $(terminateSimulation), nominalsOfContinuousStatesChanged: $(nominalsOfContinuousStatesChanged), valuesOfContinuousStatesChanged: $(valuesOfContinuousStatesChanged), nextEventTimeDefined: $(nextEventTimeDefined), nextEventTime: $(nextEventTime)) → $(status)" return status end @@ -1211,10 +1939,7 @@ The model enters Continuous-Time Mode and all discrete-time equations become ina This function has to be called when changing from Event Mode (after the global event iteration in Event Mode over all involved FMUs and other models has converged) into Continuous-Time Mode. """ function fmi3EnterContinuousTimeMode(cfunc::Ptr{Nothing}, c::fmi3Instance) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,), - c) + status = ccall(cfunc, fmi3Status, (fmi3Instance,), c)::fmi3Status @debug "fmi3EnterContinuousTimeMode(c: $(c)) → $(status)" return status end @@ -1225,11 +1950,8 @@ Source: FMISpec3.0, Version D5ef1c1: 2.3.5. State: Event Mode This function must be called to change from Event Mode into Step Mode in Co-Simulation (see 4.2.). """ -function fmi3EnterStepMode(cfunc::Ptr{Nothing}, c::fmi3Instance) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,), - c) +function fmi3EnterStepMode(cfunc::Ptr{Nothing}, c::fmi3Instance)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance,), c) @debug "fmi3EnterStepMode(c: $(c)) → $(status)" return status end @@ -1240,11 +1962,8 @@ Source: FMISpec3.0, Version D5ef1c1: 3.2.1. State: Continuous-Time Mode Set a new time instant and re-initialize caching of variables that depend on time, provided the newly provided time value is different to the previously set time value (variables that depend solely on constants or parameters need not to be newly computed in the sequel, but the previously computed values can be reused). """ -function fmi3SetTime(cfunc::Ptr{Nothing}, c::fmi3Instance, time::fmi3Float64) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, fmi3Float64), - c, time) +function fmi3SetTime(cfunc::Ptr{Nothing}, c::fmi3Instance, time::fmi3Float64)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance, fmi3Float64), c, time) @debug "fmi3SetTime(c: $(c), time: $(time)) → $(status)" return status end @@ -1255,15 +1974,15 @@ Source: FMISpec3.0, Version D5ef1c1: 3.2.1. State: Continuous-Time Mode Set a new (continuous) state vector and re-initialize caching of variables that depend on the states. Argument nx is the length of vector x and is provided for checking purposes """ -function fmi3SetContinuousStates(cfunc::Ptr{Nothing}, c::fmi3Instance, - x::AbstractArray{fmi3Float64}, - nx::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3Float64}, Csize_t), - c, x, nx) +function fmi3SetContinuousStates( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + x::AbstractArray{fmi3Float64}, + nx::Csize_t, +)::fmi3Status + status = ccall(cfunc, fmi3Status, (fmi3Instance, Ptr{fmi3Float64}, Csize_t), c, x, nx) @debug "fmi3SetContinuousStates(c: $(c), x: $(x), nx: $(nx)) → $(status)" - return status + return status end export fmi3SetContinuousStates @@ -1272,13 +1991,20 @@ Source: FMISpec3.0, Version D5ef1c1: 3.2.1. State: Continuous-Time Mode Compute first-oder state derivatives at the current time instant and for the current states. """ -function fmi3GetContinuousStateDerivatives!(cfunc::Ptr{Nothing}, c::fmi3Instance, - derivatives::AbstractArray{fmi3Float64}, - nx::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3Float64}, Csize_t), - c, derivatives, nx) +function fmi3GetContinuousStateDerivatives!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + derivatives::AbstractArray{fmi3Float64}, + nx::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3Float64}, Csize_t), + c, + derivatives, + nx, + ) @debug "fmi3GetContinuousStateDerivatives(c: $(c), derivatives: $(derivatives), nx: $(nx)) → $(status)" return status end @@ -1289,11 +2015,20 @@ Source: FMISpec3.0, Version D5ef1c1: 3.2.1. State: Continuous-Time Mode Compute event indicators at the current time instant and for the current states. EventIndicators signal Events by their sign change. """ -function fmi3GetEventIndicators!(cfunc::Ptr{Nothing}, c::fmi3Instance, eventIndicators::AbstractArray{fmi3Float64}, ni::Csize_t) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, Ptr{fmi3Float64}, Csize_t), - c, eventIndicators, ni) +function fmi3GetEventIndicators!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + eventIndicators::AbstractArray{fmi3Float64}, + ni::Csize_t, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, Ptr{fmi3Float64}, Csize_t), + c, + eventIndicators, + ni, + ) @debug "fmi3GetEventIndicators(c: $(c), eventIndicators: $(eventIndicators), ni: $(ni)) → $(status)" return status end @@ -1306,14 +2041,22 @@ This function must be called by the environment after every completed step of th If enterEventMode == fmi3True, the event mode must be entered If terminateSimulation == fmi3True, the simulation shall be terminated """ -function fmi3CompletedIntegratorStep!(cfunc::Ptr{Nothing}, c::fmi3Instance, - noSetFMUStatePriorToCurrentPoint::fmi3Boolean, - enterEventMode::Ref{fmi3Boolean}, - terminateSimulation::Ref{fmi3Boolean}) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance, fmi3Boolean, Ptr{fmi3Boolean}, Ptr{fmi3Boolean}), - c, noSetFMUStatePriorToCurrentPoint, enterEventMode, terminateSimulation) +function fmi3CompletedIntegratorStep!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + noSetFMUStatePriorToCurrentPoint::fmi3Boolean, + enterEventMode::Ref{fmi3Boolean}, + terminateSimulation::Ref{fmi3Boolean}, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, fmi3Boolean, Ptr{fmi3Boolean}, Ptr{fmi3Boolean}), + c, + noSetFMUStatePriorToCurrentPoint, + enterEventMode, + terminateSimulation, + ) @debug "fmi3CompletedIntegratorStep(c: $(c), noSetFMUStatePriorToCurrentPoint: $(noSetFMUStatePriorToCurrentPoint), enterEventMode: $(enterEventMode), terminateSimulation: $(terminateSimulation)) → $(status)" return status end @@ -1324,11 +2067,26 @@ Source: FMISpec3.0, Version D5ef1c1: 3.2.1. State: Continuous-Time Mode The model enters Event Mode from the Continuous-Time Mode in ModelExchange oder Step Mode in CoSimulation and discrete-time equations may become active (and relations are not “frozen”). """ -function fmi3EnterEventMode(cfunc::Ptr{Nothing}, c::fmi3Instance, stepEvent::fmi3Boolean, stateEvent::fmi3Boolean, rootsFound::AbstractArray{fmi3Int32}, nEventIndicators::Csize_t, timeEvent::fmi3Boolean) - status = ccall(cfunc, - fmi3Status, - (fmi3Instance,fmi3Boolean, fmi3Boolean, Ptr{fmi3Int32}, Csize_t, fmi3Boolean), - c, stepEvent, stateEvent, rootsFound, nEventIndicators, timeEvent) +function fmi3EnterEventMode( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + stepEvent::fmi3Boolean, + stateEvent::fmi3Boolean, + rootsFound::AbstractArray{fmi3Int32}, + nEventIndicators::Csize_t, + timeEvent::fmi3Boolean, +)::fmi3Status + status = ccall( + cfunc, + fmi3Status, + (fmi3Instance, fmi3Boolean, fmi3Boolean, Ptr{fmi3Int32}, Csize_t, fmi3Boolean), + c, + stepEvent, + stateEvent, + rootsFound, + nEventIndicators, + timeEvent, + ) @debug "fmi3EnterEventMode(c: $(c), stepEvent: $(stepEvent), stateEvent: $(stateEvent), rootsFound: $(rootsFound), nEventIndicators: $(nEventIndicators), timeEvent: $(timeEvent)) → $(status)" return status end @@ -1339,13 +2097,43 @@ Source: FMISpec3.0, Version D5ef1c1: 4.2.1. State: Step Mode The computation of a time step is started. """ -function fmi3DoStep!(cfunc::Ptr{Nothing}, c::fmi3Instance, currentCommunicationPoint::fmi3Float64, communicationStepSize::fmi3Float64, noSetFMUStatePriorToCurrentPoint::fmi3Boolean, - eventEncountered::Ref{fmi3Boolean}, terminateSimulation::Ref{fmi3Boolean}, earlyReturn::Ref{fmi3Boolean}, lastSuccessfulTime::Ref{fmi3Float64}) - @assert cfunc != C_NULL ["fmi3DoStep(...): This FMU does not support fmi3DoStep, probably it's a ME-FMU with no CS-support?"] - - status = ccall(cfunc, fmi3Status, - (fmi3Instance, fmi3Float64, fmi3Float64, fmi3Boolean, Ptr{fmi3Boolean}, Ptr{fmi3Boolean}, Ptr{fmi3Boolean}, Ptr{fmi3Float64}), - c, currentCommunicationPoint, communicationStepSize, noSetFMUStatePriorToCurrentPoint, eventEncountered, terminateSimulation, earlyReturn, lastSuccessfulTime) +function fmi3DoStep!( + cfunc::Ptr{Nothing}, + c::fmi3Instance, + currentCommunicationPoint::fmi3Float64, + communicationStepSize::fmi3Float64, + noSetFMUStatePriorToCurrentPoint::fmi3Boolean, + eventEncountered::Ref{fmi3Boolean}, + terminateSimulation::Ref{fmi3Boolean}, + earlyReturn::Ref{fmi3Boolean}, + lastSuccessfulTime::Ref{fmi3Float64}, +)::fmi3Status + @assert cfunc != C_NULL [ + "fmi3DoStep(...): This FMU does not support fmi3DoStep, probably it's a ME-FMU with no CS-support?", + ] + + status = ccall( + cfunc, + fmi3Status, + ( + fmi3Instance, + fmi3Float64, + fmi3Float64, + fmi3Boolean, + Ptr{fmi3Boolean}, + Ptr{fmi3Boolean}, + Ptr{fmi3Boolean}, + Ptr{fmi3Float64}, + ), + c, + currentCommunicationPoint, + communicationStepSize, + noSetFMUStatePriorToCurrentPoint, + eventEncountered, + terminateSimulation, + earlyReturn, + lastSuccessfulTime, + ) @debug "fmi3DoStep(c: $(c), currentCommunicationPoint: $(currentCommunicationPoint), communicationStepSize: $(communicationStepSize), noSetFMUStatePriorToCurrentPoint: $(noSetFMUStatePriorToCurrentPoint), eventEncountered: $(eventEncountered), terminateSimulation: $(terminateSimulation), earlyReturn: $(earlyReturn), lastSuccessfulTime: $(lastSuccessfulTime)) → $(status)" return status end diff --git a/src/FMI3/ctype.jl b/src/FMI3/ctype.jl index 87fccf9..5c8bfa2 100644 --- a/src/FMI3/ctype.jl +++ b/src/FMI3/ctype.jl @@ -21,8 +21,8 @@ mutable struct fmi3VariableDependency index::UInt # optional - dependencies::Union{Array{UInt, 1}, Nothing} - dependenciesKind::Union{Array{fmi3DependencyKind, 1}, Nothing} + dependencies::Union{Array{UInt,1},Nothing} + dependenciesKind::Union{Array{fmi3DependencyKind,1},Nothing} # Constructor function fmi3VariableDependency(index) @@ -45,39 +45,39 @@ mutable struct fmi3VariableFloat32 <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{Bool, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{Bool,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - quantity::Union{String, Nothing} - unit::Union{String, Nothing} - displayUnit::Union{String, Nothing} - declaredType::Union{String, Nothing} - relativeQuantity::Union{Bool, Nothing} - min::Union{fmi3Float32, Nothing} - max::Union{fmi3Float32, Nothing} - nominal::Union{fmi3Float32, Nothing} - unbounded::Union{fmi3Boolean, Nothing} - start::Union{fmi3Float32, Nothing} - derivative::Union{fmi3ValueReference, Nothing} - reinit::Union{Bool, Nothing} + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + quantity::Union{String,Nothing} + unit::Union{String,Nothing} + displayUnit::Union{String,Nothing} + declaredType::Union{String,Nothing} + relativeQuantity::Union{Bool,Nothing} + min::Union{fmi3Float32,Nothing} + max::Union{fmi3Float32,Nothing} + nominal::Union{fmi3Float32,Nothing} + unbounded::Union{fmi3Boolean,Nothing} + start::Union{fmi3Float32,Nothing} + derivative::Union{fmi3ValueReference,Nothing} + reinit::Union{Bool,Nothing} # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableFloat32(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -86,7 +86,7 @@ mutable struct fmi3VariableFloat32 <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -102,7 +102,7 @@ mutable struct fmi3VariableFloat32 <: fmi3Variable inst.start = nothing inst.derivative = nothing inst.reinit = nothing - return inst + return inst end end @@ -113,39 +113,39 @@ mutable struct fmi3VariableFloat64 <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - quantity::Union{String, Nothing} - unit::Union{String, Nothing} - displayUnit::Union{String, Nothing} - declaredType::Union{String, Nothing} - relativeQuantity::Union{Bool, Nothing} - min::Union{fmi3Float64, Nothing} - max::Union{fmi3Float64, Nothing} - nominal::Union{fmi3Float64, Nothing} - unbounded::Union{fmi3Boolean, Nothing} - start::Union{fmi3Float64, Nothing} - derivative::Union{fmi3ValueReference, Nothing} - reinit::Union{Bool, Nothing} + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + quantity::Union{String,Nothing} + unit::Union{String,Nothing} + displayUnit::Union{String,Nothing} + declaredType::Union{String,Nothing} + relativeQuantity::Union{Bool,Nothing} + min::Union{fmi3Float64,Nothing} + max::Union{fmi3Float64,Nothing} + nominal::Union{fmi3Float64,Nothing} + unbounded::Union{fmi3Boolean,Nothing} + start::Union{fmi3Float64,Nothing} + derivative::Union{fmi3ValueReference,Nothing} + reinit::Union{Bool,Nothing} # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableFloat64(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -154,7 +154,7 @@ mutable struct fmi3VariableFloat64 <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -181,32 +181,32 @@ mutable struct fmi3VariableInt8 <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - quantity::Union{String, Nothing} - declaredType::Union{String, Nothing} - min::Union{fmi3Int8, Nothing} - max::Union{fmi3Int8, Nothing} - start::Union{fmi3Int8, Nothing} - + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + quantity::Union{String,Nothing} + declaredType::Union{String,Nothing} + min::Union{fmi3Int8,Nothing} + max::Union{fmi3Int8,Nothing} + start::Union{fmi3Int8,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableInt8(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -215,7 +215,7 @@ mutable struct fmi3VariableInt8 <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -225,7 +225,7 @@ mutable struct fmi3VariableInt8 <: fmi3Variable inst.max = nothing inst.start = nothing return inst - end + end end mutable struct fmi3VariableUInt8 <: fmi3Variable @@ -235,32 +235,32 @@ mutable struct fmi3VariableUInt8 <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - quantity::Union{String, Nothing} - declaredType::Union{String, Nothing} - min::Union{fmi3UInt8, Nothing} - max::Union{fmi3UInt8, Nothing} - start::Union{fmi3UInt8, Nothing} - + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + quantity::Union{String,Nothing} + declaredType::Union{String,Nothing} + min::Union{fmi3UInt8,Nothing} + max::Union{fmi3UInt8,Nothing} + start::Union{fmi3UInt8,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableUInt8(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -269,7 +269,7 @@ mutable struct fmi3VariableUInt8 <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -279,7 +279,7 @@ mutable struct fmi3VariableUInt8 <: fmi3Variable inst.max = nothing inst.start = nothing return inst - end + end end mutable struct fmi3VariableInt16 <: fmi3Variable @@ -289,32 +289,32 @@ mutable struct fmi3VariableInt16 <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - quantity::Union{String, Nothing} - declaredType::Union{String, Nothing} - min::Union{fmi3Int16, Nothing} - max::Union{fmi3Int16, Nothing} - start::Union{fmi3Int16, Nothing} - + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + quantity::Union{String,Nothing} + declaredType::Union{String,Nothing} + min::Union{fmi3Int16,Nothing} + max::Union{fmi3Int16,Nothing} + start::Union{fmi3Int16,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableInt16(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -323,7 +323,7 @@ mutable struct fmi3VariableInt16 <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -333,7 +333,7 @@ mutable struct fmi3VariableInt16 <: fmi3Variable inst.max = nothing inst.start = nothing return inst - end + end end mutable struct fmi3VariableUInt16 <: fmi3Variable @@ -343,32 +343,32 @@ mutable struct fmi3VariableUInt16 <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - quantity::Union{String, Nothing} - declaredType::Union{String, Nothing} - min::Union{fmi3UInt16, Nothing} - max::Union{fmi3UInt16, Nothing} - start::Union{fmi3UInt16, Nothing} - + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + quantity::Union{String,Nothing} + declaredType::Union{String,Nothing} + min::Union{fmi3UInt16,Nothing} + max::Union{fmi3UInt16,Nothing} + start::Union{fmi3UInt16,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableUInt16(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -377,7 +377,7 @@ mutable struct fmi3VariableUInt16 <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -387,7 +387,7 @@ mutable struct fmi3VariableUInt16 <: fmi3Variable inst.max = nothing inst.start = nothing return inst - end + end end mutable struct fmi3VariableInt32 <: fmi3Variable @@ -397,32 +397,32 @@ mutable struct fmi3VariableInt32 <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - quantity::Union{String, Nothing} - declaredType::Union{String, Nothing} - min::Union{fmi3Int32, Nothing} - max::Union{fmi3Int32, Nothing} - start::Union{fmi3Int32, Nothing} - + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + quantity::Union{String,Nothing} + declaredType::Union{String,Nothing} + min::Union{fmi3Int32,Nothing} + max::Union{fmi3Int32,Nothing} + start::Union{fmi3Int32,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableInt32(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -431,7 +431,7 @@ mutable struct fmi3VariableInt32 <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -441,7 +441,7 @@ mutable struct fmi3VariableInt32 <: fmi3Variable inst.max = nothing inst.start = nothing return inst - end + end end mutable struct fmi3VariableUInt32 <: fmi3Variable @@ -451,32 +451,32 @@ mutable struct fmi3VariableUInt32 <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - quantity::Union{String, Nothing} - declaredType::Union{String, Nothing} - min::Union{fmi3UInt32, Nothing} - max::Union{fmi3UInt32, Nothing} - start::Union{fmi3UInt32, Nothing} - + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + quantity::Union{String,Nothing} + declaredType::Union{String,Nothing} + min::Union{fmi3UInt32,Nothing} + max::Union{fmi3UInt32,Nothing} + start::Union{fmi3UInt32,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableUInt32(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -485,7 +485,7 @@ mutable struct fmi3VariableUInt32 <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -495,7 +495,7 @@ mutable struct fmi3VariableUInt32 <: fmi3Variable inst.max = nothing inst.start = nothing return inst - end + end end mutable struct fmi3VariableInt64 <: fmi3Variable @@ -505,32 +505,32 @@ mutable struct fmi3VariableInt64 <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - quantity::Union{String, Nothing} - declaredType::Union{String, Nothing} - min::Union{fmi3Int64, Nothing} - max::Union{fmi3Int64, Nothing} - start::Union{fmi3Int64, Nothing} - + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + quantity::Union{String,Nothing} + declaredType::Union{String,Nothing} + min::Union{fmi3Int64,Nothing} + max::Union{fmi3Int64,Nothing} + start::Union{fmi3Int64,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableInt64(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -539,7 +539,7 @@ mutable struct fmi3VariableInt64 <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -549,7 +549,7 @@ mutable struct fmi3VariableInt64 <: fmi3Variable inst.max = nothing inst.start = nothing return inst - end + end end mutable struct fmi3VariableUInt64 <: fmi3Variable @@ -559,32 +559,32 @@ mutable struct fmi3VariableUInt64 <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - quantity::Union{String, Nothing} - declaredType::Union{String, Nothing} - min::Union{fmi3UInt64, Nothing} - max::Union{fmi3UInt64, Nothing} - start::Union{fmi3UInt64, Nothing} - + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + quantity::Union{String,Nothing} + declaredType::Union{String,Nothing} + min::Union{fmi3UInt64,Nothing} + max::Union{fmi3UInt64,Nothing} + start::Union{fmi3UInt64,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableUInt64(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -593,7 +593,7 @@ mutable struct fmi3VariableUInt64 <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -603,7 +603,7 @@ mutable struct fmi3VariableUInt64 <: fmi3Variable inst.max = nothing inst.start = nothing return inst - end + end end mutable struct fmi3VariableBoolean <: fmi3Variable @@ -613,29 +613,29 @@ mutable struct fmi3VariableBoolean <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - declaredType::Union{String, Nothing} - start::Union{fmi3Boolean, Nothing} - + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + declaredType::Union{String,Nothing} + start::Union{fmi3Boolean,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableBoolean(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -644,14 +644,14 @@ mutable struct fmi3VariableBoolean <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated inst.declaredType = nothing inst.start = nothing return inst - end + end end mutable struct fmi3VariableString <: fmi3Variable @@ -661,25 +661,25 @@ mutable struct fmi3VariableString <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - start::Union{String, Nothing} - + start::Union{String,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableString(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -688,10 +688,10 @@ mutable struct fmi3VariableString <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.start = nothing return inst - end + end end mutable struct fmi3VariableBinary <: fmi3Variable @@ -701,31 +701,31 @@ mutable struct fmi3VariableBinary <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - declaredType::Union{String, Nothing} + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + declaredType::Union{String,Nothing} mimeType::String - maxSize::Union{Unsigned, Nothing} - start::Union{fmi3Binary, Nothing} - + maxSize::Union{Unsigned,Nothing} + start::Union{fmi3Binary,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableBinary(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -734,7 +734,7 @@ mutable struct fmi3VariableBinary <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -743,7 +743,7 @@ mutable struct fmi3VariableBinary <: fmi3Variable inst.maxSize = nothing inst.start = nothing return inst - end + end end mutable struct fmi3VariableClock <: fmi3Variable @@ -753,34 +753,34 @@ mutable struct fmi3VariableClock <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - declaredType::Union{String, Nothing} + declaredType::Union{String,Nothing} canBeDeactivated::Bool - priority::Union{Unsigned, Nothing} - intervalVariability::Union{String, Nothing} # TODO might need to get a own enum for clock type - intervalDecimal::Union{Real, Nothing} - shiftDecimal::Union{Real, Nothing} + priority::Union{Unsigned,Nothing} + intervalVariability::Union{String,Nothing} # TODO might need to get a own enum for clock type + intervalDecimal::Union{Real,Nothing} + shiftDecimal::Union{Real,Nothing} supportsFraction::Bool - resolution::Union{Unsigned, Nothing} - intervalCounter::Union{Unsigned, Nothing} - shiftCounter::Union{Unsigned, Nothing} - + resolution::Union{Unsigned,Nothing} + intervalCounter::Union{Unsigned,Nothing} + shiftCounter::Union{Unsigned,Nothing} + # dependencies - dependencies #::Array{fmi3Int32} - dependenciesKind #::Array{fmi3String} + dependencies::Any #::Array{fmi3Int32} + dependenciesKind::Any #::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableClock(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -789,7 +789,7 @@ mutable struct fmi3VariableClock <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.declaredType = nothing inst.canBeDeactivated = false inst.priority = nothing @@ -801,7 +801,7 @@ mutable struct fmi3VariableClock <: fmi3Variable inst.intervalCounter = nothing inst.shiftCounter = nothing return inst - end + end end mutable struct fmi3VariableEnumeration <: fmi3Variable @@ -811,32 +811,32 @@ mutable struct fmi3VariableEnumeration <: fmi3Variable name::String valueReference::fmi3ValueReference causality::fmi3Causality - variability::fmi3Variability + variability::fmi3Variability # Optional - description::Union{String, Nothing} - canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean, Nothing} - annotations::Union{fmi3Annotation, Nothing} - clocks::Union{Array{fmi3ValueReference}, Nothing} + description::Union{String,Nothing} + canHandleMultipleSetPerTimeInstant::Union{fmi3Boolean,Nothing} + annotations::Union{fmi3Annotation,Nothing} + clocks::Union{Array{fmi3ValueReference},Nothing} # type specific attributes - intermediateUpdate::Union{Bool, Nothing} - previous::Union{fmi3ValueReference, Nothing} - initial::Union{fmi3Initial, Nothing} - quantity::Union{String, Nothing} - declaredType::Union{String, Nothing} - min::Union{fmi3Int64, Nothing} - max::Union{fmi3Int64, Nothing} - start::Union{fmi3Int64, Nothing} - + intermediateUpdate::Union{Bool,Nothing} + previous::Union{fmi3ValueReference,Nothing} + initial::Union{fmi3Initial,Nothing} + quantity::Union{String,Nothing} + declaredType::Union{String,Nothing} + min::Union{fmi3Int64,Nothing} + max::Union{fmi3Int64,Nothing} + start::Union{fmi3Int64,Nothing} + # dependencies - dependencies # ToDo: Typing! ::Array{fmi3Int32} - dependenciesKind # ToDo: Typing! ::Array{fmi3String} + dependencies::Any # ToDo: Typing! ::Array{fmi3Int32} + dependenciesKind::Any # ToDo: Typing! ::Array{fmi3String} # Constructor for not further specified ModelVariable function fmi3VariableEnumeration(name::String, valueReference::fmi3ValueReference) inst = new() - inst.name = name + inst.name = name inst.valueReference = valueReference inst.description = "" inst.causality = fmi3CausalityLocal @@ -845,7 +845,7 @@ mutable struct fmi3VariableEnumeration <: fmi3Variable inst.canHandleMultipleSetPerTimeInstant = fmi3False inst.clocks = nothing inst.annotations = nothing - + inst.intermediateUpdate = fmi3False inst.previous = nothing inst.initial = fmi3InitialCalculated @@ -855,7 +855,7 @@ mutable struct fmi3VariableEnumeration <: fmi3Variable inst.max = nothing inst.start = nothing return inst - end + end end # Custom helper, not part of the FMI-Spec. @@ -894,15 +894,15 @@ end mutable struct fmi3ModelDescriptionClockType name::String description::Union{String,Nothing} - canBeDeactivated::Union{Bool, Nothing} - priority::Union{UInt, Nothing} - intervalVariability # TODO type - intervalDecimal::Union{Real, Nothing} - shiftDecimal::Union{Real, Nothing} - supportsFraction::Union{Bool, Nothing} - resolution::Union{UInt64, Nothing} - intervalCounter::Union{UInt64, Nothing} - shiftCounter::Union{UInt64, Nothing} + canBeDeactivated::Union{Bool,Nothing} + priority::Union{UInt,Nothing} + intervalVariability::Any # TODO type + intervalDecimal::Union{Real,Nothing} + shiftDecimal::Union{Real,Nothing} + supportsFraction::Union{Bool,Nothing} + resolution::Union{UInt64,Nothing} + intervalCounter::Union{UInt64,Nothing} + shiftCounter::Union{UInt64,Nothing} # Constructor function fmi3ModelDescriptionClockType(name::String) @@ -923,11 +923,11 @@ end # Custom helper, not part of the FMI-Spec. mutable struct fmi3ModelDescriptionModelStructure - outputs::Union{Array{fmi3VariableDependency, 1}, Nothing} - continuousStateDerivatives::Union{Array{fmi3VariableDependency, 1}, Nothing} - clockedStates::Union{Array{fmi3VariableDependency, 1}, Nothing} - initialUnknowns::Union{Array{fmi3Unknown, 1}, Nothing} - eventIndicators::Union{Array{fmi3VariableDependency, 1}, Nothing} + outputs::Union{Array{fmi3VariableDependency,1},Nothing} + continuousStateDerivatives::Union{Array{fmi3VariableDependency,1},Nothing} + clockedStates::Union{Array{fmi3VariableDependency,1},Nothing} + initialUnknowns::Union{Array{fmi3Unknown,1},Nothing} + eventIndicators::Union{Array{fmi3VariableDependency,1},Nothing} # Constructor function fmi3ModelDescriptionModelStructure() @@ -947,24 +947,24 @@ mutable struct fmi3ModelDescriptionModelExchange modelIdentifier::String # optional - needsExecutionTool::Union{Bool, Nothing} - canBeInstantiatedOnlyOncePerProcess::Union{Bool, Nothing} - canGetAndSetFMUState::Union{Bool, Nothing} - canSerializeFMUState::Union{Bool, Nothing} - providesDirectionalDerivatives::Union{Bool, Nothing} - providesAdjointDerivatives::Union{Bool, Nothing} - providesPerElementDependencies::Union{Bool, Nothing} - needsCompletedIntegratorStep::Union{Bool, Nothing} - providesEvaluateDiscreteStates::Union{Bool, Nothing} + needsExecutionTool::Union{Bool,Nothing} + canBeInstantiatedOnlyOncePerProcess::Union{Bool,Nothing} + canGetAndSetFMUState::Union{Bool,Nothing} + canSerializeFMUState::Union{Bool,Nothing} + providesDirectionalDerivatives::Union{Bool,Nothing} + providesAdjointDerivatives::Union{Bool,Nothing} + providesPerElementDependencies::Union{Bool,Nothing} + needsCompletedIntegratorStep::Union{Bool,Nothing} + providesEvaluateDiscreteStates::Union{Bool,Nothing} # constructor - function fmi3ModelDescriptionModelExchange() + function fmi3ModelDescriptionModelExchange() inst = new() - return inst + return inst end - function fmi3ModelDescriptionModelExchange(modelIdentifier::String) - inst = fmi3ModelDescriptionModelExchange() + function fmi3ModelDescriptionModelExchange(modelIdentifier::String) + inst = fmi3ModelDescriptionModelExchange() inst.modelIdentifier = modelIdentifier inst.needsExecutionTool = nothing inst.canBeInstantiatedOnlyOncePerProcess = nothing @@ -975,7 +975,7 @@ mutable struct fmi3ModelDescriptionModelExchange inst.providesPerElementDependencies = nothing inst.needsCompletedIntegratorStep = nothing inst.providesEvaluateDiscreteStates = nothing - return inst + return inst end end @@ -985,32 +985,32 @@ mutable struct fmi3ModelDescriptionCoSimulation modelIdentifier::String # optional - needsExecutionTool::Union{Bool, Nothing} - canBeInstantiatedOnlyOncePerProcess::Union{Bool, Nothing} - canGetAndSetFMUState::Union{Bool, Nothing} - canSerializeFMUState::Union{Bool, Nothing} - providesDirectionalDerivatives::Union{Bool, Nothing} - providesAdjointDerivatives::Union{Bool, Nothing} - providesPerElementDependencies::Union{Bool, Nothing} - needsCompletedIntegratorStep::Union{Bool, Nothing} - providesEvaluateDiscreteStates::Union{Bool, Nothing} - canHandleVariableCommunicationStepSize::Union{Bool, Nothing} - fixedInternalStepSize::Union{Real, Nothing} - recommendedIntermediateInputSmoothness::Union{Int, Nothing} - maxOutputDerivativeOrder::Union{UInt, Nothing} - providesIntermediateUpdate::Union{Bool, Nothing} - mightReturnEarlyFromDoStep::Union{Bool, Nothing} - canReturnEarlyAfterIntermediateUpdate::Union{Bool, Nothing} - hasEventMode::Union{Bool, Nothing} - canInterpolateInputs::Union{Bool, Nothing} + needsExecutionTool::Union{Bool,Nothing} + canBeInstantiatedOnlyOncePerProcess::Union{Bool,Nothing} + canGetAndSetFMUState::Union{Bool,Nothing} + canSerializeFMUState::Union{Bool,Nothing} + providesDirectionalDerivatives::Union{Bool,Nothing} + providesAdjointDerivatives::Union{Bool,Nothing} + providesPerElementDependencies::Union{Bool,Nothing} + needsCompletedIntegratorStep::Union{Bool,Nothing} + providesEvaluateDiscreteStates::Union{Bool,Nothing} + canHandleVariableCommunicationStepSize::Union{Bool,Nothing} + fixedInternalStepSize::Union{Real,Nothing} + recommendedIntermediateInputSmoothness::Union{Int,Nothing} + maxOutputDerivativeOrder::Union{UInt,Nothing} + providesIntermediateUpdate::Union{Bool,Nothing} + mightReturnEarlyFromDoStep::Union{Bool,Nothing} + canReturnEarlyAfterIntermediateUpdate::Union{Bool,Nothing} + hasEventMode::Union{Bool,Nothing} + canInterpolateInputs::Union{Bool,Nothing} # constructor - function fmi3ModelDescriptionCoSimulation() + function fmi3ModelDescriptionCoSimulation() inst = new() - return inst + return inst end - function fmi3ModelDescriptionCoSimulation(modelIdentifier::String) + function fmi3ModelDescriptionCoSimulation(modelIdentifier::String) inst = fmi3ModelDescriptionCoSimulation() inst.modelIdentifier = modelIdentifier inst.needsExecutionTool = nothing @@ -1031,7 +1031,7 @@ mutable struct fmi3ModelDescriptionCoSimulation inst.mightReturnEarlyFromDoStep = nothing inst.canReturnEarlyAfterIntermediateUpdate = nothing inst.hasEventMode = nothing - return inst + return inst end end @@ -1041,22 +1041,22 @@ mutable struct fmi3ModelDescriptionScheduledExecution modelIdentifier::String # optional - needsExecutionTool::Union{Bool, Nothing} - canBeInstantiatedOnlyOncePerProcess::Union{Bool, Nothing} - canGetAndSetFMUState::Union{Bool, Nothing} - canSerializeFMUState::Union{Bool, Nothing} - providesDirectionalDerivatives::Union{Bool, Nothing} - providesAdjointDerivatives::Union{Bool, Nothing} - providesPerElementDependencies::Union{Bool, Nothing} + needsExecutionTool::Union{Bool,Nothing} + canBeInstantiatedOnlyOncePerProcess::Union{Bool,Nothing} + canGetAndSetFMUState::Union{Bool,Nothing} + canSerializeFMUState::Union{Bool,Nothing} + providesDirectionalDerivatives::Union{Bool,Nothing} + providesAdjointDerivatives::Union{Bool,Nothing} + providesPerElementDependencies::Union{Bool,Nothing} # constructor - function fmi3ModelDescriptionScheduledExecution() + function fmi3ModelDescriptionScheduledExecution() inst = new() - return inst + return inst end - function fmi3ModelDescriptionScheduledExecution(modelIdentifier::String) - inst = fmi3ModelDescriptionScheduledExecution() + function fmi3ModelDescriptionScheduledExecution(modelIdentifier::String) + inst = fmi3ModelDescriptionScheduledExecution() inst.modelIdentifier = modelIdentifier inst.needsExecutionTool = nothing inst.canBeInstantiatedOnlyOncePerProcess = nothing @@ -1065,7 +1065,7 @@ mutable struct fmi3ModelDescriptionScheduledExecution inst.providesDirectionalDerivatives = nothing inst.providesAdjointDerivatives = nothing inst.providesPerElementDependencies = nothing - return inst + return inst end end @@ -1097,30 +1097,30 @@ mutable struct fmi3ModelDescription <: fmiModelDescription instantiationToken::String # replaces GUID # optional - description::Union{String, Nothing} - author::Union{String, Nothing} - version::Union{String, Nothing} - copyright::Union{String, Nothing} - license::Union{String, Nothing} - generationTool::Union{String, Nothing} - generationDateAndTime # DateTime - variableNamingConvention::Union{fmi3VariableNamingConvention, Nothing} - numberOfEventIndicators::Union{UInt, Nothing} - - unitDefinitions::Array{fmi3Unit, 1} - typeDefinitions::Array{fmi3SimpleType, 1} + description::Union{String,Nothing} + author::Union{String,Nothing} + version::Union{String,Nothing} + copyright::Union{String,Nothing} + license::Union{String,Nothing} + generationTool::Union{String,Nothing} + generationDateAndTime::Any # DateTime + variableNamingConvention::Union{fmi3VariableNamingConvention,Nothing} + numberOfEventIndicators::Union{UInt,Nothing} + + unitDefinitions::Array{fmi3Unit,1} + typeDefinitions::Array{fmi3SimpleType,1} logCategories::Array # ToDo: Array type - defaultExperiment::Union{fmi3ModelDescriptionDefaultExperiment, Nothing} - clockType::Union{fmi3ModelDescriptionClockType, Nothing} + defaultExperiment::Union{fmi3ModelDescriptionDefaultExperiment,Nothing} + clockType::Union{fmi3ModelDescriptionClockType,Nothing} vendorAnnotations::Array # ToDo: Array type - modelVariables::Array{fmi3Variable, 1} + modelVariables::Array{fmi3Variable,1} modelStructure::fmi3ModelDescriptionModelStructure - modelExchange::Union{fmi3ModelDescriptionModelExchange, Nothing} - coSimulation::Union{fmi3ModelDescriptionCoSimulation, Nothing} - scheduledExecution::Union{fmi3ModelDescriptionScheduledExecution, Nothing} + modelExchange::Union{fmi3ModelDescriptionModelExchange,Nothing} + coSimulation::Union{fmi3ModelDescriptionCoSimulation,Nothing} + scheduledExecution::Union{fmi3ModelDescriptionScheduledExecution,Nothing} # additionals valueReferences::Array{fmi3ValueReference} @@ -1130,10 +1130,10 @@ mutable struct fmi3ModelDescription <: fmiModelDescription derivativeValueReferences::Array{fmi3ValueReference} intermediateUpdateValueReferences::Array{fmi3ValueReference} parameterValueReferences::Array{fmi3ValueReference} - stringValueReferences::Dict{String, fmi3ValueReference} - + stringValueReferences::Dict{String,fmi3ValueReference} + numberOfContinuousStates::Int - + # additional fields (non-FMI-specific) valueReferenceIndicies::Dict{UInt,UInt} @@ -1144,17 +1144,17 @@ mutable struct fmi3ModelDescription <: fmiModelDescription inst.modelName = "" inst.instantiationToken = "" - inst.modelExchange = nothing + inst.modelExchange = nothing inst.coSimulation = nothing inst.scheduledExecution = nothing inst.defaultExperiment = nothing inst.clockType = nothing - inst.modelVariables = Array{fmi3Variable, 1}() + inst.modelVariables = Array{fmi3Variable,1}() inst.modelStructure = fmi3ModelDescriptionModelStructure() inst.numberOfEventIndicators = nothing - + inst.valueReferences = [] inst.inputValueReferences = [] inst.outputValueReferences = [] @@ -1162,17 +1162,19 @@ mutable struct fmi3ModelDescription <: fmiModelDescription inst.derivativeValueReferences = [] inst.parameterValueReferences = [] - return inst + return inst end end export fmi3ModelDescription # Overload the Base.show() function for custom printing of the fmi3ModelDescription. -function Base.show(io::IO, desc::fmi3ModelDescription) - print(io, +function Base.show(io::IO, desc::fmi3ModelDescription) + print( + io, "Model name: $(desc.modelName) FMI version: $(desc.fmiVersion) Instantiation Token: $(desc.instantiationToken) Description: $(desc.description) - Model variables: $(desc.modelVariables)") -end \ No newline at end of file + Model variables: $(desc.modelVariables)", + ) +end diff --git a/src/FMICore.jl b/src/FMICore.jl index 71b2c30..fe291e9 100644 --- a/src/FMICore.jl +++ b/src/FMICore.jl @@ -14,7 +14,7 @@ if juliaArch == 32 end # abstract types for inheritance -abstract type fmiModelDescription end +abstract type fmiModelDescription end export fmiModelDescription const SI_UNITS = (:kg, :m, :s, :A, :K, :mol, :cd, :rad) diff --git a/test/FMI2/cfunc.jl b/test/FMI2/cfunc.jl new file mode 100644 index 0000000..5d29584 --- /dev/null +++ b/test/FMI2/cfunc.jl @@ -0,0 +1,6 @@ +# +# Copyright (c) 2021 Tobias Thummerer, Lars Mikelsons, Josef Kircher +# Licensed under the MIT license. See LICENSE file in the project root for details. +# + +# [ToDo] tests for FMI2 diff --git a/test/FMI3/cfunc.jl b/test/FMI3/cfunc.jl new file mode 100644 index 0000000..e83d334 --- /dev/null +++ b/test/FMI3/cfunc.jl @@ -0,0 +1,6 @@ +# +# Copyright (c) 2021 Tobias Thummerer, Lars Mikelsons, Josef Kircher +# Licensed under the MIT license. See LICENSE file in the project root for details. +# + +# [ToDo] tests for FMI3 diff --git a/test/eval.jl b/test/eval.jl index 2a3b8e4..8d7aafe 100644 --- a/test/eval.jl +++ b/test/eval.jl @@ -6,9 +6,9 @@ using PkgEval using FMICore -config = Configuration(; julia="1.10"); +config = Configuration(; julia = "1.10"); -package = Package(; name="FMICore"); +package = Package(; name = "FMICore"); @info "PkgEval" result = evaluate([config], [package]) @@ -17,4 +17,4 @@ result = evaluate([config], [package]) println(result) @info "Log" -println(result.log) \ No newline at end of file +println(result.log) diff --git a/test/runtests.jl b/test/runtests.jl index 243969a..2a6df73 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,6 +8,9 @@ using Test @testset "FMICore.jl" begin @testset "FMI2" begin - # [ToDo] + include("FMI2/cfunc.jl") end -end \ No newline at end of file + @testset "FMI3" begin + include("FMI3/cfunc.jl") + end +end