Exemplo n.º 1
0
    def initUI(self):
        self.grid = QtGui.QGridLayout()
        self.setLayout(self.grid)
        self.lbl1 = QtGui.QLabel("Select beamline")
        self.lbl2 = QtGui.QLabel(
            "Enter theta position pv if other than default")
        self.lbl3 = QtGui.QLabel("Warning Message")
        self.lbl4 = QtGui.QLabel(
            "NOTE: PV for 2-IDE data processed before Feb 2018 is 657")
        self.btn = QtGui.QPushButton("Okay")
        self.txtfield = QtGui.QLineEdit("8")
        self.txtfield2 = QtGui.QLineEdit("663")
        self.button = QtGui.QCheckBox("Bionanoprobe")
        self.button2 = QtGui.QCheckBox("2-IDE")
        self.setWindowTitle('Configuration')
        self.btn.setAutoRepeat(True)

        vb = QtGui.QVBoxLayout()
        vb.addWidget(self.lbl1, 1)
        vb.addWidget(self.button, 2)
        vb.addWidget(self.button2, 3)
        vb2 = QtGui.QVBoxLayout()
        vb2.addWidget(self.lbl2, 1)
        vb2.addWidget(self.txtfield, 2)
        vb2.addWidget(self.txtfield2, 3)
        vb3 = QtGui.QVBoxLayout()
        vb3.addWidget(self.lbl3)
        vb3.addWidget(self.lbl4)
        vb4 = QtGui.QVBoxLayout()
        vb4.addWidget(self.btn)

        self.grid.addLayout(vb, 0, 0, 2, 1)
        self.grid.addLayout(vb2, 0, 1, 2, 2)
        self.grid.addLayout(vb3, 4, 0, 2, 3)
        self.grid.addLayout(vb4, 6, 1, 1, 1)
Exemplo n.º 2
0
    def addVisItem(self, name, visitem):
        print "[detector display] received visitem=", name
        self.user_items[name] = visitem
        self.user_item_checkboxes[name] = QtGui.QCheckBox('')
        self.map_user_checkboxes2name[self.user_item_checkboxes[name]] = name
        self.user_item_checkboxes[name].setChecked(True)
        # connect to signal
        # multiple sub-objects!
        if type(visitem) is list:
            self.user_subitem_cbxs[name] = []
            for ix, subitem in enumerate(visitem):
                self.user_subitem_cbxs[name].append(QtGui.QCheckBox(''))
                self.user_subitem_cbxs[name][ix].setChecked(True)

        # make tree widget item
        item = pg.TreeWidgetItem(['', name])
        item.setWidget(0, self.user_item_checkboxes[name])
        self.user_item_tree.addTopLevelItem(item)

        if type(visitem) is list:
            for ix in range(0, len(visitem)):
                subitem = visitem[ix]
                if hasattr(subitem, "uservisname"):
                    subname = subitem.uservisname + "_%d" % (ix)
                else:
                    subname = name + "_%d" % (ix)
                subitem = pg.TreeWidgetItem([subname])
                item.addChild(subitem)
                self.user_item_tree.setItemWidget(
                    subitem, 1, self.user_subitem_cbxs[name][ix])
Exemplo n.º 3
0
    def __init__(self):
        super().__init__()
        self.setWindowTitle('CUWB Monitor - CDP Data Type Filtering')
        self.num_columns = 10
        self.central = QtGui.QWidget()
        self.grid_layout = QtGui.QGridLayout()
        self.central.setLayout(self.grid_layout)
        self.setCentralWidget(self.central)
        self.resize(1000, 400)
        self.current_types = set()
        self.filtering = False

        self.filter_toggle_button = QtGui.QPushButton('Start Filter')
        self.filter_toggle_button.clicked.connect(self.toggle_filter)
        self.grid_layout.addWidget(self.filter_toggle_button, 0, 0, 1,
                                   self.num_columns)

        self.type_count = 0
        self.type_checkboxes = dict()
        self.type_labels = dict()
        self.types = dict()

        for cdp_type in cdp.CDP.data_item_classes.keys():
            self.types[cdp_type] = cdp.CDP.data_item_classes[cdp_type].__name__
            self.type_checkboxes[cdp_type] = QtGui.QCheckBox()
            self.type_labels[cdp_type] = QtGui.QLabel()
            self.type_count += 1

        self.types[UNKNOWN_FILTER_TYPE] = 'Unknown Types'
        self.type_checkboxes[UNKNOWN_FILTER_TYPE] = QtGui.QCheckBox()
        self.type_labels[UNKNOWN_FILTER_TYPE] = QtGui.QLabel()

        type_per_col = (int(self.type_count / (self.num_columns / 2)) + 1)
        row = 1
        col = 0
        for cdp_type in sorted(self.types.keys()):
            self.grid_layout.addWidget(self.type_checkboxes[cdp_type], row,
                                       col)
            self.grid_layout.addWidget(self.type_labels[cdp_type], row,
                                       col + 1)
            self.type_labels[cdp_type].setText(self.types[cdp_type])
            self.type_labels[cdp_type].setAlignment(QtCore.Qt.AlignLeft)
            row += 1
            if row > type_per_col:
                col += 2
                row = 1

        self.timer = self.startTimer(QPLOT_FREQUENCY)
Exemplo n.º 4
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(820, 650)
        MainWindow.setAutoFillBackground(False)
        MainWindow.setDocumentMode(False)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setContentsMargins(-1, -1, 0, 0)
        self.horizontalLayout.setSpacing(10)
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.btnAdd = QtGui.QPushButton(self.centralwidget)
        self.btnAdd.setObjectName(_fromUtf8("btnAdd"))
        self.horizontalLayout.addWidget(self.btnAdd)
        self.chkMore = QtGui.QCheckBox(self.centralwidget)
        self.chkMore.setObjectName(_fromUtf8("chkMore"))
        self.horizontalLayout.addWidget(self.chkMore)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.grPlot = PlotWidget(self.centralwidget)
        self.grPlot.setObjectName(_fromUtf8("grPlot"))
        self.verticalLayout.addWidget(self.grPlot)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Exemplo n.º 5
