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) ⇒ Object
- #add_variables_rw(*item) ⇒ Object
-
#delete! ⇒ Object
{{{.
Methods inherited from Node
#description, #description=, #exists?, #id, #name, #to_s
Instance Method Details
#add_method(*args) ⇒ Object
{{{
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'ext/opcua/server/server.c', line 277 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
{{{
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
# File 'ext/opcua/server/server.c', line 427 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]))); } |
#add_object_type(name) ⇒ Object
{{{
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'ext/opcua/server/server.c', line 52 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
{{{
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'ext/opcua/server/server.c', line 153 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
{{{
359 360 361 |
# File 'ext/opcua/server/server.c', line 359 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
{{{
362 363 364 |
# File 'ext/opcua/server/server.c', line 362 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) ⇒ Object
49 50 51 |
# File 'lib/opcua/server.rb', line 49 def add_variables(*item) item.each { |e| add_variable e } end |
#add_variables_rw(*item) ⇒ Object
52 53 54 |
# File 'lib/opcua/server.rb', line 52 def add_variables_rw(*item) item.each { |e| add_variable_rw e } end |
#delete! ⇒ Object
{{{
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
# File 'ext/opcua/server/server.c', line 725 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; } |