detect and pass band information to the map
This commit is contained in:
32
owrx/bands.py
Normal file
32
owrx/bands.py
Normal file
@ -0,0 +1,32 @@
|
||||
import json
|
||||
|
||||
|
||||
class Band(object):
|
||||
def __init__(self, dict):
|
||||
self.name = dict["name"]
|
||||
self.lower_bound = dict["lower_bound"]
|
||||
self.upper_bound = dict["upper_bound"]
|
||||
|
||||
def inBand(self, freq):
|
||||
return self.lower_bound <= freq <= self.upper_bound
|
||||
|
||||
def getName(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Bandplan(object):
|
||||
sharedInstance = None
|
||||
@staticmethod
|
||||
def getSharedInstance():
|
||||
if Bandplan.sharedInstance is None:
|
||||
Bandplan.sharedInstance = Bandplan()
|
||||
return Bandplan.sharedInstance
|
||||
|
||||
def __init__(self):
|
||||
f = open("bands.json", "r")
|
||||
bands_json = json.load(f)
|
||||
f.close()
|
||||
self.bands = [Band(d) for d in bands_json]
|
||||
|
||||
def findBand(self, freq):
|
||||
return next(band for band in self.bands if band.inBand(freq))
|
Reference in New Issue
Block a user