From: Natanael Adityasatria Date: Mon, 7 Dec 2015 12:28:08 +0000 (+0100) Subject: Fixed shutdown behaviour and added print expression X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=940cc6f23a21cc11e8216333f5ae4b4a07090d39;p=des2015.git Fixed shutdown behaviour and added print expression --- diff --git a/dsl/runtime/specs/spec1.tdsl b/dsl/runtime/specs/spec1.tdsl index bfa224f..d3271c0 100644 --- a/dsl/runtime/specs/spec1.tdsl +++ b/dsl/runtime/specs/spec1.tdsl @@ -32,11 +32,16 @@ Behaviour AvoidHighObjects right motor forward wait 250 ms Behaviour StayInLine - take control: (or Color is Black Color is DarkGray) + take control: Color is Black action: right motor forward left motor backward wait 250 ms +Behaviour Meassure + take control: + action: + measure rock + wait 250 ms Mission Assignment using Wander diff --git a/dsl/runtime/src/nl/ru/des/ShutdownBehaviour.java b/dsl/runtime/src/nl/ru/des/ShutdownBehaviour.java index 4e9e5aa..ae75647 100644 --- a/dsl/runtime/src/nl/ru/des/ShutdownBehaviour.java +++ b/dsl/runtime/src/nl/ru/des/ShutdownBehaviour.java @@ -5,8 +5,8 @@ import nl.ru.des.sensors.SensorCollector; public class ShutdownBehaviour extends BasicBehaviour{ public ShutdownBehaviour(SensorCollector sensors, EV3LargeRegulatedMotor leftMotor, - EV3LargeRegulatedMotor rightMotor) { - super(sensors, leftMotor, rightMotor); + EV3LargeRegulatedMotor rightMotor, EV3LargeRegulatedMotor measMotor) { + super(sensors, leftMotor, rightMotor, measMotor); } @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 06f9654..0e85304 100644 --- a/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend +++ b/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend @@ -9,7 +9,9 @@ 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. @@ -71,7 +73,7 @@ public class Behaviours{ } «IF b.tc != null» @Override public boolean takeControl(){ - return ; + return «printExpression(b.tc)»; } «ENDIF» @@ -99,7 +101,6 @@ public class Behaviours{ «ENDFOR» } ''' - def CharSequence makeConstants(Robot robot)''' package nl.ru.des; @@ -109,4 +110,23 @@ public class Constants{ public final static int acceleration = «robot.acc»; }''' + 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»}) + «ELSEIF e.scond.touch != null» + sensors.«e.scond.touch.d.toString()»Touch() + «ELSEIF e.scond.dist != null» + sensors.distance() «e.scond.dist.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» + ''' } \ No newline at end of file