Skip to content

Commit

Permalink
V1.0.3 (#118)
Browse files Browse the repository at this point in the history
* removed dependencies

* buf gix for `info`

* fixed info
  • Loading branch information
ThummeTo committed Aug 19, 2024
1 parent f9dba58 commit 491c978
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 52 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FMIImport"
uuid = "9fcbc62e-52a0-44e9-a616-1359a0008194"
authors = ["TT <[email protected]>", "LM <[email protected]>", "JK <[email protected]>"]
version = "1.0.2"
version = "1.0.3"

[deps]
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Expand All @@ -20,4 +20,4 @@ Downloads = "1"
FMIBase = "1.0.0"
Libdl = "1"
RelocatableFolders = "1"
julia = "1.6"
julia = "1.6"
8 changes: 4 additions & 4 deletions src/FMI2/c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ end

import FMIBase.FMICore: fmi2SetDebugLogging
"""
fmi2SetDebugLogging(c::FMU2Component, logginOn::fmi2Boolean, nCategories::Unsigned, categories::Ptr{Nothing})
fmi2SetDebugLogging(c::FMU2Component, loggingOn::fmi2Boolean, nCategories::Unsigned, categories::Ptr{Nothing})
Control the use of the logging callback function, version independent.
# Arguments
- `c::FMU2Component`: Argument `c` is a Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
- `logginOn::fmi2Boolean`: If `loggingOn = fmi2True`, debug logging is enabled for the log categories specified in categories, otherwise it is disabled. Type `fmi2Boolean` is defined as an alias Type for the C-Type Boolean and is to be used with `fmi2True` and `fmi2False`.
- `loggingOn::fmi2Boolean`: If `loggingOn = fmi2True`, debug logging is enabled for the log categories specified in categories, otherwise it is disabled. Type `fmi2Boolean` is defined as an alias Type for the C-Type Boolean and is to be used with `fmi2True` and `fmi2False`.
- `nCategories::Unsigned`: Argument `nCategories` defines the length of the argument `categories`.
- `categories::Ptr{Nothing}`:
Expand All @@ -169,9 +169,9 @@ More detailed:
- FMISpec2.0.2[p.22]: 2.1.5 Creation, Destruction and Logging of FMU Instances
See also [`fmi2SetDebugLogging`](@ref).
"""
function FMICore.fmi2SetDebugLogging(c::FMU2Component, logginOn::fmi2Boolean, nCategories::Unsigned, categories::Ptr{Nothing})
function FMICore.fmi2SetDebugLogging(c::FMU2Component, loggingOn::fmi2Boolean, nCategories::Unsigned, categories::Ptr{Nothing})

status = fmi2SetDebugLogging(c.fmu.cSetDebugLogging, c.addr, logginOn, nCategories, categories)
status = fmi2SetDebugLogging(c.fmu.cSetDebugLogging, c.addr, loggingOn, nCategories, categories)
checkStatus(c, status)
return status
end
Expand Down
108 changes: 62 additions & 46 deletions src/info.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@
# Licensed under the MIT license. See LICENSE file in the project root for details.
#

# Prints value references, but shortens if the number exceeds `max`.
function printValueReferences(fmu, vrs; max=10)
len = length(vrs)
if len <= max
for vr in vrs
println("\t\t$(vr) $(valueReferenceToString(fmu, vr))")
end
else
half = floor(Integer, max)-1
for vr in vrs[1:half]
println("\t\t$(vr) $(valueReferenceToString(fmu, vr))")
end
println(".")
println(".")
println(".")
for vr in vrs[len-half:end]
println("\t\t$(vr) $(valueReferenceToString(fmu, vr))")
end
end
nothing
end

"""
info(fmu)
Expand All @@ -19,36 +41,33 @@ function info(fmu::FMU2)

println("\tModel name:\t\t\t$(getModelName(fmu))")
println("\tFMI-Version:\t\t\t$(fmi2GetVersion(fmu))")
println("\tGUID:\t\t\t\t$(fmi2GetGUID(fmu))")
println("\tGUID:\t\t\t\t$(getGUID(fmu))")
println("\tGeneration tool:\t\t$(getGenerationTool(fmu))")
println("\tGeneration time:\t\t$(generationDateAndTime(fmu))")
println("\tGeneration time:\t\t$(getGenerationDateAndTime(fmu))")
print("\tVar. naming conv.:\t\t")
if fmi2GetVariableNamingConvention(fmu) == fmi2VariableNamingConventionFlat
if getVariableNamingConvention(fmu) == fmi2VariableNamingConventionFlat
println("flat")
elseif fmi2GetVariableNamingConvention(fmu) == fmi2VariableNamingConventionStructured
elseif getVariableNamingConvention(fmu) == fmi2VariableNamingConventionStructured
println("structured")
else
println("[unknown]")
end
println("\tEvent indicators:\t\t$(fmi2GetNumberOfEventIndicators(fmu))")
println("\tEvent indicators:\t\t$(getNumberOfEventIndicators(fmu))")

println("\tInputs:\t\t\t\t$(length(fmu.modelDescription.inputValueReferences))")
for vr in fmu.modelDescription.inputValueReferences
println("\t\t$(vr) $(fmi2ValueReferenceToString(fmu, vr))")
end
printValueReferences(fmu, fmu.modelDescription.inputValueReferences)

println("\tOutputs:\t\t\t$(length(fmu.modelDescription.outputValueReferences))")
for vr in fmu.modelDescription.outputValueReferences
println("\t\t$(vr) $(fmi2ValueReferenceToString(fmu, vr))")
end
printValueReferences(fmu, fmu.modelDescription.outputValueReferences)

println("\tStates:\t\t\t\t$(length(fmu.modelDescription.stateValueReferences))")
for vr in fmu.modelDescription.stateValueReferences
println("\t\t$(vr) $(fmi2ValueReferenceToString(fmu, vr))")
end
printValueReferences(fmu, fmu.modelDescription.stateValueReferences)

println("\tSupports Co-Simulation:\t\t$(fmi2IsCoSimulation(fmu))")
if fmi2IsCoSimulation(fmu)
println("\tParameters:\t\t\t\t$(length(fmu.modelDescription.parameterValueReferences))")
printValueReferences(fmu, fmu.modelDescription.parameterValueReferences)

println("\tSupports Co-Simulation:\t\t$(isCoSimulation(fmu))")
if isCoSimulation(fmu)
println("\t\tModel identifier:\t$(fmu.modelDescription.coSimulation.modelIdentifier)")
println("\t\tGet/Set State:\t\t$(fmu.modelDescription.coSimulation.canGetAndSetFMUstate)")
println("\t\tSerialize State:\t$(fmu.modelDescription.coSimulation.canSerializeFMUstate)")
Expand All @@ -59,8 +78,8 @@ function info(fmu::FMU2)
println("\t\tMax order out. der.:\t$(fmu.modelDescription.coSimulation.maxOutputDerivativeOrder)")
end

println("\tSupports Model-Exchange:\t$(fmi2IsModelExchange(fmu))")
if fmi2IsModelExchange(fmu)
println("\tSupports Model-Exchange:\t$(isModelExchange(fmu))")
if isModelExchange(fmu)
println("\t\tModel identifier:\t$(fmu.modelDescription.modelExchange.modelIdentifier)")
println("\t\tGet/Set State:\t\t$(fmu.modelDescription.modelExchange.canGetAndSetFMUstate)")
println("\t\tSerialize State:\t$(fmu.modelDescription.modelExchange.canSerializeFMUstate)")
Expand All @@ -72,41 +91,38 @@ end
function info(fmu::FMU3)
println("#################### Begin information for FMU ####################")

println("\tModel name:\t\t\t$(fmi3GetModelName(fmu))")
println("\tModel name:\t\t\t$(getModelName(fmu))")
println("\tFMI-Version:\t\t\t$(fmi3GetVersion(fmu))")
println("\tInstantiation Token:\t\t\t\t$(fmi3GetInstantiationToken(fmu))")
println("\tGeneration tool:\t\t$(fmi3GetGenerationTool(fmu))")
println("\tGeneration time:\t\t$(fmi3GetGenerationDateAndTime(fmu))")
println("\tInstantiation Token:\t\t\t\t$(getInstantiationToken(fmu))")
println("\tGeneration tool:\t\t$(getGenerationTool(fmu))")
println("\tGeneration time:\t\t$(getGenerationDateAndTime(fmu))")
print("\tVar. naming conv.:\t\t")
if fmi3GetVariableNamingConvention(fmu) == fmi3VariableNamingConventionFlat
if getVariableNamingConvention(fmu) == fmi3VariableNamingConventionFlat
println("flat")
elseif fmi3GetVariableNamingConvention(fmu) == fmi3VariableNamingConventionStructured
elseif getVariableNamingConvention(fmu) == fmi3VariableNamingConventionStructured
println("structured")
else
println("[unknown]")
end
println("\tEvent indicators:\t\t$(fmi3GetNumberOfEventIndicators(fmu))")
println("\tEvent indicators:\t\t$(getNumberOfEventIndicators(fmu))")

println("\tInputs:\t\t\t\t$(length(fmu.modelDescription.inputValueReferences))")
for vr in fmu.modelDescription.inputValueReferences
println("\t\t$(vr) $(fmi3ValueReferenceToString(fmu, vr))")
end
printValueReferences(fmu, fmu.modelDescription.inputValueReferences)

println("\tOutputs:\t\t\t$(length(fmu.modelDescription.outputValueReferences))")
for vr in fmu.modelDescription.outputValueReferences
println("\t\t$(vr) $(fmi3ValueReferenceToString(fmu, vr))")
end
printValueReferences(fmu, fmu.modelDescription.outputValueReferences)

println("\tStates:\t\t\t\t$(length(fmu.modelDescription.stateValueReferences))")
for vr in fmu.modelDescription.stateValueReferences
println("\t\t$(vr) $(fmi3ValueReferenceToString(fmu, vr))")
end
printValueReferences(fmu, fmu.modelDescription.stateValueReferences)

println("\tParameters:\t\t\t\t$(length(fmu.modelDescription.parameterValueReferences))")
printValueReferences(fmu, fmu.modelDescription.parameterValueReferences)

println("\tSupports Co-Simulation:\t\t$(fmi3IsCoSimulation(fmu))")
if fmi3IsCoSimulation(fmu)
println("\tSupports Co-Simulation:\t\t$(isCoSimulation(fmu))")
if isCoSimulation(fmu)
println("\t\tModel identifier:\t$(fmu.modelDescription.coSimulation.modelIdentifier)")
println("\t\tGet/Set State:\t\t$(fmu.modelDescription.coSimulation.canGetAndSetFMUstate)")
println("\t\tSerialize State:\t$(fmu.modelDescription.coSimulation.canSerializeFMUstate)")
println("\t\tGet/Set State:\t\t$(fmu.modelDescription.coSimulation.canGetAndSetFMUState)")
println("\t\tSerialize State:\t$(fmu.modelDescription.coSimulation.canSerializeFMUState)")
println("\t\tDir. Derivatives:\t$(fmu.modelDescription.coSimulation.providesDirectionalDerivatives)")
println("\t\tAdj. Derivatives:\t$(fmu.modelDescription.coSimulation.providesAdjointDerivatives)")
println("\t\tEvent Mode:\t$(fmu.modelDescription.coSimulation.hasEventMode)")
Expand All @@ -116,20 +132,20 @@ function info(fmu::FMU3)
println("\t\tMax order out. der.:\t$(fmu.modelDescription.coSimulation.maxOutputDerivativeOrder)")
end

println("\tSupports Model-Exchange:\t$(fmi3IsModelExchange(fmu))")
if fmi3IsModelExchange(fmu)
println("\tSupports Model-Exchange:\t$(isModelExchange(fmu))")
if isModelExchange(fmu)
println("\t\tModel identifier:\t$(fmu.modelDescription.modelExchange.modelIdentifier)")
println("\t\tGet/Set State:\t\t$(fmu.modelDescription.modelExchange.canGetAndSetFMUstate)")
println("\t\tSerialize State:\t$(fmu.modelDescription.modelExchange.canSerializeFMUstate)")
println("\t\tGet/Set State:\t\t$(fmu.modelDescription.modelExchange.canGetAndSetFMUState)")
println("\t\tSerialize State:\t$(fmu.modelDescription.modelExchange.canSerializeFMUState)")
println("\t\tDir. Derivatives:\t$(fmu.modelDescription.modelExchange.providesDirectionalDerivatives)")
println("\t\tAdj. Derivatives:\t$(fmu.modelDescription.modelExchange.providesAdjointDerivatives)")
end

println("\tSupports Scheduled-Execution:\t$(fmi3IsScheduledExecution(fmu))")
if fmi3IsScheduledExecution(fmu)
println("\tSupports Scheduled-Execution:\t$(isScheduledExecution(fmu))")
if isScheduledExecution(fmu)
println("\t\tModel identifier:\t$(fmu.modelDescription.scheduledExecution.modelIdentifier)")
println("\t\tGet/Set State:\t\t$(fmu.modelDescription.scheduledExecution.canGetAndSetFMUstate)")
println("\t\tSerialize State:\t$(fmu.modelDescription.scheduledExecution.canSerializeFMUstate)")
println("\t\tGet/Set State:\t\t$(fmu.modelDescription.scheduledExecution.canGetAndSetFMUState)")
println("\t\tSerialize State:\t$(fmu.modelDescription.scheduledExecution.canSerializeFMUState)")
println("\t\tNeeds Execution Tool:\t$(fmu.modelDescription.scheduledExecution.needsExecutionTool)")
println("\t\tInstantiated Once Per Process:\t$(fmu.modelDescription.scheduledExecution.canBeInstantiatedOnlyOncePerProcess)")
println("\t\tPer Element Dependencies:\t$(fmu.modelDescription.scheduledExecution.providesPerElementDependencies)")
Expand Down
2 changes: 2 additions & 0 deletions test/FMI2/model_description.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ myFMU = loadFMU("SpringFrictionPendulum1D", ENV["EXPORTINGTOOL"], ENV["EXPORTING
@test getDefaultTolerance(myFMU.modelDescription) 1e-4
@test getDefaultStepSize(myFMU.modelDescription) === nothing

info(myFMU) # check if there is an error thrown

# comfort getters (dictionaries)

@test length(getValueReferencesAndNames(myFMU.modelDescription)) == 42
Expand Down
2 changes: 2 additions & 0 deletions test/FMI3/model_description.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ myFMU = loadFMU("BouncingBall", "ModelicaReferenceFMUs", "0.0.20", "3.0")
@test getDefaultTolerance(myFMU.modelDescription) === nothing
@test getDefaultStepSize(myFMU.modelDescription) === 0.01

info(myFMU) # check if there is an error thrown

unloadFMU(myFMU)

2 comments on commit 491c978

@ThummeTo
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/113409

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.3 -m "<description of version>" 491c978949027349ef245c88c5d9e028add9c317
git push origin v1.0.3

Please sign in to comment.