Skip to content

Commit

Permalink
refactor demod backend (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
jopohl authored Jun 21, 2019
1 parent 7e0a929 commit 28acf16
Show file tree
Hide file tree
Showing 47 changed files with 378 additions and 450 deletions.
42 changes: 0 additions & 42 deletions data/ui/signal_frame.ui
Original file line number Diff line number Diff line change
Expand Up @@ -778,43 +778,6 @@ stop:1 rgba(255, 255, 255, 0));
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="LegendGraphicView" name="gvLegend">
<property name="minimumSize">
<size>
<width>0</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="interactive">
<bool>false</bool>
</property>
<property name="resizeAnchor">
<enum>QGraphicsView::AnchorViewCenter</enum>
</property>
<property name="rubberBandSelectionMode">
<enum>Qt::ContainsItemShape</enum>
</property>
<property name="optimizationFlags">
<set>QGraphicsView::DontSavePainterState</set>
</property>
</widget>
</item>
<item>
<widget class="EpicGraphicView" name="gvSignal">
<property name="enabled">
Expand Down Expand Up @@ -1308,11 +1271,6 @@ stop:1 rgba(255, 255, 255, 0));
<extends>QGraphicsView</extends>
<header>urh.ui.views.EpicGraphicView.h</header>
</customwidget>
<customwidget>
<class>LegendGraphicView</class>
<extends>QGraphicsView</extends>
<header>urh.ui.views.LegendGraphicView.h</header>
</customwidget>
<customwidget>
<class>TextEditProtocolView</class>
<extends>QTextEdit</extends>
Expand Down
6 changes: 3 additions & 3 deletions src/urh/ainterpretation/AutoInterpretation.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,11 @@ def estimate(iq_array: IQArray, noise: float = None, modulation: str = None) ->
message_indices = merge_message_segments_for_ook(message_indices)

if modulation == "OOK" or modulation == "ASK":
data = signal_functions.afp_demod(iq_array.data, noise, 0)
data = signal_functions.afp_demod(iq_array.data, noise, "ASK")
elif modulation == "FSK":
data = signal_functions.afp_demod(iq_array.data, noise, 1)
data = signal_functions.afp_demod(iq_array.data, noise, "FSK")
elif modulation == "PSK":
data = signal_functions.afp_demod(iq_array.data, noise, 2)
data = signal_functions.afp_demod(iq_array.data, noise, "PSK")
else:
raise ValueError("Unsupported Modulation")

Expand Down
2 changes: 1 addition & 1 deletion src/urh/ainterpretation/Wavelet.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def cwt_haar(x: np.ndarray, scale=10):
# data = np.fromfile("/tmp/psk.complex", dtype=np.complex64)
# data = np.fromfile("/home/joe/GIT/urh/tests/data/psk_generated.complex", dtype=np.complex64)[0:8000]
modulator = Modulator("")
modulator.modulation_type_str = "PSK"
modulator.modulation_type = "PSK"
modulator.param_for_zero = 0
modulator.param_for_one = 180
modulator.carrier_freq_hz = 5e3
Expand Down
6 changes: 3 additions & 3 deletions src/urh/cli/urh_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def build_modulator_from_args(arguments: argparse.Namespace):

result.param_for_zero = param_zero
result.param_for_one = param_one
result.modulation_type_str = arguments.modulation_type
result.modulation_type = arguments.modulation_type
result.sample_rate = arguments.sample_rate

return result
Expand Down Expand Up @@ -150,7 +150,7 @@ def build_protocol_sniffer_from_args(arguments: argparse.Namespace):
bh = build_backend_handler_from_args(arguments)

result = ProtocolSniffer(arguments.bit_length, arguments.center, arguments.noise, arguments.tolerance,
Modulator.MODULATION_TYPES.index(arguments.modulation_type),
arguments.modulation_type,
arguments.device.lower(), bh)
result.rcv_device.frequency = arguments.frequency
result.rcv_device.sample_rate = arguments.sample_rate
Expand Down Expand Up @@ -261,7 +261,7 @@ def parse_project_file(file_path: str):
result["carrier_phase"] = modulator.carrier_phase_deg
result["parameter_zero"] = modulator.param_for_zero
result["parameter_one"] = modulator.param_for_one
result["modulation_type"] = modulator.modulation_type_str
result["modulation_type"] = modulator.modulation_type