0
    def __init__(self, cg):
        super(WatchlistWindow, self).__init__()

        self.cg = cg
        self.ui = watchlist_ui.Ui_WatchlistWindow()
        self.ui.setupUi(self)

        for c, col in enumerate(WatchlistModel.columns + WatchlistModel.multiColumns):
            checkbox = QtGui.QCheckBox(col)
            checkbox.clicked.connect(self.onSelectColumns)
            self.ui.showColumns.layout().addWidget(checkbox)
            setattr(self.ui, col + '_checkbox', checkbox)# for guiSave()

        self.sortedMarkets = []
        self.sortColumns = {}
        self.recalcSortKeys = False
        self.selectedMarket = None
        self.ui.tableView.setAlternatingRowColors(True)
        header = self.ui.tableView.horizontalHeader()
        header.sectionClicked.connect(self.onHeaderSectionClicked)
        header.setResizeMode(QtGui.QHeaderView.Stretch)

        self.ui.tableView.mouseMoveEvent = self.listMouseMoveEvent
        self.ui.tableView.setMouseTracking(True)

        for i in range(len(ALL_TIMEFRAMES)):
            self.ui.showCharts.addItem(', '.join(ALL_TIMEFRAMES[:i+1]))
        for i in range(-len(ALL_TIMEFRAMES)+1, 0):
            self.ui.showCharts.addItem(', '.join(ALL_TIMEFRAMES[i:]))

        self.loadWatchlists()

        firstOne = None
        for name,watchlist in sorted(self.watchlists.items()):
            item = name
            if len(watchlist):
                item += ' (%i)' % len(watchlist)
            firstOne = item if name == 'Builtin' else firstOne
            self.ui.watchlistName.addItem(item)

        guiRestore(self.ui, gSettings)

        # Set the default selected item
        #self.ui.watchlistName.setCurrentIndex(self.ui.watchlistName.findText(firstOne))

        self.procRefresh = None
        self.ui.watchlistName.currentIndexChanged.connect(self.onWatchlistSelected)
        def onFilter():
            self.ui.filterEdit.setFocus()
            self.ui.filterEdit.selectAll()
        QtGui.QShortcut(QtGui.QKeySequence('Ctrl+F'), self, onFilter)
        self.ui.filterEdit.textChanged.connect(self.onSelectColumns)

        self.model = WatchlistModel(self)
        self.ui.tableView.setModel(self.model)
        selectionModel = self.ui.tableView.selectionModel()
        selectionModel.selectionChanged.connect(self.listSelectionChanged)
Exemplo n.º 6
0
    def initUI(self):
        names = list()

        for i in arange(self.numlabels):
            names.append("")
        self.grid = QtGui.QGridLayout()
        self.lbl = QtGui.QLabel()
        self.lbl2 = QtGui.QLabel()
        self.lbl.setText(
            "closing this window won't affect your selection of the files")
        self.lbl2.setText(
            "You should convert the files in order to generate sinogram or reconstructed data"
        )
        self.btn = QtGui.QPushButton('Save Data in Memory', self)
        self.btn2 = QtGui.QPushButton("set Image Tag", self)
        self.btn3 = QtGui.QPushButton("set Element", self)
        self.btn4 = QtGui.QPushButton("Sort data by angle")

        columns = np.ceil(np.sqrt(self.numlabels))
        rows = 10
        j = 0
        pos = list()
        for y in arange(columns):
            for x in arange(rows):
                pos.append((x, y))

        self.button = list()
        for i in names:
            self.button.append(QtGui.QCheckBox(i))
            self.grid.addWidget(self.button[j], pos[j][0], pos[j][1])
            j = j + 1
        self.setLayout(self.grid)

        self.vb = QtGui.QVBoxLayout()
        self.vb2 = QtGui.QVBoxLayout()

        self.vb.addWidget(self.lbl, 12)
        self.vb.addWidget(self.lbl2, 13)

        hb = QtGui.QHBoxLayout()
        hb.addWidget(self.btn2)
        hb.addWidget(self.btn3)
        hb.addWidget(self.btn4)

        self.vb2.addLayout(hb)
        self.vb2.addWidget(self.btn)

        self.grid.addLayout(self.vb, 11, 0, 1, 7)
        self.grid.addLayout(self.vb2, 13, 1, 1, 3)

        self.move(100, 100)
        self.setWindowTitle('Calculator')
        self.show()
Exemplo n.º 7
0
    def init(self, name):
        self.name = name

        self.autoscale_button = QtGui.QCheckBox('Autoscale')
        self.autoscale_button.setCheckState(True)

        self.welch_button = QtGui.QCheckBox('Use Welch')
        self.welch_button.setCheckState(False)

        self.plot_widget = pg.PlotWidget(title=name)
        self.plot_widget.block = self

        self.plot_widget.setLabel('bottom', 'Frequency', units='Hz')
        self.plot_widget.setLabel("left", "Time", units='s')

        #TODO: listener for this
        #self.plot_widget.setYRange(-self.history_size / self.sampling_rate, 0)

        #self.plot_widget.setLimits(xMin=0, yMax=0)
        #self.plot_widget.showButtons()
        #self.waterfallPlotWidget.setAspectLocked(True)
        #self.waterfallPlotWidget.setDownsampling(mode="peak")
        #self.waterfallPlotWidget.setClipToView(True)
        
        # Setup histogram widget (for controlling waterfall plot levels and gradients)
        self.histogram = pg.PlotWidget(title='Histogram')
        self.waterfallHistogram = pg.HistogramLUTItem()
        self.histogram.addItem(self.waterfallHistogram)
        self.waterfallHistogram.gradient.loadPreset("flame")
        #self.waterfallHistogram.setHistogramRange(-50, 0)
        #self.waterfallHistogram.setLevels(-50, 0)

        self.waterfallImg = pg.ImageItem()
        self.plot_widget.clear()
        self.plot_widget.addItem(self.waterfallImg)      
        self.waterfallHistogram.setImageItem(self.waterfallImg)

        self.setup_range()

        self.update_counter = 0
