Ejemplo n.º 1
0
    def __init__(self, parent=None):
        super(ModeListSaveBlock, self).__init__(parent)

        self.grid.addWidget(QtWidgets.QLabel("Comment:"), 0, 0)
        self.grid.addWidget(QtWidgets.QLabel("author:"), 1, 0)

        self.comment_line = QtWidgets.QLineEdit()
        self.grid.addWidget(self.comment_line, 0, 1)

        self.author_line = QtWidgets.QLineEdit()
        self.grid.addWidget(self.author_line, 1, 1)

        self.btn_save = QtWidgets.QPushButton('save')
        self.grid.addWidget(self.btn_save, 0, 2, 2, 1)
        self.btn_save.clicked.connect(self.save_cb)
Ejemplo n.º 2
0
    def __init__(self, parent=None):
        super(PresetMgrW, self).__init__(parent)

        self.preset_names = ['p0', 'p1', 'p2', 'p3']
        self.preset_bs = [
            QtWidgets.QPushButton('-->' + x) for x in self.preset_names
        ]
        for ind in range(len(self.preset_bs)):
            self.grid.addWidget(self.preset_bs[ind], ind, 0)
            self.preset_bs[ind].clicked.connect(self.bs_proc)

        self.mgr = KickersPresetMgr()
Ejemplo n.º 3
0
    def __init__(self, parent=None, **kwargs):
        super(TrainingCtlW, self).__init__(parent)

        self.setContentsMargins(0, 0, 0, 0)
        self.grid = QtWidgets.QGridLayout()
        self.grid.setContentsMargins(0, 0, 0, 0)
        self.grid.setSpacing(0)
        self.setLayout(self.grid)

        self.grid.addWidget(QtWidgets.QLabel("Training shots control"), 0, 0,
                            1, 4, QtCore.Qt.AlignHCenter)

        self.grid.addWidget(QtWidgets.QLabel("Interval,s"), 1, 0)

        self.sb_interval = CXSpinBox(cname='cxhw:0.ddm.extr_train_interval')
        self.grid.addWidget(self.sb_interval, 1, 1)

        self.grid.addWidget(QtWidgets.QLabel("run"), 1, 2)

        self.cb_run = CXCheckBox(cname='cxhw:0.ddm.extr_train')
        self.grid.addWidget(self.cb_run, 1, 3)
Ejemplo n.º 4
0
    def __init__(self, parent=None):
        super(ExtractorWidget, self).__init__(parent)
        self.setContentsMargins(0, 0, 0, 0)
        self.grid = QtWidgets.QGridLayout()
        self.grid.setContentsMargins(0, 0, 0, 0)
        self.grid.setSpacing(0)
        self.setLayout(self.grid)

        self.b_start = QtWidgets.QPushButton('start')
        self.grid.addWidget(self.b_start, 0, 0)

        self.b_stop = QtWidgets.QPushButton('stop')
        self.grid.addWidget(self.b_stop, 0, 1)

        self.b_start.clicked.connect(self.extract)
        self.b_stop.clicked.connect(extr.stop)

        extr.unexpectedShot.connect(self.unexpected_shot_proc)
        extr.extractionDone.connect(self.extr_proc)

        self.st_time = 0
        self.fi_time = 0
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        super(LinstarterWidget, self).__init__(parent)
        self.setContentsMargins(0, 0, 0, 0)
        self.grid = QtWidgets.QGridLayout()
        self.grid.setContentsMargins(0, 0, 0, 0)
        self.grid.setSpacing(0)
        self.setLayout(self.grid)

        self.b_start = QtWidgets.QPushButton('start')
        self.grid.addWidget(self.b_start, 0, 0)

        self.b_stop = QtWidgets.QPushButton('stop')
        self.grid.addWidget(self.b_stop, 0, 1)

        self.lin_st = linstarter.LinStarter()
        self.b_start.clicked.connect(self.run_counter)
        self.b_stop.clicked.connect(self.lin_st.stop)

        self.lin_st.runmodeChanged.connect(print)
        self.lin_st.nshotsChanged.connect(print)
        self.lin_st.runDone.connect(self.rundone_proc)

        self.st_time = 0
        self.fi_time = 0