return result

Expand Down
10 changes: 5 additions & 5 deletions src/urh/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ class color:
# ROI-SELECTION COLORS
SELECTION_COLOR = QColor("darkblue") # overwritten by system color (bin/urh)
NOISE_COLOR = QColor("red")
SELECTION_OPACITY = 0.8
SELECTION_OPACITY = 1
NOISE_OPACITY = 0.4

# SEPARATION COLORS
ONES_AREA_COLOR = QColor.fromRgb(0, 128, 128)
ZEROS_AREA_COLOR = QColor.fromRgb(90, 9, 148)
SEPARATION_OPACITY = 0.2
SEPARATION_PADDING = .05 # Prozent
ONES_AREA_COLOR = Qt.darkGreen
ZEROS_AREA_COLOR = Qt.darkRed
SEPARATION_OPACITY = 0.25
SEPARATION_PADDING = .05 # percent

# PROTOCOL TABLE COLORS
SELECTED_ROW_COLOR = QColor.fromRgb(0, 0, 255)
Expand Down
5 changes: 1 addition & 4 deletions src/urh/controller/CompareFrameController.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,10 +1046,7 @@ def on_btn_analyze_clicked(self):
self.message_type_table_model.update()
self.ui.tblViewMessageTypes.clearSelection()
except Exception as e:
logger.exception(e)
Errors.generic_error("Failed to assign labels",
"An error occurred during automatic label assignment",
traceback.format_exc())
Errors.exception(e)

self.ui.progressBarLogicAnalyzer.setValue(90)

Expand Down
6 changes: 3 additions & 3 deletions src/urh/controller/GeneratorTabController.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def show_modulation_info(self):
self.ui.lCarrierPhaseValue.setText(cur_mod.carrier_phase_str)
self.ui.lBitLenValue.setText(cur_mod.bit_len_str)
self.ui.lSampleRateValue.setText(cur_mod.sample_rate_str)
mod_type = cur_mod.modulation_type_str
mod_type = cur_mod.modulation_type
self.ui.lModTypeValue.setText(mod_type)
if mod_type == "ASK":
prefix = "Amplitude"
Expand Down Expand Up @@ -394,7 +394,7 @@ def generate_file(self):
sample_rate = 1e6
FileOperator.save_data_dialog("generated", modulated_samples, sample_rate=sample_rate, parent=self)
except Exception as e:
Errors.generic_error(self.tr("Failed to generate data"), str(e), traceback.format_exc())
Errors.exception(e)
self.unsetCursor()

def prepare_modulation_buffer(self, total_samples: int, show_error=True) -> IQArray:
Expand Down Expand Up @@ -606,7 +606,7 @@ def on_btn_send_clicked(self):
dialog.show()
dialog.graphics_view.show_full_scene(reinitialize=True)
except Exception as e:
Errors.generic_error(self.tr("Failed to generate data"), str(e), traceback.format_exc())
Errors.exception(e)
self.unsetCursor()

@pyqtSlot()
Expand Down
6 changes: 3 additions & 3 deletions src/urh/controller/MainController.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def close_signal_frame(self, signal_frame: SignalFrame):
self.set_frame_numbers()
self.refresh_main_menu()
except Exception as e:
Errors.generic_error(self.tr("Failed to close"), str(e), traceback.format_exc())
Errors.exception(e)
self.unsetCursor()

def add_files(self, filepaths, group_id=0, enforce_sample_rate=None):
Expand Down Expand Up @@ -560,7 +560,7 @@ def on_open_recent_action_triggered(self):
self.add_files(FileOperator.uncompress_archives([action.data()], QDir.tempPath()))
self.unsetCursor()
except Exception as e:
Errors.generic_error(self.tr("Failed to open"), str(e), traceback.format_exc())
Errors.exception(e)
self.unsetCursor()

