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

{{{



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

#find(qname) ⇒ Object

{{{



598
599
600
601
602
603
604
605
606
# File 'ext/opcua/server/server.c', line 598

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

{{{



564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
# File 'ext/opcua/server/server.c', line 564

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), NULL, node_free, ret);
}