Ejemplo n.º 6
0
    def __init__(self, parent=None):
        super(TrainingCtlW, self).__init__(parent)
        self.setContentsMargins(0, 0, 0, 0)
        self.grid = QtWidgets.QGridLayout()
        self.grid.setContentsMargins(0, 0, 0, 0)
        self.grid.setSpacing(0)
        self.setLayout(self.grid)

        self.grid.addWidget(QtWidgets.QLabel("Training shots control"), 0, 0,
                            1, 4)

        self.grid.addWidget(QtWidgets.QLabel("Interval,s"), 1, 0)

        self.sb_interval = FSpinBox()
        self.grid.addWidget(self.sb_interval, 1, 1)

        self.grid.addWidget(QtWidgets.QLabel("run"), 1, 2)

        self.cb_run = FCheckBox()
        self.grid.addWidget(self.cb_run, 1, 3)

        self.cb_run.stateChanged.connect(self.run_proc)

        extr.trainingStopped.connect(self.training_stopped_proc)
Ejemplo n.º 7
0
    def update_modelist(self, **kwargs):
        self.updating_list = True
        limit = kwargs.get('limit', 100)
        offset = kwargs.get('offset', 0)
        update_marked = kwargs.get('update_marked', False)
        filter = kwargs.get('filter', None)
        load_archived = kwargs.get('load_archived', False)

        if update_marked:
            self.marked_modes = [list(x) for x in self.modes_db.marked_modes([1, 2, 3, 4, 5, 6, 7, 8])]

        self.modes = [list(x) for x in self.modes_db.mode_list(limit, offset, filter, load_archived)]

        self.all_modes = self.marked_modes + self.modes
        m_num = len(self.all_modes)
        cr_num = self.rowCount()
        if m_num > cr_num:
            self.setRowCount(m_num)
            for ind in range(cr_num, m_num):
                for rind in range(len(self.all_modes[0])):
                    self.setItem(ind, rind, QtWidgets.QTableWidgetItem())
        elif m_num < cr_num:
            self.setRowCount(m_num)

        start_ind = 8
        if update_marked:
            start_ind = 0

        for ind in range(start_ind, m_num):
            row = self.all_modes[ind]
            for rind in range(1, len(row)):
                if rind == 3:
                    rtext = row[rind].strftime("%Y-%m-%d %H:%M:%S")
                else:
                    rtext = row[rind]
                item = self.item(ind, rind-1)
                item.setText(rtext)
                if rind == 4:
                    item.setBackground(mode_dqcolors.get(rtext, def_qcolor))
                if rind == 5:
                    item.setBackground(mode_qcolors.get(rtext, def_qcolor))
        self.resizeRowsToContents()
        self.mode_unselect()
        self.updating_list = False
Ejemplo n.º 8
0
    def __init__(self, parent=None):
        super(SaverWidget, self).__init__(parent)
        self.modes_db = ModesDB()

        self.flist = ModeListCtrl()
        self.flist.setFixedSize(900, 800)
        self.grid.addWidget(self.flist, 0, 0, 2, 1)

        self.stree = SysTree()
        self.grid.addWidget(self.stree, 0, 1)
        self.stree.selectionChanged.connect(self.sys_cb)

        self.kindt = KindTable()
        self.kindt.setFixedSize(350, 160)
        self.grid.addWidget(self.kindt, 1, 1)
        self.kindt.selectionChanged.connect(self.kinds_cb)

        self.status_text = QtWidgets.QPlainTextEdit()
        self.status_text.setFixedHeight(40)
        self.status_text.setReadOnly(True)
        self.status_text.setCenterOnScroll(True)
        self.grid.addWidget(self.status_text, 2, 0, 1, 2)

        self.selected_kinds = self.kindt.selected()
        self.selected_sys = []

        self.mode_cli = ModesClient()
        self.mode_cli.modeSaved.connect(self.mode_saved)
        self.mode_cli.modeLoaded.connect(self.mode_loaded)
        self.mode_cli.update.connect(self.update_db)

        self.flist.markMode.connect(self.mode_cli.mark_mode)
        self.flist.archiveMode.connect(self.archive_mode)
        self.flist.loadMode.connect(self.load_mode)
        self.flist.saveMode.connect(self.save)
        self.flist.setZeros.connect(self.set_zeros)
        self.flist.outMsg.connect(self.print_msg)

        self.flist.listw.modeUpdated.connect(self.mode_cli.ask_update)
