Commit 7083b085 authored by Ulrich Kemloh's avatar Ulrich Kemloh

Conditional compiling for the case no protocol buffers adn the grpc

modules are available. It is still a bit tedious for windows users to
get it to compile them.
parent a9cc10d9
......@@ -141,6 +141,7 @@ endif(BUILD_TESTING OR BUILD_CPPUNIT_TEST)
if(BUILD_TESTING)
file(GLOB_RECURSE test_py_files "${CMAKE_TEST_DIR}/*runtest_*.py")
endif(BUILD_TESTING)
# add sources and headers
set ( source_files
Simulation.cpp
......@@ -191,12 +192,6 @@ set ( source_files
voronoi/VoronoiDiagramGenerator.cpp
matsim/HybridSimulationManager.cpp
matsim/JPSserver.cpp
matsim/JPSclient.cpp
matsim/MATSimInterface.pb.cc
matsim/MATSimInterface.grpc.pb.cc
routing/AccessPoint.cpp
routing/DirectionStrategy.cpp
routing/DummyRouter.cpp
......@@ -273,13 +268,6 @@ set ( header_files
routing/cognitive_map/fire_mesh/Knot.h
routing/cognitive_map/fire_mesh/FireMeshStorage.h
matsim/JPSclient.h
matsim/MATSimInterface.grpc.pb.h
matsim/MATSimInterface.proto
matsim/HybridSimulationManager.h
matsim/JPSserver.h
matsim/MATSimInterface.pb.h
pedestrian/Pedestrian.h
pedestrian/PedDistributor.h
pedestrian/Ellipse.h
......@@ -340,10 +328,9 @@ add_library ( core STATIC ${source_files} )
#add_library ( core SHARED ${source_files} )
#Target
add_executable( jpscore main.cpp )
add_executable( jpscore main.cpp )
target_link_libraries(jpscore core grpc++_unsecure grpc gpr dl)
#target_link_libraries(jpscore core grpc++_unsecure grpc gpr protobuf dl)
target_link_libraries(jpscore core )
if(WIN32)
target_link_libraries (jpscore core wsock32)
......@@ -354,10 +341,31 @@ if(CGAL_FOUND)
endif(CGAL_FOUND)
#protocol buffer
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
find_package(Protobuf OPTIONAL)
if(PROTOBUF_FOUND)
target_link_libraries (jpscore ${PROTOBUF_LIBRARY})
message(STATUS "Protocol buffer library found")
include_directories(${PROTOBUF_INCLUDE_DIRS})
set (hybrid_source_files
matsim/HybridSimulationManager.cpp
matsim/JPSserver.cpp
matsim/JPSclient.cpp
matsim/MATSimInterface.pb.cc
matsim/MATSimInterface.grpc.pb.cc
)
set (hybrid_header_files
matsim/JPSclient.h
matsim/MATSimInterface.grpc.pb.h
matsim/MATSimInterface.proto
matsim/HybridSimulationManager.h
matsim/JPSserver.h
matsim/MATSimInterface.pb.h
)
add_library (hybrid STATIC ${hybrid_source_files} )
target_link_libraries (core hybrid grpc++_unsecure grpc gpr ${PROTOBUF_LIBRARY} dl)
#PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS foo.proto)
#add_executable(jpscore ${PROTO_SRCS} ${PROTO_HDRS})
endif(PROTOBUF_FOUND)
......
......@@ -34,7 +34,10 @@
#include "math/GompertzModel.h"
#include "pedestrian/AgentsSourcesManager.h"
#include "pedestrian/AgentsQueue.h"
#ifdef _USE_PROTOCOL_BUFFER
#include "matsim/HybridSimulationManager.h"
#endif
#ifdef _OPENMP
#include <omp.h>
......@@ -225,11 +228,13 @@ bool Simulation::InitArgs(const ArgumentParser& args)
//src->Dump();
}
#ifdef _USE_PROTOCOL_BUFFER
//iniitalize the hybridmode if defined
if(nullptr!=(_hybridSimManager=args.GetHybridSimManager()))
{
_hybridSimManager->Init(_building.get());
}
#endif
//perform customs initialisation, like computing the phi for the gcfm
//this should be called after the routing engine has been initialised
......@@ -549,12 +554,13 @@ void Simulation::ProcessAgentsQueue()
{
_building->AddPedestrian(ped);
}
#ifdef _USE_PROTOCOL_BUFFER
//outgoing pedestrians
if (_hybridSimManager)
{
_hybridSimManager->ProcessOutgoingAgent();
}
#endif
}
AgentsSourcesManager& Simulation::GetAgentSrcManager()
......
......@@ -57,7 +57,10 @@
#include "../routing/CognitiveMapRouter.h"
#include "../math/GompertzModel.h"
#include "../math/GCFMModel.h"
#ifdef _USE_PROTOCOL_BUFFER
#include "../matsim/HybridSimulationManager.h"
#endif
using namespace std;
......@@ -363,6 +366,7 @@ bool ArgumentParser::ParseIniFile(string inifile)
}
}
#ifdef _USE_PROTOCOL_BUFFER
//check the simulation mode
//trajectories
TiXmlNode* xSimMode = xMainNode->FirstChild("hybrid_simulation");
......@@ -373,6 +377,7 @@ bool ArgumentParser::ParseIniFile(string inifile)
_hybridSimManager=std::shared_ptr<HybridSimulationManager>(new HybridSimulationManager(server,port));
Log->Write(_hybridSimManager->ToString());
}
#endif
//pick up which model to use
//get the wanted ped model id
......
......@@ -49,6 +49,7 @@ class TiXmlNode;
class AgentsParameters;
class HybridSimulationManager;
extern OutputHandler* Log;
class ArgumentParser
......
......@@ -49,6 +49,7 @@
// should be true only when using this file in the simulation core
#define _SIMULATOR 1
//#define _USE_PROTOCOL_BUFFER 1
......
......@@ -30,11 +30,13 @@
#include "general/ArgumentParser.h"
#include "./Simulation.h"
#include "pedestrian/AgentsSourcesManager.h"
#ifdef _USE_PROTOCOL_BUFFER
#include "matsim/HybridSimulationManager.h"
#endif
#include <thread>
#include <functional>
//#include <boost/version.hpp>
int main(int argc, char **argv)
{
......@@ -58,6 +60,8 @@ int main(int argc, char **argv)
{
//evacuation time
int evacTime = 0;
#ifdef _USE_PROTOCOL_BUFFER
//Start the thread for managing incoming messages from MatSim
auto hybrid=args->GetHybridSimManager();
//process the hybrid simulation
......@@ -67,6 +71,7 @@ int main(int argc, char **argv)
}
//process the normal simulation
else
#endif
{
//Start the threads for managing the sources of agents if any
std::thread t1(sim.GetAgentSrcManager());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment