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-2012 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 <cassert>
36 #include <microsim/MSEdgeControl.h>
37 #include <microsim/MSEdge.h>
38 #include <microsim/MSLane.h>
39 #include <microsim/MSNet.h>
40 #include <microsim/MSVehicle.h>
41 #include <microsim/MSGlobals.h>
43 #include "MSXMLRawOut.h"
44 
45 #ifdef HAVE_MESOSIM
46 #include <mesosim/MELoop.h>
47 #include <mesosim/MESegment.h>
48 #endif
49 
50 #ifdef CHECK_MEMORY_LEAKS
51 #include <foreign/nvwa/debug_new.h>
52 #endif // CHECK_MEMORY_LEAKS
53 
54 
55 // ===========================================================================
56 // method definitions
57 // ===========================================================================
58 void
60  SUMOTime timestep) {
61  of.openTag("timestep") << " time=\"" << time2string(timestep) << "\">\n";
62  const std::vector<MSEdge*> &edges = ec.getEdges();
63  for (std::vector<MSEdge*>::const_iterator e = edges.begin(); e != edges.end(); ++e) {
64  writeEdge(of, **e);
65  }
66  of.closeTag();
67 }
68 
69 
70 void
72  //en
74  if (!dump) {
75 #ifdef HAVE_MESOSIM
77  MESegment* seg = MSGlobals::gMesoNet->getSegmentForEdge(edge);
78  while (seg != 0) {
79  if (seg->getCarNumber() != 0) {
80  dump = true;
81  break;
82  }
83  seg = seg->getNextSegment();
84  }
85  } else {
86 #endif
87  const std::vector<MSLane*> &lanes = edge.getLanes();
88  for (std::vector<MSLane*>::const_iterator lane = lanes.begin(); lane != lanes.end(); ++lane) {
89  if (((**lane).getVehicleNumber() != 0)) {
90  dump = true;
91  break;
92  }
93  }
94 #ifdef HAVE_MESOSIM
95  }
96 #endif
97  }
98  //en
99  if (dump) {
100  of.openTag("edge") << " id=\"" << edge.getID() << "\">\n";
101 #ifdef HAVE_MESOSIM
103  MESegment* seg = MSGlobals::gMesoNet->getSegmentForEdge(edge);
104  while (seg != 0) {
105  seg->writeVehicles(of);
106  seg = seg->getNextSegment();
107  }
108  } else {
109 #endif
110  const std::vector<MSLane*> &lanes = edge.getLanes();
111  for (std::vector<MSLane*>::const_iterator lane = lanes.begin(); lane != lanes.end(); ++lane) {
112  writeLane(of, **lane);
113  }
114 #ifdef HAVE_MESOSIM
115  }
116 #endif
117  of.closeTag();
118  }
119 }
120 
121 
122 void
124  of.openTag("lane") << " id=\"" << lane.myID << "\"";
125  if (lane.getVehicleNumber() != 0) {
126  of << ">\n";
127  for (std::vector<MSVehicle*>::const_iterator veh = lane.myVehBuffer.begin();
128  veh != lane.myVehBuffer.end(); ++veh) {
129  writeVehicle(of, **veh);
130  }
131  for (MSLane::VehCont::const_iterator veh = lane.myVehicles.begin();
132  veh != lane.myVehicles.end(); ++veh) {
133  writeVehicle(of, **veh);
134  }
135  }
136  of.closeTag(lane.getVehicleNumber() == 0);
137 }
138 
139 
140 void
142  if (veh.isOnRoad()) {
143  of.openTag("vehicle") << " id=\"" << veh.getID() << "\" pos=\""
144  << veh.getPositionOnLane() << "\" speed=\"" << veh.getSpeed() << "\"";
145  of.closeTag(true);
146  }
147 }
148 
149 
150 
151 /****************************************************************************/
152