Log closing/opening of activities

parent 4601a1b6
Pipeline #16865 passed with stages
in 17 minutes and 43 seconds
......@@ -466,6 +466,10 @@ bool GeoFileParser::LoadTrafficInfo(Building* building)
int id = xmltoi(xDoor->Attribute("trans_id"), -1);
if (id!=-1) {
std::string str("INFO:\tParsed Door: \n");
char tmp[100];
sprintf(tmp, "\t>> ID: %d\n", id);
str.append(tmp);
//------------------ state
std::string state = xmltoa(xDoor->Attribute("state"), "open");
//store transition in a map and call getTransition/getCrossin
......@@ -478,11 +482,15 @@ bool GeoFileParser::LoadTrafficInfo(Building* building)
else {
Log->Write("WARNING:\t Unknown door state: <%s>. open or close. Default: open", state.c_str());
}
sprintf(tmp, "\t>> state: %s\n", state.c_str());
str.append(tmp);
//------------------ outflow
double outflow = xmltof(xDoor->Attribute("outflow"), -1.0);
if(outflow >= 0)
{
building->GetTransition(id)->SetOutflowRate(outflow);
sprintf(tmp, "\t>> ouflow: %.2f\n", outflow);
str.append(tmp);
}
//----------------- dt
double DT = xmltof(xDoor->Attribute("dt"), -1.0);
......@@ -491,19 +499,25 @@ bool GeoFileParser::LoadTrafficInfo(Building* building)
building->GetTransition(id)->SetDT(DT);
}
//----------------- dn
double DN = xmltof(xDoor->Attribute("dn"), -1.0);
int DN = xmltof(xDoor->Attribute("dn"), -1.0);
if(DN >= 0)
{
building->GetTransition(id)->SetDN(DN);
sprintf(tmp, "\t>> dn: %d\n", DN);
str.append(tmp);
}
//------------------ max door usage
double mdu = xmltof(xDoor->Attribute("max_agents"), -1);
int mdu = xmltof(xDoor->Attribute("max_agents"), -1);
if(mdu >= 0)
{
building->GetTransition(id)->SetMaxDoorUsage(mdu);
sprintf(tmp, "\t>> max_agents: %d\n", mdu);
str.append(tmp);
}
//------------------
//-----------------
Log->Write(str);
}
else {
id = xmltoi(xDoor->Attribute("cross_id"), -1);
......
......@@ -579,9 +579,8 @@ double Simulation::RunBody(double maxSimTime)
Trans->UpdateClosingTime( _deltaT);
if(Trans->GetClosingTime() <= _deltaT)
{
std::cout << KRED << " In simulation:" << Pedestrian::GetGlobalTime() << RESET << "\n";
Trans->changeTemporaryState();
std::cerr << Trans->GetID() << " " << Pedestrian::GetGlobalTime() << " open " << Trans->GetDoorUsage() << std::endl;
Log-> Write("INFO:\tReset state of door %d, Time=%.2f", Trans->GetID(), Pedestrian::GetGlobalTime());
}
}
......@@ -697,17 +696,11 @@ void Simulation::UpdateFlowAtDoors(const Pedestrian& ped) const
trans->IncreaseDoorUsage(1, ped.GetGlobalTime());
trans->IncreasePartialDoorUsage(1);
std::cout << KYEL << Pedestrian::GetGlobalTime() << " " << trans->GetPartialDoorUsage() << " " << trans->GetDN()<< "\n" << RESET;
// when <dn> agents pass <trans>, we start evaluating the flow
// .. and maybe close the <trans>
if( trans->GetPartialDoorUsage() == trans->GetDN() ) {
std::cout << "Regulate flow at " << Pedestrian::GetGlobalTime() << "\n";
std::cout << "dn = " << trans->GetDN() << "\n";
trans->regulateFlow(Pedestrian::GetGlobalTime());
trans->ResetPartialDoorUsage();
getc(stdin);
}
}
......
......@@ -187,7 +187,7 @@ int Crossing::CommonSubroomWith(Crossing* other, SubRoom* &subroom) {
void Crossing::IncreaseDoorUsage(int number, double time)
{
// std::cout << "IncreaseDoorUsage with door " << GetID() << " status: " << _isOpen<< " lastpassing " << _lastPassingTime << " time "<< time<<"\n";
_doorUsage += number;
_lastPassingTime = time;
_flowAtExit += to_string(time) + " " + to_string(_doorUsage) + "\n";
......@@ -253,8 +253,6 @@ double Crossing::GetClosingTime() const
void Crossing::UpdateClosingTime(double dt)
{
_closingTime -= dt;
// std::cout << "UPdateClosingTime for " << GetID() << ", "<< _closingTime << "\n";
// std::cout << "Status: " << _isOpen << "\n";
}
bool Crossing::isTemporaryClosed()
......@@ -292,49 +290,36 @@ void Crossing::regulateFlow(double time)
double number = GetPartialDoorUsage();
double T = time - _lastFlowMeasurement;
double flow = number / T;
std::cout << KRED << "time " << time << std::endl;
std::cout << KRED << "lastFlowMeasurement " << _lastFlowMeasurement << std::endl;
std::cout << KRED << "closingTime " << _closingTime << std::endl;
std::cout << KRED << "T " << T << std::endl;
std::cout << KRED << "flow " << flow << RESET <<std::endl;
if(flow > _outflowRate)
{
// _outflowRate > flow (=number/deltaTime)
// _outflowRate = number/(deltaTime + t1)
// --> [1]
//---------------------------
//---------------------------
_closingTime = number / _outflowRate - T; //[1]
_temporaryClosed = true;
this->Close();
//---------------------------
std::cout << GetID() << " " << " close " << _doorUsage << " " << GetPartialDoorUsage() << " " << _lastFlowMeasurement << " " << time << std::endl;
std::cout << KGRN << "Closing transition " << GetID() << ". Closing time " << _closingTime <<"\n";
std::cout << "time: " << time << " _lastFlowMeasurement: "<<_lastFlowMeasurement << " Waiting time " << "\n";
// std::cout << "last passing time " << xoldTime << "\n";
// std::cout << "delta time " << deltaTime << "\n";
std::cout << "door usage " << _doorUsage << std::endl;
std::cout << "PartialDoorUsage " << number << "\n";
std::cout << "\n ---> J = " << flow << std::endl ;
std::cout << "Max J " << _outflowRate << "\n" << RESET;
std::cout << "Temporary state " << _temporaryClosed << std::endl;
// getc(stdin);
}
else{
std::cout << KYEL << GetID()<< ": Nice Flow " << flow <<" max " << _outflowRate << "\n" << RESET;
}
// close the door is mdu is reached
if(_doorUsage >= _maxDoorUsage)
{
std::cerr << GetID() << " " << time << " CLOSE " << _doorUsage << std::endl;
std::cout << KGRN << "Closing door " << GetID() << "because doorUsage " << _doorUsage << " > maxDoorUsage " << _maxDoorUsage << "\n"<< RESET;
this->Close();
Log-> Write("INFO:\tClosing door %d. DoorUsage = %d (max = %d). Flow = %.2f (max = %.2f) Time=%.2f", GetID(), GetDoorUsage(), GetMaxDoorUsage(), flow, _outflowRate, time);
}
// close the door is mdu is reached
if(_doorUsage >= _maxDoorUsage)
{
Log-> Write("INFO:\tClosing door %d. DoorUsage = %d (>= %d). Time=%.2f", GetID(), GetDoorUsage(), GetMaxDoorUsage(), time);
this->Close();
_temporaryClosed = false;
......@@ -347,5 +332,4 @@ void Crossing::changeTemporaryState()
_temporaryClosed = false;
_closingTime = 0;
this->Open();
std::cout << KRED<< ">> ChangeTemporaryState Open door for trans "<< GetID() <<", " <<this->_lastPassingTime << "\n" << RESET;
}
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