introduce enums for state management

This commit is contained in:
Jakob Ketterl
2021-02-20 22:54:07 +01:00
parent dd5ab32b47
commit c2e8ac516c
6 changed files with 86 additions and 75 deletions

View File

@@ -2,7 +2,7 @@ from owrx.config.core import CoreConfig
from owrx.config import Config
from csdr import csdr
import threading
from owrx.source import SdrSource, SdrSourceEventClient
from owrx.source import SdrSourceEventClient, SdrSourceState, SdrBusyState, SdrClientClass
from owrx.property import PropertyStack
import logging
@@ -73,14 +73,14 @@ class SpectrumThread(csdr.output, SdrSourceEventClient):
c.cancel()
self.subscriptions = []
def getClientClass(self):
return SdrSource.CLIENT_USER
def getClientClass(self) -> SdrClientClass:
return SdrClientClass.USER
def onStateChange(self, state):
if state in [SdrSource.STATE_STOPPING, SdrSource.STATE_FAILED]:
def onStateChange(self, state: SdrSourceState):
if state in [SdrSourceState.STOPPING, SdrSourceState.FAILED]:
self.dsp.stop()
elif state == SdrSource.STATE_RUNNING:
elif state is SdrSourceState.RUNNING:
self.dsp.start()
def onBusyStateChange(self, state):
def onBusyStateChange(self, state: SdrBusyState):
pass