Class: OPCUA::Client
- Inherits:
-
Object
- Object
- OPCUA::Client
- Defined in:
- lib/opcua/client.rb,
ext/opcua/client/client.c
Defined Under Namespace
Classes: cMethodNode, cNode, cVarNode
Instance Method Summary collapse
-
#check_subscription ⇒ Object
{{{.
-
#debug ⇒ Object
{{{.
-
#debug=(val) ⇒ Object
{{{.
-
#default_ns ⇒ Object
{{{.
-
#default_ns=(val) ⇒ Object
{{{.
-
#disconnect ⇒ Object
{{{.
-
#get(*args) ⇒ Object
{{{.
- #get_base ⇒ Object
-
#initialize(url, user, pass) ⇒ Object
constructor
{{{.
- #initialize_base ⇒ Object
-
#namespaces ⇒ Object
{{{.
-
#subscription_interval ⇒ Object
{{{.
-
#subscription_interval=(val) ⇒ Object
{{{.
Constructor Details
#initialize(url, user, pass) ⇒ Object
{{{
216 217 218 219 220 221 222 |
# File 'ext/opcua/client/client.c', line 216 def initialize(url) if url =~ /(^[^:]+):\/\/([^:]+):([^@]+)@(.*)$/ initialize_base("#{$1}://#{$4}",$2,$3) else initialize_base(url,nil,nil) end end |
Instance Method Details
#check_subscription ⇒ Object
{{{
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
# File 'ext/opcua/client/client.c', line 556
static VALUE client_run(VALUE self) { //{{{
client_struct *pss;
Data_Get_Struct(self, client_struct, pss);
if (!pss->started) rb_raise(rb_eRuntimeError, "Client disconnected.");
if (pss->firstrun) {
pss->firstrun = false;
pss->subs_changed = false;
pss->subscription_response = UA_Client_Subscriptions_create(pss->master, pss->subscription_request, NULL, NULL, NULL);
if (pss->subscription_response.responseHeader.serviceResult != UA_STATUSCODE_GOOD)
rb_raise(rb_eRuntimeError, "Subscription could not be created.");
for (int i = 0; i < RARRAY_LEN(pss->subs); i++) {
client_run_iterate(rb_ary_entry(pss->subs,i));
}
}
UA_Client_run_iterate(pss->master, 100);
return self;
}
|
#debug ⇒ Object
{{{
412 413 414 415 416 417 418 |
# File 'ext/opcua/client/client.c', line 412
static VALUE client_debug(VALUE self) { //{{{
client_struct *pss;
Data_Get_Struct(self, client_struct, pss);
if (!pss->started) rb_raise(rb_eRuntimeError, "Client disconnected.");
return (pss->debug) ? Qtrue : Qfalse;
}
|
#debug=(val) ⇒ Object
{{{
419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'ext/opcua/client/client.c', line 419
static VALUE client_debug_set(VALUE self, VALUE val) { //{{{
client_struct *pss;
Data_Get_Struct(self, client_struct, pss);
if (!pss->started) rb_raise(rb_eRuntimeError, "Client disconnected.");
if (val == Qtrue) {
pss->config->logger = UA_Log_Stdout_;
pss->debug = Qtrue;
} else {
pss->config->logger = UA_Log_None_;
pss->debug = Qfalse;
}
return self;
}
|
#default_ns ⇒ Object
{{{
394 395 396 397 398 399 400 |
# File 'ext/opcua/client/client.c', line 394
static VALUE client_default_ns(VALUE self) { //{{{
client_struct *pss;
Data_Get_Struct(self, client_struct, pss);
if (!pss->started) rb_raise(rb_eRuntimeError, "Client disconnected.");
return UINT2NUM(pss->default_ns);
}
|
#default_ns=(val) ⇒ Object
{{{
401 402 403 404 405 406 407 408 409 410 411 |
# File 'ext/opcua/client/client.c', line 401
static VALUE client_default_ns_set(VALUE self, VALUE val) { //{{{
client_struct *pss;
Data_Get_Struct(self, client_struct, pss);
if (!pss->started) rb_raise(rb_eRuntimeError, "Client disconnected.");
if (NIL_P(val) || TYPE(val) != T_FIXNUM)
rb_raise(rb_eTypeError, "subscription interval is not an integer");
pss->default_ns = NUM2UINT(val);
return self;
}
|
#disconnect ⇒ Object
{{{
576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
# File 'ext/opcua/client/client.c', line 576
static VALUE client_disconnect(VALUE self) { //{{{
client_struct *pss;
Data_Get_Struct(self, client_struct, pss);
if (!pss->started) rb_raise(rb_eRuntimeError, "Client disconnected.");
if (!pss->firstrun) {
// do we need to delete the individual monResponse (#UA_MonitoredItemCreateResult_clear)?
UA_Client_Subscriptions_deleteSingle(pss->master,pss->subscription_response.subscriptionId);
}
UA_Client_disconnect(pss->master);
pss->started = false;
return self;
}
|
#get(*args) ⇒ Object
{{{
324 325 326 327 328 329 330 331 332 |
# File 'ext/opcua/client/client.c', line 324 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_base ⇒ Object
11 |
# File 'lib/opcua/client.rb', line 11 alias_method :get_base, :get |
#initialize_base ⇒ Object
10 |
# File 'lib/opcua/client.rb', line 10 alias_method :initialize_base, :initialize |
#namespaces ⇒ Object
{{{
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'ext/opcua/client/client.c', line 434
static VALUE client_namespaces(VALUE self) { //{{{
client_struct *pss;
Data_Get_Struct(self, client_struct, pss);
if (!pss->started) rb_raise(rb_eRuntimeError, "Client disconnected.");
UA_Variant value;
UA_Variant_init(&value);
UA_StatusCode retval = UA_Client_readValueAttribute(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);
}
|
#subscription_interval ⇒ Object
{{{
376 377 378 379 380 381 382 |
# File 'ext/opcua/client/client.c', line 376
static VALUE client_subscription_interval(VALUE self) { //{{{
client_struct *pss;
Data_Get_Struct(self, client_struct, pss);
if (!pss->started) rb_raise(rb_eRuntimeError, "Client disconnected.");
return UINT2NUM(pss->subscription_request.requestedPublishingInterval);
}
|
#subscription_interval=(val) ⇒ Object
{{{
383 384 385 386 387 388 389 390 391 392 393 |
# File 'ext/opcua/client/client.c', line 383
static VALUE client_subscription_interval_set(VALUE self, VALUE val) { //{{{
client_struct *pss;
Data_Get_Struct(self, client_struct, pss);
if (!pss->started) rb_raise(rb_eRuntimeError, "Client disconnected.");
if (NIL_P(val) || TYPE(val) != T_FIXNUM)
rb_raise(rb_eTypeError, "subscription interval is not an integer");
pss->subscription_request.requestedPublishingInterval = NUM2UINT(val);
return self;
}
|