Esempio n. 1
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        public Model(PreControl preControl, MainControl mainControl, EndControl endControl, Vehicle[] vehicles = null)
        {
            vehicles = vehicles ?? new[]
            {
                new Vehicle {
                    Kind = VehicleKind.OverheightVehicle
                },
                new Vehicle {
                    Kind = VehicleKind.OverheightVehicle
                },
                new Vehicle {
                    Kind = VehicleKind.HighVehicle
                }
            };

            VehicleSet = new VehicleSet(vehicles);
            VehicleSet.FinishedObserver = new FinishedObserverDisabled();

            SetupController(preControl);
            SetupController(mainControl);
            SetupController(endControl);

            HeightControl = new HeightControl(preControl, mainControl, endControl);
            Bind(nameof(VehicleSet.IsTunnelClosed), nameof(HeightControl.TrafficLights.IsRed));
        }
Esempio n. 2
0
		public void Initialize()
		{
			var lightBarrier1 = new LightBarrier(position: 200);
			var lightBarrier2 = new LightBarrier(position: 400);

			var detectorLeft = new OverheadDetector(Lane.Left, position: 400);
			var detectorRight = new OverheadDetector(Lane.Right, position: 400);
			var detectorFinal = new OverheadDetector(Lane.Left, position: 600);

			var trafficLights = new TrafficLights();

			var preControl = new OriginalPreControl(lightBarrier1);
			var mainControl = new OriginalMainControl(lightBarrier2, detectorLeft, detectorRight, timeout: 30);
			var endControl = new OriginalEndControl(detectorFinal, timeout: 10);

			var vehicle1 = new Vehicle(VehicleKind.OverheightTruck);
			var vehicle2 = new Vehicle(VehicleKind.Truck);
			var vehicle3 = new Vehicle(VehicleKind.OverheightTruck);

			var heightControl = new HeightControl(preControl, mainControl, endControl, trafficLights);
			var vehicles = new VehicleCollection(vehicle1, vehicle2, vehicle3);

			_model = new Model();
			_model.AddRootComponents(heightControl, vehicles);

			Bind(vehicles, lightBarrier1);
			Bind(vehicles, lightBarrier2);
			Bind(vehicles, detectorLeft);
			Bind(vehicles, detectorRight);
			Bind(vehicles, detectorFinal);

			_model.Bind(vehicles.RequiredPorts.IsTunnelClosed = trafficLights.ProvidedPorts.IsRed);
		}