def update_setpoints(self, joint):
        self.table_widget.setRowCount(len(joint.setpoints))

        for i, setpoint in enumerate(joint.setpoints):
            time_item = QTableWidgetItem(
                str(round(setpoint.time, self.TABLE_DIGITS)))

            position_item = QTableWidgetItem(
                str(round(math.degrees(setpoint.position), self.TABLE_DIGITS)))

            velocity_item = QTableWidgetItem(
                str(round(math.degrees(setpoint.velocity), self.TABLE_DIGITS)))

            self.table_widget.setItem(i, 0, time_item)
            self.table_widget.setItem(i, 1, position_item)
            self.table_widget.setItem(i, 2, velocity_item)

        self.table_widget.setItemDelegate(
            JointSettingSpinBoxDelegate(
                joint.limits.velocity,
                joint.limits.lower,
                joint.limits.upper,
                joint.duration,
            ))
        self.table_widget.resizeColumnsToContents()
Ejemplo n.º 2
0
    def __init__(self, subsystem_name, parent=None):
        super(StateHistoryDialog, self).__init__(parent)

        self.parent = parent

        self.setWindowFlags(Qt.Window)

        rp = rospkg.RosPack()
        ui_file = os.path.join(rp.get_path('rqt_agent'), 'resource', 'StateHistory.ui')
        loadUi(ui_file, self)

        self.setWindowTitle(subsystem_name + " - state history")

        self.pushButton_close.clicked.connect(self.closeClick)

        hdr = self.MyHorizHeader(self.tableWidget)
        hdr.setMinimumSectionSize(40)
        hdr.setDefaultSectionSize(40)
        self.tableWidget.setHorizontalHeader(hdr)

        self.initialized = False
        item0 = QTableWidgetItem("behavior")
        item1 = QTableWidgetItem("reason")
        item2 = QTableWidgetItem("time")
        self.tableWidget.setHorizontalHeaderItem (0, item0)
        self.tableWidget.setHorizontalHeaderItem (1, item1)
        self.tableWidget.setHorizontalHeaderItem (2, item2)
        self.tableWidget.setColumnWidth(0, 100)
        self.tableWidget.setColumnWidth(1, 50)
        self.tableWidget.setColumnWidth(2, 75)
Ejemplo n.º 3
0
 def _add_parameter(self, param):
     key = QTableWidgetItem(param.key)
     key.setFlags(key.flags() & ~Qt.ItemIsEditable)
     row = self.skill_params_table.rowCount()
     self.skill_params_table.insertRow(row)
     #row = row-1
     self.skill_params_table.setItem(row, 0, key)
     if param.dataTypeIs(bool):
         cbox = QCheckBox()
         if param.hasSpecifiedDefault():
             cbox.setChecked(param.default)
         self.skill_params_table.setCellWidget(row, 1, cbox)
     elif param.dataTypeIs(Element):
         combobox = QComboBox()
         self.skill_params_table.setCellWidget(row, 1, combobox)
         matches = self._wmi.resolve_elements(param.default)
         if param.paramTypeIs(ParamTypes.Optional):
             combobox.addItem("", None)
         for e in matches:
             combobox.addItem(e.printState(), e._id)
     else:
         lineedit = QLineEdit()
         if param.isSpecified():
             lineedit.setText(str(param.value))
         self.skill_params_table.setCellWidget(row, 1, lineedit)
Ejemplo n.º 4
0
    def set_motor_joint_states(self, data):
        if self.current_tab == 0:
            self.motorheaderlist = []
            for i in range(0, len(data.name)):
                self.torquelist[i].append(float(data.effort[i]))
                if not data.name[i] in self.motorheaderlist:
                    self.motorheaderlist.append(data.name[i])
                for j in range(0, len(self.motorheaderlist)):
                    if j < 10:
                        selected = self._widget.tableWidget
                        k = j
                    else:
                        selected = self._widget.tableWidget_2
                        k = j - 10
                    for j in self.motorheaderlist:
                        if j == data.name[i]:
                            selected.setItem(
                                2, k,
                                QTableWidgetItem(
                                    str(
                                        round(
                                            float(
                                                math.degrees(
                                                    data.position[i])), 2))))
                            selected.setItem(
                                5, k,
                                QTableWidgetItem(
                                    str(round(float(data.effort[i]), 2))))

            self._widget.tableWidget.setHorizontalHeaderLabels(
                self.motorheaderlist)
            self._widget.tableWidget_2.setHorizontalHeaderLabels(
                self.motorheaderlist[10:])

            self.totrigger.emit()
