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() self.handleSdrAvailable()
def onFail(self): def onFail(self):
self.handleSdrFailed()
def handleSdrFailed(self):
logger.warning('SDR device "%s" has failed, selecting new device', self.sdr.getName()) 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.write_log_message('SDR device "{0}" has failed, selecting new device'.format(self.sdr.getName()))
self.setSdr() 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: def getClientClass(self) -> SdrClientClass:
return SdrClientClass.USER return SdrClientClass.USER

View File

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

View File

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

View File

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