Ejemplo n.º 1
0
 public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
   String ret = "cos( ";
   TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
   ret = ret + translatorBlock.toCode();
   ret = ret + " )";
   return codePrefix + ret + codeSuffix;
 }
Ejemplo n.º 2
0
 public String toCode() throws SocketNullException {
   String ret = "( ";
   TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
   ret = ret + translatorBlock.toCode();
   ret = ret + " && ";
   translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
   ret = ret + translatorBlock.toCode();
   ret = ret + " )";
   return codePrefix + ret + codeSuffix;
 }
Ejemplo n.º 3
0
 public String toCode() {
   String ret;
   ret = "void loop()\n{\n";
   TranslatorBlock translatorBlock = getTranslatorBlockAtSocket(0);
   while (translatorBlock != null) {
     ret = ret + translatorBlock.toCode();
     translatorBlock = translatorBlock.nextTranslatorBlock();
   }
   ret = ret + "}\n\n";
   return ret;
 }
Ejemplo n.º 4
0
 public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
   String ret = "if (";
   TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
   ret = ret + translatorBlock.toCode();
   ret = ret + ")\n{\n";
   translatorBlock = getTranslatorBlockAtSocket(1);
   while (translatorBlock != null) {
     ret = ret + translatorBlock.toCode();
     translatorBlock = translatorBlock.nextTranslatorBlock();
   }
   ret = ret + "}\n";
   return ret;
 }
Ejemplo n.º 5
0
 public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
   String ret = "long current=millis();\nwhile(current+";
   TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
   ret = ret + translatorBlock.toCode();
   ret = ret + ">millis())\n{";
   translatorBlock = getTranslatorBlockAtSocket(1);
   while (translatorBlock != null) {
     ret = ret + "\t" + translatorBlock.toCode();
     translatorBlock = translatorBlock.nextTranslatorBlock();
   }
   ret = ret + "}\n";
   return ret;
 }
  @Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
    TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(0);
    if (!(tb instanceof VariableNumberUnsignedLongBlock)) {
      throw new BlockException(
          blockId, uiMessageBundle.getString("ardublock.error_msg.long_number_var_slot"));
    }

    String ret = tb.toCode();
    tb = this.getRequiredTranslatorBlockAtSocket(1);
    ret = ret + " = " + tb.toCode() + " ;\n";
    // ret = ret + " = " + "(unsigned long)" + tb.toCode() + " ;\n";
    return ret;
  }
Ejemplo n.º 7
0
  @Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
    translator.addHeaderFile("Wire.h");
    translator.addHeaderFile("BlunoOled00.h");

    translator.addDefinitionCommand("BlunoOled oled;\n");

    translator.addSetupCommand("oled.oled_init();\n");

    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);

    String ret = "oled.print(" + translatorBlock.toCode() + ");\n";
    return ret;
  }
Ejemplo n.º 8
0
  public String toCode() throws SocketNullException {
    String trigPin;
    String echoPin;
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    trigPin = translatorBlock.toCode();
    translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
    echoPin = translatorBlock.toCode();

    // translator.addSetupCommand("digitalWrite( " + trigPin + " , LOW );");

    translator.addDefinitionCommand(ultraSonicFunction);

    String ret = "ardublockUltrasonicSensor( " + trigPin + " , " + echoPin + " )";

    return codePrefix + ret + codeSuffix;
  }
Ejemplo n.º 9
0
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
    setupWatchdog(translator);

    TranslatorBlock t5 = getRequiredTranslatorBlockAtSocket(0);
    String bol1 = t5.toString();

    if (bol1.startsWith("com.ardublock.translator.block.DigitalHigh")) {
      String ret = "wdt_enable( ";
      TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(1);
      ret = ret + tb.toCode();
      ret = ret + " );\n";

      return ret;
    } else {
      String ret = "wdt_disable();\n";

      return ret;
    }
  }
Ejemplo n.º 10
0
  @Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException {

    String tempInit = getTranslatorBlockAtSocket(0).toCode();
    // System.out.println("tempInit is"+tempInit);
    String init = new String("");
    for (int i = 0; i < tempInit.length(); i++) {
      if (i + 1 != tempInit.length()) {
        if (tempInit.charAt(i) == '=' && tempInit.charAt(i + 1) == '=') {
          i++;
        }
      }
      init += tempInit.charAt(i);
    }

    // System.out.println(init + "init is ");
    String cond = getTranslatorBlockAtSocket(1).toCode();
    String step = getTranslatorBlockAtSocket(2).toCode();
    String var = new String("");
    for (int i = 0; i < init.length(); i++) {
      if (init.charAt(i) == '=') {
        break;
      }
      var += init.charAt(i);
    }
    step = var + "+= " + step;
    init = "float " + init;
    init = removeBracket(init);
    step = removeBracket(step);
    String execution = "";
    if (!isTranslatorBlockAtSocketNull(3)) {
      // execution = getTranslatorBlockAtSocket(3).toCode();
      TranslatorBlock translatorBlock = getTranslatorBlockAtSocket(3);
      while (translatorBlock != null) {
        execution = execution + translatorBlock.toCode();
        translatorBlock = translatorBlock.nextTranslatorBlock();
      }
    }

    String ret = "for(" + init + " ; " + cond + " ; " + step + " ){\n" + execution + "\n}\n";
    return ret;
  }
Ejemplo n.º 11
0
 public String toCode() {
   String ret = "map ( ";
   TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(0);
   ret = ret + tb.toCode();
   ret = ret + " , ";
   tb = this.getRequiredTranslatorBlockAtSocket(1);
   ret = ret + tb.toCode();
   ret = ret + " , ";
   tb = this.getRequiredTranslatorBlockAtSocket(2);
   ret = ret + tb.toCode();
   ret = ret + " , ";
   tb = this.getRequiredTranslatorBlockAtSocket(3);
   ret = ret + tb.toCode();
   ret = ret + " , ";
   tb = this.getRequiredTranslatorBlockAtSocket(4);
   ret = ret + tb.toCode();
   ret = ret + " ) ";
   return codePrefix + ret + codeSuffix;
 }
Ejemplo n.º 12
0
 public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
   TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(0);
   String ret = "delayMicroseconds( " + tb.toCode() + " );\n";
   return ret;
 }