@pyqtSlot()
Expand Down Expand Up @@ -783,7 +783,7 @@ def show_open_dialog(self, directory=False):
self.add_files(file_names)
self.unsetCursor()
except Exception as e:
Errors.generic_error(self.tr("Failed to open"), str(e), traceback.format_exc())
Errors.exception(e)
self.unsetCursor()

@pyqtSlot()
Expand Down
2 changes: 1 addition & 1 deletion src/urh/controller/SimulatorTabController.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def on_btn_simulate_clicked(self):
try:
self.get_simulator_dialog().exec_()
except Exception as e:
Errors.generic_error("An error occurred", str(e))
Errors.exception(e)

def get_simulator_dialog(self) -> SimulatorDialog:
protos = [p for proto_list in self.tree_model.protocols.values() for p in proto_list]
Expand Down
6 changes: 3 additions & 3 deletions src/urh/controller/dialogs/ModulatorDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def current_modulator(self):
return mod

def set_ui_for_current_modulator(self):
index = self.ui.comboBoxModulationType.findText("*(" + self.current_modulator.modulation_type_str + ")",
index = self.ui.comboBoxModulationType.findText("*(" + self.current_modulator.modulation_type + ")",
Qt.MatchWildcard)
self.ui.comboBoxModulationType.setCurrentIndex(index)
self.ui.doubleSpinBoxCarrierFreq.setValue(self.current_modulator.carrier_freq_hz)
Expand Down Expand Up @@ -443,10 +443,10 @@ def on_gaus_filter_wdith_changed(self):

@pyqtSlot()
def on_modulation_type_changed(self):
if self.current_modulator.modulation_type_str == self.__cur_selected_mod_type():
if self.current_modulator.modulation_type == self.__cur_selected_mod_type():
write_standard_parameters = False
else:
self.current_modulator.modulation_type_str = self.__cur_selected_mod_type()
self.current_modulator.modulation_type = self.__cur_selected_mod_type()
write_standard_parameters = True

self.__set_gauss_ui_visibility(self.__cur_selected_mod_type() == "GFSK")
Expand Down
2 changes: 1 addition & 1 deletion src/urh/controller/dialogs/SimulatorDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def on_selected_tx_device_changed(self):
self.device_settings_tx_widget.device = self.simulator.sender.device
except Exception as e:
self.device_settings_tx_widget.ui.cbDevice.setCurrentText(old_name)
Errors.generic_error("Error occurred", str(e))
Errors.exception(e)

@pyqtSlot()
def on_btn_test_sniff_settings_clicked(self):
Expand Down
6 changes: 3 additions & 3 deletions src/urh/controller/widgets/ModulationSettingsWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def show_selected_modulation_infos(self):
self.ui.labelCarrierFrequencyValue.setText(modulator.carrier_frequency_str)
self.ui.labelBitLengthValue.setText(modulator.bit_len_str)
self.ui.labelSampleRateValue.setText(modulator.sample_rate_str)
self.ui.labelModulationTypeValue.setText(modulator.modulation_type_verbose_str)
self.ui.labelModulationTypeValue.setText(modulator.modulation_type_verbose)
prefixes = {"ASK": "Amplitude", "PSK": "Phase", "FSK": "Frequency", "GFSK": "Frequency"}
self.ui.labelParamZero.setText(prefixes[modulator.modulation_type_str] + " for 0:")
self.ui.labelParamOne.setText(prefixes[modulator.modulation_type_str] + " for 1:")
self.ui.labelParamZero.setText(prefixes[modulator.modulation_type] + " for 0:")
self.ui.labelParamOne.setText(prefixes[modulator.modulation_type] + " for 1:")

self.ui.labelParamZeroValue.setText(modulator.param_for_zero_str)
self.ui.labelParamOneValue.setText(modulator.param_for_one_str)
Expand Down
Loading

0 comments on commit 28acf16

Please sign in to comment.