本文整理汇总了C++中STEPS2TIME函数的典型用法代码示例。如果您正苦于以下问题:C++ STEPS2TIME函数的具体用法?C++ STEPS2TIME怎么用?C++ STEPS2TIME使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STEPS2TIME函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: STEPS2TIME
bool
MSInductLoop::notifyMove(SUMOVehicle& veh, SUMOReal oldPos,
SUMOReal newPos, SUMOReal newSpeed) {
if (newPos < myPosition) {
// detector not reached yet
return true;
}
if (newPos >= myPosition && oldPos < myPosition) {
// entered the detector by move
SUMOReal entryTime = STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep());
if (newSpeed != 0) {
if (myPosition > oldPos) {
entryTime += (myPosition - oldPos) / newSpeed;
}
}
enterDetectorByMove(veh, entryTime);
}
if (newPos - veh.getVehicleType().getLength() > myPosition) {
// vehicle passed the detector
SUMOReal leaveTime = STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep());
leaveTime += (myPosition - oldPos + veh.getVehicleType().getLength()) / newSpeed;
leaveDetectorByMove(veh, leaveTime);
return false;
}
// vehicle stays on the detector
return true;
}
示例2: GUIParameterTableWindow
GUIParameterTableWindow*
GUICalibrator::getParameterWindow(GUIMainWindow& app,
GUISUMOAbstractView&) {
GUIParameterTableWindow* ret;
if (isActive()) {
ret = new GUIParameterTableWindow(app, *this, 10);
// add items
ret->mkItem("interval start", false, STEPS2TIME(myCurrentStateInterval->begin));
ret->mkItem("interval end", false, STEPS2TIME(myCurrentStateInterval->end));
ret->mkItem("aspired flow [veh/h]", false, myCurrentStateInterval->q);
ret->mkItem("aspired speed", false, myCurrentStateInterval->v);
ret->mkItem("default speed", false, myDefaultSpeed);
ret->mkItem("required vehicles", true, new FunctionBinding<GUICalibrator, int>(this, &GUICalibrator::totalWished));
ret->mkItem("passed vehicles", true, new FunctionBinding<GUICalibrator, int>(this, &GUICalibrator::passed));
ret->mkItem("inserted vehicles", true, new FunctionBinding<GUICalibrator, int>(this, &GUICalibrator::inserted));
ret->mkItem("removed vehicles", true, new FunctionBinding<GUICalibrator, int>(this, &GUICalibrator::removed));
ret->mkItem("cleared in jam", true, new FunctionBinding<GUICalibrator, int>(this, &GUICalibrator::clearedInJam));
} else {
ret = new GUIParameterTableWindow(app, *this, 1);
const std::string nextStart =
(myCurrentStateInterval != myIntervals.end() ?
time2string(myCurrentStateInterval->begin) :
"simulation end");
ret->mkItem("inactive until", false, nextStart);
}
// close building
ret->closeBuilding();
return ret;
}
示例3: getStretchAreaNo
void
MSTLLogicControl::WAUTSwitchProcedure_Stretch::stretchLogic(SUMOTime step, SUMOTime startPos, SUMOTime allStretchTime) {
unsigned int currStep = myTo->getIndexFromOffset(startPos);
SUMOTime durOfPhase = myTo->getPhase(currStep).duration;
SUMOTime remainingStretchTime = allStretchTime;
SUMOTime StretchTimeOfPhase = 0;
unsigned int stretchUmlaufAnz = (unsigned int) TplConvert::_2SUMOReal(myTo->getParameterValue("StretchUmlaufAnz").c_str());
SUMOReal facSum = 0;
int areasNo = getStretchAreaNo(myTo);
for (int x = 0; x < areasNo; x++) {
StretchBereichDef def = getStretchBereichDef(myTo, x + 1);
facSum += def.fac;
}
facSum *= stretchUmlaufAnz;
//switch to startPos and stretch this phase, if there is a end of "bereich" between startpos and end of phase
SUMOTime diffToStart = getDiffToStartOfPhase(*myTo, startPos);
for (int x = 0; x < areasNo; x++) {
StretchBereichDef def = getStretchBereichDef(myTo, x + 1);
SUMOTime end = TIME2STEPS(def.end);
SUMOTime endOfPhase = (startPos + durOfPhase - diffToStart);
if (end <= endOfPhase && end >= startPos) {
SUMOReal fac = def.fac;
SUMOReal actualfac = fac / facSum;
facSum = facSum - fac;
StretchTimeOfPhase = TIME2STEPS(int(STEPS2TIME(remainingStretchTime) * actualfac + 0.5));
remainingStretchTime = allStretchTime - StretchTimeOfPhase;
}
}
if (facSum == 0) {
WRITE_WARNING("The computed factor sum in WAUT '" + myWAUT.id + "' at time '" + toString(STEPS2TIME(step)) + "' equals zero;\n assuming an error in WAUT definition.");
return;
}
durOfPhase = durOfPhase - diffToStart + StretchTimeOfPhase;
myTo->changeStepAndDuration(myControl, step, currStep, durOfPhase);
currStep = (currStep + 1) % (int)myTo->getPhases().size();
// stretch all other phases, if there is a "bereich"
while (remainingStretchTime > 0) {
for (unsigned int i = currStep; i < myTo->getPhases().size() && remainingStretchTime > 0; i++) {
durOfPhase = myTo->getPhase(i).duration;
SUMOTime beginOfPhase = myTo->getOffsetFromIndex(i);
SUMOTime endOfPhase = beginOfPhase + durOfPhase;
for (int j = 0; j < areasNo && remainingStretchTime > 0; j++) {
StretchBereichDef def = getStretchBereichDef(myTo, j + 1);
SUMOTime end = TIME2STEPS(def.end);
SUMOReal fac = def.fac;
if ((beginOfPhase <= end) && (endOfPhase >= end)) {
SUMOReal actualfac = fac / facSum;
StretchTimeOfPhase = TIME2STEPS(int(STEPS2TIME(remainingStretchTime) * actualfac + 0.5));
facSum -= fac;
durOfPhase += StretchTimeOfPhase;
remainingStretchTime -= StretchTimeOfPhase;
}
}
myTo->addOverridingDuration(durOfPhase);
}
currStep = 0;
}
}
示例4: throw
void MSInductLoop::writeXMLOutput(OutputDevice &dev,
SUMOTime startTime, SUMOTime stopTime) throw(IOError) {
SUMOReal t(STEPS2TIME(stopTime-startTime));
unsigned nVehCrossed ;
SUMOReal flow ;
SUMOReal occupancy = 0;
SUMOReal meanLength, meanSpeed;
dev.openTag("interval");
dev <<" begin=\""<<time2string(startTime)<<"\" end=\""<<
time2string(stopTime)<<"\" \n";
unsigned totVeh = 0;
for(unsigned stripIndex=0;stripIndex<myStripCount;stripIndex++){
int no_vehicles = myVehicleDataCont[stripIndex].size();
nVehCrossed = (unsigned) no_vehicles;
flow = ((SUMOReal) no_vehicles / (SUMOReal) t) * (SUMOReal) 3600.0;
for (std::deque< VehicleData >::const_iterator i=myVehicleDataCont[stripIndex].begin(); i!=myVehicleDataCont[stripIndex].end(); ++i) {
SUMOReal timeOnDetDuringInterval = (*i).leaveTimeM - MAX2(STEPS2TIME(startTime), (*i).entryTimeM);
timeOnDetDuringInterval = MIN2(timeOnDetDuringInterval, t);
occupancy += timeOnDetDuringInterval;
}
for (std::map< MSVehicle*, SUMOReal >::const_iterator i=myVehiclesOnDet[stripIndex].begin(); i!=myVehiclesOnDet[stripIndex].end(); ++i) {
SUMOReal timeOnDetDuringInterval = STEPS2TIME(stopTime) - MAX2(STEPS2TIME(startTime), (*i).second);
occupancy += timeOnDetDuringInterval;
}
occupancy = no_vehicles!=0 ? occupancy / t * (SUMOReal) 100.0 : 0;
meanSpeed = no_vehicles!=0
? accumulate(myVehicleDataCont[stripIndex].begin(), myVehicleDataCont[stripIndex].end(), (SUMOReal) 0.0, speedSum) / (SUMOReal) myVehicleDataCont[stripIndex].size()
: -1;
meanLength = no_vehicles!=0
? accumulate(myVehicleDataCont[stripIndex].begin(), myVehicleDataCont[stripIndex].end(), (SUMOReal) 0.0, lengthSum) / (SUMOReal) myVehicleDataCont[stripIndex].size()
: -1;
if(no_vehicles >= 1){
dev <<"\tstripNum=\""<<stripIndex<<" \"vehicle_id=\""<< (myVehicleDataCont[stripIndex].begin())->idM
<<"\" flow=\""<<flow<<
"\" occupancy=\""<<occupancy<<"\" speed=\""<<meanSpeed<<
"\" length=\""<<meanLength<<
"\" nVehEntered=\""<<no_vehicles<<"\" \n";
totVeh += no_vehicles;
}
else {
dev << "\tstripNum=\""<<stripIndex
<<"\" flow=\""<<flow<<
"\" occupancy=\""<<occupancy<<"\" speed=\""<<meanSpeed<<
"\" length=\""<<meanLength<<
"\" nVehEntered=\""<<no_vehicles<<"\" \n";
totVeh += no_vehicles;
}
}
dev << "total_Vehicles=\" "<<totVeh + myDismissedVehicleNumber <<"\"";
dev.closeTag(true);
reset();
}
示例5: STEPS2TIME
void
MSMeanData_Net::MSLaneMeanDataValues::write(OutputDevice& dev, const SUMOTime period,
const SUMOReal numLanes, const SUMOReal defaultTravelTime, const int numVehicles) const {
if (myParent == 0) {
if (sampleSeconds > 0) {
dev << "\" density=\"" << sampleSeconds / STEPS2TIME(period) *(SUMOReal) 1000 / myLaneLength <<
"\" occupancy=\"" << vehLengthSum / STEPS2TIME(period) / myLaneLength / numLanes *(SUMOReal) 100 <<
"\" waitingTime=\"" << waitSeconds <<
"\" speed=\"" << travelledDistance / sampleSeconds;
}
dev << "\" departed=\"" << nVehDeparted <<
"\" arrived=\"" << nVehArrived <<
"\" entered=\"" << nVehEntered <<
"\" left=\"" << nVehLeft << "\"";
if (nVehVaporized > 0) {
dev << " vaporized=\"" << nVehVaporized << "\"";
}
dev.closeTag();
return;
}
if (sampleSeconds > myParent->myMinSamples) {
SUMOReal traveltime = myParent->myMaxTravelTime;
if (travelledDistance > 0.f) {
traveltime = MIN2(traveltime, myLaneLength * sampleSeconds / travelledDistance);
}
if (numVehicles > 0) {
dev << "\" traveltime=\"" << sampleSeconds / numVehicles <<
"\" waitingTime=\"" << waitSeconds <<
"\" speed=\"" << travelledDistance / sampleSeconds;
} else {
dev << "\" traveltime=\"" << traveltime <<
"\" density=\"" << sampleSeconds / STEPS2TIME(period) *(SUMOReal) 1000 / myLaneLength <<
"\" occupancy=\"" << vehLengthSum / STEPS2TIME(period) / myLaneLength / numLanes *(SUMOReal) 100 <<
"\" waitingTime=\"" << waitSeconds <<
"\" speed=\"" << travelledDistance / sampleSeconds;
}
} else if (defaultTravelTime >= 0.) {
dev << "\" traveltime=\"" << defaultTravelTime <<
"\" speed=\"" << myLaneLength / defaultTravelTime;
}
dev << "\" departed=\"" << nVehDeparted <<
"\" arrived=\"" << nVehArrived <<
"\" entered=\"" << nVehEntered <<
"\" left=\"" << nVehLeft <<
"\" laneChangedFrom=\"" << nVehLaneChangeFrom <<
"\" laneChangedTo=\"" << nVehLaneChangeTo << "\"";
if (nVehVaporized > 0) {
dev << " vaporized=\"" << nVehVaporized << "\"";
}
dev.closeTag();
}
示例6: GUIParameterTableWindow
GUIParameterTableWindow*
GUIVehicle::getTypeParameterWindow(GUIMainWindow& app,
GUISUMOAbstractView&) {
GUIParameterTableWindow* ret =
new GUIParameterTableWindow(app, *this, 26
+ (int)myType->getParameter().getParametersMap().size()
+ (int)myType->getParameter().lcParameter.size()
+ (int)myType->getParameter().jmParameter.size());
// add items
ret->mkItem("Type Information:", false, "");
ret->mkItem("type [id]", false, myType->getID());
ret->mkItem("length", false, myType->getLength());
ret->mkItem("width", false, myType->getWidth());
ret->mkItem("height", false, myType->getHeight());
ret->mkItem("minGap", false, myType->getMinGap());
ret->mkItem("vehicle class", false, SumoVehicleClassStrings.getString(myType->getVehicleClass()));
ret->mkItem("emission class", false, PollutantsInterface::getName(myType->getEmissionClass()));
ret->mkItem("carFollowModel", false, SUMOXMLDefinitions::CarFollowModels.getString((SumoXMLTag)getCarFollowModel().getModelID()));
ret->mkItem("LaneChangeModel", false, SUMOXMLDefinitions::LaneChangeModels.getString(getLaneChangeModel().getModelID()));
ret->mkItem("guiShape", false, getVehicleShapeName(myType->getGuiShape()));
ret->mkItem("maximum speed [m/s]", false, getMaxSpeed());
ret->mkItem("maximum acceleration [m/s^2]", false, getCarFollowModel().getMaxAccel());
ret->mkItem("maximum deceleration [m/s^2]", false, getCarFollowModel().getMaxDecel());
ret->mkItem("emergency deceleration [m/s^2]", false, getCarFollowModel().getEmergencyDecel());
ret->mkItem("apparent deceleration [m/s^2]", false, getCarFollowModel().getApparentDecel());
ret->mkItem("imperfection (sigma)", false, getCarFollowModel().getImperfection());
ret->mkItem("desired headway (tau)", false, getCarFollowModel().getHeadwayTime());
ret->mkItem("person capacity", false, myType->getPersonCapacity());
ret->mkItem("boarding time", false, STEPS2TIME(myType->getBoardingDuration()));
ret->mkItem("container capacity", false, myType->getContainerCapacity());
ret->mkItem("loading time", false, STEPS2TIME(myType->getLoadingDuration()));
if (MSGlobals::gLateralResolution > 0) {
ret->mkItem("minGapLat", false, myType->getMinGapLat());
ret->mkItem("maxSpeedLat", false, myType->getMaxSpeedLat());
ret->mkItem("latAlignment", false, toString(myType->getPreferredLateralAlignment()));
} else if (MSGlobals::gLaneChangeDuration > 0) {
ret->mkItem("maxSpeedLat", false, myType->getMaxSpeedLat());
}
for (auto item : myType->getParameter().lcParameter) {
ret->mkItem(toString(item.first).c_str(), false, toString(item.second));
}
for (auto item : myType->getParameter().jmParameter) {
ret->mkItem(toString(item.first).c_str(), false, toString(item.second));
}
// close building
ret->closeBuilding(&(myType->getParameter()));
return ret;
}
示例7: getPhases
void
GNETLSEditorFrame::initPhaseTable(unsigned int index) {
myPhaseTable->setVisibleRows(1);
myPhaseTable->setVisibleColumns(2);
myPhaseTable->hide();
if (myDefinitions.size() > 0) {
const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases = getPhases();
myPhaseTable->setTableSize((int)phases.size(), 2);
myPhaseTable->setVisibleRows((int)phases.size());
myPhaseTable->setVisibleColumns(2);
for (unsigned int row = 0; row < phases.size(); row++) {
myPhaseTable->setItemText(row, 0, toString(STEPS2TIME(phases[row].duration)).c_str());
myPhaseTable->setItemText(row, 1, phases[row].state.c_str());
myPhaseTable->getItem(row, 1)->setJustify(FXTableItem::LEFT);
}
myPhaseTable->fitColumnsToContents(0, 2);
const int maxWidth = 140 - 4;
int desiredWidth = myPhaseTable->getColumnWidth(0) +
myPhaseTable->getColumnWidth(1) + 3;
int spaceForScrollBar = desiredWidth > maxWidth ? 15 : 0;
myPhaseTable->setHeight((int)phases.size() * 21 + spaceForScrollBar); // experimental
myPhaseTable->setWidth(MIN2(desiredWidth, maxWidth));
myPhaseTable->setCurrentItem(index, 0);
myPhaseTable->selectRow(index, true);
myPhaseTable->show();
myPhaseTable->setFocus();
}
update();
}
示例8: sortByBeginTime
void
ODMatrix::writeFlows(const SUMOTime begin, const SUMOTime end,
OutputDevice& dev, bool noVtype,
const std::string& prefix,
bool asProbability) {
if (myContainer.size() == 0) {
return;
}
int flowName = 0;
sortByBeginTime();
// recheck begin time
for (std::vector<ODCell*>::const_iterator i = myContainer.begin(); i != myContainer.end(); ++i) {
const ODCell* const c = *i;
if (c->end > begin && c->begin < end) {
dev.openTag(SUMO_TAG_FLOW).writeAttr(SUMO_ATTR_ID, prefix + toString(flowName++));
dev.writeAttr(SUMO_ATTR_BEGIN, time2string(c->begin));
dev.writeAttr(SUMO_ATTR_END, time2string(c->end));
if (!asProbability) {
dev.writeAttr(SUMO_ATTR_NUMBER, int(c->vehicleNumber));
} else {
const double probability = float(c->vehicleNumber) / STEPS2TIME(c->end - c->begin);
if (probability > 1) {
WRITE_WARNING("Flow density of " + toString(probability) + " vehicles per second, cannot be represented with a simple probability. Falling back to even spacing.");
dev.writeAttr(SUMO_ATTR_NUMBER, int(c->vehicleNumber));
} else {
dev.setPrecision(6);
dev.writeAttr(SUMO_ATTR_PROB, probability);
dev.setPrecision();
}
}
writeDefaultAttrs(dev, noVtype, *i);
dev.closeTag();
}
}
}
示例9: MIN2
SUMOTime
MESegment::newArrival(const MEVehicle* const v, SUMOReal newSpeed, SUMOTime currentTime) {
// since speed is only an upper bound pos may be to optimistic
const SUMOReal pos = MIN2(myLength, STEPS2TIME(currentTime - v->getLastEntryTime()) * v->getSpeed());
// traveltime may not be 0
return currentTime + MAX2(TIME2STEPS((myLength - pos) / newSpeed), SUMOTime(1));
}
示例10: getSUMOTime
long
GNETLSEditorFrame::onCmdPhaseEdit(FXObject*, FXSelector, void* ptr) {
/* @note: there is a bug when copying/pasting rows: when this handler is
* called the value of the cell is not yet updated. This means you have to
* click inside the cell and hit enter to actually update the value */
FXTablePos* tp = (FXTablePos*)ptr;
FXString value = myPhaseTable->getItemText(tp->row, tp->col);
if (tp->col == 0) {
// duration edited
if (GNEAttributeCarrier::canParse<SUMOReal>(value.text())) {
SUMOTime duration = getSUMOTime(value);
if (duration > 0) {
myEditedDef->getLogic()->setPhaseDuration(tp->row, duration);
myHaveModifications = true;
updateCycleDuration();
return 1;
}
}
// input error, reset value
myPhaseTable->setItemText(tp->row, 0, toString(STEPS2TIME(getPhases()[tp->row].duration)).c_str());
} else {
// state edited
try {
// insert phase with new step and delete the old phase
myEditedDef->getLogic()->addStep(getPhases()[tp->row].duration, value.text(), tp->row);
myEditedDef->getLogic()->deletePhase(tp->row + 1);
myHaveModifications = true;
onCmdPhaseSwitch(0, 0, 0);
} catch (ProcessError) {
// input error, reset value
myPhaseTable->setItemText(tp->row, 1, getPhases()[tp->row].state.c_str());
}
}
return 1;
}
示例11: assert
long
GNETLSEditorFrame::onCmdDefSwitch(FXObject*, FXSelector, void*) {
assert(myCurrentJunction != 0);
assert((int)myDefinitions.size() == myProgramComboBox->getNumItems());
NBTrafficLightDefinition* tlDef = myDefinitions[myProgramComboBox->getCurrentItem()];
// logic may not have been recomputed yet. recompute to be sure
NBTrafficLightLogicCont& tllCont = myViewNet->getNet()->getTLLogicCont();
myViewNet->getNet()->computeJunction(myCurrentJunction);
NBTrafficLightLogic* tllogic = tllCont.getLogic(tlDef->getID(), tlDef->getProgramID());
if (tllogic != 0) {
// now we can be sure that the tlDef is up to date (i.e. re-guessed)
buildIinternalLanes(tlDef);
// create working copy from original def
delete myEditedDef;
myEditedDef = new NBLoadedSUMOTLDef(tlDef, tllogic);
myOffset->setText(toString(STEPS2TIME(myEditedDef->getLogic()->getOffset())).c_str());
initPhaseTable();
updateCycleDuration();
} else {
// tlDef has no valid logic (probably because id does not control any links
onCmdCancel(0, 0, 0);
myViewNet->setStatusBarText("Traffic light does not control any links");
}
return 1;
}
示例12: updateMeanData
void
MSCalibrator::writeXMLOutput() {
if (myOutput != nullptr) {
updateMeanData();
const int p = passed();
// meandata will be off if vehicles are removed on the next edge instead of this one
const int discrepancy = myEdgeMeanData.nVehEntered + myEdgeMeanData.nVehDeparted - myEdgeMeanData.nVehVaporized - passed();
assert(discrepancy >= 0);
const std::string ds = (discrepancy > 0 ? "\" vaporizedOnNextEdge=\"" + toString(discrepancy) : "");
const double durationSeconds = STEPS2TIME(myCurrentStateInterval->end - myCurrentStateInterval->begin);
(*myOutput) << " <interval begin=\"" << time2string(myCurrentStateInterval->begin) <<
"\" end=\"" << time2string(myCurrentStateInterval->end) <<
"\" id=\"" << myID <<
"\" nVehContrib=\"" << p <<
"\" removed=\"" << myRemoved <<
"\" inserted=\"" << myInserted <<
"\" cleared=\"" << myClearedInJam <<
"\" flow=\"" << p * 3600.0 / durationSeconds <<
"\" aspiredFlow=\"" << myCurrentStateInterval->q <<
"\" speed=\"" << myEdgeMeanData.getTravelledDistance() / myEdgeMeanData.getSamples() <<
"\" aspiredSpeed=\"" << myCurrentStateInterval->v <<
ds << //optional
"\"/>\n";
}
myDidSpeedAdaption = false;
myInserted = 0;
myRemoved = 0;
myClearedInJam = 0;
myHaveWarnedAboutClearingJam = false;
reset();
}
示例13: closeSimulation
void MSNet::closeSimulation(SUMOTime start)
{
if (myLogExecutionTime) {
long duration = SysUtils::getCurrentMillis() - mySimBeginMillis;
std::ostringstream msg;
msg << "Performance: " << "\n" << " Duration: " << duration << " ms" << "\n";
if (duration != 0) {
msg << " Real time factor: " << (STEPS2TIME(myStep - start) * 1000. / (SUMOReal)duration) << "\n";
msg.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
msg.setf(std::ios::showpoint); // print decimal point
msg << " UPS: " << ((SUMOReal) myVehiclesMoved * 1000. / (SUMOReal) duration) << "\n";
}
const std::string scaleNotice = ((myVehicleControl->getLoadedVehicleNo() != myVehicleControl->getDepartedVehicleNo()) ?
" (Loaded: " + toString(myVehicleControl->getLoadedVehicleNo()) + ")" : "");
msg << "Vehicles: " << "\n"
<< " Emitted: " << myVehicleControl->getDepartedVehicleNo() << scaleNotice << "\n"
<< " Running: " << myVehicleControl->getRunningVehicleNo() << "\n"
<< " Waiting: " << myInserter->getWaitingVehicleNo() << "\n";
WRITE_MESSAGE(msg.str());
}
myDetectorControl->close(myStep);
#ifndef NO_TRACI
traci::TraCIServer::close();
#endif
}
示例14: MAX2
void MSEdge::recalcCache() {
if (myLanes->empty()) {
return;
}
myLength = myLanes->front()->getLength();
myEmptyTraveltime = myLength / MAX2(getSpeedLimit(), NUMERICAL_EPS);
if (MSGlobals::gMesoTLSPenalty > 0 || MSGlobals::gMesoMinorPenalty > 0) {
// add tls penalties to the minimum travel time
SUMOTime minPenalty = -1;
for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
MSLane* l = *i;
const MSLinkCont& lc = l->getLinkCont();
for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
MSLink* link = *j;
SUMOTime linkPenalty = link->getMesoTLSPenalty() + (link->havePriority() ? 0 : MSGlobals::gMesoMinorPenalty);
if (minPenalty == -1) {
minPenalty = linkPenalty;
} else {
minPenalty = MIN2(minPenalty, linkPenalty);
}
}
}
if (minPenalty > 0) {
myEmptyTraveltime += STEPS2TIME(minPenalty);
}
}
}
示例15: STEPS2TIME
bool
MSE3Collector::MSE3EntryReminder::notifyMove(SUMOVehicle& veh, double oldPos,
double newPos, double newSpeed) {
if (myCollector.myEnteredContainer.find(&veh) == myCollector.myEnteredContainer.end() && newPos > myPosition) {
if (oldPos > myPosition) {
// was behind the detector already in the last step
return false;
} else {
// entered in this step
const double oldSpeed = veh.getPreviousSpeed();
const double entryTime = STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep());
assert(!MSGlobals::gSemiImplicitEulerUpdate || newSpeed != 0); // how could it move across the detector otherwise
const double timeBeforeEnter = MSCFModel::passingTime(oldPos, myPosition, newPos, oldSpeed, newSpeed);
const double fractionTimeOnDet = TS - timeBeforeEnter;
myCollector.enter(veh, entryTime - fractionTimeOnDet, fractionTimeOnDet);
#ifdef DEBUG_E3_NOTIFY_MOVE
if (DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
std::cout << "\n" << SIMTIME
<< " MSE3EntryReminder::notifyMove() (" << getDescription() << "on lane '" << myLane->getID() << "')"
<< " vehicle '" << veh.getID() << "'"
<< " entered. oldPos=" << oldPos << " newPos=" << newPos << " newSpeed=" << newSpeed << "\n";
}
#endif
}
}
return true;
}