Exemplo n.º 8
0
 def __init__(self, apiKey, parent=None):
     super(Login, self).__init__(parent)
     self.apiKey = apiKey
     self.setWindowTitle('IG Login')
     self.textName = QtGui.QLineEdit(self)
     self.textPass = QtGui.QLineEdit(self)
     self.textPass.setEchoMode(QtGui.QLineEdit.Password)
     self.saveLogin = QtGui.QCheckBox('Save Login', self)
     self.saveLogin.setChecked(True)
     self.buttonLogin = QtGui.QPushButton('Login', self)
     self.buttonLogin.clicked.connect(self.handleLogin)
     layout = QtGui.QVBoxLayout(self)
     layout.addWidget(self.textName)
     layout.addWidget(self.textPass)
     layout.addWidget(self.saveLogin)
     layout.addWidget(self.buttonLogin)
Exemplo n.º 9
0
 def add_row(self, name, checkbox_name=None):
    current_row = self.layout.rowCount()
    if self.layout.count != 0:
       current_row +=1
    l = QtGui.QLabel(name) # graph width label
    sp = QtGui.QSpinBox()     # graph width spinbox
    sp.setMaximum(max(QtGui.QApplication.desktop().size().width(),
                      QtGui.QApplication.desktop().size().height()))
    self.rows[name] = (l, sp)
    self.layout.addWidget(l,current_row, 0)
    self.layout.addWidget(sp,current_row, 1)
    if checkbox_name is not None:
       l_check = QtGui.QLabel(checkbox_name)
       check = QtGui.QCheckBox()
       self.layout.addWidget(l_check, current_row, 2)
       self.layout.addWidget(check, current_row, 3)
       return l, sp, check
    return l, sp
Exemplo n.º 10
0
    def display_cuwb_networks_widget(self):
        self.cuwb_nets = QtGui.QWidget()
        self.cuwb_nets.setSizePolicy(QtGui.QSizePolicy.Minimum,
                                     QtGui.QSizePolicy.Maximum)
        nets_layout = QtGui.QVBoxLayout()
        self.cuwb_nets.setLayout(nets_layout)
        self.scroll_area.setWidget(self.cuwb_nets)

        if len(self.network_discovery.available_networks) == 0:
            label = QtGui.QLabel("No CUWB networks are available")
            label.setStyleSheet('color: red')
            nets_layout.addWidget(label, QtCore.Qt.AlignCenter)
        else:
            # Restart CDP streams indexes and empty all containers to avoid duplication
            self.stream_idx = 0
            self.cdp_streams = dict()
            self.stream_checkboxes = dict()
            # All available addresses indexed by ListeningAddrInfo  objects.
            # The values are sets of stream_idx. This information is used to
            # auto check/uncheck checkboxes equivalent addresses.
            # It does not include the indexes of streams with interface '0.0.0.0'
            self.available_addresses = dict()
            # It includes the indexes of streams with interface '0.0.0.0'
            self.any_interface_streams = dict()
            for serial, net_info in sorted(
                    self.network_discovery.available_networks.items(),
                    key=lambda item:
                (item[1].instance_name, item[1].hostname, item[1].source_ip)):
                cuwb_net = QtGui.QFrame()
                cuwb_net.setFrameStyle(QtGui.QFrame.StyledPanel
                                       | QtGui.QFrame.Raised)
                cuwb_net.setLineWidth(1)
                net_layout = QtGui.QGridLayout()
                net_layout.setMargin(0)
                cuwb_net.setLayout(net_layout)

                header = QtGui.QWidget()
                header_layout = QtGui.QGridLayout()
                header.setLayout(header_layout)
                label = QtGui.QLabel('Network: <b>{} ({})</b>'.format(
                    net_info.instance_name, serial))
                header_layout.addWidget(label, 0, 0)
                label = QtGui.QLabel('Host: <b>{}</b>'.format(
                    net_info.hostname))
                header_layout.addWidget(label, 0, 1)
                label = QtGui.QLabel('{}'.format(net_info.source_ip))
                header_layout.addWidget(label, 0, 2, QtCore.Qt.AlignRight)
                net_layout.addWidget(header, 0, 0)

                streams = QtGui.QWidget()
                streams_layout = QtGui.QGridLayout()
                streams.setLayout(streams_layout)
                idx = 0
                stream_order = ['external', 'internal', 'config', 'debug']
                for stream_name in stream_order:
                    # Check if we received information about the CDP stream
                    # before trying to display it
                    if stream_name not in net_info.cdp_streams:
                        continue
                    stream = net_info.cdp_streams[stream_name]
                    label = QtGui.QLabel('{}'.format(
                        stream.alias.capitalize()))
                    streams_layout.addWidget(label, idx, 0)
                    label = QtGui.QLabel('{}/{}'.format(
                        stream.interface, stream.netmask))
                    streams_layout.addWidget(label, idx, 1)
                    label = QtGui.QLabel('->')
                    streams_layout.addWidget(label, idx, 2,
                                             QtCore.Qt.AlignCenter)
                    label = QtGui.QLabel('{}:{}'.format(
                        stream.ip, stream.port))
                    streams_layout.addWidget(label, idx, 3)
                    # Add CDP stream checkbox and connect Qt signal to callback function to handle state changes
                    self.stream_checkboxes[self.stream_idx] = QtGui.QCheckBox()
                    self.stream_checkboxes[
                        self.stream_idx].stateChanged.connect(
                            partial(self.stream_click_event, self.stream_idx))
                    streams_layout.addWidget(
                        self.stream_checkboxes[self.stream_idx], idx, 4,
                        QtCore.Qt.AlignRight)

                    if not self.network_discovery.is_interface_available(
                            stream):
                        # Disable checkbox if interface is not on the same subnet
                        self.stream_checkboxes[self.stream_idx].setEnabled(
                            False)
                    else:
                        # Dynamically add attribute to store the equivalent address(es)
                        # using the local interface(s)
                        stream.equivalent_addresses = self.get_equivalent_addresses(
                            stream)

                        if stream.interface != StreamInformation.any_interface:
                            for listen_addr in stream.equivalent_addresses:
                                # Check if there is another CDP stream with the same IP, port and
                                # equivalent local interface and keep track of the indexes of these streams
                                if listen_addr not in self.available_addresses:
                                    self.available_addresses[
                                        listen_addr] = set()
                                self.available_addresses[listen_addr].add(
                                    self.stream_idx)
                                # Check if we are already listening on this address and autocheck the checkbox
                                if listen_addr in self.active_addresses:
                                    self.stream_checkboxes[
                                        self.stream_idx].setChecked(True)
                        else:
                            # Check if there is another CDP stream with the same IP, port and
                            # interface set to '0.0.0.0' and keep track of the indexes of these streams
                            if stream not in self.any_interface_streams:
                                self.any_interface_streams[stream] = set()
                            self.any_interface_streams[stream].add(
                                self.stream_idx)
                            # Check if we are already listening on this address and autocheck the checkbox
                            if stream in self.active_any_interface_streams:
                                self.stream_checkboxes[
                                    self.stream_idx].setChecked(True)

                    # Keep track of all the displayed CDP streams and their indexes
                    self.cdp_streams[self.stream_idx] = stream
                    self.stream_idx += 1
                    idx += 1
                net_layout.addWidget(streams, 1, 0)
                nets_layout.addWidget(cuwb_net)
