/// <summary> /// Constructor for the bus. /// </summary> /// <param name="busID">ID of the bus</param> /// <param name="Routes">All the routes the bus can drive on. Is multiple routes when complex</param> /// <param name="uSpeed">Update speed</param> /// <param name="startDecending">Direction of the route. True = Last to first stop.</param> /// <param name="startingMinSpeed">Initial minimum speed of the bus</param> /// <param name="startingMaxSpeed">Initial maximum speed of the bus</param> /// <param name="randomize">True if the bus should have a random position on the route initially.</param> public Bus(int busID, List<BusRoute> Routes, int uSpeed, bool startDecending, int startingMinSpeed, int startingMaxSpeed, bool randomize) { routes = Routes; bID = busID; updateSpeed = uSpeed; //If complex, pick a route on random. initialRoute = Routes[SimulationConfig.rand.Next(0, routes.Count)]; shouldRandomize = randomize; //If the bus should travel from first to last stop initially, flip the route. if (startDecending) { initialRoute.TurnAround(); } //Update the current route and direction of the bus on the MySQL database. UpdateBusDB(); maxSpeed = startingMaxSpeed; minSpeed = startingMinSpeed; //Set floating point for the bus thread to be "." instead of ",". gpsPosCalcThread = new Thread(new ThreadStart(gpsCalc)); System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)gpsPosCalcThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; gpsPosCalcThread.CurrentCulture = customCulture; //Set the intial position of the bus on the route. SetInitialPos(); }
public Bus(int busID, List<BusRoute> Routes, int uSpeed, bool startDecending, int startingMinSpeed, int startingMaxSpeed, bool randomize) { routes = Routes; bID = busID; updateSpeed = uSpeed; initialRoute = Routes[SimulationConfig.rand.Next(0, routes.Count)]; shouldRandomize = randomize; if (startDecending) { initialRoute.TurnAround(); } UpdateBusDB(); maxSpeed = startingMaxSpeed; minSpeed = startingMinSpeed; gpsPosCalcThread = new Thread(new ThreadStart(gpsCalc)); System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)gpsPosCalcThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; gpsPosCalcThread.CurrentCulture = customCulture; SetInitialPos(); }