Class: OPCUA::Server

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

Defined Under Namespace

Classes: Node, ObjectMethodNode, ObjectNode, ObjectReferenceNode, ObjectVarNode, ReferenceSubNode, ReferenceTopNode, TypeSubNode, TypeTopNode

Instance Method Summary collapse

Constructor Details

#initializeObject

{{{



959
960
961
962
963
964
965
966
967
968
969
# File 'ext/opcua/server/server.c', line 959

static VALUE server_init(VALUE self) { //{{{
  server_struct *pss;

  Data_Get_Struct(self, server_struct, pss);

  UA_StatusCode retval = UA_Server_run_startup(pss->master);
  if (retval != UA_STATUSCODE_GOOD)
    rb_raise(rb_eRuntimeError, "Server could not be started.");

  return self;
}

Instance Method Details

#active_namespaceObject

{{{



1044
1045
1046
1047
1048
# File 'ext/opcua/server/server.c', line 1044

static VALUE server_active_namespace(VALUE self) { //{{{
  server_struct *pss;
  Data_Get_Struct(self, server_struct, pss);
  return UINT2NUM(pss->default_ns);
}

#active_namespace=(val) ⇒ Object

{{{



1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
# File 'ext/opcua/server/server.c', line 1049

static VALUE server_active_namespace_set(VALUE self, VALUE val) { //{{{
  server_struct *pss;
  Data_Get_Struct(self, server_struct, pss);

  if (NIL_P(val) || TYPE(val) != T_FIXNUM)
    rb_raise(rb_eTypeError, "namespace is not an integer");

  pss->default_ns = NUM2UINT(val);
  return self;
}

#add_namespace(name) ⇒ Object

{{{



979
980
981
982
983
984
985
986
987
988
989
990
991
992
# File 'ext/opcua/server/server.c', line 979

static VALUE server_add_namespace(VALUE self, VALUE name) { //{{{
  server_struct *pss;

  Data_Get_Struct(self, server_struct, pss);

  VALUE str;
  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);

  pss->default_ns = UA_Server_addNamespace(pss->master, nstr);
  return INT2NUM(pss->default_ns);
}

#debugObject

{{{



1008
1009
1010
1011
1012
1013
# File 'ext/opcua/server/server.c', line 1008

static VALUE server_debug(VALUE self) { //{{{
  server_struct *pss;
  Data_Get_Struct(self, server_struct, pss);

  return (pss->debug) ? Qtrue : Qfalse;
}

#debug=(val) ⇒ Object

{{{



1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
# File 'ext/opcua/server/server.c', line 1014

static VALUE server_debug_set(VALUE self, VALUE val) { //{{{
  server_struct *pss;
  Data_Get_Struct(self, server_struct, pss);

  if (val == Qtrue) {
    pss->config->logger = UA_Log_Stdout_;
    pss->debug = Qtrue;
  } else {
    pss->config->logger = UA_Log_None_;
    pss->debug = Qfalse;
  }
  return self;
}

#get(*args) ⇒ Object

{{{



781
782
783
784
785
786
787
788
789
# File 'ext/opcua/server/server.c', line 781

def get(*a)
  if a.length == 1 && a[0].to_s =~ /ns=(\d+);i=(.*)/
    get_base $1.to_i, $2.to_i
  elsif a.length == 1 && a[0].to_s =~ /ns=(\d+);s=(.*)/
    get_base $1.to_i, $2
  else
    get_base *a
  end
end

#get_baseObject



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

alias_method :get_base, :get

#namespacesObject

{{{



1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
# File 'ext/opcua/server/server.c', line 1027

static VALUE server_namespaces(VALUE self) { //{{{
  server_struct *pss;
  Data_Get_Struct(self, server_struct, pss);

  UA_Variant value;
  UA_Variant_init(&value);
  UA_StatusCode retval = UA_Server_readValue(pss->master, UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_NAMESPACEARRAY), &value);

  VALUE ret = Qnil;
  if (retval == UA_STATUSCODE_GOOD) {
    ret = extract_value(value);
  }

  UA_Variant_clear(&value);
  RB_OBJ_FREEZE(ret);
  return rb_ary_entry(ret,0);
}

#objectsObject

{{{



1003
1004
1005
1006
1007
# File 'ext/opcua/server/server.c', line 1003

static VALUE server_objects(VALUE self) { //{{{
  server_struct *pss;
  Data_Get_Struct(self, server_struct, pss);
  return node_wrap(cObjectNode, node_alloc(pss, UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER)));
}

#referencesObject

{{{



998
999
1000
1001
1002
# File 'ext/opcua/server/server.c', line 998

static VALUE server_references(VALUE self) { //{{{
  server_struct *pss;
  Data_Get_Struct(self, server_struct, pss);
  return node_wrap(cReferenceTopNode, node_alloc(pss, UA_NODEID_NUMERIC(0, UA_NS0ID_NONHIERARCHICALREFERENCES)));
}

#runObject

{{{



970
971
972
973
974
975
976
977
978
# File 'ext/opcua/server/server.c', line 970

static VALUE server_run(VALUE self) { //{{{
  server_struct *pss;

  Data_Get_Struct(self, server_struct, pss);

  UA_UInt16 timeout = UA_Server_run_iterate(pss->master, false);

  return rb_float_new(timeout/1000.0);
}

#typesObject

{{{



993
994
995
996
997
# File 'ext/opcua/server/server.c', line 993

static VALUE server_types(VALUE self) { //{{{
  server_struct *pss;
  Data_Get_Struct(self, server_struct, pss);
  return node_wrap(cTypeTopNode, node_alloc(pss, UA_NODEID_NUMERIC(0, UA_NS0ID_BASEOBJECTTYPE)));
}