Exemplo n.º 1
0
class SpsWidget(QWidget):
    def __init__(self, spsGUI):
        QWidget.__init__(self)
        self.spsGUI = spsGUI
        self.tronLayout = TronLayout()
        self.mainLayout = GridLayout()
        self.mainLayout.setSpacing(1)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)

        self.mainLayout.addLayout(self.tronLayout, 0, 0)
        self.mainLayout.addWidget(Aitmodule(self), 1, 0)

        for smId in range(1, 12):
            if 'sm%d' % smId not in self.actor.config.sections():
                continue

            arms = [
                arm.strip()
                for arm in self.actor.config.get('sm%d' %
                                                 smId, 'arms').split(',')
                if arm
            ]
            enu = self.actor.config.getboolean('sm%d' % smId, 'enu')
            self.mainLayout.addWidget(
                Specmodule(self, smId=smId, enu=enu, arms=arms), smId + 1, 0)

        self.setLayout(self.mainLayout)

    @property
    def actor(self):
        return self.spsGUI.actor

    @property
    def isConnected(self):
        return self.spsGUI.isConnected

    def sendCommand(self, actor, cmdStr, callFunc):
        import opscore.actor.keyvar as keyvar
        self.actor.cmdr.bgCall(**dict(actor=actor,
                                      cmdStr=cmdStr,
                                      timeLim=1600,
                                      callFunc=callFunc,
                                      callCodes=keyvar.AllCodes))

    def heartBeat(self):
        self.tronLayout.tronStatus.dial.heartBeat()

    def showError(self, title, error):
        reply = QMessageBox.critical(self, title, error, QMessageBox.Ok)

    def setEnabled(self, a0: bool) -> None:
        widgets = [
            self.mainLayout.itemAt(i).widget()
            for i in range(self.mainLayout.count())
        ]

        for widget in widgets:
            widget.setEnabled(a0)
Exemplo n.º 2
0
class ControlPanel(QWidget):
    def __init__(self, controlDialog):
        QWidget.__init__(self)
        self.controlDialog = controlDialog
        self.grid = GridLayout()
        self.grid.setContentsMargins(*(4 * (1, )))
        self.grid.setSizeConstraint(QLayout.SetMinimumSize)
        self.setLayout(self.grid)

        self.createWidgets()
        self.setInLayout()
        self.setEnabled(False)

    @property
    def moduleRow(self):
        return self.controlDialog.moduleRow

    @property
    def actorName(self):
        return self.controlDialog.moduleRow.actorName

    def createWidgets(self):
        pass

    def setInLayout(self):
        pass

    def addCommandSet(self, commands):
        self.commands = commands
        self.grid.addWidget(self.commands, 0, self.grid.columnCount(),
                            self.grid.rowCount(), self.grid.columnCount())
        self.spacer = QSpacerItem(0, 0, QSizePolicy.Minimum,
                                  QSizePolicy.MinimumExpanding)
        self.grid.addItem(self.spacer, self.grid.rowCount(), 0)

    def updateIcon(self, a0):
        icon = Icon('green.png') if a0 else Icon('orange.png')
        self.controlDialog.tabWidget.setTabIcon(
            self.controlDialog.tabWidget.indexOf(self), icon)
        self.controlDialog.tabWidget.setIconSize(
            QSize(styles.bigFont + 2, styles.bigFont + 2))

    def setEnabled(self, a0: bool):
        self.updateIcon(a0)
        for item in [self.grid.itemAt(i) for i in range(self.grid.count())]:
            if issubclass(type(item), QSpacerItem):
                continue
            elif issubclass(type(item), QLayout):
                item.setEnabled(a0)
            else:
                item.widget().setEnabled(a0)
Exemplo n.º 3
0
class CommandsGB(QGroupBox):
    def __init__(self, controlPanel, fontSize=styles.smallFont):
        QGroupBox.__init__(self)
        self.controlPanel = controlPanel
        self.grid = GridLayout()
        self.grid.setContentsMargins(1, 7, 1, 1)
        self.setTitle('Commands')
        self.setLayout(self.grid)
        self.setStyleSheet(
            "QGroupBox {font-size: %ipt; border: 1px solid #d7d4d1;border-radius: 3px;margin-top: 1ex;} "
            % (fontSize) +
            "QGroupBox::title {subcontrol-origin: margin;subcontrol-position: top center; padding: 0 3px;}"
        )

    def setEnabled(self, a0: bool):
        for item in [self.grid.itemAt(i) for i in range(self.grid.count())]:
            if (issubclass(type(item), QSpacerItem)):
                continue
            elif (issubclass(type(item), QLayout)):
                item.setEnabled(a0)
            else:
                item.widget().setEnabled(a0)