Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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");
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 4
0
 public RecruitTram(int time, Tram tram, iHasRails place)
 {
     Priority = 0;
     ETime    = time; Subject = tram; Place = place;
     Name     = "RecruitTram";
     base.addToList();
 }
Ejemplo n.º 5
0
 public StartPassTransfer(int time, Tram tram, iHasRails place)
 {
     EventList.checkForTram(tram);
     Priority  = 2;
     tram.busy = true;
     ETime     = time; Subject = tram; Place = place;
     Name      = "StartPassTransfer";
     base.addToList();
 }
Ejemplo n.º 6
0
        public EndPassTransfer(int time, Tram tram, iHasRails place, int In, int Out, bool cont)
        {
            EventList.checkForTram(tram);

            Priority = 4;
            PassIn   = In; PassOut = Out;
            ETime    = time; Subject = tram; Place = place;
            Cont     = cont;
            Name     = "EndPassTransfer";
            base.addToList();
        }
Ejemplo n.º 7
0
 /*
     In addition to moving the tram: logs some data on tram activity.
 */
 private void moveTo(iHasRails place) {
     if (Simulation.EXPLICIT) Console.WriteLine("Moving tram " + TramNo.ToString() + " from " + Position.Name + " to " + place.Name);
     
     if (!place.AddTram(this)) {
         Console.WriteLine("Error trying to move Tram" + TramNo.ToString() + " to station " + place.Name);
         Console.ReadLine(); Sim.EmergencyExit();
     }
     Position.RemoveTram(this);
     logger.WriteLine(Time.Now().ToString() + " , " + Position.Name + " , " + place.Name);
     tramActivitylog.WriteLine(Time.Now().ToString() + " , Move , " + Position.Name + " , " + place.Name);
     Position = place;
     
 }
Ejemplo n.º 8
0
 public EndTransit(int time, Tram tram, iHasRails place)
 {
     EventList.checkForTram(tram);
     Priority  = 5;
     ETime     = time; Subject = tram; Place = place;
     tram.busy = true;
     if (!place.Name.Trim().Equals(tram.Position.Next.Name.Trim()))
     {
         Console.WriteLine("AT EndTransit: place and subject.position.next do not match. \"" + Place.Name + "\" vs \"" + Subject.Position.Next.Name + "\"");
         Console.ReadLine(); EventList.Sim.EmergencyExit();
     }
     Name = "Endtransit";
     base.addToList();
 }
Ejemplo n.º 9
0
 public PassEmbarkWait(int time, Tram tram, int pin, iHasRails place)
 {
     EventList.checkForTram(tram);
     Priority     = 3;
     ETime        = time; Subject = tram; Place = place;
     Subject.busy = true;
     Pin          = pin;
     Name         = "PassEmbarkWait";
     if (!Place.Name.Trim().Equals(Subject.Position.Name.Trim()))
     {
         Console.WriteLine("At creation of passembarkwait: place and subject.position do not match. " + Place.Name + " vs " + Subject.Position.Name);
         Console.ReadLine(); EventList.Sim.EmergencyExit();
     }
     base.addToList();
 }
Ejemplo n.º 10
0
        public TrackLock(int time, Tram tram, iHasRails place, int track, bool incoming)
        {
            Priority = 6;
            ETime    = time; Place = place; Track = track; Incoming = incoming;
            Place.LockTrack(track);
            Name = "TrackLock";
            if (Simulation.EXPLICIT)
            {
                Console.WriteLine("Starting tracklock of  at station " + Place.Name + " at time " + Time.Now().ToString());
                if (Simulation.WAIT)
                {
                    Console.ReadLine();
                }
            }

            base.addToList();
        }
Ejemplo n.º 11
0
        /*
         *  In addition to moving the tram: logs some data on tram activity.
         */
        private void moveTo(iHasRails place)
        {
            if (Simulation.EXPLICIT)
            {
                Console.WriteLine("Moving tram " + TramNo.ToString() + " from " + Position.Name + " to " + place.Name);
            }

            if (!place.AddTram(this))
            {
                Console.WriteLine("Error trying to move Tram" + TramNo.ToString() + " to station " + place.Name);
                Console.ReadLine(); Sim.EmergencyExit();
            }
            Position.RemoveTram(this);
            logger.WriteLine(Time.Now().ToString() + " , " + Position.Name + " , " + place.Name);
            tramActivitylog.WriteLine(Time.Now().ToString() + " , Move , " + Position.Name + " , " + place.Name);
            Position = place;
        }
