Commit 30aee062 authored by Nils Kaminski's avatar Nils Kaminski
Browse files

Test is connected before execution

parent 0513eea3
......@@ -46,6 +46,20 @@ public class ExecuteInstruction implements Instruction {
return threadName;
}
protected String addConditionIfDynamic(String exec){
if(isDynamic()){
String inst = componentName.substring(0, componentName.indexOf("["));
String id = componentName.substring(componentName.indexOf("[")+1, componentName.lastIndexOf("]"));
return String.format("if(_%s_connected[%s]){%s}", inst, id, exec);
}
return exec;
}
@Override
public String getTargetLanguageInstruction() {
String result = "";
......@@ -54,17 +68,15 @@ public class ExecuteInstruction implements Instruction {
//this.threadName = "thread" + threadCounter;
result += "std::thread "+ threadName + "( [ this ] {";
//++threadCounter;
result += "this->" + componentName + ".execute();});\n";
return result;
}
//OLD: result += "this->" + componentName + ".execute();});\n";
result += addConditionIfDynamic("this->"+componentName+".execute();");
result += "});\n";
if(dynamic){
return String.format("if(true){ executeDynamicConnects(&%s); %s.execute();}\n",
componentName, componentName);
return result;
}
return componentName + ".execute();\n";
return addConditionIfDynamic(componentName + ".execute();")+"\n";
}
@Override
......
......@@ -29,6 +29,7 @@ public class DynamicPortConnectDynamicInstanceTest extends AbstractSymtabTest {
GeneratorCPP generatorCPP = new GeneratorCPP();
generatorCPP.useArmadilloBackend();
generatorCPP.setGenerationTargetPath(target);
// generatorCPP.setUseThreadingOptimization(true);
List<File> files = generatorCPP.generateFiles(symtab, componentSymbol, symtab);
}catch (IOException ex){
ex.printStackTrace();
......
......@@ -15,6 +15,9 @@ dynamic component Test1{
instance PassThrough pt[1:3];
connect a[1] -> pt[1].in1;
connect pt[1].out1 -> b[1];
@ a::connect && b::connect {
connect a[?] -> pt[?].in1;
connect pt[?].out1 -> b[?];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment