Tiny refactoring of active services display.
This commit is contained in:
parent
044ed9b261
commit
49f24a7598
|
|
@ -37,12 +37,8 @@ class ServiceController(AuthorizationMixin, WebpageController):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def renderService(c):
|
def renderService(c):
|
||||||
# Choose units based on frequency
|
# Choose units based on frequency
|
||||||
mode = c["mode"]
|
|
||||||
freq = c["freq"]
|
freq = c["freq"]
|
||||||
if freq is None:
|
if freq >= 1000000000:
|
||||||
freq = ""
|
|
||||||
unit = ""
|
|
||||||
elif freq >= 1000000000:
|
|
||||||
freq = freq / 1000000000
|
freq = freq / 1000000000
|
||||||
unit = "GHz"
|
unit = "GHz"
|
||||||
elif freq >= 30000000:
|
elif freq >= 30000000:
|
||||||
|
|
@ -55,8 +51,7 @@ class ServiceController(AuthorizationMixin, WebpageController):
|
||||||
unit = "Hz"
|
unit = "Hz"
|
||||||
# Removing trailing zeros, converting mode to upper case
|
# Removing trailing zeros, converting mode to upper case
|
||||||
freq = re.sub(r"\.?0+$", "", "{0}".format(freq))
|
freq = re.sub(r"\.?0+$", "", "{0}".format(freq))
|
||||||
mode = "???" if mode is None else mode.upper()
|
|
||||||
# Format row
|
# Format row
|
||||||
return "<tr><td>{0}</td><td>{1} {2}</td><td>{3}{4}</td></tr>".format(
|
return "<tr><td>{0}</td><td>{1} {2}</td><td>{3}{4}</td></tr>".format(
|
||||||
mode, c["sdr"], c["band"], freq, unit
|
c["mode"].upper(), c["sdr"], c["band"], freq, unit
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -403,10 +403,13 @@ class Services(object):
|
||||||
band = handler.source.getProfileName()
|
band = handler.source.getProfileName()
|
||||||
for service in handler.services:
|
for service in handler.services:
|
||||||
if isinstance(service, ServiceDemodulatorChain):
|
if isinstance(service, ServiceDemodulatorChain):
|
||||||
result.append({
|
freq = service.getFrequency()
|
||||||
"sdr" : sdr,
|
mode = service.getMode()
|
||||||
"band" : band,
|
if freq and mode:
|
||||||
"freq" : service.getFrequency(),
|
result.append({
|
||||||
"mode" : service.getMode()
|
"sdr" : sdr,
|
||||||
})
|
"band" : band,
|
||||||
|
"freq" : freq,
|
||||||
|
"mode" : mode
|
||||||
|
})
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue