Skip to content

Commit

Permalink
Merge pull request #132 from karlTH/master
Browse files Browse the repository at this point in the history
fixe some bug
  • Loading branch information
taweili committed Mar 17, 2016
2 parents b758410 + a35db26 commit fdb6015
Show file tree
Hide file tree
Showing 182 changed files with 6,760 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,23 @@ public DigitalOutputBlock(Long blockId, Translator translator, String codePrefix
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
String portNum = translatorBlock.toCode();


if (translatorBlock instanceof NumberBlock)
{
String number = translatorBlock.toCode();
String setupCode = "pinMode( " + number + " , OUTPUT);";
translator.addSetupCommand(setupCode);

String ret = "digitalWrite( ";
ret = ret + number;
ret = ret + " , ";
translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
ret = ret + translatorBlock.toCode();
ret = ret + " );\n";
return ret;
translator.addOutputPin(portNum.trim());
}
else
{
translator.addDefinitionCommand(ARDUBLOCK_DIGITAL_WRITE_DEFINE);
String ret = "__ardublockDigitalWrite(";

ret = ret + translatorBlock.toCode();
ret = ret + ", ";
translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
ret = ret + translatorBlock.toCode();
ret = ret + ");\n";
return ret;
String setupCode = "pinMode( " + portNum + " , OUTPUT);";
translator.addSetupCommand(setupCode);
}
translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
String value = translatorBlock.toCode();

String ret = "digitalWrite(" + portNum + " , " + value + ");\n";
return ret;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.ardublock.translator.block.Duinoedu;

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 CodeHeadBlock extends TranslatorBlock
{
public CodeHeadBlock(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
translator.addDefinitionCommand("//libraries at http://duinoedu.com/dl/lib/autre/EDU_CodeCache/");
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
translator.addHeaderFile("codeCache.h");
String ret = translatorBlock.toCode();
//ret=ret.substring(1);
//ret=ret.replace(ret.substring(ret.length()-1),"");
ret=ret+";\n";
translator.addDefinitionCommand(ret);
return "";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.ardublock.translator.block.Duinoedu;

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 CodeLoopBlock extends TranslatorBlock
{
public CodeLoopBlock(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
translator.addDefinitionCommand("//libraries at http://duinoedu.com/dl/lib/autre/EDU_CodeCache/");
translator.addHeaderFile("codeCache.h");
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
String ret = "\t"+translatorBlock.toCode();
//ret=ret.substring(1);
//ret=ret.replace(ret.substring(ret.length()),";");
ret=ret+";\n";
return ret;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.ardublock.translator.block.Duinoedu;

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 CodeSetupBlock extends TranslatorBlock
{
public CodeSetupBlock(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
translator.addDefinitionCommand("//libraries at http://duinoedu.com/dl/lib/autre/EDU_CodeCache/");
translator.addHeaderFile("codeCache.h");
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
String ret = translatorBlock.toCode();
//ret=ret.substring(1);
//ret=ret.replace(ret.substring(ret.length()-1),"");
ret=ret+";\n";
translator.addSetupCommandForced(ret);
return "";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ardublock.translator.block.Duinoedu;

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

public class Gps_ActiverInterruption extends TranslatorBlock
{

public Gps_ActiverInterruption(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label) {
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException {
return codePrefix + "monGps.activerInterruption();" + codeSuffix;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ardublock.translator.block.Duinoedu;

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

public class Gps_Angle extends TranslatorBlock
{

public Gps_Angle(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label) {
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException {
return codePrefix + "monGps.angle()" + codeSuffix;
}

}
19 changes: 19 additions & 0 deletions src/main/java/com/ardublock/translator/block/DuinoEDU/Gps_Day.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ardublock.translator.block.Duinoedu;

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

public class Gps_Day extends TranslatorBlock
{

public Gps_Day(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label) {
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException {
return codePrefix + "monGps.jour()" + codeSuffix;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ardublock.translator.block.Duinoedu;

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

public class Gps_DesactiverInterruption extends TranslatorBlock
{

public Gps_DesactiverInterruption(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label) {
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException {
return codePrefix + "monGps.desactiverInterruption();" + codeSuffix;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ardublock.translator.block.Duinoedu;

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

public class Gps_Hour extends TranslatorBlock
{

public Gps_Hour(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label) {
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException {
return codePrefix + "monGps.Gps_Hour()" + codeSuffix;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.ardublock.translator.block.Duinoedu;

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 Gps_Init extends TranslatorBlock {

public Gps_Init (Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}

//@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
String connect;
String jetlag;
String Interruption;
String Info;
String Frequence;

TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
connect = translatorBlock.toCode();
translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
Interruption = translatorBlock.toCode();
translatorBlock = this.getRequiredTranslatorBlockAtSocket(2);
jetlag = translatorBlock.toCode();
translatorBlock = this.getRequiredTranslatorBlockAtSocket(3);
Info = translatorBlock.toCode();
translatorBlock = this.getRequiredTranslatorBlockAtSocket(4);
Frequence = translatorBlock.toCode();

translator.addHeaderFile("Adafruit_GPS.h");
translator.addHeaderFile("SoftwareSerial.h");
translator.addHeaderFile("duinoeduGpsAdd.h");
translator.addDefinitionCommand("//libraries at http://duinoedu.com/dl/lib/dupont/EDU_Adafruit_GPS/ \n//libraries at http://duinoedu.com/dl/lib/dupont/EDU_duinoeduGpsAdd/\n "
+ "duinoeduGpsAdd monGps;\n"
+ "EDUGPS_INTERRUPTION(HORLOGE_0_DEPASSE_VALEUR_A) {\n"
+ " monGps.lireUnCaractere();\n"
+ "}\n");
translator.addSetupCommand(connect+Interruption+"monGps.definirDecalageHoraire("+jetlag+");");
translator.addSetupCommand("monGps.definirQuantiteInformation("+Info+");");
translator.addSetupCommand("monGps.definirFrequenceTrames(EDUGPS_"+Frequence+"HZ);");
String ret;

ret = "";


return ret ;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ardublock.translator.block.Duinoedu;

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

public class Gps_LatitudeDirection extends TranslatorBlock
{

public Gps_LatitudeDirection(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label) {
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException {
return codePrefix + "monGps.latitudeDirection()" + codeSuffix;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ardublock.translator.block.Duinoedu;

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

public class Gps_LatitudeGoogleMaps extends TranslatorBlock
{

public Gps_LatitudeGoogleMaps(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label) {
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException {
return codePrefix + "monGps.latitudeGoogleMapsNbr()" + codeSuffix;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ardublock.translator.block.Duinoedu;

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

public class Gps_LatitudeNbr extends TranslatorBlock
{

public Gps_LatitudeNbr(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label) {
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException {
return codePrefix + "monGps.latitudeNbr()" + codeSuffix;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ardublock.translator.block.Duinoedu;

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

public class Gps_LongitudeDirection extends TranslatorBlock
{

public Gps_LongitudeDirection(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label) {
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException {
return codePrefix + "monGps.longitudeDirection()" + codeSuffix;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ardublock.translator.block.Duinoedu;

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

public class Gps_LongitudeGoogleMaps extends TranslatorBlock
{

public Gps_LongitudeGoogleMaps(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label) {
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException {
return codePrefix + "monGps.longitudeGoogleMapsNbr()" + codeSuffix;
}

}
Loading

0 comments on commit fdb6015

Please sign in to comment.