|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Structure representing possible vehicle parameter 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 00020 00021 // =========================================================================== 00022 // included modules 00023 // =========================================================================== 00024 #ifdef _MSC_VER 00025 #include <windows_config.h> 00026 #else 00027 #include <config.h> 00028 #endif 00029 00030 #include <algorithm> 00031 #include <utils/common/SUMOVTypeParameter.h> 00032 #include <utils/common/ToString.h> 00033 #include <utils/common/TplConvert.h> 00034 #include <utils/common/MsgHandler.h> 00035 #include <utils/iodevices/OutputDevice.h> 00036 #include <utils/options/OptionsCont.h> 00037 #include <utils/xml/SUMOXMLDefinitions.h> 00038 00039 #ifdef CHECK_MEMORY_LEAKS 00040 #include <foreign/nvwa/debug_new.h> 00041 #endif // CHECK_MEMORY_LEAKS 00042 00043 00044 // =========================================================================== 00045 // member method definitions 00046 // =========================================================================== 00047 SUMOVTypeParameter::SUMOVTypeParameter() throw() 00048 : id(DEFAULT_VTYPE_ID), length(DEFAULT_VEH_LENGTH), 00049 minGap(DEFAULT_VEH_MINGAP), maxSpeed(DEFAULT_VEH_MAXSPEED), 00050 defaultProbability(DEFAULT_VEH_PROB), 00051 speedFactor(DEFAULT_VEH_SPEEDFACTOR), speedDev(DEFAULT_VEH_SPEEDDEV), 00052 emissionClass(SVE_UNKNOWN), color(RGBColor::DEFAULT_COLOR), 00053 vehicleClass(SVC_UNKNOWN), width(DEFAULT_VEH_GUIWIDTH), 00054 shape(DEFAULT_VEH_SHAPE), 00055 cfModel(DEFAULT_VEH_FOLLOW_MODEL), lcModel(DEFAULT_VEH_LANE_CHANGE_MODEL), 00056 setParameter(0), saved(false), onlyReferenced(false) { 00057 } 00058 00059 00060 void 00061 SUMOVTypeParameter::write(OutputDevice& dev) const throw(IOError) { 00062 if (onlyReferenced) { 00063 return; 00064 } 00065 dev.openTag(SUMO_TAG_VTYPE); 00066 dev.writeAttr(SUMO_ATTR_ID, id); 00067 if (wasSet(VTYPEPARS_LENGTH_SET)) { 00068 dev.writeAttr(SUMO_ATTR_LENGTH, length); 00069 } 00070 if (wasSet(VTYPEPARS_MINGAP_SET)) { 00071 dev.writeAttr(SUMO_ATTR_MINGAP, minGap); 00072 } 00073 if (wasSet(VTYPEPARS_MAXSPEED_SET)) { 00074 dev.writeAttr(SUMO_ATTR_MAXSPEED, maxSpeed); 00075 } 00076 if (wasSet(VTYPEPARS_PROBABILITY_SET)) { 00077 dev.writeAttr(SUMO_ATTR_PROB, defaultProbability); 00078 } 00079 if (wasSet(VTYPEPARS_SPEEDFACTOR_SET)) { 00080 dev.writeAttr(SUMO_ATTR_SPEEDFACTOR, speedFactor); 00081 } 00082 if (wasSet(VTYPEPARS_SPEEDDEVIATION_SET)) { 00083 dev.writeAttr(SUMO_ATTR_SPEEDDEV, speedDev); 00084 } 00085 if (wasSet(VTYPEPARS_VEHICLECLASS_SET)) { 00086 dev.writeAttr(SUMO_ATTR_VCLASS, toString(vehicleClass)); 00087 } 00088 if (wasSet(VTYPEPARS_EMISSIONCLASS_SET)) { 00089 dev.writeAttr(SUMO_ATTR_EMISSIONCLASS, getVehicleEmissionTypeName(emissionClass)); 00090 } 00091 if (wasSet(VTYPEPARS_SHAPE_SET)) { 00092 dev.writeAttr(SUMO_ATTR_GUISHAPE, getVehicleShapeName(shape)); 00093 } 00094 if (wasSet(VTYPEPARS_WIDTH_SET)) { 00095 dev.writeAttr(SUMO_ATTR_GUIWIDTH, width); 00096 } 00097 if (wasSet(VTYPEPARS_COLOR_SET)) { 00098 dev.writeAttr(SUMO_ATTR_COLOR, color); 00099 } 00100 00101 if (cfParameter.size()!=0) { 00102 dev << ">\n"; 00103 dev.openTag(cfModel); 00104 std::vector<SumoXMLAttr> attrs; 00105 for (CFParams::const_iterator i=cfParameter.begin(); i!=cfParameter.end(); ++i) { 00106 attrs.push_back(i->first); 00107 } 00108 std::sort(attrs.begin(), attrs.end()); 00109 for (std::vector<SumoXMLAttr>::const_iterator i=attrs.begin(); i!=attrs.end(); ++i) { 00110 dev.writeAttr(*i, cfParameter.find(*i)->second); 00111 } 00112 dev.closeTag(true); 00113 dev.closeTag(); 00114 } else { 00115 dev.closeTag(true); 00116 } 00117 } 00118 00119 00120 /****************************************************************************/ 00121