Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.0.1 #11

Merged
merged 12 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FMIBase"
uuid = "900ee838-d029-460e-b485-d98a826ceef2"
authors = ["TT <[email protected]>", "LM <[email protected]>"]
version = "1.0.0"
version = "1.0.1"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand All @@ -24,6 +24,16 @@ MAT = "23992714-dd62-5051-b70f-ba57cb901cac"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"

# This is necessary to prevent errors with Julia 1.6 while using `compat`, in latest Julia, this is not necessary anymore.
[extras]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
MAT = "23992714-dd62-5051-b70f-ba57cb901cac"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"

[extensions]
CSVExt = ["CSV"]
DataFramesExt = ["DataFrames"]
Expand All @@ -34,14 +44,21 @@ PlotsExt = ["Plots"]
ReverseDiffExt = ["ReverseDiff"]

[compat]
CSV = "0.10"
ChainRulesCore = "1.20 - 1.23"
DataFrames = "1"
DiffEqCallbacks = "2.0 - 3.6"
EzXML = "1.1 - 1.2"
FMICore = "1.0.1"
MAT = "0.10"
JLD2 = "0.4"
ForwardDiff = "0.10"
PackageExtensionCompat = "1.0.0"
Plots = "1"
ProgressMeter = "1.7"
Reexport = "1.0 - 1.2"
Requires = "1.3.0"
ReverseDiff = "1"
SciMLBase = "2.0"
ZipFile = "0.10.0"
julia = "1.6"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[*FMIBase.jl*](https://github.com/ThummeTo/FMIBase.jl) provides the foundation for the Julia packages [*FMIImport.jl*](https://github.com/ThummeTo/FMIImport.jl) and [*FMIExport.jl*](https://github.com/ThummeTo/FMIExport.jl).

[![Dev Docs](https://img.shields.io/badge/docs-dev-blue.svg)](https://ThummeTo.github.io/FMI.jl/dev)
[![Run Tests](https://github.com/ThummeTo/FMIBase.jl/actions/workflows/Test.yml/badge.svg)](https://github.com/ThummeTo/FMIBase.jl/actions/workflows/Test.yml)
[![Test (latest)](https://github.com/ThummeTo/FMIBase.jl/actions/workflows/TestLatest.yml/badge.svg)](https://github.com/ThummeTo/FMIBase.jl/actions/workflows/TestLatest.yml)
[![Test (LTS)](https://github.com/ThummeTo/FMIBase.jl/actions/workflows/TestLTS.yml/badge.svg)](https://github.com/ThummeTo/FMIBase.jl/actions/workflows/TestLTS.yml)
[![Run PkgEval](https://github.com/ThummeTo/FMIBase.jl/actions/workflows/Eval.yml/badge.svg)](https://github.com/ThummeTo/FMIBase.jl/actions/workflows/Eval.yml)
[![Coverage](https://codecov.io/gh/ThummeTo/FMIBase.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ThummeTo/FMIBase.jl)

Expand Down
20 changes: 10 additions & 10 deletions src/get_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Retrieves values for the refernces `vrs` and stores them in `dst`
function getValue!(comp::FMU2Component, vrs::fmi2ValueReferenceFormat, dstArray::AbstractArray) # [ToDo] implement via array views!
vrs = prepareValueReference(comp, vrs)

@assert length(vrs) == length(dstArray) "fmi2Get!(...): Number of value references doesn't match number of `dstArray` elements."
@assert length(vrs) == length(dstArray) "getValue!(...): Number of value references doesn't match number of `dstArray` elements."

retcodes = collect(fmi2StatusOK for i in 1:length(vrs))

Expand All @@ -43,13 +43,13 @@ function getValue!(comp::FMU2Component, vrs::fmi2ValueReferenceFormat, dstArray:
elseif mv.Boolean != nothing
#@assert isa(dstArray[i], Union{Real, Bool}) "fmi2Get!(...): Unknown data type for value reference `$(vr)` at index $(i), should be `Bool`, is `$(typeof(dstArray[i]))`."
values = zeros(fmi2Boolean, num)
fmi2GetBoolean(comp, [vr], num, values)
fmi2GetBoolean!(comp, [vr], num, values)
dstArray[i] = values[1]
elseif mv.String != nothing
#@assert isa(dstArray[i], String) "fmi2Get!(...): Unknown data type for value reference `$(vr)` at index $(i), should be `String`, is `$(typeof(dstArray[i]))`."
values = zeros(fmi2String, num)
values = Vector{fmi2String}(undef, num)
fmi2GetString!(comp, [vr], num, values)
dstArray[i] = values[1]
dstArray[i] = unsafe_string(values[1])
elseif mv.Enumeration != nothing
@warn "getValue!(...): Currently not implemented for fmi2Enum."
else
Expand All @@ -62,7 +62,7 @@ end
function getValue!(inst::FMU3Instance, vrs::fmi3ValueReferenceFormat, dstArray::Array)
vrs = prepareValueReference(inst, vrs)

@assert length(vrs) == length(dstArray) "fmi3Get!(...): Number of value references doesn't match number of `dstArray` elements."
@assert length(vrs) == length(dstArray) "getValue!(...): Number of value references doesn't match number of `dstArray` elements."

retcodes = collect(fmi3StatusOK for i in 1:length(vrs))

Expand Down Expand Up @@ -131,12 +131,12 @@ function getValue!(inst::FMU3Instance, vrs::fmi3ValueReferenceFormat, dstArray::
dstArray[i] = values[1]
elseif isa(mv, FMICore.fmi3VariableString)
#@assert isa(dstArray[i], String) "fmi3Get!(...): Unknown data type for value reference `$(vr)` at index $(i), should be `String`, is `$(typeof(dstArray[i]))`."
values = zeros(fmi3String, num)
values = Vector{fmi3String}(undef, num)
fmi3GetString!(inst, [vr], num, values, num)
dstArray[i] = values[1]
dstArray[i] = unsafe_string(values[1])
elseif isa(mv, FMICore.fmi3VariableBinary)
#@assert isa(dstArray[i], String) "fmi3Get!(...): Unknown data type for value reference `$(vr)` at index $(i), should be `String`, is `$(typeof(dstArray[i]))`."
values = zeros(fmi3Binary, num)
values = Vector{fmi3Binary}(undef, num)
fmi3GetBinary!(inst, [vr], num, values, num)
dstArray[i] = values[1]
elseif isa(mv, FMICore.fmi3VariableEnumeration)
Expand Down Expand Up @@ -177,15 +177,15 @@ end
export getValue

"""
setValue(comp::FMU2Component,
setValue(component,
vrs::fmi2ValueReferenceFormat,
srcArray::AbstractArray;
filter=nothing)

Stores the specific value of `fmi2ScalarVariable` containing the modelVariables with the identical fmi2ValueReference and returns an array that indicates the Status.

# Arguments
- `comp::FMU2Component`: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
- `comp::FMUInstance` (FMU2Component or FMU3Instance): Mutable struct represents an instantiated instance of an FMU in the FMI 2 or 3.
- `vrs::fmi2ValueReferenceFormat`: wildcards for how a user can pass a fmi[X]ValueReference
- `srcArray::AbstractArray`: Stores the specific value of `fmi2ScalarVariable` containing the modelVariables with the identical fmi2ValueReference to the input variable vr (vr = vrs[i]). `srcArray` has the same length as `vrs`.

Expand Down
Loading