From d66c5c319eb15f45086d6d0f6bda34b7ebedc42e Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Mon, 7 Dec 2015 12:19:07 +0100 Subject: [PATCH] update language' --- dsl/runtime/specs/spec1.tdsl | 2 ++ dsl/runtime/src/nl/ru/des/BasicBehaviour.java | 13 +++++++++++-- .../missions/generator/TaskDSLGenerator.xtend | 9 ++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/dsl/runtime/specs/spec1.tdsl b/dsl/runtime/specs/spec1.tdsl index 57bd7ba..bfa224f 100644 --- a/dsl/runtime/specs/spec1.tdsl +++ b/dsl/runtime/specs/spec1.tdsl @@ -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: diff --git a/dsl/runtime/src/nl/ru/des/BasicBehaviour.java b/dsl/runtime/src/nl/ru/des/BasicBehaviour.java index 5095222..c91e613 100644 --- a/dsl/runtime/src/nl/ru/des/BasicBehaviour.java +++ b/dsl/runtime/src/nl/ru/des/BasicBehaviour.java @@ -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() { diff --git a/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend b/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend index d4f6915..06f9654 100644 --- a/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend +++ b/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend @@ -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»){ -- 2.20.1