コード例 #1
0
        private Simulation Sim;                 //Only used to call emergency exit.

        public Tram(int number, Endstation place, int max, string datafolder, Simulation sim)
        {
            PassMax       = max;
            PassCurr      = 0;
            TramNo        = number;
            indepot       = true;
            busy          = false;
            Position      = place;
            hasloaded     = false;
            TotIn         = 0; TotOut = 0;
            cameFromDepot = false;
            Sim           = sim;

            int i = 0;

            while (i < place.depot.Length)
            {
                if (place.depot[i] == null)
                {
                    place.depot[i] = this;
                    break;
                }
                i++;
            }
            logger = new StreamWriter(datafolder + "Tram" + TramNo.ToString() + ".csv");
            logger.WriteLine("time , place of departure , place of arrival");
            tramActivitylog = new StreamWriter(datafolder + "activityLogTram" + TramNo.ToString() + ".txt");
            logPassengers   = new StreamWriter(datafolder + "Tram" + TramNo.ToString() + "PassLog.csv");
            logPassengers.WriteLine("time, location, passengers, passengers in, passengers out");
        }
コード例 #2
0
        /*
         *  Currently unused.
         */
        public void moveToDepot(Endstation place)
        {
            if (indepot)
            {
                return;
            }
            Position.RemoveTram(this);
            int i = 0;

            while (i < place.depot.Length)
            {
                if (place.depot[i] == null)
                {
                    place.depot[i] = this;
                    break;
                }
                i++;
            }
            indepot  = true;
            Position = place;
            if (!place.Name.Equals(Position.Name))
            {
                Console.WriteLine("WTF");
                Console.ReadLine();
            }
        }
コード例 #3
0
        private Simulation Sim;                 //Only used to call emergency exit.

        public Tram(int number, Endstation place, int max, string datafolder, Simulation sim)
        {
            PassMax = max;
            PassCurr = 0;
            TramNo = number;
            indepot = true;
            busy = false;
            Position = place;
            hasloaded = false;
            TotIn = 0; TotOut = 0;
            cameFromDepot = false;
            Sim = sim;

            int i = 0;
            while (i < place.depot.Length) {
                if (place.depot[i] == null) {
                    place.depot[i] = this;
                    break;
                }
                i++;
            }
            logger = new StreamWriter(datafolder + "Tram" + TramNo.ToString() + ".csv");
            logger.WriteLine("time , place of departure , place of arrival");
            tramActivitylog = new StreamWriter(datafolder+"activityLogTram" + TramNo.ToString() + ".txt");
            logPassengers = new StreamWriter(datafolder + "Tram" +TramNo.ToString() + "PassLog.csv");
            logPassengers.WriteLine("time, location, passengers, passengers in, passengers out");
        }
コード例 #4
0
        /*
         *  Creates the new track layout
         */
        private void buildRailRoad()
        {
            if (EXPLICIT)
            {
                Console.WriteLine("Initialising railway");
                if (WAIT)
                {
                    Console.ReadLine();
                }
            }
            railway = new iHasRails[2 * Stations.Length];
            for (int i = 0; i < Stations.Length; i++)
            {
                TimeDistr passdens;
                int       pass;
                if (Stations[i][Stations[i].Length - 1] == '0')
                {
                    passdens = PassDens_0;
                    pass     = PassDir0;
                }
                else
                {
                    passdens = PassDens_1;
                    pass     = PassDir1;
                }

                if (isEndstation[i])
                {
                    // This block: calculates the offset necesary in the timeschedule.
                    int drivetime = 0;
                    for (int j = 0; j < i; j++)
                    {
                        drivetime += Convert.ToInt32(DrivTimAvg[j]) + PerStationLeeway;
                    }
                    if (drivetime > 0)
                    {
                        drivetime += 4 * 60;
                    }

                    railway[2 * i] = new Endstation(Stations[i], hasDepot[i], NoTrams, PassInrates[i],
                                                    PassOutrates[i], passdens, pass, DrivTimAvg[i],
                                                    DrivTimVar[i], TramSchedule, drivetime, DataFolder, this
                                                    );
                }
                else
                {
                    railway[2 * i] = new Station(Stations[i], PassInrates[i], PassOutrates[i], passdens, pass,
                                                 DrivTimAvg[i], DrivTimVar[i], DataFolder, this);
                }

                railway[2 * i + 1] = new InTransit(NoTrams, this, Stations[i]);
            }

            for (int i = 0; i < railway.Length; i++)
            {
                railway[i].initStuff(railway[(railway.Length + i - 1) % railway.Length], railway[(railway.Length + i + 1) % railway.Length]
                                     );
            }
        }
