Skip to content

Commit

Permalink
[Application] [Docs] rpitx-control-0.1 application release (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
IgrikXD authored Oct 25, 2023
1 parent 5805110 commit 21e80a9
Show file tree
Hide file tree
Showing 9 changed files with 579 additions and 212 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
__pycache__
SavedConfiguration
SavedConfiguration
*.pkl
*.log
18 changes: 18 additions & 0 deletions AmplifiersList/Amplifiers.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Model Number,Case Style,Subcategories,F Low (MHz),F High (MHz),Gain (dB) Typ.,NF (dB) Typ.,Power Out (dBm) @ 1dB Comp. Typ.,Out. IP3 (dBm) Typ.,Input VSWR (:1) Typ.,Output VSWR (:1) Typ.,Voltage (V),DC Current (mA),Connector Type,Option,Interface,Impedance (Ohms),
GALI-39+,DF782,Low Noise Amplifier,DC,7000,19.7,2.4,9,22.9,1.6,1.5,3.5,35,-,-,SMT,50,Y
GALI-52+,DF782,Low Noise Amplifier,DC,2000,17.8,2.7,15.5,32,1.35,1.4,4.4,50,-,-,SMT,50,Y
GALI-74+,DF782,Low Noise Amplifier,DC,1000,21.8,2.7,18.3,38,1.2,1.6,4.8,80,-,-,SMT,50,Y
GALI-S66+,DF782,Low Noise Amplifier,DC,3000,18.2,2.4,3.3,19.1,1.1,1.2,3.5,16,-,-,SMT,50,Y
LEE-39+,FG873,Low Noise Amplifier,DC,8000,20.8,2.4,10.4,23.4,1.3,1.3,3.5,35,-,-,SMT,50,Y
LEE2-6+,MC1630-1,Low Noise Amplifier,DC,7000,18.9,2.3,2.8,17.6,1.33,1.54,3.6,16,-,-,SMT,50,Y
LHA-13HLN+,DQ1225,Low Noise Amplifier,1,1000,22.7,1.2,28,43.3,1.28,1.32,8,239,-,-,SMT,50,N
LHA-13LN+,DQ1225,Low Noise Amplifier,1,1000,22.4,1.1,23.3,38.3,1.28,1.28,5/3,143/73,-,-,SMT,50,N
MAR-6SM+,WW107,Low Noise Amplifier,DC,2000,20.2,2.3,3.7,18.1,1.2,1.2,3.5,16,-,-,SMT,50,Y
PHA-13HLN+,DF782,Low Noise Amplifier,1,1000,22.7,1.1,28.7,43,1.3,1.3,8,234,-,-,SMT,50,Y
PHA-13LN+,DF782,Low Noise Amplifier,1,1000,22.4,1,24.5,39,1.3,1.3,5.0/3/0,138/71,-,-,SMT,50,Y
PSA-8A+,CA1389,Low Noise Amplifier,DC,4000,31,3,12.8,25.8,1.28,1.25,5,36,-,-,SMT,50,Y
PSA-39+,CA1389,Low Noise Amplifier,DC,6000,23,2.2,10.7,23.3,1.28,1.22,5,32,-,-,SMT,50,Y
RAM-6A+,AF190,Low Noise Amplifier,DC,2000,19.7,2.3,3.2,17.3,1.2,1.2,3.5,16,-,-,SMT,50,Y
RAM-8A+,AF190,Low Noise Amplifier,DC,1000,28,2.6,12.6,24.4,1.6,1.8,3.7,36,-,-,SMT,50,Y
TSS-13HLN+,DQ1225,Low Noise Amplifier,1,1000,23,1.4,28.4,42.9,1.43,1.37,8,234,-,-,SMT,50,Y
TSS-13LN+,DQ1225,Low Noise Amplifier,1,1000,22.8,1.1,24.5,39.2,1.28,1.32,5/3,142/72,-,-,SMT,50,Y
90 changes: 90 additions & 0 deletions ControlApplication/Components.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import os
import pandas
import pickle
import sys

class BaseModel:
def __init__(self, model_number, case_style, description):
self.model_number = model_number
self.case_style = case_style
self.description = description

class Filter(BaseModel):
def __init__(self, model_number, case_style, description, filter_type, passband_f1, passband_f2, stopband_f3, stopband_f4):
super().__init__(model_number, case_style, description)
self.filter_type = filter_type
self.passband_f1 = passband_f1
self.passband_f2 = passband_f2
self.stopband_f3 = stopband_f3
self.stopband_f4 = stopband_f4

class Amplifier(BaseModel):
def __init__(self, model_number, case_style, description, f_low, f_high, gain):
super().__init__(model_number, case_style, description)
self.f_low = f_low
self.f_high = f_high
self.gain = gain

class ComponentsList:

FILTER = "Filter"
AMPLIFIER = "Amplifier"

def __init__(self, model_type, models_dir, dump_filename, log_filename = None):
self.model_type = model_type
self.dump_file_path = os.path.join(models_dir, dump_filename)
self.log_filename = log_filename

if os.path.exists(self.dump_file_path):
self.data = self.loadDump(self.dump_file_path)
else:
self.data = self.getModelsList(models_dir)
self.saveDump(self.dump_file_path)

def getModelsList(self, models_dir):
models = []

for model_info_filename in os.listdir(models_dir):

if model_info_filename.endswith('.csv'):
model_info_path = os.path.join(models_dir, model_info_filename)
df = pandas.read_csv(model_info_path)

for _, row in df.iterrows():
if self.model_type == self.FILTER:
model = Filter(
row['Model Number'],
row['Case Style'],
row['Description'],
row['Filter Type'],
row['Passband F1 (MHz)'],
row['Passband F2 (MHz)'],
row['Stopband F3 (MHz)'],
row['Stopband F4 (MHz)']
)
elif self.model_type == self.AMPLIFIER:
model = Amplifier(
row['Model Number'],
row['Case Style'],
row['Subcategories'],
row['F Low (MHz)'],
row['F High (MHz)'],
row['Gain (dB) Typ.']
)
models.append(model)

return models

def loadDump(self, dump_file_path):
with open(dump_file_path, 'rb') as model_list_dump_file:
if ("--show-debug-info" in sys.argv) and (self.log_filename != None):
with open(self.log_filename, "a") as file:
file.write(f"[INFO]: Dump loaded: {dump_file_path}\n")
return pickle.load(model_list_dump_file)

def saveDump(self, dump_file_path):
with open(dump_file_path, 'wb') as model_list_dump_file:
pickle.dump(self.data, model_list_dump_file)
if ("--show-debug-info" in sys.argv) and (self.log_filename != None):
with open(self.log_filename, "a") as file:
file.write(f"[INFO]: Dump saved: {dump_file_path}\n")
141 changes: 69 additions & 72 deletions ControlApplication/Device.py
Original file line number Diff line number Diff line change
@@ -1,83 +1,80 @@
from abc import ABC, abstractmethod
import os
import pickle

CONFIGS_DIR = "./SavedConfiguration/"

class SwitchStrategy(ABC):
@abstractmethod
def enableFilter(self, filter_index):
pass

class SPDTSwitchStrategy(SwitchStrategy):
def enableFilter(self, filter_index):
# TODO
print(f"Enabling filter {filter_index} on SPDT switch")

class SP3TSwitchStrategy(SwitchStrategy):
def enableFilter(self, filter_index):
# TODO
print(f"Enabling filter {filter_index} on SP3T switch")

class SP4TSwitchStrategy(SwitchStrategy):
def enableFilter(self, filter_index):
# TODO
print(f"Enabling filter {filter_index} on SP4T switch")

class SP6TSwitchStrategy(SwitchStrategy):
def enableFilter(self, filter_index):
# TODO
print(f"Enabling filter {filter_index} on SP6T switch")
from RFSwitch import *

class Device:
def __init__(self, switch_type, model_name):
self.switch_type = switch_type
# List of available device for operation
DEVICES_LIST = [
"rpitx-expansion-board-SP3T",
"rpitx-expansion-board-SP4T",
"rpitx-expansion-board-SP6T",
"rpitx-expansion-board-SP3T-LNA",
"rpitx-expansion-board-SP4T-LNA",
"rpitx-expansion-board-SP6T-LNA"
]

# Matching a specific device with its configuration
# <DEVICE> : (<NUMBER OF AVAILABLE FILTERS>, <FILTER SWITCH TRUTH TABLE>, <LNA SWITCH THRUTH TABLE>)
DEVICE_TYPE_MAPPING = {
# Boards without LNA
DEVICES_LIST[0]: (3, RFSwitch.SP3T_SWITCH_TRUTH_TABLE, None),
DEVICES_LIST[1]: (4, RFSwitch.SP4T_SWITCH_TRUTH_TABLE, None),
DEVICES_LIST[2]: (6, RFSwitch.SP6T_SWITCH_TRUTH_TABLE, None),
# Boards with LNA
DEVICES_LIST[3]: (3, RFSwitch.SP3T_SWITCH_TRUTH_TABLE, RFSwitch.SPDT_SWITCH_TRUTH_TABLE),
DEVICES_LIST[4]: (4, RFSwitch.SP4T_SWITCH_TRUTH_TABLE, RFSwitch.SPDT_SWITCH_TRUTH_TABLE),
DEVICES_LIST[5]: (6, RFSwitch.SP6T_SWITCH_TRUTH_TABLE, RFSwitch.SPDT_SWITCH_TRUTH_TABLE)
}

def __init__(self, model_name, log_filename = None):
self.model_name = model_name
self.filters = []
if (switch_type == "SPDT"):
self.switch_strategy = SPDTSwitchStrategy()
elif (switch_type == "SP3T"):
self.switch_strategy = SP3TSwitchStrategy()
elif (switch_type == "SP4T"):
self.switch_strategy = SP4TSwitchStrategy()
elif (switch_type == "SP6T"):
self.switch_strategy = SP6TSwitchStrategy()

def setSwitchStrategy(self, switch_strategy):
self.switch_strategy = switch_strategy

def enableFilter(self, filter_index):
if self.switch_strategy:
self.switch_strategy.enableFilter(filter_index)
else:
print("Switch strategy not set!")
self.filter_switch = None
self.lna = []
self.lna_switch = None
self.log_filename = log_filename

def saveConfiguration(self):
os.makedirs(CONFIGS_DIR, exist_ok=True)
def initFilterRFSwitches(self, input_switch_pinout, output_switch_pinout, switch_truth_table):
if self.filter_switch is None:
self.filter_switch = FilterSwitch(input_switch_pinout, output_switch_pinout, switch_truth_table, self.log_filename)

with open(f"{CONFIGS_DIR}{self.model_name}.pkl", 'wb') as device_configuration_file:
pickle.dump(self, device_configuration_file)
def initLNA(self, input_switch_pinout, output_switch_pinout, switch_truth_table):
if switch_truth_table and self.lna_switch is None:
self.lna_switch = LNASwitch(input_switch_pinout, output_switch_pinout, switch_truth_table, self.log_filename)

return f"{CONFIGS_DIR}{self.model_name}.pkl"

def getConfigurationInfo(self):
configuration_info = "=" * 60
configuration_info += "\nActive board configuration:\n"
configuration_info += "=" * 60
configuration_info += f"\nChoosed board: {self.model_name}\n"
configuration_info += "=" * 60
configuration_info += f"\nChoosed filters:\n"
configuration_info += "=" * 60
delimiter = "=" * 60
configuration_info = f"{delimiter}\nActive board configuration:\n"
configuration_info += f"{delimiter}\nChoosed board: {self.model_name}\n"

if self.lna:
lna_info = self.lna[0]
amplifier_info = (
f"{delimiter}\nAmplifier:\n"
f"Model Number: {lna_info.model_number}\n"
f"Case Style: {lna_info.case_style}\n"
f"Description: {lna_info.description}\n"
f"F Low: {lna_info.f_low}\n"
f"F High: {lna_info.f_high} MHz\n"
f"Gain Typ: {lna_info.gain} dB\n"
)
configuration_info += amplifier_info

configuration_info += f"{delimiter}\nChoosed filters:\n"
configuration_info += delimiter

for i, filter_obj in enumerate(self.filters, start=1):
configuration_info += f"\nFilter {i}:\n"
configuration_info += f"Model Number: {filter_obj.model_number}\n"
configuration_info += f"Case Style: {filter_obj.case_style}\n"
configuration_info += f"Description: {filter_obj.description}\n"
configuration_info += f"Filter Type: {filter_obj.filter_type}\n"
configuration_info += f"Passband F1: {filter_obj.passband_f1} MHz\n"
configuration_info += f"Passband F2: {filter_obj.passband_f2} MHz\n"
configuration_info += f"Stopband F3: {filter_obj.stopband_f3} MHz\n"
configuration_info += f"Stopband F4: {filter_obj.stopband_f4} MHz\n"
configuration_info += "=" * 60
filter_info = (
f"\nFilter {i}:\n"
f"Model Number: {filter_obj.model_number}\n"
f"Case Style: {filter_obj.case_style}\n"
f"Description: {filter_obj.description}\n"
f"Filter Type: {filter_obj.filter_type}\n"
f"Passband F1: {filter_obj.passband_f1} MHz\n"
f"Passband F2: {filter_obj.passband_f2} MHz\n"
f"Stopband F3: {filter_obj.stopband_f3} MHz\n"
f"Stopband F4: {filter_obj.stopband_f4} MHz\n"
f"{delimiter}"
)
configuration_info += filter_info

return configuration_info
return configuration_info
38 changes: 0 additions & 38 deletions ControlApplication/Filter.py

This file was deleted.

Loading

0 comments on commit 21e80a9

Please sign in to comment.