mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Work in progress
This commit is contained in:
parent
dbd1cf1d98
commit
395e505b84
5 changed files with 17 additions and 11 deletions
|
@ -3,18 +3,20 @@ from modem.modem import RF
|
|||
|
||||
class TxCommand():
|
||||
|
||||
def __init__(self, modem: RF, apiParams):
|
||||
def __init__(self, apiParams):
|
||||
self.setParamsFromApi(apiParams)
|
||||
self.modem = modem
|
||||
self.frame_factory = DataFrameFactory(modem)
|
||||
|
||||
def setParamsFromApi(self, apiParams):
|
||||
pass
|
||||
|
||||
def getName(self):
|
||||
return type(self).__name__
|
||||
|
||||
def getPayload(self):
|
||||
pass
|
||||
|
||||
def execute(self, modem):
|
||||
def execute(self, modem_state, tx_frame_queue):
|
||||
pass
|
||||
|
||||
def transmit(self, frame):
|
||||
|
|
|
@ -6,6 +6,10 @@ class PingCommand(TxCommand):
|
|||
self.dxcall = apiParams['dxcall']
|
||||
return super().setParamsFromApi()
|
||||
|
||||
def execute(self):
|
||||
self.frame_factory.build_ping(self.dxcall)
|
||||
def execute(self, modem_state, tx_frame_queue):
|
||||
frame = self.frame_factory.build_ping(self.dxcall)
|
||||
|
||||
|
||||
return super().execute(modem_state, tx_frame_queue)
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ class DataFrameFactory:
|
|||
fec_frame[1:7] = helpers.callsign_to_bytes(self.myfullcall)
|
||||
return fec_frame
|
||||
|
||||
def build_qrv(self):
|
||||
def build_qrv(self, snr):
|
||||
qrv_frame = bytearray(self.length_sig0_frame)
|
||||
qrv_frame[:1] = bytes([FR_TYPE.QRV.value])
|
||||
qrv_frame[1:7] = helpers.callsign_to_bytes(self.myfullcall)
|
||||
|
|
|
@ -119,12 +119,12 @@ class DISPATCHER():
|
|||
def worker_transmit(self) -> None:
|
||||
"""Dispatch incoming UI instructions for transmitting operations"""
|
||||
while True:
|
||||
data = self.data_queue_transmit.get()
|
||||
command = self.data_queue_transmit.get()
|
||||
self.log.debug(
|
||||
"[Modem] TX DISPATCHER - got a transmit command",
|
||||
command=data,
|
||||
command=command.getName(),
|
||||
)
|
||||
|
||||
command.execute()
|
||||
|
||||
|
||||
# Dispatch commands known to command_dispatcher
|
||||
|
|
|
@ -77,7 +77,7 @@ def validate(req, param, validator, isRequired = True):
|
|||
|
||||
# Takes a transmit command and puts it in the transmit command queue
|
||||
def enqueue_tx_command(cmd_class, params = {}):
|
||||
command = cmd_class(modem, params)
|
||||
command = cmd_class(service_manager.modem, params)
|
||||
tx_cmd_queue.put(command)
|
||||
app.logger.info(f"Command {type(command).__name__} enqueued.")
|
||||
|
||||
|
|
Loading…
Reference in a new issue