SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSXMLRawOut.cpp
Go to the documentation of this file.
1 /****************************************************************************/
11 // Realises dumping the complete network state
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
14 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <microsim/MSEdgeControl.h>
36 #include <microsim/MSEdge.h>
37 #include <microsim/MSLane.h>
38 #include <microsim/MSNet.h>
39 #include <microsim/MSVehicle.h>
40 #include <microsim/MSGlobals.h>
42 #include "MSXMLRawOut.h"
43 
44 #ifdef HAVE_INTERNAL
45 #include <mesosim/MELoop.h>
46 #include <mesosim/MESegment.h>
47 #endif
48 
49 #ifdef CHECK_MEMORY_LEAKS
50 #include <foreign/nvwa/debug_new.h>
51 #endif // CHECK_MEMORY_LEAKS
52 
53 
54 // ===========================================================================
55 // method definitions
56 // ===========================================================================
57 void
59  SUMOTime timestep) {
60  of.openTag("timestep") << " time=\"" << time2string(timestep) << "\"";
61  const std::vector<MSEdge*>& edges = ec.getEdges();
62  for (std::vector<MSEdge*>::const_iterator e = edges.begin(); e != edges.end(); ++e) {
63  writeEdge(of, **e);
64  }
65  of.closeTag();
66 }
67 
68 
69 void
71  //en
73  if (!dump) {
74 #ifdef HAVE_INTERNAL
76  MESegment* seg = MSGlobals::gMesoNet->getSegmentForEdge(edge);
77  while (seg != 0) {
78  if (seg->getCarNumber() != 0) {
79  dump = true;
80  break;
81  }
82  seg = seg->getNextSegment();
83  }
84  } else {
85 #endif
86  const std::vector<MSLane*>& lanes = edge.getLanes();
87  for (std::vector<MSLane*>::const_iterator lane = lanes.begin(); lane != lanes.end(); ++lane) {
88  if (((**lane).getVehicleNumber() != 0)) {
89  dump = true;
90  break;
91  }
92  }
93 #ifdef HAVE_INTERNAL
94  }
95 #endif
96  }
97  //en
98  if (dump) {
99  of.openTag("edge") << " id=\"" << edge.getID() << "\"";
100 #ifdef HAVE_INTERNAL
102  MESegment* seg = MSGlobals::gMesoNet->getSegmentForEdge(edge);
103  while (seg != 0) {
104  seg->writeVehicles(of);
105  seg = seg->getNextSegment();
106  }
107  } else {
108 #endif
109  const std::vector<MSLane*>& lanes = edge.getLanes();
110  for (std::vector<MSLane*>::const_iterator lane = lanes.begin(); lane != lanes.end(); ++lane) {
111  writeLane(of, **lane);
112  }
113 #ifdef HAVE_INTERNAL
114  }
115 #endif
116  of.closeTag();
117  }
118 }
119 
120 
121 void
123  of.openTag("lane") << " id=\"" << lane.myID << "\"";
124  if (lane.getVehicleNumber() != 0) {
125  for (std::vector<MSVehicle*>::const_iterator veh = lane.myVehBuffer.begin();
126  veh != lane.myVehBuffer.end(); ++veh) {
127  writeVehicle(of, **veh);
128  }
129  for (MSLane::VehCont::const_iterator veh = lane.myVehicles.begin();
130  veh != lane.myVehicles.end(); ++veh) {
131  writeVehicle(of, **veh);
132  }
133  }
134  of.closeTag();
135 }
136 
137 
138 void
140  if (veh.isOnRoad()) {
141  of.openTag("vehicle") << " id=\"" << veh.getID() << "\" pos=\""
142  << veh.getPositionOnLane() << "\" speed=\"" << veh.getSpeed() << "\"";
143  of.closeTag();
144  }
145 }
146 
147 
148 /****************************************************************************/