00001
00002
00004
00005 #if !defined(AFX_LANE_H__3506F588_71F6_4DF9_AF0A_10B8BA4B9F50__INCLUDED_)
00006 #define AFX_LANE_H__3506F588_71F6_4DF9_AF0A_10B8BA4B9F50__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #include "stdafx.h"
00013 #include "Vehicle.h"
00014 #include "OutputDetector.h"
00015 #include "SpeedLimit.h"
00016 #include "MetricsDetector.h"
00017 #include "Gradient.h"
00018 #include "LaneChangeDetector.h"
00019
00020 using namespace std;
00021
00024 class Lane
00025 {
00026 public:
00027 void clear();
00028 void CheckFeatures(const double curTime, double prevPosition, double curPosition, Vehicle* pVeh);
00029 void setRoadSegments(std::vector<RoadSegment*> segments);
00030 void setOutputDetector(OutputDetector* out);
00031 Lane();
00032 Lane(int iLane, int length, std::vector<Detector*> detectors, bool DirPos, bool AllowLaneChange);
00033 virtual ~Lane();
00034
00035 bool update(const double step, const double curTime);
00036 int getIndex();
00037 double getLastPos();
00038 int getNoVeh();
00039 double getLength();
00040
00041 void insert(int i, Vehicle* pVeh);
00042 void setRightLane(Lane* right);
00043 void setLeftLane(Lane* left);
00044
00045 std::vector<Vehicle*> getPos();
00046
00047
00048 private:
00049 Vehicle* FinadAdjacentVehicle(Lane* AdjacentLane, double location,
00050 bool front, int* iAdjacentLane = NULL);
00051
00052 Lane* ChangeLanes(Vehicle* pVeh);
00053 Lane* ImplementLaneChange(Vehicle* pVeh, int LaneChangeID, int iVehLeftLane, int iVehRightLane);
00054
00055 void CheckDetectors(const double curTime, double prevPosition, double curPosition, Vehicle* pVeh);
00056 void CheckRoadSegments(double prevPosition, double curPosition, Vehicle* pVeh);
00057
00058 std::vector<Vehicle*> m_pVehicles;
00059 std::vector<Detector*> m_vDetectors;
00060
00061 int m_Dir;
00062 int m_iLane;
00063 double m_Flow;
00064 double m_RoadLength;
00065 int m_NoVeh;
00066 double m_PrevVehiclePosition;
00067 bool m_AllowLaneChanging;
00068 bool m_DirPos;
00069 double m_CurTime;
00070 bool m_bTrackLaneChanges;
00071
00072 std::vector<RoadSegment*> m_RoadSegments;
00073
00074 Lane* m_LeftLane;
00075 Lane* m_RightLane;
00076 OutputDetector* m_pOutputDetector;
00077 LaneChangeDetector* m_pLaneChangeDetector;
00078
00079 double MIN_SPACE_FOR_NEXT_VEHICLE;
00080 };
00081
00082 #endif // !defined(AFX_LANE_H__3506F588_71F6_4DF9_AF0A_10B8BA4B9F50__INCLUDED_)