def __init__(self, layer_stack, parent=None): super().__init__(parent) self.layer_stack = layer_stack self.setLayout(Qt.QVBoxLayout()) self.views_splitter = Qt.QSplitter(Qt.Qt.Vertical) self.layout().addWidget(self.views_splitter) self.pages_groupbox = Qt.QGroupBox('Pages') l = Qt.QVBoxLayout() self.pages_groupbox.setLayout(l) self.pages_view = PagesView() l.addWidget(self.pages_view) ll = Qt.QHBoxLayout() self.toggle_playing_action = Qt.QAction(self) self.toggle_playing_action.setText('Play') self.toggle_playing_action.setShortcut(Qt.Qt.Key_P) self.toggle_playing_action.setCheckable(True) self.toggle_playing_action.setChecked(False) self.toggle_playing_action.setEnabled(False) self.toggle_playing_action.toggled.connect(self._on_toggle_play_action_toggled) self.toggle_playing_button = Qt.QPushButton('\N{BLACK RIGHT-POINTING POINTER}') self.toggle_playing_button.setCheckable(True) self.toggle_playing_button.setEnabled(False) self.toggle_playing_button.clicked.connect(self._on_toggle_play_button_toggled) self._play_advance_frame.connect(self._on_play_advance_frame, Qt.Qt.QueuedConnection) ll.addSpacerItem(Qt.QSpacerItem(0, 0, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum)) ll.addWidget(self.toggle_playing_button) ll.addSpacerItem(Qt.QSpacerItem(0, 0, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum)) l.addLayout(ll) self.pages_model = PagesModel(PageList(), self.pages_view) self.pages_model.handle_dropped_files = self._handle_dropped_files self.pages_model.rowsInserted.connect(self._on_model_rows_inserted) self.pages_model.rowsRemoved.connect(self._on_model_reset_or_rows_removed) self.pages_model.modelReset.connect(self._on_model_reset_or_rows_removed) self.pages_model.rowsInserted.connect(self._on_model_reset_or_rows_inserted_indirect, Qt.Qt.QueuedConnection) self.pages_model.modelReset.connect(self._on_model_reset_or_rows_inserted_indirect, Qt.Qt.QueuedConnection) self.pages_view.setModel(self.pages_model) self.pages_view.selectionModel().currentRowChanged.connect(self.apply) self.pages_view.selectionModel().selectionChanged.connect(self._on_page_selection_changed) self.views_splitter.addWidget(self.pages_groupbox) self.page_content_groupbox = Qt.QGroupBox('Page Contents') self.page_content_groupbox.setLayout(Qt.QHBoxLayout()) self.page_content_view = DefaultTable() h = self.page_content_view.horizontalHeader() h.setStretchLastSection(True) h.setHighlightSections(False) h.setSectionsClickable(False) h = self.page_content_view.verticalHeader() h.setHighlightSections(False) h.setSectionsClickable(False) self.page_content_groupbox.layout().addWidget(self.page_content_view) self.page_content_model = PageContentModel(layer_stack, self.page_content_view) self.page_content_model.rowsInserted.connect(self._on_content_model_rows_inserted, Qt.Qt.QueuedConnection) self.page_content_model.modelReset.connect(self._on_content_model_rows_inserted, Qt.Qt.QueuedConnection) self.page_content_view.setModel(self.page_content_model) self.views_splitter.addWidget(self.page_content_groupbox) self.views_splitter.setStretchFactor(0, 4) self.views_splitter.setStretchFactor(0, 1) self.views_splitter.setSizes((1, 0)) self._attached_page = None self.delete_selected_action = Qt.QAction(self) self.delete_selected_action.setText('Delete pages') self.delete_selected_action.setToolTip('Delete currently selected main flipbook pages') self.delete_selected_action.setShortcut(Qt.Qt.Key_Delete) self.delete_selected_action.setShortcutContext(Qt.Qt.WidgetShortcut) self.delete_selected_action.triggered.connect(self.delete_selected) self.pages_view.addAction(self.delete_selected_action) self.consolidate_selected_action = Qt.QAction(self) self.consolidate_selected_action.setText('Consolidate pages') self.consolidate_selected_action.setToolTip('Consolidate selected main flipbook pages (combine them into one page)') self.consolidate_selected_action.setShortcut(Qt.Qt.Key_Return) self.consolidate_selected_action.setShortcutContext(Qt.Qt.WidgetWithChildrenShortcut) self.consolidate_selected_action.triggered.connect(self.merge_selected) self.addAction(self.consolidate_selected_action) self._on_page_selection_changed() self.freeimage = FREEIMAGE(show_messagebox_on_error=True, error_messagebox_owner=self) self.apply()
def __init__(self, parent=None): """ Create dialog. Arguments: parent (Optional[QWidget]): Parent widget. Defaults to *None*. """ super(AboutDlg, self).__init__(parent) self.setModal(True) text = translate("AboutDlg", "About {}").format("AsterStudy") self.setWindowTitle(text) icon_lbl = Q.QLabel(self) title_lbl = Q.QLabel(self) version_lbl = Q.QLabel(self) description_lbl = Q.QLabel(self) license_lbl = Q.QLabel(self) credits_lbl = Q.QLabel(self) copyright_lbl = Q.QLabel(self) self.info_te = Q.QTextEdit(self) ok_btn = Q.QPushButton(self) main_wg = Q.QWidget(self) info_wg = Q.QWidget(self) hlayout = Q.QHBoxLayout() hlayout.addWidget(license_lbl) hlayout.addWidget(credits_lbl) glayout = Q.QGridLayout(main_wg) glayout.setContentsMargins(0, 0, 0, 0) glayout.addWidget(icon_lbl, 1, 1, 5, 1) glayout.addWidget(title_lbl, 1, 2) glayout.addWidget(version_lbl, 2, 2) glayout.addWidget(description_lbl, 4, 2) glayout.addLayout(hlayout, 6, 1, 1, 2) glayout.addWidget(copyright_lbl, 7, 0, 1, 4) glayout.setRowMinimumHeight(0, 10) glayout.setRowMinimumHeight(3, 10) glayout.setRowMinimumHeight(5, 20) glayout.setRowStretch(5, 10) glayout.setRowMinimumHeight(7, 40) glayout.setColumnMinimumWidth(0, 10) glayout.setColumnMinimumWidth(3, 10) hlayout = Q.QHBoxLayout() hlayout.addStretch() hlayout.addWidget(ok_btn) hlayout.addStretch() vlayout = Q.QVBoxLayout(info_wg) vlayout.addWidget(self.info_te) vlayout.addLayout(hlayout) slayout = Q.QStackedLayout() slayout.addWidget(main_wg) slayout.addWidget(info_wg) self.setLayout(slayout) pixmap = load_pixmap("asterstudy.png") icon_lbl.setPixmap(pixmap) icon_lbl.setFixedSize(pixmap.size() * 1.2) icon_lbl.setAlignment(Q.Qt.AlignCenter) title_lbl.setText(wrap_html("AsterStudy", "h1")) text = translate("AboutDlg", "Version: {}").format(version()) version_lbl.setText(wrap_html(text, "h4")) text = translate("AboutDlg", "GUI framework for {code_aster}") text = text.format( code_aster=wrap_html("code_aster", "a", href="code_aster")) description_lbl.setText(wrap_html(text, "h3")) description_lbl.setTextInteractionFlags(Q.Qt.LinksAccessibleByMouse) description_lbl.linkActivated.connect(self._browseCodeAster) text = translate("AboutDlg", "License Information") license_lbl.setText(wrap_html(text, "a", href="license")) license_lbl.setAlignment(Q.Qt.AlignCenter) license_lbl.setTextInteractionFlags(Q.Qt.LinksAccessibleByMouse) license_lbl.linkActivated.connect(self._showLicense) text = translate("AboutDlg", "Credits") credits_lbl.setText(wrap_html(text, "a", href="credits")) credits_lbl.setAlignment(Q.Qt.AlignCenter) credits_lbl.setTextInteractionFlags(Q.Qt.LinksAccessibleByMouse) credits_lbl.linkActivated.connect(self._showCredits) text = "Copyright 2016 EDF R&D" copyright_lbl.setText(italic(text)) copyright_lbl.setAlignment(Q.Qt.AlignCenter) self.info_te.setReadOnly(True) self.info_te.setMinimumWidth(450) ok_btn.setText(translate("AsterStudy", "&OK")) ok_btn.clicked.connect(self._showMain) palette = self.palette() palette.setColor(Q.QPalette.Window, Q.QColor("#f7f7f7")) self.setPalette(palette) palette.setColor(Q.QPalette.Window, Q.QColor("#ebebeb")) copyright_lbl.setPalette(palette) copyright_lbl.setAutoFillBackground(True) self.resize(self.minimumSizeHint())
def __init__(self, app, parent): super().__init__() self.question_data = parent.question_data statement_title = Qt.QLabel('Текст вопроса:', self) statement_title.setFont(Qt.QFont('Arial', 25)) self.statement_input = Qt.QPlainTextEdit( self.question_data['statement'], self) self.statement_input.setFont(Qt.QFont('Arial', 20)) self.statement_input.setMinimumHeight(220) self.statement_input.textChanged.connect(self.update_status) answer_title = Qt.QLabel('Правильный ответ:', self) answer_title.setFont(Qt.QFont('Arial', 25)) self.answer_input = Qt.QLineEdit(self.question_data['correct'], self) self.answer_input.setFont(Qt.QFont('Arial', 20)) self.answer_input.setCursorPosition(0) self.answer_input.textChanged.connect(self.update_status) maxscore_title = Qt.QLabel('Максимальный балл:', self) maxscore_title.setFont(Qt.QFont('Arial', 25)) self.maxscore_input = Qt.QLineEdit(str(self.question_data['maxscore']), self) self.maxscore_input.setFont(Qt.QFont('Arial', 20)) self.maxscore_input.textChanged.connect(self.update_status) self.save_button = Qt.QPushButton(Qt.QIcon(common.SAVE), 'Сохранить', self) self.save_button.setObjectName('Button') self.save_button.setIconSize(Qt.QSize(35, 35)) self.save_button.setFont(Qt.QFont('Arial', 20)) self.save_button.clicked.connect(lambda: app.save_question_data( { 'rowid': self.question_data['rowid'], 'type': self.question_data['type'], 'statement': self.statement_input.toPlainText(), 'correct': self.answer_input.text(), 'maxsubs': 1, 'maxscore': int(self.maxscore_input.text()) })) self.status_img = Qt.QLabel(self) self.status_img.setScaledContents(True) self.status_img.setFixedSize(Qt.QSize(50, 50)) self.status_label = Qt.QLabel(self) self.status_label.setFont(Qt.QFont('Arial', 20)) self.update_status() delete_button = Qt.QPushButton(Qt.QIcon(common.DELETE), 'Удалить вопрос', self) delete_button.setObjectName('Button') delete_button.setIconSize(Qt.QSize(35, 35)) delete_button.setFont(Qt.QFont('Arial', 20)) delete_button.clicked.connect( lambda: app.delete_question(self.question_data['rowid'])) title_layout = Qt.QVBoxLayout() title_layout.addWidget(answer_title) title_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) title_layout.addWidget(maxscore_title) title_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) input_layout = Qt.QVBoxLayout() input_layout.addWidget(self.answer_input) input_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) input_layout.addWidget(self.maxscore_input) input_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) main_layout = Qt.QHBoxLayout() main_layout.addLayout(title_layout) main_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) main_layout.addLayout(input_layout) self.lower_layout.addWidget(self.save_button) self.lower_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) self.lower_layout.addWidget(self.status_img) self.lower_layout.addWidget(self.status_label) self.lower_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) self.lower_layout.addStretch(1) self.lower_layout.addWidget(delete_button) self.layout.addWidget(statement_title) self.layout.addSpacerItem(Qt.QSpacerItem(0, 10)) self.layout.addWidget(self.statement_input) self.layout.addSpacerItem(Qt.QSpacerItem(0, 20)) self.layout.addLayout(main_layout)
def __init__(self, app, exam_id): super().__init__() self.app = app self.exam_id = exam_id self.question_id = None self.question_number = None self.exam_data = None self.question_data = None self.questions_ids = [] back_button = Qt.QPushButton(Qt.QIcon(common.LEFT), '', self) back_button.setObjectName('Flat') back_button.setCursor(Qt.Qt.PointingHandCursor) back_button.setIconSize(Qt.QSize(35, 35)) back_button.setFixedSize(Qt.QSize(55, 55)) back_button.clicked.connect(lambda _: app.display_home_page()) scroll_area = Qt.QScrollArea() scroll_area.setWidgetResizable(True) scroll_area.setFrameShape(Qt.QFrame.NoFrame) scroll_area.setSizePolicy(Qt.QSizePolicy.Minimum, Qt.QSizePolicy.Minimum) self.settings_button = Qt.QPushButton(Qt.QIcon(common.SETTINGS), '', self) self.settings_button.setObjectName('Flat') self.settings_button.setCursor(Qt.Qt.PointingHandCursor) self.settings_button.setIconSize(Qt.QSize(30, 30)) self.settings_button.setFixedSize(Qt.QSize(50, 50)) self.settings_button.clicked.connect( lambda _: self.app.view_exam_settings()) self.questions_layout = Qt.QHBoxLayout() self.questions_layout.setSpacing(0) short_question_action = Qt.QWidgetAction(self) short_question_action.setFont(Qt.QFont('Arial', 15)) short_question_action.setText('Вопрос с кратким ответом') short_question_action.triggered.connect( lambda: self.app.create_question(self.exam_id, 'Short')) long_question_action = Qt.QWidgetAction(self) long_question_action.setFont(Qt.QFont('Arial', 15)) long_question_action.setText('Вопрос с развёрнутым ответом') long_question_action.triggered.connect( lambda: self.app.create_question(self.exam_id, 'Long')) create_menu = Qt.QMenu(self) create_menu.addAction(short_question_action) create_menu.addAction(long_question_action) create_button = Qt.QPushButton(Qt.QIcon(common.CREATE), '', self) create_button.setObjectName('Flat') create_button.setCursor(Qt.Qt.PointingHandCursor) create_button.setIconSize(Qt.QSize(40, 40)) create_button.setFixedSize(Qt.QSize(50, 50)) create_button.setMenu(create_menu) self.widget = Qt.QWidget(self) scroll_layout = Qt.QHBoxLayout() scroll_layout.setSpacing(0) scroll_layout.setContentsMargins(0, 0, 0, 0) scroll_layout.setSizeConstraint(Qt.QLayout.SetMinimumSize) scroll_layout.addWidget(self.settings_button) scroll_layout.addLayout(self.questions_layout) scroll_layout.addSpacerItem(Qt.QSpacerItem(5, 0)) scroll_layout.addWidget(create_button) scroll_layout.addStretch(1) scroll_widget = Qt.QWidget(self) scroll_widget.setLayout(scroll_layout) scroll_area.setWidget(scroll_widget) upper_layout = Qt.QHBoxLayout() upper_layout.addWidget(back_button) upper_layout.addSpacerItem(Qt.QSpacerItem(10, 0)) upper_layout.addWidget(scroll_area) layout = Qt.QVBoxLayout() layout.addLayout(upper_layout) layout.addSpacerItem(Qt.QSpacerItem(0, 10)) layout.addWidget(self.widget) self.setLayout(layout)
def initUI(self): # print('initUI()') self.qchk_lock = Qt.QCheckBox( 'Lock On' ) # Not displayed, for status reading only (to act like the other LoopFilter) self.qchk_lock.setChecked(False) # first column: contains the radio buttons to select the mode vbox = Qt.QVBoxLayout() self.qradio_mode_off = Qt.QRadioButton('Off') self.qradio_mode_off.setChecked(True) self.qradio_mode_slow = Qt.QRadioButton('Acquisition on slow PZT only') self.qradio_mode_fast = Qt.QRadioButton('Lock on fast PZT only') self.qradio_mode_both = Qt.QRadioButton('Lock on both PZTs') # self.qradio_mode_off.setEnabled(self.bDisplayLockChkBox) # self.qradio_mode_slow.setEnabled(self.bDisplayLockChkBox) # self.qradio_mode_fast.setEnabled(self.bDisplayLockChkBox) # self.qradio_mode_both.setEnabled(self.bDisplayLockChkBox) # Two checkboxes to flip the sign self.qchk_flip1 = Qt.QCheckBox('Flip sign on acquisition') self.qchk_flip1.clicked.connect(self.setIntegratorGainEvent) self.qchk_flip2 = Qt.QCheckBox('Flip sign on lock') self.qchk_flip2.clicked.connect(self.setIntegratorGainEvent) self.qradio_mode_off.clicked.connect(self.updateSettings) self.qradio_mode_slow.clicked.connect(self.updateSettings) self.qradio_mode_fast.clicked.connect(self.updateSettings) self.qradio_mode_both.clicked.connect(self.updateSettings) self.qgroup_mode = Qt.QButtonGroup(self) self.qgroup_mode.addButton(self.qradio_mode_off) self.qgroup_mode.addButton(self.qradio_mode_slow) self.qgroup_mode.addButton(self.qradio_mode_fast) self.qgroup_mode.addButton(self.qradio_mode_both) self.qchk_hold = Qt.QCheckBox('Hold both') self.qchk_hold.clicked.connect(self.updateSettings) self.qlabel_int1_state = Qt.QLabel('Integrator 1 state: Off') self.qlabel_int2_state = Qt.QLabel('Integrator 2 state: Off') vbox.addWidget(self.qradio_mode_off) vbox.addWidget(self.qradio_mode_slow) vbox.addWidget(self.qradio_mode_fast) vbox.addWidget(self.qradio_mode_both) #FEATURE vbox.addWidget(self.qchk_flip1) vbox.addWidget(self.qchk_flip2) #vbox.addWidget(self.qchk_hold) vbox.addWidget(self.qlabel_int1_state) vbox.addWidget(self.qlabel_int2_state) vbox.addStretch(1) ## The slow PZT integrators BW controls: # The label to indicate the predicted closed-loop BW self.qlbl_acquisition = Qt.QLabel('Acq gain:') self.qlabel_int1_gain = Qt.QLabel('BW : 10 Hz') self.qlabel_int1_gain.setAlignment(Qt.Qt.AlignHCenter) # The knob to set the open-loop gain, and thus closed-loop BW self.qcombo_int1_gain = Qt.QComboBox() gainsList = range(-31, 31) gainsList = list(map(str, gainsList)) self.qcombo_int1_gain.addItems(gainsList) self.qcombo_int1_gain.setCurrentIndex( 32 - 17 ) # this has to be overridden if we load the register settings (TODO) self.qcombo_int1_gain.currentIndexChanged.connect( self.setIntegratorGainEvent) self.qlbl_lock_gain = Qt.QLabel('Lock gain:') self.qlabel_int2_gain = Qt.QLabel('BW : 1 kHz') self.qlabel_int2_gain.setAlignment(Qt.Qt.AlignHCenter) # The knob to set the open-loop gain, and thus closed-loop BW self.qcombo_int2_gain = Qt.QComboBox() gainsList = range(-31, 31) gainsList = list(map(str, gainsList)) self.qcombo_int2_gain.addItems(gainsList) self.qcombo_int2_gain.setCurrentIndex( 32 - 17 ) # this has to be overridden if we load the register settings (TODO) self.qcombo_int2_gain.currentIndexChanged.connect( self.setIntegratorGainEvent) self.qgroupbox_integrators = Qt.QGroupBox('Slow PZT (DAC2)') vbox_int = Qt.QVBoxLayout() vbox_int.addWidget(self.qlbl_acquisition) vbox_int.addWidget(self.qcombo_int1_gain) vbox_int.addWidget(self.qlabel_int1_gain) vbox_int.addWidget(self.qlbl_lock_gain) vbox_int.addWidget(self.qcombo_int2_gain) vbox_int.addWidget(self.qlabel_int2_gain) vbox_int.addStretch(1) self.qgroupbox_integrators.setLayout(vbox_int) # The controls for the fast PZT's loop filter settings, contains only one (composite) widget: self.qgroupbox_pll = Qt.QGroupBox('Fast PZT (DAC1)', self) # self.dac1_ui.setParent(self.qgroupbox_pll) vbox3 = Qt.QVBoxLayout() vbox3.addWidget(self.dac1_ui) self.qgroupbox_pll.setLayout(vbox3) # Put all the vboxes and groupboxes into a single layout: hbox = Qt.QHBoxLayout() hbox.addLayout(vbox) hbox.addWidget(self.qgroupbox_integrators) hbox.addWidget(self.qgroupbox_pll) hbox.setStretch(2, 1) self.setLayout(hbox)
def initUI(self): # Add a first QwtPlot to the UI: #self.qplt_mag = Qwt.QwtPlot() self.qplt_mag = pg.PlotWidget() self.qplt_mag.setTitle('Magnitude response') #self.qplt_mag.setCanvasBackground(Qt.Qt.white) #self.qplt_mag.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLog10ScaleEngine()) self.qplt_mag.getPlotItem().setLogMode(x=True) #print('DisplayTransferFunctionWindow: initUI(): first plot widget created') # plot_grid = Qwt.QwtPlotGrid() # plot_grid.setMajPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) # plot_grid.attach(self.qplt_mag) self.qplt_mag.showGrid(x=True, y=True) self.colors_order = [ [0, 114, 189], [217, 83, 25], [237, 177, 32], [126, 47, 142], [119, 172, 48], [77, 190, 238], [162, 20, 47], ] # Add a second QwtPlot to the UI: self.qplt_phase = pg.PlotWidget() self.qplt_phase.setTitle('Phase response') #self.qplt_phase.setCanvasBackground(Qt.Qt.white) #self.qplt_phase.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLog10ScaleEngine()) self.qplt_phase.getPlotItem().setLogMode(x=True) #print('DisplayTransferFunctionWindow: initUI(): 2nd plot widget created') # plot_grid = Qwt.QwtPlotGrid() # plot_grid.setMajPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) # plot_grid.attach(self.qplt_phase) self.qplt_phase.showGrid(x=True, y=True) # create the lists to hold the curve objects as they get added to the plots: self.curve_mag_list = [] self.curve_phase_list = [] ###################################################################### # Controls to adjust the model ###################################################################### # Units select units_label = Qt.QLabel('Units:') self.qcombo_units = Qt.QComboBox() self.qcombo_units.addItems([ 'dB', 'Linear', 'real part', 'imag part', 'Ohms, 50*Vin/Vout', 'Ohms, shunt DUT, 50 ohms probe', 'Ohms, Shunt DUT, high-Z probe + Series source impedance' ]) self.qcombo_units.setCurrentIndex(0) # self.qcombo_units.changeEvent.connect(self.updateGraph) self.qcombo_units.currentIndexChanged.connect(self.updateGraph) self.qlabel_SeriesImpedance = Qt.QLabel('Series Impedance [Ohms]:') self.qedit_SeriesImpedance = Qt.QLineEdit('100e3') self.qedit_SeriesImpedance.editingFinished.connect(self.updateGraph) self.qchk_display_model = Qt.QCheckBox('Display model') self.qchk_display_model.setChecked(False) self.qchk_DDCFilter = Qt.QCheckBox('DDC sinc filter') self.qchk_DDCFilter.clicked.connect(self.updateGraph) self.qradio_signp = Qt.QRadioButton('+ Sign') self.qradio_signp.setChecked(True) self.qradio_signn = Qt.QRadioButton('- Sign') button_group = Qt.QButtonGroup() button_group.addButton(self.qradio_signp) button_group.addButton(self.qradio_signn) self.qradio_signp.clicked.connect(self.updateGraph) self.qradio_signn.clicked.connect(self.updateGraph) # set the default DC gain to the value of the transfer function at the lowest frequency: self.qlabel_k = Qt.QLabel('DC Gain [dB]') self.qedit_k = Qt.QLineEdit(str(0)) self.qedit_k.setMaximumWidth(60) self.qedit_k.textChanged.connect(self.updateGraph) self.qlabel_f1 = Qt.QLabel('1st order poles') self.qedit_f1 = Qt.QLineEdit('20e3,600e3') self.qedit_f1.setMaximumWidth(120) self.qedit_f1.textChanged.connect(self.updateGraph) self.qlabel_f0 = Qt.QLabel('2nd order poles') self.qedit_f0 = Qt.QLineEdit('1.5e6') self.qedit_f0.setMaximumWidth(120) self.qedit_f0.textChanged.connect(self.updateGraph) self.qlabel_zeta = Qt.QLabel('zeta') self.qedit_zeta = Qt.QLineEdit('0.1') self.qedit_zeta.setMaximumWidth(120) self.qedit_zeta.textChanged.connect(self.updateGraph) self.qlabel_T = Qt.QLabel('Pure delay') self.qedit_T = Qt.QLineEdit('570e-9') self.qedit_T.setMaximumWidth(60) self.qedit_T.textChanged.connect(self.updateGraph) self.qchk_controller = Qt.QCheckBox('Closed-loop prediction') self.qchk_controller.clicked.connect(self.updateGraph) self.qlabel_pgain = Qt.QLabel('P gain [dB]') self.qedit_pgain = Qt.QLineEdit('-100') self.qedit_pgain.setMaximumWidth(60) self.qedit_pgain.textChanged.connect(self.updateGraph) self.qlabel_icorner = Qt.QLabel('I corner [Hz]') self.qedit_icorner = Qt.QLineEdit('0') self.qedit_icorner.setMaximumWidth(60) self.qedit_icorner.textChanged.connect(self.updateGraph) self.qedit_comment = Qt.QTextEdit('') # self.qedit_comment.setMaximumWidth(80) #self.qedit_comment.textChanged.connect(self.updateGraph) # Put all the widgets into a grid layout grid = Qt.QGridLayout() grid.addWidget(units_label, 0, 0) grid.addWidget(self.qcombo_units, 0, 1) grid.addWidget(self.qlabel_SeriesImpedance, 1, 0) grid.addWidget(self.qedit_SeriesImpedance, 1, 1) # grid.addWidget(self.qchk_display_model , 2, 1) # grid.addWidget(self.qradio_signp , 3, 0) # grid.addWidget(self.qradio_signn , 3, 1) # grid.addWidget(self.qlabel_k , 4, 0) # grid.addWidget(self.qedit_k , 4, 1) # grid.addWidget(self.qlabel_f1 , 5, 0) # grid.addWidget(self.qedit_f1 , 5, 1) # grid.addWidget(self.qlabel_f0 , 6, 0) # grid.addWidget(self.qedit_f0 , 6, 1) # grid.addWidget(self.qlabel_zeta , 7, 0) # grid.addWidget(self.qedit_zeta , 7, 1) # grid.addWidget(self.qlabel_T , 8, 0) # grid.addWidget(self.qedit_T , 8, 1) # grid.addWidget(self.qchk_controller , 9, 0, 1, 2) # grid.addWidget(self.qlabel_pgain , 10, 0) # grid.addWidget(self.qedit_pgain , 10, 1) # grid.addWidget(self.qlabel_icorner , 12, 0) # grid.addWidget(self.qedit_icorner , 12, 1) # grid.addWidget(self.qchk_DDCFilter , 13, 0, 1, 2) grid.addWidget(self.qedit_comment, 14, 0, 1, 2) grid.setRowStretch(15, 0) # grid.addWidget(Qt.QLabel(''), 12, 0, 1, 2) # grid.setRowStretch(14, 1) vbox = Qt.QVBoxLayout() vbox.addWidget(self.qplt_mag) vbox.addWidget(self.qplt_phase) hbox = Qt.QHBoxLayout() hbox.addLayout(grid) hbox.addLayout(vbox, 1) # hbox.setStretch(2, 1) self.setLayout(hbox) # Adjust the size and position of the window self.resize(1200, 500) self.center() self.setWindowTitle('Transfer function #%d' % self.window_number) self.show()
def __init__(self, app, group_name, user_name): super().__init__() back_button = Qt.QPushButton(Qt.QIcon(common.LEFT), '', self) back_button.setObjectName('Flat') back_button.setCursor(Qt.Qt.PointingHandCursor) back_button.setIconSize(Qt.QSize(35, 35)) back_button.setFixedSize(Qt.QSize(55, 55)) back_button.clicked.connect(lambda _: app.display_home_page()) profile_title = Qt.QLabel('Профиль', self) profile_title.setFont(Qt.QFont('Arial', 30)) profile_title.setAlignment(Qt.Qt.AlignCenter) scroll_area = Qt.QScrollArea() scroll_area.setWidgetResizable(True) scroll_area.setFrameShape(Qt.QFrame.NoFrame) info_title = Qt.QLabel('Информация', self) info_title.setFont(Qt.QFont('Arial', 25)) user_title = Qt.QLabel('Имя пользователя:', self) user_title.setFont(Qt.QFont('Arial', 20)) user_label = Qt.QLabel(user_name, self) user_label.setFont(Qt.QFont('Arial', 20, 65, True)) group_title = Qt.QLabel('Состоит в группе:', self) group_title.setFont(Qt.QFont('Arial', 20)) group_label = Qt.QLabel(group_name, self) group_label.setFont(Qt.QFont('Arial', 20, 65, True)) change_password_title = Qt.QLabel('Изменить пароль', self) change_password_title.setFont(Qt.QFont('Arial', 25)) old_password_title = Qt.QLabel('Старый пароль:', self) old_password_title.setFont(Qt.QFont('Arial', 20)) self.old_password_input = Qt.QLineEdit(self) self.old_password_input.setFont(Qt.QFont('Arial', 20)) self.old_password_input.setMinimumWidth(400) self.old_password_input.setEchoMode(Qt.QLineEdit.Password) new_password_title = Qt.QLabel('Новый пароль:', self) new_password_title.setFont(Qt.QFont('Arial', 20)) self.new_password_input = Qt.QLineEdit(self) self.new_password_input.setFont(Qt.QFont('Arial', 20)) self.new_password_input.setMinimumWidth(400) self.new_password_input.setEchoMode(Qt.QLineEdit.Password) self.new_password_input.textChanged.connect( self.update_change_password_button_state) repeat_title = Qt.QLabel('Повторите пароль:', self) repeat_title.setFont(Qt.QFont('Arial', 20)) self.repeat_input = Qt.QLineEdit(self) self.repeat_input.setFont(Qt.QFont('Arial', 20)) self.repeat_input.setMinimumWidth(400) self.repeat_input.setEchoMode(Qt.QLineEdit.Password) self.repeat_input.textChanged.connect( self.update_change_password_button_state) self.change_password_button = Qt.QPushButton('Изменить пароль', self) self.change_password_button.setObjectName('Button') self.change_password_button.setFont(Qt.QFont('Arial', 20)) self.change_password_button.clicked.connect( lambda: app.change_password(self.old_password_input.text(), self.new_password_input.text())) self.status_label = Qt.QLabel(self) self.status_label.setFont(Qt.QFont('Arial', 20)) self.status_label.setWordWrap(True) self.status_label.setMinimumWidth(380) upper_layout = Qt.QHBoxLayout() upper_layout.addWidget(back_button) upper_layout.addWidget(profile_title) info_title_layout = Qt.QVBoxLayout() info_title_layout.addWidget(user_title) info_title_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) info_title_layout.addWidget(group_title) info_label_layout = Qt.QVBoxLayout() info_label_layout.addWidget(user_label) info_label_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) info_label_layout.addWidget(group_label) info_layout = Qt.QHBoxLayout() info_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) info_layout.addLayout(info_title_layout) info_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) info_layout.addLayout(info_label_layout) info_layout.addStretch(1) change_password_title_layout = Qt.QVBoxLayout() change_password_title_layout.addWidget(old_password_title) change_password_title_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) change_password_title_layout.addWidget(new_password_title) change_password_title_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) change_password_title_layout.addWidget(repeat_title) change_password_input_layout = Qt.QVBoxLayout() change_password_input_layout.addWidget(self.old_password_input) change_password_input_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) change_password_input_layout.addWidget(self.new_password_input) change_password_input_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) change_password_input_layout.addWidget(self.repeat_input) change_password_main_layout = Qt.QHBoxLayout() change_password_main_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) change_password_main_layout.addLayout(change_password_title_layout) change_password_main_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) change_password_main_layout.addLayout(change_password_input_layout) change_password_main_layout.addStretch(1) change_password_button_layout = Qt.QHBoxLayout() change_password_button_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) change_password_button_layout.addWidget(self.change_password_button) change_password_button_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) change_password_button_layout.addWidget(self.status_label) change_password_button_layout.addStretch(1) scroll_layout = Qt.QVBoxLayout() scroll_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) scroll_layout.addWidget(info_title) scroll_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) scroll_layout.addLayout(info_layout) scroll_layout.addSpacerItem(Qt.QSpacerItem(0, 30)) scroll_layout.addWidget(change_password_title) scroll_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) scroll_layout.addLayout(change_password_main_layout) scroll_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) scroll_layout.addLayout(change_password_button_layout) scroll_layout.addStretch(1) scroll_widget = Qt.QWidget(self) scroll_widget.setLayout(scroll_layout) scroll_area.setWidget(scroll_widget) layout = Qt.QVBoxLayout() layout.addLayout(upper_layout) layout.addSpacerItem(Qt.QSpacerItem(0, 20)) layout.addWidget(scroll_area) self.setLayout(layout)
def __init__(self): gr.top_block.__init__(self, "Lab 3") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 3") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "lab3") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.freqc = freqc = 900 self.zeta = zeta = 0.707 self.std_dev = std_dev = 0.01 self.sps = sps = 8 self.samp_rate = samp_rate = 1000 self.nat_freq = nat_freq = 10000 self.lw = lw = 2 self.gain_ = gain_ = 0.5 self.freqc_ = freqc_ = freqc self.fps = fps = 30 self.fo = fo = 0 self.const_qpsk = const_qpsk = digital.constellation_calcdist(digital.psk_4()[0], digital.psk_4()[1], 4, 1).base() self.const_bpsk = const_bpsk = digital.constellation_calcdist(digital.psk_2()[0], digital.psk_2()[1], 2, 1).base() self.bw = bw = 1 self.buff_size = buff_size = 32768 self.bSignal = bSignal = 0 self.bSelectPLL = bSelectPLL = 0 self.axis = axis = 2 ################################################## # Blocks ################################################## self._zeta_range = Range(0, 4, 0.001, 0.707, 200) self._zeta_win = RangeWidget(self._zeta_range, self.set_zeta, 'Damping Factor (Zeta)', "counter_slider", float) self.top_grid_layout.addWidget(self._zeta_win, 13, 0, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Loop Filter Output') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Spectrum') self.top_grid_layout.addWidget(self.tab0, 0, 0, 10, 2) for r in range(0, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._std_dev_range = Range(0, 0.1, 0.001, 0.01, 200) self._std_dev_win = RangeWidget(self._std_dev_range, self.set_std_dev, 'Noise Std. Dev', "counter_slider", float) self.top_grid_layout.addWidget(self._std_dev_win, 11, 0, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._nat_freq_range = Range(0, 100e3, 1, 10000, 200) self._nat_freq_win = RangeWidget(self._nat_freq_range, self.set_nat_freq, 'Natural Freq (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._nat_freq_win, 13, 1, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._gain__range = Range(0.1, 1, 0.01, 0.5, 200) self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'Gain (Amp)', "counter_slider", float) self.top_grid_layout.addWidget(self._gain__win, 10, 1, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._freqc__range = Range(70, 6000, .01, freqc, 200) self._freqc__win = RangeWidget(self._freqc__range, self.set_freqc_, 'Carrier (MHz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freqc__win, 10, 0, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._fo_range = Range(0, 100e3, 100, 0, 200) self._fo_win = RangeWidget(self._fo_range, self.set_fo, 'Frequency Offset (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._fo_win, 11, 1, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._bSignal_options = (0, 1, 2, ) # Create the labels list self._bSignal_labels = ('Tone', 'BPSK', 'QPSK', ) # Create the combo box # Create the radio buttons self._bSignal_group_box = Qt.QGroupBox('Signal Select' + ": ") self._bSignal_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._bSignal_button_group = variable_chooser_button_group() self._bSignal_group_box.setLayout(self._bSignal_box) for i, _label in enumerate(self._bSignal_labels): radio_button = Qt.QRadioButton(_label) self._bSignal_box.addWidget(radio_button) self._bSignal_button_group.addButton(radio_button, i) self._bSignal_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bSignal_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bSignal_options.index(i))) self._bSignal_callback(self.bSignal) self._bSignal_button_group.buttonClicked[int].connect( lambda i: self.set_bSignal(self._bSignal_options[i])) self.top_grid_layout.addWidget(self._bSignal_group_box, 12, 0, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._bSelectPLL_options = (0, 1, 2, 3, ) # Create the labels list self._bSelectPLL_labels = ('Standard', 'Costas', 'Costas w/ HL', 'QPSK Costas', ) # Create the combo box # Create the radio buttons self._bSelectPLL_group_box = Qt.QGroupBox('PLL Order' + ": ") self._bSelectPLL_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._bSelectPLL_button_group = variable_chooser_button_group() self._bSelectPLL_group_box.setLayout(self._bSelectPLL_box) for i, _label in enumerate(self._bSelectPLL_labels): radio_button = Qt.QRadioButton(_label) self._bSelectPLL_box.addWidget(radio_button) self._bSelectPLL_button_group.addButton(radio_button, i) self._bSelectPLL_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bSelectPLL_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bSelectPLL_options.index(i))) self._bSelectPLL_callback(self.bSelectPLL) self._bSelectPLL_button_group.buttonClicked[int].connect( lambda i: self.set_bSelectPLL(self._bSelectPLL_options[i])) self.top_grid_layout.addWidget(self._bSelectPLL_group_box, 12, 1, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.wes_costas_cc_0 = wes.costas_cc(nat_freq / (samp_rate*1000), zeta, bSelectPLL) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 4096, #size samp_rate*1000, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-10000, 10000) self.qtgui_time_sink_x_0_0.set_y_label('Frequency (Hz)', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ['blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 1 ) self.qtgui_freq_sink_x_0.set_update_time(1/fps) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) labels = ['In-Phase', 'Quadrature', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0.set_processor_affinity([0]) self.interp_fir_filter_xxx_1_0_0 = filter.interp_fir_filter_ccc(sps, (1,1,1,1,1,1,1,1)) self.interp_fir_filter_xxx_1_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_1_0 = filter.interp_fir_filter_ccc(sps, (1,1,1,1,1,1,1,1)) self.interp_fir_filter_xxx_1_0.declare_sample_delay(0) self.iio_pluto_source_0 = iio.pluto_source(epy_module_0.RX, int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, True, True, True, 'manual', 32, '', True) self.iio_pluto_sink_0 = iio.pluto_sink(epy_module_0.TX, int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, False, 10.0, '', True) self.digital_chunks_to_symbols_xx_1_0 = digital.chunks_to_symbols_bc(const_qpsk.points(), 1) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc(const_bpsk.points(), 1) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex*1,bSignal,0) self.blocks_selector_0_0.set_enabled(True) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_cc(1/6.28*samp_rate*1000) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(gain_ ) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_0 = blocks.add_const_cc(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate*1000, analog.GR_COS_WAVE, fo, 1, 0, 0) self.analog_random_source_x_0_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 4, 8192))), True) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 2, 8192))), True) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, std_dev, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.wes_costas_cc_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.analog_random_source_x_0_0, 0), (self.digital_chunks_to_symbols_xx_1_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_selector_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_selector_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_1_0, 0), (self.interp_fir_filter_xxx_1_0_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_selector_0_0, 1)) self.connect((self.interp_fir_filter_xxx_1_0_0, 0), (self.blocks_selector_0_0, 2)) self.connect((self.wes_costas_cc_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.wes_costas_cc_0, 1), (self.blocks_tag_gate_0, 0))
def __init__(self): gr.top_block.__init__(self, "Wifi Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Tx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wifi_tx") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.tx_gain = tx_gain = 0.75 self.samp_rate = samp_rate = 2e6 self.pdu_length = pdu_length = 500 self.out_buf_size = out_buf_size = 96000 self.lo_offset = lo_offset = 0 self.interval = interval = 100 self.freq = freq = 2412000000.0 self.encoding = encoding = 0 self.device_6 = device_6 = "hackrf=26b468dc3540b58f" self.device_5 = device_5 = "hackrf=88869dc38686a1b" self.device_4 = device_4 = "hackrf=88869dc2930b41b" self.device_3 = device_3 = "hackrf=88869dc3347501b" self.device_2 = device_2 = "hackrf=88869dc3918701b" self.device_1 = device_1 = "hackrf=88869dc3397a01b" self.RF = RF = 14 self.IF = IF = 30 self.BB = BB = 20 ################################################## # Blocks ################################################## # Create the options list self._samp_rate_options = [ 2000000.0, 5000000.0, 10000000.0, 20000000.0 ] # Create the labels list self._samp_rate_labels = ['2MHz', '5 MHz', '10 MHz', '20 MHz'] # Create the combo box self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate: ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for _label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(_label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) # Create the radio buttons self.top_layout.addWidget(self._samp_rate_tool_bar) self._pdu_length_range = Range(0, 1500, 1, 500, 200) self._pdu_length_win = RangeWidget(self._pdu_length_range, self.set_pdu_length, 'pdu_length', "counter_slider", int) self.top_layout.addWidget(self._pdu_length_win) self._interval_range = Range(10, 1000, 1, 100, 200) self._interval_win = RangeWidget(self._interval_range, self.set_interval, 'interval', "counter_slider", int) self.top_layout.addWidget(self._interval_win) # Create the options list self._encoding_options = [0, 1, 2, 3, 4, 5, 6, 7] # Create the labels list self._encoding_labels = [ 'BPSK 1/2', 'BPSK 3/4', 'QPSK 1/2', 'QPSK 3/4', '16QAM 1/2', '16QAM 3/4', '64QAM 2/3', '64QAM 3/4' ] # Create the combo box # Create the radio buttons self._encoding_group_box = Qt.QGroupBox('encoding' + ": ") self._encoding_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._encoding_button_group = variable_chooser_button_group() self._encoding_group_box.setLayout(self._encoding_box) for i, _label in enumerate(self._encoding_labels): radio_button = Qt.QRadioButton(_label) self._encoding_box.addWidget(radio_button) self._encoding_button_group.addButton(radio_button, i) self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod( self._encoding_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._encoding_options.index(i))) self._encoding_callback(self.encoding) self._encoding_button_group.buttonClicked[int].connect( lambda i: self.set_encoding(self._encoding_options[i])) self.top_layout.addWidget(self._encoding_group_box) self._RF_range = Range(0, 40, 1, 14, 200) self._RF_win = RangeWidget(self._RF_range, self.set_RF, 'RF', "counter_slider", float) self.top_layout.addWidget(self._RF_win) self._IF_range = Range(0, 40, 1, 30, 200) self._IF_win = RangeWidget(self._IF_range, self.set_IF, 'IF', "counter_slider", float) self.top_layout.addWidget(self._IF_win) self._BB_range = Range(0, 40, 1, 20, 200) self._BB_win = RangeWidget(self._BB_range, self.set_BB, 'BB', "counter_slider", float) self.top_layout.addWidget(self._BB_win) self.wifi_phy_hier_0 = wifi_phy_hier( bandwidth=samp_rate, chan_est=0, encoding=encoding, frequency=2.45e9, sensitivity=0.56, ) self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'tx_gain', "counter_slider", float) self.top_layout.addWidget(self._tx_gain_win) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + device_1) self.osmosdr_sink_0.set_time_unknown_pps(osmosdr.time_spec_t()) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(2.45e9, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(RF, 0) self.osmosdr_sink_0.set_if_gain(IF, 0) self.osmosdr_sink_0.set_bb_gain(BB, 0) self.osmosdr_sink_0.set_antenna('', 0) self.osmosdr_sink_0.set_bandwidth(0, 0) # Create the options list self._lo_offset_options = [0, 6000000.0, 11000000.0] # Create the labels list self._lo_offset_labels = ['0', '6000000.0', '11000000.0'] # Create the combo box self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset: ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for _label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(_label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) # Create the radio buttons self.top_layout.addWidget(self._lo_offset_tool_bar) self.ieee802_11_mac_0 = ieee802_11.mac( [0x23, 0x23, 0x23, 0x23, 0x23, 0x23], [0x42, 0x42, 0x42, 0x42, 0x42, 0x42], [0xff, 0xff, 0xff, 0xff, 0xff, 255]) # Create the options list self._freq_options = [ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ] # Create the labels list self._freq_labels = [ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ] # Create the combo box self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq: ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for _label in self._freq_labels: self._freq_combo_box.addItem(_label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) # Create the radio buttons self.top_layout.addWidget(self._freq_tool_bar) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.01, 100, 1000) self.foo_packet_pad2_0.set_min_output_buffer(96000) self.blocks_vector_source_x_0 = blocks.vector_source_c((0, ), False, 1, []) self.blocks_socket_pdu_0 = blocks.socket_pdu('TCP_SERVER', '', '52001', 10000, False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.6) self.blocks_multiply_const_vxx_0.set_min_output_buffer(100000) self.blocks_message_strobe_0_0 = blocks.message_strobe( pmt.intern("".join("x" for i in range(pdu_length))), interval) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_11_mac_0, 'app in')) self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.ieee802_11_mac_0, 'app in')) self.msg_connect((self.ieee802_11_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, parent=None): Qt.QMainWindow.__init__(self, parent) self.frame = Qt.QFrame() self.hLayout = Qt.QHBoxLayout() self.vLayout = Qt.QVBoxLayout() self.label1 = QtWidgets.QLabel("Altere entre as teclas W e S") self.label2 = QtWidgets.QLabel("Digite a altura da forma") self.label3 = QtWidgets.QLabel("Digite a largura da forma") self.label4 = QtWidgets.QLabel("Digite a profundidade da forma") self.editAltura = QtWidgets.QSpinBox() self.editAltura.setMinimum(1) self.editAltura.setMaximum(50) self.editAltura.setSingleStep(1) self.editAltura.setValue(10) self.editAltura.valueChanged.connect(self.atualizarDesenho) self.editLargura = QtWidgets.QSpinBox() self.editLargura.setMinimum(1) self.editLargura.setMaximum(50) self.editLargura.setSingleStep(1) self.editLargura.setValue(20) self.editLargura.valueChanged.connect(self.atualizarDesenho) self.editProfundidade = QtWidgets.QSpinBox() self.editProfundidade.setMinimum(1) self.editProfundidade.setMaximum(50) self.editProfundidade.setSingleStep(1) self.editProfundidade.setValue(30) self.editProfundidade.valueChanged.connect(self.atualizarDesenho) self.vLayout.addWidget(self.label1) self.vLayout.addWidget(self.label2) self.vLayout.addWidget(self.editAltura) self.vLayout.addWidget(self.label3) self.vLayout.addWidget(self.editLargura) self.vLayout.addWidget(self.label4) self.vLayout.addWidget(self.editProfundidade) self.vLayout.addStretch(1) self.hLayout.addLayout(self.vLayout) self.hLayout.addStretch(1) self.vtkWidget = QVTKRenderWindowInteractor(self.frame) self.hLayout.addWidget(self.vtkWidget) self.setLayout(self.hLayout) self.ren = vtk.vtkRenderer() self.vtkWidget.GetRenderWindow().AddRenderer(self.ren) self.iren = self.vtkWidget.GetRenderWindow().GetInteractor() # Create source self.source = vtk.vtkCubeSource() self.source.SetCenter(0, 0, 0) self.source.SetXLength(10) self.source.SetYLength(20) self.source.SetZLength(30) # Create a mapper self.mapper = vtk.vtkPolyDataMapper() self.mapper.SetInputConnection(self.source.GetOutputPort()) # Create an actor self.actor = vtk.vtkActor() self.actor.SetMapper(self.mapper) self.ren.AddActor(self.actor) self.ren.ResetCamera() self.frame.setLayout(self.hLayout) self.setCentralWidget(self.frame) self.show() self.iren.Initialize() self.iren.Start()
def __init__(self): super().__init__() self.style = ['QPushButton {background-color: #eeeeec}', \ 'QPushButton {background-color: #babdb6}'] self.fileURL = '' self.sbFontSize = Qt.QSpinBox() self.sbFontSize.setRange(5, 40) self.sbFontSize.setValue(12) self.sbFontSize.valueChanged.connect(self.onFontSizeChanged) self.button = [] self.button.append(Qt.QPushButton('Подчеркнуть', self)) self.button[0].clicked.connect(self.onFontUnderlineChanged) self.button.append(Qt.QPushButton('Курсив', self)) self.button[1].clicked.connect(self.onFontItalicChanged) self.button.append(Qt.QPushButton('Жирный', self)) self.button[2].clicked.connect(self.onFontBoldChanged) self.statusBar() self.setFocus() self.combo = QtWidgets.QComboBox(self) self.combo.setEditable(True) self.combo.editTextChanged.connect(self.onFontFamilyChanged) self.combo.addItems(QtGui.QFontDatabase().families()) self.textEdit = Qt.QTextEdit('') self.textEdit.setFontWeight(12) if 'Arial' in QtGui.QFontDatabase().families(): self.textEdit.setFontFamily('Arial') else: self.textEdit.setFontFamily('Ubuntu') self.textEdit.cursorPositionChanged.connect(self.cursorPositionChanged) layout = Qt.QHBoxLayout() layout.addWidget(self.sbFontSize) for i in self.button[0:3]: i.setStyleSheet(self.style[0]) layout.addWidget(i) layout.addWidget(self.combo) edit = Qt.QWidget() edit.setLayout(layout) layout1 = Qt.QHBoxLayout() layout1.addWidget(self.sbFontSize) for i in self.button[3:]: i.setStyleSheet(self.style[0]) layout1.addWidget(i) redact = Qt.QWidget() redact.setLayout(layout1) layout2 = Qt.QVBoxLayout() layout2.addWidget(redact) layout2.addWidget(edit) layout2.addWidget(self.textEdit) central_widget = Qt.QWidget() central_widget.setLayout(layout2) self.cursorPositionChanged() self.setCentralWidget(central_widget) Open = QAction('Open', self) Open.setShortcut('Ctrl+O') Open.setStatusTip('Open new File') Open.triggered.connect(self.openFile) Save = QAction('Save', self) Save.setShortcut('Ctrl+S') Save.setStatusTip('Save File') Save.triggered.connect(self.saveFile) New = QAction('New', self) New.setShortcut('Ctrl+N') New.setStatusTip('New File') New.triggered.connect(self.newFile) menubar = self.menuBar() file = menubar.addMenu('&File') file.addAction(Open) file.addAction(Save) file.addAction(New)
def setup_ui(self) -> None: self.setVisible(False) layout = Qt.QVBoxLayout(self) layout.setObjectName('SceningToolbar.setup_ui.layout') layout.setContentsMargins(0, 0, 0, 0) layout_line_1 = Qt.QHBoxLayout() layout_line_1.setObjectName('SceningToolbar.setup_ui.layout_line_1') layout.addLayout(layout_line_1) self.items_combobox = ComboBox[SceningList](self) self.items_combobox.setDuplicatesEnabled(True) self.items_combobox.setMinimumContentsLength(4) layout_line_1.addWidget(self.items_combobox) self.add_list_button = Qt.QPushButton(self) self.add_list_button.setText('Add List') layout_line_1.addWidget(self.add_list_button) self.remove_list_button = Qt.QPushButton(self) self.remove_list_button.setText('Remove List') self.remove_list_button.setEnabled(False) layout_line_1.addWidget(self.remove_list_button) self.view_list_button = Qt.QPushButton(self) self.view_list_button.setText('View List') self.view_list_button.setEnabled(False) layout_line_1.addWidget(self.view_list_button) self.import_file_button = Qt.QPushButton(self) self.import_file_button.setText('Import List') layout_line_1.addWidget(self.import_file_button) self.seek_to_prev_button = Qt.QToolButton(self) self.seek_to_prev_button.setText('⏪') self.seek_to_prev_button.setEnabled(False) layout_line_1.addWidget(self.seek_to_prev_button) font = self.seek_to_prev_button.font() font.setPixelSize(19) self.seek_to_prev_button.setFont(font) self.seek_to_next_button = Qt.QToolButton(self) self.seek_to_next_button.setText('⏩') self.seek_to_next_button.setFont(font) self.seek_to_next_button.setEnabled(False) layout_line_1.addWidget(self.seek_to_next_button) layout_line_1.addStretch() layout_line_2 = Qt.QHBoxLayout() layout_line_2.setObjectName('SceningToolbar.setup_ui.layout_line_2') layout.addLayout(layout_line_2) self.add_single_frame_button = Qt.QToolButton(self) # self.add_single_frame_button.setText('Add Single Frame') self.add_single_frame_button.setText('🆎') self.add_single_frame_button.setFont(font) self.add_single_frame_button.setToolTip('Add Single Frame Scene') layout_line_2.addWidget(self.add_single_frame_button) self.toggle_first_frame_button = Qt.QToolButton(self) # self.toggle_first_frame_button.setText('Frame 1') self.toggle_first_frame_button.setText('🅰️') self.toggle_first_frame_button.setFont(font) self.toggle_first_frame_button.setToolTip('Toggle Start of New Scene') self.toggle_first_frame_button.setCheckable(True) layout_line_2.addWidget(self.toggle_first_frame_button) self.toggle_second_frame_button = Qt.QToolButton(self) # self.toggle_second_frame_button.setText('Frame 2') self.toggle_second_frame_button.setText('🅱️') self.toggle_second_frame_button.setFont(font) self.toggle_second_frame_button.setToolTip('Toggle End of New Scene') self.toggle_second_frame_button.setCheckable(True) layout_line_2.addWidget(self.toggle_second_frame_button) self.label_lineedit = Qt.QLineEdit(self) self.label_lineedit.setPlaceholderText('New Scene Label') layout_line_2.addWidget(self.label_lineedit) self.add_to_list_button = Qt.QPushButton(self) self.add_to_list_button.setText('Add to List') self.add_to_list_button.setEnabled(False) layout_line_2.addWidget(self.add_to_list_button) self.remove_last_from_list_button = Qt.QPushButton(self) self.remove_last_from_list_button.setText('Remove Last') self.remove_last_from_list_button.setEnabled(False) layout_line_2.addWidget(self.remove_last_from_list_button) self.remove_at_current_frame_button = Qt.QPushButton(self) self.remove_at_current_frame_button.setText('Remove at Current Frame') self.remove_at_current_frame_button.setEnabled(False) layout_line_2.addWidget(self.remove_at_current_frame_button) separator_line_2 = Qt.QFrame(self) separator_line_2.setObjectName( 'SceningToolbar.setup_ui.separator_line_2') separator_line_2.setFrameShape(Qt.QFrame.VLine) separator_line_2.setFrameShadow(Qt.QFrame.Sunken) layout_line_2.addWidget(separator_line_2) self.export_template_label = Qt.QLabel(self) self.export_template_label.setText('Export Template:') layout_line_2.addWidget(self.export_template_label) self.export_template_lineedit = Qt.QLineEdit(self) self.export_template_lineedit.setToolTip( r'Use {start} and {end} as placeholders. ' r'Both are valid for single frame scenes. ' r'{label} is available, too.' ) self.export_template_lineedit.setText(r'({start},{end}),') layout_line_2.addWidget(self.export_template_lineedit) self.export_multiline_button = Qt.QPushButton(self) self.export_multiline_button.setText('Export Multiline') self.export_multiline_button.setEnabled(False) layout_line_2.addWidget(self.export_multiline_button) self.export_single_line_button = Qt.QPushButton(self) self.export_single_line_button.setText('Export Single Line') self.export_single_line_button.setEnabled(False) layout_line_2.addWidget(self.export_single_line_button) layout_line_2.addStretch() layout_line_2.addStretch() # statusbar label self.status_label = Qt.QLabel(self) self.status_label.setVisible(False) self.main.statusbar.addPermanentWidget(self.status_label)
def setup_ui(self) -> None: layout = Qt.QHBoxLayout(self) layout.setObjectName('PlaybackToolbar.setup_ui.layout') layout.setContentsMargins(0, 0, 0, 0) self.seek_to_start_button = Qt.QToolButton(self) self.seek_to_start_button.setText('⏮') self.seek_to_start_button.setToolTip('Seek to First Frame') layout.addWidget(self.seek_to_start_button) font = self.seek_to_start_button.font() font.setPixelSize(19) self.seek_to_start_button.setFont(font) self.seek_n_frames_b_button = Qt.QToolButton(self) self.seek_n_frames_b_button.setText('⏪') self.seek_n_frames_b_button.setFont(font) self.seek_n_frames_b_button.setToolTip('Seek N Frames Backwards') layout.addWidget(self.seek_n_frames_b_button) self.seek_to_prev_button = Qt.QToolButton(self) self.seek_to_prev_button.setText('◂') self.seek_to_prev_button.setFont(font) self.seek_to_prev_button.setToolTip('Seek 1 Frame Backwards') layout.addWidget(self.seek_to_prev_button) self.play_pause_button = Qt.QToolButton(self) self.play_pause_button.setText('⏯') self.play_pause_button.setFont(font) self.play_pause_button.setToolTip('Play/Pause') self.play_pause_button.setCheckable(True) layout.addWidget(self.play_pause_button) self.seek_to_next_button = Qt.QToolButton(self) self.seek_to_next_button.setText('▸') self.seek_to_next_button.setFont(font) self.seek_to_next_button.setToolTip('Seek 1 Frame Forward') layout.addWidget(self.seek_to_next_button) self.seek_n_frames_f_button = Qt.QToolButton(self) self.seek_n_frames_f_button.setText('⏩') self.seek_n_frames_f_button.setFont(font) self.seek_n_frames_f_button.setToolTip('Seek N Frames Forward') layout.addWidget(self.seek_n_frames_f_button) self.seek_to_end_button = Qt.QToolButton(self) self.seek_to_end_button.setText('⏭') self.seek_to_end_button.setFont(font) self.seek_to_end_button.setToolTip('Seek to Last Frame') layout.addWidget(self.seek_to_end_button) self.seek_frame_control = FrameEdit[FrameInterval](self) self.seek_frame_control.setMinimum(FrameInterval(1)) self.seek_frame_control.setToolTip('Seek N Frames Step') layout.addWidget(self.seek_frame_control) self.seek_time_control = TimeEdit[TimeInterval](self) layout.addWidget(self.seek_time_control) self.fps_spinbox = Qt.QDoubleSpinBox(self) self.fps_spinbox.setRange(0.001, 9999.0) self.fps_spinbox.setDecimals(3) self.fps_spinbox.setSuffix(' fps') layout.addWidget(self.fps_spinbox) self.fps_reset_button = Qt.QPushButton(self) self.fps_reset_button.setText('Reset FPS') layout.addWidget(self.fps_reset_button) self.fps_unlimited_checkbox = Qt.QCheckBox(self) self.fps_unlimited_checkbox.setText('Unlimited FPS') layout.addWidget(self.fps_unlimited_checkbox) layout.addStretch()
def initWidgets(self): pixmap = Qt.QPixmap("./icons/arrow.png") base = pixmap.transformed(Qt.QTransform().rotate(-90)) arrow_u = Qt.QIcon(base) arrow_r = Qt.QIcon(base.transformed(Qt.QTransform().rotate(90))) arrow_l = Qt.QIcon(base.transformed(Qt.QTransform().rotate(270))) arrow_d = Qt.QIcon(base.transformed(Qt.QTransform().rotate(180))) arrow_ur = base.transformed(Qt.QTransform().rotate(45)) x = (arrow_ur.width() - base.width()) / 2 y = (arrow_ur.height() - base.height()) / 2 arrow_ur = Qt.QIcon(arrow_ur.copy(x, y, base.width(), base.height())) arrow_dr = Qt.QIcon( base.transformed(Qt.QTransform().rotate(135)).copy( x, y, base.width(), base.height())) arrow_dl = Qt.QIcon( base.transformed(Qt.QTransform().rotate(225)).copy( x, y, base.width(), base.height())) arrow_ul = Qt.QIcon( base.transformed(Qt.QTransform().rotate(315)).copy( x, y, base.width(), base.height())) btn_size = 20 frame_lbl = Qt.QLabel("Slew Controls:") frame_lbl.setAlignment(Qt.Qt.AlignLeft | Qt.Qt.AlignVCenter) frame_lbl.setStyleSheet( "QLabel {font:12pt; font-weight:bold; text-decoration: underline; color:rgb(255,0,0);}" ) frame_lbl.setFixedWidth(200) frame_lbl.setFixedHeight(20) #Top Row of buttons self.ulButton = Qt.QPushButton(self) self.ulButton.setIcon(arrow_ul) self.ulButton.setIconSize(Qt.QSize(btn_size, btn_size)) self.ulButton.setStyleSheet( "QPushButton { background-color:rgb(200,0,0); }") self.uButton = Qt.QPushButton(self) self.uButton.setIcon(arrow_u) self.uButton.setIconSize(Qt.QSize(btn_size, btn_size)) self.uButton.setStyleSheet( "QPushButton { background-color:rgb(200,0,0); }") self.urButton = Qt.QPushButton(self) self.urButton.setIcon(arrow_ur) self.urButton.setIconSize(Qt.QSize(btn_size, btn_size)) self.urButton.setStyleSheet( "QPushButton { background-color:rgb(200,0,0); }") top_hbox = Qt.QHBoxLayout() top_hbox.addWidget(self.ulButton) top_hbox.addWidget(self.uButton) top_hbox.addWidget(self.urButton) #Middle Row of buttons self.lButton = Qt.QPushButton(self) self.lButton.setIcon(arrow_l) self.lButton.setIconSize(Qt.QSize(btn_size, btn_size)) self.lButton.setStyleSheet( "QPushButton { background-color:rgb(200,0,0); }") self.stopButton = Qt.QPushButton(self) pixmap = Qt.QPixmap("./icons/stop.png") self.stopButton.setIcon(Qt.QIcon(pixmap)) self.stopButton.setIconSize(Qt.QSize(btn_size, btn_size)) self.stopButton.setStyleSheet( "QPushButton { background-color:rgb(200,0,0); }") self.rButton = Qt.QPushButton(self) self.rButton.setIcon(arrow_r) self.rButton.setIconSize(Qt.QSize(btn_size, btn_size)) self.rButton.setStyleSheet( "QPushButton { background-color:rgb(200,0,0); }") middle_hbox = Qt.QHBoxLayout() middle_hbox.addWidget(self.lButton) middle_hbox.addWidget(self.stopButton) middle_hbox.addWidget(self.rButton) #Bottom Row of Buttons self.dlButton = Qt.QPushButton(self) self.dlButton.setIcon(arrow_dl) self.dlButton.setIconSize(Qt.QSize(btn_size, btn_size)) self.dlButton.setStyleSheet( "QPushButton { background-color:rgb(200,0,0); }") self.dButton = Qt.QPushButton(self) self.dButton.setIcon(arrow_d) self.dButton.setIconSize(Qt.QSize(btn_size, btn_size)) self.dButton.setStyleSheet( "QPushButton { background-color:rgb(200,0,0); }") self.drButton = Qt.QPushButton(self) self.drButton.setIcon(arrow_dr) self.drButton.setIconSize(Qt.QSize(btn_size, btn_size)) self.drButton.setStyleSheet( "QPushButton { background-color:rgb(200,0,0); }") bottom_hbox = Qt.QHBoxLayout() bottom_hbox.addWidget(self.dlButton) bottom_hbox.addWidget(self.dButton) bottom_hbox.addWidget(self.drButton) #Controls for Azimuth Motor Speed lbl = Qt.QLabel("Azimuth Speed:") lbl.setAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignVCenter) lbl.setStyleSheet("QLabel {font:10pt; color:rgb(255,0,0);}") lbl.setFixedWidth(100) self.slewAzSpeedSlider = Qt.QSlider(QtCore.Qt.Horizontal) self.slewAzSpeedSlider.setMaximum(9) self.slewAzSpeedSlider.setMinimum(1) self.slewAzSpeedSlider.setValue(9) self.slewAzSpeedSlider.setStyleSheet( "QSlider {background-color:rgb(0,0,0); color:rgb(200,0,0)}") self.slewAzLabel = Qt.QLabel("{:d}".format(self.az_speed)) self.slewAzLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.slewAzLabel.setStyleSheet("QLabel {color:rgb(255,0,0);}") az_hbox = Qt.QHBoxLayout() az_hbox.addWidget(lbl) az_hbox.addWidget(self.slewAzSpeedSlider) az_hbox.addWidget(self.slewAzLabel) #Controls for Elevation Motor Speed lbl = Qt.QLabel("Elevation Speed:") lbl.setAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignVCenter) lbl.setStyleSheet("QLabel { font:10pt; color:rgb(255,0,0);}") lbl.setFixedWidth(100) self.slewElSpeedSlider = Qt.QSlider(QtCore.Qt.Horizontal) self.slewElSpeedSlider.setMaximum(9) self.slewElSpeedSlider.setMinimum(1) self.slewElSpeedSlider.setValue(9) self.slewElSpeedSlider.setStyleSheet( "QSlider {background-color:rgb(0,0,0); color:rgb(200,0,0)}") self.slewElLabel = Qt.QLabel("{:d}".format(self.el_speed)) self.slewElLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.slewElLabel.setStyleSheet("QLabel {color:rgb(255,0,0);}") el_hbox = Qt.QHBoxLayout() el_hbox.addWidget(lbl) el_hbox.addWidget(self.slewElSpeedSlider) el_hbox.addWidget(self.slewElLabel) self.lock_cb = Qt.QCheckBox('Synchronize Speeds', self) self.lock_cb.setStyleSheet( "QCheckBox { font:10pt; background-color:rgb(0,0,0); color:rgb(255,0,0); }" ) self.lock_cb.setChecked(True) vbox = Qt.QVBoxLayout() vbox.addWidget(frame_lbl) vbox.addLayout(top_hbox) vbox.addLayout(middle_hbox) vbox.addLayout(bottom_hbox) vbox.addLayout(az_hbox) vbox.addLayout(el_hbox) vbox.addWidget(self.lock_cb) vbox.addStretch(1) self.setLayout(vbox)
def initUI(self): # init the UI self.qlabel_serial = Qt.QLabel('Connected FPGAs') self.qlabel_broadcast = Qt.QLabel('UDP Broadcast address') self.qlabel_firmware = Qt.QLabel('FPGA Firmware file') self.qlabel_software = Qt.QLabel('CPU Software file') self.qcombo_serial = Qt.QComboBox() self.qcombo_serial.setMinimumContentsLength(100) # I can't figure out how to make it scale correctly with content so we'll make it big enough... self.qcombo_serial.setSizeAdjustPolicy(Qt.QComboBox.AdjustToMinimumContentsLength) self.qedit_broadcast = Qt.QLineEdit(self.strBroadcastAddress) self.qedit_firmware = Qt.QLineEdit(self.strFPGAFirmware) self.qedit_software = Qt.QLineEdit(self.strCPUFirmware) self.qbtn_send_broadcast = Qt.QPushButton('Broadcast discovery packet') self.qbtn_reprogram_fpga = Qt.QPushButton('Update FPGA firmware') self.qbtn_reprogram_cpu = Qt.QPushButton('Update CPU software') self.qbtn_send_broadcast.clicked.connect(self.reset_list_and_send_broadcast) self.qbtn_reprogram_fpga.clicked.connect(self.programFPGAClicked) self.qbtn_reprogram_cpu.clicked.connect(self.programCPUClicked) self.qradio_reprogram = Qt.QRadioButton('Send default values') self.qradio_noreprogram = Qt.QRadioButton('Connect to an already running box (NOT WORKING YET)') self.qradio_reprogram.setChecked(True) self.qradio_noreprogram.setDisabled(True) btn_group = Qt.QButtonGroup(self) btn_group.addButton(self.qradio_reprogram) btn_group.setId(self.qradio_reprogram, 0) btn_group.addButton(self.qradio_noreprogram) btn_group.setId(self.qradio_noreprogram, 1) # btn_group2 = Qt.QButtonGroup(self) # btn_group2.addButton(self.qradio_usefromlist) # btn_group2.setId(self.qradio_usefromlist, 0) # btn_group2.addButton(self.qradio_usefromtextbox) # btn_group2.setId(self.qradio_usefromtextbox, 1) self.qbtn_yes = Qt.QPushButton('OK') self.qbtn_no = Qt.QPushButton('Cancel') self.qbtn_yes.clicked.connect(self.okClicked) self.qbtn_no.clicked.connect(self.cancelClicked) self.qgroupbox_IP_addr = Qt.QGroupBox('IP Address') gridIP = Qt.QGridLayout() self.qradio_usefromlist = Qt.QRadioButton('Use listed') self.qradio_usefromtextbox = Qt.QRadioButton('Use manual entry') self.qradio_usefromtextbox.setChecked(False) self.qradio_usefromlist.setChecked(True) self.qlabel_manual_entry = Qt.QLabel('Manual IP entry') self.qedit_manual_entry = Qt.QLineEdit('') gridIP.addWidget(self.qradio_usefromtextbox, 0, 0) gridIP.addWidget(self.qlabel_manual_entry, 0, 1) gridIP.addWidget(self.qedit_manual_entry, 0, 2) gridIP.addWidget(self.qradio_usefromlist, 1, 0) gridIP.addWidget(self.qlabel_serial, 1, 1) gridIP.addWidget(self.qcombo_serial, 1, 2) gridIP.addWidget(self.qbtn_send_broadcast, 2, 0) gridIP.addWidget(self.qlabel_broadcast, 2, 1) gridIP.addWidget(self.qedit_broadcast, 2, 2) self.qgroupbox_IP_addr.setLayout(gridIP) self.qgroupbox_connection = Qt.QGroupBox('Red Pitaya Connection') gridConnection = Qt.QGridLayout() self.qradio_pushValue = Qt.QRadioButton('Push default values to Red Pitaya') self.qradio_existingRP = Qt.QRadioButton('Reconnect to an already running Red Pitaya') self.qradio_noRP = Qt.QRadioButton('Open the GUI without any Red Pitaya') self.qradio_existingRP.setChecked(True) gridConnection.addWidget(self.qradio_pushValue, 0, 0) gridConnection.addWidget(self.qradio_existingRP, 0, 1) gridConnection.addWidget(self.qradio_noRP, 0, 2) self.qgroupbox_connection.setLayout(gridConnection) # btn_group2 = Qt.QButtonGroup(self) # btn_group2.addButton(self.qradio_clk_internal) # btn_group2.addButton(self.qradio_clk_external) # btn_group2.setId(self.qradio_clk_internal, 2) # btn_group2.setId(self.qradio_clk_external, 3) # self.close.connect(self.closeEvent) grid = Qt.QGridLayout() grid.addWidget(self.qgroupbox_IP_addr, 2, 0, 1, 3) grid.addWidget(self.qgroupbox_connection, 0, 0, 1, 3) grid.addWidget(self.qbtn_reprogram_fpga, 3, 0) grid.addWidget(self.qlabel_firmware, 3, 1) grid.addWidget(self.qedit_firmware, 3, 2) grid.addWidget(self.qbtn_reprogram_cpu, 4, 0) grid.addWidget(self.qlabel_software, 4, 1) grid.addWidget(self.qedit_software, 4, 2) # #FEATURE # grid.addWidget(self.qradio_reprogram, 4, 0) # grid.addWidget(self.qradio_noreprogram, 4, 1) # grid.addWidget(self.qradio_clk_internal, 3, 0) # grid.addWidget(self.qradio_clk_external, 3, 1) # grid.addWidget(self.qbtn_yes, 4, 0) # grid.addWidget(self.qbtn_no, 4, 1) hbox = Qt.QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self.qbtn_yes) hbox.addWidget(self.qbtn_no) grid.addLayout(hbox, 5, 0, 1, 3) self.setLayout(grid) self.setWindowTitle('Initial configuration') self.qbtn_yes.setFocus() self.show()
def __init__(self): gr.top_block.__init__(self, "Dvbs2 Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Dvbs2 Tx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "dvbs2_tx") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.tx_gain = tx_gain = 0 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.qtgui_variable = qtgui_variable = '"labul' self.pilots = pilots = 0 self.noise_type = noise_type = "Gaussian" self.noise = noise = 0.1 self.code_rate_qpsk = code_rate_qpsk = "9/10" self.code_rate_8psk = code_rate_8psk = "9/10" self.code_rate_32apsk = code_rate_32apsk = "9/10" self.code_rate_16apsk = code_rate_16apsk = "9/10" self.center_freq = center_freq = 1280e6 self.browse_button = browse_button = 0 self.FEC_Frame_size = FEC_Frame_size = 'Normal' ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 89, 1, 0, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._rolloff_options = (0.2, 0.25, 0.35, ) self._rolloff_labels = (str(self._rolloff_options[0]), str(self._rolloff_options[1]), str(self._rolloff_options[2]), ) self._rolloff_tool_bar = Qt.QToolBar(self) self._rolloff_tool_bar.addWidget(Qt.QLabel('Rolloff'+": ")) self._rolloff_combo_box = Qt.QComboBox() self._rolloff_tool_bar.addWidget(self._rolloff_combo_box) for label in self._rolloff_labels: self._rolloff_combo_box.addItem(label) self._rolloff_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rolloff_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rolloff_options.index(i))) self._rolloff_callback(self.rolloff) self._rolloff_combo_box.currentIndexChanged.connect( lambda i: self.set_rolloff(self._rolloff_options[i])) self.top_grid_layout.addWidget(self._rolloff_tool_bar, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.constellation_tab = Qt.QTabWidget() self.constellation_tab_widget_0 = Qt.QWidget() self.constellation_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_0) self.constellation_tab_grid_layout_0 = Qt.QGridLayout() self.constellation_tab_layout_0.addLayout(self.constellation_tab_grid_layout_0) self.constellation_tab.addTab(self.constellation_tab_widget_0, 'QPSK') self.constellation_tab_widget_1 = Qt.QWidget() self.constellation_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_1) self.constellation_tab_grid_layout_1 = Qt.QGridLayout() self.constellation_tab_layout_1.addLayout(self.constellation_tab_grid_layout_1) self.constellation_tab.addTab(self.constellation_tab_widget_1, '8PSK') self.constellation_tab_widget_2 = Qt.QWidget() self.constellation_tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_2) self.constellation_tab_grid_layout_2 = Qt.QGridLayout() self.constellation_tab_layout_2.addLayout(self.constellation_tab_grid_layout_2) self.constellation_tab.addTab(self.constellation_tab_widget_2, '16APSK') self.constellation_tab_widget_3 = Qt.QWidget() self.constellation_tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.constellation_tab_widget_3) self.constellation_tab_grid_layout_3 = Qt.QGridLayout() self.constellation_tab_layout_3.addLayout(self.constellation_tab_grid_layout_3) self.constellation_tab.addTab(self.constellation_tab_widget_3, '32APSK') self.top_grid_layout.addWidget(self.constellation_tab, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_sink = uhd.usrp_sink( ",".join(('', '')), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink.set_samp_rate(samp_rate) self.uhd_usrp_sink.set_center_freq(center_freq, 0) self.uhd_usrp_sink.set_gain(tx_gain, 0) self._qtgui_variable_tool_bar = Qt.QToolBar(self) if None: self._qtgui_variable_formatter = None else: self._qtgui_variable_formatter = lambda x: str(x) self._qtgui_variable_tool_bar.addWidget(Qt.QLabel('label'+": ")) self._qtgui_variable_label = Qt.QLabel(str(self._qtgui_variable_formatter(self.qtgui_variable))) self._qtgui_variable_tool_bar.addWidget(self._qtgui_variable_label) self.top_grid_layout.addWidget(self._qtgui_variable_tool_bar, 3, 0, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink.set_update_time(0.10) self.qtgui_freq_sink.set_y_axis(-140, 10) self.qtgui_freq_sink.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink.enable_autoscale(False) self.qtgui_freq_sink.enable_grid(True) self.qtgui_freq_sink.set_fft_average(0.2) self.qtgui_freq_sink.enable_axis_labels(True) self.qtgui_freq_sink.enable_control_panel(False) if not True: self.qtgui_freq_sink.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink.set_plot_pos_half(not True) labels = ['DVB-S2', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink.set_line_label(i, labels[i]) self.qtgui_freq_sink.set_line_width(i, widths[i]) self.qtgui_freq_sink.set_line_color(i, colors[i]) self.qtgui_freq_sink.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_win = sip.wrapinstance(self.qtgui_freq_sink.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_win, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._pilots_options = (1, 0, ) self._pilots_labels = ("On", "Off", ) self._pilots_group_box = Qt.QGroupBox('Pilots') self._pilots_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._pilots_button_group = variable_chooser_button_group() self._pilots_group_box.setLayout(self._pilots_box) for i, label in enumerate(self._pilots_labels): radio_button = Qt.QRadioButton(label) self._pilots_box.addWidget(radio_button) self._pilots_button_group.addButton(radio_button, i) self._pilots_callback = lambda i: Qt.QMetaObject.invokeMethod(self._pilots_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._pilots_options.index(i))) self._pilots_callback(self.pilots) self._pilots_button_group.buttonClicked[int].connect( lambda i: self.set_pilots(self._pilots_options[i])) self.top_grid_layout.addWidget(self._pilots_group_box, 3, 1, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._noise_type_options = ("Uniform", "Gaussian", "Laplacian", "Impulse", ) self._noise_type_labels = (str(self._noise_type_options[0]), str(self._noise_type_options[1]), str(self._noise_type_options[2]), str(self._noise_type_options[3]), ) self._noise_type_tool_bar = Qt.QToolBar(self) self._noise_type_tool_bar.addWidget(Qt.QLabel('Noise Type'+": ")) self._noise_type_combo_box = Qt.QComboBox() self._noise_type_tool_bar.addWidget(self._noise_type_combo_box) for label in self._noise_type_labels: self._noise_type_combo_box.addItem(label) self._noise_type_callback = lambda i: Qt.QMetaObject.invokeMethod(self._noise_type_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._noise_type_options.index(i))) self._noise_type_callback(self.noise_type) self._noise_type_combo_box.currentIndexChanged.connect( lambda i: self.set_noise_type(self._noise_type_options[i])) self.top_grid_layout.addWidget(self._noise_type_tool_bar, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.noise_source = analog.noise_source_c(analog.GR_GAUSSIAN, 0, 0) self._noise_range = Range(0, 1, 0.01, 0.1, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise', "counter", float) self.top_grid_layout.addWidget(self._noise_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.file_source = blocks.file_source(gr.sizeof_char*1, '/home/anisan/videos/The_Maker/900.ts', True) self.file_source.set_begin_tag(pmt.PMT_NIL) self.fft_filter = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate/2, rolloff, taps)), 1) self.fft_filter.declare_sample_delay(0) self.dvbs2_physical = dvbs2.physical_cc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK, dvbs2.PILOTS_OFF, 0) self.dvbs2_modulator = dvbs2.modulator_bc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK) self.dvbs2_ldpc = dvbs2.ldpc_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_OTHER) self.dvbs2_interleaver = dvbs2.interleaver_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK) self.dvbs2_bbscrambler = dvbs2.bbscrambler_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10) self.dvbs2_bbheader = dvbs2.bbheader_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.RO_0_20) self.dvb_bch = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10) self._code_rate_qpsk_options = ["1/4", "1/3", "2/5", "1/2", "3/5", "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_qpsk_labels = map(str, self._code_rate_qpsk_options) self._code_rate_qpsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_qpsk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_qpsk_button_group = variable_chooser_button_group() self._code_rate_qpsk_group_box.setLayout(self._code_rate_qpsk_box) for i, label in enumerate(self._code_rate_qpsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_qpsk_box.addWidget(radio_button) self._code_rate_qpsk_button_group.addButton(radio_button, i) self._code_rate_qpsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_qpsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_qpsk_options.index(i))) self._code_rate_qpsk_callback(self.code_rate_qpsk) self._code_rate_qpsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_qpsk(self._code_rate_qpsk_options[i])) self.constellation_tab_layout_0.addWidget(self._code_rate_qpsk_group_box) self._code_rate_8psk_options = ["3/5", "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_8psk_labels = map(str, self._code_rate_8psk_options) self._code_rate_8psk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_8psk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_8psk_button_group = variable_chooser_button_group() self._code_rate_8psk_group_box.setLayout(self._code_rate_8psk_box) for i, label in enumerate(self._code_rate_8psk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_8psk_box.addWidget(radio_button) self._code_rate_8psk_button_group.addButton(radio_button, i) self._code_rate_8psk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_8psk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_8psk_options.index(i))) self._code_rate_8psk_callback(self.code_rate_8psk) self._code_rate_8psk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_8psk(self._code_rate_8psk_options[i])) self.constellation_tab_layout_1.addWidget(self._code_rate_8psk_group_box) self._code_rate_32apsk_options = ["3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_32apsk_labels = map(str, self._code_rate_32apsk_options) self._code_rate_32apsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_32apsk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_32apsk_button_group = variable_chooser_button_group() self._code_rate_32apsk_group_box.setLayout(self._code_rate_32apsk_box) for i, label in enumerate(self._code_rate_32apsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_32apsk_box.addWidget(radio_button) self._code_rate_32apsk_button_group.addButton(radio_button, i) self._code_rate_32apsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_32apsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_32apsk_options.index(i))) self._code_rate_32apsk_callback(self.code_rate_32apsk) self._code_rate_32apsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_32apsk(self._code_rate_32apsk_options[i])) self.constellation_tab_layout_3.addWidget(self._code_rate_32apsk_group_box) self._code_rate_16apsk_options = [ "2/3", "3/4", "4/5", "5/6", "8/9", "9/10"] self._code_rate_16apsk_labels = map(str, self._code_rate_16apsk_options) self._code_rate_16apsk_group_box = Qt.QGroupBox('Code Rate') self._code_rate_16apsk_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._code_rate_16apsk_button_group = variable_chooser_button_group() self._code_rate_16apsk_group_box.setLayout(self._code_rate_16apsk_box) for i, label in enumerate(self._code_rate_16apsk_labels): radio_button = Qt.QRadioButton(label) self._code_rate_16apsk_box.addWidget(radio_button) self._code_rate_16apsk_button_group.addButton(radio_button, i) self._code_rate_16apsk_callback = lambda i: Qt.QMetaObject.invokeMethod(self._code_rate_16apsk_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._code_rate_16apsk_options.index(i))) self._code_rate_16apsk_callback(self.code_rate_16apsk) self._code_rate_16apsk_button_group.buttonClicked[int].connect( lambda i: self.set_code_rate_16apsk(self._code_rate_16apsk_options[i])) self.constellation_tab_grid_layout_2.addWidget(self._code_rate_16apsk_group_box) _browse_button_push_button = Qt.QPushButton('Browse') self._browse_button_choices = {'Pressed': 1, 'Released': 0} _browse_button_push_button.pressed.connect(lambda: self.set_browse_button(self._browse_button_choices['Pressed'])) _browse_button_push_button.released.connect(lambda: self.set_browse_button(self._browse_button_choices['Released'])) self.top_grid_layout.addWidget(_browse_button_push_button, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.add_bloc = blocks.add_vcc(1) self._FEC_Frame_size_options = ('Normal', 'Short', ) self._FEC_Frame_size_labels = (str(self._FEC_Frame_size_options[0]), str(self._FEC_Frame_size_options[1]), ) self._FEC_Frame_size_group_box = Qt.QGroupBox('FEC Frame Size') self._FEC_Frame_size_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._FEC_Frame_size_button_group = variable_chooser_button_group() self._FEC_Frame_size_group_box.setLayout(self._FEC_Frame_size_box) for i, label in enumerate(self._FEC_Frame_size_labels): radio_button = Qt.QRadioButton(label) self._FEC_Frame_size_box.addWidget(radio_button) self._FEC_Frame_size_button_group.addButton(radio_button, i) self._FEC_Frame_size_callback = lambda i: Qt.QMetaObject.invokeMethod(self._FEC_Frame_size_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._FEC_Frame_size_options.index(i))) self._FEC_Frame_size_callback(self.FEC_Frame_size) self._FEC_Frame_size_button_group.buttonClicked[int].connect( lambda i: self.set_FEC_Frame_size(self._FEC_Frame_size_options[i])) self.top_grid_layout.addWidget(self._FEC_Frame_size_group_box, 4, 1, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.add_bloc, 0), (self.qtgui_freq_sink, 0)) self.connect((self.dvb_bch, 0), (self.dvbs2_ldpc, 0)) self.connect((self.dvbs2_bbheader, 0), (self.dvbs2_bbscrambler, 0)) self.connect((self.dvbs2_bbscrambler, 0), (self.dvb_bch, 0)) self.connect((self.dvbs2_interleaver, 0), (self.dvbs2_modulator, 0)) self.connect((self.dvbs2_ldpc, 0), (self.dvbs2_interleaver, 0)) self.connect((self.dvbs2_modulator, 0), (self.dvbs2_physical, 0)) self.connect((self.dvbs2_physical, 0), (self.fft_filter, 0)) self.connect((self.fft_filter, 0), (self.add_bloc, 0)) self.connect((self.file_source, 0), (self.dvbs2_bbheader, 0)) self.connect((self.noise_source, 0), (self.add_bloc, 1))
def __init__(self, example='layerName', parent=None): Qt.QDialog.__init__( self, parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint) self.setWindowTitle("Rename") self.base_name = example self.sb_remove_start = Qt.QSpinBox() self.sb_remove_start.setMinimumWidth(50) self.sb_remove_start.setRange(0, 9) self.sb_remove_start.setObjectName('trim_start') self.sb_remove_end = Qt.QSpinBox() self.sb_remove_end.setRange(0, 9) self.sb_remove_end.setMinimumWidth(50) self.sb_remove_end.setObjectName('trim_end') self.le_prefix = Qt.QLineEdit() self.le_prefix.setValidator( Qt.QRegExpValidator(Qt.QRegExp(valid_name_re), self)) self.le_prefix.setObjectName('prefix') self.le_suffix = Qt.QLineEdit() self.le_suffix.setValidator( Qt.QRegExpValidator(Qt.QRegExp(valid_name_re), self)) self.le_suffix.setObjectName('suffix') self.le_base_name = Qt.QLineEdit() self.le_base_name.setValidator( Qt.QRegExpValidator(Qt.QRegExp(valid_name_re), self)) # keep spaces for number self.le_base_name.setMaxLength(max_name_len - 2) self.le_base_name.setObjectName('basename') self.sb_padding = Qt.QSpinBox() self.sb_padding.setRange(1, 4) self.sb_padding.setValue(2) self.sb_padding.setObjectName('padding') self.sb_start = Qt.QSpinBox() self.sb_start.setRange(0, 999) self.sb_start.setObjectName('start') self.le_find = Qt.QLineEdit() self.le_find.setObjectName('find') self.le_replace = Qt.QLineEdit() self.le_replace.setValidator( Qt.QRegExpValidator(Qt.QRegExp(valid_name_re), self)) self.le_replace.setObjectName('replace') self.lbl_ex = Qt.QLabel('Example: ' + self.base_name + ' -> ') self.lbl_name = Qt.QLabel(self.base_name) pb_accept = Qt.QPushButton("Accept") pb_accept.clicked.connect(self.accept) pb_cancel = Qt.QPushButton("Cancel") pb_cancel.clicked.connect(self.reject) layout = Qt.QHBoxLayout() layout.addWidget(self.sb_padding) layout.addWidget(Qt.QLabel("start #: ")) layout.addWidget(self.sb_start) layout2 = Qt.QHBoxLayout() layout2.addStretch() layout2.addWidget(self.lbl_ex) layout2.addWidget(self.lbl_name) layout2.addStretch() grid = Qt.QGridLayout() grid.addWidget(Qt.QLabel("Find: "), 0, 0, 1, 1) grid.addWidget(self.le_find, 0, 1, 1, 2) grid.addWidget(Qt.QLabel("Replace: "), 0, 3, 1, 1) grid.addWidget(self.le_replace, 0, 4, 1, 2) grid.addWidget(Qt.QLabel("Strip start: "), 1, 0, 1, 1) grid.addWidget(self.sb_remove_start, 1, 1, 1, 1) grid.addItem( Qt.QSpacerItem(0, 0, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Fixed), 1, 2, 1, 1) grid.addWidget(Qt.QLabel("Strip end: "), 1, 3, 1, 1) grid.addWidget(self.sb_remove_end, 1, 4, 1, 1) grid.addItem( Qt.QSpacerItem(0, 0, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Fixed), 1, 5, 1, 1) grid.addWidget(Qt.QLabel("Base name: "), 2, 0, 1, 1) grid.addWidget(self.le_base_name, 2, 1, 1, 2) grid.addWidget(Qt.QLabel('Padding: '), 2, 3, 1, 1) grid.addLayout(layout, 2, 4, 1, 2) grid.addWidget(Qt.QLabel("Add prefix: "), 3, 0, 1, 1) grid.addWidget(self.le_prefix, 3, 1, 1, 2) grid.addWidget(Qt.QLabel("Add suffix: "), 3, 3, 1, 1) grid.addWidget(self.le_suffix, 3, 4, 1, 2) grid.addLayout(layout2, 4, 0, 1, 6) grid.addItem( Qt.QSpacerItem(0, 10, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Fixed), 5, 0, 1, 6) grid.addWidget(pb_accept, 6, 0, 1, 3) grid.addWidget(pb_cancel, 6, 3, 1, 3) self.setLayout(grid) self.setSizeGripEnabled(False) self.setSizePolicy(Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Fixed) self.connect_widgets() self.settings = ZlmSettings.instance().get('rename_ui', {}) self.load_settings()
def __init__(self): gr.top_block.__init__(self, "Wifi Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Rx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wifi_rx") self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 10e6 self.lo_offset = lo_offset = 0 self.gain = gain = 0.75 self.freq = freq = 5890000000 self.chan_est = chan_est = 0 ################################################## # Blocks ################################################## self._samp_rate_options = [5e6, 10e6, 20e6] self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_grid_layout.addWidget(self._samp_rate_tool_bar) self._lo_offset_options = ( 0, 6e6, 11e6, ) self._lo_offset_labels = ( str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), ) self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) self.top_grid_layout.addWidget(self._lo_offset_tool_bar) self._gain_range = Range(0, 1, 0.01, 0.75, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) self.top_grid_layout.addWidget(self._gain_win) self._freq_options = [ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ] self._freq_labels = [ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_grid_layout.addWidget(self._freq_tool_bar) self._chan_est_options = [ ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB ] self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"] self._chan_est_group_box = Qt.QGroupBox("chan_est") self._chan_est_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._chan_est_button_group = variable_chooser_button_group() self._chan_est_group_box.setLayout(self._chan_est_box) for i, label in enumerate(self._chan_est_labels): radio_button = Qt.QRadioButton(label) self._chan_est_box.addWidget(radio_button) self._chan_est_button_group.addButton(radio_button, i) self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod( self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i))) self._chan_est_callback(self.chan_est) self._chan_est_button_group.buttonClicked[int].connect( lambda i: self.set_chan_est(self._chan_est_options[i])) self.top_grid_layout.addWidget(self._chan_est_group_box) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("serial=F5EAC0", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(freq, rf_freq=freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_normalized_gain(gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_auto_dc_offset(False, 0) self.uhd_usrp_source_0.set_auto_iq_balance(False, 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 48 * 10, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win) self.ieee802_11_sync_short_0 = ieee802_11.sync_short( 0.56, 2, False, False) self.ieee802_11_sync_long_0 = ieee802_11.sync_long( sync_length, True, False) self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(True, True) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff( window_size + 16) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc( window_size) self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer( chan_est, freq, samp_rate, False, False) self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(True, False) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.complex_t, 'packet_len') self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.ieee802_11_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_sync_short_0, 2)) self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_frame_equalizer_0, 0)) self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.ieee802_11_decode_mac_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.ieee802_11_sync_long_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self, parent, data_dir): super(QGlyphViewer, self).__init__(parent) # Make tha actual QtWidget a child so that it can be re parented interactor = QVTKRenderWindowInteractor(self) self.layout = Qt.QHBoxLayout() self.layout.addWidget(interactor) self.layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.layout) # Read the data xyx_file = os.path.join(data_dir, "combxyz.bin") q_file = os.path.join(data_dir, "combq.bin") pl3d = vtk.vtkMultiBlockPLOT3DReader() pl3d.SetXYZFileName(xyx_file) pl3d.SetQFileName(q_file) pl3d.SetScalarFunctionNumber(100) pl3d.SetVectorFunctionNumber(202) pl3d.Update() blocks = pl3d.GetOutput() b0 = blocks.GetBlock(0) # Setup VTK environment renderer = vtk.vtkRenderer() render_window = interactor.GetRenderWindow() render_window.AddRenderer(renderer) interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera()) render_window.SetInteractor(interactor) renderer.SetBackground(0.2, 0.2, 0.2) # Draw Outline """ outline = vtk.vtkStructuredGridOutlineFilter() outline.SetInputData(b0) outline_mapper = vtk.vtkPolyDataMapper() outline_mapper.SetInputConnection(outline.GetOutputPort()) outline_actor = vtk.vtkActor() outline_actor.SetMapper(outline_mapper) outline_actor.GetProperty().SetColor(1,1,1) renderer.AddActor(outline_actor) renderer.ResetCamera() """ # Draw Outline """ outline = vtk.vtkStructuredGridOutlineFilter() outline.SetInputData(b0) outline_mapper = vtk.vtkPolyDataMapper() outline_mapper.SetInputConnection(outline.GetOutputPort()) outline_actor = vtk.vtkActor() outline_actor.SetMapper(outline_mapper) outline_actor.GetProperty().SetColor(1,1,1) renderer.AddActor(outline_actor) renderer.ResetCamera() """ # Threshold points threshold = vtk.vtkThresholdPoints() threshold.SetInputData(b0) threshold.ThresholdByUpper(0.5) # Draw arrows arrow = vtk.vtkArrowSource() glyphs = vtk.vtkGlyph3D() glyphs.SetInputData(b0) glyphs.SetSourceConnection(arrow.GetOutputPort()) glyphs.SetInputConnection(threshold.GetOutputPort()) glyphs.SetVectorModeToUseVector() glyphs.SetScaleModeToScaleByVector() glyphs.SetScaleFactor(0.005) glyphs.SetColorModeToColorByVector() # Mapper glyph_mapper = vtk.vtkPolyDataMapper() glyph_mapper.SetInputConnection(glyphs.GetOutputPort()) glyph_actor = vtk.vtkActor() glyph_actor.SetMapper(glyph_mapper) glyph_mapper.UseLookupTableScalarRangeOn() renderer.AddActor(glyph_actor) # Set color lookuptable glyphs.Update() s0, sf = glyphs.GetOutput().GetScalarRange() lut = vtk.vtkColorTransferFunction() lut.AddRGBPoint(s0, 1, 0, 0) lut.AddRGBPoint(sf, 0, 1, 0) glyph_mapper.SetLookupTable(lut) self.b0 = b0 self.renderer = renderer self.interactor = interactor self.threshold = threshold
def init_widgets(self): lbl_width = 50 val_width = 125 lbl_height = 12 btn_height = 20 frame_lbl = Qt.QLabel("Sync Controls:") frame_lbl.setAlignment(Qt.Qt.AlignLeft | Qt.Qt.AlignVCenter) frame_lbl.setStyleSheet( "QLabel {font:12pt; font-weight:bold; text-decoration: underline; color:rgb(255,0,0);}" ) frame_lbl.setFixedWidth(200) frame_lbl.setFixedHeight(20) self.azLabel = Qt.QLabel("Sync Azimuth:") self.azLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.azLabel.setStyleSheet("QLabel {font:10pt; color:rgb(255,0,0);}") self.azTextBox = Qt.QLineEdit() self.azTextBox.setText("000.000") self.azTextBox.setInputMask("#00.000;") self.azTextBox.setEchoMode(Qt.QLineEdit.Normal) self.azTextBox.setStyleSheet( "QLineEdit {font:10pt; background-color:rgb(200,75,75); color:rgb(0,0,0);}" ) self.azTextBox.setMaxLength(3) self.azTextBox.setFixedWidth(80) self.azTextBox.setFixedHeight(20) az_hbox = Qt.QHBoxLayout() az_hbox.addWidget(self.azLabel) az_hbox.addWidget(self.azTextBox) self.elLabel = Qt.QLabel("Sync Elevation:") self.elLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.elLabel.setStyleSheet("QLabel {font:10pt; color:rgb(255,0,0);}") self.elTextBox = Qt.QLineEdit() self.elTextBox.setText("00.000") self.elTextBox.setInputMask("#00.000;") self.elTextBox.setEchoMode(Qt.QLineEdit.Normal) self.elTextBox.setStyleSheet( "QLineEdit {font:10pt; background-color:rgb(200,75,75); color:rgb(0,0,0);}" ) self.elTextBox.setMaxLength(3) self.elTextBox.setFixedWidth(80) self.elTextBox.setFixedHeight(20) el_hbox = Qt.QHBoxLayout() el_hbox.addWidget(self.elLabel) el_hbox.addWidget(self.elTextBox) self.syncButton = Qt.QPushButton("Sync") self.syncButton.setFixedHeight(btn_height) self.syncButton.setStyleSheet( "QPushButton { font:10pt; background-color:rgb(200,0,0); }") vbox = Qt.QVBoxLayout() vbox.addWidget(frame_lbl) vbox.addLayout(az_hbox) vbox.addLayout(el_hbox) vbox.addWidget(self.syncButton) self.setLayout(vbox)
def __init__(self): gr.top_block.__init__(self, "Nsf Airspy Event Detect: 10 MHz") Qt.QWidget.__init__(self) self.setWindowTitle("Nsf Airspy Event Detect: 10 MHz") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "NsfDetect100") self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.ObsName = ObsName = "Detect100" self.ConfigFile = ConfigFile = ObsName + ".conf" self._telescope_save_config = ConfigParser.ConfigParser() self._telescope_save_config.read(ConfigFile) try: telescope_save = self._telescope_save_config.get( 'main', 'telescope') except: telescope_save = 'My Horn' self.telescope_save = telescope_save self._observer_save_config = ConfigParser.ConfigParser() self._observer_save_config.read(ConfigFile) try: observer_save = self._observer_save_config.get('main', 'observer') except: observer_save = 'Science Aficionado' self.observer_save = observer_save self._nsigmas_config = ConfigParser.ConfigParser() self._nsigmas_config.read(ConfigFile) try: nsigmas = self._nsigmas_config.getfloat('main', 'nsimga') except: nsigmas = 5.5 self.nsigmas = nsigmas self._fftsize_save_config = ConfigParser.ConfigParser() self._fftsize_save_config.read(ConfigFile) try: fftsize_save = self._fftsize_save_config.getint( 'main', 'samplesize') except: fftsize_save = 1024 self.fftsize_save = fftsize_save self._device_save_config = ConfigParser.ConfigParser() self._device_save_config.read(ConfigFile) try: device_save = self._device_save_config.get('main', 'device') except: device_save = 'airspy,bias=1,pack=1' self.device_save = device_save self._Gain3s_config = ConfigParser.ConfigParser() self._Gain3s_config.read(ConfigFile) try: Gain3s = self._Gain3s_config.getfloat('main', 'gain3') except: Gain3s = 14. self.Gain3s = Gain3s self._Gain2s_config = ConfigParser.ConfigParser() self._Gain2s_config.read(ConfigFile) try: Gain2s = self._Gain2s_config.getfloat('main', 'gain2') except: Gain2s = 14. self.Gain2s = Gain2s self._Gain1s_config = ConfigParser.ConfigParser() self._Gain1s_config.read(ConfigFile) try: Gain1s = self._Gain1s_config.getfloat('main', 'gain1') except: Gain1s = 14. self.Gain1s = Gain1s self._Frequencys_config = ConfigParser.ConfigParser() self._Frequencys_config.read(ConfigFile) try: Frequencys = self._Frequencys_config.getfloat('main', 'frequency') except: Frequencys = 1420.4e6 self.Frequencys = Frequencys self._Elevation_save_config = ConfigParser.ConfigParser() self._Elevation_save_config.read(ConfigFile) try: Elevation_save = self._Elevation_save_config.getfloat( 'main', 'elevation') except: Elevation_save = 90. self.Elevation_save = Elevation_save self._Bandwidths_config = ConfigParser.ConfigParser() self._Bandwidths_config.read(ConfigFile) try: Bandwidths = self._Bandwidths_config.getfloat('main', 'bandwidth') except: Bandwidths = 10e6 self.Bandwidths = Bandwidths self._Azimuth_save_config = ConfigParser.ConfigParser() self._Azimuth_save_config.read(ConfigFile) try: Azimuth_save = self._Azimuth_save_config.getfloat( 'main', 'azimuth') except: Azimuth_save = 180. self.Azimuth_save = Azimuth_save self.nsigma = nsigma = nsigmas self.fftsize = fftsize = fftsize_save self.Telescope = Telescope = telescope_save self.Observer = Observer = observer_save self.Mode = Mode = 2 self.Gain3 = Gain3 = Gain3s self.Gain2 = Gain2 = Gain2s self.Gain1 = Gain1 = Gain1s self.Frequency = Frequency = Frequencys self.EventMode = EventMode = 0 self.Elevation = Elevation = Elevation_save self.Device = Device = device_save self.Bandwidth = Bandwidth = Bandwidths self.Azimuth = Azimuth = Azimuth_save ################################################## # Blocks ################################################## self._nsigma_range = Range(0., 10., .1, nsigmas, 100) self._nsigma_win = RangeWidget(self._nsigma_range, self.set_nsigma, 'N Sigma', "counter", float) self.top_grid_layout.addWidget(self._nsigma_win, 7, 0, 1, 2) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._fftsize_tool_bar = Qt.QToolBar(self) self._fftsize_tool_bar.addWidget(Qt.QLabel('Sample_Size' + ": ")) self._fftsize_line_edit = Qt.QLineEdit(str(self.fftsize)) self._fftsize_tool_bar.addWidget(self._fftsize_line_edit) self._fftsize_line_edit.returnPressed.connect( lambda: self.set_fftsize(int(str(self._fftsize_line_edit.text())))) self.top_grid_layout.addWidget(self._fftsize_tool_bar, 1, 2, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._Telescope_tool_bar = Qt.QToolBar(self) self._Telescope_tool_bar.addWidget(Qt.QLabel('Tel' + ": ")) self._Telescope_line_edit = Qt.QLineEdit(str(self.Telescope)) self._Telescope_tool_bar.addWidget(self._Telescope_line_edit) self._Telescope_line_edit.returnPressed.connect( lambda: self.set_Telescope( str(str(self._Telescope_line_edit.text())))) self.top_grid_layout.addWidget(self._Telescope_tool_bar, 1, 0, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Observer_tool_bar = Qt.QToolBar(self) self._Observer_tool_bar.addWidget(Qt.QLabel('Who' + ": ")) self._Observer_line_edit = Qt.QLineEdit(str(self.Observer)) self._Observer_tool_bar.addWidget(self._Observer_line_edit) self._Observer_line_edit.returnPressed.connect( lambda: self.set_Observer(str(str(self._Observer_line_edit.text())) )) self.top_grid_layout.addWidget(self._Observer_tool_bar, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Mode_options = ( 0, 2, ) self._Mode_labels = ( 'Monitor', 'Detect', ) self._Mode_group_box = Qt.QGroupBox('Data Mode') self._Mode_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._Mode_button_group = variable_chooser_button_group() self._Mode_group_box.setLayout(self._Mode_box) for i, label in enumerate(self._Mode_labels): radio_button = Qt.QRadioButton(label) self._Mode_box.addWidget(radio_button) self._Mode_button_group.addButton(radio_button, i) self._Mode_callback = lambda i: Qt.QMetaObject.invokeMethod( self._Mode_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._Mode_options.index(i))) self._Mode_callback(self.Mode) self._Mode_button_group.buttonClicked[int].connect( lambda i: self.set_Mode(self._Mode_options[i])) self.top_grid_layout.addWidget(self._Mode_group_box, 6, 0, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Gain3_tool_bar = Qt.QToolBar(self) self._Gain3_tool_bar.addWidget(Qt.QLabel('Gain3' + ": ")) self._Gain3_line_edit = Qt.QLineEdit(str(self.Gain3)) self._Gain3_tool_bar.addWidget(self._Gain3_line_edit) self._Gain3_line_edit.returnPressed.connect(lambda: self.set_Gain3( eng_notation.str_to_num(str(self._Gain3_line_edit.text())))) self.top_grid_layout.addWidget(self._Gain3_tool_bar, 2, 6, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self._Gain2_tool_bar = Qt.QToolBar(self) self._Gain2_tool_bar.addWidget(Qt.QLabel('Gain2' + ": ")) self._Gain2_line_edit = Qt.QLineEdit(str(self.Gain2)) self._Gain2_tool_bar.addWidget(self._Gain2_line_edit) self._Gain2_line_edit.returnPressed.connect(lambda: self.set_Gain2( eng_notation.str_to_num(str(self._Gain2_line_edit.text())))) self.top_grid_layout.addWidget(self._Gain2_tool_bar, 2, 4, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._Gain1_tool_bar = Qt.QToolBar(self) self._Gain1_tool_bar.addWidget(Qt.QLabel('Gain1' + ": ")) self._Gain1_line_edit = Qt.QLineEdit(str(self.Gain1)) self._Gain1_tool_bar.addWidget(self._Gain1_line_edit) self._Gain1_line_edit.returnPressed.connect(lambda: self.set_Gain1( eng_notation.str_to_num(str(self._Gain1_line_edit.text())))) self.top_grid_layout.addWidget(self._Gain1_tool_bar, 2, 2, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._Frequency_tool_bar = Qt.QToolBar(self) self._Frequency_tool_bar.addWidget(Qt.QLabel('Freq. Hz' + ": ")) self._Frequency_line_edit = Qt.QLineEdit(str(self.Frequency)) self._Frequency_tool_bar.addWidget(self._Frequency_line_edit) self._Frequency_line_edit.returnPressed.connect( lambda: self.set_Frequency( eng_notation.str_to_num(str(self._Frequency_line_edit.text())) )) self.top_grid_layout.addWidget(self._Frequency_tool_bar, 0, 4, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._EventMode_options = ( 0, 1, ) self._EventMode_labels = ( 'Wait', 'Write', ) self._EventMode_group_box = Qt.QGroupBox('Write Mode') self._EventMode_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._EventMode_button_group = variable_chooser_button_group() self._EventMode_group_box.setLayout(self._EventMode_box) for i, label in enumerate(self._EventMode_labels): radio_button = Qt.QRadioButton(label) self._EventMode_box.addWidget(radio_button) self._EventMode_button_group.addButton(radio_button, i) self._EventMode_callback = lambda i: Qt.QMetaObject.invokeMethod( self._EventMode_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._EventMode_options.index(i))) self._EventMode_callback(self.EventMode) self._EventMode_button_group.buttonClicked[int].connect( lambda i: self.set_EventMode(self._EventMode_options[i])) self.top_grid_layout.addWidget(self._EventMode_group_box, 5, 0, 1, 2) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Elevation_tool_bar = Qt.QToolBar(self) self._Elevation_tool_bar.addWidget(Qt.QLabel('Elevation' + ": ")) self._Elevation_line_edit = Qt.QLineEdit(str(self.Elevation)) self._Elevation_tool_bar.addWidget(self._Elevation_line_edit) self._Elevation_line_edit.returnPressed.connect( lambda: self.set_Elevation( eng_notation.str_to_num(str(self._Elevation_line_edit.text())) )) self.top_grid_layout.addWidget(self._Elevation_tool_bar, 1, 6, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self._Device_tool_bar = Qt.QToolBar(self) self._Device_tool_bar.addWidget(Qt.QLabel('Dev' + ": ")) self._Device_line_edit = Qt.QLineEdit(str(self.Device)) self._Device_tool_bar.addWidget(self._Device_line_edit) self._Device_line_edit.returnPressed.connect( lambda: self.set_Device(str(str(self._Device_line_edit.text())))) self.top_grid_layout.addWidget(self._Device_tool_bar, 2, 0, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Bandwidth_tool_bar = Qt.QToolBar(self) self._Bandwidth_tool_bar.addWidget(Qt.QLabel('Bandwidth' + ": ")) self._Bandwidth_line_edit = Qt.QLineEdit(str(self.Bandwidth)) self._Bandwidth_tool_bar.addWidget(self._Bandwidth_line_edit) self._Bandwidth_line_edit.returnPressed.connect( lambda: self.set_Bandwidth( eng_notation.str_to_num(str(self._Bandwidth_line_edit.text())) )) self.top_grid_layout.addWidget(self._Bandwidth_tool_bar, 1, 4, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._Azimuth_tool_bar = Qt.QToolBar(self) self._Azimuth_tool_bar.addWidget(Qt.QLabel('Azimuth' + ": ")) self._Azimuth_line_edit = Qt.QLineEdit(str(self.Azimuth)) self._Azimuth_tool_bar.addWidget(self._Azimuth_line_edit) self._Azimuth_line_edit.returnPressed.connect(lambda: self.set_Azimuth( eng_notation.str_to_num(str(self._Azimuth_line_edit.text())))) self.top_grid_layout.addWidget(self._Azimuth_tool_bar, 0, 6, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self.radio_astro_ra_event_sink_0 = radio_astro.ra_event_sink( ObsName + ".not", fftsize, Frequency * 1.E-6, Bandwidth * 1.E-6, EventMode, 'Event Detection', Observer, Telescope, Device, float(Gain1), Azimuth, Elevation) self.radio_astro_ra_event_log_0 = radio_astro.ra_event_log( '', 'Event Detection', fftsize, Bandwidth * 1.e-6) self.radio_astro_detect_0 = radio_astro.detect( fftsize, nsigma, Frequency, Bandwidth, fftsize * 1.e-6 / Bandwidth, Mode) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( fftsize, #size Bandwidth, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(1) self.qtgui_time_sink_x_0_0.set_y_axis(-.3, .3) self.qtgui_time_sink_x_0_0.set_y_label('Event', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['I', 'Q', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 3, 2, 5, 6) for r in range(3, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( fftsize, 100, -.5, .5, "", 2) self.qtgui_histogram_sink_x_0.set_update_time(1) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['I', 'Q', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance( self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 3, 0, 2, 2) for r in range(3, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + Device) self.osmosdr_source_0.set_sample_rate(Bandwidth) self.osmosdr_source_0.set_center_freq(Frequency, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(float(Gain1), 0) self.osmosdr_source_0.set_if_gain(float(Gain2), 0) self.osmosdr_source_0.set_bb_gain(float(Gain3), 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(Bandwidth, 0) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, fftsize) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fftsize) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_histogram_sink_x_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.radio_astro_detect_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_log_0, 0)) self.connect((self.radio_astro_detect_0, 0), (self.radio_astro_ra_event_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 2") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 2") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "lab2") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.sps = sps = 8 self.roll_off = roll_off = 0.5 self.freqc = freqc = 900 self.std_dev = std_dev = 0.05 self.samp_rate = samp_rate = 1024 self.rrc_filter = rrc_filter = firdes.root_raised_cosine(4, sps, 1, roll_off, 32*sps+1) self.phase = phase = 0 self.lw = lw = 2 self.gain_ = gain_ = 0.5 self.freqc_ = freqc_ = freqc self.fps = fps = 30 self.const = const = digital.constellation_calcdist(digital.psk_2()[0], digital.psk_2()[1], 2, 1).base() self.bw = bw = 1 self.buff_size = buff_size = 32768 self.bNoise = bNoise = 0 self.bFilter = bFilter = 0 self.axis = axis = 2 self.N = N = 0 ################################################## # Blocks ################################################## self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Spectrum/Constellation') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Eye Diagram') self.top_grid_layout.addWidget(self.tab0, 0, 0, 10, 2) for r in range(0, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._std_dev_range = Range(0, 1, 0.01, 0.05, 200) self._std_dev_win = RangeWidget(self._std_dev_range, self.set_std_dev, 'Noise Std. Dev', "counter_slider", float) self.top_grid_layout.addWidget(self._std_dev_win, 11, 0, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._phase_range = Range(-180*2, 180*2, 0.1, 0, 200) self._phase_win = RangeWidget(self._phase_range, self.set_phase, 'Phase Offset (Degrees)', "counter_slider", float) self.top_grid_layout.addWidget(self._phase_win, 11, 1, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._gain__range = Range(0.1, 1, 0.01, 0.5, 200) self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'Gain (Amp)', "counter_slider", float) self.top_grid_layout.addWidget(self._gain__win, 10, 1, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._freqc__range = Range(70, 6000, .01, freqc, 200) self._freqc__win = RangeWidget(self._freqc__range, self.set_freqc_, 'Carrier (MHz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freqc__win, 10, 0, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._bNoise_options = (0, 1, ) # Create the labels list self._bNoise_labels = ('Noise Only', 'Signal + Noise', ) # Create the combo box # Create the radio buttons self._bNoise_group_box = Qt.QGroupBox('Waveform Select' + ": ") self._bNoise_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._bNoise_button_group = variable_chooser_button_group() self._bNoise_group_box.setLayout(self._bNoise_box) for i, _label in enumerate(self._bNoise_labels): radio_button = Qt.QRadioButton(_label) self._bNoise_box.addWidget(radio_button) self._bNoise_button_group.addButton(radio_button, i) self._bNoise_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bNoise_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bNoise_options.index(i))) self._bNoise_callback(self.bNoise) self._bNoise_button_group.buttonClicked[int].connect( lambda i: self.set_bNoise(self._bNoise_options[i])) self.top_grid_layout.addWidget(self._bNoise_group_box, 12, 1, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._bFilter_options = (0, 1, ) # Create the labels list self._bFilter_labels = ('Rectangular', 'Raised Cosine', ) # Create the combo box # Create the radio buttons self._bFilter_group_box = Qt.QGroupBox('Pulse Shaping Select' + ": ") self._bFilter_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._bFilter_button_group = variable_chooser_button_group() self._bFilter_group_box.setLayout(self._bFilter_box) for i, _label in enumerate(self._bFilter_labels): radio_button = Qt.QRadioButton(_label) self._bFilter_box.addWidget(radio_button) self._bFilter_button_group.addButton(radio_button, i) self._bFilter_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bFilter_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._bFilter_options.index(i))) self._bFilter_callback(self.bFilter) self._bFilter_button_group.buttonClicked[int].connect( lambda i: self.set_bFilter(self._bFilter_options[i])) self.top_grid_layout.addWidget(self._bFilter_group_box, 12, 0, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._N_range = Range(0, 7, 1, 0, 200) self._N_win = RangeWidget(self._N_range, self.set_N, 'Nth Sample', "counter_slider", float) self.top_grid_layout.addWidget(self._N_win, 13, 1, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._roll_off_range = Range(0.01, 0.99, 0.01, 0.5, 200) self._roll_off_win = RangeWidget(self._roll_off_range, self.set_roll_off, 'Beta (Roll-Off-Factor)', "counter_slider", float) self.top_grid_layout.addWidget(self._roll_off_win, 13, 0, 1, 1) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 2*sps, #size 1, #samp_rate "", #name 10 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(1/fps) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "buffer_start") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] widths = [lw, lw, lw, lw, lw, lw, lw, lw, lw, lw] colors = ['blue', 'red', 'yellow', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(10): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 5, 1) for r in range(0, 5): self.tab0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( int(1e5), 400, -axis, axis, "", 1 ) self.qtgui_histogram_sink_x_0.set_update_time(1/fps) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(True) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers= [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_histogram_sink_x_0_win, 5, 1, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 1 ) self.qtgui_freq_sink_x_0_0.set_update_time(1/fps) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) labels = ['Magnitude', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 5, 1) for r in range(0, 5): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0.set_processor_affinity([0]) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 2 ) self.qtgui_freq_sink_x_0.set_update_time(1/fps) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['In-Phase', 'Quadrature', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0.set_processor_affinity([0]) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(1/fps) self.qtgui_const_sink_x_0.set_y_axis(-axis, axis) self.qtgui_const_sink_x_0.set_x_axis(-axis, axis) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 5, 1) for r in range(0, 5): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_const_sink_x_0.set_processor_affinity([0]) self.interp_fir_filter_xxx_1_0 = filter.interp_fir_filter_ccc(sps, (1,1,1,1,1,1,1,1)) self.interp_fir_filter_xxx_1_0.declare_sample_delay(0) self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(sps, rrc_filter) self.interp_fir_filter_xxx_1.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, rrc_filter) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.iio_pluto_source_0 = iio.pluto_source('', int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, True, True, True, 'manual', 32, '', True) self.iio_pluto_sink_0 = iio.pluto_sink('', int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, False, 10.0, '', True) self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc(const.points(), 1) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex*1,bFilter,0) self.blocks_selector_0_0.set_enabled(True) self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex*1,N,0) self.blocks_selector_0.set_enabled(True) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(np.exp(1j*2*pi*phase/360)) self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_cc(2) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_cc(bNoise) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(gain_ ) self.blocks_delay_0_2 = blocks.delay(gr.sizeof_float*1, -N+1024) self.blocks_delay_0_1 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_1 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_0_1_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_0_1 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_0_0_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_0_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, sps) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_gr_complex*1, 1) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 2, 8192))), True) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, std_dev, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_delay_0_2, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_deinterleave_0, 7), (self.blocks_selector_0, 7)) self.connect((self.blocks_deinterleave_0, 4), (self.blocks_selector_0, 4)) self.connect((self.blocks_deinterleave_0, 3), (self.blocks_selector_0, 3)) self.connect((self.blocks_deinterleave_0, 6), (self.blocks_selector_0, 6)) self.connect((self.blocks_deinterleave_0, 5), (self.blocks_selector_0, 5)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_selector_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_selector_0, 1)) self.connect((self.blocks_deinterleave_0, 2), (self.blocks_selector_0, 2)) self.connect((self.blocks_delay_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_delay_0_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_delay_0_0_0, 0), (self.blocks_delay_0_0_0_0, 0)) self.connect((self.blocks_delay_0_0_0, 0), (self.qtgui_time_sink_x_0, 3)) self.connect((self.blocks_delay_0_0_0_0, 0), (self.blocks_delay_0_1, 0)) self.connect((self.blocks_delay_0_0_0_0, 0), (self.qtgui_time_sink_x_0, 4)) self.connect((self.blocks_delay_0_0_0_0_0, 0), (self.blocks_delay_0_0_0_1_0, 0)) self.connect((self.blocks_delay_0_0_0_0_0, 0), (self.qtgui_time_sink_x_0, 8)) self.connect((self.blocks_delay_0_0_0_1, 0), (self.blocks_delay_0_0_0_0_0, 0)) self.connect((self.blocks_delay_0_0_0_1, 0), (self.qtgui_time_sink_x_0, 7)) self.connect((self.blocks_delay_0_0_0_1_0, 0), (self.qtgui_time_sink_x_0, 9)) self.connect((self.blocks_delay_0_0_1, 0), (self.blocks_delay_0_0_0_1, 0)) self.connect((self.blocks_delay_0_0_1, 0), (self.qtgui_time_sink_x_0, 6)) self.connect((self.blocks_delay_0_1, 0), (self.blocks_delay_0_0_1, 0)) self.connect((self.blocks_delay_0_1, 0), (self.qtgui_time_sink_x_0, 5)) self.connect((self.blocks_delay_0_2, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0_2, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_selector_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_selector_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.blocks_selector_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_selector_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.blocks_selector_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1, 0)) self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.interp_fir_filter_xxx_1_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_selector_0_0, 1)) self.connect((self.interp_fir_filter_xxx_1, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.interp_fir_filter_xxx_1_0, 0), (self.blocks_multiply_const_vxx_0_0_0, 0))
def __init__(self, plugin, gui, icon): Qt.QDialog.__init__(self, gui) self.plugin = plugin self.gui = gui self.full_db = gui.current_db self.db = gui.current_db.new_api self.elastic_search_client = None self.conversion_time_dict = {} self.setWindowTitle(TITLE) self.setWindowIcon(icon) self.setWindowFlags(QtCore.Window | QtCore.WindowTitleHint | QtCore.CustomizeWindowHint) max_fit_size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) self.layout = Qt.QVBoxLayout() self.setLayout(self.layout) self.search_label = Qt.QLabel('Enter &text to search in content') self.layout.addWidget(self.search_label) self.search_text_layout = Qt.QHBoxLayout() self.search_textbox = Qt.QComboBox(self) self.search_textbox.setMinimumWidth(400) self.search_textbox.setEditable(True) self.search_textbox.setInsertPolicy(Qt.QComboBox.NoInsert) for _, value in sorted(prefs.get('search_lru', {}).items()): self.search_textbox.addItem(value) self.search_textbox.setEditText('') self.search_textbox.editTextChanged.connect( self.on_search_text_changed) self.search_label.setBuddy(self.search_textbox) self.search_text_layout.addWidget(self.search_textbox) self.search_help_button = Qt.QToolButton(self) self.search_help_button.setText('?') fixed_size_policy = self.search_help_button.sizePolicy() fixed_size_policy.setHorizontalPolicy(QtWidgets.QSizePolicy.Fixed) self.search_help_button.setSizePolicy(fixed_size_policy) self.search_help_button.clicked.connect(self.on_search_help) self.search_text_layout.addWidget(self.search_help_button) self.layout.addLayout(self.search_text_layout) self.search_button = Qt.QToolButton(self) self.search_button.setEnabled(False) self.search_button.setToolButtonStyle(QtCore.ToolButtonTextBesideIcon) self.search_button.setText('&Search') self.search_button.setPopupMode(Qt.QToolButton.MenuButtonPopup) self.search_button.clicked.connect(self.on_search_all) self.search_dropdown = Qt.QMenu() self.search_dropdown.addAction('Search in the &whole library', self.on_search_all) self.search_dropdown.addAction('Search in &selected books', self.on_search_selected) self.search_button.setMenu(self.search_dropdown) self.search_button.setSizePolicy(max_fit_size_policy) self.layout.addWidget(self.search_button) self.cancel_button = Qt.QToolButton(self) self.cancel_button.setText('&Cancel') self.cancel_button.clicked.connect(self.on_cancel) self.cancel_button.setVisible(False) self.cancel_button.setSizePolicy(max_fit_size_policy) self.layout.addWidget(self.cancel_button) self.status_label = Qt.QLabel() self.status_label.setAlignment(QtCore.AlignCenter) self.layout.addWidget(self.status_label) self.progress_bar = Qt.QProgressBar(self) self.progress_bar.setVisible(False) retain_size_policy = self.progress_bar.sizePolicy() retain_size_policy.setRetainSizeWhenHidden(True) self.progress_bar.setSizePolicy(retain_size_policy) self.layout.addWidget(self.progress_bar) self.details_button = Qt.QPushButton(self) self.details_button.setText('&Details') self.details_button.setVisible(False) retain_size_policy = self.details_button.sizePolicy() retain_size_policy.setRetainSizeWhenHidden(True) self.details_button.setSizePolicy(retain_size_policy) self.details_button.setFlat(True) self.details_button.setStyleSheet('text-align: left') icon = get_icons('images/right-arrow.png') self.details_button.setIcon(icon) self.details_button.clicked.connect(self.on_details) self.layout.addWidget(self.details_button) self.details = Qt.QListWidget(self) self.details.setVisible(False) self.layout.addWidget(self.details) self.layout.addStretch() self.reindex_button = Qt.QToolButton(self) self.reindex_button.setToolButtonStyle(QtCore.ToolButtonTextBesideIcon) self.reindex_button.setText('Reindex &new books') self.reindex_button.setPopupMode(Qt.QToolButton.MenuButtonPopup) self.reindex_button.clicked.connect(self.on_reindex) self.reindex_dropdown = Qt.QMenu() self.reindex_dropdown.addAction('Reindex &new books', self.on_reindex) self.reindex_dropdown.addAction('Reindex &all books', self.on_reindex_all) self.reindex_button.setMenu(self.reindex_dropdown) self.reindex_button.setSizePolicy(max_fit_size_policy) self.layout.addWidget(self.reindex_button) self.conf_button = Qt.QToolButton(self) self.conf_button.setText('&Options...') self.conf_button.clicked.connect(self.on_config) self.conf_button.setSizePolicy(max_fit_size_policy) self.layout.addWidget(self.conf_button) self.readme_button = Qt.QToolButton(self) self.readme_button.setText('&Readme...') self.readme_button.clicked.connect(self.on_readme) self.readme_button.setSizePolicy(max_fit_size_policy) self.layout.addWidget(self.readme_button) self.close_button = Qt.QToolButton(self) self.close_button.setText('&Close') self.close_button.clicked.connect(self.close) self.close_button.setSizePolicy(max_fit_size_policy) self.layout.addWidget(self.close_button) self.thread_pool = Qt.QThreadPool() self.add_workers_submitted = 0 self.add_workers_complete = 0 self.delete_workers_submitted = 0 self.delete_workers_complete = 0 self.first_paint = True self.pdftotext_full_path = None self.ids = None if 'version' not in prefs: file_formats = set(prefs['file_formats'].split(',') + ARCHIVE_FORMATS) prefs['file_formats'] = ','.join(file_formats) prefs['version'] = CapsPlugin.version self.key_pressed.connect(self.on_key_pressed)
def setup_ui(self) -> None: layout = Qt.QHBoxLayout(self) layout.setObjectName('BenchmarkToolbar.setup_ui.layout') layout.setContentsMargins(0, 0, 0, 0) start_label = Qt.QLabel(self) start_label.setObjectName('BenchmarkToolbar.setup_ui.start_label') start_label.setText('Start:') layout.addWidget(start_label) self.start_frame_control = FrameEdit[Frame](self) layout.addWidget(self.start_frame_control) self.start_time_control = TimeEdit[Time](self) layout.addWidget(self.start_time_control) end_label = Qt.QLabel(self) end_label.setObjectName('BenchmarkToolbar.setup_ui.end_label') end_label.setText('End:') layout.addWidget(end_label) self.end_frame_control = FrameEdit[Frame](self) layout.addWidget(self.end_frame_control) self.end_time_control = TimeEdit[Time](self) layout.addWidget(self.end_time_control) total_label = Qt.QLabel(self) total_label.setObjectName('BenchmarkToolbar.setup_ui.total_label') total_label.setText('Total:') layout.addWidget(total_label) self.total_frames_control = FrameEdit[FrameInterval](self) self.total_frames_control.setMinimum(FrameInterval(1)) layout.addWidget(self.total_frames_control) self.total_time_control = TimeEdit[TimeInterval](self) layout.addWidget(self.total_time_control) self.prefetch_checkbox = Qt.QCheckBox(self) self.prefetch_checkbox.setText('Prefetch') self.prefetch_checkbox.setChecked(True) self.prefetch_checkbox.setToolTip( 'Request multiple frames in advance.') layout.addWidget(self.prefetch_checkbox) self.unsequenced_checkbox = Qt.QCheckBox(self) self.unsequenced_checkbox.setText('Unsequenced') self.unsequenced_checkbox.setChecked(True) self.unsequenced_checkbox.setToolTip( "If enabled, next frame will be requested each time " "frameserver returns completed frame. " "If disabled, first frame that's currently processing " "will be waited before requesting next. Like for playback. ") layout.addWidget(self.unsequenced_checkbox) self.run_abort_button = Qt.QPushButton(self) self.run_abort_button.setText('Run') self.run_abort_button.setCheckable(True) layout.addWidget(self.run_abort_button) self.info_label = Qt.QLabel(self) layout.addWidget(self.info_label) layout.addStretch()
def __init__(self): gr.top_block.__init__(self, "Lab 1") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 1") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "lab1") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.freqc = freqc = 900 self.sps = sps = 8 self.samp_rate = samp_rate = 1000 self.phase = phase = 0 self.mod_M = mod_M = 0 self.gain_ = gain_ = 0.5 self.freqc_ = freqc_ = freqc self.fps = fps = 30 self.foffset = foffset = 0 self.bw = bw = 1 self.buff_size = buff_size = 32768 self.analog_gain = analog_gain = 32 ################################################## # Blocks ################################################## self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Spectrum/Constellation') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Time-Series') self.top_grid_layout.addWidget(self.tab0, 0, 0, 10, 2) for r in range(0, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._phase_range = Range(-180*2, 180*2, 0.1, 0, 200) self._phase_win = RangeWidget(self._phase_range, self.set_phase, 'Phase Offset (Degrees)', "counter_slider", float) self.top_grid_layout.addWidget(self._phase_win, 11, 1, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._mod_M_options = (0, 1, ) # Create the labels list self._mod_M_labels = ('BPSK', 'QPSK', ) # Create the combo box # Create the radio buttons self._mod_M_group_box = Qt.QGroupBox('Modulation Select' + ": ") self._mod_M_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._mod_M_button_group = variable_chooser_button_group() self._mod_M_group_box.setLayout(self._mod_M_box) for i, _label in enumerate(self._mod_M_labels): radio_button = Qt.QRadioButton(_label) self._mod_M_box.addWidget(radio_button) self._mod_M_button_group.addButton(radio_button, i) self._mod_M_callback = lambda i: Qt.QMetaObject.invokeMethod(self._mod_M_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._mod_M_options.index(i))) self._mod_M_callback(self.mod_M) self._mod_M_button_group.buttonClicked[int].connect( lambda i: self.set_mod_M(self._mod_M_options[i])) self.top_grid_layout.addWidget(self._mod_M_group_box, 12, 1, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._gain__range = Range(0.1, 1, 0.01, 0.5, 200) self._gain__win = RangeWidget(self._gain__range, self.set_gain_, 'Gain (Amp)', "counter_slider", float) self.top_grid_layout.addWidget(self._gain__win, 10, 1, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._freqc__range = Range(70, 6000, .01, freqc, 200) self._freqc__win = RangeWidget(self._freqc__range, self.set_freqc_, 'Carrier (MHz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freqc__win, 10, 0, 1, 1) for r in range(10, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._foffset_range = Range(-10, 10, 1, 0, 10) self._foffset_win = RangeWidget(self._foffset_range, self.set_foffset, 'Frequency Offset (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._foffset_win, 12, 0, 1, 1) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._analog_gain_range = Range(0, 64, 1, 32, 200) self._analog_gain_win = RangeWidget(self._analog_gain_range, self.set_analog_gain, 'Gain (Analog)', "counter_slider", float) self.top_grid_layout.addWidget(self._analog_gain_win, 11, 0, 1, 1) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 131072, #size samp_rate*1000, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(1/fps) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ['blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 10, 2) for r in range(0, 10): self.tab0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 2): self.tab0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 1 ) self.qtgui_freq_sink_x_0_0.set_update_time(1/fps) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) labels = ['Magnitude', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 5, 1) for r in range(0, 5): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0.set_processor_affinity([0]) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*1e3, #bw "", #name 2 ) self.qtgui_freq_sink_x_0.set_update_time(1/fps) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['In-Phase', 'Quadrature', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 5, 0, 5, 1) for r in range(5, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0.set_processor_affinity([0]) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(1/fps) self.qtgui_const_sink_x_0.set_y_axis(-3, 3) self.qtgui_const_sink_x_0.set_x_axis(-3, 3) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 10, 1) for r in range(0, 10): self.tab0_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tab0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_const_sink_x_0.set_processor_affinity([0]) self.iio_pluto_source_0 = iio.pluto_source('', int(freqc_*1e6), int(samp_rate*1000), 20000000, buff_size, True, True, True, 'manual', analog_gain, '', True) self.iio_pluto_sink_0 = iio.pluto_sink('', int(freqc_*1e6)+foffset, int(samp_rate*1000), 20000000, buff_size, False, 10.0, '', True) self.digital_psk_mod_0_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=sps, excess_bw=1, verbose=False, log=False) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(np.exp(1j*2*pi*phase/360)) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(mod_M) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(gain_ * np.exp(1j * pi / 4)) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_imag_1 = blocks.complex_to_imag(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 4, 8192))), True) self.analog_agc_xx_0 = analog.agc_cc(1e-4, ( 1.0 + mod_M), 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_complex_to_imag_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_imag_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.analog_agc_xx_0, 0)) self.connect((self.digital_psk_mod_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.blocks_multiply_const_vxx_1, 0))
def __init__(self): gr.top_block.__init__(self, "Uhd Hf Am") Qt.QWidget.__init__(self) self.setWindowTitle("Uhd Hf Am") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "uhd_hf_am") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2.5e6 self.rx_freq = rx_freq = 1.0e6 self.fine_freq = fine_freq = 0 self.coarse_freq = coarse_freq = 0 self.volume = volume = 1 self.usb_lsb = usb_lsb = -1 self.ssb_am = ssb_am = 0 self.selection = selection = ((1, 0, 0), (0, 1, 0), (0, 0, 1)) self.pll_lbw = pll_lbw = 200 self.pll_freq = pll_freq = 100 self.lpf_cutoff = lpf_cutoff = 2e3 self.interp = interp = 48 self.freq_label = freq_label = rx_freq + fine_freq + coarse_freq self.decim = decim = samp_rate / 1e3 self.decay_rate = decay_rate = 100e-6 self.audio_ref = audio_ref = 1 self.audio_max_gain = audio_max_gain = 1 self.audio_gain = audio_gain = 1 self.audio_decay = audio_decay = 100 self.audio_attack = audio_attack = 1000 ################################################## # Blocks ################################################## self._volume_range = Range(0, 100, .1, 1, 200) self._volume_win = RangeWidget(self._volume_range, self.set_volume, 'volume', "counter_slider", float) self.top_grid_layout.addWidget(self._volume_win, 7, 0, 1, 4) for r in range(7, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._usb_lsb_options = [-1, 1] # Create the labels list self._usb_lsb_labels = ['USB', 'LSB'] # Create the combo box # Create the radio buttons self._usb_lsb_group_box = Qt.QGroupBox('usb_lsb' + ": ") self._usb_lsb_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._usb_lsb_button_group = variable_chooser_button_group() self._usb_lsb_group_box.setLayout(self._usb_lsb_box) for i, _label in enumerate(self._usb_lsb_labels): radio_button = Qt.QRadioButton(_label) self._usb_lsb_box.addWidget(radio_button) self._usb_lsb_button_group.addButton(radio_button, i) self._usb_lsb_callback = lambda i: Qt.QMetaObject.invokeMethod( self._usb_lsb_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._usb_lsb_options.index(i))) self._usb_lsb_callback(self.usb_lsb) self._usb_lsb_button_group.buttonClicked[int].connect( lambda i: self.set_usb_lsb(self._usb_lsb_options[i])) self.top_grid_layout.addWidget(self._usb_lsb_group_box, 5, 5, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._ssb_am_options = [0, 1, 2] # Create the labels list self._ssb_am_labels = ['SSB', 'AM', 'AM*'] # Create the combo box # Create the radio buttons self._ssb_am_group_box = Qt.QGroupBox('ssb_am' + ": ") self._ssb_am_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ssb_am_button_group = variable_chooser_button_group() self._ssb_am_group_box.setLayout(self._ssb_am_box) for i, _label in enumerate(self._ssb_am_labels): radio_button = Qt.QRadioButton(_label) self._ssb_am_box.addWidget(radio_button) self._ssb_am_button_group.addButton(radio_button, i) self._ssb_am_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ssb_am_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ssb_am_options.index(i))) self._ssb_am_callback(self.ssb_am) self._ssb_am_button_group.buttonClicked[int].connect( lambda i: self.set_ssb_am(self._ssb_am_options[i])) self.top_grid_layout.addWidget(self._ssb_am_group_box, 4, 4, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self._rx_freq_range = Range(.2e6, 100e6, 100e3, 1.0e6, 200) self._rx_freq_win = RangeWidget(self._rx_freq_range, self.set_rx_freq, 'rx_freq', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_freq_win, 4, 0, 1, 4) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._pll_lbw_tool_bar = Qt.QToolBar(self) self._pll_lbw_tool_bar.addWidget(Qt.QLabel('pll_lbw' + ": ")) self._pll_lbw_line_edit = Qt.QLineEdit(str(self.pll_lbw)) self._pll_lbw_tool_bar.addWidget(self._pll_lbw_line_edit) self._pll_lbw_line_edit.returnPressed.connect(lambda: self.set_pll_lbw( eng_notation.str_to_num(str(self._pll_lbw_line_edit.text())))) self.top_grid_layout.addWidget(self._pll_lbw_tool_bar, 9, 7, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 8): self.top_grid_layout.setColumnStretch(c, 1) self._pll_freq_tool_bar = Qt.QToolBar(self) self._pll_freq_tool_bar.addWidget(Qt.QLabel('pll_freq' + ": ")) self._pll_freq_line_edit = Qt.QLineEdit(str(self.pll_freq)) self._pll_freq_tool_bar.addWidget(self._pll_freq_line_edit) self._pll_freq_line_edit.returnPressed.connect( lambda: self.set_pll_freq( eng_notation.str_to_num(str(self._pll_freq_line_edit.text())))) self.top_grid_layout.addWidget(self._pll_freq_tool_bar, 9, 6, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._lpf_cutoff_options = [2000.0, 3000.0, 4000.0, 8000.0] # Create the labels list self._lpf_cutoff_labels = ['2000.0', '3000.0', '4000.0', '8000.0'] # Create the combo box self._lpf_cutoff_tool_bar = Qt.QToolBar(self) self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff: ")) self._lpf_cutoff_combo_box = Qt.QComboBox() self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_combo_box) for _label in self._lpf_cutoff_labels: self._lpf_cutoff_combo_box.addItem(_label) self._lpf_cutoff_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lpf_cutoff_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lpf_cutoff_options.index(i))) self._lpf_cutoff_callback(self.lpf_cutoff) self._lpf_cutoff_combo_box.currentIndexChanged.connect( lambda i: self.set_lpf_cutoff(self._lpf_cutoff_options[i])) # Create the radio buttons self.top_grid_layout.addWidget(self._lpf_cutoff_tool_bar, 4, 5, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._fine_freq_range = Range(-1e3, 1e3, 1, 0, 200) self._fine_freq_win = RangeWidget(self._fine_freq_range, self.set_fine_freq, 'fine_freq', "counter_slider", float) self.top_grid_layout.addWidget(self._fine_freq_win, 6, 0, 1, 4) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._decay_rate_options = [0.0001, 0.065, 0.02] # Create the labels list self._decay_rate_labels = ['Fast', 'Medium', 'Slow'] # Create the combo box # Create the radio buttons self._decay_rate_group_box = Qt.QGroupBox('decay_rate' + ": ") self._decay_rate_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._decay_rate_button_group = variable_chooser_button_group() self._decay_rate_group_box.setLayout(self._decay_rate_box) for i, _label in enumerate(self._decay_rate_labels): radio_button = Qt.QRadioButton(_label) self._decay_rate_box.addWidget(radio_button) self._decay_rate_button_group.addButton(radio_button, i) self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._decay_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._decay_rate_options.index(i))) self._decay_rate_callback(self.decay_rate) self._decay_rate_button_group.buttonClicked[int].connect( lambda i: self.set_decay_rate(self._decay_rate_options[i])) self.top_grid_layout.addWidget(self._decay_rate_group_box, 4, 6, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self._coarse_freq_range = Range(-100e3, 100e3, 1, 0, 200) self._coarse_freq_win = RangeWidget(self._coarse_freq_range, self.set_coarse_freq, 'coarse_freq', "counter_slider", float) self.top_grid_layout.addWidget(self._coarse_freq_win, 5, 0, 1, 4) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._audio_ref_tool_bar = Qt.QToolBar(self) self._audio_ref_tool_bar.addWidget(Qt.QLabel('audio_ref' + ": ")) self._audio_ref_line_edit = Qt.QLineEdit(str(self.audio_ref)) self._audio_ref_tool_bar.addWidget(self._audio_ref_line_edit) self._audio_ref_line_edit.returnPressed.connect( lambda: self.set_audio_ref( eng_notation.str_to_num(str(self._audio_ref_line_edit.text())) )) self.top_grid_layout.addWidget(self._audio_ref_tool_bar, 9, 3, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self._audio_max_gain_tool_bar = Qt.QToolBar(self) self._audio_max_gain_tool_bar.addWidget( Qt.QLabel('audio_max_gain' + ": ")) self._audio_max_gain_line_edit = Qt.QLineEdit(str(self.audio_max_gain)) self._audio_max_gain_tool_bar.addWidget(self._audio_max_gain_line_edit) self._audio_max_gain_line_edit.returnPressed.connect( lambda: self.set_audio_max_gain( eng_notation.str_to_num( str(self._audio_max_gain_line_edit.text())))) self.top_grid_layout.addWidget(self._audio_max_gain_tool_bar, 9, 5, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(5, 6): self.top_grid_layout.setColumnStretch(c, 1) self._audio_gain_tool_bar = Qt.QToolBar(self) self._audio_gain_tool_bar.addWidget(Qt.QLabel('audio_gain' + ": ")) self._audio_gain_line_edit = Qt.QLineEdit(str(self.audio_gain)) self._audio_gain_tool_bar.addWidget(self._audio_gain_line_edit) self._audio_gain_line_edit.returnPressed.connect( lambda: self.set_audio_gain( eng_notation.str_to_num(str(self._audio_gain_line_edit.text())) )) self.top_grid_layout.addWidget(self._audio_gain_tool_bar, 9, 4, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self._audio_decay_tool_bar = Qt.QToolBar(self) self._audio_decay_tool_bar.addWidget(Qt.QLabel('audio_decay' + ": ")) self._audio_decay_line_edit = Qt.QLineEdit(str(self.audio_decay)) self._audio_decay_tool_bar.addWidget(self._audio_decay_line_edit) self._audio_decay_line_edit.returnPressed.connect( lambda: self.set_audio_decay( eng_notation.str_to_num(str(self._audio_decay_line_edit.text()) ))) self.top_grid_layout.addWidget(self._audio_decay_tool_bar, 9, 2, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._audio_attack_tool_bar = Qt.QToolBar(self) self._audio_attack_tool_bar.addWidget(Qt.QLabel('audio_attack' + ": ")) self._audio_attack_line_edit = Qt.QLineEdit(str(self.audio_attack)) self._audio_attack_tool_bar.addWidget(self._audio_attack_line_edit) self._audio_attack_line_edit.returnPressed.connect( lambda: self.set_audio_attack( eng_notation.str_to_num( str(self._audio_attack_line_edit.text())))) self.top_grid_layout.addWidget(self._audio_attack_tool_bar, 9, 1, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("addr=10.41.1.11", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), ) self.uhd_usrp_source_1.set_subdev_spec('A:B', 0) self.uhd_usrp_source_1.set_time_source('gpsdo', 0) self.uhd_usrp_source_1.set_clock_source('gpsdo', 0) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 0) self.uhd_usrp_source_1.set_gain(0, 0) self.uhd_usrp_source_1.set_samp_rate(samp_rate) self.uhd_usrp_source_1.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=200, decimation=int(samp_rate / 1e3), taps=None, fractional_bw=None) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=interp, decimation=int(decim), taps=None, fractional_bw=None) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate / decim * interp / 3, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8, 0, 1, 4) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.010) self.qtgui_number_sink_0.set_title('') labels = ["RSSI", '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in range(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 50) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 5, 6, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 7): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim * interp / 3, #bw "", #name 1) self.qtgui_freq_sink_x_0_0.set_update_time(0.0010) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) self.qtgui_freq_sink_x_0_0.disable_legend() labels = ['', 'processed', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 6, 4, 3, 2) for r in range(6, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim * interp, #bw "", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-120, -10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) labels = ['pre-d', 'processed', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 4, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0_1 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 3, firdes.low_pass(1, samp_rate / decim * interp, lpf_cutoff, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100, firdes.WIN_HAMMING, 6.76)) self._freq_label_tool_bar = Qt.QToolBar(self) if None: self._freq_label_formatter = None else: self._freq_label_formatter = lambda x: eng_notation.num_to_str(x) self._freq_label_tool_bar.addWidget(Qt.QLabel('Tuned Freq' + ": ")) self._freq_label_label = Qt.QLabel( str(self._freq_label_formatter(self.freq_label))) self._freq_label_tool_bar.addWidget(self._freq_label_label) self.top_grid_layout.addWidget(self._freq_label_tool_bar, 5, 4, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range( rx_freq, samp_rate / int(samp_rate / 1e3) * 200) self._fosphor_qt_sink_c_0_win = sip.wrapinstance( self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_win, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_matrix_xx_0_0_0 = blocks.multiply_matrix_cc( (selection[ssb_am], ), gr.TPP_ALL_TO_ALL) self.blocks_multiply_matrix_xx_0 = blocks.multiply_matrix_ff( (selection[ssb_am], ), gr.TPP_ALL_TO_ALL) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_ff(100000) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_ff(usb_lsb) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(volume) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 1000, 1 / 1000.0, 4000, 1) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(16000, '', True) self.analog_sig_source_x_0_0_0 = analog.sig_source_f( samp_rate / decim * interp / 3, analog.GR_SIN_WAVE, 1.5e3, 1, 0, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate / decim * interp / 3, analog.GR_COS_WAVE, 1.5e3, 1, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1 * (fine_freq + coarse_freq), 1, 0, 0) self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc( math.pi / pll_lbw, math.pi / pll_freq, -math.pi / pll_freq) self.analog_agc2_xx_0_0 = analog.agc2_ff(audio_attack, audio_decay, audio_ref, audio_gain) self.analog_agc2_xx_0_0.set_max_gain(audio_max_gain) self.analog_agc2_xx_0 = analog.agc2_cc(0.1, decay_rate, .3, 1000) self.analog_agc2_xx_0.set_max_gain(65000) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_multiply_matrix_xx_0_0_0, 2)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_1_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_matrix_xx_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.low_pass_filter_0_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_matrix_xx_0, 2)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_multiply_matrix_xx_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blocks_multiply_matrix_xx_0_0_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_matrix_xx_0_0_0, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_matrix_xx_0_0_0, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.blocks_multiply_xx_1_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0))
def main(self): ############################################## - OLD CODE - ############################################## # this opens the connection to the fpga (hard-coded IP address for now) # strList = self.sl.getDeviceList() ########################################################################### # Update the FPGA bitfile and the Zynq monitor-tcp C program # send new bitfile version # try: # self.sl.dev.write_file_on_remote(strFilenameLocal=r'D:\Projects\RedPitaya\fpga\project\redpitaya.runs\impl_1\red_pitaya_top.bit', strFilenameRemote='/opt/red_pitaya_top.bit') # self.sl.dev.write_file_on_remote(strFilenameLocal=r'D:\Projets_Xilinx\RedPitaya\fpga\project\redpitaya.runs\impl_1\red_pitaya_top.bit', strFilenameRemote='/opt/red_pitaya_top.bit') # pass # except: # print("warning, could not update fpga bitfile") # pass # program FPGA with new bitfile: # self.sl.dev.send_shell_command('cat /opt/red_pitaya_top.bit > /dev/xdevcfg') # time.sleep(3) # # # send new monitor-tcp version # self.sl.dev.write_file_on_remote(strFilenameLocal=u'D:\\Université\\Dropbox\\22_H2015\\Red Pitaya\\monitor-tcp\\monitor-tcp', strFilenameRemote='/opt/monitor-tcp-new') # # # set executable permissions # self.sl.dev.send_shell_command('chmod +x /opt/monitor-tcp-new') # # copy over old file # self.sl.dev.send_shell_command('mv /opt/monitor-tcp-new /opt/monitor-tcp') # # # send reboot command # self.sl.dev.send_reboot_command() # self.sl.dev.sock.shutdown(socket.SHUT_RDWR) # self.sl.dev.sock.close() # # time.sleep(1) # give some time for tcp server to come back up ## return # self.sl.getDeviceList() # reconnect # # #self.sl.dev.OpenTCPConnection(self.sl.dev.HOST, self.sl.dev.PORT) # hack to get things working quickly ## self.sl.dev.sock.connect((self.sl.dev.HOST, self.sl.dev.PORT)) # ## return # for quick debug tests ############################################## - OLD CODE - ############################################## # Start the User Interface bTriggerEvents = False bConnectedRP = False self.strSelectedSerial = "000000000000" # if self.initial_config.bOk == False: # # User clicked cancel. simply close the program: # return # if self.initial_config.qradio_pushValue.isChecked(): # print("Push") # bTriggerEvents = True # bConnectedRP = True # self.loadDefaultValueFromConfigFile(self.initial_config.strSelectedSerial) # elif self.initial_config.qradio_existingRP.isChecked(): # print("Reconnection") # bTriggerEvents = False # bConnectedRP = True # elif self.initial_config.qradio_noRP.isChecked(): # print("No RP") # bTriggerEvents = False # bConnectedRP = False bUpdateFPGA = bTriggerEvents bSendToFPGA = bTriggerEvents ########################################################################### # Create the object which handles the configuration parameters (DAC offsets, DAC gains, beat frequency modulation range, etc): #sp = SLLSystemParameters() # config_window = SLLConfigurationWindow() # config_window.loadParameters(sp) # config_window.hide() ########################################################################### # Load all our windows: # Style sheet which includes the color scheme for each specific box: try: # custom_style_sheet = ('#MainWindow {color: white; background-color: %s;}' % self.devices_data[self.initial_config.strSelectedSerial]['color']) custom_style_sheet = ( '#MainWindow {color: white; background-color: %s;}' % self.devices_data[self.strSelectedSerial]['color']) except KeyError: custom_style_sheet = '' # The shorthand name which gets added to the window names: try: # custom_shorthand = self.devices_data[self.initial_config.strSelectedSerial]['shorthand'] custom_shorthand = self.devices_data[ self.strSelectedSerial]['shorthand'] except KeyError: custom_shorthand = '' # Have to be careful with the modulus setting (double-check with a scope to make sure the output frequency is right) # I think the output frequency for the square wave mode is given by: # 200 MHz/(2*(modulus+1)) # While for the pulsed mode (bPulses = 1), the frequency is: # 200 MHz/(modulus+1) self.divider_settings_window = DisplayDividerAndResidualsStreamingSettingsWindow( self.sl, self.sp, clk_divider_modulus=67e3, bDividerOn=0, bPulses=0, custom_style_sheet=custom_style_sheet, custom_shorthand=custom_shorthand) # Optical lock window # self.xem_gui_mainwindow2 = XEM_GUI_MainWindow(self.sl, custom_shorthand + ': Optical lock', 1, (False, True, False), sp, custom_style_sheet, self.initial_config.strSelectedSerial, bUpdateFPGA = bSendToFPGA, bConnectedRP = bConnectedRP) self.xem_gui_mainwindow2 = XEM_GUI_MainWindow( self.sl, custom_shorthand + ': Optical lock', 1, (False, True, False), self.sp, custom_style_sheet, self.strSelectedSerial) # CEO Lock window # self.xem_gui_mainwindow = XEM_GUI_MainWindow(self.sl, custom_shorthand + ': CEO lock', 0, (True, False, False), sp, custom_style_sheet, self.initial_config.strSelectedSerial, bUpdateFPGA = bSendToFPGA, bConnectedRP = bConnectedRP) self.xem_gui_mainwindow = XEM_GUI_MainWindow( self.sl, custom_shorthand + ': CEO lock', 0, (True, False, False), self.sp, custom_style_sheet, self.strSelectedSerial) # ########################################################################### # # For testing the Red Pitaya with the built-in DDS: # # addr_vco = 2 # addr_vco_amplitude = 0x0000 # addr_vco_freq_msb = 0x0004 # addr_vco_freq_lsb = 0x0008 # # vco_amplitude = round(0.01*(2**15-1)) ## vco_freq_word = np.array([round((15e6/100e6+1./600.)*2.**48)]).astype(np.int64) ## # break vco word into msbs and lsbs: ## vco_freq_word_msbs = vco_freq_word >> 32 ## vco_freq_word_lsbs = np.bitwise_and(vco_freq_word, (1<<32)-1) # # # write amplitude # address_uint32 = (addr_vco << 20) + addr_vco_amplitude # data_uint32 = vco_amplitude # self.sl.dev.write_Zynq_register_uint32(address_uint32, data_uint32) ######################################################### # The two frequency counter: strOfTime = time.strftime("%m_%d_%Y_%H_%M_%S_") try: # temp_control_port = self.devices_data[self.initial_config.strSelectedSerial]['port'] temp_control_port = self.devices_data[ self.strSelectedSerial]['port'] except: temp_control_port = 0 strNameTemplate = 'data_logging\%s' % strOfTime # strNameTemplate = '%s_%s_' % (strNameTemplate, self.initial_config.strSelectedSerial) # strNameTemplate = '%s_%s_' % (strNameTemplate, self.strSelectedSerial) self.strNameTemplate = strNameTemplate self.freq_error_window1 = FreqErrorWindowWithTempControlV2( self.sl, 'CEO beat in-loop counter', self.sp, 0, strNameTemplate, custom_style_sheet, 0, self.xem_gui_mainwindow) self.freq_error_window2 = FreqErrorWindowWithTempControlV2( self.sl, 'Optical beat in-loop counter', self.sp, 1, strNameTemplate, custom_style_sheet, temp_control_port, self.xem_gui_mainwindow2) self.counters_window = Qt.QWidget() self.counters_window.setObjectName('MainWindow') self.counters_window.setStyleSheet(custom_style_sheet) vbox = Qt.QVBoxLayout() vbox.addWidget(self.freq_error_window1) vbox.addWidget(self.freq_error_window2) self.counters_window.setLayout(vbox) self.counters_window.setWindowTitle(custom_shorthand + ': Frequency counters') #self.counters_window.setGeometry(993, 40, 800, 1010) #self.counters_window.setGeometry(0, 0, 750, 1000) # self.counters_window.resize(600, 1080-100+30) #self.counters_window.move(QtGui.QDesktopWidget().availableGeometry().topLeft() + Qt.QPoint(985, 10)) #self.counters_window.show() # Dither windows, this code could be moved to another class/file to help with clutter: self.dither_widget0 = DisplayDitherSettingsWindow( self.sl, self.sp, 0, modulation_frequency_in_hz='1e3', output_amplitude='1e-3', integration_time_in_seconds='0.1', bEnableDither=True, custom_style_sheet=custom_style_sheet) self.dither_widget1 = DisplayDitherSettingsWindow( self.sl, self.sp, 1, modulation_frequency_in_hz='5.1e3', output_amplitude='1e-3', integration_time_in_seconds='0.1', bEnableDither=True, custom_style_sheet=custom_style_sheet) #dither_widget2 = DisplayDitherSettingsWindow(self.sl, self.sp, 2, modulation_frequency_in_hz='110' , output_amplitude='1e-4', integration_time_in_seconds='0.1', bEnableDither=True, custom_style_sheet=custom_style_sheet) self.RP_Settings = ConfigRPSettingsUI( self.sl, self.sp, self, custom_style_sheet=custom_style_sheet, custom_shorthand=custom_shorthand) self.settings_window = Qt.QWidget() self.settings_window.setObjectName('MainWindow') self.settings_window.setStyleSheet(custom_style_sheet) vbox1 = Qt.QVBoxLayout() vbox1.addWidget(self.dither_widget0) vbox1.addWidget(self.dither_widget1) #vbox1.addWidget(dither_widget2) vbox1.addStretch(1) vbox2 = Qt.QVBoxLayout() vbox2.addWidget(self.RP_Settings) vbox2.addWidget(self.divider_settings_window) hbox = Qt.QHBoxLayout() hbox.addLayout(vbox1) hbox.addLayout(vbox2) hbox.addStretch(1) self.settings_window.setLayout(hbox) self.settings_window.setWindowTitle(custom_shorthand + ': Dither controls') #self.settings_window.show() # ########################################################################### # # For testing out the transfer function window: # frequency_axis = np.logspace(np.log10(10e3), np.log10(2e6), 10e3) # transfer_function = 1/(1 + 1j*frequency_axis/100e3) # window_number = 1 # vertical_units = 'V/V' # tf_window1 = DisplayTransferFunctionWindow(frequency_axis, transfer_function, window_number, vertical_units) # # # Regroup the two windows into a single one: self.main_windows = Qt.QWidget() self.main_windows.setObjectName('MainWindow') self.main_windows.setStyleSheet(custom_style_sheet) tabs = QtGui.QTabWidget() # self.xem_gui_mainwindow2.resize(600, 700) # self.xem_gui_mainwindow.setContentsMargins(0, 0, 0, 0) # self.xem_gui_mainwindow.layout().setContentsMargins(0, 0, 0, 0) # self.xem_gui_mainwindow2.setContentsMargins(0, 0, 0, 0) # self.xem_gui_mainwindow2.layout().setContentsMargins(0, 0, 0, 0) # self.counters_window.setContentsMargins(0, 0, 0, 0) # self.counters_window.layout().setContentsMargins(0, 0, 0, 0) # dither_window.setContentsMargins(0, 0, 0, 0) # dither_window.layout().setContentsMargins(0, 0, 0, 0) # dfr_timing_gui.setContentsMargins(0, 0, 0, 0) # dfr_timing_gui.layout().setContentsMargins(0, 0, 0, 0) # self.divider_settings_window.setContentsMargins(0, 0, 0, 0) # self.divider_settings_window.layout().setContentsMargins(0, 0, 0, 0) #tabs.setMaximumSize(1920,1080-100+30) # self.main_windows.setMaximumSize(600,600) # self.xem_gui_mainwindow.setMaximumSize(600,600) # self.xem_gui_mainwindow2.setMaximumSize(600,600) # self.counters_window.setMaximumSize(600,600) # dither_window.setMaximumSize(600,600) # dfr_timing_gui.setMaximumSize(600,600) # self.divider_settings_window.setMaximumSize(600,600) tabs.addTab(self.xem_gui_mainwindow, "Fast EOM Lock") tabs.addTab(self.xem_gui_mainwindow2, "Slow Lock") tabs.addTab(self.counters_window, "Counters") tabs.addTab(self.settings_window, "Settings") #FEATURE #tabs.addTab(dfr_timing_gui, "DFr trigger generator") #tabs.addTab(self.divider_settings_window, "Filter settings") # tabs.setGeometry(0, 0, 750, 1000) box = QtGui.QHBoxLayout() box.addWidget(tabs) self.main_windows.setLayout(box) self.main_windows.setWindowTitle(custom_shorthand) #self.main_windows.move(QtGui.QDesktopWidget().availableGeometry().topLeft() + Qt.QPoint(945-300, 0)) self.main_windows.move( QtGui.QDesktopWidget().availableGeometry().topLeft() + Qt.QPoint(800 - 300, 0)) self.main_windows.show() self.connectionGUI() # Enter main event loop #self.app.exec_() try: self.app.exec_() except: print("XEM_GUI3.py: Exception during app.exec_()")
def __init__(self, app, parent): super().__init__() self.exam_data = parent.exam_data settings_title = Qt.QLabel('Настройки экзамена', self) settings_title.setFont(Qt.QFont('Arial', 30)) name_title = Qt.QLabel('Название экзамена:', self) name_title.setFont(Qt.QFont('Arial', 20)) self.name_input = Qt.QLineEdit(self.exam_data['name'], self) self.name_input.setFont(Qt.QFont('Arial', 20)) self.name_input.setCursorPosition(0) self.name_input.textChanged.connect(self.update_status) duration_title = Qt.QLabel('Продолжительность (в минутах):', self) duration_title.setFont(Qt.QFont('Arial', 20)) self.duration_input = Qt.QLineEdit(str(self.exam_data['duration']), self) self.duration_input.setFont(Qt.QFont('Arial', 20)) self.duration_input.textChanged.connect(self.update_status) state_title = Qt.QLabel('Для участия:', self) state_title.setFont(Qt.QFont('Arial', 20)) self.state_box = Qt.QComboBox(self) self.state_box.setFont(Qt.QFont('Arial', 20)) self.state_box.addItems(['Недоступен', 'Открыт']) self.state_box.setCurrentIndex(self.exam_data['published']) self.state_box.currentIndexChanged.connect(self.update_status) results_button = Qt.QPushButton('Таблица результатов', self) results_button.setObjectName('Button') results_button.setFont(Qt.QFont('Arial', 20)) results_button.clicked.connect( lambda: app.display_results_page(self.exam_data['rowid'])) self.save_button = Qt.QPushButton(Qt.QIcon(common.SAVE), 'Сохранить', self) self.save_button.setObjectName('Button') self.save_button.setIconSize(Qt.QSize(35, 35)) self.save_button.setFont(Qt.QFont('Arial', 20)) self.save_button.clicked.connect(lambda: app.save_exam_data( { 'rowid': self.exam_data['rowid'], 'name': self.name_input.text(), 'duration': self.duration_input.text(), 'published': self.state_box.currentIndex() })) self.status_img = Qt.QLabel(self) self.status_img.setScaledContents(True) self.status_img.setFixedSize(Qt.QSize(50, 50)) self.status_label = Qt.QLabel(self) self.status_label.setFont(Qt.QFont('Arial', 20)) self.update_status() delete_button = Qt.QPushButton(Qt.QIcon(common.DELETE), 'Удалить экзамен', self) delete_button.setObjectName('Button') delete_button.setIconSize(Qt.QSize(35, 35)) delete_button.setFont(Qt.QFont('Arial', 20)) delete_button.clicked.connect(lambda: app.display_confirm_page( 'Вы уверены, что хотите удалить этот экзамен?', lambda: app. display_exam(self.exam_data['rowid']), lambda: app.delete_exam( self.exam_data['rowid']))) title_layout = Qt.QVBoxLayout() title_layout.addWidget(name_title) title_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) title_layout.addWidget(duration_title) title_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) title_layout.addWidget(state_title) input_layout = Qt.QVBoxLayout() input_layout.addWidget(self.name_input) input_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) input_layout.addWidget(self.duration_input) input_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) input_layout.addWidget(self.state_box) main_layout = Qt.QHBoxLayout() main_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) main_layout.addLayout(title_layout) main_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) main_layout.addLayout(input_layout) results_layout = Qt.QHBoxLayout() results_layout.addWidget(results_button) results_layout.addStretch(1) self.lower_layout.addWidget(self.save_button) self.lower_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) self.lower_layout.addWidget(self.status_img) self.lower_layout.addWidget(self.status_label) self.lower_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) self.lower_layout.addStretch(1) self.lower_layout.addWidget(delete_button) self.layout.addWidget(settings_title) self.layout.addSpacerItem(Qt.QSpacerItem(0, 40)) self.layout.addLayout(main_layout) self.layout.addSpacerItem(Qt.QSpacerItem(0, 40)) self.layout.addLayout(results_layout) self.layout.addStretch(1)
def __init__(self, app, group_name, list_of_exams): super().__init__() update_button = Qt.QPushButton(Qt.QIcon(common.UPDATE), '', self) update_button.setObjectName('Flat') update_button.setCursor(Qt.Qt.PointingHandCursor) update_button.setIconSize(Qt.QSize(35, 35)) update_button.setFixedSize(Qt.QSize(55, 55)) update_button.clicked.connect(lambda _: app.display_home_page()) exams_title = Qt.QLabel('Экзамены группы ' + group_name, self) exams_title.setFont(Qt.QFont('Arial', 30)) view_profile_action = Qt.QWidgetAction(self) view_profile_action.setFont(Qt.QFont('Arial', 15)) view_profile_action.setText('Профиль') view_profile_action.triggered.connect( lambda _: app.display_profile_page()) exit_action = Qt.QWidgetAction(self) exit_action.setFont(Qt.QFont('Arial', 15)) exit_action.setText('Выйти') exit_action.triggered.connect(lambda _: app.logout()) user_menu = Qt.QMenu(self) user_menu.addAction(view_profile_action) user_menu.addAction(exit_action) user_button = Qt.QPushButton(Qt.QIcon(common.USER), '', self) user_button.setObjectName('Flat') user_button.setCursor(Qt.Qt.PointingHandCursor) user_button.setIconSize(Qt.QSize(35, 35)) user_button.setFixedSize(Qt.QSize(55, 55)) user_button.setMenu(user_menu) scroll_area = Qt.QScrollArea() scroll_area.setFrameShape(Qt.QFrame.NoFrame) scroll_layout = Qt.QVBoxLayout() scroll_layout.setSizeConstraint(Qt.QLayout.SetMinimumSize) for exam in list_of_exams: exam_id = exam['rowid'] exam_name = exam['name'] exam_button = Qt.QPushButton(Qt.QIcon(common.EXAM30), exam_name, self) exam_button.setObjectName('Flat') exam_button.setCursor(Qt.Qt.PointingHandCursor) exam_button.setIconSize(Qt.QSize(30, 30)) exam_button.setFont(Qt.QFont('Arial', 20)) exam_button.clicked.connect( common.return_lambda(app.display_exam, exam_id)) exam_layout = Qt.QHBoxLayout() exam_layout.addWidget(exam_button) exam_layout.addStretch(1) scroll_layout.addLayout(exam_layout) scroll_layout.addStretch(1) scroll_widget = Qt.QWidget(self) scroll_widget.setLayout(scroll_layout) scroll_area.setWidget(scroll_widget) upper_layout = Qt.QHBoxLayout() upper_layout.addWidget(update_button) upper_layout.addStretch(1) upper_layout.addWidget(exams_title) upper_layout.addStretch(1) upper_layout.addWidget(user_button) layout = Qt.QVBoxLayout() layout.addLayout(upper_layout) layout.addSpacerItem(Qt.QSpacerItem(0, 20)) layout.addWidget(scroll_area) self.setLayout(layout)
def __init__(self, app, exam_id, question_data, question_result): super().__init__() self.question_data = question_data self.question_details = common.get_question_details(question_result) back_button = Qt.QPushButton(Qt.QIcon(common.LEFT), '', self) back_button.setObjectName('Flat') back_button.setCursor(Qt.Qt.PointingHandCursor) back_button.setIconSize(Qt.QSize(35, 35)) back_button.setFixedSize(Qt.QSize(55, 55)) back_button.clicked.connect(lambda: app.display_results_page(exam_id)) check_title = Qt.QLabel('Результаты проверки', self) check_title.setFont(Qt.QFont('Arial', 30)) scroll_area = Qt.QScrollArea() scroll_area.setWidgetResizable(True) scroll_area.setFrameShape(Qt.QFrame.NoFrame) statement_title = Qt.QLabel('Текст вопроса:', self) statement_title.setFont(Qt.QFont('Arial', 25)) statement_label = Qt.QLabel(self.question_data['statement'], self) statement_label.setFont(Qt.QFont('Arial', 20)) statement_label.setWordWrap(True) answer_title = Qt.QLabel('Ответ участника:', self) answer_title.setFont(Qt.QFont('Arial', 25)) answer_label = Qt.QLabel(self.question_details['answer'], self) answer_label.setFont(Qt.QFont('Arial', 20)) answer_label.setWordWrap(True) self.save_button = Qt.QPushButton('Сохранить', self) self.save_button.setObjectName('Button') self.save_button.setFont(Qt.QFont('Arial', 20)) self.save_button.clicked.connect(lambda: app.save_submission_score( exam_id, self.question_data['rowid'], question_result['rowid'], self.score_input.text() )) score_title = Qt.QLabel('Баллы (из ' + str(self.question_data['maxscore']) + '):', self) score_title.setFont(Qt.QFont('Arial', 20)) self.score_input = Qt.QLineEdit(self.question_details['score'], self) self.score_input.setFont(Qt.QFont('Arial', 20)) self.score_input.setMinimumWidth(200) self.score_input.textChanged.connect(self.update_status) self.score_input.returnPressed.connect(self.save_button.click) self.status_img = Qt.QLabel(self) self.status_img.setScaledContents(True) self.status_img.setFixedSize(Qt.QSize(50, 50)) self.status_label = Qt.QLabel(self) self.status_label.setFont(Qt.QFont('Arial', 20)) self.update_status() upper_layout = Qt.QHBoxLayout() upper_layout.addWidget(back_button) upper_layout.addStretch(1) upper_layout.addWidget(check_title) upper_layout.addStretch(1) statement_layout = Qt.QVBoxLayout() statement_layout.addWidget(statement_title) statement_layout.addSpacerItem(Qt.QSpacerItem(0, 10)) statement_layout.addWidget(statement_label) answer_layout = Qt.QVBoxLayout() answer_layout.addWidget(answer_title) answer_layout.addSpacerItem(Qt.QSpacerItem(0, 10)) answer_layout.addWidget(answer_label) scroll_layout = Qt.QVBoxLayout() scroll_layout.addLayout(statement_layout) scroll_layout.addSpacerItem(Qt.QSpacerItem(0, 20)) scroll_layout.addLayout(answer_layout) scroll_layout.addStretch(1) scroll_widget = Qt.QWidget(self) scroll_widget.setLayout(scroll_layout) scroll_area.setWidget(scroll_widget) score_layout = Qt.QHBoxLayout() score_layout.addWidget(score_title) score_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) score_layout.addWidget(self.score_input) save_layout = Qt.QHBoxLayout() save_layout.addWidget(self.save_button) save_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) save_layout.addWidget(self.status_img) save_layout.addWidget(self.status_label) save_layout.addSpacerItem(Qt.QSpacerItem(20, 0)) save_layout.addStretch(1) save_layout.addLayout(score_layout) layout = Qt.QVBoxLayout() layout.addLayout(upper_layout) layout.addSpacerItem(Qt.QSpacerItem(0, 20)) layout.addWidget(scroll_area) layout.addSpacerItem(Qt.QSpacerItem(0, 20)) layout.addLayout(save_layout) self.setLayout(layout)