SUMOReal GUILane::getColorValue(size_t activeScheme) const { switch (activeScheme) { case 1: return gSelected.isSelected(getType(), getGlID()) || gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID()); case 2: return (SUMOReal)myPermissions; case 3: return getSpeedLimit(); case 4: return getBruttoOccupancy(); case 5: return getNettoOccupancy(); case 6: return firstWaitingTime(); case 7: return getEdgeLaneNumber(); case 8: return getCO2Emissions() / myLength; case 9: return getCOEmissions() / myLength; case 10: return getPMxEmissions() / myLength; case 11: return getNOxEmissions() / myLength; case 12: return getHCEmissions() / myLength; case 13: return getFuelConsumption() / myLength; case 14: return getHarmonoise_NoiseEmissions(); case 15: { return getStoredEdgeTravelTime(); } case 16: { MSEdgeWeightsStorage& ews = MSNet::getInstance()->getWeightsStorage(); if (!ews.knowsTravelTime(myEdge)) { return -1; } else { SUMOReal value(0); ews.retrieveExistingTravelTime(myEdge, 0, value); return 100 * myLength / value / getSpeedLimit(); } } case 17: { return 1 / myLengthGeometryFactor; } } return 0; }
SUMOReal MSEdge::getMeanSpeed() const { SUMOReal v = 0; SUMOReal no = 0; if (MSGlobals::gUseMesoSim) { for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) { const SUMOReal vehNo = (SUMOReal) segment->getCarNumber(); v += vehNo * segment->getMeanSpeed(); no += vehNo; } if (no == 0) { return getLength() / myEmptyTraveltime; // may include tls-penalty } } else { for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) { const SUMOReal vehNo = (SUMOReal)(*i)->getVehicleNumber(); v += vehNo * (*i)->getMeanSpeed(); no += vehNo; } if (no == 0) { return getSpeedLimit(); } } return v / no; }
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); } } }
void sendByteAndReceiveByte(void) { if(getStopwatch1() > 500) { I2CTWI_transmitByte(ARDUINO_WRITE_ADDRESS, speed); //writing the speed of rp6 uint8_t someByteToRead = 0; someByteToRead = I2CTWI_readByte(ARDUINO_READ_ADDRESS); //read the maximum speed writeInteger(someByteToRead, DEC); getSpeedLimit(someByteToRead); setStopwatch1(0); } }
SUMOReal GUIEdge::getMeanSpeed() const { SUMOReal v = 0; SUMOReal no = 0; for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) { SUMOReal vehNo = (SUMOReal) segment->getCarNumber(); v += vehNo * segment->getMeanSpeed(); no += vehNo; } if (no == 0) { return getSpeedLimit(); } return v / no; }
GUIParameterTableWindow* GUILane::getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView&) { GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 5); // add items ret->mkItem("maxspeed [m/s]", false, getSpeedLimit()); ret->mkItem("length [m]", false, myLength); ret->mkItem("street name", false, myEdge->getStreetName()); ret->mkItem("stored traveltime [s]", true, new FunctionBinding<GUILane, SUMOReal>(this, &GUILane::getStoredEdgeTravelTime)); ret->mkItem("allowed vehicle class", false, getVehicleClassNames(myPermissions)); ret->mkItem("disallowed vehicle class", false, getVehicleClassNames(~myPermissions)); // close building ret->closeBuilding(); return ret; }
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)); }
void MSEdge::recalcCache() { myLength = myLanes->front()->getLength(); myEmptyTraveltime = myLength / MAX2(getSpeedLimit(), NUMERICAL_EPS); }