Package com.ardublock.translator.block.exception

Examples of com.ardublock.translator.block.exception.BlockException


  @Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException
  {
    TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(0);
    if (!(tb instanceof VariablePolyBlock))  {
      throw new BlockException(blockId, uiMessageBundle.getString("ardublock.error_msg.char_var_slot"));
    }
   
    String ret = tb.toCode();
    tb = this.getRequiredTranslatorBlockAtSocket(1);
    ret = ret + " = " ;
View Full Code Here


  public String toCode() throws SocketNullException, SubroutineNotDeclaredException
  {
    String varName="";//this.getRequiredTranslatorBlockAtSocket(0);
    TranslatorBlock teste = this.getRequiredTranslatorBlockAtSocket(0);
    if (!(teste instanceof VariableNumberBlock || teste instanceof VariableNumberUnsignedLongBlock || teste instanceof VariableNumberDoubleBlock)) {
      throw new BlockException(blockId, uiMessageBundle.getString("ardublock.error_msg.number_var_slot"));
    }
    varName=varName+teste.toCode();
    //translator.addDefinitionCommand("int " + varName + "; //teste");
    String ret = "for (" + varName + "= 1; " + varName + "<= ( ";
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
View Full Code Here

    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");
      //ChannelNumber = "4";
    }
    if (Integer.parseInt(Speed) > 255 )
    {
      throw new BlockException(this.blockId, "the Speed of DC Motor must be 0(stop) to 255(full speed)");
      //Speed = "255";
    }
   
    if (Integer.parseInt(ChannelNumber) == 1 || Integer.parseInt(ChannelNumber) == 2)
    {
View Full Code Here

    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");
      //ChannelNumber = "4";
    }
    if (Integer.parseInt(Speed) > 255 )
    {
      throw new BlockException(this.blockId, "the Speed of DC Motor must be 0(stop) to 255(full speed)");
      //Speed = "255";
    }
   
    if (Integer.parseInt(ChannelNumber) == 1 || Integer.parseInt(ChannelNumber) == 2)
    {
View Full Code Here

    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;
    }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());
      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";
    }else{
      output+= servo+".write("+block.toCode()+");\n";
View Full Code Here

    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");
      //ChannelNumber = "4";
    }
    if (Integer.parseInt(Speed) > 255 )
    {
      throw new BlockException(this.blockId, "the Speed of DC Motor must be 0(stop) to 255(full speed)");
      //Speed = "255";
    }
   
    if (Integer.parseInt(ChannelNumber) == 1 || Integer.parseInt(ChannelNumber) == 2)
    {
View Full Code Here

  @Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException
  {
    TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(0);
    if (!(tb instanceof variable_String)) {
      throw new BlockException(blockId, uiMessageBundle.getString("ardublock.error_msg.string_var_slot"));
    }
   
    String ret = tb.toCode();
    tb = this.getRequiredTranslatorBlockAtSocket(1);
    ret = ret + " = " + tb.toCode() + " ;\n";
View Full Code Here

  @Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException
  {
    TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(0);
    if (!(tb instanceof VariableNumberDoubleBlock)) {
      throw new BlockException(blockId, uiMessageBundle.getString("ardublock.error_msg.double_number_var_slot"));
    }
   
    String ret = tb.toCode();
    tb = this.getRequiredTranslatorBlockAtSocket(1);
    ret = ret + " = " + tb.toCode() + " ;\n";
View Full Code Here

   
    TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(0);
   
    if (tb instanceof MessageBlock)
    {
      throw new BlockException(tb.blockId, "message cannot be override, choose string variable instead");
    }
   
    return codePrefix + "__ab_getIrCommand(" + tb.toCode() + ");\n" + codeSuffix;
  }
View Full Code Here

  public String toCode() throws SocketNullException, SubroutineNotDeclaredException
  {
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    if (!(translatorBlock instanceof NumberBlock))
    {
      throw new BlockException(this.blockId, "the Pin# of Servo must a number");
    }
   
   
    NumberBlock pinNumberBlock = (NumberBlock)translatorBlock;
    String pinNumber = pinNumberBlock.toCode();
View Full Code Here

TOP

Related Classes of com.ardublock.translator.block.exception.BlockException

Copyright © 2018 www.massapicom. 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.