本文整理汇总了C++中MESegment::initialise方法的典型用法代码示例。如果您正苦于以下问题:C++ MESegment::initialise方法的具体用法?C++ MESegment::initialise怎么用?C++ MESegment::initialise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MESegment
的用法示例。
在下文中一共展示了MESegment::initialise方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
bool
MSEdge::insertVehicle(SUMOVehicle& v, SUMOTime time) const {
// when vaporizing, no vehicles are inserted...
if (isVaporizing()) {
return false;
}
#ifdef HAVE_INTERNAL
if (MSGlobals::gUseMesoSim) {
const SUMOVehicleParameter& pars = v.getParameter();
SUMOReal pos = 0.0;
switch (pars.departPosProcedure) {
case DEPART_POS_GIVEN:
if (pars.departPos >= 0.) {
pos = pars.departPos;
} else {
pos = pars.departPos + getLength();
}
if (pos < 0 || pos > getLength()) {
WRITE_WARNING("Invalid departPos " + toString(pos) + " given for vehicle '" +
v.getID() + "'. Inserting at lane end instead.");
pos = getLength();
}
break;
case DEPART_POS_RANDOM:
case DEPART_POS_RANDOM_FREE:
pos = RandHelper::rand(getLength());
break;
default:
break;
}
bool result = false;
MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this, pos);
MEVehicle* veh = static_cast<MEVehicle*>(&v);
if (pars.departPosProcedure == DEPART_POS_FREE) {
while (segment != 0 && !result) {
result = segment->initialise(veh, time);
segment = segment->getNextSegment();
}
} else {
result = segment->initialise(veh, time);
}
return result;
}
#else
UNUSED_PARAMETER(time);
#endif
MSLane* insertionLane = getDepartLane(static_cast<MSVehicle&>(v));
return insertionLane != 0 && insertionLane->insertVehicle(static_cast<MSVehicle&>(v));
}
示例2: ProcessError
bool
MSEdge::insertVehicle(SUMOVehicle& v, SUMOTime time, const bool checkOnly) const {
// when vaporizing, no vehicles are inserted, but checking needs to be successful to trigger removal
if (isVaporizing()) {
return checkOnly;
}
const SUMOVehicleParameter& pars = v.getParameter();
const MSVehicleType& type = v.getVehicleType();
if (pars.departSpeedProcedure == DEPART_SPEED_GIVEN && pars.departSpeed > getVehicleMaxSpeed(&v)) {
if (type.getSpeedDeviation() > 0 && pars.departSpeed <= type.getSpeedFactor() * getSpeedLimit() * (2 * type.getSpeedDeviation() + 1.)) {
WRITE_WARNING("Choosing new speed factor for vehicle '" + pars.id + "' to match departure speed.");
v.setChosenSpeedFactor(type.computeChosenSpeedDeviation(0, pars.departSpeed / (type.getSpeedFactor() * getSpeedLimit())));
} else {
throw ProcessError("Departure speed for vehicle '" + pars.id +
"' is too high for the departure edge '" + getID() + "'.");
}
}
if (checkOnly && v.getEdge()->getPurpose() == MSEdge::EDGEFUNCTION_DISTRICT) {
return true;
}
if (!checkOnly) {
std::string msg;
if (!v.hasValidRoute(msg)) {
if (MSGlobals::gCheckRoutes) {
throw ProcessError("Vehicle '" + v.getID() + "' has no valid route. " + msg);
} else if (v.getEdge()->getPurpose() == MSEdge::EDGEFUNCTION_DISTRICT) {
WRITE_WARNING("Removing vehicle '" + pars.id + "' which has no valid route.");
MSNet::getInstance()->getInsertionControl().descheduleDeparture(&v);
return false;
}
}
}
if (MSGlobals::gUseMesoSim) {
SUMOReal pos = 0.0;
switch (pars.departPosProcedure) {
case DEPART_POS_GIVEN:
if (pars.departPos >= 0.) {
pos = pars.departPos;
} else {
pos = pars.departPos + getLength();
}
if (pos < 0 || pos > getLength()) {
WRITE_WARNING("Invalid departPos " + toString(pos) + " given for vehicle '" +
v.getID() + "'. Inserting at lane end instead.");
pos = getLength();
}
break;
case DEPART_POS_RANDOM:
case DEPART_POS_RANDOM_FREE:
pos = RandHelper::rand(getLength());
break;
default:
break;
}
bool result = false;
MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this, pos);
MEVehicle* veh = static_cast<MEVehicle*>(&v);
if (pars.departPosProcedure == DEPART_POS_FREE) {
while (segment != 0 && !result) {
if (checkOnly) {
result = segment->hasSpaceFor(veh, time, true);
} else {
result = segment->initialise(veh, time);
}
segment = segment->getNextSegment();
}
} else {
if (checkOnly) {
result = segment->hasSpaceFor(veh, time, true);
} else {
result = segment->initialise(veh, time);
}
}
return result;
}
if (checkOnly) {
switch (v.getParameter().departLaneProcedure) {
case DEPART_LANE_GIVEN:
case DEPART_LANE_DEFAULT:
case DEPART_LANE_FIRST_ALLOWED: {
const SUMOReal occupancy = getDepartLane(static_cast<MSVehicle&>(v))->getBruttoOccupancy();
return occupancy == (SUMOReal)0 || occupancy * myLength + v.getVehicleType().getLengthWithGap() <= myLength;
}
default:
for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
const SUMOReal occupancy = (*i)->getBruttoOccupancy();
if (occupancy == (SUMOReal)0 || occupancy * myLength + v.getVehicleType().getLengthWithGap() <= myLength) {
return true;
}
}
}
return false;
}
MSLane* insertionLane = getDepartLane(static_cast<MSVehicle&>(v));
return insertionLane != 0 && insertionLane->insertVehicle(static_cast<MSVehicle&>(v));
}