Commit f4309f6a authored by Ulrich Kemloh's avatar Ulrich Kemloh

fixed error in the proto file

parent e62a47bd
......@@ -547,6 +547,7 @@ void Simulation::ProcessAgentsQueue()
{
_building->AddPedestrian(ped);
}
#ifdef _USE_PROTOCOL_BUFFER
//outgoing pedestrians
if (_hybridSimManager)
......
......@@ -89,7 +89,7 @@
#define FINAL_DEST_OUT -1
// Linked cells
#define LIST_EMPTY -1
#define LIST_EMPTY -1
enum RoomState {
......
......@@ -21,7 +21,7 @@ JPSclient::JPSclient(std::shared_ptr<ChannelInterface> channel)
//communication channel to JuPedsim
// stub for testing and to be removed in the final version
_jupedsimChannel= ExternInterfaceService::NewStub(channel);
_jupedsimChannel = ExternInterfaceService::NewStub(channel);
}
JPSclient::~JPSclient()
......@@ -183,6 +183,11 @@ bool JPSclient::SendTrajectories(Building* building)
}
Status status =_matsimChannel->reqSendTrajectories(&context, request, &reply);
// if(!status.IsOk())
// {
// Log->Write("ERROR:\t RPC JPSClient call failed <reqSendTrajectories>");
// }
return status.IsOk();
//Log->Write("ERROR:\t RPC JPSClient call failed <reqSendTrajectories>");
}
......@@ -34,7 +34,6 @@ JPSserver::JPSserver(Simulation& src): _SimManager(src)
JPSserver::~JPSserver()
{
}
void JPSserver::RunSimulation()
......@@ -46,9 +45,10 @@ void JPSserver::RunSimulation()
if(_doSimulation)
{
_SimManager.RunBody(_maxSimTime);
//important: _doSimulation should be set to false before doing any other things
_doSimulation=false;
_jpsClient->SendTrajectories(_SimManager.GetBuilding());
_jpsClient->NotifyEndOfSimulation();
_doSimulation=false;
}
//Log->Write("INFO:\tRPC::JPSserver idle for 3 seconds");
......
......@@ -619,7 +619,7 @@ void protobuf_AddDesc_MATSimInterface_2eproto() {
"ern2MATSim\0225\n\005agent\030\001 \001(\0132&.org.matsim.h"
"ybrid.Extern2MATSim.Agent\032&\n\005Agent\022\n\n\002id"
"\030\001 \001(\t\022\021\n\tleaveNode\030\002 \001(\t\"\300\001\n\031Extern2MAT"
"SimTrajectories\022\014\n\004time\030\001 \001(\001\022A\n\005agent\030\002"
"SimTrajectories\022\014\n\004time\030\001 \001(\001\022A\n\005agent\030\017"
" \003(\01322.org.matsim.hybrid.Extern2MATSimTr"
"ajectories.Agent\032R\n\005Agent\022\n\n\002id\030\001 \001(\005\022\t\n"
"\001x\030\002 \001(\001\022\t\n\001y\030\003 \001(\001\022\t\n\001z\030\004 \001(\001\022\r\n\005color\030"
......@@ -3245,20 +3245,20 @@ bool Extern2MATSimTrajectories::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
if (input->ExpectTag(18)) goto parse_agent;
if (input->ExpectTag(122)) goto parse_agent;
break;
}
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 2;
case 2: {
if (tag == 18) {
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 15;
case 15: {
if (tag == 122) {
parse_agent:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_agent()));
} else {
goto handle_unusual;
}
if (input->ExpectTag(18)) goto parse_agent;
if (input->ExpectTag(122)) goto parse_agent;
if (input->ExpectAtEnd()) goto success;
break;
}
......@@ -3292,10 +3292,10 @@ void Extern2MATSimTrajectories::SerializeWithCachedSizes(
::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->time(), output);
}
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 2;
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 15;
for (unsigned int i = 0, n = this->agent_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, this->agent(i), output);
15, this->agent(i), output);
}
// @@protoc_insertion_point(serialize_end:org.matsim.hybrid.Extern2MATSimTrajectories)
......@@ -3309,11 +3309,11 @@ void Extern2MATSimTrajectories::SerializeWithCachedSizes(
target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->time(), target);
}
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 2;
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 15;
for (unsigned int i = 0, n = this->agent_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
WriteMessageNoVirtualToArray(
2, this->agent(i), target);
15, this->agent(i), target);
}
// @@protoc_insertion_point(serialize_to_array_end:org.matsim.hybrid.Extern2MATSimTrajectories)
......@@ -3328,7 +3328,7 @@ int Extern2MATSimTrajectories::ByteSize() const {
total_size += 1 + 8;
}
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 2;
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 15;
total_size += 1 * this->agent_size();
for (int i = 0; i < this->agent_size(); i++) {
total_size +=
......@@ -3503,7 +3503,7 @@ void Extern2MATSimTrajectories::InternalSwap(Extern2MATSimTrajectories* other) {
// @@protoc_insertion_point(field_set:org.matsim.hybrid.Extern2MATSimTrajectories.time)
}
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 2;
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 15;
int Extern2MATSimTrajectories::agent_size() const {
return agent_.size();
}
......
......@@ -848,10 +848,10 @@ class Extern2MATSimTrajectories : public ::google::protobuf::Message {
double time() const;
void set_time(double value);
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 2;
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 15;
int agent_size() const;
void clear_agent();
static const int kAgentFieldNumber = 2;
static const int kAgentFieldNumber = 15;
const ::org::matsim::hybrid::Extern2MATSimTrajectories_Agent& agent(int index) const;
::org::matsim::hybrid::Extern2MATSimTrajectories_Agent* mutable_agent(int index);
::org::matsim::hybrid::Extern2MATSimTrajectories_Agent* add_agent();
......@@ -2577,7 +2577,7 @@ inline void Extern2MATSimTrajectories::set_time(double value) {
// @@protoc_insertion_point(field_set:org.matsim.hybrid.Extern2MATSimTrajectories.time)
}
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 2;
// repeated .org.matsim.hybrid.Extern2MATSimTrajectories.Agent agent = 15;
inline int Extern2MATSimTrajectories::agent_size() const {
return agent_.size();
}
......
......@@ -50,7 +50,7 @@ message Extern2MATSimTrajectories {
}
optional double time = 1;
repeated Agent agent = 2;
repeated Agent agent = 15;
}
message MATSim2ExternTrajectoriesReceived {
......
......@@ -164,25 +164,24 @@ bool PedDistributor::InitDistributor(const string& fileName, const std::map<int,
//Parse the sources
TiXmlNode* xSources=xRootNode->FirstChild("agents_sources");
if(xSources)
for(TiXmlElement* e = xSources->FirstChildElement("source"); e;
{
for (TiXmlElement* e = xSources->FirstChildElement("source"); e;
e = e->NextSiblingElement("source"))
{
int id = xmltoi(e->Attribute("id"),-1);
int frequency = xmltoi(e->Attribute("frequency"),-1);
int agents_max = xmltoi(e->Attribute("agents_max"),-1);
int group_id = xmltoi(e->Attribute("group_id"),-1);
string caption = xmltoa(e->Attribute("caption"),"no caption");
//shared_ptr<AgentsSource> my_ptr(new classA);
auto source= shared_ptr<AgentsSource>(new AgentsSource(id,caption,agents_max,group_id,frequency));
int id = xmltoi(e->Attribute("id"), -1);
int frequency = xmltoi(e->Attribute("frequency"), -1);
int agents_max = xmltoi(e->Attribute("agents_max"), -1);
int group_id = xmltoi(e->Attribute("group_id"), -1);
string caption = xmltoa(e->Attribute("caption"), "no caption");
auto source = shared_ptr<AgentsSource>(
new AgentsSource(id, caption, agents_max, group_id,
frequency));
_start_dis_sources.push_back(source);
//look for the start distribution and populate the source
Log->Write("INFO:\tSource with id %s will not be parsed !",e->Attribute("id"));
Log->Write("INFO:\tSource with id %s will not be parsed !", e->Attribute("id"));
}
}
Log->Write("INFO: \t...Done");
return true;
}
......@@ -362,7 +361,6 @@ bool PedDistributor::Distribute(Building* building) const
nPeds++;
}
}
//cout<<"ID sub: "<<dist->GetGroupId()<<endl;
}
for(const auto& dist: _start_dis)
......@@ -376,7 +374,6 @@ bool PedDistributor::Distribute(Building* building) const
nPeds++;
}
}
//cout<<"ID room: "<<dist->GetGroupId()<<endl;
}
}
return nPeds;
......@@ -578,6 +575,7 @@ vector<Point > PedDistributor::PossiblePositions(const SubRoom& r)
std::random_shuffle(all_positions.begin(), all_positions.end());
return all_positions;
}
/* Verteilt N Fußgänger in SubRoom r
* Algorithms:
* - Lege Gitter von min_x bis max_x mit Abstand dx und entsprechend min_y bis max_y mit
......@@ -596,106 +594,10 @@ vector<Point > PedDistributor::PossiblePositions(const SubRoom& r)
void PedDistributor::DistributeInSubRoom(SubRoom* r,int nAgents , vector<Point>& positions, int* pid,
StartDistribution* para, Building* building) const
{
// set the pedestrians
for (int i = 0; i < nAgents; ++i) {
Pedestrian* ped = para->GenerateAgent(building,pid,positions);
building->AddPedestrian(ped);
for (int i = 0; i < nAgents; ++i)
{
Pedestrian* ped = para->GenerateAgent(building, pid, positions);
building->AddPedestrian(ped);
}
}
//void PedDistributor::DistributeInSubRoom(SubRoom* r,int nAgents , vector<Point>& positions, int* pid,
// StartDistributionRoom* para, Building* building) const
//{
//
// //in the case a range was specified
// double distArea[4];
// para->Getbounds(distArea);
// AgentsParameters* agents_para=para->GetGroupParameters();
//
// // set the pedestrians
// for (int i = 0; i < nAgents; ++i) {
//
// Pedestrian* ped = new Pedestrian();
// // PedIndex
// ped->SetID(*pid);
// ped->SetAge(para->GetAge());
// ped->SetGender(para->GetGender());
// ped->SetHeight(para->GetHeight());
// ped->SetFinalDestination(para->GetGoalId());
// ped->SetGroup(para->GetGroupId());
// ped->SetRouter(building->GetRoutingEngine()->GetRouter(para->GetRouterId()));
// //ped->SetTrip(); // not implemented
//
// // a und b setzen muss vor v0 gesetzt werden,
// // da sonst v0 mit Null überschrieben wird
// JEllipse E = JEllipse();
// E.SetAv(agents_para->GetAtau());
// E.SetAmin(agents_para->GetAmin());
// E.SetBmax(agents_para->GetBmax());
// E.SetBmin(agents_para->GetBmin());
// ped->SetEllipse(E);
// ped->SetTau(agents_para->GetTau());
// ped->SetV0Norm(agents_para->GetV0(),
// agents_para->GetV0DownStairs(),
// agents_para->GetV0UpStairs());
// //ped->SetV(Point(0.0,0.0));
//
// // first default Position
// int index = -1;
// //int index = rand() % positions.size();
//
// //in the case a range was specified
// for (unsigned int a=0;a<positions.size();a++)
// {
// Point pos=positions[a];
// if((distArea[0]<=pos._x) &&
// (pos._x <= distArea[1])&&
// (distArea[2]<=pos._y) &&
// (pos._y < distArea[3]))
// {
// index=a;
// break;
// }
// }
// if(index==-1)
// {
// Log->Write("ERROR:\t Cannot distribute pedestrians in the mentioned area [%0.2f,%0.2f,%0.2f,%0.2f]",
// distArea[0],distArea[1],distArea[2],distArea[3]);
// Log->Write("ERROR:\t Specifying a subroom_id might help");
// }
//
// Point pos = positions[index];
// ped->SetPos(pos,true); //true for the initial position
// ped->SetBuilding(building);
// positions.erase(positions.begin() + index);
// ped->SetRoomID(para->GetRoomId(),"");
// ped->SetSubRoomID(r->GetSubRoomID());
// ped->SetPatienceTime(para->GetPatience());
// ped->SetPremovementTime(para->GetPremovementTime());
// ped->SetRiskTolerance(para->GetRiskTolerance());
// const Point& start_pos = para->GetStartPosition();
//
//
// if((std::isnan(start_pos._x)==0 ) && (std::isnan(start_pos._y)==0 ) ) {
// if(r->IsInSubRoom(start_pos)==false){
// Log->Write("ERROR: \t cannot distribute pedestrian %d in Room %d at fixed position %s",
// *pid, para->GetRoomId(), start_pos.toString().c_str());
// Log->Write("ERROR: \t Make sure that the position is inside the geometry and belongs to the specified room / subroom");
// exit(EXIT_FAILURE);
// }
//
// ped->SetPos(start_pos,true); //true for the initial position
// Log->Write("INFO: \t fixed position for ped %d in Room %d %s",
// *pid, para->GetRoomId(), start_pos.toString().c_str());
// }
//
// //r->AddPedestrian(ped);
// building->AddPedestrian(ped);
// (*pid)++;
// }
//}
//SubRoom* r,int nAgents , vector<Point>& positions, int* pid,
// StartDistributionRoom* para, Building* building
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