aboutsummaryrefslogtreecommitdiffstats
path: root/library/CBSP_Types.ttcn
diff options
context:
space:
mode:
Diffstat (limited to 'library/CBSP_Types.ttcn')
-rw-r--r--library/CBSP_Types.ttcn19
1 files changed, 19 insertions, 0 deletions
diff --git a/library/CBSP_Types.ttcn b/library/CBSP_Types.ttcn
index c4c6cf25..5ab3c98b 100644
--- a/library/CBSP_Types.ttcn
+++ b/library/CBSP_Types.ttcn
@@ -378,5 +378,24 @@ external function enc_CBSP_PDU(in CBSP_PDU msg) return octetstring
external function dec_CBSP_PDU(in octetstring msg) return CBSP_PDU
with { extension "prototype(convert) decode(RAW)" };
+/* convert from warning period encoding to seconds */
+function f_cbsp_period2s(uint8_t period) return integer
+{
+ if (period == 0) {
+ return -1; /* infinite */
+ } else if (period <= 10) {
+ return period;
+ } else if (period <= 20) {
+ return 10 + (period - 10)*2;
+ } else if (period <= 38) {
+ return 30 + (period - 20)*5;
+ } else if (period <= 86) {
+ return 120 + (period - 38)*10;
+ } else if (period <= 186) {
+ return 600 + (period - 86)*30;
+ } else {
+ return 0;
+ }
+}
} with { encode "RAW"; variant "FIELDORDER(msb)" }