Exemple #1
0
 public void LoadBeaconDetails(BeaconLocation beacon)
 {
     if (beacon == null)
     {
         HostName   = "";
         PortNumber = 8080;
     }
     else
     {
         HostName   = beacon.Address.Address.ToString();
         PortNumber = beacon.Address.Port;
     }
 }
Exemple #2
0
        static void Carry()
        {
            LcdConsole.WriteLine("Vracanje do IR beacona...");
            ir.Mode = IRMode.Seek;
            BeaconLocation beacon = ir.ReadBeaconLocation();

            motors.SetSpeed(C.carryTurnSpeed, (short)(C.right * Math.Sign(beacon.Location)));

            while (beacon.Location > 5 || beacon.Location < -5)
            {
                beacon = ir.ReadBeaconLocation();
            }
            while (beacon.Distance > C.carryDistanceToBeacon)
            {
                motors.SetSpeed(C.carryForwardSpeed, beacon.Location); // Potreban koeficijent
                beacon = ir.ReadBeaconLocation();                      // Mozda potrebno Thread.Sleep
            }
            motors.Brake();
            Thread.Sleep(C.motorBrakeSleepTime);
            LcdConsole.WriteLine("Rastojanje do IR beacona: {0}", ir.ReadBeaconLocation().Distance.ToString());
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            IRChannel[] channels = { IRChannel.One, IRChannel.Two, IRChannel.Three, IRChannel.Four };

            int channelIdx = 0;
            ManualResetEvent terminateProgram = new ManualResetEvent(false);
            var          sensor = new EV3IRSensor(SensorPort.In1);
            ButtonEvents buts   = new ButtonEvents();

            LcdConsole.WriteLine("Use IR on port1");
            LcdConsole.WriteLine("Up distance");
            LcdConsole.WriteLine("Down beacon location");
            LcdConsole.WriteLine("Enter read command");
            LcdConsole.WriteLine("Left change channel");
            LcdConsole.WriteLine("Right read as string");
            LcdConsole.WriteLine("Esc. terminate");
            buts.EscapePressed += () => {
                terminateProgram.Set();
            };
            buts.UpPressed += () => {
                LcdConsole.WriteLine("Distance " + sensor.ReadDistance() + " cm");
            };
            buts.EnterPressed += () => {
                LcdConsole.WriteLine("Remote command " + sensor.ReadRemoteCommand() + " on channel " + sensor.Channel);
            };
            buts.DownPressed += () => {
                BeaconLocation location = sensor.ReadBeaconLocation();
                LcdConsole.WriteLine("Beacon location: " + location.Location + " Beacon distance: " + location.Distance + " cm");
            };
            buts.LeftPressed += () => {
                channelIdx     = (channelIdx + 1) % channels.Length;
                sensor.Channel = channels[channelIdx];
                LcdConsole.WriteLine("Channel is set to: " + channels[channelIdx]);
            };
            buts.RightPressed += () => {
                LcdConsole.WriteLine(sensor.ReadAsString());
            };
            terminateProgram.WaitOne();
        }