X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=ric_robot_suite%2Fric-python-utils%2Fricutils%2FE2SimUtils.py;h=409ad65360614b81c7cf1e29f672d78138d1ee25;hb=ca6b81bb15b879eff50598350b018946f2e3dced;hp=d5f3fa18c6bd4d7a4ecad8cdb864edd7d31eae0d;hpb=c5fa07bcd8cbd614bcd813cac698385b789bcfcb;p=it%2Ftest.git diff --git a/ric_robot_suite/ric-python-utils/ricutils/E2SimUtils.py b/ric_robot_suite/ric-python-utils/ricutils/E2SimUtils.py index d5f3fa1..409ad65 100644 --- a/ric_robot_suite/ric-python-utils/ricutils/E2SimUtils.py +++ b/ric_robot_suite/ric-python-utils/ricutils/E2SimUtils.py @@ -56,3 +56,22 @@ class E2SimUtils(object): def randomRANName(self, prefix=""): prefix = prefix + ''.join(random.choice(string.ascii_uppercase) for _ in range(4-(min(4, len(prefix))))) return prefix[0:4].upper() + ''.join(random.choice(string.digits) for _ in range(6)) + + def TranslategNodeBID(self, prefix, plmn, bits): + # given a gNodeB type prefix, a plmn (as a string, no spaces), and a bitstring + # return a gNodeB ID + plmn = ''.join(filter(lambda c: c in list(string.hexdigits), plmn)) + bits = ''.join(filter(lambda c: c in ['0', '1'], bits)) + mnc3 = (int(plmn[2:4],16) & 0xf0) >> 4 + if mnc3 == 15: + return '%s:%d%d%d-0%d%d-%x' % \ + (prefix,\ + int(plmn[0:2],16) & 0xf, (int(plmn[0:2],16) & 0xf0) >> 4, int(plmn[2:4],16) & 0xf,\ + int(plmn[4:6],16) & 0x0f, (int(plmn[4:6],16) & 0xf0) >> 4, \ + int((bits + "0" * (len(bits)%4)),2)) + else: + return '%s:%d%d%d-%d%d%d-%x' % \ + (prefix,\ + int(plmn[0:2],16) & 0xf, (int(plmn[0:2],16) & 0xf0) >> 4, int(plmn[2:4],16) & 0xf,\ + int(plmn[4:6],16) & 0x0f, (int(plmn[4:6],16) & 0xf0) >> 4, mnc3,\ + int((bits + "0" * (len(bits)%4)),2))