opcua 0.21 → 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 +16 -1
- data/cert/cert.h +52 -52
- data/cert/cert_key.h +99 -99
- data/example/client_subscription.rb +6 -0
- data/example/server_values_callback.rb +43 -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 +109 -21
- data/lib/opcua/server.rb +16 -4
- data/opcua.gemspec +2 -2
- metadata +8 -6
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
|
@@ -122,11 +124,24 @@ Multible variables can be defined at once with the ```.add_variables``` command.
|
|
122
124
|
t.add_variables :TestVar1, :TestVar2
|
123
125
|
```
|
124
126
|
By default variables are read-only.
|
125
|
-
If you want to add a variable with read/write support you must use the ```.
|
127
|
+
If you want to add a variable with read/write support you must use the ```.add_variable_rw``` method.
|
126
128
|
```ruby
|
127
129
|
t.add_variable_rw :TestVar1
|
128
130
|
```
|
129
131
|
|
132
|
+
It is also possible to add a block to the variable. The block is called
|
133
|
+
whenever the variable is changed. Each block gets three parameters passed:
|
134
|
+
nodeid, new value, and if the value has been changed through a client (true) or
|
135
|
+
internally in the server (false).
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
t.add_variable_rw :Value do |node,value,external|
|
139
|
+
p node.id # ObjectVarNode object, which has properties such as #id, #value
|
140
|
+
p value # new content of the variable
|
141
|
+
p external # true || false
|
142
|
+
end
|
143
|
+
```
|
144
|
+
|
130
145
|
##### Add Object
|
131
146
|
|
132
147
|
With ```.add_object(:TestObject)``` a new object named _TestObject_ is added. The second parameter is optional and definies of which type the new object is. Default the object is from _BaseObjectType_. In this example the created object is from _FolderType_. All child nodes of the object can be definded in the ```tap{}``` area.
|
data/cert/cert.h
CHANGED
@@ -1,70 +1,70 @@
|
|
1
1
|
unsigned char cert_der[] = {
|
2
2
|
0x30, 0x82, 0x03, 0x18, 0x30, 0x82, 0x02, 0x00, 0xa0, 0x03, 0x02, 0x01,
|
3
|
-
0x02, 0x02, 0x14,
|
4
|
-
|
3
|
+
0x02, 0x02, 0x14, 0x11, 0x2f, 0x7b, 0xb4, 0x32, 0x5f, 0x6d, 0xe3, 0x4f,
|
4
|
+
0x2c, 0x3a, 0x98, 0xb9, 0x10, 0xb5, 0x3a, 0x2b, 0xfa, 0xc1, 0x30, 0x30,
|
5
5
|
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b,
|
6
6
|
0x05, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04,
|
7
7
|
0x03, 0x0c, 0x0a, 0x72, 0x75, 0x62, 0x79, 0x2d, 0x6f, 0x70, 0x63, 0x75,
|
8
|
-
0x61, 0x30, 0x1e, 0x17, 0x0d, 0x32,
|
9
|
-
|
10
|
-
|
8
|
+
0x61, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x31, 0x32, 0x37, 0x31,
|
9
|
+
0x36, 0x30, 0x30, 0x32, 0x39, 0x5a, 0x17, 0x0d, 0x32, 0x32, 0x30, 0x31,
|
10
|
+
0x31, 0x37, 0x31, 0x36, 0x30, 0x30, 0x32, 0x39, 0x5a, 0x30, 0x15, 0x31,
|
11
11
|
0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0a, 0x72, 0x75,
|
12
12
|
0x62, 0x79, 0x2d, 0x6f, 0x70, 0x63, 0x75, 0x61, 0x30, 0x82, 0x01, 0x22,
|
13
13
|
0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
|
14
14
|
0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a,
|
15
|
-
0x02, 0x82, 0x01, 0x01, 0x00,
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
15
|
+
0x02, 0x82, 0x01, 0x01, 0x00, 0xb0, 0xb5, 0x71, 0x62, 0xfe, 0x5b, 0xb7,
|
16
|
+
0xc2, 0xbc, 0x0e, 0x37, 0xf4, 0xa3, 0x73, 0x29, 0x2e, 0x6e, 0x19, 0x53,
|
17
|
+
0x60, 0xeb, 0xfe, 0x18, 0x78, 0xda, 0xf6, 0xbd, 0xc2, 0x2c, 0xdf, 0x1e,
|
18
|
+
0x45, 0x08, 0xef, 0x98, 0xe8, 0x14, 0x43, 0xb2, 0x82, 0x48,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0xd4, 0x4b, 0x92, 0x78,
|
33
|
+
0x68, 0x17, 0x51, 0xa5, 0x0d, 0x3a, 0xe9, 0xde, 0x59, 0xfa, 0x92, 0x30,
|
34
|
+
0x12, 0xc7, 0x72, 0x4b, 0xf3, 0x3b, 0xbf, 0x7d, 0x95, 0x55, 0x48, 0x8e,
|
35
|
+
0x68, 0x8a, 0xf7, 0x49, 0x66, 0x77, 0x77, 0xb2, 0xd5, 0x1b, 0x09, 0xa1,
|
36
|
+
0xa6, 0xf4, 0x2c, 0xec, 0x4f, 0xdf, 0xf1, 0xf4, 0x83, 0x02, 0x03, 0x01,
|
37
37
|
0x00, 0x01, 0xa3, 0x60, 0x30, 0x5e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d,
|
38
|
-
0x0e, 0x04, 0x16, 0x04, 0x14,
|
39
|
-
|
40
|
-
|
38
|
+
0x0e, 0x04, 0x16, 0x04, 0x14, 0x94, 0x96, 0x95, 0x63, 0xe7, 0xf5, 0x26,
|
39
|
+
0x38, 0x3e, 0xdf, 0x99, 0xec, 0x11, 0x08, 0xaf, 0x91, 0xde, 0xc6, 0x01,
|
40
|
+
0x44, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04,
|
41
41
|
0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x1d,
|
42
42
|
0x11, 0x04, 0x15, 0x30, 0x13, 0x86, 0x11, 0x72, 0x75, 0x62, 0x79, 0x2d,
|
43
43
|
0x6f, 0x70, 0x63, 0x75, 0x61, 0x3a, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74,
|
44
44
|
0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04,
|
45
45
|
0x03, 0x02, 0x05, 0xa0, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
|
46
46
|
0xf7, 0x0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, 0xf1, 0xab, 0x02, 0xad,
|
58
|
+
0xa9, 0x66, 0x97, 0x25, 0xb9, 0x9d, 0xce, 0xab, 0xa6, 0x5d, 0xbb, 0xf0,
|
59
|
+
0x1d, 0x0e, 0x1b, 0x2a, 0x80, 0x67, 0xa8, 0x7d, 0x03, 0xab, 0x07, 0x5a,
|
60
|
+
0x48, 0xf5, 0x6e, 0x67, 0x9d, 0x9c, 0xdb, 0xce, 0x79, 0x4e, 0x35, 0x22,
|
61
|
+
0x64, 0x97, 0x75, 0xe6, 0x32, 0x70, 0xf0, 0x32, 0xc3, 0x7c, 0x02, 0x5b,
|
62
|
+
0x6e, 0x82, 0x89, 0xa3, 0xd1, 0x33, 0x69, 0x0f, 0xf8, 0x1a, 0x3e, 0x35,
|
63
|
+
0x35, 0x0e, 0xe0, 0x54, 0x0f, 0x49, 0x00, 0xdc, 0x57, 0x89, 0x7b, 0x8b,
|
64
|
+
0x1c, 0x3b, 0xcc, 0x18, 0x81, 0x39, 0xfc, 0x80, 0x61, 0xc9, 0xc7, 0xd6,
|
65
|
+
0x9e, 0x5b, 0xfe, 0x54, 0x3b, 0x15, 0x9e, 0x9c, 0x8e, 0xe4, 0xb1, 0x77,
|
66
|
+
0x7a, 0x81, 0xfd, 0xc0, 0x75, 0x3b, 0xd9, 0xb3, 0x98, 0x4c, 0xa4, 0x53,
|
67
|
+
0xd0, 0xc3, 0xa8, 0x70, 0x95, 0x86, 0x1e, 0xc4, 0x77, 0xa4, 0x2f, 0x13,
|
68
|
+
0xe6, 0x36, 0x51, 0x1a
|
69
69
|
};
|
70
70
|
unsigned int cert_der_len = 796;
|
data/cert/cert_key.h
CHANGED
@@ -1,103 +1,103 @@
|
|
1
1
|
unsigned char cert_key_der[] = {
|
2
2
|
0x30, 0x82, 0x04, 0xa3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00,
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
3
|
+
0xb0, 0xb5, 0x71, 0x62, 0xfe, 0x5b, 0xb7, 0xc2, 0xbc, 0x0e, 0x37, 0xf4,
|
4
|
+
0xa3, 0x73, 0x29, 0x2e, 0x6e, 0x19, 0x53, 0x60, 0xeb, 0xfe, 0x18, 0x78,
|
5
|
+
0xda, 0xf6, 0xbd, 0xc2, 0x2c, 0xdf, 0x1e, 0x45, 0x08, 0xef, 0x98, 0xe8,
|
6
|
+
0x14, 0x43, 0xb2, 0x82, 0x48, 0xa8, 0x85, 0xc1, 0x96, 0x19, 0x6c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4, 0x63, 0x41, 0x84,
|
90
|
+
0x60, 0x7f, 0x66, 0xe1, 0x02, 0x81, 0x80, 0x65, 0x47, 0x60, 0x82, 0x1e,
|
91
|
+
0x4c, 0x1a, 0x29, 0x18, 0xca, 0x78, 0xf8, 0x8d, 0x22, 0xad, 0x4d, 0xcf,
|
92
|
+
0x36, 0xa7, 0x82, 0x79, 0xda, 0x37, 0x0c, 0x0c, 0x2d, 0x8c, 0x15, 0xd2,
|
93
|
+
0xd9, 0x45, 0x37, 0xbb, 0xf3, 0x2c, 0xa3, 0xce, 0xad, 0x88, 0xdc, 0x5d,
|
94
|
+
0xae, 0x08, 0x00, 0xf3, 0x3a, 0xdd, 0xa7, 0x8f, 0xe6, 0xd8, 0x7e, 0xf8,
|
95
|
+
0x73, 0xe1, 0x2e, 0x92, 0x40, 0xdd, 0xdc, 0x6d, 0xdd, 0xe3, 0x1c, 0x31,
|
96
|
+
0xbf, 0x7e, 0x9e, 0x8d, 0xb2, 0xf5, 0xb4, 0x85, 0x45, 0xf5, 0x9f, 0xd1,
|
97
|
+
0x7b, 0x16, 0x7e, 0x15, 0x5b, 0x31, 0xbf, 0x4b, 0x62, 0xda, 0x33, 0x4d,
|
98
|
+
0xc7, 0x9d, 0x07, 0xd5, 0x48, 0xdf, 0x22, 0x91, 0xc1, 0xdc, 0xfb, 0x1f,
|
99
|
+
0x4a, 0x03, 0x10, 0x5f, 0x80, 0x2e, 0x2c, 0x91, 0x75, 0x52, 0x84, 0xd8,
|
100
|
+
0x3c, 0x10, 0x21, 0xf7, 0x13, 0x62, 0xfa, 0x87, 0x9e, 0x9c, 0x9d, 0xa5,
|
101
|
+
0xfd, 0xf2, 0xc2
|
102
102
|
};
|
103
103
|
unsigned int cert_key_der_len = 1191;
|
@@ -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
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require_relative '../lib/opcua/server'
|
3
|
+
#require 'opcua/server'
|
4
|
+
|
5
|
+
Daemonite.new do
|
6
|
+
on startup do |opts|
|
7
|
+
opts['server'] = OPCUA::Server.new
|
8
|
+
opts['server'].add_namespace "https://centurio.work/kelch"
|
9
|
+
|
10
|
+
t = opts['server'].types.add_object_type(:Test).tap{ |u|
|
11
|
+
u.add_object(:Measurements, opts['server'].types.folder).tap{ |v|
|
12
|
+
v.add_object(:BitRegister, opts['server'].types.folder).tap{ |w|
|
13
|
+
w.add_variable_rw :Wert do |node,value,external|
|
14
|
+
if external
|
15
|
+
p node.id
|
16
|
+
p value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
v = opts['server'].objects.manifest(:Tester, t)
|
24
|
+
|
25
|
+
opts['mm'] = v.find :Measurements
|
26
|
+
opts['br'] = opts['mm'].find :BitRegister
|
27
|
+
opts['value'] = opts['br'].find :Wert
|
28
|
+
rescue => e
|
29
|
+
puts e.message
|
30
|
+
end
|
31
|
+
|
32
|
+
run do |opts|
|
33
|
+
opts['server'].run
|
34
|
+
opts['value'].value = rand
|
35
|
+
rescue => e
|
36
|
+
puts e.message
|
37
|
+
end
|
38
|
+
|
39
|
+
on exit do
|
40
|
+
# we could disconnect here, but OPCUA::Server does not have an explicit disconnect
|
41
|
+
puts 'bye.'
|
42
|
+
end
|
43
|
+
end.loop!
|
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
@@ -335,11 +335,56 @@ static VALUE node_add_method(int argc, VALUE* argv, VALUE self) { //{{{
|
|
335
335
|
return node_wrap(CLASS_OF(self),node_alloc(parent->master,node_add_method_ua_simple(nstr,parent,opts,blk)));
|
336
336
|
} //}}}
|
337
337
|
|
338
|
-
static
|
338
|
+
static void node_add_variable_callback( //{{{
|
339
|
+
UA_Server *server,
|
340
|
+
const UA_NodeId *sessionId, void *sessionContext,
|
341
|
+
const UA_NodeId *nodeId, void *nodeContext,
|
342
|
+
const UA_NumericRange *range, const UA_DataValue *data
|
343
|
+
) {
|
344
|
+
node_struct *me = (node_struct *)nodeContext;
|
345
|
+
UA_Guid internal = UA_GUID("00000001-0000-0000-0000-000000000000");
|
346
|
+
|
347
|
+
// if (sessionId->identifierType == UA_NODEIDTYPE_NUMERIC) {
|
348
|
+
// printf("sessionId ns=%d;i=%d\n", sessionId->namespaceIndex, sessionId->identifier.numeric);
|
349
|
+
// } else if(sessionId->identifierType == UA_NODEIDTYPE_STRING) {
|
350
|
+
// printf("sessionId ns=%d;s=%.*s\n", sessionId->namespaceIndex, (int)sessionId->identifier.string.length, sessionId->identifier.string.data);
|
351
|
+
// } else if(sessionId->identifierType == UA_NODEIDTYPE_GUID) {
|
352
|
+
// if (UA_Guid_equal(&(sessionId->identifier.guid),&internal)) {
|
353
|
+
// printf("sessionId internal session\n");
|
354
|
+
// } else {
|
355
|
+
// printf("sessionId ns=%d;g=%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",sessionId->namespaceIndex,UA_PRINTF_GUID_DATA(sessionId->identifier.guid));
|
356
|
+
// }
|
357
|
+
// } else if(sessionId->identifierType == UA_NODEIDTYPE_BYTESTRING) {
|
358
|
+
// printf("sessionId ns=%d;b=%.*s\n", sessionId->namespaceIndex, (int)sessionId->identifier.string.length, sessionId->identifier.string.data);
|
359
|
+
// } else if(UA_NodeId_isNull(sessionId)) {
|
360
|
+
// printf("sessionId is null");
|
361
|
+
// } else {
|
362
|
+
// printf("sessionId ns=%d;unsupported\n",sessionId->namespaceIndex);
|
363
|
+
// }
|
364
|
+
|
365
|
+
VALUE args = rb_ary_new();
|
366
|
+
rb_ary_push(args, Data_Wrap_Struct(cVarNode,NULL,NULL,me));
|
367
|
+
VALUE para = extract_value(data->value);
|
368
|
+
rb_ary_push(args,rb_ary_entry(para,0));
|
369
|
+
if (UA_Guid_equal(&(sessionId->identifier.guid),&internal)) {
|
370
|
+
rb_ary_push(args,Qfalse);
|
371
|
+
} else {
|
372
|
+
rb_ary_push(args,Qtrue);
|
373
|
+
}
|
374
|
+
if (me->method != Qnil) {
|
375
|
+
rb_proc_call(me->method,args);
|
376
|
+
}
|
377
|
+
} //}}}
|
378
|
+
static UA_NodeId node_add_variable_ua(UA_Int32 type, UA_NodeId n, UA_LocalizedText dn, UA_QualifiedName qn, node_struct *parent, UA_Byte accesslevelmask, VALUE blk) { //{{{
|
339
379
|
UA_VariableAttributes vAttr = UA_VariableAttributes_default;
|
340
380
|
vAttr.displayName = dn;
|
341
381
|
vAttr.accessLevel = accesslevelmask;
|
342
382
|
|
383
|
+
node_struct *me = node_alloc(parent->master,n);
|
384
|
+
me->method = blk;
|
385
|
+
rb_gc_register_address(&blk);
|
386
|
+
rb_gc_register_address(&me->method);
|
387
|
+
|
343
388
|
UA_Server_addVariableNode(parent->master->master,
|
344
389
|
n,
|
345
390
|
parent->id,
|
@@ -347,9 +392,13 @@ static UA_NodeId node_add_variable_ua(UA_Int32 type, UA_NodeId n, UA_LocalizedTe
|
|
347
392
|
qn,
|
348
393
|
UA_NODEID_NUMERIC(0, type),
|
349
394
|
vAttr,
|
350
|
-
|
395
|
+
(void *)me,
|
351
396
|
NULL);
|
352
397
|
|
398
|
+
UA_ValueCallback callback ;
|
399
|
+
callback.onWrite = node_add_variable_callback;
|
400
|
+
UA_Server_setVariableNode_valueCallback(parent->master->master, n, callback);
|
401
|
+
|
353
402
|
UA_Server_addReference(parent->master->master,
|
354
403
|
n,
|
355
404
|
UA_NODEID_NUMERIC(0, UA_NS0ID_HASMODELLINGRULE),
|
@@ -357,15 +406,28 @@ static UA_NodeId node_add_variable_ua(UA_Int32 type, UA_NodeId n, UA_LocalizedTe
|
|
357
406
|
true);
|
358
407
|
|
359
408
|
return n;
|
360
|
-
}
|
361
|
-
static UA_NodeId node_add_variable_ua_simple(UA_Int32 type,
|
409
|
+
} //}}}
|
410
|
+
static UA_NodeId node_add_variable_ua_simple(UA_Int32 type, VALUE str, node_struct *parent, UA_Byte accesslevelmask, bool numeric, VALUE blk) { //{{{
|
411
|
+
int nodeid = nodecounter++;
|
412
|
+
char *nstr = (char *)StringValuePtr(str);
|
413
|
+
|
414
|
+
UA_NodeId n;
|
415
|
+
if (numeric) {
|
416
|
+
n = UA_NODEID_NUMERIC(parent->master->default_ns,nodeid);
|
417
|
+
rb_hash_aset(parent->master->methods,INT2NUM(nodeid),blk);
|
418
|
+
} else {
|
419
|
+
n = UA_NODEID_STRING(parent->master->default_ns,nstr);
|
420
|
+
rb_hash_aset(parent->master->methods,str,blk);
|
421
|
+
}
|
422
|
+
rb_gc_register_address(&blk);
|
362
423
|
return node_add_variable_ua(
|
363
424
|
type,
|
364
|
-
|
425
|
+
n,
|
365
426
|
UA_LOCALIZEDTEXT("en-US", nstr),
|
366
427
|
UA_QUALIFIEDNAME(parent->master->default_ns, nstr),
|
367
428
|
parent,
|
368
|
-
accesslevelmask
|
429
|
+
accesslevelmask,
|
430
|
+
blk
|
369
431
|
);
|
370
432
|
} //}}}
|
371
433
|
static VALUE node_add_variable_wrap(int argc, VALUE* argv, VALUE self, UA_Byte accesslevelmask, bool numeric) { //{{{
|
@@ -375,22 +437,28 @@ static VALUE node_add_variable_wrap(int argc, VALUE* argv, VALUE self, UA_Byte a
|
|
375
437
|
rb_raise(rb_eArgError, "wrong number of arguments");
|
376
438
|
}
|
377
439
|
|
440
|
+
Data_Get_Struct(self, node_struct, parent);
|
441
|
+
if (!parent->exists) rb_raise(rb_eRuntimeError, "Node does not exist anymore.");
|
442
|
+
|
443
|
+
VALUE name;
|
444
|
+
VALUE ttype;
|
445
|
+
VALUE blk;
|
446
|
+
rb_gc_register_address(&blk);
|
447
|
+
|
448
|
+
rb_scan_args(argc, argv, "11&", &name, &ttype, &blk);
|
449
|
+
|
378
450
|
UA_UInt32 type;
|
379
|
-
if (
|
380
|
-
type = NUM2INT(argv[1]);
|
381
|
-
} else {
|
451
|
+
if (NIL_P(ttype)) {
|
382
452
|
type = UA_NS0ID_BASEDATAVARIABLETYPE;
|
453
|
+
} else {
|
454
|
+
type = NUM2INT(ttype);
|
383
455
|
}
|
384
456
|
|
385
|
-
|
386
|
-
if (!parent->exists) rb_raise(rb_eRuntimeError, "Node does not exist anymore.");
|
387
|
-
|
388
|
-
VALUE str = rb_obj_as_string(argv[0]);
|
457
|
+
VALUE str = rb_obj_as_string(name);
|
389
458
|
if (NIL_P(str) || TYPE(str) != T_STRING)
|
390
459
|
rb_raise(rb_eTypeError, "cannot convert obj to string");
|
391
|
-
char *nstr = (char *)StringValuePtr(str);
|
392
460
|
|
393
|
-
return node_wrap(cVarNode,node_alloc(parent->master,node_add_variable_ua_simple(type,
|
461
|
+
return node_wrap(cVarNode,node_alloc(parent->master,node_add_variable_ua_simple(type,str,parent,accesslevelmask,numeric,blk)));
|
394
462
|
} //}}}
|
395
463
|
static VALUE node_add_variable(int argc, VALUE* argv, VALUE self) { //{{{
|
396
464
|
return node_add_variable_wrap(argc,argv,self,UA_ACCESSLEVELMASK_READ,true);
|
@@ -449,10 +517,18 @@ static UA_NodeId node_add_object_ua(UA_Int32 type, UA_NodeId n, UA_LocalizedText
|
|
449
517
|
|
450
518
|
return n;
|
451
519
|
} //}}}
|
452
|
-
static UA_NodeId node_add_object_ua_simple(UA_Int32 type, char* nstr, node_struct *parent, node_struct *datatype, VALUE ref) { //{{{
|
520
|
+
static UA_NodeId node_add_object_ua_simple(UA_Int32 type, char* nstr, node_struct *parent, node_struct *datatype, VALUE ref, bool numeric) { //{{{
|
521
|
+
int nodeid = nodecounter++;
|
522
|
+
UA_NodeId n;
|
523
|
+
if (numeric) {
|
524
|
+
n = UA_NODEID_NUMERIC(parent->master->default_ns,nodeid);
|
525
|
+
} else {
|
526
|
+
n = UA_NODEID_STRING(parent->master->default_ns,nstr);
|
527
|
+
}
|
528
|
+
|
453
529
|
return node_add_object_ua(
|
454
530
|
type,
|
455
|
-
|
531
|
+
n,
|
456
532
|
UA_LOCALIZEDTEXT("en-US", nstr),
|
457
533
|
UA_QUALIFIEDNAME(parent->master->default_ns, nstr),
|
458
534
|
parent,
|
@@ -489,7 +565,7 @@ static VALUE node_add_object(int argc, VALUE* argv, VALUE self) { //{{{
|
|
489
565
|
rb_raise(rb_eTypeError, "cannot convert obj to string");
|
490
566
|
char *nstr = (char *)StringValuePtr(str);
|
491
567
|
|
492
|
-
return node_wrap(CLASS_OF(self),node_alloc(parent->master,node_add_object_ua_simple(type,nstr,parent,datatype,argv[2])));
|
568
|
+
return node_wrap(CLASS_OF(self),node_alloc(parent->master,node_add_object_ua_simple(type,nstr,parent,datatype,argv[2],true)));
|
493
569
|
} //}}}
|
494
570
|
|
495
571
|
static UA_StatusCode node_manifest_iter(UA_NodeId child_id, UA_Boolean is_inverse, UA_NodeId reference_type_id, void *handle) { //{{{
|
@@ -564,10 +640,22 @@ static UA_StatusCode node_manifest_iter(UA_NodeId child_id, UA_Boolean is_invers
|
|
564
640
|
UA_BrowsePathResult property = node_browse_path(parent->master->master, child_id, UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION), pqn, false);
|
565
641
|
UA_QualifiedName_clear(&pqn);
|
566
642
|
|
643
|
+
VALUE blk;
|
644
|
+
if (child_id.identifierType == UA_NODEIDTYPE_NUMERIC) {
|
645
|
+
blk = rb_hash_aref(parent->master->methods,INT2NUM(child_id.identifier.numeric));
|
646
|
+
} else if (child_id.identifierType == UA_NODEIDTYPE_STRING) {
|
647
|
+
blk = rb_hash_aref(parent->master->methods,rb_str_new((const char *)child_id.identifier.string.data,child_id.identifier.string.length));
|
648
|
+
} else if (child_id.identifierType == UA_NODEIDTYPE_BYTESTRING) {
|
649
|
+
blk = rb_hash_aref(parent->master->methods,rb_str_new((const char *)child_id.identifier.byteString.data,child_id.identifier.byteString.length));
|
650
|
+
} else {
|
651
|
+
blk = Qnil;
|
652
|
+
}
|
653
|
+
|
654
|
+
|
567
655
|
if (property.statusCode == UA_STATUSCODE_GOOD) {
|
568
|
-
node_add_variable_ua(UA_NS0ID_PROPERTYTYPE,UA_NODEID_STRING(parent->master->default_ns,buffer),dn,qn,newnode,al);
|
656
|
+
node_add_variable_ua(UA_NS0ID_PROPERTYTYPE,UA_NODEID_STRING(parent->master->default_ns,buffer),dn,qn,newnode,al,blk);
|
569
657
|
} else {
|
570
|
-
node_add_variable_ua(UA_NS0ID_BASEDATAVARIABLETYPE,UA_NODEID_STRING(parent->master->default_ns,buffer),dn,qn,newnode,al);
|
658
|
+
node_add_variable_ua(UA_NS0ID_BASEDATAVARIABLETYPE,UA_NODEID_STRING(parent->master->default_ns,buffer),dn,qn,newnode,al,blk);
|
571
659
|
}
|
572
660
|
|
573
661
|
UA_BrowsePathResult_clear(&property);
|
@@ -758,7 +846,7 @@ static VALUE node_value_set(VALUE self, VALUE value) { //{{{
|
|
758
846
|
}
|
759
847
|
|
760
848
|
UA_Server_writeValue(ns->master->master, ns->id, variant);
|
761
|
-
|
849
|
+
UA_Variant_clear(&variant);
|
762
850
|
}
|
763
851
|
return self;
|
764
852
|
} //}}}
|
data/lib/opcua/server.rb
CHANGED
@@ -46,11 +46,23 @@ module OPCUA
|
|
46
46
|
def add_property_rw(*item)
|
47
47
|
item.each { |e| add_property_rw e }
|
48
48
|
end
|
49
|
-
def add_variables(*item)
|
50
|
-
item.each
|
49
|
+
def add_variables(*item,&blk)
|
50
|
+
item.each do |e|
|
51
|
+
if blk.nil?
|
52
|
+
add_variable e
|
53
|
+
else
|
54
|
+
add_variable e, &blk
|
55
|
+
end
|
56
|
+
end
|
51
57
|
end
|
52
|
-
def add_variables_rw(*item)
|
53
|
-
item.each
|
58
|
+
def add_variables_rw(*item,&blk)
|
59
|
+
item.each do |e|
|
60
|
+
if blk.nil?
|
61
|
+
add_variable_rw e
|
62
|
+
else
|
63
|
+
add_variable_rw e, &blk
|
64
|
+
end
|
65
|
+
end
|
54
66
|
end
|
55
67
|
end
|
56
68
|
end
|
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."
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.required_ruby_version = '>=2.5.0'
|
17
17
|
|
18
|
-
s.authors = ['Juergen eTM Mangler','Florian Pauker']
|
18
|
+
s.authors = ['Juergen eTM Mangler','Florian Pauker','Matthias Ehrendorfer']
|
19
19
|
|
20
20
|
s.email = 'juergen.mangler@gmail.com'
|
21
21
|
s.homepage = 'https://github.com/etm/opcua-smart'
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
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
|
8
8
|
- Florian Pauker
|
9
|
-
|
9
|
+
- Matthias Ehrendorfer
|
10
|
+
autorequire:
|
10
11
|
bindir: tools
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2021-02-23 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: daemonite
|
@@ -84,6 +85,7 @@ files:
|
|
84
85
|
- example/server.rb
|
85
86
|
- example/server_deep.rb
|
86
87
|
- example/server_values.rb
|
88
|
+
- example/server_values_callback.rb
|
87
89
|
- example/server_xml.rb
|
88
90
|
- example/test.rb
|
89
91
|
- ext/opcua/client/client.c
|
@@ -123,7 +125,7 @@ homepage: https://github.com/etm/opcua-smart
|
|
123
125
|
licenses:
|
124
126
|
- LGPL-3.0
|
125
127
|
metadata: {}
|
126
|
-
post_install_message:
|
128
|
+
post_install_message:
|
127
129
|
rdoc_options: []
|
128
130
|
require_paths:
|
129
131
|
- lib
|
@@ -138,8 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
140
|
- !ruby/object:Gem::Version
|
139
141
|
version: '0'
|
140
142
|
requirements: []
|
141
|
-
rubygems_version: 3.1.
|
142
|
-
signing_key:
|
143
|
+
rubygems_version: 3.1.4
|
144
|
+
signing_key:
|
143
145
|
specification_version: 4
|
144
146
|
summary: Preliminary release of opcua (open62541) ruby bindings. C performance, Ruby
|
145
147
|
elegance, simplicity, and productivity.
|