final push
[des2015.git] / dsl / runtime / src / nl / ru / des / Marster.java
index 16dd328..a5c47c7 100644 (file)
@@ -1,10 +1,10 @@
 package nl.ru.des;
 
+import java.io.File;
 import java.io.PrintStream;
 import java.util.LinkedList;
 import java.util.Random;
 
-import lejos.hardware.Button;
 import lejos.hardware.Sound;
 import lejos.hardware.ev3.EV3;
 import lejos.hardware.ev3.LocalEV3;
@@ -20,6 +20,7 @@ import lejos.hardware.sensor.EV3UltrasonicSensor;
 import lejos.hardware.sensor.NXTLightSensor;
 import lejos.robotics.RegulatedMotor;
 import lejos.robotics.SampleProvider;
+import lejos.utility.Delay;
 import nl.ru.des.sensors.BTController;
 import nl.ru.des.sensors.RemoteSensors;
 import nl.ru.des.sensors.SensorCollector;
@@ -28,6 +29,44 @@ public class Marster {
        public static Arbitrator arb;
        public static Random random;
        
+       public static void playPacman(){
+               int whole = 2000;
+               Sound.playNote(Sound.PIANO, 494, whole/16);// b4
+               Sound.playNote(Sound.PIANO, 988, whole/16);// b5
+               Sound.playNote(Sound.PIANO, 740, whole/16);// f#5
+               Sound.playNote(Sound.PIANO, 622, whole/16);// eb5
+               Sound.playNote(Sound.PIANO, 988, whole/32);// b5
+               Sound.playNote(Sound.PIANO, 740, whole/16+whole/32);// f#5
+               Sound.playNote(Sound.PIANO, 622, whole/8);// eb5
+               
+               Sound.playNote(Sound.PIANO, 523, whole/16);// c5
+               Sound.playNote(Sound.PIANO, 1047, whole/16);// c6
+               Sound.playNote(Sound.PIANO, 784, whole/16);// g5
+               Sound.playNote(Sound.PIANO, 659, whole/16);// e5
+               Sound.playNote(Sound.PIANO, 1047, whole/32);// c6
+               Sound.playNote(Sound.PIANO, 784, whole/16+whole/32);// g5
+               Sound.playNote(Sound.PIANO, 659, whole/8);// e5
+               
+               Sound.playNote(Sound.PIANO, 494, whole/16);// b4
+               Sound.playNote(Sound.PIANO, 988, whole/16);// b5
+               Sound.playNote(Sound.PIANO, 740, whole/16);// f#5
+               Sound.playNote(Sound.PIANO, 622, whole/16);// eb5
+               Sound.playNote(Sound.PIANO, 988, whole/32);// b5
+               Sound.playNote(Sound.PIANO, 740, whole/16+whole/32);// f#5
+               Sound.playNote(Sound.PIANO, 622, whole/8);// eb5
+               
+               Sound.playNote(Sound.PIANO, 622, whole/32);// eb5
+               Sound.playNote(Sound.PIANO, 659, whole/32);// e5
+               Sound.playNote(Sound.PIANO, 698, whole/16);// f5
+               Sound.playNote(Sound.PIANO, 698, whole/32);// f5
+               Sound.playNote(Sound.PIANO, 740, whole/32);// f#5
+               Sound.playNote(Sound.PIANO, 784, whole/16);// g5
+               Sound.playNote(Sound.PIANO, 784, whole/32);// g5
+               Sound.playNote(Sound.PIANO, 831, whole/32);// ab5
+               Sound.playNote(Sound.PIANO, 880, whole/16);// a5
+               Sound.playNote(Sound.PIANO, 988, whole/8);// b5
+       }
+       
        @SuppressWarnings("resource")
        public static void main(String[] args) {
                EV3 brick = LocalEV3.get();
@@ -37,7 +76,6 @@ public class Marster {
                
                System.out.println("Loading keylistener...");
                brick.getKey("Escape").addKeyListener(new ButtonListener());
-
                if(brick.getName().equalsIgnoreCase("Rover6") || brick.getName().equalsIgnoreCase("Rover8")){
                        System.out.println("Starting as a slave...");
                        System.out.println("My name is " + brick.getName());
@@ -89,16 +127,18 @@ public class Marster {
                        sc.calibrate();
                        LinkedList<Mission> missions = Missions.getMissions(sc, rightMotor, leftMotor, measMotor);
                        random = new Random();
-                       System.out.println("Press any button to start");
-                       Button.waitForAnyEvent();
+                       Delay.msDelay(2000);
+                       playPacman();
                        for(Mission m : missions){
                                System.out.println("Start " + m.name + " mission...");
                                arb = new Arbitrator(m.behaviours);
                                sc.reset();
                                arb.start();
                                Sound.buzz();
+                               Delay.msDelay(5000);
                                System.out.println(m.name + " finished!!1one!");
                        }
+                       Sound.playSample(new File("rick.wav"), Sound.VOL_MAX);
                        System.exit(0);
                }
        }