Exemplo n.º 11
0
    def initUI(self):
        self.combo = QtGui.QComboBox(self)
        self.method = QtGui.QComboBox(self)
        self.btn = QtGui.QPushButton('Click2')
        self.save = QtGui.QPushButton("Save tiff files")
        self.save.setHidden(True)
        self.btn.setText("Sinogram")
        self.sld = QtGui.QSlider(QtCore.Qt.Horizontal, self)
        self.lcd = QtGui.QLineEdit("0")
        self.lbl = QtGui.QLabel()
        self.cbox = QtGui.QCheckBox("")
        self.lbl2 = QtGui.QLabel("Center")
        self.lbl.setText("")

        self.threshLbl = QtGui.QLabel("threshold")
        self.threshLe = QtGui.QLineEdit("")
        self.threshBtn = QtGui.QPushButton("Apply")

        centerBox = QtGui.QHBoxLayout()
        centerBox.addWidget(self.cbox)
        centerBox.addWidget(self.lbl2)
        centerBox.addWidget(self.lcd)
        self.lcd.setEnabled(False)
        self.methodname = ["mlem", "gridrec", "art", "pml_hybrid", "pml_quad"]

        self.mulBtn = QtGui.QPushButton("x 10")
        self.divBtn = QtGui.QPushButton("/ 10")
        mdBox = QtGui.QHBoxLayout()
        mdBox.addWidget(self.mulBtn)
        mdBox.addWidget(self.divBtn)

        self.maxLbl = QtGui.QLabel("Max")
        self.minLbl = QtGui.QLabel("Min")
        self.maxText = QtGui.QLineEdit()
        self.minText = QtGui.QLineEdit()

        maxBox = QtGui.QHBoxLayout()
        minBox = QtGui.QHBoxLayout()
        maxBox.addWidget(self.maxLbl)
        maxBox.addWidget(self.maxText)
        minBox.addWidget(self.minLbl)
        minBox.addWidget(self.minText)

        self.betaName = QtGui.QLabel("Beta")
        self.deltaName = QtGui.QLabel("Delta")
        self.itersName = QtGui.QLabel("Iteration")
        self.beta = QtGui.QLineEdit("1")
        self.delta = QtGui.QLineEdit("0.01")
        self.iters = QtGui.QLineEdit("10")

        betaBox = QtGui.QHBoxLayout()
        deltaBox = QtGui.QHBoxLayout()
        itersBox = QtGui.QHBoxLayout()
        threshBox = QtGui.QHBoxLayout()
        betaBox.addWidget(self.betaName)
        betaBox.addWidget(self.beta)
        deltaBox.addWidget(self.deltaName)
        deltaBox.addWidget(self.delta)
        itersBox.addWidget(self.itersName)
        itersBox.addWidget(self.iters)
        threshBox.addWidget(self.threshLbl)
        threshBox.addWidget(self.threshLe)
        threshBox.addWidget(self.threshBtn)

        for k in arange(len(self.methodname)):
            self.method.addItem(self.methodname[k])
        vb = QtGui.QVBoxLayout()
        vb.addWidget(self.combo)
        vb.addWidget(self.method)
        vb.addWidget(self.btn)
        vb.addWidget(self.save)
        vb.addLayout(centerBox)
        vb.addLayout(threshBox)
        vb.addWidget(self.sld)
        vb.addWidget(self.lbl)
        vb.addLayout(mdBox)
        vb.addLayout(maxBox)
        vb.addLayout(minBox)
        vb.addLayout(itersBox)
        vb.addLayout(betaBox)
        vb.addLayout(deltaBox)
        self.setLayout(vb)
