Class: OPCUA::Client::cNode

Inherits:
Object
  • Object
show all
Defined in:
ext/opcua/client/client.c

Direct Known Subclasses

cMethodNode, cVarNode

Instance Method Summary collapse

Instance Method Details

#idObject

{{{



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'ext/opcua/client/client.c', line 460

static VALUE node_id(VALUE self) { //{{{
  node_struct *ns;

  Data_Get_Struct(self, node_struct, ns);

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

#to_sObject

{{{



478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'ext/opcua/client/client.c', line 478

static VALUE node_to_s(VALUE self) { //{{{
  node_struct *ns;
  VALUE ret;

  Data_Get_Struct(self, node_struct, ns);

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

#unsubscribeObject

{{{



493
494
495
496
497
498
499
500
501
502
503
504
505
506
# File 'ext/opcua/client/client.c', line 493

static VALUE unsubscribe(VALUE self) { //{{{
  node_struct *ns;

  Data_Get_Struct(self, node_struct, ns);

  if (ns->master->subrun && ns->monId > 0) {
    UA_Client_MonitoredItems_deleteSingle(ns->master->master, ns->master->subscription_response.subscriptionId, ns->monId);
    ns->monId = 0;
    rb_ary_delete(ns->master->subs, self);
    return Qtrue;
  } else {
    return Qfalse;
  }
}