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

Support DCP standard #2049

Merged
merged 34 commits into from
Dec 2, 2024
Merged

Support DCP standard #2049

merged 34 commits into from
Dec 2, 2024

Conversation

robbr48
Copy link
Contributor

@robbr48 robbr48 commented Jan 15, 2021

Support for the Distributed Co-simulation Protocol (DCP) standard. This enables communication between Hopsan and other DCP supporting tools, as well as with physical devices. Hopsan is hard-coded to use UDP protocol for now, but TCP/IP can alsobe supported in the future as well as CAN and Bluetooth.

It is possible to both export Hopsan models and simulate them in other tools, as well as importing and simulating models from other tools. Due to the lack of open source DCP tools, I have only been able to test simulations between Hopsan and Hopsan.

The implementation is based on the DCPLib subproject, which in turn requires three new dependencies; Asio, Xerces and libzip.

@robbr48 robbr48 self-assigned this Jan 15, 2021
@robbr48 robbr48 added import/export Code generator, Library Compilation simulation Simulator and core modeling capabilities and behavior labels Jan 15, 2021
@@ -87,6 +87,24 @@
</releasefile>
</dependency>

<dependency name="asio">
<releasefile sha1="bac61183b633a6d91ef7ae31836434bdf4f2b0d0">
<url>https://sourceforge.net/projects/asio/files/asio/1.12.1 (Stable)/asio-1.12.1.zip</url>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the exact versions listed here required? Otherwise it would be "better" to install them from the package repository on Linux systems. But i guess having them as a fall-back in-case system is to old might make sense.

More use full would be the downloads (and build scripts) for Windows

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found out that Asio does not need to be compiled, it can be used as header-only. This makes things much easier.

hopsandcp/dcpmaster.cpp Outdated Show resolved Hide resolved
void DcpMaster::start() {
std::thread b(&DcpManagerMaster::start, manager);
std::chrono::seconds dura(1);
std::this_thread::sleep_for(dura);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sleeping random time is not safe, sometimes its enough sometime not. Is there some other way to "wait long enough"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this either but can't think of a better solution. This code snippet is taken directly from the examples provided by DCPLib.

hopsandcp/dcpmaster.cpp Outdated Show resolved Hide resolved
hopsandcp/dcpmaster.cpp Outdated Show resolved Hide resolved
hopsandcp/dcpslave.cpp Outdated Show resolved Hide resolved
hopsandcp/utilities.cpp Outdated Show resolved Hide resolved
@peterNordin
Copy link
Member

Made some comments, but have not had time to test, have no obvious ideas, seems like a reasonable approach

@robbr48
Copy link
Contributor Author

robbr48 commented Feb 9, 2021

Just so you know, I am going to remove the command line interface and convert hopsandcp into a library. Then the gui and cli can link against this library directly. The important thing is that hopsancore should not depend on DCPLib.

…r. Handle empty strings in HString::split().
Fix Windows dependencies

Added missing dependencies for Appveyor

Added CMakeLists.txt to hopsandcp

Add missing calls to dependency scripts for Appveyor

Correct include directories in CMake

Build all dependencies with ci-build

Added Linux script for setting up DCPLib

Set executable permission  to DCPLib install script

Added include path to libzip

Fix Linux setup script for libzip

Add include paths to Xerces and Asio

Add include path to libzip

Fix compilation error without ZMQ

Remove pause from Xerces setup script

Added missing include

Add patch to DCPLib code to fix a missing include

Add logging define to DCPLib to resolve compilation error

Patch for missing function in DCPLib

Enable LOGGING flag in hopsandcp

Specify release build for Zlib on Windows

Correct use of define in call to CMake

Make Cmake define public

Changed to forward slashes in CMake path

Remove unneeded patch

Added hopsandcp dependency to HopsanGUI

Added libzip dependency to HopsanCore

Patch DCPLib to make IpToString function inlined

Fix release build for zlib

Fix CMake build

Add check for MinGW compiler flag

Add Zlib, add DCPLib to setup scripts

Fix Linux compilation

Compilation fixes

Test local libzip in ci-build

Attempt to fix MSVC compilation

Add Zlib setup script to Appveyor

Attempt to fix MSVC linking

Attempt to fix patch command for msvc

Fix patch for Windows builds

Attempt to link Xerces with MSVC

Find local xerces with msvc

Attempt to fix libzip linking on msvc
@robbr48 robbr48 marked this pull request as ready for review October 25, 2024 07:04
@robbr48 robbr48 added this to the 2.23.0 milestone Oct 25, 2024
@robbr48 robbr48 merged commit 76225c4 into Hopsan:master Dec 2, 2024
3 checks passed
@robbr48 robbr48 deleted the dcp_slave branch December 2, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
import/export Code generator, Library Compilation simulation Simulator and core modeling capabilities and behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants