Package com.ardublock.translator.block

Examples of com.ardublock.translator.block.TranslatorBlock.toCode()


     
     
    TranslatorBlock ChannelBlock = this.getRequiredTranslatorBlockAtSocket(0);
    TranslatorBlock SpeedBlock = this.getRequiredTranslatorBlockAtSocket(1);
    String ChannelNumber = ChannelBlock.toCode();
    String Speed = SpeedBlock.toCode();
    String MotorDeclare;
   
    if (Integer.parseInt(ChannelNumber) > 4 )
    {
      throw new BlockException(this.blockId, "the Channel# of DC Motor must be 1,2,3 or 4");
View Full Code Here


    String servo = "servoDriver"+block.toCode();
   
    block = this.getRequiredTranslatorBlockAtSocket(1);
    String device = block.toCode();
    if(block instanceof NumberBlock){
      int deviceId = Integer.parseInt(block.toCode());
      if(deviceId>2||deviceId<1){
        throw new BlockException(this.blockId, "the Device Id of Servo must be in Range(1,2)");
      }
      deviceId = deviceId>2?2:(deviceId<1?1:deviceId);
      device = ""+deviceId;
View Full Code Here

      deviceId = deviceId>2?2:(deviceId<1?1:deviceId);
      device = ""+deviceId;
    }else{
      device = "1";
    }
    String ret = "MeServo "+servo+"(PORT_"+block.toCode()+","+device+");";
    translator.addDefinitionCommand(ret);
    String output = "";
    block = this.getRequiredTranslatorBlockAtSocket(2);
    if(block instanceof NumberBlock){
      int angle = Integer.parseInt(block.toCode());
View Full Code Here

    String ret = "MeServo "+servo+"(PORT_"+block.toCode()+","+device+");";
    translator.addDefinitionCommand(ret);
    String output = "";
    block = this.getRequiredTranslatorBlockAtSocket(2);
    if(block instanceof NumberBlock){
      int angle = Integer.parseInt(block.toCode());
      if(angle>180||angle<0){
        throw new BlockException(this.blockId, "the angle of Servo must be in Range(0,180)");
      }
      angle = angle>180?180:(angle<0?0:angle);
      output+= servo+".write("+angle+");\n";
View Full Code Here

        throw new BlockException(this.blockId, "the angle of Servo must be in Range(0,180)");
      }
      angle = angle>180?180:(angle<0?0:angle);
      output+= servo+".write("+angle+");\n";
    }else{
      output+= servo+".write("+block.toCode()+");\n";
    }
    return output;
  }

}
View Full Code Here

  public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
    translator.addHeaderFile("Makeblock.h");
    translator.addHeaderFile("SoftwareSerial.h");
    translator.addHeaderFile("Wire.h");
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    String ret = "MeLineFinder lineFinder"+translatorBlock.toCode()+"(PORT_"+translatorBlock.toCode()+");";
    translator.addDefinitionCommand(ret);
    return "lineFinder"+translatorBlock.toCode()+".readSensors()";
  }

}
View Full Code Here

  public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
    translator.addHeaderFile("Makeblock.h");
    translator.addHeaderFile("SoftwareSerial.h");
    translator.addHeaderFile("Wire.h");
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    String ret = "MeLineFinder lineFinder"+translatorBlock.toCode()+"(PORT_"+translatorBlock.toCode()+");";
    translator.addDefinitionCommand(ret);
    return "lineFinder"+translatorBlock.toCode()+".readSensors()";
  }

}
View Full Code Here

    translator.addHeaderFile("SoftwareSerial.h");
    translator.addHeaderFile("Wire.h");
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    String ret = "MeLineFinder lineFinder"+translatorBlock.toCode()+"(PORT_"+translatorBlock.toCode()+");";
    translator.addDefinitionCommand(ret);
    return "lineFinder"+translatorBlock.toCode()+".readSensors()";
  }

}
View Full Code Here

    {
      String Pin ;
      String Brightness;

      TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
      Pin = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
      Brightness = translatorBlock.toCode();
     
      String ret = "strip_pin"+Pin+".setBrightness("+Brightness +");\n";
     
View Full Code Here

      String Brightness;

      TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
      Pin = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
      Brightness = translatorBlock.toCode();
     
      String ret = "strip_pin"+Pin+".setBrightness("+Brightness +");\n";
     
      return codePrefix + ret + codeSuffix;
       
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.