Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4 : // This program and the accompanying materials are made available under the
5 : // terms of the Eclipse Public License 2.0 which is available at
6 : // https://www.eclipse.org/legal/epl-2.0/
7 : // This Source Code may also be made available under the following Secondary
8 : // Licenses when the conditions for such availability set forth in the Eclipse
9 : // Public License 2.0 are satisfied: GNU General Public License, version 2
10 : // or later which is available at
11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 : /****************************************************************************/
14 : /// @file StorageHelper.h
15 : /// @author Michael Behrisch
16 : /// @date 2020-12-17
17 : ///
18 : // Functions for reading, writing and converting TraCIResults to tcpip::Storage
19 : /****************************************************************************/
20 : #pragma once
21 : #include <config.h>
22 : #include <foreign/tcpip/storage.h>
23 : #include <libsumo/TraCIDefs.h>
24 : #include <utils/common/ToString.h>
25 :
26 :
27 : // ===========================================================================
28 : // class definitions
29 : // ===========================================================================
30 : namespace libsumo {
31 :
32 : class StorageHelper {
33 : public:
34 255 : static inline std::shared_ptr<tcpip::Storage> toStorage(const TraCIResult& v) {
35 : std::shared_ptr<tcpip::Storage> result = std::make_shared<tcpip::Storage>();
36 255 : if (v.getType() == POSITION_ROADMAP || v.getType() == POSITION_2D || v.getType() == POSITION_3D) {
37 : writeCompound(*result, 2);
38 : }
39 255 : if (v.getType() != -1) {
40 243 : result->writeUnsignedByte(v.getType());
41 : }
42 255 : switch (v.getType()) {
43 : case TYPE_STRING:
44 140 : result->writeString(v.getString());
45 140 : break;
46 : case TYPE_DOUBLE:
47 71 : result->writeDouble(((const TraCIDouble&)v).value);
48 : break;
49 : case TYPE_INTEGER:
50 20 : result->writeInt(((const TraCIInt&)v).value);
51 : break;
52 : case TYPE_BYTE:
53 2 : result->writeByte(((const TraCIInt&)v).value);
54 : break;
55 : case TYPE_UBYTE:
56 2 : result->writeUnsignedByte(((const TraCIInt&)v).value);
57 : break;
58 : case POSITION_ROADMAP:
59 4 : result->writeString(((const TraCIRoadPosition&)v).edgeID);
60 4 : result->writeDouble(((const TraCIRoadPosition&)v).pos);
61 4 : result->writeUnsignedByte(((const TraCIRoadPosition&)v).laneIndex);
62 : break;
63 : case POSITION_2D:
64 4 : result->writeDouble(((const TraCIPosition&)v).x);
65 4 : result->writeDouble(((const TraCIPosition&)v).y);
66 : break;
67 : case POSITION_3D:
68 0 : result->writeDouble(((const TraCIPosition&)v).x);
69 0 : result->writeDouble(((const TraCIPosition&)v).y);
70 0 : result->writeDouble(((const TraCIPosition&)v).z);
71 : break;
72 12 : case -1: {
73 : // a hack for transfering multiple values
74 : const auto& pl = ((const TraCIStringDoublePairList&)v).value;
75 12 : const bool tisb = pl.size() == 2 && pl[0].first != "";
76 12 : writeCompound(*result, pl.size() == 2 && !tisb ? 2 : (int)pl.size() + 1);
77 12 : if (pl.size() == 1) {
78 4 : writeTypedDouble(*result, pl.front().second);
79 4 : writeTypedString(*result, pl.front().first);
80 8 : } else if (pl.size() == 2) {
81 4 : if (tisb) {
82 2 : writeTypedInt(*result, (int)(pl.front().second + 0.5));
83 2 : writeTypedString(*result, pl.front().first);
84 2 : writeTypedByte(*result, (int)(pl.back().second + 0.5));
85 : } else {
86 2 : writeTypedDouble(*result, pl.front().second);
87 2 : writeTypedDouble(*result, pl.back().second);
88 : }
89 4 : } else if (pl.size() == 3) {
90 2 : writeTypedDouble(*result, pl[0].second);
91 2 : writeTypedDouble(*result, pl[1].second);
92 2 : writeTypedDouble(*result, pl[2].second);
93 2 : writeTypedString(*result, pl[2].first);
94 2 : } else if (pl.size() == 4) {
95 2 : writeTypedDouble(*result, pl[0].second);
96 2 : writeTypedDouble(*result, pl[1].second);
97 2 : writeTypedDouble(*result, pl[2].second);
98 2 : writeTypedDouble(*result, pl[3].second);
99 2 : writeTypedString(*result, pl[3].first);
100 : }
101 : break;
102 : }
103 0 : default:
104 0 : throw TraCIException("Unknown type " + toHex(v.getType()));
105 : }
106 255 : if (v.getType() == POSITION_ROADMAP || v.getType() == POSITION_2D || v.getType() == POSITION_3D) {
107 8 : result->writeUnsignedByte(REQUEST_DRIVINGDIST);
108 : }
109 255 : return result;
110 : }
111 :
112 112815 : static inline int readTypedInt(tcpip::Storage& ret, const std::string& error = "") {
113 112815 : if (ret.readUnsignedByte() != libsumo::TYPE_INTEGER && error != "") {
114 8 : throw TraCIException(error);
115 : }
116 112811 : return ret.readInt();
117 : }
118 :
119 103297 : static inline int readTypedByte(tcpip::Storage& ret, const std::string& error = "") {
120 103297 : if (ret.readUnsignedByte() != libsumo::TYPE_BYTE && error != "") {
121 0 : throw TraCIException(error);
122 : }
123 103297 : return ret.readByte();
124 : }
125 :
126 344 : static inline int readTypedUnsignedByte(tcpip::Storage& ret, const std::string& error = "") {
127 344 : if (ret.readUnsignedByte() != libsumo::TYPE_UBYTE && error != "") {
128 0 : throw TraCIException(error);
129 : }
130 344 : return ret.readUnsignedByte();
131 : }
132 :
133 293575 : static inline double readTypedDouble(tcpip::Storage& ret, const std::string& error = "") {
134 293575 : if (ret.readUnsignedByte() != libsumo::TYPE_DOUBLE && error != "") {
135 10 : throw TraCIException(error);
136 : }
137 293570 : return ret.readDouble();
138 : }
139 :
140 210 : static inline std::vector<double> readTypedDoubleList(tcpip::Storage& ret, const std::string& error = "") {
141 210 : if (ret.readUnsignedByte() != libsumo::TYPE_DOUBLELIST && error != "") {
142 0 : throw TraCIException(error);
143 : }
144 210 : return ret.readDoubleList();
145 : }
146 :
147 357034 : static inline std::string readTypedString(tcpip::Storage& ret, const std::string& error = "") {
148 357034 : if (ret.readUnsignedByte() != libsumo::TYPE_STRING && error != "") {
149 6 : throw TraCIException(error);
150 : }
151 357031 : return ret.readString();
152 : }
153 :
154 2837 : static inline std::vector<std::string> readTypedStringList(tcpip::Storage& ret, const std::string& error = "") {
155 2837 : if (ret.readUnsignedByte() != libsumo::TYPE_STRINGLIST && error != "") {
156 4 : throw TraCIException(error);
157 : }
158 2834 : return ret.readStringList();
159 : }
160 :
161 324 : static inline const libsumo::TraCIColor readTypedColor(tcpip::Storage& ret, const std::string& error = "") {
162 324 : if (ret.readUnsignedByte() != libsumo::TYPE_COLOR && error != "") {
163 4 : throw TraCIException(error);
164 : }
165 : libsumo::TraCIColor into;
166 322 : into.r = static_cast<unsigned char>(ret.readUnsignedByte());
167 322 : into.g = static_cast<unsigned char>(ret.readUnsignedByte());
168 322 : into.b = static_cast<unsigned char>(ret.readUnsignedByte());
169 322 : into.a = static_cast<unsigned char>(ret.readUnsignedByte());
170 322 : return into;
171 : }
172 :
173 119 : static inline const libsumo::TraCIPosition readTypedPosition2D(tcpip::Storage& ret, const std::string& error = "") {
174 119 : if (ret.readUnsignedByte() != libsumo::POSITION_2D && error != "") {
175 2 : throw TraCIException(error);
176 : }
177 118 : libsumo::TraCIPosition p;
178 118 : p.x = ret.readDouble();
179 118 : p.y = ret.readDouble();
180 118 : return p;
181 : }
182 :
183 108 : static inline const libsumo::TraCIPositionVector readTypedPolygon(tcpip::Storage& ret, const std::string& error = "") {
184 108 : if (ret.readUnsignedByte() != libsumo::TYPE_POLYGON && error != "") {
185 2 : throw TraCIException(error);
186 : }
187 : libsumo::TraCIPositionVector poly;
188 107 : readPolygon(ret, poly);
189 107 : return poly;
190 : }
191 :
192 84125 : static inline int readCompound(tcpip::Storage& ret, int expectedSize = -1, const std::string& error = "") {
193 84125 : const int type = ret.readUnsignedByte();
194 84119 : const int size = ret.readInt();
195 84119 : if (error != "") {
196 81047 : if (type != libsumo::TYPE_COMPOUND || (expectedSize != -1 && size != expectedSize)) {
197 0 : throw TraCIException(error);
198 : }
199 : }
200 84119 : return size;
201 : }
202 :
203 6151 : static inline void readPolygon(tcpip::Storage& ret, libsumo::TraCIPositionVector& poly) {
204 6151 : int size = ret.readUnsignedByte();
205 6151 : if (size == 0) {
206 4 : size = ret.readInt();
207 : }
208 22469 : for (int i = 0; i < size; ++i) {
209 16318 : libsumo::TraCIPosition p;
210 16318 : p.x = ret.readDouble();
211 16318 : p.y = ret.readDouble();
212 16318 : p.z = 0.;
213 16318 : poly.value.emplace_back(p);
214 : }
215 6151 : }
216 :
217 515 : static inline bool readBool(tcpip::Storage& ret, const std::string& error = "") {
218 515 : if (ret.readUnsignedByte() != libsumo::TYPE_UBYTE && error != "") {
219 0 : throw TraCIException(error);
220 : }
221 515 : return ret.readUnsignedByte() != 0;
222 : }
223 :
224 30 : static inline void readStage(tcpip::Storage& inputStorage, libsumo::TraCIStage& stage, const std::string& error = "") {
225 30 : stage.type = readTypedInt(inputStorage, error);
226 30 : stage.vType = readTypedString(inputStorage, error);
227 30 : stage.line = readTypedString(inputStorage, error);
228 30 : stage.destStop = readTypedString(inputStorage, error);
229 30 : stage.edges = readTypedStringList(inputStorage, error);
230 30 : stage.travelTime = readTypedDouble(inputStorage, error);
231 30 : stage.cost = readTypedDouble(inputStorage, error);
232 30 : stage.length = readTypedDouble(inputStorage, error);
233 30 : stage.intended = readTypedString(inputStorage, error);
234 30 : stage.depart = readTypedDouble(inputStorage, error);
235 30 : stage.departPos = readTypedDouble(inputStorage, error);
236 30 : stage.arrivalPos = readTypedDouble(inputStorage, error);
237 30 : stage.description = readTypedString(inputStorage, error);
238 30 : }
239 :
240 33 : static inline void readConnection(tcpip::Storage& inputStorage, libsumo::TraCIConnection& connection, const std::string& error = "") {
241 33 : connection.approachedLane = readTypedString(inputStorage, error);
242 33 : connection.approachedInternal = readTypedString(inputStorage, error);
243 33 : connection.hasPrio = readBool(inputStorage, error);
244 33 : connection.isOpen = readBool(inputStorage, error);
245 33 : connection.hasFoe = readBool(inputStorage, error);
246 33 : connection.state = readTypedString(inputStorage, error);
247 33 : connection.direction = readTypedString(inputStorage, error);
248 33 : connection.length = readTypedDouble(inputStorage, error);
249 33 : }
250 :
251 17426 : static inline void readVehicleDataVector(tcpip::Storage& inputStorage, std::vector<libsumo::TraCIVehicleData>& result, const std::string& error = "") {
252 17426 : const int n = readTypedInt(inputStorage, error);
253 19564 : for (int i = 0; i < n; ++i) {
254 : libsumo::TraCIVehicleData vd;
255 2138 : vd.id = readTypedString(inputStorage, error);
256 2138 : vd.length = readTypedDouble(inputStorage, error);
257 2138 : vd.entryTime = readTypedDouble(inputStorage, error);
258 2138 : vd.leaveTime = readTypedDouble(inputStorage, error);
259 2138 : vd.typeID = readTypedString(inputStorage, error);
260 2138 : result.emplace_back(vd);
261 : }
262 17426 : }
263 :
264 1535 : static inline void readReservation(tcpip::Storage& inputStorage, libsumo::TraCIReservation& result, const std::string& error = "") {
265 1535 : readCompound(inputStorage, 10, error);
266 1535 : result.id = readTypedString(inputStorage, error);
267 1535 : result.persons = readTypedStringList(inputStorage, error);
268 1535 : result.group = readTypedString(inputStorage, error);
269 1535 : result.fromEdge = readTypedString(inputStorage, error);
270 1535 : result.toEdge = readTypedString(inputStorage, error);
271 1535 : result.departPos = readTypedDouble(inputStorage, error);
272 1535 : result.arrivalPos = readTypedDouble(inputStorage, error);
273 1535 : result.depart = readTypedDouble(inputStorage, error);
274 1535 : result.reservationTime = readTypedDouble(inputStorage, error);
275 1535 : result.state = readTypedInt(inputStorage, error);
276 1535 : }
277 :
278 36 : static inline void readLogic(tcpip::Storage& inputStorage, libsumo::TraCILogic& logic, const std::string& error = "") {
279 36 : readCompound(inputStorage, 5, error);
280 36 : logic.programID = readTypedString(inputStorage);
281 36 : logic.type = readTypedInt(inputStorage);
282 36 : logic.currentPhaseIndex = readTypedInt(inputStorage);
283 36 : int numPhases = readCompound(inputStorage);
284 276 : while (numPhases-- > 0) {
285 240 : readCompound(inputStorage, 6);
286 240 : libsumo::TraCIPhase* phase = new libsumo::TraCIPhase();
287 240 : phase->duration = readTypedDouble(inputStorage);
288 240 : phase->state = readTypedString(inputStorage);
289 240 : phase->minDur = readTypedDouble(inputStorage);
290 240 : phase->maxDur = readTypedDouble(inputStorage);
291 240 : int numNext = readCompound(inputStorage);
292 285 : while (numNext-- > 0) {
293 90 : phase->next.push_back(readTypedInt(inputStorage));
294 : }
295 240 : phase->name = readTypedString(inputStorage);
296 240 : logic.phases.emplace_back(phase);
297 : }
298 36 : int numParams = readCompound(inputStorage);
299 39 : while (numParams-- > 0) {
300 6 : const std::vector<std::string> key_value = readTypedStringList(inputStorage);
301 3 : logic.subParameter[key_value[0]] = key_value[1];
302 3 : }
303 36 : }
304 :
305 253 : static inline void readConstraintVector(tcpip::Storage& inputStorage, std::vector<libsumo::TraCISignalConstraint>& result, const std::string& error = "") {
306 253 : const int n = readTypedInt(inputStorage, error);
307 457 : for (int i = 0; i < n; ++i) {
308 : libsumo::TraCISignalConstraint c;
309 204 : c.signalId = readTypedString(inputStorage);
310 204 : c.tripId = readTypedString(inputStorage);
311 204 : c.foeId = readTypedString(inputStorage);
312 204 : c.foeSignal = readTypedString(inputStorage);
313 204 : c.limit = readTypedInt(inputStorage);
314 204 : c.type = readTypedInt(inputStorage);
315 204 : c.mustWait = readTypedByte(inputStorage) != 0;
316 204 : c.active = readTypedByte(inputStorage) != 0;
317 204 : const std::vector<std::string> paramItems = readTypedStringList(inputStorage);
318 300 : for (int j = 0; j < (int)paramItems.size(); j += 2) {
319 96 : c.param[paramItems[j]] = paramItems[j + 1];
320 : }
321 204 : result.emplace_back(c);
322 204 : }
323 253 : }
324 :
325 11 : static inline void readLinkVectorVector(tcpip::Storage& inputStorage, std::vector< std::vector<libsumo::TraCILink> >& result, const std::string& error = "") {
326 11 : const int n = readTypedInt(inputStorage, error);
327 195 : for (int i = 0; i < n; ++i) {
328 : std::vector<libsumo::TraCILink> controlledLinks;
329 184 : int numLinks = readTypedInt(inputStorage);
330 368 : while (numLinks-- > 0) {
331 368 : std::vector<std::string> link = readTypedStringList(inputStorage);
332 184 : controlledLinks.emplace_back(link[0], link[2], link[1]);
333 184 : }
334 184 : result.emplace_back(controlledLinks);
335 184 : }
336 11 : }
337 :
338 :
339 20 : static inline void readBestLanesVector(tcpip::Storage& inputStorage, std::vector<libsumo::TraCIBestLanesData>& result, const std::string& error = "") {
340 20 : const int n = readTypedInt(inputStorage, error);
341 38 : for (int i = 0; i < n; ++i) {
342 : libsumo::TraCIBestLanesData info;
343 18 : info.laneID = readTypedString(inputStorage);
344 18 : info.length = readTypedDouble(inputStorage);
345 18 : info.occupation = readTypedDouble(inputStorage);
346 18 : info.bestLaneOffset = readTypedUnsignedByte(inputStorage);
347 18 : info.allowsContinuation = readBool(inputStorage);
348 18 : info.continuationLanes = readTypedStringList(inputStorage, error);
349 18 : result.emplace_back(info);
350 : }
351 20 : }
352 :
353 70 : static inline void readCollisionVector(tcpip::Storage& inputStorage, std::vector<libsumo::TraCICollision>& result, const std::string& error = "") {
354 70 : int numCollisions = readTypedInt(inputStorage, error);
355 75 : while (numCollisions-- > 0) {
356 : libsumo::TraCICollision c;
357 5 : c.collider = readTypedString(inputStorage);
358 5 : c.victim = readTypedString(inputStorage);
359 5 : c.colliderType = readTypedString(inputStorage);
360 5 : c.victimType = readTypedString(inputStorage);
361 5 : c.colliderSpeed = readTypedDouble(inputStorage);
362 5 : c.victimSpeed = readTypedDouble(inputStorage);
363 5 : c.type = readTypedString(inputStorage);
364 5 : c.lane = readTypedString(inputStorage);
365 5 : c.pos = readTypedDouble(inputStorage);
366 5 : result.emplace_back(c);
367 5 : }
368 70 : }
369 :
370 32 : static inline void readJunctionFoeVector(tcpip::Storage& inputStorage, std::vector<libsumo::TraCIJunctionFoe>& result, const std::string& error = "") {
371 32 : const int n = readTypedInt(inputStorage, error);
372 77 : for (int i = 0; i < n; ++i) {
373 : libsumo::TraCIJunctionFoe info;
374 45 : info.foeId = readTypedString(inputStorage);
375 45 : info.egoDist = readTypedDouble(inputStorage);
376 45 : info.foeDist = readTypedDouble(inputStorage);
377 45 : info.egoExitDist = readTypedDouble(inputStorage);
378 45 : info.foeExitDist = readTypedDouble(inputStorage);
379 45 : info.egoLane = readTypedString(inputStorage);
380 45 : info.foeLane = readTypedString(inputStorage);
381 45 : info.egoResponse = readBool(inputStorage);
382 45 : info.foeResponse = readBool(inputStorage);
383 45 : result.emplace_back(info);
384 45 : }
385 32 : }
386 :
387 735 : static inline void readStopVector(tcpip::Storage& inputStorage, std::vector<libsumo::TraCINextStopData>& result, const std::string& error = "") {
388 735 : const int n = readTypedInt(inputStorage, error);
389 2353 : for (int i = 0; i < n; ++i) {
390 3236 : libsumo::TraCINextStopData s;
391 1618 : s.lane = readTypedString(inputStorage);
392 1618 : s.endPos = readTypedDouble(inputStorage);
393 1618 : s.stoppingPlaceID = readTypedString(inputStorage);
394 1618 : s.stopFlags = readTypedInt(inputStorage);
395 1618 : s.duration = readTypedDouble(inputStorage);
396 1618 : s.until = readTypedDouble(inputStorage);
397 1618 : s.startPos = readTypedDouble(inputStorage);
398 1618 : s.intendedArrival = readTypedDouble(inputStorage);
399 1618 : s.arrival = readTypedDouble(inputStorage);
400 1618 : s.depart = readTypedDouble(inputStorage);
401 1618 : s.split = readTypedString(inputStorage);
402 1618 : s.join = readTypedString(inputStorage);
403 1618 : s.actType = readTypedString(inputStorage);
404 1618 : s.tripId = readTypedString(inputStorage);
405 1618 : s.line = readTypedString(inputStorage);
406 1618 : s.speed = readTypedDouble(inputStorage);
407 1618 : result.emplace_back(s);
408 1618 : }
409 735 : }
410 :
411 275 : static inline void readTLSDataVector(tcpip::Storage& inputStorage, std::vector<libsumo::TraCINextTLSData>& result, const std::string& error = "") {
412 275 : const int n = readTypedInt(inputStorage, error);
413 626 : for (int i = 0; i < n; ++i) {
414 : libsumo::TraCINextTLSData tls;
415 351 : tls.id = readTypedString(inputStorage);
416 351 : tls.tlIndex = readTypedInt(inputStorage);
417 351 : tls.dist = readTypedDouble(inputStorage);
418 351 : tls.state = (char)readTypedByte(inputStorage);
419 351 : result.emplace_back(tls);
420 : }
421 275 : }
422 :
423 :
424 : static inline void writeTypedByte(tcpip::Storage& content, int value) {
425 4486 : content.writeUnsignedByte(libsumo::TYPE_BYTE);
426 5818 : content.writeByte(value);
427 3712 : }
428 :
429 : static inline void writeTypedUnsignedByte(tcpip::Storage& content, int value) {
430 499 : content.writeUnsignedByte(libsumo::TYPE_UBYTE);
431 499 : content.writeUnsignedByte(value);
432 : }
433 :
434 : static inline void writeTypedInt(tcpip::Storage& content, int value) {
435 117785 : content.writeUnsignedByte(libsumo::TYPE_INTEGER);
436 119117 : content.writeInt(value);
437 23786 : }
438 :
439 : static inline void writeTypedDouble(tcpip::Storage& content, double value) {
440 122853 : content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
441 160677 : content.writeDouble(value);
442 21729 : }
443 :
444 : static inline void writeTypedString(tcpip::Storage& content, const std::string& value) {
445 189433 : content.writeUnsignedByte(libsumo::TYPE_STRING);
446 223572 : content.writeString(value);
447 92648 : }
448 :
449 : static inline void writeTypedStringList(tcpip::Storage& content, const std::vector<std::string>& value) {
450 40876 : content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
451 47180 : content.writeStringList(value);
452 1202 : }
453 :
454 : static inline void writeCompound(tcpip::Storage& content, int size) {
455 86576 : content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
456 92880 : content.writeInt(size);
457 12904 : }
458 :
459 38 : static inline void writePolygon(tcpip::Storage& content, const libsumo::TraCIPositionVector& shape) {
460 38 : content.writeUnsignedByte(libsumo::TYPE_POLYGON);
461 38 : if (shape.value.size() <= 255) {
462 37 : content.writeUnsignedByte((int)shape.value.size());
463 : } else {
464 1 : content.writeUnsignedByte(0);
465 1 : content.writeInt((int)shape.value.size());
466 : }
467 465 : for (const libsumo::TraCIPosition& pos : shape.value) {
468 427 : content.writeDouble(pos.x);
469 427 : content.writeDouble(pos.y);
470 : }
471 38 : }
472 :
473 6304 : static inline void writeStage(tcpip::Storage& content, const libsumo::TraCIStage& stage) {
474 : writeCompound(content, 13);
475 6304 : content.writeUnsignedByte(libsumo::TYPE_INTEGER);
476 6304 : content.writeInt(stage.type);
477 6304 : writeTypedString(content, stage.vType);
478 6304 : writeTypedString(content, stage.line);
479 6304 : writeTypedString(content, stage.destStop);
480 6304 : writeTypedStringList(content, stage.edges);
481 6304 : writeTypedDouble(content, stage.travelTime);
482 6304 : writeTypedDouble(content, stage.cost);
483 6304 : writeTypedDouble(content, stage.length);
484 6304 : writeTypedString(content, stage.intended);
485 6304 : writeTypedDouble(content, stage.depart);
486 6304 : writeTypedDouble(content, stage.departPos);
487 6304 : writeTypedDouble(content, stage.arrivalPos);
488 6304 : writeTypedString(content, stage.description);
489 6304 : }
490 :
491 666 : static inline void writeConstraint(tcpip::Storage& content, const libsumo::TraCISignalConstraint& c) {
492 666 : writeTypedString(content, c.signalId);
493 666 : writeTypedString(content, c.tripId);
494 666 : writeTypedString(content, c.foeId);
495 666 : writeTypedString(content, c.foeSignal);
496 666 : writeTypedInt(content, c.limit);
497 666 : writeTypedInt(content, c.type);
498 666 : writeTypedByte(content, c.mustWait);
499 666 : writeTypedByte(content, c.active);
500 : std::vector<std::string> paramItems;
501 1002 : for (const auto& item : c.param) {
502 336 : paramItems.push_back(item.first);
503 336 : paramItems.push_back(item.second);
504 : }
505 : writeTypedStringList(content, paramItems);
506 666 : }
507 :
508 : };
509 :
510 :
511 : }
512 :
513 : typedef libsumo::StorageHelper StoHelp;
|