Ejemplo n.º 5
0
 def wm_tree_widget_currentItemChanged(self, item, prev_item):
     while self.wm_properties_widget.rowCount() > 0:
         self.wm_properties_widget.removeRow(0)
     item = QTableWidgetItem(str(item.text(0)))
     self.wm_properties_widget.insertRow(0)
     self.wm_properties_widget.setItem(0, 0, item)
     while self.wm_relations_widget.rowCount() > 0:
         self.wm_relations_widget.removeRow(0)
     item = QTableWidgetItem("")
     self.wm_relations_widget.insertRow(0)
     self.wm_relations_widget.setItem(0, 0, item)
Ejemplo n.º 6
0
    def _update_data_table(self):
        self._data_table.setRowCount(0)

        for data_key, data_dict in self._data_buffer.items():
            current_row = self._data_table.rowCount()
            self._data_table.insertRow(current_row)
            self._data_table.setItem(current_row, 0, QTableWidgetItem(data_dict['time']))
            self._data_table.setItem(current_row, 1, QTableWidgetItem(data_dict['trig_name']))
            self._data_table.setItem(current_row, 2, QTableWidgetItem(data_dict['trig_type']))
            self._data_table.setItem(current_row, 3, QTableWidgetItem(data_dict['data']._type))
            self._data_table.setItem(current_row, 4, QTableWidgetItem(data_key))
        self._data_table.sortItems(0, Qt.DescendingOrder)
    def set_current_grid(self):

        if 'grid' not in self.step.keys():
            self.add_grid()

        self.gridTable.setItem(0, 1, QTableWidgetItem(self.step['grid']['X']))
        self.gridTable.setItem(1, 1, QTableWidgetItem(self.step['grid']['Y']))
        self.gridTable.setItem(2, 1,
                               QTableWidgetItem(self.step['grid']['x_first']))
        self.gridTable.setItem(3, 1,
                               QTableWidgetItem(self.step['grid']['x_step']))
        self.gridTable.setItem(4, 1,
                               QTableWidgetItem(self.step['grid']['y_step']))
Ejemplo n.º 8
0
 def _update_progress_table(self, msg):
     last_msg = self.tableWidget_output.item(self.tableWidget_output.rowCount() - 1, 5).text() if self.tableWidget_output.rowCount() > 0 else ""
     if msg.progress_message != "Start" and (msg.label.find("task") >= 0 or (msg.progress_message != "End" and msg.progress_message != last_msg)):
         self.tableWidget_output.insertRow(self.tableWidget_output.rowCount())
         self.tableWidget_output.setItem(self.tableWidget_output.rowCount() - 1, 0, QTableWidgetItem("{:0.3f}".format(msg.progress_time)))
         self.tableWidget_output.setItem(self.tableWidget_output.rowCount() - 1, 1, QTableWidgetItem("{}_{}".format(msg.parent_label, msg.parent_id)))
         self.tableWidget_output.setItem(self.tableWidget_output.rowCount() - 1, 2, QTableWidgetItem("{}_{}".format(msg.label, msg.id)))
         self.tableWidget_output.setItem(self.tableWidget_output.rowCount() - 1, 3, QTableWidgetItem(State(msg.state).name))
         self.tableWidget_output.setItem(self.tableWidget_output.rowCount() - 1, 4, QTableWidgetItem(str(msg.progress_code)))
         progress = QTableWidgetItem(str(msg.progress_message))
         progress.setToolTip(str(msg.progress_message))
         self.tableWidget_output.setItem(self.tableWidget_output.rowCount() - 1, 5, progress)
         self.tableWidget_output.scrollToBottom()
