Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into kel/fmi3-clocks
Browse files Browse the repository at this point in the history
  • Loading branch information
lausdahl committed Sep 16, 2024
2 parents 43d112d + 1aac687 commit 89c594e
Show file tree
Hide file tree
Showing 18 changed files with 416 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'



Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Required
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.7"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

python:
version: 3.7
install:
- requirements: docs/requirements.txt
- requirements: docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -101,4 +101,4 @@ endif()

install(TARGETS sim
RUNTIME DESTINATION bin
LIBRARY DESTINATION bin)
LIBRARY DESTINATION bin)
7 changes: 7 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
sphinxcontrib-plantuml==0.18
recommonmark==0.7.1



sphinx<2
sphinx-rtd-theme<0.5
readthedocs-sphinx-ext<2.3
jinja2<3.1.0
129 changes: 128 additions & 1 deletion docs/user/cli.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,132 @@
.. _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
----------------------
The command line interface options is available via the cli option :code:`--help`.

.. code-block:: bash
Usage: maestro import [-hivV] [-di] [-if] [-nop] [-pa] [-output=<output>]
[-vi=<verify>] [-fsp=<fmuSearchPaths>]... <type>
[<files>...]
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'
<type> The valid import formats: Sg1
[<files>...] One or more specification files
-di, --[no-]dump-intermediate
Dump all intermediate expansions
-fsp, --fmu-search-path=<fmuSearchPaths>
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=<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>
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=<output>] [-runtime=<runtime>]
[-thz=<transitionCheckFrequency>]
[-tms=<transitionMinStep>]
[-transition=<transitionPath>] [-vi=<verify>]
[-wait=<wait>] [<files>...]
Interpret a specification using the build in Java interpreter. Remember to
place all necessary runtime extensions in the classpath
[<files>...] 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=<output> Path to a directory where the export will be stored
-pa, --[no-]preserve-annotations
Preserve annotations
-runtime=<runtime> Path to a runtime file which should be included in
the export
-thz, --transition-check-frequency=<transitionCheckFrequency>
The interval which transition spec will be checked
at.
-tms, --transition-minimum-step=<transitionMinStep>
The minimum step per for each none empty offering of
candidates. It reset once a candidate is
removedchecked at.
-transition=<transitionPath>
Path to a directory with a transition specification
-v, --verbose Verbose
-V, --version Print version information and exit.
-vi, --verify=<verify>
Verify the spec according to the following verifier
groups: FMI2, Any
-wait=<wait> Wait the specified seconds before processing.
Intended for allowing a debugger or profiler to be
attached before the processing starts.
Sub command: export
----------------------

.. code-block:: bash
Usage: maestro export [-hvV] [-output=<output>] [-runtime=<runtime>]
[-vi=<verify>] <type> [<files>...]
Specification export
<type> The valid exporters: Cpp
[<files>...] One or more specification files
-h, --help Show this help message and exit.
-output=<output> Path to a directory where the export will be stored
-runtime=<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>
Verify the spec according to the following verifier
groups: FMI2, Any
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static String getString(Value value) {
throw new InterpreterException("Value is not string");
}

public static void checkArgLength(List<Value> values, int size) {
public static void checkArgLength(List<Value> values, int size) {
if (values == null) {
throw new InterpreterException("No values passed");
}
Expand Down Expand Up @@ -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.deref().isNumeric()) {
try {
FmuComponentStateValue stateValue = (FmuComponentStateValue) v;
FmuResult<Long> 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<byte[]> res = component.serializeFMUstate(stateValue.getModule(), size.longValue());

if (res.status == Fmi2Status.OK) {
List<ByteValue> 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 ( sizeValue.isNumeric()) {
try {
NumericValue size = (NumericValue) sizeValue;
ArrayValue<ByteValue> byteArray = (ArrayValue<ByteValue>) 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<IFmiComponentState> 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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ public void freeInstance() throws FmuInvocationException {

}

@Override
public FmuResult<Long> getSerializedFMUstateSize(IFmiComponentState iFmiComponentState) throws FmuInvocationException {
return new FmuResult<>(Fmi2Status.Error, null);
}

@Override
public FmuResult<byte[]> serializeFMUstate(IFmiComponentState iFmiComponentState, long l) throws FmuInvocationException {
return new FmuResult<>(Fmi2Status.Error, null);
}

@Override
public FmuResult<IFmiComponentState> deSerializeFMUstate(byte[] bytes, long l) throws FmuInvocationException {
return new FmuResult<>(Fmi2Status.Error, null);
}

@Override
public boolean isValid() {
return false;
Expand Down
Loading

0 comments on commit 89c594e

Please sign in to comment.