lib/CTRL: Improve and add more helper templates and functions
Change-Id: Icc6ac860ebd6a719f9e0cb5c5345fb4d39a864ce
This commit is contained in:
parent
5a2d743e5d
commit
579cd7a406
|
@ -71,10 +71,16 @@ module Osmocom_CTRL_Functions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* send a TRAP */
|
||||||
|
function f_ctrl_trap(IPA_CTRL_PT pt, CtrlVariable variable, CtrlValue val) {
|
||||||
|
pt.send(ts_CtrlMsgTrap(variable, val));
|
||||||
|
}
|
||||||
|
|
||||||
/* Expect a matching TRAP */
|
/* Expect a matching TRAP */
|
||||||
function f_ctrl_exp_trap(IPA_CTRL_PT pt, template CtrlVariable variable,
|
function f_ctrl_exp_trap(IPA_CTRL_PT pt, template CtrlVariable variable,
|
||||||
template CtrlValue val := ?) return CtrlValue {
|
template CtrlValue val := ?, float timeout_val := 2.0)
|
||||||
timer T := 2.0;
|
return CtrlValue {
|
||||||
|
timer T := timeout_val;
|
||||||
var CtrlMessage rx;
|
var CtrlMessage rx;
|
||||||
T.start;
|
T.start;
|
||||||
alt {
|
alt {
|
||||||
|
@ -88,6 +94,29 @@ module Osmocom_CTRL_Functions {
|
||||||
return rx.trap.val;
|
return rx.trap.val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Expect a matching SET, optionally answer */
|
||||||
|
function f_ctrl_exp_set(IPA_CTRL_PT pt, template CtrlVariable variable,
|
||||||
|
template CtrlValue val := ?,
|
||||||
|
template (omit) CtrlValue rsp := omit,
|
||||||
|
float timeout_val := 2.0)
|
||||||
|
return CtrlValue {
|
||||||
|
timer T := timeout_val;
|
||||||
|
var CtrlMessage rx;
|
||||||
|
T.start;
|
||||||
|
alt {
|
||||||
|
[] pt.receive(tr_CtrlMsgSet(?, variable, val)) -> value rx {
|
||||||
|
if (ispresent(rsp)) {
|
||||||
|
pt.send(ts_CtrlMsgSetRepl(rx.cmd.id, valueof(variable), valueof(rsp)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[] T.timeout {
|
||||||
|
setverdict(fail, "Timeout waiting for SET ", variable);
|
||||||
|
mtc.stop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rx.cmd.val;
|
||||||
|
}
|
||||||
|
|
||||||
/* Expect a matching GET result */
|
/* Expect a matching GET result */
|
||||||
function f_ctrl_get_exp(IPA_CTRL_PT pt, CtrlVariable variable, template CtrlValue exp) {
|
function f_ctrl_get_exp(IPA_CTRL_PT pt, CtrlVariable variable, template CtrlValue exp) {
|
||||||
var charstring ctrl_resp;
|
var charstring ctrl_resp;
|
||||||
|
|
|
@ -94,6 +94,50 @@ template CtrlMessage ts_CtrlMsgSet(CtrlId id, CtrlVariable variable, CtrlValue v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template CtrlMessage ts_CtrlMsgTrap(CtrlVariable variable, template (omit) CtrlValue val := omit) := {
|
||||||
|
trap := {
|
||||||
|
variable := variable,
|
||||||
|
val := val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template CtrlMessage ts_CtrlMsgGetRepl(CtrlId id, CtrlVariable variable, CtrlValue val) := {
|
||||||
|
resp := {
|
||||||
|
verb := "GET_REPLY",
|
||||||
|
id := id,
|
||||||
|
variable := variable,
|
||||||
|
val := val
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template CtrlMessage ts_CtrlMsgSetRepl(CtrlId id, CtrlVariable variable, CtrlValue val) := {
|
||||||
|
resp := {
|
||||||
|
verb := "SET_REPLY",
|
||||||
|
id := id,
|
||||||
|
variable := variable,
|
||||||
|
val := val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template CtrlMessage tr_CtrlMsgGet(template CtrlId id, template CtrlVariable variable := ?) := {
|
||||||
|
cmd := {
|
||||||
|
verb := "GET",
|
||||||
|
id := id,
|
||||||
|
variable := variable,
|
||||||
|
val := ?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template CtrlMessage tr_CtrlMsgSet(template CtrlId id, template CtrlVariable variable := ?,
|
||||||
|
template CtrlValue val := ?) := {
|
||||||
|
cmd := {
|
||||||
|
verb := "SET",
|
||||||
|
id := id,
|
||||||
|
variable := variable,
|
||||||
|
val := val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template CtrlMessage tr_CtrlMsgGetRepl(template CtrlId id, template CtrlVariable variable := ?) := {
|
template CtrlMessage tr_CtrlMsgGetRepl(template CtrlId id, template CtrlVariable variable := ?) := {
|
||||||
resp := {
|
resp := {
|
||||||
verb := "GET_REPLY",
|
verb := "GET_REPLY",
|
||||||
|
|
Loading…
Reference in New Issue