opcua 0.25 → 0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/example/client_subscription.rb +6 -0
- data/ext/opcua/client/client.c +30 -14
- data/ext/opcua/client/client.h +2 -2
- data/ext/opcua/helpers/finders.c +0 -6
- data/ext/opcua/server/server.c +1 -1
- data/opcua.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0bd449baa58c495096569ded2e6a50df7e0554ff273b0c853ae8302dc33e544
|
4
|
+
data.tar.gz: b6d8ee15542d9be07673ea0522c88f19e0309261ff454cf47f4f1d3b8b8fc927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 880f9af425e78f1dfd71e30383b4133201e1af01bd23de16c96a18e5ca0e75d0696b856d3453d8ea75fce4578f2574b823645b0ca39671c0fb626855e9dbc159
|
7
|
+
data.tar.gz: f695ee96bdfe1c19a632698b25171e08142b425cd1eeca2f10cb1f72fed7b58cc996bddedf4f833f072b2016696772b37c87a6def87f3ddef7549724321ab813
|
data/README.md
CHANGED
@@ -50,6 +50,8 @@ sudo make install
|
|
50
50
|
gem install opcua
|
51
51
|
```
|
52
52
|
|
53
|
+
If you get errors during compilation, please file an issue in github. Maybe the API open62541 API changed (constant improvements are happening).
|
54
|
+
|
53
55
|
If the installation works correctly, but examples are still complaining about missing lib62541.so, try this:
|
54
56
|
|
55
57
|
```sh
|
@@ -9,8 +9,14 @@ client = OPCUA::Client.new("opc.tcp://localhost:4840")
|
|
9
9
|
client.subscription_interval = 100 # default 500
|
10
10
|
|
11
11
|
node = client.get 2, '/KalimatC34/Tools/Tool1/ToolNumber' # get node from nodeid
|
12
|
+
n2 = client.get 2, '/KalimatC34/Tools/Tool2/ToolNumber' # get node from nodeid
|
13
|
+
p node.unsubscribe
|
12
14
|
node.on_change do |value,timestamp|
|
13
15
|
p value
|
16
|
+
if value == 2
|
17
|
+
p 'unsub'
|
18
|
+
p node.unsubscribe
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
16
22
|
while true
|
data/ext/opcua/client/client.c
CHANGED
@@ -33,6 +33,7 @@ static node_struct * node_alloc(client_struct *client, UA_NodeId nodeid) { //{{{
|
|
33
33
|
ns->id = nodeid;
|
34
34
|
ns->on_change = Qnil;
|
35
35
|
ns->waiting = 0;
|
36
|
+
ns->monId = 0;
|
36
37
|
|
37
38
|
return ns;
|
38
39
|
} //}}}
|
@@ -99,7 +100,6 @@ static VALUE node_on_change(VALUE self) { //{{{
|
|
99
100
|
rb_gc_register_address(&ns->on_change);
|
100
101
|
|
101
102
|
rb_ary_push(ns->master->subs,self);
|
102
|
-
ns->master->subs_changed = true;
|
103
103
|
|
104
104
|
return self;
|
105
105
|
} //}}}
|
@@ -184,7 +184,7 @@ static VALUE node_on_value_change(VALUE self) { // {{{
|
|
184
184
|
/* -- */
|
185
185
|
static void client_free(client_struct *pss) { //{{{
|
186
186
|
if (pss != NULL) {
|
187
|
-
if (
|
187
|
+
if (pss->subrun) {
|
188
188
|
// do we need to delete the individual monResponse (#UA_MonitoredItemCreateResult_clear)?
|
189
189
|
UA_Client_Subscriptions_deleteSingle(pss->master,pss->subscription_response.subscriptionId);
|
190
190
|
}
|
@@ -201,11 +201,10 @@ static VALUE client_alloc(VALUE self) { //{{{
|
|
201
201
|
|
202
202
|
pss->master = UA_Client_new();
|
203
203
|
pss->config = UA_Client_getConfig(pss->master);
|
204
|
-
pss->
|
204
|
+
pss->subrun = false;
|
205
205
|
pss->started = true;
|
206
206
|
pss->debug = true;
|
207
207
|
pss->subs = rb_ary_new();
|
208
|
-
pss->subs_changed = false;
|
209
208
|
pss->subscription_interval = 500;
|
210
209
|
pss->default_ns = 2;
|
211
210
|
|
@@ -491,6 +490,20 @@ static VALUE node_to_s(VALUE self) { //{{{
|
|
491
490
|
}
|
492
491
|
return ret;
|
493
492
|
} //}}}
|
493
|
+
static VALUE unsubscribe(VALUE self) { //{{{
|
494
|
+
node_struct *ns;
|
495
|
+
|
496
|
+
Data_Get_Struct(self, node_struct, ns);
|
497
|
+
|
498
|
+
if (ns->master->subrun && ns->monId > 0) {
|
499
|
+
UA_Client_MonitoredItems_deleteSingle(ns->master->master, ns->master->subscription_response.subscriptionId, ns->monId);
|
500
|
+
ns->monId = 0;
|
501
|
+
rb_ary_delete(ns->master->subs, self);
|
502
|
+
return Qtrue;
|
503
|
+
} else {
|
504
|
+
return Qfalse;
|
505
|
+
}
|
506
|
+
} //}}}
|
494
507
|
|
495
508
|
static VALUE node_call(int argc, VALUE* argv, VALUE self) { //{{{
|
496
509
|
node_struct *ns;
|
@@ -553,7 +566,7 @@ static VALUE node_call(int argc, VALUE* argv, VALUE self) { //{{{
|
|
553
566
|
}
|
554
567
|
} //}}}
|
555
568
|
|
556
|
-
static void
|
569
|
+
static void client_run_handler(UA_Client *client, UA_UInt32 subId, void *subContext, UA_UInt32 monId, void *monContext, UA_DataValue *value) { //{{{
|
557
570
|
VALUE val = (VALUE)monContext;
|
558
571
|
|
559
572
|
if (NIL_P(val) || TYPE(val) != T_NIL) {
|
@@ -573,7 +586,7 @@ static void client_run_handler(UA_Client *client, UA_UInt32 subId, void *subCon
|
|
573
586
|
rb_proc_call(val,args);
|
574
587
|
}
|
575
588
|
} //}}}
|
576
|
-
static void
|
589
|
+
static void client_run_iterate(VALUE key) { //{{{
|
577
590
|
node_struct *ns;
|
578
591
|
Data_Get_Struct(key, node_struct, ns);
|
579
592
|
|
@@ -583,26 +596,28 @@ static void client_run_iterate(VALUE key) { //{{{
|
|
583
596
|
UA_Client_MonitoredItems_createDataChange(ns->master->master, ns->master->subscription_response.subscriptionId,
|
584
597
|
UA_TIMESTAMPSTORETURN_BOTH,
|
585
598
|
monRequest, (void *)ns->on_change, client_run_handler, NULL);
|
599
|
+
ns->monId = monResponse.monitoredItemId;
|
586
600
|
|
587
601
|
if(monResponse.statusCode != UA_STATUSCODE_GOOD) {
|
588
602
|
rb_raise(rb_eRuntimeError, "Monitoring item failed: %s\n", UA_StatusCode_name(monResponse.statusCode));
|
589
603
|
}
|
604
|
+
UA_MonitoredItemCreateResult_clear(&monResponse);
|
605
|
+
UA_MonitoredItemCreateRequest_clear(&monRequest);
|
590
606
|
} //}}}
|
591
607
|
static VALUE client_run(VALUE self) { //{{{
|
592
608
|
client_struct *pss;
|
593
609
|
Data_Get_Struct(self, client_struct, pss);
|
594
610
|
if (!pss->started) rb_raise(rb_eRuntimeError, "Client disconnected.");
|
595
611
|
|
596
|
-
if (pss->
|
597
|
-
pss->
|
598
|
-
pss->subs_changed = false;
|
612
|
+
if (!pss->subrun) {
|
613
|
+
pss->subrun = true;
|
599
614
|
pss->subscription_response = UA_Client_Subscriptions_create(pss->master, pss->subscription_request, NULL, NULL, NULL);
|
600
615
|
if (pss->subscription_response.responseHeader.serviceResult != UA_STATUSCODE_GOOD)
|
601
616
|
rb_raise(rb_eRuntimeError, "Subscription could not be created.");
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
617
|
+
}
|
618
|
+
while (RARRAY_LEN(pss->subs)>0) {
|
619
|
+
VALUE aentry = rb_ary_pop(pss->subs);
|
620
|
+
client_run_iterate(aentry);
|
606
621
|
}
|
607
622
|
UA_Client_run_iterate(pss->master, 100);
|
608
623
|
|
@@ -613,7 +628,7 @@ static VALUE client_disconnect(VALUE self) { //{{{
|
|
613
628
|
Data_Get_Struct(self, client_struct, pss);
|
614
629
|
if (!pss->started) rb_raise(rb_eRuntimeError, "Client disconnected.");
|
615
630
|
|
616
|
-
if (
|
631
|
+
if (pss->subrun) {
|
617
632
|
// do we need to delete the individual monResponse (#UA_MonitoredItemCreateResult_clear)?
|
618
633
|
UA_Client_Subscriptions_deleteSingle(pss->master,pss->subscription_response.subscriptionId);
|
619
634
|
}
|
@@ -648,6 +663,7 @@ void Init_client(void) {
|
|
648
663
|
|
649
664
|
rb_define_method(cNode, "to_s", node_to_s, 0);
|
650
665
|
rb_define_method(cNode, "id", node_id, 0);
|
666
|
+
rb_define_method(cNode, "unsubscribe", unsubscribe, 0);
|
651
667
|
|
652
668
|
rb_define_method(cMethodNode, "call", node_call, -1);
|
653
669
|
|
data/ext/opcua/client/client.h
CHANGED
@@ -11,11 +11,10 @@ typedef struct client_struct {
|
|
11
11
|
UA_CreateSubscriptionResponse subscription_response;
|
12
12
|
|
13
13
|
UA_UInt32 subscription_interval;
|
14
|
-
bool
|
14
|
+
bool subrun;
|
15
15
|
bool started;
|
16
16
|
bool debug;
|
17
17
|
VALUE subs;
|
18
|
-
bool subs_changed;
|
19
18
|
UA_UInt16 default_ns;
|
20
19
|
} client_struct;
|
21
20
|
|
@@ -23,5 +22,6 @@ typedef struct node_struct {
|
|
23
22
|
client_struct *master;
|
24
23
|
VALUE on_change;
|
25
24
|
UA_NodeId id;
|
25
|
+
UA_UInt32 monId;
|
26
26
|
int waiting;
|
27
27
|
} node_struct;
|
data/ext/opcua/helpers/finders.c
CHANGED
@@ -39,7 +39,6 @@ bool server_node_get_reference(UA_Server *server, UA_NodeId parent, UA_NodeId *r
|
|
39
39
|
// qn.name.data
|
40
40
|
// );
|
41
41
|
|
42
|
-
UA_BrowseResult_deleteMembers(&bRes);
|
43
42
|
UA_BrowseResult_clear(&bRes);
|
44
43
|
return true;
|
45
44
|
}
|
@@ -63,13 +62,11 @@ bool server_node_get_reference_by_name(UA_Server *server, UA_NodeId parent, UA_Q
|
|
63
62
|
if (UA_QualifiedName_equal(&qn,&name)) {
|
64
63
|
UA_NodeId_copy(&ref->nodeId.nodeId,result);
|
65
64
|
|
66
|
-
UA_BrowseResult_deleteMembers(&bRes);
|
67
65
|
UA_BrowseResult_clear(&bRes);
|
68
66
|
return true;
|
69
67
|
}
|
70
68
|
}
|
71
69
|
|
72
|
-
UA_BrowseResult_deleteMembers(&bRes);
|
73
70
|
UA_BrowseResult_clear(&bRes);
|
74
71
|
return false;
|
75
72
|
}
|
@@ -100,7 +97,6 @@ bool client_node_get_reference_by_name(UA_Client *client, UA_NodeId parent, UA_Q
|
|
100
97
|
}
|
101
98
|
}
|
102
99
|
|
103
|
-
UA_BrowseResponse_deleteMembers(&bResp);
|
104
100
|
UA_BrowseResponse_clear(&bResp);
|
105
101
|
return success;
|
106
102
|
}
|
@@ -126,7 +122,6 @@ bool client_node_get_reference_by_type(UA_Client *client, UA_NodeId parent, UA_N
|
|
126
122
|
}
|
127
123
|
}
|
128
124
|
|
129
|
-
UA_BrowseResponse_deleteMembers(&bResp);
|
130
125
|
UA_BrowseResponse_clear(&bResp);
|
131
126
|
return success;
|
132
127
|
}
|
@@ -164,7 +159,6 @@ bool client_node_list_references(UA_Client *client, UA_NodeId parent, bool inver
|
|
164
159
|
|
165
160
|
}
|
166
161
|
}
|
167
|
-
UA_BrowseResponse_deleteMembers(&bResp);
|
168
162
|
UA_BrowseResponse_clear(&bResp);
|
169
163
|
return false;
|
170
164
|
}
|
data/ext/opcua/server/server.c
CHANGED
data/opcua.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "opcua"
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.26"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.license = "LGPL-3.0"
|
6
6
|
s.summary = "Preliminary release of opcua (open62541) ruby bindings. C performance, Ruby elegance, simplicity, and productivity."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opcua
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.26'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen eTM Mangler
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: tools
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-02-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: daemonite
|