Package com.ardublock.translator.block.drawing

Source Code of com.ardublock.translator.block.drawing.SetParameters

/**************************************************
Description   :
Author    : Leo Yan
Created     : 2014/6
**************************************************/

package com.ardublock.translator.block.drawing;

import com.ardublock.translator.Translator;
import com.ardublock.translator.block.TranslatorBlock;
import com.ardublock.translator.block.exception.SocketNullException;
import com.ardublock.translator.block.exception.SubroutineNotDeclaredException;

public class SetParameters extends TranslatorBlock
{
  public SetParameters(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
  {
    super(blockId, translator);
  }

  @Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException
  {
    Util.setupEnv(translator);

    String ret;
    String strVar;

    TranslatorBlock childBlock;

    ret = "DBG_BEGIN(9600);\n\n";

    childBlock = getTranslatorBlockAtSocket(0);

    if (childBlock != null)
    {
      ret += "Drawing.setWakeCondition(" + childBlock.toCode() + ");\n";
    }

    childBlock = getTranslatorBlockAtSocket(1);
    if (childBlock != null)
    {
      ret += "Drawing.setDuration(" + childBlock.toCode() + ");\n";
    }

   
    ret += "\n" + "PaletteRuleConfigRec_stru ruleTbl[]={";

    childBlock = getTranslatorBlockAtSocket(2);
    while (childBlock != null)
    {
      strVar = childBlock.toCode();

      if ( strVar.length() > 5 )
      {
        ret += "{" + strVar + "},";
      }
     
      childBlock = childBlock.nextTranslatorBlock();
    }
   
    ret += "};\n";

    ret += "\n";
    ret += "Drawing.init(ruleTbl, sizeof(ruleTbl)/sizeof(PaletteRuleConfigRec_stru));\n";
   
    return ret;
  }
}
TOP

Related Classes of com.ardublock.translator.block.drawing.SetParameters

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.