42 const std::string
id = inputStorage.
readString();
45 if (!libsumo::TrafficLight::handleVariable(
id, variable, &server, &inputStorage)) {
48 std::vector<libsumo::TraCILogic> logics = libsumo::TrafficLight::getAllProgramLogics(
id);
57 for (
const std::shared_ptr<libsumo::TraCIPhase>& phase : logic.phases) {
64 for (
int n : phase->next) {
70 for (
const auto& item : logic.subParameter) {
77 const std::vector<std::vector<libsumo::TraCILink> > links = libsumo::TrafficLight::getControlledLinks(
id);
81 tempContent.
writeInt((
int)links.size());
83 for (
const std::vector<libsumo::TraCILink>& sublinks : links) {
85 tempContent.
writeInt((
int)sublinks.size());
89 tempContent.
writeStringList(std::vector<std::string>({ link.fromLane, link.toLane, link.viaLane }));
138 std::vector<libsumo::TraCISignalConstraint> constraints = libsumo::TrafficLight::getConstraints(
id, tripId);
140 const int cnt = 1 + (int)constraints.size() * 5;
144 for (
const auto& c : constraints) {
154 std::vector<libsumo::TraCISignalConstraint> constraints = libsumo::TrafficLight::getConstraintsByFoe(
id, foeId);
156 const int cnt = 1 + (int)constraints.size() * 5;
160 for (
const auto& c : constraints) {
175 std::string foeSignal;
183 std::vector<libsumo::TraCISignalConstraint> constraints = libsumo::TrafficLight::swapConstraints(
id, tripId, foeSignal, foeId);
185 const int cnt = 1 + (int)constraints.size() * 5;
189 for (
const auto& c : constraints) {
202 for (Parameterised::Map::const_iterator i = params.begin(); i != params.end(); ++i) {
203 if (
"connection:" == (*i).first.substr(0, 11)) {
211 for (Parameterised::Map::const_iterator i = params.begin(); i != params.end(); ++i) {
212 if (
"connection:" != (*i).first.substr(0, 11)) {
217 std::string connection = (*i).first.substr(11);
218 std::string from, to;
219 const std::string::size_type b = connection.find(
"->");
220 if (b == std::string::npos) {
223 from = connection.substr(0, b);
224 to = connection.substr(b + 2);
226 bool denotesEdge = from.find(
"_") == std::string::npos;
227 MSLane* fromLane =
nullptr;
229 MSTrafficLightLogic::LaneVectorVector::const_iterator j = lanes.begin();
230 for (; j != lanes.end() && fromLane ==
nullptr;) {
231 for (MSTrafficLightLogic::LaneVector::const_iterator k = (*j).begin(); k != (*j).end() && fromLane ==
nullptr;) {
232 if (denotesEdge && (*k)->getEdge().getID() == from) {
234 }
else if (!denotesEdge && (*k)->getID() == from) {
237 if (fromLane ==
nullptr) {
241 if (fromLane ==
nullptr) {
245 if (fromLane ==
nullptr) {
248 int pos = (int)std::distance(lanes.begin(), j);
270 std::string warning =
"";
282 const std::string
id = inputStorage.
readString();
290 libsumo::TrafficLight::setPhase(
id, index);
298 libsumo::TrafficLight::setPhaseName(
id, name);
306 libsumo::TrafficLight::setProgram(
id, subID);
310 double duration = 0.;
314 libsumo::TrafficLight::setPhaseDuration(
id, duration);
322 libsumo::TrafficLight::setRedYellowGreenState(
id, state);
344 const int numPhases = inputStorage.
readInt();
345 for (
int j = 0; j < numPhases; ++j) {
349 const int items = inputStorage.
readInt();
350 if (items != 6 && items != 5) {
353 double duration = 0., minDuration = 0., maxDuration = 0.;
354 std::vector<int> next;
372 const int numNext = inputStorage.
readInt();
373 for (
int k = 0; k < numNext; k++) {
378 next.push_back(nextEntry);
390 const int numParams = inputStorage.
readInt();
391 for (
int j = 0; j < numParams; j++) {
392 std::vector<std::string> par;
396 libsumo::TrafficLight::setCompleteRedYellowGreenDefinition(
id, logic);
409 std::string foeSignal;
417 libsumo::TrafficLight::removeConstraints(
id, tripId, foeSignal, foeId);
425 libsumo::TrafficLight::updateConstraints(
id, tripId);
438 std::string foeSignal;
454 libsumo::TrafficLight::addConstraint(
id, tripId, foeSignal, foeId, type, limit);
471 libsumo::TrafficLight::setParameter(
id, name, value);
495 std::vector<std::string> paramItems;
496 for (
auto item : c.
param) {
497 paramItems.push_back(item.first);
498 paramItems.push_back(item.second);
std::string toHex(const T i, std::streamsize numDigits=0)
Representation of a lane in the micro simulation.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
const std::string & getState() const
Returns the state within this phase.
MSTrafficLightLogic * getActive() const
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
The parent class for traffic light logics.
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
const LaneVectorVector & getLaneVectors() const
Returns the list of lists of all lanes controlled by this tls.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa2: Get Traffic Lights Variable)
static void writeConstraint(TraCIServer &server, const libsumo::TraCISignalConstraint &c)
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc2: Change Traffic Lights State)
TraCI server used to control sumo by a remote TraCI client.
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
tcpip::Storage & getWrapperStorage()
void initWrapper(const int domainID, const int variable, const std::string &objID)
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
static void writeTypedDouble(tcpip::Storage &content, double value)
static void writeCompound(tcpip::Storage &content, int size)
static void writeTypedInt(tcpip::Storage &content, int value)
static void writeTypedStringList(tcpip::Storage &content, const std::vector< std::string > &value)
static void writeTypedByte(tcpip::Storage &content, int value)
static void writeTypedString(tcpip::Storage &content, const std::string &value)
An error which allows to continue.
std::map< std::string, std::string > subParameter
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
virtual std::string readString()
virtual void writeString(const std::string &s)
virtual void writeInt(int)
virtual int readUnsignedByte()
virtual void writeStringList(const std::vector< std::string > &s)
virtual void writeUnsignedByte(int)
StorageType::size_type size() const
virtual void writeStorage(tcpip::Storage &store)
TRACI_CONST int CMD_GET_TL_VARIABLE
TRACI_CONST int TL_CONSTRAINT_REMOVE
TRACI_CONST int TL_BLOCKING_VEHICLES
TRACI_CONST int TL_CONSTRAINT_SWAP
TRACI_CONST int TL_PRIORITY_VEHICLES
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int TL_COMPLETE_DEFINITION_RYG
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int TL_CONSTRAINT_UPDATE
TRACI_CONST int TL_EXTERNAL_STATE
TRACI_CONST int TYPE_STRINGLIST
TRACI_CONST int TL_CONTROLLED_LINKS
TRACI_CONST int TYPE_INTEGER
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int TL_CONSTRAINT_BYFOE
TRACI_CONST int TL_CONSTRAINT
TRACI_CONST int TL_PROGRAM
TRACI_CONST int RESPONSE_GET_TL_VARIABLE
TRACI_CONST int TL_PHASE_DURATION
TRACI_CONST int TL_CONSTRAINT_ADD
TRACI_CONST int TL_PHASE_INDEX
TRACI_CONST int TL_COMPLETE_PROGRAM_RYG
TRACI_CONST int CMD_SET_TL_VARIABLE
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
TRACI_CONST int TYPE_STRING
TRACI_CONST int TL_RIVAL_VEHICLES
std::string foeId
the tripId or vehicle id of the train that must pass first
std::string tripId
the tripId or vehicle id of the train that is constrained
std::string foeSignal
the tlsID of the rail signla that the foe must pass first
std::string signalId
the idea of the rail signal where this constraint is active
std::map< std::string, std::string > param
additional parameters
bool active
whether this constraint is active
int type
the type of constraint (predecessor:0, insertionPredecessor:1)
bool mustWait
whether tripId must still wait for foeId to pass foeSignal
int limit
the number of trains that must be recorded at the foeSignal