Ejemplo n.º 1
0
        private void InitializeDevices()
        {
            Connection = new IPConnection();
            Connection.Connect("localhost", 4223);

            ServoBrick = new BrickServo("ap6zRki6edN", Connection);
            SetupServoBrick();
            DistanceBricklet = new BrickletDistanceIR("8XU", Connection);
            var distanceCollection = new ClosestDistanceSensorCollection();
            distanceCollection.AddSensor(new ImmediateDistanceIRSensor(DistanceBricklet));
            Distances = distanceCollection;

            var drivingStrategy = new SimpleDistanceDrivingStrategy(Engine, Distances);
            drivingStrategy.MinimumDrivingDistance = 30.Centimeters();
            drivingStrategy.ReversalDistance = 11.Centimeters();
            drivingStrategy.RefreshInterval = 10;
            this.DrivingStrategy = drivingStrategy;
        }
Ejemplo n.º 2
0
        private IDrivingStrategy SelectDrivingStrategy(IPlace place)
        {
            IDrivingStrategy drivingStrategy = null;

            if (place is IRoadStretch)
            {
                if (_roadDrivingStrategy == null)
                {
                    _roadDrivingStrategy = new RoadDrivingStrategy();
                }
                drivingStrategy = _roadDrivingStrategy;
            }
            else if (place is ITrafficLight)
            {
                if (_traficLightDrivingStrategy == null)
                {
                    _traficLightDrivingStrategy = new TrafficLightDrivingStrategy();
                }
                drivingStrategy = _traficLightDrivingStrategy;
            }

            return drivingStrategy;
        }