Class: OPCUA::Server::TypeSubNode
- Defined in:
- lib/opcua/server.rb,
ext/opcua/server/server.c
Instance Method Summary collapse
-
#add_method(*args) ⇒ Object
{{{.
-
#add_object(*args) ⇒ Object
{{{.
-
#add_object_type(name) ⇒ Object
{{{.
- #add_properties(*item) ⇒ Object
- #add_property(name) ⇒ Object
- #add_property_rw(*item) ⇒ Object
-
#add_reference(to, type) ⇒ Object
{{{.
-
#add_variable(*args) ⇒ Object
{{{.
-
#add_variable_rw(*args) ⇒ Object
{{{.
- #add_variables(*item, &blk) ⇒ Object
- #add_variables_rw(*item, &blk) ⇒ Object
-
#delete! ⇒ Object
{{{.
Methods inherited from Node
#description, #description=, #exists?, #id, #name, #to_s
Instance Method Details
#add_method(*args) ⇒ Object
{{{
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'ext/opcua/server/server.c', line 313
static VALUE node_add_method(int argc, VALUE* argv, VALUE self) { //{{{
node_struct *parent;
VALUE name;
VALUE opts;
VALUE blk;
rb_gc_register_address(&blk);
if (argc < 1) { // there should be 1 or more arguments
rb_raise(rb_eArgError, "wrong number of arguments");
}
rb_scan_args(argc, argv, "1:&", &name, &opts, &blk);
if (NIL_P(opts)) opts = rb_hash_new();
Data_Get_Struct(self, node_struct, parent);
if (!parent->exists) rb_raise(rb_eRuntimeError, "Node does not exist anymore.");
VALUE str = rb_obj_as_string(name);
if (NIL_P(str) || TYPE(str) != T_STRING)
rb_raise(rb_eTypeError, "cannot convert obj to string");
char *nstr = (char *)StringValuePtr(str);
return node_wrap(CLASS_OF(self),node_alloc(parent->master,node_add_method_ua_simple(nstr,parent,opts,blk)));
}
|
#add_object(*args) ⇒ Object
{{{
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
# File 'ext/opcua/server/server.c', line 539
static VALUE node_add_object(int argc, VALUE* argv, VALUE self) { //{{{
node_struct *parent;
node_struct *datatype;
if (argc > 3 || argc < 2) { // there should only be 2 or 3 arguments
rb_raise(rb_eArgError, "wrong number of arguments");
}
UA_UInt32 type;
if (argc == 3 && argv[2] != Qnil) {
type = NUM2INT(argv[2]);
} else {
type = UA_NS0ID_MODELLINGRULE_MANDATORY;
}
if (!(rb_obj_is_kind_of(argv[1],cTypeTopNode) || rb_obj_is_kind_of(argv[1],cTypeSubNode))) {
rb_raise(rb_eArgError, "argument 2 has to be a type.");
}
Data_Get_Struct(self, node_struct, parent);
if (!parent->exists) rb_raise(rb_eRuntimeError, "Parent node does not exist anymore.");
Data_Get_Struct(argv[1], node_struct, datatype);
if (!datatype->exists) rb_raise(rb_eRuntimeError, "Datatype node does not exist anymore.");
VALUE str = rb_obj_as_string(argv[0]);
if (NIL_P(str) || TYPE(str) != T_STRING)
rb_raise(rb_eTypeError, "cannot convert obj to string");
char *nstr = (char *)StringValuePtr(str);
return node_wrap(CLASS_OF(self),node_alloc(parent->master,node_add_object_ua_simple(type,nstr,parent,datatype,argv[2],true)));
}
|
#add_object_type(name) ⇒ Object
{{{
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'ext/opcua/server/server.c', line 71
static VALUE node_add_object_type(VALUE self, VALUE name) { //{{{
node_struct *ns;
Data_Get_Struct(self, node_struct, ns);
if (!ns->exists) rb_raise(rb_eRuntimeError, "Node does not exist anymore.");
VALUE str = rb_obj_as_string(name);
if (NIL_P(str) || TYPE(str) != T_STRING)
rb_raise(rb_eTypeError, "cannot convert obj to string");
char *nstr = (char *)StringValuePtr(str);
UA_NodeId n = UA_NODEID_NUMERIC(ns->master->default_ns, nodecounter++);
UA_ObjectTypeAttributes dtAttr = UA_ObjectTypeAttributes_default;
dtAttr.displayName = UA_LOCALIZEDTEXT("en-US", nstr);
UA_Server_addObjectTypeNode(ns->master->master,
n,
ns->id,
UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE),
UA_QUALIFIEDNAME(ns->master->default_ns, nstr),
dtAttr,
NULL,
NULL);
return node_wrap(cTypeSubNode,node_alloc(ns->master,n));
}
|
#add_properties(*item) ⇒ Object
43 44 45 |
# File 'lib/opcua/server.rb', line 43 def add_properties(*item) item.each { |e| add_property e } end |
#add_property(name) ⇒ Object
37 38 39 |
# File 'lib/opcua/server.rb', line 37 def add_property(name) add_variable name, OPCUA::PROPERTYTYPE end |
#add_property_rw(*item) ⇒ Object
40 41 42 |
# File 'lib/opcua/server.rb', line 40 def add_property_rw add_variable_rw name, OPCUA::PROPERTYTYPE end |
#add_reference(to, type) ⇒ Object
{{{
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'ext/opcua/server/server.c', line 172
static VALUE node_add_reference(VALUE self, VALUE to, VALUE type) { //{{{
node_struct *ns;
node_struct *tos;
node_struct *tys;
Data_Get_Struct(self, node_struct, ns);
if (!ns->exists) rb_raise(rb_eRuntimeError, "Node does not exist anymore.");
if (!(rb_obj_is_kind_of(type,cReferenceSubNode) || rb_obj_is_kind_of(to,cTypeSubNode))) {
rb_raise(rb_eArgError, "arguments have to be NodeIDs.");
}
Data_Get_Struct(to, node_struct, tos);
if (!tos->exists) rb_raise(rb_eRuntimeError, "To (arg 1) node does not exist anymore.");
Data_Get_Struct(type, node_struct, tys);
if (!tys->exists) rb_raise(rb_eRuntimeError, "Type (arg 2) node does not exist anymore.");
UA_NodeId n = UA_NODEID_NUMERIC(ns->master->default_ns, nodecounter++);
UA_ExpandedNodeId toNodeId;
toNodeId.serverIndex = 0;
toNodeId.namespaceUri = UA_STRING_NULL;
toNodeId.nodeId = tos->id;
UA_Server_addReference(ns->master->master,
n,
tys->id,
toNodeId,
true);
return node_wrap(cReferenceNode,node_alloc(ns->master,n));
}
|
#add_variable(*args) ⇒ Object
{{{
463 464 465 |
# File 'ext/opcua/server/server.c', line 463
static VALUE node_add_variable(int argc, VALUE* argv, VALUE self) { //{{{
return node_add_variable_wrap(argc,argv,self,UA_ACCESSLEVELMASK_READ,true);
}
|
#add_variable_rw(*args) ⇒ Object
{{{
466 467 468 |
# File 'ext/opcua/server/server.c', line 466
static VALUE node_add_variable_rw(int argc, VALUE* argv, VALUE self) { //{{{
return node_add_variable_wrap(argc,argv,self,UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE,true);
}
|
#add_variables(*item, &blk) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/opcua/server.rb', line 49 def add_variables(*item,&blk) item.each do |e| if blk.nil? add_variable e else add_variable e, &blk end end end |
#add_variables_rw(*item, &blk) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/opcua/server.rb', line 58 def add_variables_rw(*item,&blk) item.each do |e| if blk.nil? add_variable_rw e else add_variable_rw e, &blk end end end |
#delete! ⇒ Object
{{{
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 |
# File 'ext/opcua/server/server.c', line 872
static VALUE node_delete(VALUE self) { //{{{
node_struct *ns;
Data_Get_Struct(self, node_struct, ns);
if (!ns->exists) rb_raise(rb_eRuntimeError, "Node does not exist anymore.");
UA_StatusCode retval = UA_Server_deleteNode(ns->master->master, ns->id, true);
if (retval == UA_STATUSCODE_GOOD) {
ns->exists = false;
return Qtrue;
}
return Qfalse;
}
|