Ejemplo n.º 9
0
    def updateState(self, mcd):
        hist = mcd[0]
        if self.tableWidget.rowCount() != len(hist):
            self.tableWidget.setRowCount( len(hist) )
        row = 0
        curr_pred = mcd[1].split(",")
        curr_pred_v = []
        for cp in curr_pred:
            k_v = cp.split(":")
            if len(k_v) == 2:
                curr_pred_v.append(k_v[1])

        for ss in hist:
            for col in range(3):
                self.tableWidget.setItem(row, col, QTableWidgetItem(ss[col]))
            pred = ss[3].split(",")

            if not self.initialized:
                self.initialized = True
                predicates = []
                for p in pred:
                    k_v = p.split(":")
                    if len(k_v) != 2:
                        continue
                    predicates.append( k_v[0] )

                self.tableWidget.setColumnCount(len(predicates)+3)
                idx = 3
                for p in predicates:
                    item = QTableWidgetItem(p)
                    self.tableWidget.setHorizontalHeaderItem(idx, item)
                    idx += 1

            idx = 0
            for p in pred:
                k_v = p.split(":")
                if len(k_v) != 2:
                    continue
                if row == 0:
                    self.tableWidget.setItem(row, 3+idx, QTableWidgetItem(k_v[1] + " ("+curr_pred_v[idx]+")"))
                else:
                    self.tableWidget.setItem(row, 3+idx, QTableWidgetItem(k_v[1]))
                idx += 1
                
            row = row + 1
Ejemplo n.º 10
0
    def _add_entry(self):
        self._table_widget.blockSignals(True)

        # insert new row
        self._table_widget.insertRow(self._table_widget.rowCount() - 1)

        # move key and value items up
        self._table_widget.setItem(
            self._table_widget.rowCount() - 2, 0,
            self._table_widget.takeItem(self._table_widget.rowCount() - 1, 0))
        self._table_widget.setItem(
            self._table_widget.rowCount() - 2, 1,
            self._table_widget.takeItem(self._table_widget.rowCount() - 1, 1))
        self._table_widget.setItem(self._table_widget.rowCount() - 1, 0,
                                   QTableWidgetItem())
        self._table_widget.setItem(self._table_widget.rowCount() - 1, 1,
                                   QTableWidgetItem())

        # add 'remove' button
        item = QTableWidgetItem()
        item.setFlags(Qt.NoItemFlags)
        self._table_widget.setItem(self._table_widget.rowCount() - 2, 2, item)
        self._table_widget.setCellWidget(
            self._table_widget.rowCount() - 2, 2,
            self._create_cell_push_button(
                '', lambda: self._table_widget.removeRow(item.row()),
                QIcon.fromTheme('list-remove')))

        self._table_widget.blockSignals(False)
Ejemplo n.º 11
0
 def new_pano_state(self, msg):
     self.tableWidget.clearContents()
     self.files = {}
     self.pixmaps = {}
     j = 0
     self.tableWidget.setRowCount(
         len(msg.in_transfer) + len(msg.transferred))
     for i in msg.in_transfer:
         self.tableWidget.setItem(j, 0, QTableWidgetItem(i))
         self.tableWidget.setItem(j, 1, QTableWidgetItem("Transferring"))
         j += 1
         # self.tableWidget.setRowCount(j)
     for i in msg.transferred:
         self.tableWidget.setItem(j, 0, QTableWidgetItem(i))
         self.tableWidget.setItem(j, 1, QTableWidgetItem("Transferred"))
         self.files[j] = i
         print self.files
         self.pixmaps[j] = QPixmap(i)
         j += 1
