Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 20 additions & 1 deletion co_sim_io/impl/communication/file_communication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "communication.hpp"
#include "../vtk_utilities.hpp"
#include "../filesystem_inc.hpp"
#include "../version.hpp"

namespace CoSimIO {
namespace Internals {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion co_sim_io/impl/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace CoSimIO {

constexpr int GetMajorVersion() {
return 1;
return 2;
}

constexpr int GetMinorVersion() {
Expand Down
29 changes: 2 additions & 27 deletions co_sim_io/python/co_sim_io_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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<double>& rValues){
return CoSimIO::ImportData(
Expand Down
14 changes: 4 additions & 10 deletions tests/integration_tutorials/c/hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tutorials/cpp/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ int main()
int minor_version = info.Get<int>("minor_version");
std::string patch_version = info.Get<std::string>("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;
}
2 changes: 1 addition & 1 deletion tests/integration_tutorials/python/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)