Example #1
0
 def _dorefresh(self):
     # request node state, and subscribe to it via the curried callback
     # the curry() is handy because it will automatically disconnect the
     # subscription when deleted
     self._callback = curry(self._update_state)
     self._node.subscribe_state(self._callback)
     meqds.request_node_state(self._node)
Example #2
0
    def _update_solverlist(self, node, state, event=None):

        names = {}
        for i in state.solvable['command_by_list']:
            if 'state' in i and i['state']['solvable'] and 'name' in i:
                nameslist = i['name']
        if isinstance(nameslist, str):
            names[nameslist] = 1
        else:
            for name in nameslist:
                names[name] = 1

        try:
            nodegroups = state.parm_group
        except AttributeError:
            return
        # get solver from dictionary
        if self._solverdict[node.name]['group'] == nodegroups:
            return
        else:
            self._solverdict[node.name]['group'] = nodegroups
            self._solverdict[node.name]['parms'] = names
            for parm in list(self._parmdict.keys()):
                parmnode = self._parmdict[parm]['node']
                # update parmtable if needed
                meqds.request_node_state(parmnode)
        self.putcheckboxes()
Example #3
0
 def _dorefresh(self):
     # request node state, and subscribe to it via the curried callback
     # the curry() is handy because it will automatically disconnect the
     # subscription when deleted
     self._callback = curry(self._update_state)
     self._node.subscribe_state(self._callback)
     meqds.request_node_state(self._node)
Example #4
0
    def _update_solverlist(self, node, state, event=None):

        names = {}
        for i in state.solvable["command_by_list"]:
            if i.has_key("state") and i["state"]["solvable"] and i.has_key("name"):
                nameslist = i["name"]
        if isinstance(nameslist, str):
            names[nameslist] = 1
        else:
            for name in nameslist:
                names[name] = 1

        try:
            nodegroups = state.parm_group
        except AttributeError:
            return
        # get solver from dictionary
        if self._solverdict[node.name]["group"] == nodegroups:
            return
        else:
            self._solverdict[node.name]["group"] = nodegroups
            self._solverdict[node.name]["parms"] = names
            for parm in self._parmdict.keys():
                parmnode = self._parmdict[parm]["node"]
                # update parmtable if needed
                meqds.request_node_state(parmnode)
        self.putcheckboxes()
Example #5
0
    def set_data(self, dataitem, **opts):
        request = getattr(dataitem.data, 'request', None)
        if self._request and request:
            self._request = request

        if not self._has_data:
            self._has_data = True
            state = dataitem.data
            if not request:
                QMessageBox.warning(
                    self.wtop(), "Warning",
                    "No request found in Node, Please specify request first via Reexecute"
                )
                self.enable_exec.setOn(False)
                self.enable_exec.setEnabled(False)
                self.buttonOk.setEnabled(False)
            else:
                #
                #     #print self._node;
                self.enable_exec.setOn(True)
                self.enable_exec.setEnabled(True)
                self.buttonOk.setEnabled(True)
                self._request = request

            self.unsubscribe_all()
            #parmlist is sorted by name.
            self._parmlist = []
            self._solverdict = {}
            self._parmdict = {}
            #all names off the nodes except parms
            self._nodedict = {}

            # recursively get all parms and solvers behind this node
            if self._node:
                self.getnodelist(meqds.nodelist[self._node])
            else:
                self.getnodelist(meqds.nodelist[self._name])
            #subscribe to solvers
            for solverkey in list(self._solverdict.keys()):
                solver = self._solverdict[solverkey]['node']
                # subscribe
                solver.subscribe_state(self._callbacksolver)
                meqds.request_node_state(solver)

            # fill listbox with MeqParm names
            self.parmtable.setNumCols(
                len(list(self._solverdict.keys())) + solverstart)
            self.parmtable.setNumRows(len(self._parmlist))
            self.parmtable.setReadOnly(True)
            self.parmtable.horizontalHeader().setLabel(0, "name")
            self.parmtable.horizontalHeader().setLabel(1, "c00")
            self.parmtable.horizontalHeader().setLabel(2, "shape")
            self.parmtable.horizontalHeader().setLabel(
                3, pixmaps.publish.iconset(), "")
            self.parmtable.horizontalHeader().setLabel(4, "0")
            self.parmtable.setColumnWidth(0, 100)
            self.parmtable.setColumnWidth(1, 200)
            self.parmtable.setColumnWidth(2, 60)
            self.parmtable.setColumnWidth(3, 25)
            self.parmtable.setColumnWidth(4, 25)
            #        self.parmtable.horizontalHeader () .setLabel(3,"i");
            tooltip = "click to sort"
            QToolTip.add(self.parmtable.horizontalHeader(), tooltip)
            QObject.connect(self.parmtable.horizontalHeader(),
                            SIGNAL("released(int)"), self.sortColumn)
            if self._currentparm:
                self._currentparm.reject()
                self._currentparm = None
            self._parmindex = -1

            self.updateTable()
            for parmkey in self._parmlist:
                parm = self._parmdict[parmkey]['node']
                parm.subscribe_state(self._callbackparm)
                meqds.request_node_state(parm)

            self.buttonReset.setEnabled(False)

            if not self._parmlist:
                QMessageBox.warning(self.wtop(), "Warning",
                                    "No parameters found")
                self.buttonReset.setEnabled(False)

            self.enable()
            self.flash_refresh()