Ejemplo n.º 12
0
 def handle_add_button_clicked(self, checked):
   '''When the add button is clicked this function moves any selected items to the plan queue table.'''
   #get selected items
   selected_plans = self._widget.planList.selectedItems()
   #create a new row in the queue table for each selection and insert it
   for i in selected_plans:
     row_position = self._widget.planQueueTable.rowCount()
     self._widget.planQueueTable.insertRow(row_position)
     self._widget.planQueueTable.setItem(row_position-1, 1, QTableWidgetItem(i.text()))
   self._widget.planList.selectionModel().clear()
   self._widget.planQueueTable.resizeColumnsToContents()
   return
    def pose_selected(self, index):
        rospy.loginfo('%s::%s:' % (self._name, self.get_function_name()))

        if index < 0:
            self.posesTable.setRowCount(0)

        pose = self.get_pose(index)

        if pose == None or len(pose) != 2 or len(pose[0]) != 3 or len(
                pose[1]) != 3:
            return

        axes = [['X', 'Y', 'Z'], ['roll', 'pitch', 'yaw']]
        self.posesTable.setRowCount(0)
        for i in range(len(axes)):
            for j in range(len(axes[i])):
                row_count = self.posesTable.rowCount()
                self.posesTable.insertRow(row_count)
                self.posesTable.setItem(row_count, 0,
                                        QTableWidgetItem(axes[i][j]))
                self.posesTable.setItem(row_count, 1,
                                        QTableWidgetItem(str(pose[i][j])))
def update_table(table, joint, duration):
    table.setRowCount(len(joint.setpoints))

    for i in range(0, len(joint.setpoints)):

        time_item = QTableWidgetItem(str(round(joint.setpoints[i].time, TABLE_DIGITS)))

        position_item = QTableWidgetItem(
            str(round(math.degrees(joint.setpoints[i].position), TABLE_DIGITS)))

        velocity_item = QTableWidgetItem(
            str(round(math.degrees(joint.setpoints[i].velocity), TABLE_DIGITS)))

        table.setItem(i, 0, time_item)
        table.setItem(i, 1, position_item)
        table.setItem(i, 2, velocity_item)

    table.setItemDelegate(JointSettingSpinBoxDelegate(
        joint.limits.velocity, joint.limits.lower, joint.limits.upper, duration))
    # table.resizeRowsToContents()
    table.resizeColumnsToContents()
    return table
Ejemplo n.º 15
0
    def _init_table_widget(self):
        self._table_widget.blockSignals(True)

        self._table_widget.setRowCount(1)
        self._table_widget.setColumnCount(3)

        self._table_widget.verticalHeader().setVisible(False)
        self._table_widget.setHorizontalHeaderLabels(['Key', 'Value', ''])
        self._table_widget.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)
        self._table_widget.horizontalHeader().setSectionResizeMode(
            2, QHeaderView.ResizeToContents)

        self._table_widget.setItem(0, 0, QTableWidgetItem())
        self._table_widget.setItem(0, 1, QTableWidgetItem())
        self._table_widget.setItem(0, 2, QTableWidgetItem())
        self._table_widget.item(0, 2).setFlags(Qt.NoItemFlags)
        self._table_widget.setCellWidget(
            0, 2,
            self._create_cell_push_button('', lambda: self._add_entry(),
                                          QIcon.fromTheme('list-add')))

        self._table_widget.blockSignals(False)
    def joint_pose_selected(self, index):
        rospy.loginfo('%s::%s: index: %d' %
                      (self._name, self.get_function_name(), index))

        if index < 0:
            self.jointPosesTable.setRowCount(0)

        joint_pose = self.get_joint_pose(index)

        if joint_pose == None or len(joint_pose) != len(self.joint_state.name):
            return

        self.jointPosesTable.setRowCount(0)
        for i in range(len(joint_pose)):
            row_count = self.jointPosesTable.rowCount()
            self.jointPosesTable.insertRow(row_count)
            self.jointPosesTable.setItem(
                row_count, 0, QTableWidgetItem(self.joint_state.name[i]))
            self.jointPosesTable.setItem(row_count, 1,
                                         QTableWidgetItem(str(joint_pose[i])))
            rospy.loginfo('%s::%s: adding : %s, %f' %
                          (self._name, self.get_function_name(),
                           self.joint_state.name[i], joint_pose[i]))
