Пример #1
0
def test_add_variable_float_fail(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler, "Add Variable", modeler.get_current_server(), dtype=ua.ObjectIds.Float)
    dia.valLineEdit.setText("oiuiu")
    with pytest.raises(ValueError):
        args = dia.get_args()
        new_node = mgr.add_variable(*args)
Пример #2
0
def test_add_variable_double_list(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler, "Add Variable", modeler.get_current_server(), dtype=ua.ObjectIds.Double)
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children()
    assert isinstance(new_node.get_value(), float)
Пример #3
0
 def test_add_variable_double_list(self):
     self.modeler.tree_ui.expand_to_node("Objects")
     val = [9.9, 5.5, 1.2]
     dia = NewUaVariableDialog(self.modeler, "Add Variable", self.modeler.get_current_server(), default_value=val, dtype=ua.ObjectIds.Double)
     args = dia.get_args()
     new_node = self.mgr.add_variable(*args)
     self.assertIn(new_node, self.modeler.get_current_server().nodes.objects.get_children())
     self.assertEqual(val, new_node.get_value())
Пример #4
0
def test_add_variable_bytes(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler, "Add Variable", modeler.get_current_server(), dtype=ua.ObjectIds.ByteString)
    val = b"lkjkjl"
    dia.valLineEdit.setText(val.decode())
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children()
    assert val == new_node.get_value()
Пример #5
0
def test_add_variable_extobj(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler,
                              "Add Variable",
                              modeler.get_current_server(),
                              dtype=ua.ObjectIds.Structure)
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children(
    )
Пример #6
0
def test_add_variable_float_fail(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler,
                              "Add Variable",
                              modeler.get_current_server(),
                              dtype=ua.ObjectIds.Float)
    dia.valLineEdit.setText("oiuiu")
    with pytest.raises(ValueError):
        args = dia.get_args()
        new_node = mgr.add_variable(*args)
Пример #7
0
 def test_add_variable_float_fail(self):
     self.modeler.tree_ui.expand_to_node("Objects")
     dia = NewUaVariableDialog(self.modeler,
                               "Add Variable",
                               self.modeler.get_current_server(),
                               default_value=b"lkjkl",
                               dtype=ua.ObjectIds.Float)
     with self.assertRaises(ValueError):
         args = dia.get_args()
         new_node = self.mgr.add_variable(*args)
Пример #8
0
def test_add_variable_double_list(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler,
                              "Add Variable",
                              modeler.get_current_server(),
                              dtype=ua.ObjectIds.Double)
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children(
    )
    assert isinstance(new_node.read_value(), float)
Пример #9
0
 def test_add_variable_bytes(self):
     self.modeler.tree_ui.expand_to_node("Objects")
     dia = NewUaVariableDialog(self.modeler,
                               "Add Variable",
                               self.modeler.get_current_server(),
                               default_value=b"lkjkl",
                               dtype=ua.ObjectIds.ByteString)
     args = dia.get_args()
     new_node = self.mgr.add_variable(*args)
     self.assertIn(
         new_node,
         self.modeler.get_current_server().nodes.objects.get_children())
Пример #10
0
 def test_add_variable_double(self):
     self.modeler.tree_ui.set_current_node("Objects")
     dia = NewUaVariableDialog(self.modeler,
                               "Add Variable",
                               self.modeler.get_current_server(),
                               default_value=9.99,
                               dtype=ua.ObjectIds.Double)
     args = dia.get_args()
     new_node = self.modeler.model_mgr.add_variable(*args)
     self.assertIn(
         new_node,
         self.modeler.get_current_server().nodes.objects.get_children())
Пример #11
0
def test_add_variable_bytes(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler,
                              "Add Variable",
                              modeler.get_current_server(),
                              dtype=ua.ObjectIds.ByteString)
    val = b"lkjkjl"
    dia.valLineEdit.setText(val.decode())
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children(
    )
    assert val == new_node.read_value()
Пример #12
0
 def add_property(self):
     args, ok = NewUaVariableDialog.getArgs(self.modeler,
                                            "Add Property",
                                            self._model_mgr.server_mgr,
                                            default_value=9.99)
     if ok:
         node = self._model_mgr.add_property(*args)
         self._add_modelling_rule(node)
Пример #13
0
 def add_property(self):
     dtype = self.settings.value("last_datatype", None)
     args, ok = NewUaVariableDialog.getArgs(self.modeler,
                                            "Add Property",
                                            self._model_mgr.server_mgr,
                                            default_value=9.99,
                                            dtype=dtype)
     if ok:
         self._model_mgr.add_property(*args)
Пример #14
0
 def add_variable(self):
     dtype = self.settings.value("last_datatype", None)
     args, ok = NewUaVariableDialog.getArgs(self.modeler,
                                            "Add Variable",
                                            self._model_mgr.server_mgr,
                                            default_value=9.99,
                                            dtype=dtype)
     if ok:
         node = self._model_mgr.add_variable(*args)
         self.settings.setValue("last_datatype", args[4])
         self._add_modelling_rule(node)
Пример #15
0
 def add_variable(self):
     args, ok = NewUaVariableDialog.getArgs(self.modeler, "Add Variable", self._model_mgr.server_mgr)
     if ok:
         node = self._model_mgr.add_variable(*args)
         self._add_modelling_rule(node)
Пример #16
0
 def add_property(self):
     args, ok = NewUaVariableDialog.getArgs(self.modeler, "Add Property", self._model_mgr.server_mgr)
     if ok:
         node = self._model_mgr.add_property(*args)
         self._add_modelling_rule(node)
Пример #17
0
def test_add_variable_extobj(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler, "Add Variable", modeler.get_current_server(), dtype=ua.ObjectIds.Structure)
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children()