Exemplo n.º 12
0
    def timerEvent(self, e):
        if not UwbNetwork.running:
            self.close()

        if self.serial in UwbNetwork.nodes.keys():

            if self.resize_flag:
                self.resize(400, 5)
                self.resize_flag = False

            if self.type_count > len(UwbNetwork.nodes[self.serial].cdp_pkts):
                for row in range(self.type_count):
                    self.type_labels[row].close()
                    self.count_labels[row].close()
                    self.disp_freqs[row].close()
                    self.disp_checks[row].close()
                    del self.type_labels[row]
                    del self.count_labels[row]
                    del self.disp_freqs[row]
                    del self.disp_checks[row]
                self.resize_flag = True
                self.type_count = 0


            while len(UwbNetwork.nodes[self.serial].cdp_pkts) > self.type_count:
                self.type_labels.update([(self.type_count, QtGui.QLabel())])
                self.count_labels.update([(self.type_count, QtGui.QLabel())])
                self.disp_freqs.update([(self.type_count, QtGui.QLabel())])
                self.disp_checks.update([(self.type_count, QtGui.QCheckBox())])

                self.type_labels[self.type_count].setAlignment(QtCore.Qt.AlignRight)
                self.count_labels[self.type_count].setAlignment(QtCore.Qt.AlignCenter)
                self.disp_freqs[self.type_count].setAlignment(QtCore.Qt.AlignCenter)
                self.grid_layout.addWidget(self.type_labels[self.type_count], self.type_count + 1, 0)
                self.grid_layout.addWidget(self.count_labels[self.type_count], self.type_count + 1, 1)
                self.grid_layout.addWidget(self.disp_freqs[self.type_count], self.type_count + 1, 2)
                self.grid_layout.addWidget(self.disp_checks[self.type_count], self.type_count + 1, 3)

                self.count_labels[self.type_count].mouseReleaseEvent = partial(self.countClickEvent, self.type_count)
                self.count_labels[self.type_count].setStyleSheet('color: blue')

                self.type_count += 1

            for type in UwbNetwork.nodes[self.serial].cdp_pkts.keys():
                UwbNetwork.nodes[self.serial].cdp_pkts_frequency_deques[type].append((UwbNetwork.nodes[self.serial].cdp_pkts_count[type], time.time()))
                UwbNetwork.nodes[self.serial].cdp_pkts_freq[type] = UwbNetwork.nodes[self.serial].calculate_frequency(UwbNetwork.nodes[self.serial].cdp_pkts_frequency_deques[type])

            _cdp_types = np.sort(list(UwbNetwork.nodes[self.serial].cdp_pkts.keys()))
            for _row in range(self.type_count):

                if self.type_labels[_row].text() != UwbNetwork.nodes[self.serial].cdp_pkts_name[_cdp_types[_row]]:
                    self.type_labels[_row].setText(UwbNetwork.nodes[self.serial].cdp_pkts_name[_cdp_types[_row]])
                    if _cdp_types[_row] in map_type_to_plot or _cdp_types[_row] == AppSettingsChunk.type \
                       or _cdp_types[_row] in map_type_to_display_window:
                        self.type_labels[_row].setStyleSheet('color: blue')
                        self.type_labels[_row].mouseReleaseEvent = partial(self.labelClickEvent, _cdp_types[_row])
                    else:
                        self.type_labels[_row].setStyleSheet('color: grey')
                        self.type_labels[_row].mouseReleaseEvent = None

                    if UwbNetwork.nodes[self.serial].cdp_pkts_selected[_cdp_types[_row]]:
                        self.disp_checks[_row].setCheckState(QtCore.Qt.Checked)
                    else:
                        self.disp_checks[_row].setCheckState(QtCore.Qt.Unchecked)

                _previous_count = self.count_labels[_row].text()
                if _previous_count: _previous_count = int(_previous_count)
                self.count_labels[_row].setText('{:5d}'.format(UwbNetwork.nodes[self.serial].cdp_pkts_count[_cdp_types[_row]]))
                self.disp_freqs[_row].setText('{:0.3f} Hz'.format(UwbNetwork.nodes[self.serial].cdp_pkts_freq[_cdp_types[_row]]))
                if not _previous_count: _previous_count = int(self.count_labels[_row].text())


                if self.disp_checks[_row].isChecked():
                    _current_size = UwbNetwork.nodes[self.serial].cdp_pkts_count[_cdp_types[_row]] - _previous_count
                    UwbNetwork.nodes[self.serial].cdp_pkts_selected[_cdp_types[_row]] = True
                    for idx in range(_current_size):
                        print(UwbNetwork.nodes[self.serial].cdp_pkts[_cdp_types[_row]][idx - _current_size])
                else: UwbNetwork.nodes[self.serial].cdp_pkts_selected[_cdp_types[_row]] = False