Ejemplo n.º 17
0
    def set_current_arm(self):  # this is view...
        self._widget.groupNameEdit.setText(self.get_current_movegroup_name())
        self._widget.actionNSEdit.setText(self.get_current_actionns())
        self._widget.baseLinkEdit.setText(self.get_current_base_link())
        self._widget.endEffectorEdit.setText(self.get_current_end_effector())

        joint_names = self.get_current_joint_names()
        self._widget.jointsTable.setRowCount(len(joint_names))
        for i in range(len(joint_names)):
            self._widget.jointsTable.setItem(i, 0,
                                             QTableWidgetItem(joint_names[i]))

        inputs = self.get_current_inputs()
        self._widget.inputsTable.setRowCount(0)
        for input_key in inputs:  # different ways of filling the tabele
            row_count = self._widget.inputsTable.rowCount()
            self._widget.inputsTable.insertRow(row_count)
            self._widget.inputsTable.setItem(row_count, 0,
                                             QTableWidgetItem(input_key))
            self._widget.inputsTable.setItem(
                row_count, 1, QTableWidgetItem(str(inputs[input_key])))

        outputs = self.get_current_outputs()
        self._widget.outputsTable.setRowCount(0)
        for output_key in outputs:  # different ways of filling the tabele
            row_count = self._widget.outputsTable.rowCount()
            self._widget.outputsTable.insertRow(row_count)
            self._widget.outputsTable.setItem(row_count, 0,
                                              QTableWidgetItem(output_key))
            self._widget.outputsTable.setItem(
                row_count, 1, QTableWidgetItem(str(outputs[output_key])))

        self._widget.stepBox.clear()
        steps = self.get_steps()
        for s in steps:
            self._widget.stepBox.addItem(s)
        self._widget.stepBox.setCurrentIndex(0)
Ejemplo n.º 18
0
  def handle_send_button_clicked(self, checked):
    '''When send button is clicked any items in the plan queue table are sent (in order) to the sent plans table.
     It then publishes a string array of these plans so that the ow_plexil_plan_selection node can run them 
     sequentially. If the subscriber is not connected a popup box reminding the user to run the ow_plexil node will show up.'''
    if self.check_client_set_up() == False:
      return

    num_rows = self._widget.planQueueTable.rowCount()
    plans_sent = []
    #creates a new row in the sent table for each item in the queue table and inserts it
    for i in range(num_rows):
      plan_name = self._widget.planQueueTable.item(0,0).text()
      plans_sent.append(str(plan_name + ".plx"))
      self._widget.planQueueTable.removeRow(0)
      
      row_position = self._widget.sentPlansTable.rowCount()
      self._widget.sentPlansTable.insertRow(row_position)
      self._widget.sentPlansTable.setItem(row_position, 0, QTableWidgetItem(plan_name))
      self._widget.sentPlansTable.setItem(row_position, 1, QTableWidgetItem("Pending..."))
      self._widget.sentPlansTable.resizeColumnsToContents()

    # Create msg and send to subscriber for plan execution
    self.plan_select_client("ADD", plans_sent)
    return
Ejemplo n.º 19
0
    def __init__(self, context):
        super(Controls, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName('Controls')

        # Create QWidget
        self._widget = QWidget()
        # Get path to UI file which should be in the "resource" folder of this package
        _ui_file = path.join(rospkg.RosPack().get_path('rqt_controls'),
                             'resource', 'Controls.ui')
        # Extend the widget with all attributes and children from UI file
        self._ui = loadUi(_ui_file, self._widget)

        self._ui.ButtonKillnode.clicked.connect(self.onKillnode)

        for i in range(0, 3):
            self._ui.MotorTable.setItem(i, 0, QTableWidgetItem())
            self._ui.MotorTable.setItem(i, 1, QTableWidgetItem())

        # Give QObjects reasonable names
        self._widget.setObjectName('ControlsUi')
        self._widget.setWindowTitle("Robot Controls")
        # Show _widget.windowTitle on left-top of each plugin (when
        # it's set in _widget). This is useful when you open multiple
        # plugins at once. Also if you open multiple instances of your
        # plugin at once, these lines add number to make it easy to
        # tell from pane to pane.
        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() +
                                        (' (%d)' % context.serial_number()))
        # Add widget to the user interface
        context.add_widget(self._widget)

        self._ui.BatteryPanel.display(999.9)
        self.motor_stats = rospy.Subscriber("skid_steering_node/motor_stats",
                                            ChannelFloat32, self.callback)
