started with new rover, bt still not worknig:(
[des2015.git] / dsl / xtend / src / robots / missions / generator / TaskDSLGenerator.xtend
index 58e115f..d4f6915 100644 (file)
@@ -9,9 +9,7 @@ import org.eclipse.xtext.generator.IFileSystemAccess
 import org.eclipse.xtext.generator.IGenerator
 import robots.missions.taskDSL.Behaviour
 import robots.missions.taskDSL.Mission
-import robots.missions.taskDSL.OperatorE
 import robots.missions.taskDSL.Robot
-import robots.missions.taskDSL.StoppingExpression
 
 /**
  * Generates code from your model files on save.
@@ -24,8 +22,8 @@ class TaskDSLGenerator implements IGenerator {
                var root = resource.allContents.head as Robot;
                if(root != null){
                        fsa.generateFile("nl/ru/des/Constants.java", makeConstants(root));
-                       fsa.generateFile("nl/ru/des/Behaviours.java", makeBehaviours(root.behaviour));
-                       fsa.generateFile("nl/ru/des/Missions.java", makeMissions(root.mission));
+                       //fsa.generateFile("nl/ru/des/Behaviours.java", makeBehaviours(root.behaviour));
+                       //fsa.generateFile("nl/ru/des/Missions.java", makeMissions(root.mission));
                }
        }
        
@@ -47,9 +45,9 @@ 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)»;
+                                       return »;
                                }
                        }}
                «ENDFOR»));
@@ -72,7 +70,7 @@ public class Behaviours{
                }
                «IF b.tc != null»
                @Override public boolean takeControl(){
-                       return «printExpression(b.tc)»;
+                       return ;
                }
                «ENDIF»
                
@@ -88,12 +86,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»
@@ -104,41 +96,14 @@ public class Behaviours{
        «ENDFOR»
 }
        '''
-       
-       def CharSequence printExpression(StoppingExpression e)'''
-       «IF e.scond != null»
-               «IF !e.scond.colors.nullOrEmpty»
-               colors.containsAll(Constants.colorsToFind)
-               «ELSEIF e.scond.touch != null»
-               sensors.«e.scond.touch.d.toString()»Touch()
-               «ELSEIF e.scond.op != null»
-               sensors.distance() «e.scond.op.d.toString()» «e.scond.dist»
-               «ELSEIF e.scond.color != null»
-               sensors.color() == «e.scond.color.d.ordinal»
-               «ENDIF»
-       «ELSE»
-               «IF e.op.d.equals(OperatorE.AND)»
-                       «FOR ex : e.s BEFORE "(" SEPARATOR "&&" AFTER ")"»«printExpression(ex)»«ENDFOR»
-               «ELSE»
-                       «FOR ex : e.s BEFORE "(" SEPARATOR "&&" AFTER ")"»«printExpression(ex)»«ENDFOR»
-               «ENDIF»       
-       «ENDIF»
-       '''
+
        
        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