Exemplo n.º 13
0
    def __init__(self, serial, main_window=None):
        super().__init__()
        # Reference to the main window when device_id is provided as a command argument.
        # This reference is used to close the main window, which is hidden in this mode.
        self.main_window = main_window
        self.resize_flag = True

        self.central = QtGui.QWidget()  # This will be our central widget
        self.grid_layout = QtGui.QGridLayout()
        self.plot_windows = dict()
        self.display_windows = dict()

        self.serial = serial
        self.setWindowTitle('CUWB Monitor - ID: 0x{:08X}'.format(self.serial))

        self.type_title = QtGui.QLabel('Type')
        self.type_title.setStyleSheet('color: black')
        self.type_title.setAlignment(QtCore.Qt.AlignRight)
        self.type_title.setMargin(5)

        self.count_title = QtGui.QLabel('Count')
        self.count_title.setStyleSheet('color: black')
        self.count_title.setAlignment(QtCore.Qt.AlignCenter)
        self.count_title.setMargin(5)

        self.freq_title = QtGui.QLabel('Frequency')
        self.freq_title.setStyleSheet('color: black')
        self.freq_title.setAlignment(QtCore.Qt.AlignCenter)
        self.freq_title.setMargin(5)

        self.print_title = QtGui.QLabel('Print')
        self.print_title.setStyleSheet('color: black')
        self.print_title.setAlignment(QtCore.Qt.AlignLeft)
        self.print_title.setMargin(5)

        self.grid_layout.addWidget(self.type_title, 0, 0)
        self.grid_layout.addWidget(self.count_title, 0, 1)
        self.grid_layout.addWidget(self.freq_title, 0, 2)
        self.grid_layout.addWidget(self.print_title, 0, 3)

        self.type_count = 0
        self.type_labels = dict()
        self.count_labels = dict()
        self.disp_checks = dict()
        self.disp_freqs = dict()
        if self.serial in UwbNetwork.nodes.keys():
            _cdp_types = np.sort(list(UwbNetwork.nodes[self.serial].cdp_pkts.keys()))
            for _type in _cdp_types:

                self.type_labels.update([(self.type_count, QtGui.QLabel(UwbNetwork.nodes[self.serial].cdp_pkts_name[_type]))])
                self.count_labels.update([(self.type_count, QtGui.QLabel('{:5d}'.format(UwbNetwork.nodes[self.serial].cdp_pkts_count[_type])))])
                self.disp_freqs.update([(self.type_count, QtGui.QLabel('{:0.3f} Hz'.format(UwbNetwork.nodes[self.serial].cdp_pkts_freq [_type])))])
                self.disp_checks.update([(self.type_count, QtGui.QCheckBox())])

                self.type_labels[self.type_count].setAlignment(QtCore.Qt.AlignRight)
                self.count_labels[self.type_count].setAlignment(QtCore.Qt.AlignCenter)
                self.disp_freqs[self.type_count].setAlignment(QtCore.Qt.AlignCenter)

                self.grid_layout.addWidget(self.type_labels[self.type_count], self.type_count+1, 0)
                self.grid_layout.addWidget(self.count_labels[self.type_count], self.type_count+1, 1)
                self.grid_layout.addWidget(self.disp_freqs[self.type_count], self.type_count+1, 2)
                self.grid_layout.addWidget(self.disp_checks[self.type_count], self.type_count+1, 3)

                if _type in map_type_to_plot.keys() or _type == AppSettingsChunk.type:
                    self.type_labels[self.type_count].setStyleSheet('color: blue')
                    self.type_labels[self.type_count].mouseReleaseEvent = partial(self.labelClickEvent, _type)

                if _type in map_type_to_display_window.keys():
                    self.type_labels[self.type_count].setStyleSheet('color: blue')
                    self.type_labels[self.type_count].mouseReleaseEvent = partial(self.labelClickEvent, _type)

                self.count_labels[self.type_count].mouseReleaseEvent = partial(self.countClickEvent, self.type_count)
                self.count_labels[self.type_count].setStyleSheet('color: blue')

                self.type_count += 1

        self.central.setLayout(self.grid_layout)
        self.setCentralWidget(self.central)

        self.timer = self.startTimer(QPLOT_FREQUENCY)