Ejemplo n.º 20
0
 def _write_conf_to_table(self):
     self._conf_table.setRowCount(len(self._conf_yaml))
     for row, conf_key in enumerate(self._conf_yaml.items()):
         conf = conf_key[1]
         self._conf_table.setItem(row, 0, QTableWidgetItem(conf['trig_name']))
         self._conf_table.setItem(row, 1, QTableWidgetItem(conf['robot_ns']))
         self._conf_table.setItem(row, 2, QTableWidgetItem(conf['trig_topic']))
         self._conf_table.setItem(row, 3, QTableWidgetItem(conf['trig_type']))
         self._conf_table.setItem(row, 4, QTableWidgetItem(str(conf['trig_value'])))
         self._conf_table.setItem(row, 5, QTableWidgetItem(conf['trig_callback']))
Ejemplo n.º 21
0
    def addRow(self, label, c_rgba, mean, deviation):
        rowIdx = self.rowCount() - 1
        self.insertRow(rowIdx)
        # create QColor
        color = QtGui.QColor.fromRgbF(c_rgba[0], c_rgba[1], c_rgba[2],
                                      c_rgba[3])
        # create QBrush with color
        brush = QtGui.QBrush(color)

        # legend item
        leg_item = QTableWidgetItem(label)
        leg_item.setBackground(brush)
        self.setItem(rowIdx, 0, leg_item)

        # mean item
        mean_item = QTableWidgetItem(str(mean))
        mean_item.setBackground(brush)
        self.setItem(rowIdx, 1, mean_item)

        # deviation item
        dev_item = QTableWidgetItem(str(deviation))
        dev_item.setBackground(brush)
        self.setItem(rowIdx, 2, dev_item)
Ejemplo n.º 22
0
	def update_display(self):
		self.clear_display()

		self.update_flight_plan()

		for i in xrange(len(self.loaded_movement.waypoints)):
			self._widget.table_waypoints.insertRow(i)
			item_x = QTableWidgetItem(str(self.loaded_movement.waypoints[i].x))
			item_y = QTableWidgetItem(str(self.loaded_movement.waypoints[i].y))
			item_z = QTableWidgetItem(str(self.loaded_movement.waypoints[i].z))
			item_yaw = QTableWidgetItem(str(self.loaded_movement.waypoints[i].yaw))
			item_x.setTextAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight)
			item_y.setTextAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight)
			item_z.setTextAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight)
			item_yaw.setTextAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight)
			self._widget.table_waypoints.setItem(i, 0, item_x)
			self._widget.table_waypoints.setItem(i, 1, item_y)
			self._widget.table_waypoints.setItem(i, 2, item_z)
			self._widget.table_waypoints.setItem(i, 3, item_yaw)

		self.update_plot()
Ejemplo n.º 23
0
    def _add_relations_table_row(self, relation, editable_src=False, editable_dst=False):
        src = QTableWidgetItem(utils.ontology_type2name(relation['src']))
        rel = QTableWidgetItem(utils.ontology_type2name(relation['type']))
        dst = QTableWidgetItem(utils.ontology_type2name(relation['dst']))

        src.id = relation['src']
        rel.id = relation['type']
        dst.id = relation['dst']

        src.setTextAlignment(Qt.AlignRight)
        rel.setTextAlignment(Qt.AlignHCenter)
        dst.setTextAlignment(Qt.AlignLeft)

        if not editable_src:
            src.setFlags(src.flags() & ~Qt.ItemIsEditable)
        rel.setFlags(rel.flags() & ~Qt.ItemIsEditable)
        if not editable_dst:
            dst.setFlags(dst.flags() & ~Qt.ItemIsEditable)

        self.wm_relations_widget.insertRow(self.wm_relations_widget.rowCount())
        # self.wm_relations_widget.setSpan(self.wm_relations_widget.rowCount()-1, 0, 1, 3)
        self.wm_relations_widget.setItem(self.wm_relations_widget.rowCount() - 1, 0, src)
        self.wm_relations_widget.setItem(self.wm_relations_widget.rowCount() - 1, 1, rel)
        self.wm_relations_widget.setItem(self.wm_relations_widget.rowCount() - 1, 2, dst)
