Class: OPCUA::Server::ObjectNode
- Defined in:
- lib/opcua/server.rb,
ext/opcua/server/server.c
Instance Method Summary collapse
-
#delete! ⇒ Object
{{{.
-
#find(qname) ⇒ Object
{{{.
- #find_one ⇒ Object
-
#manifest(name, parent) ⇒ Object
{{{.
Methods inherited from Node
#description, #description=, #exists?, #id, #name, #to_s
Instance Method Details
#delete! ⇒ Object
{{{
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
# File 'ext/opcua/server/server.c', line 847
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;
}
|
#find(qname) ⇒ Object
{{{
719 720 721 722 723 724 725 726 727 |
# File 'ext/opcua/server/server.c', line 719 def find(*what) if what.length == 0 nil elsif what.length == 1 find_one what[0] else what.map{|e| find_one e} end end |
#find_one ⇒ Object
23 |
# File 'lib/opcua/server.rb', line 23 alias_method :find_one, :find |
#manifest(name, parent) ⇒ Object
{{{
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 |
# File 'ext/opcua/server/server.c', line 685
static VALUE node_manifest(VALUE self, VALUE name, VALUE parent) { //{{{
node_struct *ns;
node_struct *ts;
if (!(rb_obj_is_kind_of(parent,cTypeTopNode) || rb_obj_is_kind_of(parent,cTypeSubNode))) {
rb_raise(rb_eArgError, "argument 2 has to be a type.");
}
Data_Get_Struct(self, node_struct, ns);
if (!ns->exists) rb_raise(rb_eRuntimeError, "Node does not exist anymore.");
Data_Get_Struct(parent, node_struct, ts);
if (!ns->exists) rb_raise(rb_eRuntimeError, "Target 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);
char *nidstr = strnautocat(NULL,"",1);
if (ns->id.identifierType == UA_NODEIDTYPE_STRING) {
nidstr = strnautocat(nidstr,(char *)ns->id.identifier.string.data,ns->id.identifier.string.length);
nidstr = strnautocat(nidstr,"/",1);
}
nidstr = strnautocat(nidstr,nstr,strlen(nstr));
UA_NodeId n = UA_NODEID_STRING(ns->master->default_ns, nidstr);
node_struct *ret = node_alloc(ns->master,n);
node_struct *handle[2] = { ts, ret };
node_add_object_ua_rec(n,UA_LOCALIZEDTEXT("en-US", nstr),UA_QUALIFIEDNAME(ns->master->default_ns, nstr),ns,ts,ts->id,node_manifest_iter,(void *)handle);
return Data_Wrap_Struct(CLASS_OF(self), node_mark, node_free, ret);
}
|