当前位置: 首页>>代码示例>>C++>>正文


C++ SUMOVehicle类代码示例

本文整理汇总了C++中SUMOVehicle的典型用法代码示例。如果您正苦于以下问题:C++ SUMOVehicle类的具体用法?C++ SUMOVehicle怎么用?C++ SUMOVehicle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SUMOVehicle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: toString

void
MSE3Collector::leave(SUMOVehicle& veh, SUMOReal leaveTimestep) {
    if (myEnteredContainer.find(&veh) == myEnteredContainer.end()) {
        WRITE_WARNING("Vehicle '" + veh.getID() + "' left " + toString(SUMO_TAG_E3DETECTOR) + " '" + getID() + "' before entering it.");
    } else {
        E3Values values = myEnteredContainer[&veh];
        values.leaveTime = leaveTimestep;
        SUMOReal leaveTimestepFraction = leaveTimestep - (SUMOReal)((int) leaveTimestep);
        leaveTimestepFraction = fmod(leaveTimestep * 1000., 1000.) / (SUMOReal) DELTA_T;
        if (values.hadUpdate) {
            SUMOReal speedFraction = (veh.getSpeed() * leaveTimestepFraction);
            values.speedSum += speedFraction / (1000. / (SUMOReal) DELTA_T);
            values.intervalSpeedSum += speedFraction / (1000. / (SUMOReal) DELTA_T);
            if (veh.getSpeed() < myHaltingSpeedThreshold && values.haltingBegin != -1 && leaveTimestep - values.haltingBegin > myHaltingTimeThreshold) {
                values.haltings++;
                values.intervalHaltings++;
            }
        } else {
            SUMOReal speedFraction = (veh.getSpeed() * SUMOReal(1. - leaveTimestepFraction));
            values.speedSum -= speedFraction / (1000. / (SUMOReal) DELTA_T);
            values.intervalSpeedSum -= speedFraction / (1000. / (SUMOReal) DELTA_T);
        }
        myEnteredContainer.erase(&veh);
        myLeftContainer[&veh] = values;
    }
}
开发者ID:cathyyul,项目名称:sumo-0.18,代码行数:26,代码来源:MSE3Collector.cpp

示例2: throw

void
MSE3Collector::leave(SUMOVehicle& veh, SUMOReal leaveTimestep) throw() {
    if (myEnteredContainer.find(&veh)==myEnteredContainer.end()) {
        MsgHandler::getWarningInstance()->inform("Vehicle '" + veh.getID() + "' left E3-detector '" + getID() + "' before entering it.");
    } else {
        E3Values values = myEnteredContainer[&veh];
        values.leaveTime = leaveTimestep;
        SUMOReal leaveTimestepFraction = leaveTimestep - (SUMOReal)((int) leaveTimestep);
        leaveTimestepFraction = fmod(leaveTimestep * 1000., 1000.) / (SUMOReal) DELTA_T;
        if (values.hadUpdate) {
            SUMOReal speedFraction = (veh.getSpeed() * leaveTimestepFraction);
            values.speedSum += speedFraction / (1000. / (SUMOReal) DELTA_T);
            values.intervalSpeedSum += speedFraction / (1000. / (SUMOReal) DELTA_T);
            if (veh.getSpeed() < myHaltingSpeedThreshold && values.haltingBegin!=-1 && leaveTimestep-values.haltingBegin>myHaltingTimeThreshold) {
                values.haltings++;
                values.intervalHaltings++;
            }
        } else {
            SUMOReal speedFraction = (veh.getSpeed() * SUMOReal(1. - leaveTimestepFraction));
            values.speedSum -= speedFraction / (1000. / (SUMOReal) DELTA_T);
            values.intervalSpeedSum -= speedFraction / (1000. / (SUMOReal) DELTA_T);
        }
        myEnteredContainer.erase(&veh);
        myLeftContainer[&veh] = values;
    }
}
开发者ID:NeziheSozen,项目名称:sumo,代码行数:26,代码来源:MSE3Collector.cpp

