activate enable / disable cycle

This commit is contained in:
Jakob Ketterl 2021-03-18 19:59:10 +01:00
parent 37e7331627
commit d573561c67
4 changed files with 16 additions and 3 deletions

View File

@ -221,13 +221,15 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
self.handleSdrAvailable()
def onFail(self):
self.handleSdrFailed()
def handleSdrFailed(self):
logger.warning('SDR device "%s" has failed, selecting new device', self.sdr.getName())
self.write_log_message('SDR device "{0}" has failed, selecting new device'.format(self.sdr.getName()))
self.setSdr()
def onDisable(self):
logger.warning('SDR device "%s" was disabled, selecting new device', self.sdr.getName())
self.write_log_message('SDR device "{0}" was disabled, selecting new device'.format(self.sdr.getName()))
self.setSdr()
def getClientClass(self) -> SdrClientClass:
return SdrClientClass.USER

View File

@ -122,6 +122,9 @@ class ServiceHandler(SdrSourceEventClient):
logger.debug("sdr source failed; stopping services.")
self.stopServices()
def onEnable(self):
self._scheduleServiceStartup()
def isSupported(self, mode):
configured = Config.get()["services_decoders"]
available = [m.modulation for m in Modes.getAvailableServices()]

View File

@ -258,6 +258,12 @@ class ServiceScheduler(SdrSourceEventClient):
def onFail(self):
self.shutdown()
def onDisable(self):
self.shutdown()
def onEnable(self):
self.scheduleSelection()
def onBusyStateChange(self, state: SdrBusyState):
if state is SdrBusyState.IDLE:
self.scheduleSelection()

View File

@ -153,6 +153,8 @@ class SdrSource(ABC):
self.enabled = changes["enabled"]
else:
self.enabled = True
if not self.enabled:
self.stop()
for c in self.clients.copy():
if self.isEnabled():
c.onEnable()