Ejemplo n.º 9
0
    def __init__(self, parent=None):
        super(ModeListFilter, self).__init__(parent)

        self.grid.addWidget(QtWidgets.QLabel("search"), 0, 0)

        self.filter_line = QtWidgets.QLineEdit()
        self.grid.addWidget(self.filter_line, 0, 1, 1, 6)
        self.filter_line.editingFinished.connect(self.filter_cb)

        self.prev_b = QtWidgets.QPushButton("<<")
        self.grid.addWidget(self.prev_b, 1, 0)
        self.prev_b.clicked.connect(self.prev_cb)

        self.nrows_box = PSpinBox()
        self.grid.addWidget(self.nrows_box, 1, 1)
        self.nrows_box.done.connect(self.nrows_cb)

        self.grid.addWidget(QtWidgets.QLabel("@"), 1, 2)

        self.startrow_box = PSpinBox()
        self.grid.addWidget(self.startrow_box, 1, 3)
        self.startrow_box.done.connect(self.startrow_cb)

        self.grid.addWidget(QtWidgets.QLabel("of"), 1, 4)

        self.maxrows_box = PSpinBox()
        self.grid.addWidget(self.maxrows_box, 1, 5)
        self.maxrows_box.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.maxrows_box.setReadOnly(True)

        self.next_b = QtWidgets.QPushButton(">>")
        self.grid.addWidget(self.next_b, 1, 6)
        self.next_b.clicked.connect(self.next_cb)

        self.nrows = 0
        self.maxrows = 0
        self.startrow = 0
        self.filter = ''
Ejemplo n.º 10
0
    def __init__(self, parent=None):
        super(ModeListBControls, self).__init__(parent)

        self.grid.addWidget(QtWidgets.QLabel("mark"), 0, 0, 2, 1)

        self.buttons = []
        self.marks = ['einj', 'eext', 'pinj', 'pext', 'e2v4', 'p2v4', 'e2v2', 'p2v2']
        m_len = len(self.marks)
        rlen = 4
        crow = 0
        for ind in range(m_len):
            if ind == rlen:
                crow += 1
            btn = QtWidgets.QPushButton(self.marks[ind])
            btn.setStyleSheet("background-color: " + mode_colors[self.marks[ind]])
            btn.setFixedWidth(100)
            self.grid.addWidget(btn, crow, ind - crow * rlen + 1)
            self.buttons.append(btn)
            btn.clicked.connect(self.buttons_cb)

        hSpacer = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.grid.addItem(hSpacer, 0, rlen + 2)

        self.btn_archive = QtWidgets.QPushButton('Archive')
        self.grid.addWidget(self.btn_archive, 0, rlen + 3)
        self.btn_archive.setStyleSheet("background-color: red")
        self.btn_archive.setFixedWidth(110)
        self.btn_archive.clicked.connect(self.archive)

        self.btn_load = QtWidgets.QPushButton('Load')
        self.grid.addWidget(self.btn_load, 0, rlen + 4)
        self.btn_load.setFixedWidth(110)
        self.btn_load.clicked.connect(self.load)

        self.btn_zeros = QtWidgets.QPushButton('Zeros')
        self.grid.addWidget(self.btn_zeros, 1, rlen + 3)
        self.btn_zeros.setStyleSheet("background-color: yellow")
Ejemplo n.º 11
0
from cxwidgets.auxwidgets import BaseGridW
from preset_mgr import KickersPresetMgr


class PresetMgrW(BaseGridW):
    def __init__(self, parent=None):
        super(PresetMgrW, self).__init__(parent)

        self.preset_names = ['p0', 'p1', 'p2', 'p3']
        self.preset_bs = [
            QtWidgets.QPushButton('-->' + x) for x in self.preset_names
        ]
        for ind in range(len(self.preset_bs)):
            self.grid.addWidget(self.preset_bs[ind], ind, 0)
            self.preset_bs[ind].clicked.connect(self.bs_proc)

        self.mgr = KickersPresetMgr()

    def bs_proc(self):
        ind = self.preset_bs.index(self.sender())
        self.mgr.copy(src='hw', dst=self.preset_names[ind])


