00001 #ifndef _VEHICLE_H
00002 #define _VEHICLE_H
00003
00004 #include "stdafx.h"
00005 #include "IDM.h"
00006 #include <vector>
00007 #include <string>
00008 #include <fstream>
00009 #include <strstrea.h>
00010 #include "Axle.h"
00011
00014 class Vehicle
00015 {
00016
00017 public:
00018
00019 void init(int RoadLength, bool DriveOnRIght);
00020 int getLaneNoInDirection();
00021 void setTotalNoLanesInRoad(int nLanes);
00022
00023 Vehicle();
00024 virtual ~Vehicle();
00025
00026
00027 void setTime(double time);
00028 void setChangeStatus(bool stat);
00029 void setRoadPos(double r);
00030 void setPos(double p);
00031
00032 void setAccel(double acceler);
00033 void setLength(double length);
00034 void setVelocity(double velocity);
00035 void setLane(int l);
00036 void setDirection(bool DirPointsRight);
00037 void setGVW(double weight);
00038 void setAxles();
00039 void setAW(int i, double w);
00040 void setAxles(int axNo);
00041 void setAS(int i, double s);
00042
00043
00044 CString getDataString();
00045 virtual double getTime() const;
00046 void setRoadLength(int length);
00047 bool getChangeStatus();
00048 double getRoadPos();
00049 double getPos();
00050 double getDesiredVel();
00051 double getAccel();
00052 double getLength();
00053 double getVelocity();
00054 int getLane();
00055 bool getDirection();
00056 WORD getID();
00057 double getGVW();
00058 int getNoAxles();
00059 double getAW(int i);
00060 double getAS(int i);
00061
00062 DriverModel* getDriver();
00063 void setDriver(IDM driver);
00064
00065 void createSAFTVehicle(std::string data);
00066 void createCASTORVehicle(std::string data);
00067 void writeSAFTData(char* pTruck);
00068 void writeCASTORData(char* pTruck);
00069
00070 void updateProperties(double step, double accel);
00071 void update(double step, Vehicle *pV);
00072 void update(double step);
00073
00074 double calcAccel();
00075 bool changeTime(double step);
00076 double calcAccel(Vehicle* pV);
00077
00078 int DecideNextLane(double LeftAdv, double RightAdv);
00079 double DecideLaneChange(Vehicle* frontVeh, Vehicle* backVeh, bool overtake);
00080 int DecideLaneChange(Vehicle* LeftFrontVehicle, Vehicle* LeftBackVehicle,
00081 Vehicle* RightFrontVehicle, Vehicle* RightBackVehicle,
00082 bool LeftLaneExists, bool RightLaneExists);
00083
00084
00085 protected:
00086 int Round(double val) {return int(val + 0.5);};
00087
00088 WORD setID();
00089 double LaneChangeAdvantage(Vehicle* FrontVehicle, Vehicle* BackVehicle, bool overtake);
00090
00091 DriverModel* m_pDriver;
00092 IDM m_IDMDriver;
00093
00094 bool m_DriveOnRight;
00095 bool m_DirPos;
00096 int m_intDir;
00097 int m_Lane;
00098 int m_RoadLength;
00099 double m_Position;
00100 double m_RoadPosition;
00101
00102 double m_Velocity;
00103 double m_Acceleration;
00104
00105 int m_Order;
00106 int m_Head;
00107
00108 int m_Year;
00109 int m_Month;
00110 int m_Day;
00111 int m_Hour;
00112 int m_Min;
00113 int m_Sec;
00114 int m_Hndt;
00115
00116 double m_GVW;
00117 int m_Trns;
00118 int m_NoAxles;
00119 double m_Length;
00120 std::vector<Axle*> m_vAxles;
00121
00122 WORD m_ID;
00123 bool m_bLaneChange;
00124 double m_Tdelay;
00125 int m_TotalNoLanesInRoad;
00126
00127 int ROAD_END_BUFFER;
00128 double T_DELAY;
00129 double MIN_SPACE_FOR_NEXT_VEHICLE;
00130 double SAFE_BRAKING;
00131 double CRANE_AVERAGE_SPACING;
00132 double CRANE_MAX_SPACING;
00133 double LOWLOADER_MIN_MAX_SPACING;
00134 int SMALL_TRUCK_NO_AXLES;
00135 int DAYS_PER_MT;
00136 int MTS_PER_YR;
00137
00138 };
00139 #endif