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 { ...@@ -46,6 +46,20 @@ public class ExecuteInstruction implements Instruction {
return threadName; 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 @Override
public String getTargetLanguageInstruction() { public String getTargetLanguageInstruction() {
String result = ""; String result = "";
...@@ -54,17 +68,15 @@ public class ExecuteInstruction implements Instruction { ...@@ -54,17 +68,15 @@ public class ExecuteInstruction implements Instruction {
//this.threadName = "thread" + threadCounter; //this.threadName = "thread" + threadCounter;
result += "std::thread "+ threadName + "( [ this ] {"; result += "std::thread "+ threadName + "( [ this ] {";
//++threadCounter; //++threadCounter;
result += "this->" + componentName + ".execute();});\n";
return result; //OLD: result += "this->" + componentName + ".execute();});\n";
} result += addConditionIfDynamic("this->"+componentName+".execute();");
result += "});\n";
if(dynamic){ return result;
return String.format("if(true){ executeDynamicConnects(&%s); %s.execute();}\n",
componentName, componentName);
} }
return componentName + ".execute();\n"; return addConditionIfDynamic(componentName + ".execute();")+"\n";
} }
@Override @Override
......
...@@ -29,6 +29,7 @@ public class DynamicPortConnectDynamicInstanceTest extends AbstractSymtabTest { ...@@ -29,6 +29,7 @@ public class DynamicPortConnectDynamicInstanceTest extends AbstractSymtabTest {
GeneratorCPP generatorCPP = new GeneratorCPP(); GeneratorCPP generatorCPP = new GeneratorCPP();
generatorCPP.useArmadilloBackend(); generatorCPP.useArmadilloBackend();
generatorCPP.setGenerationTargetPath(target); generatorCPP.setGenerationTargetPath(target);
// generatorCPP.setUseThreadingOptimization(true);
List<File> files = generatorCPP.generateFiles(symtab, componentSymbol, symtab); List<File> files = generatorCPP.generateFiles(symtab, componentSymbol, symtab);
}catch (IOException ex){ }catch (IOException ex){
ex.printStackTrace(); ex.printStackTrace();
......
...@@ -15,6 +15,9 @@ dynamic component Test1{ ...@@ -15,6 +15,9 @@ dynamic component Test1{
instance PassThrough pt[1:3]; instance PassThrough pt[1:3];
connect a[1] -> pt[1].in1;
connect pt[1].out1 -> b[1];
@ a::connect && b::connect { @ a::connect && b::connect {
connect a[?] -> pt[?].in1; connect a[?] -> pt[?].in1;
connect pt[?].out1 -> b[?]; 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