library/IPA_Types: WIP codec for IPA UnitID (site/bts/trx)

Change-Id: I68eb0d9e28bbf5d2d8ffe916aae5a66a0fdb9bd0
This commit is contained in:
Vadim Yanitskiy 2020-05-25 23:37:00 +07:00
parent efc9413afc
commit e54102cc8d
1 changed files with 40 additions and 0 deletions

View File

@ -131,5 +131,45 @@ with { extension "prototype(convert)"
extension "decode(RAW)"
}
/* Example: 1234/0/1 (site 1234, BTS#0, TRX#0) */
type record IpaUnitId {
integer site_id,
integer bts_id,
integer trx_id
} with {
encode "TEXT"
variant "SEPARATOR('/', '/')"
};
external function enc_IpaUnitId(in IpaUnitId unit_id) return charstring
with { extension "prototype(convert) encode(TEXT)" }
external function dec_IpaUnitId(in charstring stream) return IpaUnitId
with { extension "prototype(convert) decode(TEXT)" }
template (value) IpaUnitId ts_IpaUnitId(integer site_id := 1234,
integer bts_id := 0,
integer trx_id := 0) := {
site_id := site_id,
bts_id := bts_id,
trx_id := trx_id
};
template IpaUnitId tr_IpaUnitId(template (present) integer site_id := ?,
template (present) integer bts_id := ?,
template (present) integer trx_id := ?) := {
site_id := site_id,
bts_id := bts_id,
trx_id := trx_id
};
private type component Dummy_CT { };
testcase TC_selftest_IpaUnitId() runs on Dummy_CT {
var IpaUnitId unit_id := valueof(ts_IpaUnitId(1234, 0, 3));
var charstring unit_id_enc := enc_IpaUnitId(unit_id);
log("Enc: ", unit_id_enc);
log("Dec: ", dec_IpaUnitId(unit_id_enc & "\00"));
}
} with { encode "RAW" }