5 using System.Collections.Generic;
18 public bool IsPauseScheduled {
get {
return false; } }
24 private Cell connectedCell = null;
28 internal Cell ConnectedCell
30 get {
return connectedCell; }
31 set { connectedCell = value; }
37 private const int GeneratorSimulationPriority = 0;
42 public int Priority {
get {
return GeneratorSimulationPriority; } }
49 private Queue<int> tickets =
new Queue<int>();
54 internal event EventHandler WasZeroTicketsNowOneTicketIsAvailable;
66 lastTicketUsed =
false;
68 if (tickets.Count == 0)
71 if (connectedCell.Car == null)
74 int speed = tickets.Dequeue();
76 if (tickets.Count == 0)
77 lastTicketUsed =
true;
79 Car newCar =
new Car(connectedCell, speed, transitionFunctionParameters);
81 connectedCell.Car = newCar;
97 return TimeSpan.FromSeconds(5.0);
116 tickets.Enqueue(initialSpeed);
117 if (tickets.Count == 1)
118 OnWasZeroTicketsNowOneTicketWasGenerated();
124 internal void InitializeTickets()
126 tickets =
new Queue<int>();
132 private void OnWasZeroTicketsNowOneTicketWasGenerated()
134 if (WasZeroTicketsNowOneTicketIsAvailable != null)
135 WasZeroTicketsNowOneTicketIsAvailable(
this, EventArgs.Empty);
virtual TimeSpan GetTimeToNextAction(Random random)
Returns time to generation of new ticket.
virtual void PerformAction(Random random)
Generate new car.
Represents generator of cars.
Class containing parameters of transition function.
void GenerateTicket(int initialSpeed)
Generate new ticket. In case that current number of tickets is zero add generator to set of generator...
Every class which performs some repeating action should implement this interface