app = QtWidgets.QApplication(['preset manager'])

w = PresetMgrW()
w.show()

app.exec_()
Ejemplo n.º 12
0
    def mode_saved(self, dict_msg):
        self.flist.update_modenum()
        self.flist.update_modelist()
        self.print_msg("mode saved", dict_msg['time'])

    def update_db(self):
        self.flist.update_modenum()
        self.flist.update_modelist(update_marked=True)

    def set_zeros(self):
        self.mode_cli.set_zeros(self.selected_sys, self.selected_kinds)

    def print_msg(self, msg, srv_time=None):
        if srv_time is None:
            msg_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        else:
            msg_time = time.strftime("%Y-%m-%d %H:%M:%S",
                                     time.localtime(srv_time / 1e6))
        self.status_text.appendPlainText(msg_time + ": " + msg)
        self.status_text.ensureCursorVisible()


app = QtWidgets.QApplication(['saver'])

w = SaverWidget()
w.show()
w.setFixedSize(w.size())
w.flist.update_modelist()

app.exec_()
Ejemplo n.º 13
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.modes_db = ModesDB()

        #filter controls
        self.grid_filter = QtWidgets.QGridLayout()
        self.grid.addLayout(self.grid_filter, 0, 0, 1, 1)

        self.grid_filter.addWidget(QtWidgets.QLabel("search"), 0, 0)

        self.filter_line = QtWidgets.QLineEdit()
        self.grid_filter.addWidget(self.filter_line, 0, 1, 1, 6)
        self.filter_line.editingFinished.connect(self.filter_cb)

        self.prev_b = QtWidgets.QPushButton("<<")
        self.grid_filter.addWidget(self.prev_b, 1, 0)
        self.prev_b.clicked.connect(self.prev_cb)

        self.nrows_box = PSpinBox()
        self.grid_filter.addWidget(self.nrows_box, 1, 1)
        self.nrows_box.done.connect(self.nrows_cb)

        self.grid_filter.addWidget(QtWidgets.QLabel("@"), 1, 2)

        self.startrow_box = PSpinBox()
        self.grid_filter.addWidget(self.startrow_box, 1, 3)
        self.startrow_box.done.connect(self.startrow_cb)

        self.grid_filter.addWidget(QtWidgets.QLabel("of"), 1, 4)

        self.maxrows_box = PSpinBox()
        self.grid_filter.addWidget(self.maxrows_box, 1, 5)
        self.maxrows_box.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.maxrows_box.setReadOnly(True)

        self.next_b = QtWidgets.QPushButton(">>")
        self.grid_filter.addWidget(self.next_b, 1, 6)
        self.next_b.clicked.connect(self.next_cb)

        # List
        self.listw = ModeList(db=self.modes_db)
        self.grid.addWidget(self.listw, 1, 0)
        self.listw.modeSelected.connect(self.mode_sel_cb)

        # Bottom controls
        self.grid_bottom = QtWidgets.QGridLayout()
        self.grid.addLayout(self.grid_bottom, 2, 0, 1, 1)

        self.grid_bottom.addWidget(QtWidgets.QLabel("mark"), 0, 0, 2, 1)

        self.buttons = []
        self.marks = ['einj', 'eext', 'pinj', 'pext', 'e2v4', 'p2v4', 'e2v2', 'p2v2']
        m_len = len(self.marks)
        rlen = 4
        crow = 0
        for ind in range(m_len):
            if ind == rlen:
                crow += 1
            btn = QtWidgets.QPushButton(self.marks[ind])
            btn.setStyleSheet("background-color: " + mode_colors[self.marks[ind]])
            btn.setFixedWidth(100)
            self.grid_bottom.addWidget(btn, crow, ind - crow * rlen + 1)
            self.buttons.append(btn)
            btn.clicked.connect(self.mark_buttons_cb)

        hSpacer = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.grid_bottom.addItem(hSpacer, 0, rlen + 2)

        self.btn_archive = QtWidgets.QPushButton('Archive')
        self.grid_bottom.addWidget(self.btn_archive, 0, rlen + 3)
        self.btn_archive.setStyleSheet("background-color: red")
        self.btn_archive.setFixedWidth(110)
        self.btn_archive.clicked.connect(self.btn_archive_cb)

        self.btn_load = QtWidgets.QPushButton('Load')
        self.grid_bottom.addWidget(self.btn_load, 0, rlen + 4)
        self.btn_load.setFixedWidth(110)
        self.btn_load.clicked.connect(self.btn_load_cb)

        self.btn_zeros = QtWidgets.QPushButton('Zeros')
        self.grid_bottom.addWidget(self.btn_zeros, 1, rlen + 3)
        self.btn_zeros.setStyleSheet("background-color: yellow")
        self.btn_zeros.clicked.connect(self.setZeros)

        # Save Block
        self.grid_save = QtWidgets.QGridLayout()
        self.grid.addLayout(self.grid_save, 3, 0, 1, 1)

        self.grid_save.addWidget(QtWidgets.QLabel("Comment:"), 0, 0)
        self.grid_save.addWidget(QtWidgets.QLabel("author:"), 1, 0)

        self.comment_line = QtWidgets.QLineEdit()
        self.grid_save.addWidget(self.comment_line, 0, 1)

        self.author_line = QtWidgets.QLineEdit()
        self.grid_save.addWidget(self.author_line, 1, 1)

        self.btn_save = QtWidgets.QPushButton('save')
        self.grid_save.addWidget(self.btn_save, 0, 2, 2, 1)
        self.btn_save.clicked.connect(self.btn_save_cb)

        self.nrows, self.maxrows, self.startrow, self.filter = 100, 0, 0, None
        self.update_modenum()
        self.nrows_box.setValue(self.nrows)

        self.selected_mode = None
Ejemplo n.º 14
0
            self.outMsg.emit('no mode selected')
            return
        self.loadMode.emit(self.selected_mode)

    def btn_save_cb(self):
        comment = str2u(self.comment_line.text())
        if len(comment) == 0:
            self.outMsg.emit('no comment - no save')
            return
        author = str2u(self.author_line.text())
        if len(author) == 0:
            self.outMsg.emit('save: it isn`t polite to operate machine anonymously')
            return
        self.saveMode.emit(author, comment)


if __name__ == '__main__':
    app = QtWidgets.QApplication(['mode list test'])

    w3 = ModeListCtrl()
    w3.resize(900, 800)
    w3.show()
    w3.markMode.connect(print)
    w3.archiveMode.connect(print)
    w3.loadMode.connect(print)
    w3.saveMode.connect(print)
    w3.setZeros.connect(print)
    w3.outMsg.connect(print)

    app.exec_()
Ejemplo n.º 15
0
        self.b_stop = QtWidgets.QPushButton('stop')
        self.grid.addWidget(self.b_stop, 0, 1)

        self.lin_st = linstarter.LinStarter()
        self.b_start.clicked.connect(self.run_counter)
        self.b_stop.clicked.connect(self.lin_st.stop)

        self.lin_st.runmodeChanged.connect(print)
        self.lin_st.nshotsChanged.connect(print)
        self.lin_st.runDone.connect(self.rundone_proc)

        self.st_time = 0
        self.fi_time = 0

    def rundone_proc(self):
        self.fi_time = time.time()
        print('run time:', self.fi_time - self.st_time)
        self.run_counter()

    def run_counter(self):
        self.st_time = time.time()
        self.lin_st.start()


app = QtWidgets.QApplication(['linstarter test'])

w = LinstarterWidget()
w.show()

app.exec_()
Ejemplo n.º 16
0
        extr.unexpectedShot.connect(self.unexpected_shot_proc)
        extr.extractionDone.connect(self.extr_proc)

        self.st_time = 0
        self.fi_time = 0

    def extr_proc(self):
        self.fi_time = time.time()
        print('run time:', self.fi_time - self.st_time)
        self.extract()

    def unexpected_shot_proc(self):
        print("unexpected shot")

    def extract(self):
        self.st_time = time.time()
        extr.extract()


app = QtWidgets.QApplication(['extractor_test'])

extr = extractor.Extractor()

w = ExtractorWidget()
w.show()

w2 = TrainingCtlW()
w2.show()

app.exec_()