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); 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() { 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( diff --git a/tests/integration_tutorials/c/hello.c b/tests/integration_tutorials/c/hello.c index c88603cd..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 bdb2710b..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; } 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