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

Feature/proxy-fmu #633

Merged
merged 47 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
b756af5
wip proxy integration
Apr 6, 2021
39a9e12
link against proxy
Apr 6, 2021
b33356b
wip
Apr 6, 2021
93dcba3
sucess
markaren Apr 6, 2021
a551450
update
markaren Apr 6, 2021
5602210
Merge branch 'master' into feature/proxy-server
Apr 7, 2021
b6c882b
adding cmake option for proxy and misc fixes
Apr 7, 2021
29421a3
fix option name
Apr 7, 2021
9b9b13c
add newline
Apr 7, 2021
d8a9406
fix option name
Apr 7, 2021
9a49a27
typo
Apr 7, 2021
77ba5c7
fix option name
Apr 7, 2021
c3e6e57
update target
Apr 7, 2021
9af60ff
actually use remote proxy feature..
Apr 9, 2021
eb88472
copy proxy_server.exe
Apr 9, 2021
1710002
update
Apr 10, 2021
9dd2a9c
updated namespace
Apr 12, 2021
ef930b5
check status
Apr 12, 2021
a99531e
change uri
Apr 13, 2021
44f0d52
update
Apr 14, 2021
2835d6a
Update readme
Apr 15, 2021
8f47dd6
Update conanfile.py
markaren Apr 15, 2021
f80a4fe
Update conanfile.py
markaren Apr 15, 2021
f0d6fd2
gcc7 filesystem fix
Apr 15, 2021
784f1a0
exclude debug for proxyfmu
Apr 15, 2021
3042e4a
Merge remote-tracking branch 'origin/feature/proxy-server' into featu…
Apr 15, 2021
480dfff
Custom find is not used
Apr 15, 2021
750fa7e
Merge branch 'master' into feature/proxy-server
Apr 15, 2021
8f9d4ef
add unittests
Apr 16, 2021
2884f1a
no need for minmax check anymore
Apr 17, 2021
d15b8ea
add fmi2 test for proxyfmu
Apr 17, 2021
dea4102
add test for fmi2
Apr 17, 2021
4839736
Remove CI excludes
Apr 19, 2021
95bac99
fix reference to std::filesystem in debug mode
Apr 19, 2021
b918e26
Update readme
Apr 19, 2021
73f8d87
Update proxyfmu version
May 5, 2021
ec99217
cleanup
markaren May 11, 2021
bf3e079
throw on bad file and remove empty url code path
markaren May 11, 2021
77dd4a4
add more tests
markaren May 11, 2021
0bf6954
copy booter and unix executables for proxyfmu to bin
May 12, 2021
2d4ef45
replace use of panic with exception
markaren May 31, 2021
f51e8d5
Merge branch 'master' into feature/proxy-server
markaren Jun 3, 2021
9484ec5
use cosim::filesystem
markaren Jun 3, 2021
7b53041
testing
Aug 14, 2021
a1d1611
testing
Aug 14, 2021
038c3ca
testing
Aug 14, 2021
5b23aef
Merge branch 'master' into feature/proxy-server
markaren Aug 18, 2021
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
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^[<"]cosim[/.]'
Priority: 20
- Regex: '^[<"](boost|event2|fmilib|gsl|nlohmann|xercesc|zip)[/.]'
- Regex: '^[<"](boost|event2|fmilib|gsl|nlohmann|proxyfmu|xercesc|zip)[/.]'
Priority: 30
- Regex: '^"'
Priority: 10
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/ci-conan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
build_type: [Debug, Release]
compiler_version: [7, 8, 9]
compiler_libcxx: [libstdc++11]
option_fmuproxy: ['fmuproxy=True', 'fmuproxy=False']
option_proxyfmu: ['proxyfmu=True', 'proxyfmu=False']

steps:
- uses: actions/checkout@v2
Expand All @@ -46,7 +46,7 @@ jobs:
SHORT_REFNAME="${REFNAME:0:40}"
CHANNEL="testing-${SHORT_REFNAME//\//_}"
fi
conan create -s build_type=${{ matrix.build_type }} -s compiler.version=${{ matrix.compiler_version }} -s compiler.libcxx=${{ matrix.compiler_libcxx }} -o ${{ matrix.option_fmuproxy }} -b missing . osp/${CHANNEL}
conan create -s build_type=${{ matrix.build_type }} -s compiler.version=${{ matrix.compiler_version }} -s compiler.libcxx=${{ matrix.compiler_libcxx }} -o ${{ matrix.option_proxyfmu }} -b missing . osp/${CHANNEL}
- name: Conan upload
run: |
conan upload --all -c -r osp '*'
Expand All @@ -63,12 +63,7 @@ jobs:
os: [windows-2016]
build_type: [Debug, Release]
compiler_version: [15]
option_fmuproxy: ['fmuproxy=True', 'fmuproxy=False']

exclude:
- os: windows-2016
build_type: Debug
option_fmuproxy: 'fmuproxy=True'
option_proxyfmu: ['proxyfmu=True', 'proxyfmu=False']

steps:
- uses: actions/checkout@v2
Expand All @@ -89,6 +84,6 @@ jobs:
SHORT_REFNAME="${REFNAME:0:40}"
CHANNEL="testing-${SHORT_REFNAME//\//_}"
fi
conan create -s build_type=${{ matrix.build_type }} -s compiler.version=${{ matrix.compiler_version }} -o ${{ matrix.option_fmuproxy }} -b missing . osp/${CHANNEL}
conan create -s build_type=${{ matrix.build_type }} -s compiler.version=${{ matrix.compiler_version }} -o ${{ matrix.option_proxyfmu }} -b missing . osp/${CHANNEL}
- name: Conan upload
run: conan upload --all -c -r osp '*'
10 changes: 4 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ option(LIBCOSIM_BUILD_APIDOC "Build API documentation (requires Doxygen)" ON)
option(LIBCOSIM_BUILD_PRIVATE_APIDOC "Build private API documentation (only used if LIBCOSIM_BUILD_APIDOC=ON)" OFF)
option(LIBCOSIM_STANDALONE_INSTALLATION "Whether to build for a standalone installation (Linux only; sets a relative RPATH)" OFF)
option(LIBCOSIM_USING_CONAN "Whether Conan is used for package management" OFF)
option(LIBCOSIM_WITH_FMUPROXY "Whether or not to build with fmuproxy integration" OFF)
option(LIBCOSIM_TEST_FMUPROXY "Whether or not to run fmuproxy tests (only if LIBCOSIM_BUILD_TESTS=ON and LIBCOSIM_WITH_FMUPROXY=ON)" ON)
option(LIBCOSIM_WITH_PROXYFMU "Whether or not to build with proxy-fmu integration" OFF)

# ==============================================================================
# Global internal configuration
Expand Down Expand Up @@ -115,8 +114,8 @@ find_package(FMILibrary REQUIRED)
find_package(LIBZIP REQUIRED)
find_package(YAML_CPP REQUIRED)
find_package(XercesC REQUIRED)
if(LIBCOSIM_WITH_FMUPROXY)
find_package(THRIFT 0.13.0 REQUIRED)
if(LIBCOSIM_WITH_PROXYFMU)
find_package(PROXYFMU CONFIG REQUIRED)
endif()

# ==============================================================================
Expand Down Expand Up @@ -148,7 +147,7 @@ if(LIBCOSIM_BUILD_APIDOC)
set(DOXYGEN_JAVADOC_AUTOBRIEF "YES")
set(DOXYGEN_QT_AUTOBRIEF "YES")
set(DOXYGEN_MULTILINE_CPP_IS_BRIEF "YES")
set(DOXYGEN_EXCLUDE_PATTERNS "*.cpp" "*.c" "*/fmuproxy/*service*")
set(DOXYGEN_EXCLUDE_PATTERNS "*.cpp" "*.c")
set(doxygenInputs "${CMAKE_SOURCE_DIR}/docs" "${CMAKE_SOURCE_DIR}/include")
if(LIBCOSIM_BUILD_PRIVATE_APIDOC)
list(APPEND doxygenInputs
Expand Down Expand Up @@ -209,7 +208,6 @@ install(FILES
"${CMAKE_SOURCE_DIR}/cmake/FindFMILibrary.cmake"
"${CMAKE_SOURCE_DIR}/cmake/FindLIBZIP.cmake"
"${CMAKE_SOURCE_DIR}/cmake/FindMS_GSL.cmake"
"${CMAKE_SOURCE_DIR}/cmake/FindTHRIFT.cmake"
"${CMAKE_SOURCE_DIR}/cmake/FindYAML_CPP.cmake"
DESTINATION
"${LIBCOSIM_CMAKE_INSTALL_DIR}"
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,10 @@ Then, acquire dependencies with Conan:
`--settings compiler.libcxx=libstdc++11` to this command; see Step 1 for more
information.)

#### FMU-Proxy
To include FMU-Proxy support, run conan install with the additional option:
#### proxyfmu
To include proxyfmu support, run conan install with the additional option:
```bash
-o fmuproxy=True
```
Note that it currently must be built in Release mode e.g.
```bash
conan install .. -s build_type=Release --build=missing -o fmuproxy=True
-o proxyfmu=True
```

Now, we can run CMake to generate the build system. (If you have not installed
Expand Down
43 changes: 23 additions & 20 deletions cmake/FindFMILibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
# FMILibrary_LIBRARY - Path to static library.
# FMILibrary_SHARED_LIBRARY - Path to shared/import library.
#
cmake_minimum_required (VERSION 2.8.11)

# Find static library, and use its path prefix to provide a HINTS option to the
# other find_*() commands.
Expand Down Expand Up @@ -97,31 +96,35 @@ unset (_FMILibrary_hints)

# Create the IMPORTED targets.
if (FMILibrary_LIBRARY)
add_library ("fmilib::static" STATIC IMPORTED)
set_target_properties ("fmilib::static" PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LINK_INTERFACE_LIBRARIES "${CMAKE_DL_LIBS}"
IMPORTED_LOCATION "${FMILibrary_LIBRARY}"
INTERFACE_COMPILE_DEFINITIONS "FMILibrary_STATIC_LIB_ONLY"
INTERFACE_INCLUDE_DIRECTORIES "${FMILibrary_INCLUDE_DIRS}")
if (NOT TARGET fmilib::static)
add_library ("fmilib::static" STATIC IMPORTED)
set_target_properties ("fmilib::static" PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LINK_INTERFACE_LIBRARIES "${CMAKE_DL_LIBS}"
IMPORTED_LOCATION "${FMILibrary_LIBRARY}"
INTERFACE_COMPILE_DEFINITIONS "FMILibrary_STATIC_LIB_ONLY"
INTERFACE_INCLUDE_DIRECTORIES "${FMILibrary_INCLUDE_DIRS}")
endif()
endif ()

if (FMILibrary_SHARED_LIBRARY)
add_library ("fmilib::shared" SHARED IMPORTED)
set_target_properties ("fmilib::shared" PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
INTERFACE_INCLUDE_DIRECTORIES "${FMILibrary_INCLUDE_DIRS}")
if (WIN32)
if (NOT TARGET fmilib::shared)
add_library ("fmilib::shared" SHARED IMPORTED)
set_target_properties ("fmilib::shared" PROPERTIES
IMPORTED_IMPLIB "${FMILibrary_SHARED_LIBRARY}")
if (FMILibrary_DLL)
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
INTERFACE_INCLUDE_DIRECTORIES "${FMILibrary_INCLUDE_DIRS}")
if (WIN32)
set_target_properties ("fmilib::shared" PROPERTIES
IMPORTED_LOCATION "${FMILibrary_DLL}")
IMPORTED_IMPLIB "${FMILibrary_SHARED_LIBRARY}")
if (FMILibrary_DLL)
set_target_properties ("fmilib::shared" PROPERTIES
IMPORTED_LOCATION "${FMILibrary_DLL}")
endif ()
else () # not WIN32
set_target_properties ("fmilib::shared" PROPERTIES
IMPORTED_LOCATION "${FMILibrary_SHARED_LIBRARY}")
endif ()
else () # not WIN32
set_target_properties ("fmilib::shared" PROPERTIES
IMPORTED_LOCATION "${FMILibrary_SHARED_LIBRARY}")
endif ()
endif()
endif ()

# Set the FMILibrary_LIBRARIES variable.
Expand Down
39 changes: 0 additions & 39 deletions cmake/FindTHRIFT.cmake

This file was deleted.

4 changes: 2 additions & 2 deletions cmake/project-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ find_dependency(LIBZIP REQUIRED)
find_dependency(YAML_CPP REQUIRED)
find_dependency(XercesC REQUIRED)

if(@LIBCOSIM_WITH_FMUPROXY@)
find_dependency(THRIFT REQUIRED)
if(@LIBCOSIM_WITH_PROXYFMU@)
find_dependency(PROXYFMU CONFIG REQUIRED)
endif()

list(REMOVE_AT CMAKE_MODULE_PATH -1)
17 changes: 9 additions & 8 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class LibcosimConan(ConanFile):
"openssl/1.1.1k"
)

