From 9467e5f73d46187eb42764c26b7545642e0eebb8 Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 8 Feb 2021 17:49:10 +0100 Subject: [PATCH 1/6] disabling useless checks --- tests/integration_tutorials/c/hello.c | 6 +++--- tests/integration_tutorials/cpp/hello.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration_tutorials/c/hello.c b/tests/integration_tutorials/c/hello.c index c88603cd..57927533 100644 --- a/tests/integration_tutorials/c/hello.c +++ b/tests/integration_tutorials/c/hello.c @@ -39,9 +39,9 @@ int main() int minor_version = CoSimIO_Info_GetInt(hello_info, "minor_version"); const char* patch_version = CoSimIO_Info_GetString(hello_info, "patch_version"); - COSIMIO_CHECK_EQUAL(major_version, 1); - COSIMIO_CHECK_EQUAL(minor_version, 0); - COSIMIO_CHECK_STRING_EQUAL(patch_version, "0"); + // COSIMIO_CHECK_EQUAL(major_version, 1); + // COSIMIO_CHECK_EQUAL(minor_version, 0); + // COSIMIO_CHECK_STRING_EQUAL(patch_version, "0"); CoSimIO_FreeInfo(hello_info); diff --git a/tests/integration_tutorials/cpp/hello.cpp b/tests/integration_tutorials/cpp/hello.cpp index bdb2710b..0e83eab2 100644 --- a/tests/integration_tutorials/cpp/hello.cpp +++ b/tests/integration_tutorials/cpp/hello.cpp @@ -30,8 +30,8 @@ int main() int minor_version = info.Get("minor_version"); std::string patch_version = info.Get("patch_version"); - COSIMIO_CHECK_EQUAL(major_version, 1); - COSIMIO_CHECK_EQUAL(minor_version, 0); + // COSIMIO_CHECK_EQUAL(major_version, 1); + // COSIMIO_CHECK_EQUAL(minor_version, 0); return 0; } From e1651ffdfc323be650a6595b1a83c7ed24caaeaf Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 8 Feb 2021 17:49:18 +0100 Subject: [PATCH 2/6] bump versino --- co_sim_io/impl/version.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/co_sim_io/impl/version.hpp b/co_sim_io/impl/version.hpp index 6b70895d..65719e87 100644 --- a/co_sim_io/impl/version.hpp +++ b/co_sim_io/impl/version.hpp @@ -19,7 +19,7 @@ namespace CoSimIO { constexpr int GetMajorVersion() { - return 1; + return 2; } constexpr int GetMinorVersion() { From 0af3ada7fcf984479e489e3dcc34a2a26a27b8b5 Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 8 Feb 2021 17:49:30 +0100 Subject: [PATCH 3/6] add rudimentary version check --- .../impl/communication/file_communication.hpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/co_sim_io/impl/communication/file_communication.hpp b/co_sim_io/impl/communication/file_communication.hpp index 6794ad56..7121a3e0 100644 --- a/co_sim_io/impl/communication/file_communication.hpp +++ b/co_sim_io/impl/communication/file_communication.hpp @@ -25,6 +25,7 @@ #include "communication.hpp" #include "../vtk_utilities.hpp" #include "../filesystem_inc.hpp" +#include "../version.hpp" namespace CoSimIO { namespace Internals { @@ -115,13 +116,31 @@ class FileCommunication : public Communication CheckStream(my_config_file, I_MyFileName); // TODO write configuration and do sth with it? - my_config_file << "Hello there\n"; + // Maybe in the future use Import/ExportInfo here... + my_config_file << GetMajorVersion() << "\n"; + my_config_file << GetMinorVersion() << "\n"; + my_config_file << GetPatchVersion() << "\n"; my_config_file.close(); MakeFileVisible(I_MyFileName); WaitForPath(I_PartnerFileName); + + std::ifstream partner_config_file(I_PartnerFileName); + CheckStream(partner_config_file, I_PartnerFileName); + // TODO read configuration and do sth with it? + int partner_major_version; + int partner_minor_version; + + partner_config_file >> partner_major_version; + partner_config_file >> partner_minor_version; + + partner_config_file.close(); + + CO_SIM_IO_INFO_IF("CoSimIO", GetMajorVersion() != partner_major_version) << "Major version mismatch!" << std::endl; + CO_SIM_IO_INFO_IF("CoSimIO", GetMinorVersion() != partner_minor_version) << "Minor version mismatch!" << std::endl; + RemovePath(I_PartnerFileName); WaitUntilFileIsRemoved(I_MyFileName); From 7ec41ece22f4c590efe0fd21e1e43218688c3f37 Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 8 Feb 2021 17:56:21 +0100 Subject: [PATCH 4/6] fixing --- tests/integration_tutorials/c/hello.c | 14 ++++---------- tests/integration_tutorials/cpp/hello.cpp | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/integration_tutorials/c/hello.c b/tests/integration_tutorials/c/hello.c index 57927533..bf2941fa 100644 --- a/tests/integration_tutorials/c/hello.c +++ b/tests/integration_tutorials/c/hello.c @@ -23,12 +23,6 @@ return 1; \ } -#define COSIMIO_CHECK_STRING_EQUAL(a, b) \ - if (strcmp(a,b)) { \ - printf("in line %d: %s is not equal to %s", __LINE__, a, b); \ - return 1; \ - } - int main() { CoSimIO_Info hello_info = CoSimIO_Hello(); @@ -37,11 +31,11 @@ int main() int major_version = CoSimIO_Info_GetInt(hello_info, "major_version"); int minor_version = CoSimIO_Info_GetInt(hello_info, "minor_version"); - const char* patch_version = CoSimIO_Info_GetString(hello_info, "patch_version"); + // const char* patch_version = CoSimIO_Info_GetString(hello_info, "patch_version"); + + COSIMIO_CHECK_EQUAL((major_version>0), 1); + COSIMIO_CHECK_EQUAL((minor_version>=0), 1); - // COSIMIO_CHECK_EQUAL(major_version, 1); - // COSIMIO_CHECK_EQUAL(minor_version, 0); - // COSIMIO_CHECK_STRING_EQUAL(patch_version, "0"); CoSimIO_FreeInfo(hello_info); diff --git a/tests/integration_tutorials/cpp/hello.cpp b/tests/integration_tutorials/cpp/hello.cpp index 0e83eab2..39d091ec 100644 --- a/tests/integration_tutorials/cpp/hello.cpp +++ b/tests/integration_tutorials/cpp/hello.cpp @@ -30,8 +30,8 @@ int main() int minor_version = info.Get("minor_version"); std::string patch_version = info.Get("patch_version"); - // COSIMIO_CHECK_EQUAL(major_version, 1); - // COSIMIO_CHECK_EQUAL(minor_version, 0); + COSIMIO_CHECK_EQUAL((major_version>0), 1); + COSIMIO_CHECK_EQUAL((minor_version>=0), 1); return 0; } From ef818d703a866a073a07a63d7b3b514a40be4ce2 Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 8 Feb 2021 17:56:28 +0100 Subject: [PATCH 5/6] cleaning --- co_sim_io/python/co_sim_io_python.cpp | 29 ++------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/co_sim_io/python/co_sim_io_python.cpp b/co_sim_io/python/co_sim_io_python.cpp index 8c2bc257..193492a9 100644 --- a/co_sim_io/python/co_sim_io_python.cpp +++ b/co_sim_io/python/co_sim_io_python.cpp @@ -32,28 +32,6 @@ #include "connection_status_to_python.hpp" #include "version_to_python.hpp" -namespace CoSimIO_Py_Wrappers { - -CoSimIO::Info ImportMesh( - const CoSimIO::Info& I_Info, - CoSimIO::ModelPart& rModelPart) -{ - return CoSimIO::ImportMesh( - I_Info, - rModelPart); -} - -CoSimIO::Info ExportMesh( - const CoSimIO::Info& I_Info, - const CoSimIO::ModelPart& rModelPart) -{ - return CoSimIO::ExportMesh( - I_Info, - rModelPart); -} - -} // namespace CoSimIO_Py_Wrappers - PYBIND11_MODULE(CoSimIO, m) { @@ -64,11 +42,8 @@ PYBIND11_MODULE(CoSimIO, m) m.def("Connect", &CoSimIO::Connect); m.def("Disconnect", &CoSimIO::Disconnect); - m.def("ImportMesh", CoSimIO_Py_Wrappers::ImportMesh); - m.def("ExportMesh", CoSimIO_Py_Wrappers::ExportMesh); - // TODO uncomment when starting to use new Interface - // m.def("ImportMesh", &CoSimIO::ImportMesh); - // m.def("ExportMesh", &CoSimIO::ExportMesh); + m.def("ImportMesh", &CoSimIO::ImportMesh); + m.def("ExportMesh", &CoSimIO::ExportMesh); m.def("ImportData", [](const CoSimIO::Info& I_Info, std::vector& rValues){ return CoSimIO::ImportData( From 57d74a6e69097f177b2d954696dd48aa3da557c2 Mon Sep 17 00:00:00 2001 From: philbucher Date: Mon, 8 Feb 2021 17:57:06 +0100 Subject: [PATCH 6/6] hotfix --- tests/integration_tutorials/python/hello.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_tutorials/python/hello.py b/tests/integration_tutorials/python/hello.py index 75c7167e..fe9192ed 100644 --- a/tests/integration_tutorials/python/hello.py +++ b/tests/integration_tutorials/python/hello.py @@ -22,7 +22,7 @@ def cosimio_check_equal(a, b): minor_version = info.GetInt("minor_version") patch_version = info.GetString("patch_version") -cosimio_check_equal(major_version,1) +cosimio_check_equal(major_version,2) cosimio_check_equal(minor_version,0) print("CoSimIO version", str(major_version)+"."+str(minor_version)+"."+patch_version) \ No newline at end of file