示例3: toString

void
MSE3Collector::enter(const SUMOVehicle& veh, const double entryTimestep, const double fractionTimeOnDet) {
    if (!vehicleApplies(veh)) {
        return;
    }
    if (myEnteredContainer.find(&veh) != myEnteredContainer.end()) {
        WRITE_WARNING("Vehicle '" + veh.getID() + "' reentered " + toString(SUMO_TAG_E3DETECTOR) + " '" + getID() + "'.");
        return;
    }
    const double speedFraction = veh.getSpeed() * fractionTimeOnDet;
    E3Values v;
    v.entryTime = entryTimestep;
    v.frontLeaveTime = 0;
    v.backLeaveTime = 0;
    v.speedSum = speedFraction;
    v.haltingBegin = veh.getSpeed() < myHaltingSpeedThreshold ? entryTimestep : -1;
    v.intervalSpeedSum = entryTimestep >= STEPS2TIME(myLastResetTime) ? speedFraction : 0;
    v.haltings = 0;
    v.intervalHaltings = 0;
    if (veh.getSpeed() < myHaltingSpeedThreshold) {
        if (fractionTimeOnDet > myHaltingTimeThreshold) {
            v.haltings++;
            v.intervalHaltings++;
        }
    }
    v.hadUpdate = false;
    if (!MSGlobals::gUseMesoSim) {
        v.timeLoss = static_cast<const MSVehicle&>(veh).getTimeLoss();
        v.intervalTimeLoss = v.timeLoss;
    }
    myEnteredContainer[&veh] = v;
}
开发者ID:fieryzig,项目名称:sumo,代码行数:32,代码来源:MSE3Collector.cpp

示例4:

bool
MSDevice_Person::notifyMove(SUMOVehicle& veh, SUMOReal /*oldPos*/, SUMOReal /*newPos*/, SUMOReal /*newSpeed*/) {
    if (myStopped) {
        if (!veh.isStopped()) {
            for (std::vector<MSTransportable*>::iterator i = myPersons.begin(); i != myPersons.end(); ++i) {
                (*i)->setDeparted(MSNet::getInstance()->getCurrentTimeStep());
            }
            myStopped = false;
        }
    } else {
        if (veh.isStopped()) {
            for (std::vector<MSTransportable*>::iterator i = myPersons.begin(); i != myPersons.end();) {
                MSTransportable* person = *i;
                if (&(person->getDestination()) == veh.getEdge()) {
                    if (!person->proceed(MSNet::getInstance(), MSNet::getInstance()->getCurrentTimeStep())) {
                        MSNet::getInstance()->getPersonControl().erase(person);
                    }
                    i = myPersons.erase(i);
                } else {
                    ++i;
                }
            }
            myStopped = true;
        }
    }
    return true;
}
开发者ID:aarongolliver,项目名称:sumo,代码行数:27,代码来源:MSDevice_Person.cpp

示例5:

void
MSMeanData_Amitran::MSLaneMeanDataValues::notifyMoveInternal(SUMOVehicle& veh, SUMOReal timeOnLane, SUMOReal speed) {
    sampleSeconds += timeOnLane;
    travelledDistance += speed * timeOnLane;
    typedSamples[&veh.getVehicleType()] += timeOnLane;
    typedTravelDistance[&veh.getVehicleType()] += speed * timeOnLane;
}
开发者ID:aarongolliver,项目名称:sumo,代码行数:7,代码来源:MSMeanData_Amitran.cpp

示例6: throw

