open-simulation-platform / libcosimc Goto Github PK
View Code? Open in Web Editor NEWOSP C co-simulation API
License: Mozilla Public License 2.0
OSP C co-simulation API
License: Mozilla Public License 2.0
Following the changes in open-simulation-platform/libcosim#637, moving from boost::filesystem
to std::filesystem
, libcosimc throws compiler error on missing boost::filesystem
.
Hello,
We have the following error when compiling libcosimc on branch feature/conan-2:
[ 12%] Building C object CMakeFiles/execution_from_ssp_test.dir/tests/execution_from_ssp_test.c.o
[ 19%] Built target inital_values_test
[ 25%] Building C object CMakeFiles/execution_from_ssp_custom_algo_test.dir/tests/execution_from_ssp_custom_algo_test.c.o
[ 35%] Built target connections_test
[ 35%] Built target load_config_and_teardown_test
[ 41%] Built target execution_from_osp_config_test
[ 48%] Built target observer_can_buffer_samples
[ 54%] Built target multiple_fmus_execution_test
[ 61%] Built target observer_multiple_slaves_test
[ 77%] Built target observer_initial_samples_test
[ 77%] Built target simulation_error_handling_test
[ 80%] Built target single_fmu_execution_test
[ 87%] Built target time_series_observer_test
[ 93%] Built target variable_metadata_test
In file included from /usr/include/string.h:535,
from /home/developper/DGA/libcosimc/tests/execution_from_ssp_test.c:6:
In function ‘strcpy’,
inlined from ‘main’ at /home/developper/DGA/libcosimc/tests/execution_from_ssp_test.c:63:9:
In file included from /usr/include/string.h:535,
from /home/developper/DGA/libcosimc/tests/execution_from_ssp_custom_algo_test.c:6:
In function ‘strcpy’,
inlined from ‘main’ at /home/developper/DGA/libcosimc/tests/execution_from_ssp_custom_algo_test.c:72:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:79:10: error: ‘__builtin___stpcpy_chk’ offset 2056 is out of the bounds [0, 2056] of object ‘infos’ with type ‘cosim_slave_info[2]’ [-Werror=array-bounds]
79 | return __builtin___strcpy_chk (__dest, __src, __glibc_objsize (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:79:10: error: ‘__builtin___stpcpy_chk’ offset 2056 is out of the bounds [0, 2056] of object ‘infos’ with type ‘cosim_slave_info[2]’ [-Werror=array-bounds]
79 | return __builtin___strcpy_chk (__dest, __src, __glibc_objsize (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/developper/DGA/libcosimc/tests/execution_from_ssp_test.c: In function ‘main’:
/home/developper/DGA/libcosimc/tests/execution_from_ssp_custom_algo_test.c: In function ‘main’:
/home/developper/DGA/libcosimc/tests/execution_from_ssp_test.c:57:22: note: ‘infos’ declared here
57 | cosim_slave_info infos[2];
| ^~~~~
/home/developper/DGA/libcosimc/tests/execution_from_ssp_custom_algo_test.c:66:22: note: ‘infos’ declared here
66 | cosim_slave_info infos[2];
| ^~~~~
cc1: all warnings being treated as errors
cc1: all warnings being treated as errors
gmake[2]: *** [CMakeFiles/execution_from_ssp_custom_algo_test.dir/build.make:76: CMakeFiles/execution_from_ssp_custom_algo_test.dir/tests/execution_from_ssp_custom_algo_test.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:244: CMakeFiles/execution_from_ssp_custom_algo_test.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
gmake[2]: *** [CMakeFiles/execution_from_ssp_test.dir/build.make:76: CMakeFiles/execution_from_ssp_test.dir/tests/execution_from_ssp_test.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:270: CMakeFiles/execution_from_ssp_test.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
The solution is very simple and present on pull request #52 :
for tests execution_from_ssp_custom_algo_test.c, line 66, replace :
cosim_slave_info infos[2];
with
cosim_slave_info infos[3];
The same for execution_from_ssp_test.c, line 57
Could you fix it please?
Thank you!
The C library header is getting big, and will get bigger.
I propose that we should split it.
Refer to #21
On a vehicule (boat, aircraft, rolling vehicle), an external device can be part of the simulation. It should be able to be enabled or disabled by the operator during an experiment without disturbing the global execution of a simulation.
As a | OSP user |
---|---|
I want to | be able to disable / enable a simulator while an execution is running |
So that | the execution continue running with its last output data but without (when disabled) / with (when enabled) executing the simulator "set inputs" and then "do step" and then "get outputs". |
Given that | a simulator is enabled |
---|---|
When | the user disable it |
Then | the simulator is frozen in its current state, i.e. no more interaction are done with the FMU, but its last output values are available to the rest of the platform. The execution is not disturbed at all by this event. |
Given that | a simulator is disabled |
---|---|
When | the user enable it |
Then | the simulator is restarted in its new current state, i.e. interactions restart with the FMU, with its last input values. The execution is not disturbed at all by this event. |
Given that | a simulator is enabled |
---|---|
When | the user enable it |
Then | nothing happens. |
Given that | a simulator is disabled |
---|---|
When | the user disable it |
Then | nothing happens. |
/**
* Enable a slave execution.
*
* \param [in] execution
* The concerned execution.
* \param [in] cosim_slave_index
* The slave to be enabled.
*
* \returns
* 0 on success and -1 on error.
*/
int cosim_execution_enable_slave(cosim_execution* execution, cosim_slave_index slave);
/**
* Disable a slave execution.
*
* \param [in] execution
* The concerned execution.
* \param [in] cosim_slave_index
* The slave to be disabled.
*
* \returns
* 0 on success and -1 on error.
*/
int cosim_execution_disable_slave(cosim_execution* execution, cosim_slave_index slave);
// Slave execution status.
typedef enum
{
COSIM_SLAVE_EXECUTION_DISABLED,
COSIM_SLAVE_EXECUTION_ENABLED
} cosim_slave_execution_status;
/**
* Get a slave execution status.
*
* \param [in] execution
* The concerned execution.
* \param [in] cosim_slave_index
* The slave to be queried.
* \param [out] status
* The slave status.
*
* \returns
* 0 on success and -1 on error (if slave index is invalid for instance).
*/
int cosim_execution_get_slave_execution_status(cosim_execution* execution, cosim_slave_index slave, cosim_slave_execution_status* status);
I want to make use of the libcosimc and tried to compile it from the sources
FROM debian:buster
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y curl unzip git build-essential gcc cmake python3-pip
RUN pip3 install conan \
&& conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-public
RUN curl -L -o libcosimc.zip https://github.com/open-simulation-platform/libcosimc/archive/v0.7.0.zip \
&& unzip libcosimc.zip -d / \
&& cd /libcosimc-0.7.0 \
&& mkdir build \
&& cd build \
&& CONAN_REVISIONS_ENABLED=1 conan install .. -s build_type=Release --build=missing -o libcosim:'fmuproxy=True' --settings=compiler.libcxx=libstdc++11
RUN cd /libcosimc-0.7.0/build \
&& cmake .. -DLIBCOSIM_USING_CONAN=TRUE -DLIBCOSIM_BUILD_APIDOC=OFF -DCMAKE_BUILD_TYPE=Release \
&& cmake --build .
/libcosimc-0.7.0/build/output/release/lib/libcosimc.so
This throws the error
CMake Error at CMakeLists.txt:115 (find_package):
By not providing "Findlibcosim.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "libcosim",
but CMake did not find one.
Could not find a package configuration file provided by "libcosim" with any
of the following names:
libcosimConfig.cmake
libcosim-config.cmake
Could you please enhance the README with some more instructions how to compile libcosimc?
Workflows should use https://osp.jfrog.io/artifactory/conan-local repository instead of the virtual repository https://osp.jfrog.io/artifactory/conan-public
The scm url field in conanfile.py
is set to: "url": "[email protected]:open-simulation-platform/libcosimc.git"
. Conan files relying on the scm url to fetch the package will give the error ERROR: Couldn't checkout SCM: Command 'git -c http.sslVerify=true clone "[email protected]:open-simulation-platform/libcosimc.git"
. This field is set to "auto"
for most other repos. This can be reproduced by using the conan command specified in the cosim-demo-app with --build=missing
.
On a vehicule (boat, aircraft, rolling vehicle), an external device can be part of the simulation.
It should be possible for the operator to disengage (disable + terminate + unload) or reengage (reload + restart + enable) a slave family (all instances of the same FMU) during an experiment without disturbing the global execution of a simulation.
The goal is to be able to update or debug the model code, recompile it and reintegrate it for test in the same complex experiment.
As a | OSP user |
---|---|
I want to | be able to disengage (disable + terminate + unload) or reengage (reload + restart + enable) a slave family (all instances of an FMU) while an execution is running |
So that | the execution continue running with their last output data but without (when disengaged) / with (when engaged) executing the simulator instances "set inputs" and then "do step" and then "get outputs". |
Given that | a whole simulator family is engaged |
---|---|
When | the user disengage it |
Then | the simulator family (all simulators instances of the same FMU of this simulator) are frozen in their current state, i.e. no more interaction are done with the FMU, but their last output values are available to the rest of the platform. The execution is not disturbed at all by this event. |
Then | all instances are disconnected to the execution and are terminated. |
Then | the FMU library is unloaded. |
Given that | a whole simulator family is disengaged |
---|---|
When | the user reengage it |
Then | the simulator family is reloaded, then restarted (respecting the starting steps of the model), then reconnected to the execution and then reintegrated to the step cycle in its new current state, i.e. interactions restart with the FMU, with its last input values. The execution is not disturbed at all by this event. |
Given that | a whole simulator family is engaged |
---|---|
When | the user reengage it |
Then | nothing happens. |
Given that | a whole simulator family is disengaged |
---|---|
When | the user disengage it |
Then | nothing happens. |
/**
* Engage a slave family to an execution.
*
* \param [in] execution
* The concerned execution.
* \param [in] cosim_slave_index
* One slave of the slave family to be engaged.
*
* \returns
* 0 on success and -1 on error.
*/
int cosim_execution_engage_slave_family(cosim_execution* execution, cosim_slave_index slave);
/**
* Disengage a slave family from an execution.
*
* \param [in] execution
* The concerned execution.
* \param [in] cosim_slave_index
* One slave of the slave family to be disengaged.
*
* \returns
* 0 on success and -1 on error.
*/
int cosim_execution_disengage_slave_family(cosim_execution* execution, cosim_slave_index slave);
// Slave family execution status.
typedef enum
{
COSIM_SLAVE_FAMILY_EXECUTION_DISENGAGED,
COSIM_SLAVE_FAMILY_EXECUTION_ENGAGED
} cosim_slave_family_execution_status;
/**
* Get a slave execution status.
*
* \param [in] execution
* The concerned execution.
* \param [in] cosim_slave_index
* The slave to be queried.
* \param [out] status
* The slave status.
*
* \returns
* 0 on success and -1 on error (if slave index is invalid for instance).
*/
int cosim_execution_get_slave_family_execution_status(cosim_execution* execution, cosim_slave_index slave, cosim_slave_family_execution_status* status);
It should be possible to avoid, by configuration, simulation experiment stopping because of a model fatal error, in order to be able to disengage the concerned model, debug it and then reengage it at the same point of the experiment.
As a | OSP user |
---|---|
I want to | be able to configure the continuity of service level for the whole execution (the default one), or a given slave family. The choice is at least among: - full continuity of service |
So that | a specific continuity of service level is applied to any slave family, when specified, or else, a default continuity of service level is applied to the others. |
In the OspSystemStructure XML structure:
<OspSystemStructure [...]>
...
<Simulators defaultContinuityOfService="full">
<Simulator name="model1" familyContinuityOfService="production" source="model.fmu" stepSize="0.0005"/>
<Simulator name="model2" source="model.fmu" stepSize="0.0005"/>
...
</Simulators>
...
</OspSystemStructure>
cse-server-go requires fmuproxy. Was able to create the needed conan package with -o cse-core:fmuproxy=True
locally.
Must be included in workflows as well.
It would be great if the github releases would contain prebuild static library / shared object (and include header ) for x86_64 linux.
If my understanding is correct release version of libcosimc.a is about 7 MB.
In the python world, static libraries/ shared objects are provided in a way that they are usable on many linux systems by building them on CentOS 6
.
Github actions could be used here.
It should be possible to avoid simulation experiment stopping because of a model fatal error, in order to be able to disengage the concerned model, debug it and then reengage it at the same point of the experiment.
As a | OSP user |
---|---|
I want to | be able to choose the continuity of service level for the whole execution (the default one), or a given slave family. The choice is at least among: - full continuity of service: never stop the execution, even though any slave has a fatal error; in that case, it is automatically disabled; - production continuity of service: like it is today. |
So that | a specific continuity of service level is applied to any slave family, when specified, or else, a default continuity of service level is applied to the others. |
Given that | production continuity of service is selected on the execution |
---|---|
When | the user selects full continuity of service on the execution |
Then | if any simulator falls down then The execution is not disturbed at all by this event. It is possible to disengage the simulator family for debugging it. |
Given that | production continuity of service is selected on the execution and on all simulator families |
---|---|
When | the user selects full continuity of service on it |
Then | if one of the instance of the simulator family falls down then The execution is not disturbed at all by this event. It is possible to disengage the simulator family for debugging it. else if any other simulator falls down then The execution ends |
Given that | full continuity of service is selected on the execution and on all simulator families |
---|---|
When | the user selects production continuity of service on it |
Then | if one of the instance of the simulator family falls down then The execution ends else if any other simulator falls down then The execution is not disturbed at all by this event. It is possible to disengage the concerned simulator family for debugging it. |
// Continuity of service level.
typedef enum
{
COSIM_CONTINUITY_OF_SERVICE_DEFAULT,
COSIM_CONTINUITY_OF_SERVICE_PRODUCTION,
COSIM_CONTINUITY_OF_SERVICE_FULL,
} cosim_continuity_of_service_level;
/**
* Get the execution default continuity of service level.
*
* \param [in] execution
* The concerned execution.
*
* \returns
* The execution default continuity of service level.
*/
cosim_continuity_of_service_level cosim_execution_get_default_continuity_of_service_level(cosim_execution* execution);
/**
* Set the execution default continuity of service level.
*
* \param [in] execution
* The concerned execution.
* \param [in] level
* The execution default continuity of service level.
*/
void cosim_execution_set_default_continuity_of_service_level(cosim_execution* execution, cosim_continuity_of_service_level* level);
/**
* Get the slave family continuity of service level.
*
* \param [in] execution
* The concerned execution.
* \param [in] cosim_slave_index
* The slave to be queried.
* \param [out] level
* The slave family level.
*
* \returns
* 0 on success and -1 on error (if slave index is invalid for instance).
*/
int cosim_execution_get_slave_family_continuity_of_service_level(cosim_execution* execution, cosim_slave_index slave, cosim_continuity_of_service_level* level);
/**
* Set the slave family continuity of service level.
*
* \param [in] execution
* The concerned execution.
* \param [in] cosim_slave_index
* The slave to be set.
* \param [out] level
* The slave family level.
*
* \returns
* 0 on success and -1 on error (if slave index is invalid for instance).
*/
int cosim_execution_set_slave_family_continuity_of_service_level(cosim_execution* execution, cosim_slave_index slave, cosim_continuity_of_service_level level);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.