def _add_output(self, arg): layout = QHBoxLayout() self.vlayout.addLayout(layout) layout.addWidget(QLabel("Data Type: {}".format(data_type_to_string(arg.DataType)))) layout.addWidget(QLabel("Value:")) label = QLabel("", self) self.outputs.append(label) layout.addWidget(label)
def _add_output(self, arg): layout = QHBoxLayout() self.vlayout.addLayout(layout) layout.addWidget(QLabel("Data Type: {}".format(data_type_to_string(arg.DataType)))) layout.addWidget(QLabel("Value:")) label = QLabel("", self) self.outputs.append(label) layout.addWidget(label)
def _add_input(self, arg): layout = QHBoxLayout() self.vlayout.addLayout(layout) layout.addWidget(QLabel("Name:{}".format(arg.Name), self)) layout.addWidget(QLabel("Data type:{}".format(data_type_to_string(arg.DataType)), self)) layout.addWidget(QLabel("Description:{}".format(arg.Description.Text), self)) lineedit = QLineEdit(self) lineedit.data_type = self.server.get_node(arg.DataType) self.inputs.append(lineedit) layout.addWidget(lineedit)
def _add_input(self, arg): layout = QHBoxLayout() self.vlayout.addLayout(layout) layout.addWidget(QLabel("Name:{}".format(arg.Name), self)) layout.addWidget(QLabel("Data type:{}".format(data_type_to_string(arg.DataType)), self)) layout.addWidget(QLabel("Description:{}".format(arg.Description.Text), self)) lineedit = QLineEdit(self) lineedit.data_type = self.server.get_node(arg.DataType) self.inputs.append(lineedit) layout.addWidget(lineedit)
def _show_attr(self, attr, dv): if attr == ua.AttributeIds.DataType: # FIXME: Could query for browsename here, it does not cost much string = data_type_to_string(dv.Value.Value) elif attr in (ua.AttributeIds.AccessLevel, ua.AttributeIds.UserAccessLevel, ua.AttributeIds.WriteMask, ua.AttributeIds.UserWriteMask, ua.AttributeIds.EventNotifier): string = enum_to_string(attr, dv.Value.Value) else: string = val_to_string(dv.Value.Value) name_item = QStandardItem(attr.name) vitem = QStandardItem(string) vitem.setData(AttributeData(attr, dv.Value.Value, dv.Value.VariantType), Qt.UserRole) self.model.appendRow([name_item, vitem, QStandardItem(dv.Value.VariantType.name)])
def _show_attr(self, attr, dv): if attr == ua.AttributeIds.DataType: # FIXME: Could query for browsename here, it does not cost much string = data_type_to_string(dv.Value.Value) elif attr in (ua.AttributeIds.AccessLevel, ua.AttributeIds.UserAccessLevel, ua.AttributeIds.WriteMask, ua.AttributeIds.UserWriteMask, ua.AttributeIds.EventNotifier): string = enum_to_string(attr, dv.Value.Value) else: string = val_to_string(dv.Value.Value) name_item = QStandardItem(attr.name) vitem = QStandardItem(string) vitem.setData(AttributeData(attr, dv.Value.Value, dv.Value.VariantType), Qt.UserRole) self.model.appendRow([name_item, vitem, QStandardItem(dv.Value.VariantType.name)])
def _set_attribute_data(self, data, editor, model, idx): if data.attr is ua.AttributeIds.Value: #for value we checkd data type from the variable data type # this is more robust try: data.uatype = self.attrs_widget.current_node.get_data_type_as_variant_type( ) except Exception as ex: logger.exception("Could get primitive type of variable %s", self.attrs_widget.current_node) self.error.emit(ex) raise if data.attr == ua.AttributeIds.NodeClass: data.value = ua.NodeClass[editor.currentText()] text = editor.currentText() elif data.attr == ua.AttributeIds.ValueRank: data.value = ua.ValueRank[editor.currentText()] text = editor.currentText() elif data.attr == ua.AttributeIds.DataType: data.value = editor.get_node().nodeid text = data_type_to_string(data.value) elif data.attr in (ua.AttributeIds.AccessLevel, ua.AttributeIds.UserAccessLevel, ua.AttributeIds.WriteMask, ua.AttributeIds.UserWriteMask, ua.AttributeIds.EventNotifier): data.value = editor.get_byte() text = enum_to_string(data.attr, data.value) else: if isinstance(editor, QComboBox): text = editor.currentText() else: text = editor.text() data.value = string_to_val(text, data.uatype) model.setItemData(idx, {Qt.DisplayRole: text, Qt.UserRole: data}) self._write_attr(data) if isinstance(data.value, list): # we need to refresh children item = self.attrs_widget.model.itemFromIndex(idx.sibling(0, 0)) self.attrs_widget.refresh_list(item, data.value, data.uatype)
def _set_attribute_data(self, data, editor, model, idx): if data.attr is ua.AttributeIds.Value: #for value we checkd data type from the variable data type # this is more robust try: data.uatype = self.attrs_widget.current_node.get_data_type_as_variant_type() except Exception as ex: logger.exception("Could get primitive type of variable %s", self.attrs_widget.current_node) self.error.emit(ex) raise if data.attr == ua.AttributeIds.NodeClass: data.value = ua.NodeClass[editor.currentText()] text = editor.currentText() elif data.attr == ua.AttributeIds.ValueRank: data.value = ua.ValueRank[editor.currentText()] text = editor.currentText() elif data.attr == ua.AttributeIds.DataType: data.value = editor.get_node().nodeid text = data_type_to_string(data.value) elif data.attr in (ua.AttributeIds.AccessLevel, ua.AttributeIds.UserAccessLevel, ua.AttributeIds.WriteMask, ua.AttributeIds.UserWriteMask, ua.AttributeIds.EventNotifier): data.value = editor.get_byte() text = enum_to_string(data.attr, data.value) else: if isinstance(editor, QComboBox): text = editor.currentText() else: text = editor.text() data.value = string_to_val(text, data.uatype) model.setItemData(idx, {Qt.DisplayRole: text, Qt.UserRole: data}) self._write_attr(data) if isinstance(data.value, list): # we need to refresh children item = self.attrs_widget.model.itemFromIndex(idx.sibling(0, 0)) self.attrs_widget.refresh_list(item, data.value, data.uatype)