summaryrefslogtreecommitdiffstats
path: root/library/NS_Emulation.ttcnpp
diff options
context:
space:
mode:
Diffstat (limited to 'library/NS_Emulation.ttcnpp')
-rw-r--r--library/NS_Emulation.ttcnpp46
1 files changed, 40 insertions, 6 deletions
diff --git a/library/NS_Emulation.ttcnpp b/library/NS_Emulation.ttcnpp
index e286945..7958938 100644
--- a/library/NS_Emulation.ttcnpp
+++ b/library/NS_Emulation.ttcnpp
@@ -73,25 +73,30 @@ module NS_Emulation {
Nsei nsei,
Nsvci nsvci,
NsvcState old_state,
- NsvcState new_state
+ NsvcState new_state,
+ boolean first_or_last
}
template (present) NsStatusIndication tr_NsStsInd(template (present) Nsei nsei := ?,
template (present) Nsvci nsvci := ?,
template (present) NsvcState old_state := ?,
- template (present) NsvcState state := ?) := {
+ template (present) NsvcState state := ?,
+ template (present) boolean first_or_last := ?) := {
nsei := nsei,
nsvci := nsvci,
old_state := old_state,
- new_state := state
+ new_state := state,
+ first_or_last := first_or_last
}
- template (value) NsStatusIndication ts_NsStsInd(Nsei nsei, Nsvci nsvci, NsvcState old_state, NsvcState state) := {
+ template (value) NsStatusIndication ts_NsStsInd(Nsei nsei, Nsvci nsvci, NsvcState old_state, NsvcState state,
+ boolean first_or_last := false) := {
nsei := nsei,
nsvci := nsvci,
old_state := old_state,
- new_state := state
+ new_state := state,
+ first_or_last := first_or_last
}
type enumerated NsvcState {
@@ -247,12 +252,41 @@ module NS_Emulation {
}
}
+ function f_count_nsvcs_in_state(template NsvcState state := ?) runs on NS_CT return integer {
+ var integer i;
+ var integer res := 0;
+ for (i := 0; i < lengthof(g_nsvcs); i := i+1) {
+ if (match(g_nsvcs[i].state, state)) {
+ res := res + 1;
+ }
+ }
+ return res;
+ }
+
private altstep as_ns_common() runs on NS_CT {
var NsStatusIndication rx_nssi;
var NsUnitdataIndication rx_nsudi;
var NsUnitdataRequest rx_nsudr;
/* pass from NS-VCs up to user */
- [] NSVC.receive(tr_NsStsInd(g_config.nsei)) -> value rx_nssi {
+ [] NSVC.receive(tr_NsStsInd(g_config.nsei, ?, ?, NSVC_S_ALIVE_UNBLOCKED)) -> value rx_nssi {
+ /* check if this one is the first to be unblocked */
+ var integer num_nsvc_unblocked := f_count_nsvcs_in_state(NSVC_S_ALIVE_UNBLOCKED);
+ f_nsvc_update_state(rx_nssi.nsvci, rx_nssi.new_state);
+ if (num_nsvc_unblocked == 0) {
+ rx_nssi.first_or_last := true;
+ }
+ NS_SP.send(rx_nssi);
+ }
+ [] NSVC.receive(tr_NsStsInd(g_config.nsei, ?, ?, NSVC_S_DEAD_BLOCKED)) -> value rx_nssi {
+ f_nsvc_update_state(rx_nssi.nsvci, rx_nssi.new_state);
+ /* check if this one is the last to be blocked */
+ var integer num_nsvc_unblocked := f_count_nsvcs_in_state(NSVC_S_ALIVE_UNBLOCKED);
+ if (num_nsvc_unblocked == 0) {
+ rx_nssi.first_or_last := true;
+ }
+ NS_SP.send(rx_nssi);
+ }
+ [] NSVC.receive(tr_NsStsInd(g_config.nsei, ?, ?, ?)) -> value rx_nssi {
f_nsvc_update_state(rx_nssi.nsvci, rx_nssi.new_state);
NS_SP.send(rx_nssi);
}