00001 #ifndef _ROAD_H 00002 #define _ROAD_H 00003 00004 #include "stdafx.h" 00005 #include "IDMParameterSet.h" 00006 #include "RoadFeature.h" 00007 #include "StatDetector.h" 00008 #include "Direction.h" 00009 00010 #include "CASTORFile.h" 00011 #include "SAFTFile.h" 00012 #include "Constants.h" 00013 #include <vector> 00014 #include <fstream> 00015 #include <algorithm> 00016 00017 typedef std::vector< std::vector<Vehicle*> > M2D; 00018 00021 class Road { 00022 00023 public: 00024 void setLaneChangeReg(bool trackChanges, double outputTime, int roadLen, WORD registerType); 00025 void setDriveOnRight(bool OnRight); 00026 void clear(); 00027 int getPercentComplete(); 00028 bool getAllowLaneChanging(); 00029 00030 void setAllowLaneChanging(bool status); 00031 void setLocOuputDetectorDirPos(int loc); 00032 void setLocOuputDetectorDirNeg(int loc); 00033 00034 00035 void setNoLanesDirPos(int nlpos); 00036 void setNoLanesDirNeg(int nlneg); 00037 void setNoDirections(int nd); 00038 void setNoLanes(int nl); 00039 void setRoadLength(int L); 00040 void setTrafFileNoLanesDirPos(int nl); 00041 void setTrafFileNoLanesDirNeg(int nl); 00042 00043 void setIDMParams_Car (CIDMParameterSet* Params); 00044 void setIDMParams_SmallTruck(CIDMParameterSet* Params); 00045 void setIDMParams_LargeTruck(CIDMParameterSet* Params); 00046 void setIDMParams_Crane (CIDMParameterSet* Params); 00047 void setIDMParams_Lowloader (CIDMParameterSet* Params); 00048 00049 void SetSegmentFromFeature(CRoadFeature* pFeat); 00050 void SetMetricDetFromStatDet(CStatDetector* pDet, int nLanesPos, int nLanesNeg); 00051 00052 double getLength(); 00053 M2D getVehicles(); 00054 00055 void initTruckGroup(string inFile, string outFile, WORD fileType); 00056 bool update(double step, const double curTime); 00057 void populate(double step, const double curTime); 00058 double init(); 00059 00060 Road(); 00061 virtual ~Road(); 00062 00063 private: 00064 bool m_DriveOnRight; 00065 int m_PercentComplete; 00066 void passIDMParameters(RoadSegment* segment); 00067 void MapTrafLaneToSimLane(Vehicle* pVeh); 00068 void setIDMDriverModel(Vehicle* pVeh); 00069 void SetSpeedLimitSegment(CRoadFeature* pFeat); 00070 void SetGradientSegment(CRoadFeature *pFeat); 00071 00072 CIDMParameterSet* m_pIDMParams_Car; 00073 CIDMParameterSet* m_pIDMParams_SmallTruck; 00074 CIDMParameterSet* m_pIDMParams_LargeTruck; 00075 CIDMParameterSet* m_pIDMParams_Crane; 00076 CIDMParameterSet* m_pIDMParams_Lowloader; 00077 00078 int m_LocOutputDetectorDirPos; 00079 int m_LocOutputDetectorDirNeg; 00080 00081 Direction DirectionPos; 00082 Direction DirectionNeg; 00083 00084 int m_TrafFileNoLanesDirPos; 00085 int m_TrafFileNoLanesDirNeg; 00086 00087 FileHandler* m_pFileHandler; 00088 std::vector<Vehicle*> m_BufferVehicles; 00089 std::vector<Lane*> m_vLanes; 00090 std::vector<Detector*> m_vDetectorsPos; 00091 std::vector<Detector*> m_vDetectorsNeg; 00092 00093 std::vector<int> m_vLaneLengthsPos; 00094 std::vector<int> m_vLaneLengthsNeg; 00095 00096 std::vector<RoadSegment*> m_vRoadSegmentsPos; 00097 std::vector<RoadSegment*> m_vRoadSegmentsNeg; 00098 00099 bool m_bEndOfFile; 00100 bool m_AllowLaneChanging; 00101 int m_NoLanesDirPos; 00102 int m_NoLanesDirNeg; 00103 int m_NoDirections; 00104 int m_NoLanes; 00105 int m_RoadLength; 00106 00107 double MIN_SPACE_FOR_NEXT_VEHICLE; 00108 00109 }; 00110 #endif