Exemplo n.º 14
0
    def initUI(self):
        """Initialise the GUI."""
        self.usemock = False
        hbmain = QtGui.QHBoxLayout()
        
        self.plt1 = pg.PlotWidget()
        self.plt1.setLabel('left', "y (mm)")
        self.plt1.setLabel('bottom', "x (mm)")
        self.plt1.showGrid(x=True, y=True)
        self.plt_headposition_x = pg.InfiniteLine(angle=90, movable=False)
        self.plt_headposition_y = pg.InfiniteLine(angle=0, movable=False)
        self.plt1.addItem(self.plt_headposition_x)
        self.plt1.addItem(self.plt_headposition_y)
        self.plt_gcode = self.plt1.plot(pen=pg.mkPen('r', width=2))
        self.plt1.setAspectLocked(True,ratio=1)
        
        hbmain.addWidget(self.plt1)
        
        
        vbconsole = QtGui.QVBoxLayout()
        gb = QtGui.QGroupBox('console:')
        gbvb = QtGui.QVBoxLayout()
        
        gbvbhb = QtGui.QHBoxLayout()
        self.gui_console_date_cb = QtGui.QCheckBox('show date', self, checkable=True, checked=False)
        self.gui_console_time_cb = QtGui.QCheckBox('show time', self, checkable=True, checked=False)
        gbvbhb.addWidget(self.gui_console_date_cb)
        gbvbhb.addWidget(self.gui_console_time_cb)
        gbvb.addLayout(gbvbhb)

        self.gui_consoletext = QtGui.QTextEdit()
        gbvb.addWidget(self.gui_consoletext)
        
        self.gui_command = QtGui.QLineEdit('', self)
        self.gui_command.returnPressed.connect(self.respond_gui_command)
        gbvb.addWidget(self.gui_command)
        
        gb.setLayout(gbvb)
        vbconsole.addWidget(gb)

        hbmain.addLayout(vbconsole)


        vbcontrols = QtGui.QVBoxLayout()
        
        gb = QtGui.QGroupBox('connection:')
        gbvb = QtGui.QVBoxLayout()
        hbox = QtGui.QHBoxLayout()
        pb = QtGui.QPushButton("Scan")
        pb.clicked.connect(self.scan)
        self.scanbtn = pb
        hbox.addWidget(pb)
        cb=QtGui.QComboBox()
        self.port_list=cb
        self.port_list.setMinimumWidth(200)
        hbox.addWidget(cb)
        cb=QtGui.QCheckBox("Open")
        self.opened=cb
        cb.stateChanged.connect(self.toggle_connection)
        hbox.addWidget(cb)
        gbvb.addLayout(hbox)
        gb.setLayout(gbvb)
        vbcontrols.addWidget(gb)

        # gb = QtGui.QGroupBox('controls:')
        # gbvb = QtGui.QVBoxLayout()
        # gbvbhb = QtGui.QHBoxLayout()
        # btn = QtGui.QPushButton('unlock')
        # btn.clicked.connect(self.unlock)
        # gbvbhb.addWidget(btn)
        # btn = QtGui.QPushButton('FEED HOLD')
        # btn.clicked.connect(self.feed_hold)
        # gbvbhb.addWidget(btn)
        # btn = QtGui.QPushButton('RESUME')
        # btn.clicked.connect(self.feed_resume)
        # gbvbhb.addWidget(btn)
        # gbvb.addLayout(gbvbhb)
        # gb.setLayout(gbvb)
        # vbcontrols.addWidget(gb)

        gb = QtGui.QGroupBox('main:')
        gbvb = QtGui.QVBoxLayout()
        
        
        gbvbhb = QtGui.QHBoxLayout()
        btn = QtGui.QPushButton('unlock')
        btn.clicked.connect(self.unlock)
        gbvbhb.addWidget(btn)
        
        self.motorlock_enable_cb = QtGui.QCheckBox('motorlock', self, checkable=True, checked=True)
        self.motorlock_enable_cb.clicked.connect(self.motorlock_toggle)
        gbvbhb.addWidget(self.motorlock_enable_cb)
        
        btn = QtGui.QPushButton('set MCS zero (home)!')
        btn.clicked.connect(self.gui_set_mcs_zero)
        gbvbhb.addWidget(btn)
        btn = QtGui.QPushButton('set WCS zero!')
        btn.clicked.connect(self.gui_set_wcs_zero)
        gbvbhb.addWidget(btn)
        gbvb.addLayout(gbvbhb)
        
        gbvbhb = QtGui.QHBoxLayout()
        btn = QtGui.QPushButton('G0 go to MCS origin')
        btn.clicked.connect(self.go_to_mcs_origin)
        gbvbhb.addWidget(btn)
        btn = QtGui.QPushButton('G0 go to WCS origin')
        btn.clicked.connect(self.go_to_wcs_origin)
        gbvbhb.addWidget(btn)
        gbvb.addLayout(gbvbhb)

        gb.setLayout(gbvb)
        vbcontrols.addWidget(gb)

        gb = QtGui.QGroupBox('position:')
        gbvb = QtGui.QVBoxLayout()
        gbvbhb = QtGui.QHBoxLayout()
        btn = QtGui.QPushButton('get state')
        btn.clicked.connect(self.gui_get_state)
        gbvbhb.addWidget(btn)
        self.gui_get_state_online_cb = QtGui.QCheckBox('online', self, checkable=True, checked=False)
        self.gui_get_state_online_cb.clicked.connect(self.gui_get_state_online_cb_clicked)
        gbvbhb.addWidget(self.gui_get_state_online_cb)
        
        
        
        gbvb.addLayout(gbvbhb)
        
        gbvbhb = QtGui.QHBoxLayout()
        self.gui_info_state1 = QtGui.QLabel('state', self)
        self.gui_info_state2 = QtGui.QLabel('state', self)
        self.gui_info_mcs_x = QtGui.QLabel('MCS x', self)
        self.gui_info_mcs_y = QtGui.QLabel('MCS y', self)
        self.gui_info_wcs_x = QtGui.QLabel('WCS x', self)
        self.gui_info_wcs_y = QtGui.QLabel('WCS y', self)        
        
        gbvb.addWidget(self.gui_info_state1)
        gbvb.addWidget(self.gui_info_state2)
        
        gbvbhb = QtGui.QHBoxLayout()
        gbvbhb.addWidget(self.gui_info_mcs_x)
        gbvbhb.addWidget(self.gui_info_mcs_y)
        # gbvb.addLayout(gbvbhb)
        
        #gbvbhb = QtGui.QHBoxLayout()
        gbvbhb.addWidget(self.gui_info_wcs_x)
        gbvbhb.addWidget(self.gui_info_wcs_y)
        gbvb.addLayout(gbvbhb)

        gbvb.addLayout(gbvbhb)
        
        gb.setLayout(gbvb)
        vbcontrols.addWidget(gb)
        
        

        

        gb = QtGui.QGroupBox('jogging controls:')
        gbvb = QtGui.QVBoxLayout()
        
        gbvbhb = QtGui.QHBoxLayout()
        #btn = QtGui.QPushButton('1')
        #btn.clicked.connect(self.unlock)
        #gbvbhb.addWidget(btn)
        self.gui_jog_stepsize = Spinner('jog step size (mm):', 1, step=1, guic=gbvbhb)
        self.gui_jog_feedrate = Spinner('feed rate (mm/min):', 5000, step=100, guic=gbvbhb)
        gbvb.addLayout(gbvbhb)

        horizontalGroupBox = QtGui.QGroupBox("")
        layout = QtGui.QGridLayout()
        layout.setColumnStretch(0, 1)
        layout.setColumnStretch(1, 1)
        layout.setColumnStretch(2, 1)
        
        def set_jogfun(what):
            def fun():
                self.jog(what)
            return fun
        
        
        #d = {'what': '-x +y', 'n': 0, 'm': 0}
        
        def makebutton(d):
            btn = QtGui.QPushButton(d['what'])
            btn.clicked.connect(set_jogfun(d['what']))
            layout.addWidget(btn,d['n'],d['m'])
            
        makebutton({'what': '-x +y', 'n': 0, 'm': 0})   
        makebutton({'what': '+y',    'n': 0, 'm': 1})   
        makebutton({'what': '+x +y', 'n': 0, 'm': 2})   

        makebutton({'what': '-x',    'n': 1, 'm': 0})   
        # makebutton({'what': '',      'n': 1, 'm': 1})   
        makebutton({'what': '+x',    'n': 1, 'm': 2})   

        makebutton({'what': '-x -y', 'n': 2, 'm': 0})   
        makebutton({'what': '-y',    'n': 2, 'm': 1})   
        makebutton({'what': '+x -y', 'n': 2, 'm': 2})        
        
        horizontalGroupBox.setLayout(layout)
        gbvb.addWidget(horizontalGroupBox)
        
        gb.setLayout(gbvb)
        vbcontrols.addWidget(gb)
        
        
        gb = QtGui.QGroupBox('absolute positioning:')
        gbvb = QtGui.QVBoxLayout()
        
        
        
        gbvbhb = QtGui.QHBoxLayout()
        self.gui_g1_xpos_mm = Spinner('x (mm):', 0, step=1, guic=gbvbhb)
        self.gui_g1_ypos_mm = Spinner('y (mm):', 0, step=1, guic=gbvbhb)
        gbvb.addLayout(gbvbhb)
        self.gui_g1_feedrate = Spinner('feed rate (mm/min):', 5000, step=100, guic=gbvb)
        
        gbvbhb = QtGui.QHBoxLayout()
        btn = QtGui.QPushButton('G0 GO')
        btn.clicked.connect(self.g0_go_to_position)
        gbvbhb.addWidget(btn)
        btn = QtGui.QPushButton('G1 GO')
        btn.clicked.connect(self.g1_go_to_position)
        gbvbhb.addWidget(btn)
        gbvb.addLayout(gbvbhb)
        
        gb.setLayout(gbvb)
        vbcontrols.addWidget(gb)
        
        
        gb = QtGui.QGroupBox('spindle control:')
        gbvb = QtGui.QVBoxLayout()
        
        gbvbhb = QtGui.QHBoxLayout()
        self.gui_spindlespeed = Spinner('spindle / servo:', 600, step=50, bounds=[0, 1000], guic=gbvbhb, fun=self.set_spindle_speed)
        
        self.gui_spindle_enable_cb = QtGui.QCheckBox('Spindle', self, checkable=True, checked=False)
        self.gui_spindle_enable_cb.clicked.connect(self.gui_spindle_enable_cb_clicked)
        gbvbhb.addWidget(self.gui_spindle_enable_cb)
        
        #btn = QtGui.QPushButton('ON')
        #btn.clicked.connect(self.set_spindle_on)
        #gbvbhb.addWidget(btn)
        #btn = QtGui.QPushButton('OFF')
        #btn.clicked.connect(self.set_spindle_off)
        #gbvbhb.addWidget(btn)
        
        gbvb.addLayout(gbvbhb)
        gb.setLayout(gbvb)
        vbcontrols.addWidget(gb)
        
        
        
        gb = QtGui.QGroupBox('G-code streaming:')
        gbvb = QtGui.QVBoxLayout()
        
        gbvbhb = QtGui.QHBoxLayout()
        l = QtGui.QLabel('file:')
        gbvbhb.addWidget(l)
        self.gcodefile_text = QtGui.QTextEdit(os.path.join(os.path.expanduser('~'), 'test.gcode'))
        self.gcodefile_text.setMinimumWidth(150)
        self.gcodefile_text.setMaximumHeight(30)
        gbvbhb.addWidget(self.gcodefile_text)
        btn = QtGui.QPushButton('...')
        btn.clicked.connect(self._browse_gcodefile)
        gbvbhb.addWidget(btn)
        btn = QtGui.QPushButton('load')
        btn.clicked.connect(self.gcode_load_file)
        gbvbhb.addWidget(btn)
        gbvb.addLayout(gbvbhb)
        
        gbvbhb = QtGui.QHBoxLayout()
        self.gcode_stream_progressbar = QtGui.QProgressBar(self)
        gbvbhb.addWidget(self.gcode_stream_progressbar)
        
        
        btn = QtGui.QPushButton('start streaming')
        btn.clicked.connect(self.gcode_stream_start)
        gbvbhb.addWidget(btn)
        btn = QtGui.QPushButton('stop streaming')
        btn.clicked.connect(self.gcode_stream_stop)
        gbvbhb.addWidget(btn)
        gbvb.addLayout(gbvbhb)
        
        self.gui_eta_info = QtGui.QLabel('--- streaming ETA info ---', self)
        gbvb.addWidget(self.gui_eta_info)
        
        gbvb.addLayout(gbvbhb)
        gb.setLayout(gbvb)
        vbcontrols.addWidget(gb)
        
        gb = QtGui.QGroupBox('')
        gbhb = QtGui.QHBoxLayout()
        
        btn = QtGui.QPushButton('FEED HOLD')
        btn.clicked.connect(self.feed_hold)
        btn.setMinimumHeight(60)
        gbhb.addWidget(btn)
        btn = QtGui.QPushButton('RESUME')
        btn.clicked.connect(self.feed_resume)
        btn.setMinimumHeight(60)
        gbhb.addWidget(btn)
        
        gb.setLayout(gbhb)
        vbcontrols.addWidget(gb)
        
        
        
        hbmain.addLayout(vbcontrols)
        hbmain.setStretch(0,2)
        hbmain.setStretch(1,1)
        hbmain.setStretch(2,1)
        
        self.setLayout(hbmain)
        self.setGeometry(20, 40, 1400, 900)
        self.setWindowTitle('Vplotter Controller')
        self.setStyleSheet("font-size: 12pt")
        self.show()
        self.scan()
        
        self.get_state_timer = QtCore.QTimer()
        self.get_state_timer.timeout.connect(self.gui_get_state)
        self.serial_active = False
        self.gcode_stream_running = False
Exemplo n.º 15
0
 def init_ui(self):
     self.select_dir_cb = QtGui.QCheckBox('Select directory')
     self.select_dir_cb.stateChanged.connect(self.toggle_files_folders)
     self.layout().addWidget(self.select_dir_cb)