Commit ac911a59 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+added support for timers



Change-Id: I5288e096952d58f6a268143ade9459a05cc9d7ce
Signed-off-by: Philip Makedonski's avatarmakedonski <makedonski@informatik.uni-goettingen.de>
parent 78f3b883
......@@ -1514,28 +1514,63 @@ operation TDL!Block executeAltBlock() : TTCN!GuardStatement {
gs.block = new TTCN!StatementBlock();
//naive assumption
var cf = self.behaviour.first().getMainContext(self.behaviour.first().target.first().targetGate.component);
stack.get(cf).add(gs.block);
var i = 0;
for (b in self.behaviour) {
if (i==0) {
if (b.isKindOf(TDL!Interaction)) {
gs.op = b.getGuardOp();
if (self.behaviour.first().isKindOf(TDL!Interaction)) {
var cf = self.behaviour.first().getMainContext(self.behaviour.first().target.first().targetGate.component);
stack.get(cf).add(gs.block);
var i = 0;
for (b in self.behaviour) {
if (i==0) {
//this should be redundant now
if (b.isKindOf(TDL!Interaction)) {
gs.op = b.getGuardOp();
} else {
//TODO: handle other behaviours?
}
} else {
b.execute();
}
i = i+1;
}
stack.get(cf).remove(gs.block);
} else if (self.behaviour.first().isKindOf(TDL!TimeOut)) {
var cf = self.behaviour.first().getMainContext(self.behaviour.first().componentInstance);
stack.get(cf).add(gs.block);
var i = 0;
for (b in self.behaviour) {
if (i==0) {
//this should be redundant now
if (b.isKindOf(TDL!TimeOut)) {
gs.op = b.getGuardOp();
} else {
//TODO: handle other behaviours?
}
} else {
//TODO: handle other behaviours?
b.execute();
}
} else {
b.execute();
i = i+1;
}
i = i+1;
stack.get(cf).remove(gs.block);
} else {
//TODO
}
stack.get(cf).remove(gs.block);
//TODO: statement block
return gs;
}
operation TDL!TimeOut getGuardOp() : TTCN!GuardOp {
var op = new TTCN!GuardOp();
op.timeout = new TTCN!TimeoutStatement();
op.timeout.ref = new TTCN!TimerRefOrAny();
op.timeout.ref.ref = self.timer.equivalent();
return op;
}
operation TDL!Interaction getGuardOp() : TTCN!GuardOp {
var op = new TTCN!GuardOp();
op.receive = new TTCN!ReceiveStatement();
......@@ -1874,6 +1909,71 @@ operation TDL!CompoundBehaviour execute() {
}
operation TDL!TimerStart execute() {
var ci = self.componentInstance;
if (simulateSUT or ci.role = TDL!ComponentInstanceRole#Tester) {
var sc = self.getMainContext(ci);
var sb = stack.get(sc).last();
var ssl = new TTCN!FunctionStatementList();
var sfs = new TTCN!FunctionStatement();
sfs.timer = new TTCN!TimerStatements();
sfs.timer.start = new TTCN!StartTimerStatement();
sfs.timer.start.ref = self.timer.equivalent();
sfs.timer.start.expr = self.period.getDataUseValue();
ssl.statements.add(sfs);
ssl.sc.add(";");
sb.stat.add(ssl);
}
}
operation TDL!TimerStop execute() {
var ci = self.componentInstance;
if (simulateSUT or ci.role = TDL!ComponentInstanceRole#Tester) {
var sc = self.getMainContext(ci);
var sb = stack.get(sc).last();
var ssl = new TTCN!FunctionStatementList();
var sfs = new TTCN!FunctionStatement();
sfs.timer = new TTCN!TimerStatements();
sfs.timer.stop = new TTCN!StopTimerStatement();
sfs.timer.stop.ref = new TTCN!TimerRefOrAll();
sfs.timer.stop.ref.ref = self.timer.equivalent();
ssl.statements.add(sfs);
ssl.sc.add(";");
sb.stat.add(ssl);
}
}
operation TDL!TimeOut execute() {
//TODO: handle in an alt statement?
var ci = self.componentInstance;
if (simulateSUT or ci.role = TDL!ComponentInstanceRole#Tester) {
var sc = self.getMainContext(ci);
var sb = stack.get(sc).last();
var ssl = new TTCN!FunctionStatementList();
var sfs = new TTCN!FunctionStatement();
sfs.timer = new TTCN!TimerStatements();
sfs.timer.timeout = new TTCN!TimeoutStatement();
sfs.timer.timeout.ref = new TTCN!TimerRefOrAny();
sfs.timer.timeout.ref.ref = self.timer.equivalent();
ssl.statements.add(sfs);
ssl.sc.add(";");
sb.stat.add(ssl);
}
}
operation TDL!Behaviour execute() {
(" Skipping " +self.type.name+" (not yet supported)").println();
if (self.type.name = "ParallelBehaviour" and false) {
......
Markdown is supported
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