/// <summary> /// Constructor for trajectory only /// </summary> /// <param name="veh_id">Vehicle ID</param> /// <param name="veh_traj">Vehicle Trjectory</param> public VEHICLE(int veh_id, TRAJECTORY veh_traj) { this.Veh_id = veh_id; this.Transit_Time = new double[MAXIMUM_DETECTORS]; this.Speed = new double[MAXIMUM_DETECTORS]; this.Accel = new double[MAXIMUM_DETECTORS]; this.Veh_Traj = veh_traj; this.Length = 4.47; this.CrashPotentials = new CRASHPOTENTIALS(true); }
private static void _ReadTrajectory() { using (StreamReader readFile = new StreamReader(TrajectoryCSVs)) { readFile.ReadLine(); //skip first line of the file, it's the header in the CSV that just contains description. string line; //data from the line string[] rowdata; //data split from "line". line = readFile.ReadLine(); //read the trajectory count rowdata = line.Split(','); //This splits the data from 'line' readFile.ReadLine(); //void line line = readFile.ReadLine(); //read the sums rowdata = line.Split(','); readFile.ReadLine(); //Column Headers line while ((line = readFile.ReadLine()) != null) { rowdata = line.Split(','); //This splits the data from 'line' by comma and populates my array with it. List<int> nodes = new List<int>(); TRAJECTORY Curr_Traj; int total_vehs = int.Parse(rowdata[3]); int total_nodes_in_path = int.Parse(rowdata[2]); for (int i = 5; i < total_nodes_in_path + 5; i++) { nodes.Add(int.Parse(rowdata[i])); Console.WriteLine("Found Node " + rowdata[i]); } Curr_Traj = new TRAJECTORY(nodes); //read the vehicles using this trajectory line = readFile.ReadLine(); //next line has vehicles rowdata = line.Split(','); //This splits the data from 'line' by comma and populates my array with it. for (int i = 5; i < total_vehs + 5; i++) { Console.WriteLine("Found Vehicle " + rowdata[i] + " on Path {0}-{1}", Curr_Traj.start, Curr_Traj.end); bool pass_fail = true; foreach (VEHICLE vehicle in Vehicles) { if (vehicle.Veh_id == int.Parse(rowdata[i])) { pass_fail = false; Console.WriteLine("Vehicle is Duplicate! Is this Okay?"); Console.ReadLine(); break; } } if (pass_fail) Vehicles.Add(new VEHICLE(int.Parse(rowdata[i]), Curr_Traj)); } } } }
/// <summary> /// The constructor /// </summary> /// <param name="veh_id">Vehicle ID</param> /// <param name="t_time">Transit Time</param> /// <param name="speed"></param> /// <param name="accel"></param> /// <param name="veh_traj">Vehicle Trjectory</param> public VEHICLE(int veh_id, double[] t_time, double[] speed, double[] accel, TRAJECTORY veh_traj, double length, CRASHPOTENTIALS crashpotentials) { this.Veh_id = veh_id; this.Transit_Time = accel; this.Speed = speed; this.Accel = accel; this.Veh_Traj = veh_traj; this.Length = length; this.CrashPotentials = crashpotentials; }