add always-on feature
This commit is contained in:
parent
036442aa69
commit
42828dbf65
@ -37,7 +37,7 @@ class SdrSource(ABC):
|
||||
self.activateProfile()
|
||||
self.rtlProps = self.props.collect(*self.getEventNames()).defaults(PropertyManager.getSharedInstance())
|
||||
self.wireEvents()
|
||||
self.commandMapper = CommandMapper()
|
||||
self.commandMapper = None
|
||||
|
||||
if "port" in props and props["port"] is not None:
|
||||
self.port = props["port"]
|
||||
@ -53,6 +53,12 @@ class SdrSource(ABC):
|
||||
self.state = SdrSource.STATE_STOPPED
|
||||
self.busyState = SdrSource.BUSYSTATE_IDLE
|
||||
|
||||
if self.isAlwaysOn():
|
||||
self.start()
|
||||
|
||||
def isAlwaysOn(self):
|
||||
return "always-on" in self.props and self.props["always-on"]
|
||||
|
||||
def getEventNames(self):
|
||||
return [
|
||||
"samp_rate",
|
||||
@ -63,6 +69,8 @@ class SdrSource(ABC):
|
||||
]
|
||||
|
||||
def getCommandMapper(self):
|
||||
if self.commandMapper is None:
|
||||
self.commandMapper = CommandMapper()
|
||||
return self.commandMapper
|
||||
|
||||
@abstractmethod
|
||||
@ -233,6 +241,10 @@ class SdrSource(ABC):
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# no need to check for users if we are always-on
|
||||
if self.isAlwaysOn():
|
||||
return
|
||||
|
||||
hasUsers = self.hasClients(SdrSource.CLIENT_USER)
|
||||
hasBackgroundTasks = self.hasClients(SdrSource.CLIENT_BACKGROUND)
|
||||
self.setBusyState(SdrSource.BUSYSTATE_BUSY if hasUsers else SdrSource.BUSYSTATE_IDLE)
|
||||
|
@ -3,9 +3,8 @@ from .soapy import SoapyConnectorSource
|
||||
|
||||
|
||||
class AirspySource(SoapyConnectorSource):
|
||||
def __init__(self, id, props):
|
||||
super().__init__(id, props)
|
||||
self.getCommandMapper().setMappings({"bias_tee": Flag("-t biastee=true")})
|
||||
def getCommandMapper(self):
|
||||
return super().getCommandMapper().setMappings({"bias_tee": Flag("-t biastee=true")})
|
||||
|
||||
def getDriver(self):
|
||||
return "airspy"
|
||||
|
@ -10,10 +10,12 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class ConnectorSource(SdrSource):
|
||||
def __init__(self, id, props):
|
||||
super().__init__(id, props)
|
||||
self.controlSocket = None
|
||||
self.controlPort = getAvailablePort()
|
||||
self.getCommandMapper().setMappings(
|
||||
super().__init__(id, props)
|
||||
|
||||
def getCommandMapper(self):
|
||||
return super().getCommandMapper().setMappings(
|
||||
{
|
||||
"samp_rate": Option("-s"),
|
||||
"tuner_freq": Option("-f"),
|
||||
|
@ -8,9 +8,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FifiSdrSource(DirectSource):
|
||||
def __init__(self, id, props):
|
||||
super().__init__(id, props)
|
||||
self.getCommandMapper().setBase("arecord").setMappings(
|
||||
def getCommandMapper(self):
|
||||
return super().getCommandMapper().setBase("arecord").setMappings(
|
||||
{"device": Option("-D"), "samp_rate": Option("-r")}
|
||||
).setStatic("-f S16_LE -c2 -")
|
||||
|
||||
|
@ -3,9 +3,8 @@ from owrx.command import Flag, Option
|
||||
|
||||
|
||||
class HackrfSource(DirectSource):
|
||||
def __init__(self, id, props):
|
||||
super().__init__(id, props)
|
||||
self.getCommandMapper().setBase("hackrf_transfer").setMappings(
|
||||
def getCommandMapper(self):
|
||||
return super().getCommandMapper().setBase("hackrf_transfer").setMappings(
|
||||
{
|
||||
"samp_rate": Option("-s"),
|
||||
"tuner_freq": Option("-f"),
|
||||
|
@ -2,6 +2,5 @@ from .connector import ConnectorSource
|
||||
|
||||
|
||||
class RtlSdrSource(ConnectorSource):
|
||||
def __init__(self, id, props):
|
||||
super().__init__(id, props)
|
||||
self.getCommandMapper().setBase("rtl_connector")
|
||||
def getCommandMapper(self):
|
||||
return super().getCommandMapper().setBase("rtl_connector")
|
||||
|
@ -5,9 +5,8 @@ from .connector import ConnectorSource
|
||||
|
||||
|
||||
class SoapyConnectorSource(ConnectorSource, metaclass=ABCMeta):
|
||||
def __init__(self, id, props):
|
||||
super().__init__(id, props)
|
||||
self.getCommandMapper().setBase("soapy_connector").setMappings({"antenna": Option("-a")})
|
||||
def getCommandMapper(self):
|
||||
return super().getCommandMapper().setBase("soapy_connector").setMappings({"antenna": Option("-a")})
|
||||
|
||||
"""
|
||||
must be implemented by child classes to be able to build a driver-based device selector by default.
|
||||
|
Loading…
Reference in New Issue
Block a user