Ejemplo n.º 24
0
    def set_motor_diagnostics(self, data):
        """Updates the table in the motor overview tab"""
        self.timestamp = data.header.stamp.secs  #setting timestamp here, because this topic should always exist.
        self._widget.label_13.setText(str(self.timestamp))

        self.motorheaderlist = []
        for i in range(len(data.status)):
            if data.status[i].level == 1:
                self.templist[int(data.status[i].hardware_id) - 101].append(
                    float(data.status[i].values[3].value))
                self.voltagelist[int(data.status[i].hardware_id) - 101].append(
                    float(data.status[i].values[1].value))
                if len(self.templist[i]) > 20:
                    self.templist[i].pop(0)
                if len(self.voltagelist[i]) > 20:
                    self.voltagelist[i].pop(0)
                if self.current_tab == 0:
                    if data.status[i].level == 1:
                        if not data.status[i].values[
                                2].value in self.motorheaderlist:
                            self.motorheaderlist.append(
                                data.status[i].values[2].value)
                        for j in range(0, len(self.motorheaderlist)):
                            if j < 10:
                                selected = self._widget.tableWidget
                                k = j
                            else:
                                selected = self._widget.tableWidget_2
                                k = j - 10
                            try:
                                if self.motorheaderlist[j] == data.status[
                                        i].values[2].value:
                                    selected.setItem(
                                        0, k,
                                        QTableWidgetItem(
                                            data.status[i].message))
                                    selected.setItem(
                                        1, k,
                                        QTableWidgetItem(
                                            str(
                                                round(
                                                    float(data.status[i].
                                                          values[3].value),
                                                    2))))
                                    selected.setItem(
                                        3, k,
                                        QTableWidgetItem(
                                            str(
                                                round(
                                                    float(data.status[i].
                                                          values[1].value),
                                                    2))))
                                    selected.setItem(
                                        4, k,
                                        QTableWidgetItem(
                                            data.status[i].values[0].value))
                            except IndexError:
                                rospy.logwarn(
                                    "Received a message that misses some information. Faulty message: "
                                    + data.status[i])

            self._widget.tableWidget.setHorizontalHeaderLabels(
                self.motorheaderlist)
            self._widget.tableWidget_2.setHorizontalHeaderLabels(
                self.motorheaderlist[10:])
            self._widget.tableWidget.reset()
            self._widget.tableWidget_2.reset()
            self._widget.tableWidget.setEditTriggers(
                QTableWidget.NoEditTriggers)

        self.tetrigger.emit()
        self.votrigger.emit()
Ejemplo n.º 25
0
    def _add_properties_table_row(self, prop, editable_key=False, editable_value=True):
        key = QTableWidgetItem(utils.ontology_type2name(prop.key))
        if not editable_key:
            key.setFlags(key.flags() & ~Qt.ItemIsEditable)
        value = prop.values if prop.isList() else prop.value
        if prop.dataTypeIs(float):
            val = QTableWidgetItem(format(value, '.4f') if value is not None else '')
        else:
            val = QTableWidgetItem(str(value) if value is not None else '')
        if not editable_value:
            val.setFlags(val.flags() & ~Qt.ItemIsEditable)

        if prop.dataTypeIs(bool):
            val.setText('')
            val.setFlags(val.flags() & ~Qt.ItemIsEditable)
            val.setCheckState(Qt.Checked if prop.value else Qt.Unchecked)
        # if isinstance(prop.dataType(), bool):
        #     val.setCheckState(prop.value)

        key.id = val.id = prop.key

        self.wm_properties_widget.insertRow(self.wm_properties_widget.rowCount())
        self.wm_properties_widget.setItem(self.wm_properties_widget.rowCount() - 1, 0, key)
        self.wm_properties_widget.setItem(self.wm_properties_widget.rowCount() - 1, 1, val)