Class: OPCUA::Server::ObjectNode

Inherits:
Node
  • Object
show all
Defined in:
lib/opcua/server.rb,
ext/opcua/server/server.c

Instance Method Summary collapse

Methods inherited from Node

#description, #description=, #exists?, #id, #name, #to_s

Instance Method Details

#delete!Object

{{{



784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
# File 'ext/opcua/server/server.c', line 784

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

{{{



656
657
658
659
660
661
662
663
664
# File 'ext/opcua/server/server.c', line 656

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_oneObject



23
# File 'lib/opcua/server.rb', line 23

alias_method :find_one, :find

#manifest(name, parent) ⇒ Object

{{{



622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
# File 'ext/opcua/server/server.c', line 622

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);
}