Skip to content
Snippets Groups Projects
Commit 171455d7 authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Update on custom code generation

parent d770dab1
No related branches found
No related tags found
No related merge requests found
SRCS = generated_src/main.c generated_src/PeriodicHello.c
\ No newline at end of file
SRCS = generated_src/main.c generated_src/ObserverProp1.c generated_src/RemotelyControlledMicrowave.c generated_src/RemoteControl.c generated_src/MicroWaveOven.c generated_src/Bell.c generated_src/ControlPanel.c generated_src/Controller.c generated_src/Magnetron.c generated_src/Door.c generated_src/WirelessInterface.c
\ No newline at end of file
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -71,7 +71,7 @@ public class Main implements ActionListener {
public static void main(String[] args) {
testBoolExpr();
//testBoolExpr();
//testMatrix();
/* int x = 5 * 2 + 3;
......
......@@ -86,6 +86,10 @@ public class Test {
nbOfPb += evalBool("f or t)", true, true);
nbOfPb += evalBool("f or t and f", false, false);
nbOfPb += evalBool("(3>5)or (4<6) or (1>2)", true, false);
System.out.println("Nb of problems found:" + nbOfPb);
System.exit(-1);
......
......@@ -77,6 +77,7 @@ public class AVATAR2CPOSIX {
private int timeUnit;
private boolean debug;
private boolean tracing;
private boolean includeUserCode = true;
public AVATAR2CPOSIX(AvatarSpecification _avspec) {
......@@ -87,6 +88,10 @@ public class AVATAR2CPOSIX {
timeUnit = _timeUnit;
}
public void includeUserCode(boolean _inc) {
includeUserCode = _inc;
}
public static String getGeneratedPath() {
return GENERATED_PATH;
}
......@@ -134,7 +139,7 @@ public class AVATAR2CPOSIX {
avspec.removeTimers();
if (avspec.hasApplicationCode()) {
if (avspec.hasApplicationCode() && includeUserCode) {
mainFile.appendToBeforeMainCode("/* User code */\n");
mainFile.appendToBeforeMainCode(avspec.getApplicationCode());
mainFile.appendToBeforeMainCode("\n/* End of User code */\n\n");
......@@ -227,9 +232,11 @@ public class AVATAR2CPOSIX {
//taskFile.addToMainCode("#include \"" + block.getName() + ".h\"");
String tmp = block.getGlobalCode();
if (tmp != null) {
taskFile.addToMainCode(CR + "// Header code defined in the model" + CR + tmp + CR + "// End of header code defined in the model" + CR + CR);
if (includeUserCode) {
String tmp = block.getGlobalCode();
if (tmp != null) {
taskFile.addToMainCode(CR + "// Header code defined in the model" + CR + tmp + CR + "// End of header code defined in the model" + CR + CR);
}
}
defineAllStates(block, taskFile);
......@@ -455,10 +462,12 @@ public class AVATAR2CPOSIX {
s += "case STATE__" + asme.getName() + ": " + CR;
s += traceStateEntering("__myname", asme.getName());
tmp = ((AvatarState)asme).getEntryCode();
if (tmp != null) {
if (tmp.trim().length() > 0) {
s += "/* Entry code */\n" + tmp + "\n/* End of entry code */\n\n";
if (includeUserCode) {
tmp = ((AvatarState)asme).getEntryCode();
if (tmp != null) {
if (tmp.trim().length() > 0) {
s += "/* Entry code */\n" + tmp + "\n/* End of entry code */\n\n";
}
}
}
......
......@@ -86,6 +86,9 @@ public class BoolExpressionEvaluator {
}
public String getError() {
if (errorMessage == null) {
return null;
}
int index = errorMessage.indexOf("/");
if (index == -1) {
return errorMessage;
......@@ -120,6 +123,8 @@ public class BoolExpressionEvaluator {
return false;
}
_expr = Conversion.replaceAllString(_expr, "true", "t").trim();
_expr = Conversion.replaceAllString(_expr, "false", "f").trim();
_expr = Conversion.replaceAllString(_expr, "||", "|").trim();
_expr = Conversion.replaceAllString(_expr, "&&", "&").trim();
_expr = Conversion.replaceAllString(_expr, "or", "|").trim();
......
......@@ -88,6 +88,7 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JFrame im
private static int selectedRun = 1;
private static int selectedCompile = 0;
private static int selectedViewTrace = 0;
private static boolean static_putUserCode = true;
......@@ -122,7 +123,7 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JFrame im
protected JTextField code1, code2, compiler1, compiler2, exe1, exe2, exe3, exe4, exe2int, simulationTraceFile, simulationsoclibTraceFile;
protected JTabbedPane jp1;
protected JScrollPane jsp;
protected JCheckBox removeCFiles, removeXFiles, debugmode, tracemode, optimizemode;
protected JCheckBox removeCFiles, removeXFiles, debugmode, tracemode, optimizemode, putUserCode;
protected JComboBox versionCodeGenerator, units;
protected JButton showSimulationTrace;
......@@ -263,6 +264,10 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JFrame im
optimizemode = new JCheckBox("Optimize code");
optimizemode.setSelected(optimizeModeSelected);
jp01.add(optimizemode, c01);
putUserCode = new JCheckBox("Include user code");
putUserCode.setSelected(static_putUserCode);
jp01.add(putUserCode, c01);
jp01.add(new JLabel("1 time unit ="), c01);
......@@ -472,6 +477,7 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JFrame im
removeXFilesValue = removeXFiles.isSelected();
debugValue = debugmode.isSelected();
tracingValue = tracemode.isSelected();
static_putUserCode = putUserCode.isSelected();
dispose();
}
......@@ -597,6 +603,7 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JFrame im
jta.append("Error: No AVATAR specification\n");
} else {
AVATAR2CPOSIX avatartocposix = new AVATAR2CPOSIX(avspec);
avatartocposix.includeUserCode(putUserCode.isSelected());
avatartocposix.setTimeUnit(selectedUnit);
avatartocposix.generateCPOSIX(debugmode.isSelected(), tracemode.isSelected());
testGo();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment