async def issueCommandKillBumpTest(self):
     """Kill bump test."""
     self.actuatorsTable.setRangeSelected(
         QTableWidgetSelectionRange(0, 0, self.actuatorsTable.rowCount() - 1, 11),
         False,
     )
     await self.m1m3.remote.cmd_killForceActuatorBumpTest.start()
Ejemplo n.º 2
0
 def rows_paste(self, where_to, rows_gen, up):
     ii, n = 0, 0
     col_origin = self.currentColumn()
     for row in rows_gen:
         self.insertRow(where_to + ii)
         n += 1
         for c in range(len(row)):
             self.setItem(where_to + ii, c, QTableWidgetItem(row[c]))
         ii -= 0 if up else 1
     # current & selection
     if up:
         rng = QTableWidgetSelectionRange(where_to, 0, where_to + n - 1,
                                          self.columnCount() - 1)
     else:
         where_to -= 1
         rng = QTableWidgetSelectionRange(where_to - n + 1, 0, where_to,
                                          self.columnCount() - 1)
     self.setCurrentCell(where_to, col_origin)
     self.setRangeSelected(rng, True)
 async def bumpTestAll(self):
     for i in range(4):
         colOffset = i * 3
         self.actuatorsTable.setRangeSelected(
             QTableWidgetSelectionRange(
                 0,
                 1 + colOffset,
                 self.actuatorsTable.rowCount() - 1,
                 2 + colOffset,
             ),
             False,
         )
         self.actuatorsTable.setRangeSelected(
             QTableWidgetSelectionRange(
                 0, colOffset, self.actuatorsTable.rowCount() - 1, colOffset
             ),
             True,
         )
     await self._testItem(self.actuatorsTable.selectedItems()[0])
     self.bumpTestButton.setEnabled(False)
Ejemplo n.º 4
0
    def _move_patch_bank(self, src, dest):
        """ Attempts to move a patch from one bank slot to another
        Currently triggered via a QTableWidget move event.

        src: The index the item originated from.
        dest: The index the item is being moved to.
        """

        self.ui.table_bank_left.clearSelection()
        self.ui.table_bank_right.clearSelection()

        swap = False

        if dest > 63:
            dest -= 64

        # Setup the new item.
        try:
            if src < 32:
                idx = self.ui.table_bank_left.cellWidget(src, 1).objectName()
            else:
                idx = self.ui.table_bank_right.cellWidget(src - 32,
                                                          1).objectName()
        except AttributeError:
            # Got two empty rows, ignore them.
            return

        for pch in self.data_banks:
            if dest == pch["slot"]:
                # We are doing a swap.
                swap = True
                break
        if swap:
            # Get the other item.
            if dest < 32:
                idx_dest = self.ui.table_bank_left.cellWidget(dest,
                                                              1).objectName()
            else:
                idx_dest = self.ui.table_bank_right.cellWidget(dest - 32,
                                                               1).objectName()

            # Get the old values out.
            for pch in self.data_banks:
                if pch["slot"] == src or pch["slot"] == dest:
                    self.data_banks.remove(pch)

            # Add the new values in.
            self.data_banks.append({"slot": dest, "id": idx})
            self.data_banks.append({"slot": src, "id": idx_dest})
        else:
            # We are doing a move.
            self.data_banks.append({"slot": dest, "id": idx})

            # Remove the source copy of the patch.
            for pch in self.data_banks:
                if pch["slot"] == src:
                    self.data_banks.remove(pch)
                    break

        # Set the data.
        self._set_data_bank()

        for i in range(64):
            if i == dest:
                if i > 31:
                    self.ui.table_bank_right.setRangeSelected(
                        QTableWidgetSelectionRange(i, 0, i, 0), True)
                else:
                    self.ui.table_bank_left.setRangeSelected(
                        QTableWidgetSelectionRange(i, 0, i, 0), True)

        # Reload the data in the tables.
        self._get_bank_data()
        self.ui.btn_save_bank.setEnabled(len(self.data_banks) > 0)
        self.ui.btn_export_bank.setEnabled(len(self.data_banks) > 0)
        self.ui.btn_clear_bank.setEnabled(len(self.data_banks) > 0)
Ejemplo n.º 5
0
    def _move_patch_sd(self, src, dest):
        """Attempts to move a patch from one SD card slot to another
        Currently triggered via a QTableWidget move event.

        src: The index the item originated from.
        dest: The index the item is being moved to.
        """

        self.ui.table_sd_left.clearSelection()
        self.ui.table_sd_right.clearSelection()

        if dest > 63:
            dest -= 64

        # We need to find out if we are just doing a simple move or a swap.
        if dest < 10:
            dest = str("00{}".format(dest))
        else:
            dest = str("0{}".format(dest))
        if src < 10:
            src = str("00{}".format(src))
        else:
            src = str("0{}".format(src))
        src_pch = None
        dest_pch = None
        for pch in os.listdir(self.sd_path_full):
            if pch[:3] == src:
                src_pch = pch
            if pch[:3] == dest:
                dest_pch = pch
            if src_pch is not None and dest_pch is not None:
                # We are doing a swap.
                try:
                    os.rename(
                        os.path.join(self.sd_path_full, src_pch),
                        os.path.join(self.sd_path_full, dest + src_pch[3:]),
                    )
                    os.rename(
                        os.path.join(self.sd_path_full, dest_pch),
                        os.path.join(self.sd_path_full, src + dest_pch[3:]),
                    )
                except FileExistsError:
                    # Swapping files that are named the same thing.
                    os.rename(
                        os.path.join(self.sd_path_full, src_pch),
                        os.path.join(self.sd_path_full, "064" + src_pch[3:]),
                    )
                    # Swapping files that are named the same thing.
                    os.rename(
                        os.path.join(self.sd_path_full, dest_pch),
                        os.path.join(self.sd_path_full, src + dest_pch[3:]),
                    )
                    os.rename(
                        os.path.join(self.sd_path_full, "064" + src_pch[3:]),
                        os.path.join(self.sd_path_full, dest + src_pch[3:]),
                    )
                self._set_data_sd()
                dest = int(dest)
                for i in range(64):
                    if i == dest:
                        if i > 31:
                            self.ui.table_sd_right.setRangeSelected(
                                QTableWidgetSelectionRange(i, 0, i, 0), True)
                        else:
                            self.ui.table_sd_left.setRangeSelected(
                                QTableWidgetSelectionRange(i, 0, i, 0), True)
                return

        # We are doing a move.
        if src_pch is None:
            self._set_data_sd()
            return
        os.rename(
            os.path.join(self.sd_path_full, src_pch),
            os.path.join(self.sd_path_full, dest + src_pch[3:]),
        )

        # Clear the selections and reload the tables.
        dest = int(dest)
        for i in range(64):
            if i == dest:
                if i > 31:
                    self.ui.table_sd_right.setRangeSelected(
                        QTableWidgetSelectionRange(i, 0, i, 0), True)
                else:
                    self.ui.table_sd_left.setRangeSelected(
                        QTableWidgetSelectionRange(i, 0, i, 0), True)

        self._set_data_sd()