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

{{{



872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
# File 'ext/opcua/server/server.c', line 872

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

{{{



744
745
746
747
748
749
750
751
752
# File 'ext/opcua/server/server.c', line 744

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

{{{



710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
# File 'ext/opcua/server/server.c', line 710

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