update with colors etc, we now need to test it on physical robots
[des2015.git] / dsl / xtend / src / robots / missions / generator / TaskDSLGenerator.xtend
index 58e115f..d7ee2ed 100644 (file)
@@ -47,7 +47,7 @@ public class Missions{
                        «FOR b : m.behaviours SEPARATOR ","»
                        new Behaviours.«b.name»Behaviour(sensors, rightMotor, leftMotor, colors)
                        «ENDFOR»,
-                       new ShutdownBehaviour(sensors, rightMotor, leftMotor, colors, "«m.name»"){
+                       new ShutdownBehaviour(sensors, rightMotor, leftMotor, colors){
                                @Override public boolean takeControl(){
                                        return «printExpression(m.se)»;
                                }
@@ -88,12 +88,6 @@ public class Behaviours{
                                «ELSE»
                                time = System.currentTimeMillis();
                                while(!suppressed«IF a.time.time > 0» && System.currentTimeMillis()-time>«a.time.time»«ENDIF»){
-                                       «IF !b.clcColor.nullOrEmpty»
-                                       int currentColor = sensors.color();
-                                       if (Constants.colorsToFind.contains(currentColor)) {
-                                               colors.addColor(currentColor);
-                                       }
-                                       «ENDIF»
                                        Thread.yield(); 
                                }
                                «ENDIF»
@@ -108,7 +102,7 @@ public class Behaviours{
        def CharSequence printExpression(StoppingExpression e)'''
        «IF e.scond != null»
                «IF !e.scond.colors.nullOrEmpty»
-               colors.containsAll(Constants.colorsToFind)
+               sensors.collected(new int[]{«FOR c : e.scond.colors SEPARATOR ","»«c.d.ordinal»«ENDFOR»})
                «ELSEIF e.scond.touch != null»
                sensors.«e.scond.touch.d.toString()»Touch()
                «ELSEIF e.scond.op != null»
@@ -128,17 +122,9 @@ public class Behaviours{
        def CharSequence makeConstants(Robot robot)'''
 package nl.ru.des;
 
-import java.util.Arrays;
-import java.util.List;
-
 public class Constants{
        public final static int speed = «robot.spd»;
        public final static int acceleration = «robot.acc»;
-       «FOR m : robot.mission»
-               «IF !m.se.scond.colors.nullOrEmpty»
-                       public final static List<Integer> colorsToFind = Arrays.asList(new Integer[] {«FOR c : m.se.scond.colors SEPARATOR ","»«c.d.ordinal»«ENDFOR»});
-               «ENDIF»
-       «ENDFOR»
 }'''
        
 }
\ No newline at end of file