update language'
authorMart Lubbers <mart@martlubbers.net>
Mon, 7 Dec 2015 11:19:07 +0000 (12:19 +0100)
committerMart Lubbers <mart@martlubbers.net>
Mon, 7 Dec 2015 11:19:07 +0000 (12:19 +0100)
dsl/runtime/specs/spec1.tdsl
dsl/runtime/src/nl/ru/des/BasicBehaviour.java
dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend

index 57bd7ba..bfa224f 100644 (file)
@@ -6,6 +6,8 @@ Behaviour Wander
                left motor forward
                right motor forward
                wait forever
+               measure lake
+               measure rock
 Behaviour AvoidLowLeftObjects
        take control: Touched on left
        action:
index 5095222..c91e613 100644 (file)
@@ -6,14 +6,15 @@ import nl.ru.des.sensors.SensorCollector;
 
 public abstract class BasicBehaviour implements Behavior{
        protected boolean suppressed;
-       protected EV3LargeRegulatedMotor leftMotor, rightMotor;
+       protected EV3LargeRegulatedMotor leftMotor, rightMotor, measMotor;
        protected SensorCollector sensors;
        protected long time;
        
        public BasicBehaviour(SensorCollector sensors, EV3LargeRegulatedMotor leftMotor,
-                       EV3LargeRegulatedMotor rightMotor){
+                       EV3LargeRegulatedMotor rightMotor, EV3LargeRegulatedMotor measMotor){
                this.leftMotor = leftMotor;
                this.rightMotor = rightMotor;
+               this.measMotor = measMotor;
                this.sensors = sensors;
        }
        
@@ -25,6 +26,14 @@ public abstract class BasicBehaviour implements Behavior{
                rightMotor.stop(true);
                leftMotor.stop(true);
        }
+
+       protected void rockMeasure(){
+               
+       }
+       
+       protected void lakeMeasure(){
+               
+       }
        
        @Override
        public void action() {
index d4f6915..06f9654 100644 (file)
@@ -22,7 +22,7 @@ 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/Behaviours.java", makeBehaviours(root.behaviour));
                        //fsa.generateFile("nl/ru/des/Missions.java", makeMissions(root.mission));
                }
        }
@@ -60,13 +60,14 @@ public class Missions{
 package nl.ru.des;
 
 import lejos.hardware.motor.EV3LargeRegulatedMotor;
+import nl.ru.des.sensors.SensorCollector;
 
 public class Behaviours{
        «FOR b : list»
        public static class «b.name»Behaviour extends BasicBehaviour {
                public «b.name»Behaviour(SensorCollector sensors, EV3LargeRegulatedMotor rightMotor,
-                               EV3LargeRegulatedMotor leftMotor, ColorMemory colors){
-                       super(sensors, rightMotor, leftMotor, colors);
+                               EV3LargeRegulatedMotor leftMotor,  EV3LargeRegulatedMotor measMotor){
+                       super(sensors, rightMotor, leftMotor, measMotor);
                }
                «IF b.tc != null»
                @Override public boolean takeControl(){
@@ -83,6 +84,8 @@ public class Behaviours{
                                        «a.whichMotor.d.toString()»Motor.setSpeed(«a.spd»);
                                        «ENDIF»
                                        «a.whichMotor.d.toString()»Motor.«a.dir.d.toString()»();
+                               «ELSEIF a.measureWhat != null»
+                               «a.measureWhat.d.toString()»Measure();
                                «ELSE»
                                time = System.currentTimeMillis();
                                while(!suppressed«IF a.time.time > 0» && System.currentTimeMillis()-time>«a.time.time»«ENDIF»){