options = {"fmuproxy": [True, False]}
options = {"proxyfmu": [True, False]}
default_options = (
"fmuproxy=False",
"proxyfmu=False",
"boost:shared=True",
"fmilibrary:shared=True",
"libzip:shared=True",
Expand All @@ -39,22 +39,23 @@ class LibcosimConan(ConanFile):
def set_version(self):
self.version = tools.load(path.join(self.recipe_folder, "version.txt")).strip()

def requirements(self):
if self.options.proxyfmu:
self.requires("proxyfmu/0.2.1@osp/testing")

def imports(self):
binDir = os.path.join("output", str(self.settings.build_type).lower(), "bin")
self.copy("proxyfmu*", dst=binDir, src="bin", keep_path=False)
self.copy("*.dll", dst=binDir, keep_path=False)
self.copy("*.pdb", dst=binDir, keep_path=False)

def requirements(self):
if self.options.fmuproxy:
self.requires("thrift/0.13.0")

def configure_cmake(self):
cmake = CMake(self)
cmake.definitions["LIBCOSIM_USING_CONAN"] = "ON"
cmake.definitions["LIBCOSIM_BUILD_APIDOC"] = "OFF"
cmake.definitions["LIBCOSIM_BUILD_TESTS"] = "OFF"
if self.options.fmuproxy:
cmake.definitions["LIBCOSIM_WITH_FMUPROXY"] = "ON"
if self.options.proxyfmu:
cmake.definitions["LIBCOSIM_WITH_PROXYFMU"] = "ON"
cmake.configure()
return cmake

Expand Down
54 changes: 11 additions & 43 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,16 @@ set(generatedSources
"cosim/lib_info.cpp"
)

if(LIBCOSIM_WITH_FMUPROXY)
if(LIBCOSIM_WITH_PROXYFMU)
list(APPEND privateHeaders
"cosim/fmuproxy/fmuproxy_client.hpp"
"cosim/fmuproxy/fmuproxy_helper.hpp"
"cosim/fmuproxy/fmuproxy_uri_sub_resolver.hpp"
"cosim/fmuproxy/remote_fmu.hpp"
"cosim/fmuproxy/remote_slave.hpp"
"cosim/fmuproxy/thrift_state.hpp"
"cosim/proxy/proxy_uri_sub_resolver.hpp"
"cosim/proxy/remote_fmu.hpp"
"cosim/proxy/remote_slave.hpp"
)
list(APPEND sources
"cosim/fmuproxy/fmuproxy_client.cpp"
"cosim/fmuproxy/fmuproxy_uri_sub_resolver.cpp"
"cosim/fmuproxy/remote_slave.cpp"
"cosim/fmuproxy/remote_fmu.cpp"
"cosim/fmuproxy/thrift_state.cpp"
"cosim/proxy/proxy_uri_sub_resolver.cpp"
"cosim/proxy/remote_fmu.cpp"
"cosim/proxy/remote_slave.cpp"
)
endif()

Expand Down Expand Up @@ -150,30 +145,6 @@ add_custom_command(
)
list(APPEND generatedFiles "${ospSystemStructureHeader}")

# Generate FMU-proxy classes from Thrift service definitions
if(LIBCOSIM_WITH_FMUPROXY)
if(NOT THRIFT_EXECUTABLE)
message(FATAL_ERROR "The thrift compiler was not found. Cannot build with FMU-Proxy support.")
endif()
set(thriftServiceDefinition "${CMAKE_CURRENT_SOURCE_DIR}/cosim/fmuproxy/service.thrift")
set(thriftGenerated
"${generatedSourcesDir}/FmuService.h"
"${generatedSourcesDir}/FmuService.cpp"
"${generatedSourcesDir}/service_types.h"
"${generatedSourcesDir}/service_types.cpp"
)
add_custom_command(
OUTPUT ${thriftGenerated}
COMMAND "${THRIFT_EXECUTABLE}"
"--gen" "cpp:no_skeleton"
"-out" "${generatedSourcesDir}"
"${thriftServiceDefinition}"
DEPENDS "${thriftServiceDefinition}"
)
add_library(fmuproxy-service OBJECT ${thriftGenerated})
set_target_properties(fmuproxy-service PROPERTIES POSITION_INDEPENDENT_CODE ON)
list(APPEND generatedFiles "$<TARGET_OBJECTS:fmuproxy-service>")
endif()

# ==============================================================================
# Target definition
Expand Down Expand Up @@ -210,13 +181,10 @@ target_link_libraries(cosim
yaml-cpp
)

if(LIBCOSIM_WITH_FMUPROXY)
target_compile_definitions(cosim PRIVATE "HAS_FMUPROXY")
target_link_libraries(cosim
PUBLIC
thrift::thrift
)
endif()
if(LIBCOSIM_WITH_PROXYFMU)
target_compile_definitions(cosim PRIVATE "HAS_PROXYFMU")
target_link_libraries(cosim PRIVATE proxyfmu::proxyfmu-client)
endif ()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_libraries(cosim INTERFACE "atomic")
Expand Down
3 changes: 0 additions & 3 deletions src/cosim/algorithm/fixed_step_algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#if defined(WIN32) && !defined(NOMINMAX)
# define NOMINMAX
#endif
#include "cosim/algorithm/fixed_step_algorithm.hpp"

#include "cosim/error.hpp"
Expand Down
Loading