Example #6
0
    def set_data(self, dataitem, **opts):
        request = getattr(dataitem.data, "request", None)
        if self._request and request:
            self._request = request

        if not self._has_data:
            self._has_data = True
            state = dataitem.data
            if not request:
                QMessageBox.warning(
                    self.wtop(), "Warning", "No request found in Node, Please specify request first via Reexecute"
                )
                self.enable_exec.setOn(False)
                self.enable_exec.setEnabled(False)
                self.buttonOk.setEnabled(False)
            else:
                #
                #     #print self._node;
                self.enable_exec.setOn(True)
                self.enable_exec.setEnabled(True)
                self.buttonOk.setEnabled(True)
                self._request = request

            self.unsubscribe_all()
            # parmlist is sorted by name.
            self._parmlist = []
            self._solverdict = {}
            self._parmdict = {}
            # all names off the nodes except parms
            self._nodedict = {}

            # recursively get all parms and solvers behind this node
            if self._node:
                self.getnodelist(meqds.nodelist[self._node])
            else:
                self.getnodelist(meqds.nodelist[self._name])
            # subscribe to solvers
            for solverkey in self._solverdict.keys():
                solver = self._solverdict[solverkey]["node"]
                # subscribe
                solver.subscribe_state(self._callbacksolver)
                meqds.request_node_state(solver)

            # fill listbox with MeqParm names
            self.parmtable.setNumCols(len(self._solverdict.keys()) + solverstart)
            self.parmtable.setNumRows(len(self._parmlist))
            self.parmtable.setReadOnly(True)
            self.parmtable.horizontalHeader().setLabel(0, "name")
            self.parmtable.horizontalHeader().setLabel(1, "c00")
            self.parmtable.horizontalHeader().setLabel(2, "shape")
            self.parmtable.horizontalHeader().setLabel(3, pixmaps.publish.iconset(), "")
            self.parmtable.horizontalHeader().setLabel(4, "0")
            self.parmtable.setColumnWidth(0, 100)
            self.parmtable.setColumnWidth(1, 200)
            self.parmtable.setColumnWidth(2, 60)
            self.parmtable.setColumnWidth(3, 25)
            self.parmtable.setColumnWidth(4, 25)
            #        self.parmtable.horizontalHeader () .setLabel(3,"i");
            tooltip = "click to sort"
            QToolTip.add(self.parmtable.horizontalHeader(), tooltip)
            QObject.connect(self.parmtable.horizontalHeader(), SIGNAL("released(int)"), self.sortColumn)
            if self._currentparm:
                self._currentparm.reject()
                self._currentparm = None
            self._parmindex = -1

            self.updateTable()
            for parmkey in self._parmlist:
                parm = self._parmdict[parmkey]["node"]
                parm.subscribe_state(self._callbackparm)
                meqds.request_node_state(parm)

            self.buttonReset.setEnabled(False)

            if not self._parmlist:
                QMessageBox.warning(self.wtop(), "Warning", "No parameters found")
                self.buttonReset.setEnabled(False)

            self.enable()
            self.flash_refresh()