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
Methods inherited from Node
#description, #description=, #id, #to_s
Instance Method Details
#add_method(*args) ⇒ Object
{{{
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'ext/opcua/server/server.c', line 257
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);
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
{{{
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'ext/opcua/server/server.c', line 405
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);
Data_Get_Struct(argv[1], node_struct, datatype);
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
{{{
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'ext/opcua/server/server.c', line 50
static VALUE node_add_object_type(VALUE self, VALUE name) { //{{{
node_struct *ns;
Data_Get_Struct(self, node_struct, ns);
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
{{{
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'ext/opcua/server/server.c', line 136
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 (!(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);
Data_Get_Struct(type, node_struct, tys);
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
{{{
337 338 339 |
# File 'ext/opcua/server/server.c', line 337
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
{{{
340 341 342 |
# File 'ext/opcua/server/server.c', line 340
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 |