started with new rover, bt still not worknig:(
[des2015.git] / dsl / xtend / src / robots / missions / generator / TaskDSLGenerator.xtend
index 9aecf7e..d4f6915 100644 (file)
@@ -8,10 +8,8 @@ import org.eclipse.emf.ecore.resource.Resource
 import org.eclipse.xtext.generator.IFileSystemAccess
 import org.eclipse.xtext.generator.IGenerator
 import robots.missions.taskDSL.Behaviour
-import robots.missions.taskDSL.OperatorE
-import robots.missions.taskDSL.Robot
-import robots.missions.taskDSL.StoppingExpression
 import robots.missions.taskDSL.Mission
+import robots.missions.taskDSL.Robot
 
 /**
  * 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));
                }
        }
        
@@ -33,14 +31,13 @@ class TaskDSLGenerator implements IGenerator {
 package nl.ru.des;
 
 import java.util.LinkedList;
-import java.util.List;
 
 import lejos.hardware.motor.EV3LargeRegulatedMotor;
 import lejos.robotics.subsumption.Behavior;
 import nl.ru.des.Behaviours;
 
 public class Missions{
-       public static List<Mission> getMissions(SensorCollector sensors, EV3LargeRegulatedMotor rightMotor,
+       public static LinkedList<Mission> getMissions(SensorCollector sensors, EV3LargeRegulatedMotor rightMotor,
                        EV3LargeRegulatedMotor leftMotor, ColorMemory colors){
                LinkedList<Mission> missions = new LinkedList<Mission>();
                «FOR m : list»
@@ -50,7 +47,7 @@ public class Missions{
                        «ENDFOR»,
                        new ShutdownBehaviour(sensors, rightMotor, leftMotor, colors){
                                @Override public boolean takeControl(){
-                                       return Â«printExpression(m.se)»;
+                                       return »;
                                }
                        }}
                «ENDFOR»));
@@ -73,7 +70,7 @@ public class Behaviours{
                }
                «IF b.tc != null»
                @Override public boolean takeControl(){
-                       return «printExpression(b.tc)»;
+                       return ;
                }
                «ENDIF»
                
@@ -99,26 +96,7 @@ public class Behaviours{
        «ENDFOR»
 }
        '''
-       
-       def CharSequence printExpression(StoppingExpression e)'''
-       «IF e.scond != null»
-               «IF !e.scond.colors.nullOrEmpty»
-               colors.containsAll(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»
-               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;
@@ -128,4 +106,4 @@ public class Constants{
        public final static int acceleration = «robot.acc»;
 }'''
        
-}
+}
\ No newline at end of file