Ejemplo n.º 1
0
 public PhaseController(string name, Queue <TrafficPhase> phaseQueue, PhaseController parent = null, TrafficPhase initialPhase = null)
 {
     Name           = name;
     Parent         = parent;
     CurrentPhase   = initialPhase;
     PhaseQueue     = phaseQueue;
     Timer.Interval = 1000;
     Timer.Tick    += new EventHandler(Timer_Tick);
 }
Ejemplo n.º 2
0
        public MainForm()
        {
            InitializeComponent();
            var controller = new PhaseController();

            trafficLight1.Controller                =
                trafficLight2.Controller            =
                    pedestrianLight1.Controller     =
                        pedestrianLight2.Controller = controller;
        }
Ejemplo n.º 3
0
        public Crossing()
        {
            InitializeComponent();
            MainController = new PhaseController(MainPhaseQueue, initialPhase: new TrafficPhase(PhaseType.Go, 8));
            SubController  = new PhaseController(SubPhaseQueue, MainController, new TrafficPhase(PhaseType.Stop));

            MainTrafficLight1.Controller     =
                MainTrafficLight2.Controller = MainController;
            SubTrafficLight1.Controller      =
                SubTrafficLight2.Controller  = SubController;
        }
Ejemplo n.º 4
0
        public Crossing()
        {
            InitializeComponent();
            MainController = new PhaseController("E/W", MainPhaseQueue);
            SubController  = new PhaseController("N/S", SubPhaseQueue, MainController);

            NorthTrafficLight.Switch(PhaseType.Stop);
            SouthTrafficLight.Switch(PhaseType.Stop);
            EastTrafficLight.Switch(PhaseType.Go);
            WestTrafficLight.Switch(PhaseType.Go);

            MainController.PhaseChanged += Controller_PhaseChanged;
            SubController.PhaseChanged  += Controller_PhaseChanged;
        }
Ejemplo n.º 5
0
        public Crossing()
        {
            InitializeComponent();

            MainController = new PhaseController();
            SubController  = new PhaseController();

            //set the queue to the Controller
            MainController.PhaseQueue = MainPhaseQueue;
            SubController.PhaseQueue  = SubPhaseQueue;

            MainTrafficLight1.Controller     =
                MainTrafficLight2.Controller = MainController;
            SubTrafficLight1.Controller      =
                SubTrafficLight2.Controller  = SubController;
        }
Ejemplo n.º 6
0
 public PhaseController(Queue <TrafficPhase> phaseQueue, PhaseController parent = null, TrafficPhase initialPhase = null)
 {
     Parent       = parent;
     CurrentPhase = initialPhase;
     PhaseQueue   = phaseQueue;
 }