From 564252e7c7e9f32c678b9089957fd9a4f9c46ad6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:55:18 +0200 Subject: [PATCH 01/11] CompatHelper: add new compat entry for DataFrames in [weakdeps] at version 1, (keep existing compat) (#10) * WIP * rm binaries * WIP * implemented package-ext-feature * min. adjustm. * various bug fixes * bug fixes * dep. to FMICore 1.0.1 * CompatHelper: add new compat entry for DataFrames in [weakdeps] at version 1, (keep existing compat) --------- Co-authored-by: TT Co-authored-by: CompatHelper Julia Co-authored-by: ThummeTo <83663542+ThummeTo@users.noreply.github.com> --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 1ba1903..cab2f91 100644 --- a/Project.toml +++ b/Project.toml @@ -35,6 +35,7 @@ ReverseDiffExt = ["ReverseDiff"] [compat] ChainRulesCore = "1.20 - 1.23" +DataFrames = "1" DiffEqCallbacks = "2.0 - 3.6" EzXML = "1.1 - 1.2" FMICore = "1.0.1" From 1d046b9afaf0910413574181fad0964614cbc686 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:55:54 +0200 Subject: [PATCH 02/11] CompatHelper: add new compat entry for ForwardDiff in [weakdeps] at version 0.10, (keep existing compat) (#9) Co-authored-by: CompatHelper Julia --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index cab2f91..31cd3a9 100644 --- a/Project.toml +++ b/Project.toml @@ -39,6 +39,7 @@ DataFrames = "1" DiffEqCallbacks = "2.0 - 3.6" EzXML = "1.1 - 1.2" FMICore = "1.0.1" +ForwardDiff = "0.10" PackageExtensionCompat = "1.0.0" ProgressMeter = "1.7" Reexport = "1.0 - 1.2" From e28b24b4aaf36be25ab7830a1c801f8815124f2c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:56:10 +0200 Subject: [PATCH 03/11] CompatHelper: add new compat entry for ReverseDiff in [weakdeps] at version 1, (keep existing compat) (#8) Co-authored-by: CompatHelper Julia --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 31cd3a9..a70a644 100644 --- a/Project.toml +++ b/Project.toml @@ -44,6 +44,7 @@ PackageExtensionCompat = "1.0.0" ProgressMeter = "1.7" Reexport = "1.0 - 1.2" Requires = "1.3.0" +ReverseDiff = "1" SciMLBase = "2.0" ZipFile = "0.10.0" julia = "1.6" From 982b97b7ffedcb4dffe8504cf9aeda4233bdd4d6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:56:52 +0200 Subject: [PATCH 04/11] CompatHelper: add new compat entry for Plots in [weakdeps] at version 1, (keep existing compat) (#7) Co-authored-by: CompatHelper Julia --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index a70a644..9e53f3b 100644 --- a/Project.toml +++ b/Project.toml @@ -41,6 +41,7 @@ EzXML = "1.1 - 1.2" FMICore = "1.0.1" ForwardDiff = "0.10" PackageExtensionCompat = "1.0.0" +Plots = "1" ProgressMeter = "1.7" Reexport = "1.0 - 1.2" Requires = "1.3.0" From 5dd8494bea63c5c208b4484ad8e67d68d414e36d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:58:00 +0200 Subject: [PATCH 05/11] CompatHelper: bump compat for ChainRulesCore to 1, (keep existing compat) (#6) Co-authored-by: CompatHelper Julia Co-authored-by: ThummeTo <83663542+ThummeTo@users.noreply.github.com> From b467f816504845f4f1245cd6f906903f0a4f5976 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:58:19 +0200 Subject: [PATCH 06/11] CompatHelper: add new compat entry for CSV in [weakdeps] at version 0.10, (keep existing compat) (#5) Co-authored-by: CompatHelper Julia --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 9e53f3b..bd79512 100644 --- a/Project.toml +++ b/Project.toml @@ -34,6 +34,7 @@ PlotsExt = ["Plots"] ReverseDiffExt = ["ReverseDiff"] [compat] +CSV = "0.10" ChainRulesCore = "1.20 - 1.23" DataFrames = "1" DiffEqCallbacks = "2.0 - 3.6" From 13258e4ad2ac015c81da919ef56594b8a1696eba Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:58:58 +0200 Subject: [PATCH 07/11] CompatHelper: add new compat entry for JLD2 in [weakdeps] at version 0.4, (keep existing compat) (#4) Co-authored-by: CompatHelper Julia Co-authored-by: ThummeTo <83663542+ThummeTo@users.noreply.github.com> --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index bd79512..23bd4be 100644 --- a/Project.toml +++ b/Project.toml @@ -40,6 +40,7 @@ DataFrames = "1" DiffEqCallbacks = "2.0 - 3.6" EzXML = "1.1 - 1.2" FMICore = "1.0.1" +JLD2 = "0.4" ForwardDiff = "0.10" PackageExtensionCompat = "1.0.0" Plots = "1" From bf663b54afb2b3f7d84a784fc7b5c06d0676e2ea Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:59:42 +0200 Subject: [PATCH 08/11] CompatHelper: add new compat entry for MAT in [weakdeps] at version 0.10, (keep existing compat) (#3) Co-authored-by: CompatHelper Julia Co-authored-by: ThummeTo <83663542+ThummeTo@users.noreply.github.com> --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 23bd4be..e827956 100644 --- a/Project.toml +++ b/Project.toml @@ -40,6 +40,7 @@ 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" From fdf1a803aea31490efebbd450504cd0a9d64e278 Mon Sep 17 00:00:00 2001 From: TT Date: Mon, 17 Jun 2024 16:53:15 +0200 Subject: [PATCH 09/11] getValue bug fix (unnamed function, missing "!") --- Project.toml | 2 +- src/get_set.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 1ba1903..05304e4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FMIBase" uuid = "900ee838-d029-460e-b485-d98a826ceef2" authors = ["TT ", "LM "] -version = "1.0.0" +version = "1.0.1" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" diff --git a/src/get_set.jl b/src/get_set.jl index 952085c..cecbb7f 100644 --- a/src/get_set.jl +++ b/src/get_set.jl @@ -43,7 +43,7 @@ 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]))`." From bf4667945c2d1a713d3892a0b6114740fa1d722b Mon Sep 17 00:00:00 2001 From: TT Date: Mon, 17 Jun 2024 17:16:16 +0200 Subject: [PATCH 10/11] fixed extras --- Project.toml | 9 +++++++++ src/get_set.jl | 18 +++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index 9bbab86..5d7e2fb 100644 --- a/Project.toml +++ b/Project.toml @@ -24,6 +24,15 @@ MAT = "23992714-dd62-5051-b70f-ba57cb901cac" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" +[extras] % this is necessary to prevent errors with Julia 1.6 while using `compat` +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"] diff --git a/src/get_set.jl b/src/get_set.jl index cecbb7f..84c71b3 100644 --- a/src/get_set.jl +++ b/src/get_set.jl @@ -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)) @@ -47,9 +47,9 @@ function getValue!(comp::FMU2Component, vrs::fmi2ValueReferenceFormat, dstArray: 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 @@ -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)) @@ -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) @@ -177,7 +177,7 @@ end export getValue """ - setValue(comp::FMU2Component, + setValue(component, vrs::fmi2ValueReferenceFormat, srcArray::AbstractArray; filter=nothing) @@ -185,7 +185,7 @@ export getValue 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`. From 3f505db94e9264b1d28497f46b2979b0aabab221 Mon Sep 17 00:00:00 2001 From: TT Date: Mon, 17 Jun 2024 17:19:32 +0200 Subject: [PATCH 11/11] format --- Project.toml | 3 ++- README.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 5d7e2fb..17b10db 100644 --- a/Project.toml +++ b/Project.toml @@ -24,7 +24,8 @@ MAT = "23992714-dd62-5051-b70f-ba57cb901cac" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" -[extras] % this is necessary to prevent errors with Julia 1.6 while using `compat` +# 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" diff --git a/README.md b/README.md index 748fac2..bced8fc 100644 --- a/README.md +++ b/README.md @@ -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)