diff --git a/scriptsapi/qo100_datv.py b/scriptsapi/qo100_datv.py index 673d131ce..c938dd105 100755 --- a/scriptsapi/qo100_datv.py +++ b/scriptsapi/qo100_datv.py @@ -3,15 +3,17 @@ Quick control of configuration for receiving QO-100 DATV """ -import requests, traceback, sys, json, time -from optparse import OptionParser +import traceback +import sys +from optparse import OptionParser # pylint: disable=deprecated-module +import requests import sdrangel -base_url_pattern = "http://{0}/sdrangel" -base_url = None +BASE_URL_PATTERN = "http://{0}/sdrangel" +BASE_URL = None # ====================================================================== -def getInputOptions(): +def get_input_options(): """ Parse options """ # ---------------------------------------------------------------------- parser = OptionParser(usage="usage: %%prog [-t]\n") @@ -37,115 +39,122 @@ def getInputOptions(): return options -# ====================================================================== -def change_center_frequency(content, new_frequency): - """ Change center frequency searching recursively """ -# ---------------------------------------------------------------------- - for k in content: - if isinstance(content[k], dict): - change_center_frequency(content[k], new_frequency) - elif k == "centerFrequency": - content[k] = new_frequency +class Controller: + """ Controller main class """ + def __init__(self): + self.device_hwid = None -# ====================================================================== -def change_decim(content, new_decim): - """ Change log2 decimation searching recursively """ -# ---------------------------------------------------------------------- - for k in content: - if isinstance(content[k], dict): - change_decim(content[k], new_decim) - elif k == "log2Decim": - content[k] = new_decim -# ====================================================================== -def change_rfbw(content, new_rfbw): - """ Change RF bandwidth searching recursively """ -# ---------------------------------------------------------------------- - for k in content: - if isinstance(content[k], dict): - change_rfbw(content[k], new_rfbw) - elif k == "rfBandwidth": - content[k] = new_rfbw + # ====================================================================== + def change_center_frequency(self, content, new_frequency): + """ Change center frequency searching recursively """ + # ---------------------------------------------------------------------- + for k in content: + if isinstance(content[k], dict): + self.change_center_frequency(content[k], new_frequency) + elif k == "centerFrequency": + content[k] = new_frequency -# ====================================================================== -def change_symbol_rate(content, new_symbol_rate): - """ Change symbol rate searching recursively """ -# ---------------------------------------------------------------------- - for k in content: - if isinstance(content[k], dict): - change_symbol_rate(content[k], new_symbol_rate) - elif k == "symbolRate": - content[k] = new_symbol_rate + # ====================================================================== + def change_decim(self, content, new_decim): + """ Change log2 decimation searching recursively """ + # ---------------------------------------------------------------------- + for k in content: + if isinstance(content[k], dict): + self.change_decim(content[k], new_decim) + elif k == "log2Decim": + content[k] = new_decim -# ====================================================================== -def get_device_sr_and_decim(hwtype, settings): - """ Return device sample rate and decimation """ -# ---------------------------------------------------------------------- - if hwtype == "Airspy" or hwtype == "AirspyHF": - sr_index = settings.get("devSampleRateIndex", 0) - if sr_index == 1: - sr = 3000000 + # ====================================================================== + def change_rfbw(self, content, new_rfbw): + """ Change RF bandwidth searching recursively """ + # ---------------------------------------------------------------------- + for k in content: + if isinstance(content[k], dict): + self.change_rfbw(content[k], new_rfbw) + elif k == "rfBandwidth": + content[k] = new_rfbw + + # ====================================================================== + def change_symbol_rate(self, content, new_symbol_rate): + """ Change symbol rate searching recursively """ + # ---------------------------------------------------------------------- + for k in content: + if isinstance(content[k], dict): + self.change_symbol_rate(content[k], new_symbol_rate) + elif k == "symbolRate": + content[k] = new_symbol_rate + + # ====================================================================== + def get_device_sr_and_decim(self, hwtype, settings): + """ Return device sample rate and decimation """ + # ---------------------------------------------------------------------- + if hwtype == "Airspy" or hwtype == "AirspyHF": + sr_index = settings.get("devSampleRateIndex", 0) + if sr_index == 1: + sr = 3000000 + else: + sr = 6000000 + log2_decim = settings.get("log2Decim", 0) else: - sr = 6000000 - log2_decim = settings.get("log2Decim", 0) - else: - sr = settings.get("devSampleRate", 0) - log2_decim = settings.get("log2Decim", 0) - return sr, 1<