41 std::string warning =
"";
53 const std::string
id = inputStorage.
readString();
57 libsumo::TrafficLight::setPhase(
id,
StoHelp::readTypedInt(inputStorage,
"The phase index must be given as an integer."));
61 libsumo::TrafficLight::setPhaseName(
id,
StoHelp::readTypedString(inputStorage,
"The phase name must be given as a string."));
64 libsumo::TrafficLight::setProgram(
id,
StoHelp::readTypedString(inputStorage,
"The program must be given as a string."));
67 libsumo::TrafficLight::setPhaseDuration(
id,
StoHelp::readTypedDouble(inputStorage,
"The phase duration must be given as a double."));
70 libsumo::TrafficLight::setRedYellowGreenState(
id,
StoHelp::readTypedString(inputStorage,
"The phase must be given as a string."));
79 const int numPhases =
StoHelp::readCompound(inputStorage, -1,
"A compound object is needed for the phases.");
80 for (
int j = 0; j < numPhases; ++j) {
81 const int items =
StoHelp::readCompound(inputStorage, -1,
"A compound object is needed for every phase.");
82 if (items != 6 && items != 5) {
85 const double duration =
StoHelp::readTypedDouble(inputStorage,
"set program: 4.1. parameter (duration) must be a double.");
86 const std::string state =
StoHelp::readTypedString(inputStorage,
"set program: 4.2. parameter (phase) must be a string.");
87 const double minDuration =
StoHelp::readTypedDouble(inputStorage,
"set program: 4.3. parameter (min duration) must be a double.");
88 const double maxDuration =
StoHelp::readTypedDouble(inputStorage,
"set program: 4.4. parameter (max duration) must be a double.");
89 const int numNext =
StoHelp::readCompound(inputStorage, -1,
"set program 4.5 parameter (next) must be a compound (list of ints).");
90 std::vector<int> next;
91 for (
int k = 0; k < numNext; ++k) {
92 next.push_back(
StoHelp::readTypedInt(inputStorage,
"set program: 4.5. parameter (next) must be a list of int."));
100 const int numParams =
StoHelp::readCompound(inputStorage, -1,
"set program: 5. parameter (subparams) must be a compound object.");
101 for (
int j = 0; j < numParams; ++j) {
105 libsumo::TrafficLight::setCompleteRedYellowGreenDefinition(
id, logic);
109 StoHelp::readCompound(inputStorage, 3,
"A compound object of size 3 is needed for removing constraints.");
111 const std::string foeSignal =
StoHelp::readTypedString(inputStorage,
"The foeSignal id must be given as a string.");
113 libsumo::TrafficLight::removeConstraints(
id, tripId, foeSignal, foeId);
117 libsumo::TrafficLight::updateConstraints(
id,
StoHelp::readTypedString(inputStorage,
"The tripId index must be given as a string."));
120 StoHelp::readCompound(inputStorage, 5,
"A compound object of size 5 is needed for adding constraints.");
126 libsumo::TrafficLight::addConstraint(
id, tripId, foeSignal, foeId, type, limit);
130 StoHelp::readCompound(inputStorage, 2,
"A compound object of size 2 is needed for setting a parameter.");
131 const std::string name =
StoHelp::readTypedString(inputStorage,
"The name of the parameter must be given as a string.");
133 libsumo::TrafficLight::setParameter(
id, name,
value);
157 std::vector<std::string> paramItems;
158 for (
auto item : c.
param) {
159 paramItems.push_back(item.first);
160 paramItems.push_back(item.second);
const std::string invalid_return< std::string >::value
std::string toHex(const T i, std::streamsize numDigits=0)
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.
tcpip::Storage & getWrapperStorage()
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
static int readCompound(tcpip::Storage &ret, int expectedSize=-1, const std::string &error="")
static std::vector< std::string > readTypedStringList(tcpip::Storage &ret, const std::string &error="")
static int readTypedInt(tcpip::Storage &ret, const std::string &error="")
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
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)
static double readTypedDouble(tcpip::Storage &ret, const std::string &error="")
An error which allows to continue.
virtual std::string readString()
virtual int readUnsignedByte()
TRACI_CONST int TL_CONSTRAINT_REMOVE
TRACI_CONST int TL_CONSTRAINT_UPDATE
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int TL_PROGRAM
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
std::map< std::string, std::string > subParameter
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
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