From a9650c1f6d02ea0a5529fba4e72d8ffce6dea342 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 16 May 2024 11:31:08 +0200 Subject: [PATCH 01/25] Update cli.rst --- docs/user/cli.rst | 128 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) diff --git a/docs/user/cli.rst b/docs/user/cli.rst index 5e6e03a2e..eb54b1e75 100644 --- a/docs/user/cli.rst +++ b/docs/user/cli.rst @@ -1,5 +1,131 @@ .. _cli: Command Line Interface +====================== + +The command line interface options is available via the cli option :code:`--help`. + + +.. code-block:: bash + + Usage: + + + maestro [-hV] [COMMAND] + + Description: + + Mable for co-simulating models + + Options: + -h, --help Show this help message and exit. + -V, --version Print version information and exit. + Commands: + interpret Interpret a specification using the build in Java interpreter. Remember to place all necessary runtime extensions in the classpath + export Specification export + import Created a specification from various import types. Remember to place all necessary plugin extensions in the classpath. + + Hint for sg1 import where menv should be enabled. Use the following to generate the extra input file:'jq '.parameters|keys|{"environmentParameters":.}' mm.json > menv.json' + sigver Utilise the scenario verifier tool to generate and verify algorithms. It is also possible to execute scenarios and extended multi-models. + +Sub command: import +---------------------- + +.. code-block:: bash + + Usage: maestro import [-hivV] [-di] [-if] [-nop] [-pa] [-output=] + [-vi=] [-fsp=]... + [...] + Created a specification from various import types. Remember to place all + necessary plugin extensions in the classpath. + + Hint for sg1 import where menv should be enabled. Use the following to generate + the extra input file:'jq '.parameters|keys|{"environmentParameters":.}' mm.json + > menv.json' + The valid import formats: Sg1 + [...] One or more specification files + -di, --[no-]dump-intermediate + Dump all intermediate expansions + -fsp, --fmu-search-path= + One or more search paths used to resolve relative FMU + paths. + -h, --help Show this help message and exit. + -i, --interpret Interpret spec after import + -if, --[no-]inline-framework-config + Inline all framework configs + -nop, --[no-]disable-optimize + Disable spec optimization + -output= Path to a directory where the imported spec will be + stored + -pa, --[no-]preserve-annotations + Preserve annotations + -v, --verbose Verbose + -V, --version Print version information and exit. + -vi, --verify= + Verify the spec according to the following verifier + groups: FMI2, Any + + +Sub command: interpret +---------------------- + +.. code-block:: bash + + Usage: maestro interpret [-hvV] [-di] [--[no-]expand] [--[no-]typecheck] [-nop] + [-pa] [-output=] [-runtime=] + [-thz=] + [-tms=] + [-transition=] [-vi=] + [-wait=] [...] + Interpret a specification using the build in Java interpreter. Remember to + place all necessary runtime extensions in the classpath + [...] One or more specification files + -di, --[no-]dump-intermediate + Dump all intermediate expansions + -h, --help Show this help message and exit. + --[no-]expand Perform expand + --[no-]typecheck Perform type check + -nop, --[no-]disable-optimize + Disable spec optimization + -output= Path to a directory where the export will be stored + -pa, --[no-]preserve-annotations + Preserve annotations + -runtime= Path to a runtime file which should be included in + the export + -thz, --transition-check-frequency= + The interval which transition spec will be checked + at. + -tms, --transition-minimum-step= + The minimum step per for each none empty offering of + candidates. It reset once a candidate is + removedchecked at. + -transition= + Path to a directory with a transition specification + -v, --verbose Verbose + -V, --version Print version information and exit. + -vi, --verify= + Verify the spec according to the following verifier + groups: FMI2, Any + -wait= Wait the specified seconds before processing. + Intended for allowing a debugger or profiler to be + attached before the processing starts. + +Sub command: export ---------------------- -The command line interface options is available via the cli option :code:`--help`. \ No newline at end of file + +.. code-block:: bash + + Usage: maestro export [-hvV] [-output=] [-runtime=] + [-vi=] [...] + Specification export + The valid exporters: Cpp + [...] One or more specification files + -h, --help Show this help message and exit. + -output= Path to a directory where the export will be stored + -runtime= Path to a runtime file which should be included in + the export + -v, --verbose Verbose + -V, --version Print version information and exit. + -vi, --verify= + Verify the spec according to the following verifier + groups: FMI2, Any From 9629ffe7b4a6b28c74f69d7bf2cc1e8b2aca08b9 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 16 May 2024 13:25:21 +0200 Subject: [PATCH 02/25] Update cli.rst --- docs/user/cli.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/user/cli.rst b/docs/user/cli.rst index eb54b1e75..74ac0998c 100644 --- a/docs/user/cli.rst +++ b/docs/user/cli.rst @@ -129,3 +129,4 @@ Sub command: export -vi, --verify= Verify the spec according to the following verifier groups: FMI2, Any + From 4f49eb72036abebba6426ee04143d18361ec7554 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 16 May 2024 13:30:43 +0200 Subject: [PATCH 03/25] Update .readthedocs.yml --- .readthedocs.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index b35e26369..fa5055088 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,11 +1,16 @@ # Required version: 2 +build: + os: ubuntu-22.04 + tools: + python: "3.12" + # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py python: - version: 3.7 + version: "3.12" install: - - requirements: docs/requirements.txt \ No newline at end of file + - requirements: docs/requirements.txt From a874d0d557dc97abe2ac82061a065b1532e8b637 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 16 May 2024 13:31:38 +0200 Subject: [PATCH 04/25] Update .readthedocs.yml --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index fa5055088..7a033c8c4 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -11,6 +11,6 @@ sphinx: configuration: docs/conf.py python: - version: "3.12" + version: 3.7 install: - requirements: docs/requirements.txt From fb6f9906f91730b6342904b0fcf1fd6f7e0d9b92 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 16 May 2024 13:32:20 +0200 Subject: [PATCH 05/25] Update .readthedocs.yml --- .readthedocs.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 7a033c8c4..94b1609bc 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -11,6 +11,5 @@ sphinx: configuration: docs/conf.py python: - version: 3.7 install: - requirements: docs/requirements.txt From be532040ffe6b195b2471f92135b6ac41e02511c Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 16 May 2024 13:33:20 +0200 Subject: [PATCH 06/25] Update .readthedocs.yml --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 94b1609bc..5aba58369 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -4,7 +4,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.12" + python: "3.7" # Build documentation in the docs/ directory with Sphinx sphinx: From e5c0c8a8ac06cd4c56459436953834ca045ef6c8 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 16 May 2024 13:34:58 +0200 Subject: [PATCH 07/25] Update requirements.txt --- docs/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/requirements.txt b/docs/requirements.txt index 94ad4488e..f3b5a044b 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,3 @@ sphinxcontrib-plantuml==0.18 recommonmark==0.7.1 +sphinx_rtd_theme From b158cca975964dd69fadeacd80be629712af6ecd Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 16 May 2024 13:41:59 +0200 Subject: [PATCH 08/25] Update requirements.txt --- docs/requirements.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index f3b5a044b..a9064a29a 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,13 @@ sphinxcontrib-plantuml==0.18 recommonmark==0.7.1 -sphinx_rtd_theme + + +pillow==5.4.1 +mock==1.0.1 +alabaster>=0.7,<0.8,!=0.7.5 +commonmark==0.9.1 +recommonmark==0.5.0 +sphinx<2 +sphinx-rtd-theme<0.5 +readthedocs-sphinx-ext<2.3 +jinja2<3.1.0 From d51785e306486f5720fadf805ddf4269613eb668 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 16 May 2024 13:51:04 +0200 Subject: [PATCH 09/25] Update requirements.txt --- docs/requirements.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index a9064a29a..e35d91477 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,12 +2,7 @@ sphinxcontrib-plantuml==0.18 recommonmark==0.7.1 -pillow==5.4.1 -mock==1.0.1 -alabaster>=0.7,<0.8,!=0.7.5 -commonmark==0.9.1 -recommonmark==0.5.0 + sphinx<2 sphinx-rtd-theme<0.5 readthedocs-sphinx-ext<2.3 -jinja2<3.1.0 From f78489a0c51db8faab7387fed6a486c6487b6394 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 16 May 2024 13:52:21 +0200 Subject: [PATCH 10/25] Update requirements.txt --- docs/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/requirements.txt b/docs/requirements.txt index e35d91477..64b967fd2 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -6,3 +6,4 @@ recommonmark==0.7.1 sphinx<2 sphinx-rtd-theme<0.5 readthedocs-sphinx-ext<2.3 +jinja2<3.1.0 From a818fe320c85613ced73a80cdad4a8b7ebc836fe Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 13 Jun 2024 14:13:41 +0200 Subject: [PATCH 11/25] do not use local cmake on mac CI --- maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java b/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java index 4c2bfde44..04ad278e7 100644 --- a/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java +++ b/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java @@ -140,7 +140,7 @@ String toPath(File file) { public boolean generate(File source, File build, File install) throws IOException, InterruptedException, CMakeGenerateException { String cmake = "cmake"; - if (isMac()) { + if (isMac() && "true".equals(System.getenv("CI"))) { cmake = "/usr/local/bin/cmake"; } From 503f2fc33620e3ee24ecbbba9a76e79b78a2c9cf Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 20 Jun 2024 12:57:41 +0200 Subject: [PATCH 12/25] Update CMakeUtil.java --- maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java b/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java index 04ad278e7..94edbdafb 100644 --- a/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java +++ b/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java @@ -140,7 +140,7 @@ String toPath(File file) { public boolean generate(File source, File build, File install) throws IOException, InterruptedException, CMakeGenerateException { String cmake = "cmake"; - if (isMac() && "true".equals(System.getenv("CI"))) { + if (isMac() && !"true".equals(System.getenv("CI"))) { cmake = "/usr/local/bin/cmake"; } From 28dc9e7940dc971953b16bb152d37093c0567a1a Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 20 Jun 2024 13:11:54 +0200 Subject: [PATCH 13/25] updated cpp code gen zip lib to v1.10.1 --- .../org/intocps/maestro/codegen/mabl2cpp/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codegen/mabl2cpp/src/main/resources/org/intocps/maestro/codegen/mabl2cpp/CMakeLists.txt b/codegen/mabl2cpp/src/main/resources/org/intocps/maestro/codegen/mabl2cpp/CMakeLists.txt index d95e828df..819c595ce 100644 --- a/codegen/mabl2cpp/src/main/resources/org/intocps/maestro/codegen/mabl2cpp/CMakeLists.txt +++ b/codegen/mabl2cpp/src/main/resources/org/intocps/maestro/codegen/mabl2cpp/CMakeLists.txt @@ -27,7 +27,7 @@ SET(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries") FetchContent_Declare(libzip GIT_REPOSITORY https://github.com/nih-at/libzip.git - GIT_TAG v1.7.3 + GIT_TAG v1.10.1 GIT_SHALLOW ON SOURCE_DIR "${CMAKE_BINARY_DIR}/libzip" @@ -101,4 +101,4 @@ endif() install(TARGETS sim RUNTIME DESTINATION bin - LIBRARY DESTINATION bin) \ No newline at end of file + LIBRARY DESTINATION bin) From df453edd3b1b4127865436dca37386b2bacfc559 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 20 Jun 2024 13:17:02 +0200 Subject: [PATCH 14/25] only use local cmake if not CI env --- maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java b/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java index 94edbdafb..8d4cc1706 100644 --- a/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java +++ b/maestro/src/test/java/org/intocps/maestro/util/CMakeUtil.java @@ -140,7 +140,7 @@ String toPath(File file) { public boolean generate(File source, File build, File install) throws IOException, InterruptedException, CMakeGenerateException { String cmake = "cmake"; - if (isMac() && !"true".equals(System.getenv("CI"))) { + if (isMac() && System.getenv("CI")==null) { cmake = "/usr/local/bin/cmake"; } From 07d7ae5212d898e1cda914ab2e06959acb5910ab Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 20 Jun 2024 13:48:17 +0200 Subject: [PATCH 15/25] macos-latest-large (so not arm) --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 36d775cff..deea3db3e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -16,7 +16,7 @@ env: PYTHON_VERSION: '3.12.2' MAVEN_VERSION: 3.8.1 WINDOWS_VERSION: 'windows-2019' - MACOS_VERSION: 'macos-latest' + MACOS_VERSION: 'macos-latest-large' MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn From 3d5871b5a2ec1e812a35708c9d2574136f2fba24 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 20 Jun 2024 15:59:24 +0200 Subject: [PATCH 16/25] Update maven.yml --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index deea3db3e..9a075ce0d 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-22.04, windows-2019, macos-latest ] + os: [ ubuntu-22.04, windows-2019, macos-latest-large ] steps: From 5862d445cb07c3331f695b6ab52da7d3c805f1c6 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 20 Jun 2024 16:01:19 +0200 Subject: [PATCH 17/25] Update maven.yml --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9a075ce0d..bdc7d1af1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -16,7 +16,7 @@ env: PYTHON_VERSION: '3.12.2' MAVEN_VERSION: 3.8.1 WINDOWS_VERSION: 'windows-2019' - MACOS_VERSION: 'macos-latest-large' + MACOS_VERSION: 'macos-13' MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-22.04, windows-2019, macos-latest-large ] + os: [ ubuntu-22.04, windows-2019, macos-13 ] steps: From 836a4076429d37872ea107809e83b220bac1fe82 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Tue, 16 Jul 2024 12:05:58 +0200 Subject: [PATCH 18/25] disable FullSpecCppTest on windows --- maestro/src/test/java/org/intocps/maestro/FullSpecCppTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/maestro/src/test/java/org/intocps/maestro/FullSpecCppTest.java b/maestro/src/test/java/org/intocps/maestro/FullSpecCppTest.java index 6bb894033..4a982835f 100644 --- a/maestro/src/test/java/org/intocps/maestro/FullSpecCppTest.java +++ b/maestro/src/test/java/org/intocps/maestro/FullSpecCppTest.java @@ -15,6 +15,8 @@ import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import java.io.File; import java.io.IOException; @@ -28,6 +30,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +@DisabledOnOs(OS.WINDOWS) public class FullSpecCppTest extends FullSpecTest { public static final List CACHE_FOLDERS = Arrays.asList("libzip", "rapidjson", "intocpsfmi-src"); static final File baseProjectPath = Paths.get("target", FullSpecCppTest.class.getSimpleName(), "_base").toFile().getAbsoluteFile(); From adba61946862439045dd108c1af153b8b49bbbab Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Tue, 16 Jul 2024 14:41:58 +0200 Subject: [PATCH 19/25] fix for name mismatch --- .../main/java/org/intocps/maestro/plugin/ModelSwapBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/jacobianstepbuilder/src/main/java/org/intocps/maestro/plugin/ModelSwapBuilder.java b/plugins/jacobianstepbuilder/src/main/java/org/intocps/maestro/plugin/ModelSwapBuilder.java index 91b05a536..5965c4b9b 100644 --- a/plugins/jacobianstepbuilder/src/main/java/org/intocps/maestro/plugin/ModelSwapBuilder.java +++ b/plugins/jacobianstepbuilder/src/main/java/org/intocps/maestro/plugin/ModelSwapBuilder.java @@ -28,7 +28,7 @@ static PortFmi2Api getSwapSourcePort(PortFmi2Api port, Setpair.getValue().getEnvironmentName().equals(source)).map(pair->pair.getValue().getPort(relation.get().getSource().getName())).findFirst().orElse(null);//)..getPort(relation.get().getSource().getName()); } return sourcePort; } From bede2dfa31aeeefb653b6ece0f16b796d283660a Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Tue, 16 Jul 2024 14:42:14 +0200 Subject: [PATCH 20/25] disable test --- .../test/java/org/intocps/maestro/fmi3/BuilderFmi3Test.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maestro/src/test/java/org/intocps/maestro/fmi3/BuilderFmi3Test.java b/maestro/src/test/java/org/intocps/maestro/fmi3/BuilderFmi3Test.java index 5cbe01546..f088df72d 100644 --- a/maestro/src/test/java/org/intocps/maestro/fmi3/BuilderFmi3Test.java +++ b/maestro/src/test/java/org/intocps/maestro/fmi3/BuilderFmi3Test.java @@ -28,6 +28,7 @@ import org.intocps.maestro.typechecker.TypeChecker; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.File; @@ -198,12 +199,13 @@ public void testClocks() throws Exception { } @Test + @Disabled public void testSimulateClocks() throws Exception { MablApiBuilder builder = new MablApiBuilder(); DynamicActiveBuilderScope scope = builder.getDynamicScope(); InstanceVariableFmi3Api instance = createInstance(builder, "clocks", - new File("target/Fmi3ModuleReferenceFmusTest/cache/Clocks.fmu").getAbsoluteFile().toURI()); + new File("src/test/resources/fmi3/sinewave_array.fmu").getAbsoluteFile().toURI()); // fd.enterInitializationMode(false, 0.0, 0.0, true, 10.0); From 179117f63fee76a7a424e1507d856c5fb7455b2b Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Tue, 16 Jul 2024 12:05:58 +0200 Subject: [PATCH 21/25] disable test --- .../java/org/intocps/maestro/FullSpecCppTest.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/maestro/src/test/java/org/intocps/maestro/FullSpecCppTest.java b/maestro/src/test/java/org/intocps/maestro/FullSpecCppTest.java index c0e6cd542..9a1ea00ec 100644 --- a/maestro/src/test/java/org/intocps/maestro/FullSpecCppTest.java +++ b/maestro/src/test/java/org/intocps/maestro/FullSpecCppTest.java @@ -14,6 +14,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; import java.io.File; import java.io.IOException; @@ -27,6 +29,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +@DisabledOnOs(OS.WINDOWS) public class FullSpecCppTest extends FullSpecTest { public static final List CACHE_FOLDERS = Arrays.asList("libzip", "rapidjson", "intocpsfmi-src"); static final File baseProjectPath = Paths.get("target", FullSpecCppTest.class.getSimpleName(), "_base").toFile().getAbsoluteFile(); @@ -79,7 +82,7 @@ protected boolean getMablVerbose() { @Override protected void postProcessSpec(String name, File directory, File workingDirectory, Mabl mabl, ARootDocument spec, - Map value) throws Exception { + Map value) throws Exception { if (!beforeExecuted) { configureBaseProject(); } @@ -139,8 +142,8 @@ protected void postProcessSpec(String name, File directory, File workingDirector spec.apply(new DepthFirstAnalysisAdaptor() { @Override public void caseALoadExp(ALoadExp node) { - if (node.getArgs().size() == 3 && node.getArgs().get(0) instanceof AStringLiteralExp && ((AStringLiteralExp) node.getArgs() - .get(0)).getValue().equals("FMI2")) { + if (node.getArgs().size() == 3 && node.getArgs().get(0) instanceof AStringLiteralExp && + ((AStringLiteralExp) node.getArgs().get(0)).getValue().equals("FMI2")) { if (node.getArgs().get(2) instanceof AStringLiteralExp) { fmus.add(new File(((AStringLiteralExp) node.getArgs().get(2)).getValue())); } @@ -168,8 +171,8 @@ public void caseALoadExp(ALoadExp node) { } pb = new ProcessBuilder(simProjectSimFile.getAbsolutePath(), "-runtime", runtimeFileTest.getAbsolutePath()); - File simulationWorkingDir = directory.getAbsoluteFile().getParentFile().getParentFile().getParentFile().getParentFile() - .getParentFile().getParentFile(); + File simulationWorkingDir = + directory.getAbsoluteFile().getParentFile().getParentFile().getParentFile().getParentFile().getParentFile().getParentFile(); System.out.println("Simulation working dir: " + simulationWorkingDir); pb.directory(simulationWorkingDir); Assertions.assertTrue(CMakeUtil.runProcess(pb, true), "Simulation did not complete without errors (" + name + ")"); From ef8c836c7016f4d90399c56b1796275cf5194a9d Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Tue, 16 Jul 2024 15:09:31 +0200 Subject: [PATCH 22/25] fix mac version in CI --- .github/workflows/maven.yml | 4 ++-- .github/workflows/release.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 36d775cff..bdc7d1af1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -16,7 +16,7 @@ env: PYTHON_VERSION: '3.12.2' MAVEN_VERSION: 3.8.1 WINDOWS_VERSION: 'windows-2019' - MACOS_VERSION: 'macos-latest' + MACOS_VERSION: 'macos-13' MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-22.04, windows-2019, macos-latest ] + os: [ ubuntu-22.04, windows-2019, macos-13 ] steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 311906464..9150d9653 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ env: PYTHON_VERSION: '3.11.8' MAVEN_VERSION: 3.8.1 WINDOWS_VERSION: 'windows-2019' - MACOS_VERSION: 'macos-latest' + MACOS_VERSION: 'macos-13' @@ -109,10 +109,10 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-22.04, windows-2019, macos-latest ] # ubuntu-latest, , macos-latest + os: [ ubuntu-22.04, windows-2019, macos-13 ] # ubuntu-latest, , macos-13 platform: [ x64 ] #x32, x64 ] exclude: - - os: macos-latest + - os: macos-13 platform: x32 steps: - name: Set up Java From a61f15f0e6b5306891241dcc6f0dd81fa598abcb Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Tue, 16 Jul 2024 17:23:57 +0200 Subject: [PATCH 23/25] added initial support for fmi2 state serialize --- .../maestro/interpreter/Fmi2Interpreter.java | 107 +++++++++++++++++- .../services/EnvironmentFMUComponent.java | 15 +++ pom.xml | 2 +- .../org/intocps/maestro/typechecker/FMI2.mabl | 4 + 4 files changed, 126 insertions(+), 2 deletions(-) diff --git a/interpreter/src/main/java/org/intocps/maestro/interpreter/Fmi2Interpreter.java b/interpreter/src/main/java/org/intocps/maestro/interpreter/Fmi2Interpreter.java index c51f149bb..7af5b06a7 100644 --- a/interpreter/src/main/java/org/intocps/maestro/interpreter/Fmi2Interpreter.java +++ b/interpreter/src/main/java/org/intocps/maestro/interpreter/Fmi2Interpreter.java @@ -79,7 +79,7 @@ public static String getString(Value value) { throw new InterpreterException("Value is not string"); } - public static void checkArgLength(List values, int size) { + public static void checkArgLength(List values, int size) { if (values == null) { throw new InterpreterException("No values passed"); } @@ -487,6 +487,111 @@ public static FmuComponentValue getFmuComponentValue(BufferedOutputStream fmuLog throw new InterpreterException("Invalid value"); + })); + + componentMembers.put("getSerializedFMUstateSize", new FunctionValue.ExternalFunctionValue(fcargs -> { + + checkArgLength(fcargs, 2); + + if (!(fcargs.get(1).isUpdatable())) { + throw new InterpreterException("size value not a reference value"); + } + + Value v = fcargs.get(0).deref(); + Value sizeValue = fcargs.get(1); + + if (v instanceof FmuComponentStateValue && sizeValue.isNumeric()) { + try { + FmuComponentStateValue stateValue = (FmuComponentStateValue) v; + FmuResult res = component.getSerializedFMUstateSize(stateValue.getModule()); + if (res.status == Fmi2Status.OK) { + ((UpdatableValue) sizeValue).setValue(new LongValue(res.result)); + } + return new IntegerValue(res.status.value); + } catch (FmuInvocationException e) { + throw new InterpreterException(e); + } + } + + throw new InterpreterException("Invalid value"); + + + })); + + componentMembers.put("serializeFMUstate", new FunctionValue.ExternalFunctionValue(fcargs -> { + + checkArgLength(fcargs, 3); + + if (!(fcargs.get(2).isUpdatable())) { + throw new InterpreterException("bytes value not a reference value"); + } + + Value v = fcargs.get(0).deref(); + Value sizeValue = fcargs.get(1).deref(); + Value bytesValue = fcargs.get(2); + + if (v instanceof FmuComponentStateValue && sizeValue.isNumeric()) { + try { + FmuComponentStateValue stateValue = (FmuComponentStateValue) v; + NumericValue size = (NumericValue) sizeValue; + FmuResult res = component.serializeFMUstate(stateValue.getModule(), size.longValue()); + + if (res.status == Fmi2Status.OK) { + List byteValues = new Vector<>(); + for (byte b : res.result) { + byteValues.add(new ByteValue(b)); + } + + ((UpdatableValue) bytesValue).setValue(new ArrayValue<>(byteValues)); + } + return new IntegerValue(res.status.value); + } catch (FmuInvocationException e) { + throw new InterpreterException(e); + } + } + + throw new InterpreterException("Invalid value"); + + + })); + + componentMembers.put("deSerializeFMUstate", new FunctionValue.ExternalFunctionValue(fcargs -> { + + checkArgLength(fcargs, 3); + + if (!(fcargs.get(2).isUpdatable())) { + throw new InterpreterException("bytes value not a reference value"); + } + + Value bytesValue = fcargs.get(0).deref(); + Value sizeValue = fcargs.get(1).deref(); + Value stateValue = fcargs.get(2); + + if (stateValue instanceof FmuComponentStateValue && sizeValue.isNumeric()) { + try { + NumericValue size = (NumericValue) sizeValue; + ArrayValue byteArray = (ArrayValue) bytesValue; + byte[] bytes = new byte[byteArray.getValues().size()]; + for (int i = 0; i < bytes.length; i++) { + bytes[i] = (byte) byteArray.getValues().get(i).getValue(); + } + + FmuResult res = component.deSerializeFMUstate(bytes, size.longValue()); + + if (res.status == Fmi2Status.OK) { + UpdatableValue ref = (UpdatableValue) stateValue; + ref.setValue(new FmuComponentStateValue(res.result)); + } + + return new IntegerValue(res.status.value); + } catch (FmuInvocationException e) { + throw new InterpreterException(e); + } + } + + throw new InterpreterException("Invalid value"); + + })); componentMembers.put("getRealStatus", new FunctionValue.ExternalFunctionValue(fcargs -> { diff --git a/maestro-webapi/src/main/java/org/intocps/maestro/webapi/services/EnvironmentFMUComponent.java b/maestro-webapi/src/main/java/org/intocps/maestro/webapi/services/EnvironmentFMUComponent.java index 4607a9cec..d17b8afe2 100644 --- a/maestro-webapi/src/main/java/org/intocps/maestro/webapi/services/EnvironmentFMUComponent.java +++ b/maestro-webapi/src/main/java/org/intocps/maestro/webapi/services/EnvironmentFMUComponent.java @@ -92,6 +92,21 @@ public void freeInstance() throws FmuInvocationException { } + @Override + public FmuResult getSerializedFMUstateSize(IFmiComponentState iFmiComponentState) throws FmuInvocationException { + return new FmuResult<>(Fmi2Status.Error, null); + } + + @Override + public FmuResult serializeFMUstate(IFmiComponentState iFmiComponentState, long l) throws FmuInvocationException { + return new FmuResult<>(Fmi2Status.Error, null); + } + + @Override + public FmuResult deSerializeFMUstate(byte[] bytes, long l) throws FmuInvocationException { + return new FmuResult<>(Fmi2Status.Error, null); + } + @Override public boolean isValid() { return false; diff --git a/pom.xml b/pom.xml index 02bb39e1b..c4976a7e8 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 11 11 2.17.1 - 1.4.1 + 1.4.2-SNAPSHOT 1.0.10 1.7.21 2.13.12 diff --git a/typechecker/src/main/resources/org/intocps/maestro/typechecker/FMI2.mabl b/typechecker/src/main/resources/org/intocps/maestro/typechecker/FMI2.mabl index c30134406..aee6f9602 100644 --- a/typechecker/src/main/resources/org/intocps/maestro/typechecker/FMI2.mabl +++ b/typechecker/src/main/resources/org/intocps/maestro/typechecker/FMI2.mabl @@ -51,6 +51,10 @@ import FmiComponentState; int setState(FmiComponentState state); int freeState(out FmiComponentState state); + int getSerializedFMUstateSize(FmiComponentState state, out long size); + int serializeFMUstate(FmiComponentState state, long size, out byte[] bytes); + int deSerializeFMUstate(byte[] bytes, long size, out FmiComponentState state); + } module FmiComponentState {} From 416e9860964c3c4cf9182571cba99ccd8ff46510 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 15 Aug 2024 10:08:14 +0200 Subject: [PATCH 24/25] fixed issues related to deserialization of state in fmi2 --- .../java/org/intocps/maestro/interpreter/Fmi2Interpreter.java | 4 ++-- .../java/org/intocps/maestro/interpreter/Interpreter.java | 2 +- .../org/intocps/maestro/interpreter/values/IntegerValue.java | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/interpreter/src/main/java/org/intocps/maestro/interpreter/Fmi2Interpreter.java b/interpreter/src/main/java/org/intocps/maestro/interpreter/Fmi2Interpreter.java index 7af5b06a7..cdadb765f 100644 --- a/interpreter/src/main/java/org/intocps/maestro/interpreter/Fmi2Interpreter.java +++ b/interpreter/src/main/java/org/intocps/maestro/interpreter/Fmi2Interpreter.java @@ -500,7 +500,7 @@ public static FmuComponentValue getFmuComponentValue(BufferedOutputStream fmuLog Value v = fcargs.get(0).deref(); Value sizeValue = fcargs.get(1); - if (v instanceof FmuComponentStateValue && sizeValue.isNumeric()) { + if (v instanceof FmuComponentStateValue && sizeValue.deref().isNumeric()) { try { FmuComponentStateValue stateValue = (FmuComponentStateValue) v; FmuResult res = component.getSerializedFMUstateSize(stateValue.getModule()); @@ -567,7 +567,7 @@ public static FmuComponentValue getFmuComponentValue(BufferedOutputStream fmuLog Value sizeValue = fcargs.get(1).deref(); Value stateValue = fcargs.get(2); - if (stateValue instanceof FmuComponentStateValue && sizeValue.isNumeric()) { + if ( sizeValue.isNumeric()) { try { NumericValue size = (NumericValue) sizeValue; ArrayValue byteArray = (ArrayValue) bytesValue; diff --git a/interpreter/src/main/java/org/intocps/maestro/interpreter/Interpreter.java b/interpreter/src/main/java/org/intocps/maestro/interpreter/Interpreter.java index cc6244ced..4b77b8144 100644 --- a/interpreter/src/main/java/org/intocps/maestro/interpreter/Interpreter.java +++ b/interpreter/src/main/java/org/intocps/maestro/interpreter/Interpreter.java @@ -202,7 +202,7 @@ public Value caseANotEqualBinaryExp(ANotEqualBinaryExp node, Context question) t public ArrayValue createArrayValue(List sizes, PType type, Context question) throws AnalysisException { List arrayValues = new ArrayList<>(); - for (int i = 0; i < ((NumericValue) sizes.get(0).apply(this, question)).intValue(); i++) { + for (int i = 0; i < ((NumericValue) sizes.get(0).apply(this, question).deref()).intValue(); i++) { if (sizes.size() > 1) { List nextSizes = sizes.subList(1, sizes.size()); // Call recursively diff --git a/interpreter/src/main/java/org/intocps/maestro/interpreter/values/IntegerValue.java b/interpreter/src/main/java/org/intocps/maestro/interpreter/values/IntegerValue.java index fe5f32991..f65674e8d 100644 --- a/interpreter/src/main/java/org/intocps/maestro/interpreter/values/IntegerValue.java +++ b/interpreter/src/main/java/org/intocps/maestro/interpreter/values/IntegerValue.java @@ -48,6 +48,10 @@ public int compareTo(Value other) { if (other instanceof IntegerValue || other instanceof ByteValue || other instanceof ShortValue) { NumericValue io = (NumericValue) other; return (value < io.intValue() ? -1 : (value == io.intValue() ? 0 : 1)); + }else if( other instanceof LongValue) + { + NumericValue io = (NumericValue) other; + return (value < io.longValue() ? -1 : (value == io.longValue() ? 0 : 1)); } return super.compareTo(other); From 35b3fbc95774129d3724d4b94c562e9933a36534 Mon Sep 17 00:00:00 2001 From: Kenneth Lausdahl Date: Thu, 15 Aug 2024 12:03:03 +0200 Subject: [PATCH 25/25] updated native fmu api and added serialize test --- .../intocps/maestro/FullSpecOnlineTest.java | 1 + .../org/intocps/maestro/OnlineTestUtils.java | 42 ++++++++- .../online/serialize/serialize.mabl | 85 +++++++++++++++++++ pom.xml | 4 +- 4 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 maestro/src/test/resources/specifications/online/serialize/serialize.mabl diff --git a/maestro/src/test/java/org/intocps/maestro/FullSpecOnlineTest.java b/maestro/src/test/java/org/intocps/maestro/FullSpecOnlineTest.java index 3ab9e039e..bad207cff 100644 --- a/maestro/src/test/java/org/intocps/maestro/FullSpecOnlineTest.java +++ b/maestro/src/test/java/org/intocps/maestro/FullSpecOnlineTest.java @@ -26,6 +26,7 @@ private static Stream data() { @ParameterizedTest(name = "{index} \"{0}\"") @MethodSource("data") public void test(String name, File directory) throws Exception { + OnlineTestUtils.downloadJniFmuTestFmus(); for (INode spec : parse(getSpecificationFiles(directory))) { OnlineTestUtils.download(OnlineTestUtils.collectFmus(spec, false)); } diff --git a/maestro/src/test/java/org/intocps/maestro/OnlineTestUtils.java b/maestro/src/test/java/org/intocps/maestro/OnlineTestUtils.java index 07d319afd..dd89a4811 100644 --- a/maestro/src/test/java/org/intocps/maestro/OnlineTestUtils.java +++ b/maestro/src/test/java/org/intocps/maestro/OnlineTestUtils.java @@ -1,6 +1,7 @@ package org.intocps.maestro; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.intocps.maestro.ast.analysis.AnalysisException; import org.intocps.maestro.ast.analysis.DepthFirstAnalysisAdaptor; import org.intocps.maestro.ast.node.ALoadExp; @@ -9,11 +10,15 @@ import org.intocps.maestro.ast.node.PExp; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.List; import java.util.Vector; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; public class OnlineTestUtils { @@ -26,9 +31,9 @@ public static void download(List urls) throws IOException { String file = url.getFile(); file = file.substring(file.lastIndexOf('/') + 1); File destination = new File("target/online-cache/" + file); - if (!destination.exists()) { + if (!destination.exists() && !destination.getName().endsWith("functiontest.fmu")) { - URL zipNameUrl =new URL( url.toString().replace(".fmu",".zip")); + URL zipNameUrl = new URL(url.toString().replace(".fmu", ".zip")); System.out.println("Downloading: " + zipNameUrl + " as: " + destination); FileUtils.copyURLToFile(zipNameUrl, destination); @@ -38,6 +43,39 @@ public static void download(List urls) throws IOException { } } + public static void downloadJniFmuTestFmus() throws IOException { + System.out.println("Downloading FMUs"); + URL url = new URL("https://github.com/INTO-CPS-Association/org.intocps.maestro.fmi/releases/download/Release%2F1.5.0/test-fmus.zip"); + String file = url.getFile(); + file = file.substring(file.lastIndexOf('/') + 1); + File destination = new File("target/online-cache/" + file); + if (!destination.exists()) { + +// URL zipNameUrl = new URL(url.toString().replace(".fmu", ".zip")); + + System.out.println("Downloading: " + url + " as: " + destination); + FileUtils.copyURLToFile(url, destination); + //lets unpack the fmus + if (destination.exists() && destination.isFile()) { + try (FileInputStream fis = new FileInputStream(destination); + ZipInputStream zis = new ZipInputStream(fis)) { + ZipEntry entry = zis.getNextEntry(); + while (entry != null) { + if (entry.getName().endsWith("functiontest.fmu")) { + IOUtils.copy(zis, new FileOutputStream("target/online-cache/" + new File(entry.getName()).getName())); + + } + zis.closeEntry(); + entry = zis.getNextEntry(); + } + } + } + } else { + System.out.println("Skipped - Downloading: " + url + " as: " + destination); + } + } + + public static List collectFmus(INode spec, boolean updatePath) throws AnalysisException { class FmuCollector extends DepthFirstAnalysisAdaptor { final List fmus = new Vector<>(); diff --git a/maestro/src/test/resources/specifications/online/serialize/serialize.mabl b/maestro/src/test/resources/specifications/online/serialize/serialize.mabl new file mode 100644 index 000000000..599a72372 --- /dev/null +++ b/maestro/src/test/resources/specifications/online/serialize/serialize.mabl @@ -0,0 +1,85 @@ +simulation +import Math; +import FMI2; +import DataWriter; +import Logger; +import FmiComponentState; +{ + Logger logger = load("Logger"); + FMI2 fmu = load("FMI2", "{12345678-9999-9999-9999-000000000000}", "target/online-cache/fmi2functiontest.fmu"); + FMI2Component comp = fmu.instantiate("crtlInstance", false, false); + int status=0; + status = comp.setupExperiment(false, 0.0, 0.0, true, 10.0); + logger.log(1, "Status setupExperiment: %d", status); + + status = comp.enterInitializationMode(); + logger.log(1, "Status enterInitializationMode: %d", status); + + FmiComponentState state0; + status = comp.getState(ref state0); + logger.log(1, "Status getState: %d", status); + + uint vr[1]={0}; + uint nvr=1; + real values[1]= {99.9}; + status = comp.setReal(vr,nvr,values); + logger.log(1, "Status setReal: %d", status); + + status = comp.exitInitializationMode(); + logger.log(1, "Status exitInitializationMode: %d", status); + + FmiComponentState state; + status = comp.getState(ref state); + logger.log(1, "Status getState: %d", status); + + int size=0; + status = comp.getSerializedFMUstateSize(state,ref size); + logger.log(1, "Status getSerializedFMUstateSize: %d", status); + logger.log(1, "State size: %d", size); + + byte bytes[size]; + status = comp.serializeFMUstate(state, size,ref bytes); + logger.log(1, "Status serializeFMUstate: %d", status); + int i = 0; + logger.log(1, "The state bytes:",""); + while(i11 11 2.17.1 - 1.4.2-SNAPSHOT + 1.5.0 1.0.10 1.7.21 2.13.12 @@ -418,7 +418,7 @@ commons-io commons-io - 2.10.0 + 2.15.1 compile