Testing OP25 Improvements

- New system of handling thread
This commit is contained in:
Logan Cusano
2022-03-19 01:18:45 -04:00
parent 4f230f8d33
commit 126ba907af
2 changed files with 31 additions and 8 deletions

6
bot.py
View File

@@ -312,6 +312,7 @@ class Bot(commands.Bot):
print("Starting OP25 handler")
from op25Handler import OP25Handler
self.OP25Handler = OP25Handler()
self.OP25Handler.start()
self.possible_modes = BotResources.PDB_ACCEPTABLE_HANDLERS['op25']['Modes']
# Load the proper OPUS library for the device being used
@@ -399,8 +400,7 @@ class Bot(commands.Bot):
self.GQRXHandler.set_all_settings(self.mode, self.squelch, self.freq)
elif self.Handler == 'op25':
self.OP25Handler.set_op25_parameters(self.freq)
self.OP25Handler.start()
self.OP25Handler.set_op25_parameters(self.freq, _start=True)
# Set the started variable for later checks
self.sdr_started = True
@@ -411,7 +411,7 @@ class Bot(commands.Bot):
# Wait for the running processes to close
# Close the OP25 handler
if self.Handler == 'op25':
self.OP25Handler.close_op25()
self.OP25Handler.set_op25_parameters(_stop=True)
# self.OP25Handler.join()
# Need a way to 'close' GQRX
self.sdr_started = False

View File

@@ -15,14 +15,37 @@ class OP25Handler(threading.Thread):
self.HTTP_ENABLED = False
#def start(self) -> None:
self.Start_OP25 = False
self.Stop_OP25 = False
def run(self) -> None:
self.open_op25()
while True:
if self.Start_OP25:
self.open_op25()
def set_op25_parameters(self, _frequency, _http_enabled: bool = True):
self.Frequency = _frequency
self.Start_OP25 = False
self.Stop_OP25 = False
self.HTTP_ENABLED = _http_enabled
while not self.Stop_OP25:
time.sleep(1)
self.close_op25()
time.sleep(.5)
def set_op25_parameters(self, _frequency: str = False, _http_enabled: bool = True, _start: bool = False, _stop: bool = False):
if _frequency:
self.Frequency = _frequency
if _start:
self.Start_OP25 = _start
if _stop:
self.Stop_OP25 = _stop
if _http_enabled:
self.HTTP_ENABLED = _http_enabled
def open_op25(self):
if self.OP25Proc is not None: