Commit f09fa586 authored by Joanne Hugé's avatar Joanne Hugé

wip

parent 5bb62de9
......@@ -59,6 +59,10 @@
"$ref": "cell/common.json#/properties/root_sequence_index",
"default": 204
},
"tx_dbm_power": {
"title": "Tx Power in dBm",
"type": "number"
},
"tx_gain": {
"$ref": "ru/common.json#/properties/tx_gain"
},
......
......@@ -50,18 +50,20 @@ configuration = $${slap-configuration:configuration}
sdr-dir = $${sdr:dir}
init =
import subprocess
default_map = {
DEFAULTS = {
"*": {
"tx_power_dbm": 20,
"rx_gain": 0,
},
"B28": {
"range": "758MHz - 803MHz",
"dl_earfcn": 9550,
"dl_nr_arfcn": 158400,
"nr_band": 28,
"tx_gain": [60, 62],
"rx_gain": [25, 25],
"rf_mode": "fdd",
"power_estimation": (
lambda x: "UNKNOWN",
lambda x: (-0.004711416231164319) * x**2 + (1.5976906979683085) * x + (-67.71316951508676),
[-0.004711416231164319, 1.5976906979683085, -67.71316951508676],
),
},
"B38": {
......@@ -69,12 +71,10 @@ init =
"dl_earfcn": 38050,
"dl_nr_arfcn": 519000,
"nr_band": 41,
"tx_gain": [59, 65],
"rx_gain": [25, 25],
"rf_mode": "tdd",
"power_estimation": (
lambda x: (-0.008712931375092506) * x**2 + (2.1973585140044642) * x + (-94.29420762479742),
lambda x: (-0.004472751640641793) * x**2 + (1.6308290630103919) * x + (-81.84549245154561),
[-0.008712931375092506, 2.1973585140044642, -94.29420762479742],
[-0.004472751640641793, 1.6308290630103919, -81.84549245154561],
),
},
"B39": {
......@@ -82,12 +82,10 @@ init =
"dl_earfcn": 38350,
"dl_nr_arfcn": 378000,
"nr_band": 39,
"tx_gain": [59, 64],
"rx_gain": [25, 25],
"rf_mode": "tdd",
"power_estimation": (
lambda x: (-0.008712931375092506) * x**2 + (2.1973585140044642) * x + (-94.29420762479742),
lambda x: (-0.0022523817802900985) * x**2 + (1.2674016231310092) * x + (-66.57165215468584),
[-0.008712931375092506, 2.1973585140044642, -94.29420762479742],
[-0.0022523817802900985, 1.2674016231310092, -66.57165215468584],
),
},
"B40": {
......@@ -95,12 +93,10 @@ init =
"dl_earfcn": 39150,
"dl_nr_arfcn": 470000,
"nr_band": 40,
"tx_gain": [59, 64],
"rx_gain": [25, 25],
"rf_mode": "tdd",
"power_estimation": (
lambda x: "UNKNOWN",
lambda x: (-0.0016475305254340404) * x**2 + (1.1580162105112186) * x + (-62.10679297527826),
[-0.0016475305254340404, 1.1580162105112186, -62.10679297527826],
),
},
"B41": {
......@@ -108,8 +104,6 @@ init =
"dl_earfcn": 40620,
"dl_nr_arfcn": 518600,
"nr_band": 41,
"tx_gain": [59, 64],
"rx_gain": [25, 25],
"rf_mode": "tdd",
"power_estimation": (
lambda x: "UNKNOWN",
......@@ -121,12 +115,10 @@ init =
"dl_earfcn": 42590,
"dl_nr_arfcn": 632628,
"nr_band": 78,
"tx_gain": [63, 62],
"rx_gain": [25, 25],
"rf_mode": "tdd",
"power_estimation": (
lambda x: (-0.014198126839751619) * x**2 + (2.980758813262773) * x + (-125.25800492285738),
lambda x: (0.003977721774394756) * x**2 + (0.527208191717173) * x + (-42.761142655285376),
[-0.014198126839751619, 2.980758813262773, -125.25800492285738],
[0.003977721774394756, 0.527208191717173, -42.761142655285376],
),
},
"B43": {
......@@ -134,12 +126,10 @@ init =
"dl_earfcn": 44590,
"dl_nr_arfcn": 646666,
"nr_band": 78,
"tx_gain": [63, 62],
"rx_gain": [25, 25],
"rf_mode": "tdd",
"power_estimation": (
lambda x: (-0.014198126839751619) * x**2 + (2.980758813262773) * x + (-125.25800492285738),
lambda x: (-0.0036530114002551943) * x**2 + (1.510856844601873) * x + (-74.58790185136355),
[-0.014198126839751619, 2.980758813262773, -125.25800492285738],
[-0.0036530114002551943, 1.510856844601873, -74.58790185136355],
),
},
"N77": {
......@@ -147,12 +137,10 @@ init =
"dl_earfcn": 0,
"dl_nr_arfcn": 660000,
"nr_band": 77,
"tx_gain": [60, 62],
"rx_gain": [25, 25],
"rf_mode": "tdd",
"power_estimation": (
lambda x: "UNKNOWN",
lambda x: (-0.003358281211508112) * x**2 + (1.4533760798172672) * x + (-70.18774498873421),
[-0.003358281211508112, 1.4533760798172672, -70.18774498873421],
),
},
"N79": {
......@@ -160,12 +148,10 @@ init =
"dl_earfcn": 0,
"dl_nr_arfcn": 720000,
"nr_band": 79,
"tx_gain": [60, 62],
"rx_gain": [25, 25],
"rf_mode": "tdd",
"power_estimation": (
lambda x: "UNKNOWN",
lambda x: (-0.004745509248998074) * x**2 + (1.659474968728413) * x + (-76.46937551110834),
[-0.004745509248998074, 1.659474968728413, -76.46937551110834],
),
},
"UNKNOWN": {
......@@ -173,8 +159,6 @@ init =
"dl_earfcn": 0,
"dl_nr_arfcn": 0,
"nr_band": 0,
"tx_gain": [60, 62],
"rx_gain": [25, 25],
"rf_mode": "tdd",
"power_estimation": (
lambda x: "UNKNOWN",
......@@ -189,29 +173,44 @@ init =
["sudo", "-n", options['sdr-dir'] + "/get-sdr-info", "-" + cmd]
).decode()
version = get_sdr_info('v')
options['version'] = float(version) if version != 'UNKNOWN' else 0
options['band'] = get_sdr_info('b')
options['tdd'] = get_sdr_info('t')
options['one-watt'] = bool(options['version'] >= 4)
options['ors-version'] = "{} {} {}".format(
options.update({
'version' : float(version) if version != 'UNKNOWN' else 0,
'band' : get_sdr_info('b'),
'tdd' : get_sdr_info('t'),
'one-watt': bool(options['version'] >= 4),
'ors-version': = "{} {} {}".format(
options['tdd'],
options['band'],
"2x1W" if options['one-watt'] else "2x0.5W",
)
default_tx_gain = default_map[options['band']]['tx_gain' ][int(options['one-watt'])]
default_rx_gain = default_map[options['band']]['rx_gain' ][int(options['one-watt'])]
default_earfcn = default_map[options['band']]['dl_earfcn' ]
default_nr_arfcn = default_map[options['band']]['dl_nr_arfcn']
default_nr_band = default_map[options['band']]['nr_band' ]
default_rf_mode = default_map[options['band']]['rf_mode' ]
options['range'] = default_map[options['band']]['range']
options['current-tx-gain'] = options['configuration'].get('tx_gain' , default_tx_gain )
options['current-rx-gain'] = options['configuration'].get('rx_gain' , default_rx_gain )
options['current-earfcn'] = options['configuration'].get('dl_earfcn' , default_earfcn )
options['current-nr-arfcn'] = options['configuration'].get('dl_nr_arfcn', default_nr_arfcn)
options['current-nr-band'] = options['configuration'].get('nr_band' , default_nr_band )
options['current-rf-mode'] = options['configuration'].get('rf_mode' , default_rf_mode )
power_estimate_dbm = default_map[options['band']]['power_estimation'][int(options['one-watt'])](float(options['current-tx-gain']))
),
})
band = options['band']
ors_version = int(options['one-watt'])
default_tx_gain = DEFAULTS[band]['tx_gain' ][ors_version]
default_rx_gain = DEFAULTS[band]['rx_gain' ][ors_version]
default_earfcn = DEFAULTS[band]['dl_earfcn' ]
default_nr_arfcn = DEFAULTS[band]['dl_nr_arfcn']
default_nr_band = DEFAULTS[band]['nr_band' ]
default_rf_mode = DEFAULTS[band]['rf_mode' ]
options['range'] = DEFAULTS[band]['range']
def dbm_to_gain(coefficients, x):
if not coefficients:
return None
a, b, c = *coefficients
return (2 * (x - c)) / (math.sqrt(b**2 - 4 * a * (c - x)) + b)
tx_power_dbm = options['configuration'].get('tx_dbm_power' , DEFAULTS['*']['tx_power_dbm'])
options.update({
'tx-gain' : dbm_to_gain(DEFAULTS[band]['power_estimation'][ors_version], tx_power_dbm),
'tx-power' : dbm_to_gain(DEFAULTS[band]['power_estimation'][ors_version], tx_power_dbm),
'rx-gain' : options['configuration'].get('rx_gain' , default_rx_gain ),
'earfcn' : options['configuration'].get('dl_earfcn' , default_earfcn ),
'nr-arfcn': options['configuration'].get('dl_nr_arfcn', default_nr_arfcn),
'nr-band' : options['configuration'].get('nr_band' , default_nr_band ),
'rf-mode' : options['configuration'].get('rf_mode' , default_rf_mode ),
})
power_estimate_dbm = DEFAULTS[options['band']]['power_estimation'][int(options['one-watt'])](float(options['current-tx-gain']))
if power_estimate_dbm == "UNKNOWN":
power_estimate = "Information not available for this band"
else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment