added gracefull shutdown
[des2015.git] / dsl / xtend / src / robots / missions / generator / TaskDSLGenerator.xtend
index f413af6..5af781f 100644 (file)
@@ -104,12 +104,15 @@ public class «b.name»Behaviour extends BasicBehaviour {
                                «ELSE»
                                        turnRandom(«a.turnType.start», «a.turnType.end»);
                                «ENDIF»
+                       «ELSEIF a.rl != null»
+                       measure«a.rl.d.toString()»();
                        «ELSE»
-                       measure();
+                       if(!suppressed){
+                               sensors.saveVar("«a.varName.toString()»");
+                       }
                        «ENDIF»
                «ENDFOR»
                LCDPrinter.print("Stop: «b.name»");
-               reset();
        }
 }
        '''
@@ -124,8 +127,8 @@ public class Constants{
        
        def CharSequence printExpression(StoppingExpression e)'''
        «IF e.scond != null»
-               «IF !e.scond.colors.nullOrEmpty»
-               sensors.collected(new int[]{«FOR c : e.scond.colors SEPARATOR ","»«c.d.ordinal»«ENDFOR»})
+               «IF e.scond.varName != null»
+               sensors.collected("«e.scond.varName.toString()»")
                «ELSEIF e.scond.touch != null»
                sensors.«e.scond.touch.d.toString()»Touch()
                «ELSEIF e.scond.light != null»
@@ -134,6 +137,8 @@ public class Constants{
                sensors.«e.scond.dist.d.toString()»Distance()
                «ELSEIF e.scond.color != null»
                sensors.color() == «e.scond.color.d.ordinal»
+               «ELSE»
+               false
                «ENDIF»
        «ELSEIF e.negscond != null»
                !(«printExpression(e.negscond)»)
@@ -142,6 +147,6 @@ public class Constants{
                        «FOR ex : e.s BEFORE "(" SEPARATOR "&&" AFTER ")"»«printExpression(ex)»«ENDFOR»
                «ELSE»
                        «FOR ex : e.s BEFORE "(" SEPARATOR "||" AFTER ")"»«printExpression(ex)»«ENDFOR»
-               «ENDIF»       
+               «ENDIF»
        «ENDIF»'''
 }
\ No newline at end of file