bool
MSMsgInductLoop::isStillActive(SUMOVehicle& veh, SUMOReal oldPos,
                               SUMOReal newPos, SUMOReal newSpeed) throw() {
    if (newPos < myPosition) {
        // detector not reached yet
        return true;
    }
    if (myVehiclesOnDet.find(&veh) == myVehiclesOnDet.end()) {
        // entered the detector by move
        SUMOReal entryTimestep = (SUMOReal)
                                 ((SUMOReal) MSNet::getInstance()->getCurrentTimeStep() + ((myPosition - oldPos) / newSpeed));
        if (newPos - veh.getVehicleType().getLength() > myPosition) {
            // entered and passed detector in a single timestep
            SUMOReal leaveTimestep = (SUMOReal)
                                     ((SUMOReal) MSNet::getInstance()->getCurrentTimeStep() + ((myPosition - oldPos + veh.getVehicleType().getLength()) / newSpeed));
            enterDetectorByMove(veh, entryTimestep);
            leaveDetectorByMove(veh, leaveTimestep);
            return false;
        }
        // entered detector, but not passed
        enterDetectorByMove(veh, entryTimestep);
        return true;
    } else {
        // vehicle has been on the detector the previous timestep
        if (newPos - veh.getVehicleType().getLength() >= myPosition) {
            // vehicle passed the detector
            SUMOReal leaveTimestep = (SUMOReal)
                                     ((SUMOReal) MSNet::getInstance()->getCurrentTimeStep() + ((myPosition - oldPos + veh.getVehicleType().getLength()) / newSpeed));
            leaveDetectorByMove(veh, leaveTimestep);
            return false;
        }
        // vehicle stays on the detector
        return true;
    }
}
开发者ID:NeziheSozen,项目名称:sumo,代码行数:35,代码来源:MSMsgInductLoop.cpp

示例7: enterDetectorByMove

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;
}
开发者ID:namnatulco,项目名称:sumo-complete,代码行数:27,代码来源:MSInductLoop.cpp

示例8: assert

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;
}
开发者ID:fieryzig,项目名称:sumo,代码行数:27,代码来源:MSE3Collector.cpp

示例9:

bool
MSDevice_Container::notifyMove(SUMOVehicle& veh, SUMOReal /*oldPos*/, SUMOReal /*newPos*/, SUMOReal /*newSpeed*/) {
    if (myStopped) {
        // if veh is not anymore at the stop
        if (!veh.isStopped()) {
            for (std::vector<MSTransportable*>::iterator i = myContainers.begin(); i != myContainers.end(); ++i) {
                (*i)->setDeparted(MSNet::getInstance()->getCurrentTimeStep());
            }
            myStopped = false;
        }
    } else {
        if (veh.isStopped()) {
            for (std::vector<MSTransportable*>::iterator i = myContainers.begin(); i != myContainers.end();) {
                MSTransportable* container = *i;
                if (&(container->getDestination()) == veh.getEdge()) {
                    if (!container->proceed(MSNet::getInstance(), MSNet::getInstance()->getCurrentTimeStep())) {
                        MSNet::getInstance()->getContainerControl().erase(container);
                    }
                    i = myContainers.erase(i);
                } else {
                    ++i;
                }
            }
            myStopped = true;
        }
    }
    return true;
}
开发者ID:aarongolliver,项目名称:sumo,代码行数:28,代码来源:MSDevice_Container.cpp

示例10:

void
MSPerson::MSPersonStage_Driving::proceed(MSNet* net, MSTransportable* person, SUMOTime now, Stage* previous) {
    if (previous->getDestinationStop() != 0) {
        // the arrival stop may have an access point
        myWaitingEdge = &previous->getDestinationStop()->getLane().getEdge();
        myStopWaitPos = previous->getDestinationStop()->getWaitPosition();
    } else {
        myWaitingEdge = previous->getEdge();
        myStopWaitPos = Position::INVALID;
    }
    myWaitingPos = previous->getEdgePos(now);
    myWaitingSince = now;
    SUMOVehicle* availableVehicle = net->getVehicleControl().getWaitingVehicle(myWaitingEdge, myLines, myWaitingPos, person->getID());
    if (availableVehicle != 0 && availableVehicle->getParameter().departProcedure == DEPART_TRIGGERED) {
        myVehicle = availableVehicle;
        myWaitingEdge->removePerson(person);
        myVehicle->addPerson(person);
        net->getInsertionControl().add(myVehicle);
        net->getVehicleControl().removeWaiting(myWaitingEdge, myVehicle);
        net->getVehicleControl().unregisterOneWaitingForPerson();
    } else {
        net->getPersonControl().addWaiting(myWaitingEdge, person);
        myWaitingEdge->addPerson(person);
    }
}
开发者ID:kbleeck,项目名称:customSumo26,代码行数:25,代码来源:MSPerson.cpp