Ejemplo n.º 12
0
        public StartTransit(int time, Tram tram, iHasRails place, int timenumber)
        {
            EventList.checkForTram(tram);
            Priority     = 5;
            ETime        = time; Subject = tram; Place = place; number = timenumber;
            Subject.busy = true;
            if (Place != tram.Position)
            {
                Console.WriteLine("At StartTransit event: place and subject.Position did not match. " + Place.Name + " vs " + Subject.Position.Name);
                Console.ReadLine(); EventList.Sim.EmergencyExit();
            }

            if (Simulation.EXPLICIT)
            {
                Console.WriteLine("Planned Starttransit of tram" + Subject.TramNo.ToString() + " at station " + Place.Name + " at time " + Time.Now().ToString());
            }
            Name = "StartTransit";
            base.addToList();
        }
Ejemplo n.º 13
0
        public TrackLock(int time, Tram tram, iHasRails place, int track, bool incoming ) {
            Priority = 6;
            ETime = time; Place = place; Track = track; Incoming = incoming;
            Place.LockTrack(track);
            Name = "TrackLock";
            if (Simulation.EXPLICIT) {
                Console.WriteLine("Starting tracklock of  at station " + Place.Name + " at time " + Time.Now().ToString());
                if (Simulation.WAIT) Console.ReadLine();
            }

            base.addToList();
        }
Ejemplo n.º 14
0
        public EndPassTransfer(int time, Tram tram, iHasRails place, int In, int Out, bool cont) {
            EventList.checkForTram(tram);

            Priority = 4;
            PassIn = In; PassOut = Out;
            ETime = time; Subject = tram; Place = place;
            Cont = cont;
            Name = "EndPassTransfer";
            base.addToList();
        }
Ejemplo n.º 15
0
 public StartPassTransfer(int time, Tram tram, iHasRails place) {
     EventList.checkForTram(tram);
     Priority = 2;
     tram.busy = true; 
     ETime = time; Subject = tram; Place = place;
     Name = "StartPassTransfer";
     base.addToList();            
 }
Ejemplo n.º 16
0
 public EndTransit(int time, Tram tram, iHasRails place) {
     EventList.checkForTram(tram);
     Priority = 5;
     ETime = time; Subject = tram; Place = place;
     tram.busy = true;
     if ( !place.Name.Trim().Equals( tram.Position.Next.Name.Trim())) {
         Console.WriteLine("AT EndTransit: place and subject.position.next do not match. \"" + Place.Name + "\" vs \"" + Subject.Position.Next.Name + "\"");
          Console.ReadLine(); EventList.Sim.EmergencyExit();
     }
     Name = "Endtransit";
     base.addToList();
 }
Ejemplo n.º 17
0
        public StartTransit(int time, Tram tram, iHasRails place, int timenumber) {
            EventList.checkForTram(tram);
            Priority = 5;
            ETime = time; Subject = tram; Place = place; number = timenumber;
            Subject.busy = true;
            if (Place != tram.Position) {
                 Console.WriteLine("At StartTransit event: place and subject.Position did not match. " + Place.Name + " vs " + Subject.Position.Name);
                 Console.ReadLine(); EventList.Sim.EmergencyExit();
            }

            if (Simulation.EXPLICIT) Console.WriteLine("Planned Starttransit of tram"  + Subject.TramNo.ToString() + " at station " + Place.Name + " at time " + Time.Now().ToString());
            Name = "StartTransit";
            base.addToList();
        }
Ejemplo n.º 18
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();
     }
 }
 //Cannot do this upon construction; not all iHasRails have been contructed by then.
 public virtual void initStuff(iHasRails prev, iHasRails next)
 {
     Previous = prev;
     Next     = next;
 }
 public override void initStuff(iHasRails prev, iHasRails next)
 {
     base.initStuff(prev, next);
 }
        public override void initStuff (iHasRails prev, iHasRails next) {

            base.initStuff(prev, next);
        }
Ejemplo n.º 22
0
		public RecruitTram (int time, Tram tram, iHasRails place){
            Priority = 0;
			ETime = time; Subject = tram; Place= place;
            Name = "RecruitTram";
			base.addToList();		
		}
Ejemplo n.º 23
0
        public PassEmbarkWait(int time, Tram tram, int pin, iHasRails place){
            EventList.checkForTram(tram);
            Priority = 3;
			ETime = time; Subject = tram; Place= place;
            Subject.busy = true;
            Pin = pin;
            Name = "PassEmbarkWait";
            if ( !Place.Name.Trim().Equals( Subject.Position.Name.Trim())) {
                Console.WriteLine("At creation of passembarkwait: place and subject.position do not match. " +Place.Name + " vs " + Subject.Position.Name);
                Console.ReadLine(); EventList.Sim.EmergencyExit();
            }
			base.addToList();		
		}
 //Cannot do this upon construction; not all iHasRails have been contructed by then.
 public virtual void initStuff(iHasRails prev, iHasRails next) {
     Previous = prev;
     Next = next;
 }