Class: OPCUA::Server::Node
- Inherits:
-
Object
- Object
- OPCUA::Server::Node
- Defined in:
- ext/opcua/server/server.c
Direct Known Subclasses
ObjectMethodNode, ObjectNode, ObjectReferenceNode, ObjectVarNode, ReferenceSubNode, ReferenceTopNode, TypeSubNode, TypeTopNode
Instance Method Summary collapse
-
#description ⇒ Object
{{{.
-
#description=(value) ⇒ Object
{{{.
-
#exists? ⇒ Boolean
{{{.
-
#id ⇒ Object
{{{.
-
#name ⇒ Object
{{{.
-
#to_s ⇒ Object
{{{.
Instance Method Details
#description ⇒ Object
{{{
910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 |
# File 'ext/opcua/server/server.c', line 910
static VALUE node_description(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_LocalizedText value;
UA_LocalizedText_init(&value);
UA_StatusCode retval = UA_Server_readDescription(ns->master->master, ns->id, &value);
VALUE ret = Qnil;
if (retval == UA_STATUSCODE_GOOD) {
ret = rb_str_export_locale(rb_str_new((char *)(value.text.data),value.text.length));
}
UA_LocalizedText_clear(&value);
return ret;
}
|
#description=(value) ⇒ Object
{{{
896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
# File 'ext/opcua/server/server.c', line 896
static VALUE node_description_set(VALUE self, VALUE value) { //{{{
node_struct *ns;
Data_Get_Struct(self, node_struct, ns);
if (!ns->exists) rb_raise(rb_eRuntimeError, "Node does not exist anymore.");
VALUE str = rb_obj_as_string(value);
if (NIL_P(str) || TYPE(str) != T_STRING)
rb_raise(rb_eTypeError, "cannot convert obj to string");
char *nstr = (char *)StringValuePtr(str);
UA_LocalizedText lt = UA_LOCALIZEDTEXT("en-US",nstr);
UA_Server_writeDescription(ns->master->master, ns->id, lt);
return self;
}
|
#exists? ⇒ Boolean
{{{
887 888 889 890 891 892 893 894 895 |
# File 'ext/opcua/server/server.c', line 887
static VALUE node_exists(VALUE self) { //{{{
node_struct *ns;
Data_Get_Struct(self, node_struct, ns);
if (ns->exists)
return Qtrue;
else
return Qfalse;
}
|
#id ⇒ Object
{{{
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'ext/opcua/server/server.c', line 126
static VALUE node_id(VALUE self) { //{{{
node_struct *ns;
Data_Get_Struct(self, node_struct, ns);
if (!ns->exists) rb_raise(rb_eRuntimeError, "Node does not exist anymore.");
VALUE ret = rb_ary_new();
rb_ary_push(ret,UINT2NUM(ns->id.namespaceIndex));
if (ns->id.identifierType == UA_NODEIDTYPE_NUMERIC) {
VALUE id = UINT2NUM((UA_UInt32)(ns->id.identifier.numeric));
rb_ary_push(ret,id);
} else if (ns->id.identifierType == UA_NODEIDTYPE_STRING) {
rb_ary_push(ret,rb_str_new((const char *)ns->id.identifier.string.data,ns->id.identifier.string.length));
} else if (ns->id.identifierType == UA_NODEIDTYPE_BYTESTRING) {
rb_ary_push(ret,rb_str_new((const char *)ns->id.identifier.byteString.data,ns->id.identifier.byteString.length));
}
return ret;
}
|
#name ⇒ Object
{{{
145 146 147 148 149 150 151 152 153 154 155 |
# File 'ext/opcua/server/server.c', line 145
static VALUE node_name(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_QualifiedName qn; UA_QualifiedName_init(&qn);
UA_Server_readBrowseName(ns->master->master, ns->id, &qn);
return rb_sprintf("%.*s", (int)qn.name.length, qn.name.data);
}
|
#to_s ⇒ Object
{{{
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'ext/opcua/server/server.c', line 156
static VALUE node_to_s(VALUE self) { //{{{
node_struct *ns;
VALUE ret;
Data_Get_Struct(self, node_struct, ns);
if (!ns->exists) rb_raise(rb_eRuntimeError, "Node does not exist anymore.");
if (ns->id.identifierType == UA_NODEIDTYPE_NUMERIC) {
ret = rb_sprintf("ns=%d;i=%d", ns->id.namespaceIndex, ns->id.identifier.numeric);
} else if(ns->id.identifierType == UA_NODEIDTYPE_STRING) {
ret = rb_sprintf("ns=%d;s=%.*s", ns->id.namespaceIndex, (int)ns->id.identifier.string.length, ns->id.identifier.string.data);
} else {
ret = rb_sprintf("ns=%d;unsupported",ns->id.namespaceIndex);
}
return ret;
}
|