示例11:

bool
MSRouteProbe::notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason) {
    if (myCurrentRouteDistribution != 0 && reason != MSMoveReminder::NOTIFICATION_SEGMENT && reason != MSMoveReminder::NOTIFICATION_LANE_CHANGE) {
        veh.getRoute().addReference();
        myCurrentRouteDistribution->add(1., &veh.getRoute());
    }
    return false;
}
开发者ID:rudhir-upretee,项目名称:Sumo17_With_Netsim,代码行数:8,代码来源:MSRouteProbe.cpp

示例12: STEPFLOOR

void
MSVehicleControl::vehicleDeparted(const SUMOVehicle& v) {
    ++myRunningVehNo;
    myTotalDepartureDelay += STEPS2TIME(v.getDeparture() - STEPFLOOR(v.getParameter().depart));
    MSNet::getInstance()->informVehicleStateListener(&v, MSNet::VEHICLE_STATE_DEPARTED);
    myMaxSpeedFactor = MAX2(myMaxSpeedFactor, v.getChosenSpeedFactor());
    myMinDeceleration = MIN2(myMinDeceleration, v.getVehicleType().getCarFollowModel().getMaxDecel());
}
开发者ID:cbrafter,项目名称:sumo,代码行数:8,代码来源:MSVehicleControl.cpp

示例13: pow

void
MSMeanData_Harmonoise::MSLaneMeanDataValues::notifyMoveInternal(SUMOVehicle& veh, SUMOReal timeOnLane, SUMOReal speed) {
    const SUMOReal sn = HelpersHarmonoise::computeNoise(veh.getVehicleType().getEmissionClass(),
                        (double) speed, veh.getAcceleration());
    currentTimeN += (SUMOReal) pow(10., (sn / 10.));
    sampleSeconds += timeOnLane;
    travelledDistance += speed * timeOnLane;
}
开发者ID:harora,项目名称:ITS,代码行数:8,代码来源:MSMeanData_Harmonoise.cpp

示例14: vehicleDeparted

void MSVehicleControl::vehicleDeparted(const SUMOVehicle& v)
{
    ++myRunningVehNo;
    myTotalDepartureDelay += STEPS2TIME(v.getDeparture() -
     STEPFLOOR(v.getParameter().depart));
    MSNet::getInstance()->informVehicleStateListener(&v,
     MSNet::VEHICLE_STATE_DEPARTED);
}
开发者ID:smendez-hi,项目名称:SUMO-hib,代码行数:8,代码来源:MSVehicleControl.cpp

示例15: throw

void
MSE2Collector::notifyLeave(SUMOVehicle& veh, bool isArrival, bool isLaneChange) throw() {
    if (isArrival || isLaneChange || (veh.getPositionOnLane() >= myStartPos && veh.getPositionOnLane() - veh.getVehicleType().getLength() < myEndPos)) {
        std::list<SUMOVehicle*>::iterator i = find(myKnownVehicles.begin(), myKnownVehicles.end(), &veh);
        if (i!=myKnownVehicles.end()) {
            myKnownVehicles.erase(i);
        }
    }
}
开发者ID:NeziheSozen,项目名称:sumo,代码行数:9,代码来源:MSE2Collector.cpp


注:本文中的SUMOVehicle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。