X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=dsl%2Fxtend%2Fsrc%2Frobots%2Fmissions%2Fgenerator%2FTaskDSLGenerator.xtend;h=3baaa06efa277db9f7aab98e5aae29c93e1d56cc;hb=f92a71770aa8fc8abe3a60660df2965ec18cb479;hp=ff72ba425344267d4a4702f13c870df0e4f1f83a;hpb=7d9c29a46bae0afbc961e57f3013190b31ae5234;p=des2015.git diff --git a/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend b/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend index ff72ba4..3baaa06 100644 --- a/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend +++ b/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend @@ -45,7 +45,7 @@ public class Missions{ public static LinkedList getMissions(final SensorCollector sensors, RegulatedMotor rightMotor, RegulatedMotor leftMotor, RegulatedMotor measMotor){ LinkedList missions = new LinkedList(); - «FOR m : mission» + «FOR m : mission SEPARATOR "));" AFTER "));"» missions.add(new Mission("«m.name»", new Behavior[]{ «FOR b : m.behaviours SEPARATOR "," AFTER ","»new «b.name»Behaviour(sensors, rightMotor, leftMotor, measMotor) «ENDFOR» @@ -54,7 +54,7 @@ public class Missions{ return «printExpression(m.se)»; } }} - «ENDFOR»)); + «ENDFOR» return missions; } } @@ -73,7 +73,7 @@ public class «b.name»Behaviour extends BasicBehaviour { } «IF b.tc != null» @Override public boolean takeControl(){ - return getSuppressed() == SuppressedState.IN_ACTION || «printExpression(b.tc)»; + return «printExpression(b.tc)»; } «ENDIF» @@ -89,23 +89,28 @@ public class «b.name»Behaviour extends BasicBehaviour { «a.whichMotor.d.toString()»Motor.«a.moveDir.d.toString()»(); «ELSEIF a.time != null» time = System.currentTimeMillis(); - while(getSuppressed() != SuppressedState.SUPPRESSED«IF a.time.time > 0» && System.currentTimeMillis()-time>«a.time.time»«ENDIF»){ + while(!suppressed«IF a.time.time > 0» && System.currentTimeMillis()-time<«a.time.time»«ENDIF»){ Thread.yield(); } - «ELSEIF a.turnDir != null» + «ELSEIF a.turnType != null» «IF a.acc > 0» leftMotor.setAcceleration(«a.acc»); leftMotor.setSpeed(«a.spd»); rightMotor.setAcceleration(«a.acc»); rightMotor.setSpeed(«a.spd»); «ENDIF» - «a.turnDir.d.toString()»Turn(«a.degrees»); + «IF a.turnType.turnDir != null» + «a.turnType.turnDir.d.toString()»Turn(«a.turnType.degrees»); + «ELSE» + turnRandom(«a.turnType.start», «a.turnType.end»); + «ENDIF» + «ELSEIF a.rl != null» + measure«a.rl.d.toString()»(); «ELSE» - measure(); + sensors.saveVar("«a.varName.toString()»"); «ENDIF» «ENDFOR» LCDPrinter.print("Stop: «b.name»"); - reset(); } } ''' @@ -120,8 +125,8 @@ public class Constants{ 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»}) + «IF e.scond.varName != null» + sensors.collected("«e.scond.varName.toString()»") «ELSEIF e.scond.touch != null» sensors.«e.scond.touch.d.toString()»Touch() «ELSEIF e.scond.light != null» @@ -130,12 +135,16 @@ public class Constants{ sensors.«e.scond.dist.d.toString()»Distance() «ELSEIF e.scond.color != null» sensors.color() == «e.scond.color.d.ordinal» + «ELSE» + false «ENDIF» + «ELSEIF e.negscond != null» + !(«printExpression(e.negscond)») «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» «ENDIF»''' } \ No newline at end of file