コード例 #5
0
 /*
     Creates the eventlist.
     Events added upon creation:
         EndSim event
         RecruitTram event (planned 30 seconds before each planned departure at the endstation containing the depot)
 */
 public static void buildEventList (int endtime, int[] timetable, Endstation place, Simulation sim) {
     Sim = sim;
     if (Simulation.EXPLICIT) {
         Console.WriteLine("Initialising event list");
         if (Simulation.WAIT) Console.ReadLine();
     }
     list.Add(new EndSim(endtime, sim));
     for (int i = 0; i < timetable.Length; i++) {
         int time = Math.Max(0, timetable[i] - 30);
         new RecruitTram(time, null, place);
     }
 }
コード例 #6
0
 /*
  *  Creates the eventlist.
  *  Events added upon creation:
  *      EndSim event
  *      RecruitTram event (planned 30 seconds before each planned departure at the endstation containing the depot)
  */
 public static void buildEventList(int endtime, int[] timetable, Endstation place, Simulation sim)
 {
     Sim = sim;
     if (Simulation.EXPLICIT)
     {
         Console.WriteLine("Initialising event list");
         if (Simulation.WAIT)
         {
             Console.ReadLine();
         }
     }
     list.Add(new EndSim(endtime, sim));
     for (int i = 0; i < timetable.Length; i++)
     {
         int time = Math.Max(0, timetable[i] - 30);
         new RecruitTram(time, null, place);
     }
 }
コード例 #7
0
        /*
            Creates the new track layout
        */  
        private void buildRailRoad() {
            if (EXPLICIT) {
                Console.WriteLine("Initialising railway");
                if (WAIT) Console.ReadLine();
            }
            railway = new iHasRails[2 *Stations.Length ];
            for (int i = 0; i < Stations.Length; i ++) {
                TimeDistr passdens;
                int pass;
                if (Stations[i][Stations[i].Length -1] == '0') {
                    passdens = PassDens_0;
                    pass = PassDir0;
                }
                else {
                    passdens = PassDens_1;
                    pass= PassDir1;
                }

                if (isEndstation[i]) {
                    // This block: calculates the offset necesary in the timeschedule. 
                    int drivetime = 0;
                    for (int j = 0; j < i; j++) {
                        drivetime += Convert.ToInt32(DrivTimAvg[j]) + PerStationLeeway;
                    }
                    if (drivetime > 0) drivetime += 4*60;

                    railway[2*i] = new Endstation( Stations[i], hasDepot[i], NoTrams, PassInrates[i], 
                                                   PassOutrates[i], passdens, pass, DrivTimAvg[i], 
                                                   DrivTimVar[i], TramSchedule, drivetime , DataFolder, this
                                                  );
                }
                else railway[2*i] = new Station(Stations[i], PassInrates[i], PassOutrates[i], passdens, pass,
                                                DrivTimAvg[i], DrivTimVar[i], DataFolder, this);
                
                railway[2*i + 1] = new InTransit(NoTrams, this, Stations[i]);
            }

            for (int i = 0; i < railway.Length; i++) {
                railway[i].initStuff( railway[(railway.Length + i - 1)%railway.Length], railway[(railway.Length + i + 1)%railway.Length]
                                                                          );
            }
        }
コード例 #8
0
 /*
     Currently unused.
 */
 public void moveToDepot (Endstation place) {
     if (indepot) return;
     Position.RemoveTram(this);
     int i = 0;
     while (i < place.depot.Length) {
         if (place.depot[i] == null) {
             place.depot[i] = this;
             break;
         }
         i++;
     }
     indepot = true;
     Position = place;
     if (!place.Name.Equals(Position.Name)) {
         Console.WriteLine("WTF");
         Console.ReadLine();
     }
 }