opcua 0.15 → 0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -17
- data/Rakefile +20 -12
- data/cert/cert.h +52 -52
- data/cert/cert_key.h +101 -101
- data/example/bug5.rb +1 -1
- data/example/client_get_float.rb +12 -0
- data/example/client_method.rb +6 -3
- data/example/server.rb +8 -0
- data/example/server_xml.rb +85 -0
- data/ext/opcua/client/client.c +19 -9
- data/ext/opcua/helpers/finders.c +28 -0
- data/ext/opcua/helpers/finders.h +1 -0
- data/ext/opcua/helpers/values.c +34 -4
- data/ext/opcua/helpers/values.h +1 -2
- data/ext/opcua/server/server.c +74 -18
- data/opcua.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b563025f5af4ab20c27a4f6ff05e5e442dab0d44462c346bd7d32ac3ff58ad49
|
4
|
+
data.tar.gz: '059f6ae8d6a8ed02d7577e8c7fc55154f5574549cdb47628bb4e1ace0675a3eb'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4bcf7661e9be89ac2a6be22404e07274ee829b23ee1afde5647d7f7bd0cd6987d396542e802ae5e2303895888abcc8b6a68244f97b2010b677375a01e04835b
|
7
|
+
data.tar.gz: 1fe326883189de7b5395009677b0241f23bd539a7c31e2001e63ff6bcb4c1b1c8f8d4371eb3e8e48578dcc6e9fdac215145659673da335a2b173aa02a83a3bc2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# OPC-UA Ruby Bindings (open62541)
|
2
2
|
|
3
|
-
The development of OPC UA applications takes currently a lot of effort. This is caused by the large possibilities of the OPC UA specification. With this
|
3
|
+
The development of OPC UA applications takes currently a lot of effort. This is caused by the large possibilities of the OPC UA specification. With this implementation we want to define some conventions, which shoud make the technology more useable.
|
4
4
|
|
5
5
|
## Table of Contents
|
6
6
|
|
@@ -30,27 +30,31 @@ Copyright (C) 2019-* Jürgen "eTM" Mangler
|
|
30
30
|
|
31
31
|
## Installation
|
32
32
|
|
33
|
-
|
33
|
+
|
34
|
+
```sh
|
35
|
+
# Debian/Ubuntu
|
36
|
+
apt install build-essential cmake-curses-gui libmbedtls-dev libxml2-dev libxslt-dev libz-dev libssl-dev libicu-dev
|
37
|
+
# Fedora/Redhat
|
38
|
+
dnf install @buildsys-build @development-tools cmake libxml2-devel libxslt-devel zlib-devel libicu-devel mbedtls-devel
|
39
|
+
```
|
40
|
+
|
41
|
+
Dependency: https://github.com/open62541/open62541 > 1.1 (master branch as of 2020-06-04)
|
34
42
|
|
35
43
|
```sh
|
36
44
|
git clone https://github.com/open62541/open62541.git
|
37
45
|
cd open62541
|
38
|
-
mkdir build
|
39
|
-
|
40
|
-
cmake ..
|
41
|
-
ccmake ..
|
42
|
-
# Configuration, see picture below
|
46
|
+
mkdir build && cd build
|
47
|
+
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_ENABLE_AMALGAMATION=ON -DUA_ENABLE_ENCRYPTION=ON -DUA_ENABLE_ENCRYPTION_MBEDTLS=ON ..
|
43
48
|
make
|
44
49
|
sudo make install
|
45
50
|
gem install opcua
|
46
51
|
```
|
47
52
|
|
48
|
-
![ccmake Config](config.png)
|
49
|
-
|
50
53
|
If the installation works correctly, but examples are still complaining about missing lib62541.so, try this:
|
51
54
|
|
52
55
|
```sh
|
53
|
-
sudo echo "/usr/local/lib"
|
56
|
+
sudo echo "/usr/local/lib" >> /etc/ld.so.conf.d/local.conf # add to libs path
|
57
|
+
sudo echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local.conf # add to libs path
|
54
58
|
sudo ldconfig # update libs
|
55
59
|
sudo ldconfig -p | grep libopen62541 # check if its there
|
56
60
|
```
|
@@ -67,7 +71,7 @@ The server has following functions:
|
|
67
71
|
* Find nodes in the adress space
|
68
72
|
* Loop for getting real life data
|
69
73
|
|
70
|
-
Every server application uses the
|
74
|
+
Every server application uses the Daemonite gem, which allows to run the server as service.
|
71
75
|
```ruby
|
72
76
|
Daemonite.new do
|
73
77
|
on startup do |opts|
|
@@ -93,7 +97,7 @@ server.add_namespace "https://yourdomain/testserver"
|
|
93
97
|
```
|
94
98
|
|
95
99
|
|
96
|
-
#### Create ObjectTypes
|
100
|
+
#### Create ObjectTypes
|
97
101
|
|
98
102
|
Basically all new created types are subtypes of the _BaseObjectType_. With ```server.types.add_object_type(:TestObjectType)``` a new type is defined in the information model. All nodes of the new created type are defined in the ```tap{}``` region.
|
99
103
|
|
@@ -129,7 +133,7 @@ With ```.add_object(:TestObject)``` a new object named _TestObject_ is added. Th
|
|
129
133
|
|
130
134
|
##### Add Method
|
131
135
|
|
132
|
-
Methods are added with the ```.add_method(:TestMethod)``` function. Per default the method has no input and output arguments. By adding additional arguments you can define input arguments. The code for defining a method with input arguments looks like
|
136
|
+
Methods are added with the ```.add_method(:TestMethod)``` function. Per default the method has no input and output arguments. By adding additional arguments you can define input arguments. The code for defining a method with input arguments looks like
|
133
137
|
```ruby
|
134
138
|
t.add_method :TestMethod, inputarg1: OPCUA::TYPES::STRING, inputarg2: OPCUA::TYPES::DATETIME do |node, inputarg1, inputarg2|
|
135
139
|
#do some stuff here
|
@@ -140,7 +144,7 @@ in the ```do...end```section you write the code which should be executed by call
|
|
140
144
|
|
141
145
|
#### Manifest Objects
|
142
146
|
|
143
|
-
ObjectTypes can be instiantiated with the ```.manifest``` method.
|
147
|
+
ObjectTypes can be instiantiated with the ```.manifest``` method.
|
144
148
|
|
145
149
|
```ruby
|
146
150
|
testobject =server.objects.manifest(:TestObjectType, to)
|
@@ -156,7 +160,7 @@ testobject.delete!
|
|
156
160
|
|
157
161
|
#### Find Nodes in the Addressspace
|
158
162
|
|
159
|
-
To get a specific node you should use the ```.find``` method.
|
163
|
+
To get a specific node you should use the ```.find``` method.
|
160
164
|
```ruby
|
161
165
|
tv = to.find :TestVariable
|
162
166
|
```
|
@@ -187,7 +191,7 @@ You can assign vlaues without definig a datatype. The correct _DataType_ will be
|
|
187
191
|
#### Loop for getting Real Life Data
|
188
192
|
The server loop looks like follows:
|
189
193
|
```ruby
|
190
|
-
run do
|
194
|
+
run do
|
191
195
|
sleep server.run
|
192
196
|
to.value = 'Testvariable1'
|
193
197
|
p to.value
|
@@ -196,7 +200,7 @@ The server loop looks like follows:
|
|
196
200
|
end
|
197
201
|
```
|
198
202
|
|
199
|
-
The loop starts with ```sleep server.run```. This is recommended by the open62541 developer. With the ```.value``` function you can write or get the value of a node.
|
203
|
+
The loop starts with ```sleep server.run```. This is recommended by the open62541 developer. With the ```.value``` function you can write or get the value of a node.
|
200
204
|
|
201
205
|
### Client
|
202
206
|
TBD. See examples subdirectory.
|
data/Rakefile
CHANGED
@@ -1,24 +1,26 @@
|
|
1
1
|
require 'rubygems/package_task'
|
2
|
-
require 'rake/extensiontask'
|
3
2
|
require 'fileutils'
|
4
3
|
|
5
4
|
spec = eval(File.read('opcua.gemspec'))
|
6
5
|
|
7
|
-
|
6
|
+
task :compile do
|
7
|
+
require 'rake/extensiontask'
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
puts `cert/generate_certificate.sh`
|
10
|
+
spec.extensions.each do |f|
|
11
|
+
Rake.application.clear
|
11
12
|
|
12
|
-
|
13
|
+
task :default => [:compile]
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
t = Rake::ExtensionTask.new "opcua/" + File.basename(File.dirname(f)), spec
|
16
|
+
Rake::Task[:default].invoke
|
17
|
+
end
|
18
|
+
Rake.application.clear
|
16
19
|
end
|
17
|
-
Rake.application.clear
|
18
20
|
|
19
|
-
task :default => [:
|
21
|
+
task :default => [:compile]
|
20
22
|
|
21
|
-
|
23
|
+
Gem::PackageTask.new(spec) do |pkg|
|
22
24
|
pkg.need_zip = true
|
23
25
|
pkg.need_tar = true
|
24
26
|
FileUtils.mkdir 'pkg' rescue nil
|
@@ -26,10 +28,16 @@ pkg = Gem::PackageTask.new(spec) do |pkg|
|
|
26
28
|
FileUtils.ln_sf "#{pkg.name}.gem", "pkg/#{spec.name}.gem"
|
27
29
|
end
|
28
30
|
|
29
|
-
task :push => :gem do
|
31
|
+
task :push => :gem do
|
30
32
|
`gem push pkg/opcua.gem`
|
31
33
|
end
|
32
34
|
|
33
|
-
task :install => :gem do
|
35
|
+
task :install => :gem do
|
34
36
|
`gem install pkg/opcua.gem`
|
35
37
|
end
|
38
|
+
|
39
|
+
task :clean do
|
40
|
+
FileUtils.rm_rf(File.join(__dir__,'tmp'))
|
41
|
+
FileUtils.rm_rf(File.join(__dir__,'lib','opcua','client.so'))
|
42
|
+
FileUtils.rm_rf(File.join(__dir__,'lib','opcua','server.so'))
|
43
|
+
end
|
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, 0x7e, 0x53, 0x21, 0xef, 0xe9, 0x0b, 0x90, 0x45, 0x91,
|
4
|
+
0x50, 0x71, 0x15, 0x0a, 0xcb, 0x99, 0x5a, 0xe3, 0x98, 0xc0, 0xdd, 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,
|
9
|
-
0x34,
|
10
|
-
|
8
|
+
0x61, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x30, 0x30, 0x37, 0x31, 0x30, 0x31,
|
9
|
+
0x34, 0x30, 0x36, 0x30, 0x32, 0x5a, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x36,
|
10
|
+
0x33, 0x30, 0x31, 0x34, 0x30, 0x36, 0x30, 0x32, 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, 0xbf, 0xcd, 0xca, 0x15, 0x60, 0x85, 0x47,
|
16
|
+
0xb7, 0x3d, 0x38, 0x00, 0xe2, 0x1f, 0xcc, 0xc9, 0x15, 0x7f, 0xb1, 0x58,
|
17
|
+
0xc8, 0x33, 0x8e, 0x74, 0x52, 0x1e, 0xcc, 0x5f, 0xe0, 0xa4, 0x11, 0x92,
|
18
|
+
0x47, 0x66, 0xb6, 0x33, 0x0c, 0xd0, 0xde, 0x39, 0xf6, 0xd0, 0x7b, 0x78,
|
19
|
+
0x6c, 0x13, 0xf8, 0xfd, 0x2b, 0xf0, 0x67, 0xbf, 0xd4, 0x54, 0xb9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, 0x56, 0x66, 0xd5, 0x8a,
|
34
|
+
0x08, 0x54, 0x6c, 0xad, 0xf8, 0x7c, 0x1a, 0x18, 0xdb, 0xc0, 0xf1, 0x5d,
|
35
|
+
0x4f, 0x68, 0xe5, 0x93, 0x52, 0x4a, 0x58, 0x67, 0x7d, 0x7c, 0x2c, 0xb7,
|
36
|
+
0x59, 0x16, 0x6e, 0x67, 0xab, 0x10, 0xe2, 0xab, 0x11, 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, 0x23, 0x5a, 0xee, 0xbe, 0x0a, 0x8d, 0x60,
|
39
|
+
0xac, 0x7e, 0x6b, 0xaa, 0xc2, 0xd7, 0x15, 0x4d, 0x8d, 0xac, 0x48, 0x2a,
|
40
|
+
0x59, 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, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00,
|
47
|
-
|
48
|
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12, 0xec, 0x45, 0xd2, 0x65, 0x12, 0x72,
|
59
|
+
0xf2, 0x27, 0xeb, 0x19, 0xcf, 0x1e, 0xa4, 0x5b, 0xdb, 0x48, 0x5d, 0x73,
|
60
|
+
0xc9, 0xd1, 0x38, 0x98, 0xc2, 0xb4, 0x57, 0x12, 0xb8, 0xc4, 0x9c, 0x8d,
|
61
|
+
0xad, 0xd9, 0x03, 0x01, 0x39, 0xa3, 0x90, 0x3c, 0xce, 0xcc, 0xc8, 0x38,
|
62
|
+
0x82, 0x20, 0x6a, 0x74, 0x25, 0xe5, 0x38, 0x8c, 0x70, 0xf0, 0xe4, 0x03,
|
63
|
+
0x54, 0x42, 0x12, 0xee, 0xc4, 0x9b, 0xc2, 0x7c, 0xd1, 0x70, 0xf0, 0x7f,
|
64
|
+
0xda, 0xb5, 0xa9, 0x1d, 0x4d, 0xc9, 0x7b, 0x0f, 0x94, 0xf6, 0x8a, 0xbe,
|
65
|
+
0xe1, 0xe8, 0x1b, 0xaa, 0x46, 0x84, 0x65, 0xfa, 0xd4, 0xef, 0x66, 0x4b,
|
66
|
+
0xdd, 0xb6, 0xa1, 0x17, 0xe0, 0x33, 0xd9, 0x87, 0xa1, 0xe3, 0xd0, 0x7a,
|
67
|
+
0x15, 0x44, 0xee, 0xb8, 0xab, 0x15, 0x1a, 0xd3, 0x84, 0x79, 0xaf, 0x15,
|
68
|
+
0xdd, 0x64, 0x13, 0x17
|
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
|
-
0x30, 0x82, 0x04,
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
0x00,
|
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
|
-
0x02,
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
0x90,
|
100
|
-
|
101
|
-
|
2
|
+
0x30, 0x82, 0x04, 0xa3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00,
|
3
|
+
0xbf, 0xcd, 0xca, 0x15, 0x60, 0x85, 0x47, 0xb7, 0x3d, 0x38, 0x00, 0xe2,
|
4
|
+
0x1f, 0xcc, 0xc9, 0x15, 0x7f, 0xb1, 0x58, 0xc8, 0x33, 0x8e, 0x74, 0x52,
|
5
|
+
0x1e, 0xcc, 0x5f, 0xe0, 0xa4, 0x11, 0x92, 0x47, 0x66, 0xb6, 0x33, 0x0c,
|
6
|
+
0xd0, 0xde, 0x39, 0xf6, 0xd0, 0x7b, 0x78, 0x6c, 0x13, 0xf8, 0xfd, 0x2b,
|
7
|
+
0xf0, 0x67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
|
21
|
+
0x26, 0x64, 0x8f, 0x56, 0x66, 0xd5, 0x8a, 0x08, 0x54, 0x6c, 0xad, 0xf8,
|
22
|
+
0x7c, 0x1a, 0x18, 0xdb, 0xc0, 0xf1, 0x5d, 0x4f, 0x68, 0xe5, 0x93, 0x52,
|
23
|
+
0x4a, 0x58, 0x67, 0x7d, 0x7c, 0x2c, 0xb7, 0x59, 0x16, 0x6e, 0x67, 0xab,
|
24
|
+
0x10, 0xe2, 0xab, 0x11, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x82, 0x01,
|
25
|
+
0x00, 0x15, 0x12, 0x66, 0xc1, 0x32, 0x79, 0x72, 0x07, 0x8f, 0x92, 0x37,
|
26
|
+
0x86, 0xa0, 0x37, 0xbf, 0x5f, 0xbd, 0x47, 0x9e, 0x99, 0x60, 0x10, 0xa6,
|
27
|
+
0x76, 0xdf, 0x2b, 0x54, 0xdd, 0x39, 0x29, 0x35, 0x08, 0xe3, 0x1f, 0xe1,
|
28
|
+
0x3b, 0xe7, 0x36, 0x82, 0xe7, 0xba, 0xbf, 0xd5, 0xdb, 0x09, 0xd6, 0xb0,
|
29
|
+
0xf9, 0xc2, 0xcf, 0xa3, 0x23, 0x90, 0xab, 0x44, 0x51, 0x71, 0x34, 0x48,
|
30
|
+
0x96, 0x22, 0x19, 0xfb, 0x50, 0xc3, 0x36, 0x44, 0x42, 0x66, 0xd9, 0x9b,
|
31
|
+
0xf7, 0x7a, 0x86, 0xb5, 0xb7, 0x35, 0x3a, 0x21, 0x7f, 0xbf, 0xf0, 0xc0,
|
32
|
+
0x4f, 0xa4, 0xa3, 0x20, 0x74, 0xd1, 0x38, 0x3c, 0xe9, 0x28, 0xad, 0x93,
|
33
|
+
0x82, 0xa6, 0x8a, 0x39, 0x16, 0x87, 0x98, 0x08, 0xd9, 0x4c, 0x41, 0x9b,
|
34
|
+
0xe0, 0x41, 0xef, 0xc3, 0x04, 0x26, 0xa4, 0xcf, 0x80, 0x6d, 0x7d, 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e5,
|
90
|
+
0xbf, 0xfa, 0x74, 0xd3, 0x02, 0x81, 0x80, 0x7b, 0xb4, 0xa2, 0x42, 0x72,
|
91
|
+
0xec, 0x25, 0x6a, 0x80, 0xdc, 0xbd, 0x45, 0x57, 0x6c, 0x28, 0xb9, 0x7b,
|
92
|
+
0x22, 0x70, 0x17, 0x04, 0x2d, 0x50, 0xf4, 0x74, 0x52, 0xd7, 0xc6, 0x90,
|
93
|
+
0x8a, 0x04, 0x5b, 0x0a, 0xf0, 0x21, 0x8d, 0x14, 0xe6, 0x06, 0x65, 0x1d,
|
94
|
+
0x65, 0xab, 0xee, 0xd2, 0x5a, 0x85, 0x2b, 0xde, 0xc7, 0x4a, 0x79, 0x77,
|
95
|
+
0x18, 0x1b, 0xd6, 0xe7, 0x64, 0xdb, 0xea, 0xfc, 0xc1, 0x34, 0xcc, 0xdc,
|
96
|
+
0xfa, 0xf1, 0x79, 0x95, 0xc3, 0x53, 0x40, 0x1f, 0xfe, 0x48, 0xf8, 0x13,
|
97
|
+
0x81, 0x41, 0xf2, 0x77, 0xcb, 0x0c, 0x88, 0xb4, 0xc1, 0xa8, 0xcf, 0x59,
|
98
|
+
0x1b, 0xba, 0xf3, 0x1a, 0x1d, 0xa2, 0xfc, 0x02, 0x00, 0xa2, 0xf7, 0x2a,
|
99
|
+
0x90, 0x3a, 0x02, 0xf0, 0x23, 0x13, 0xb8, 0xe7, 0xde, 0x58, 0x5d, 0xe1,
|
100
|
+
0x74, 0xbf, 0xdc, 0x62, 0xcf, 0xf4, 0x18, 0x78, 0x15, 0xbd, 0xd5, 0x4d,
|
101
|
+
0x6e, 0xfd, 0xbb
|
102
102
|
};
|
103
|
-
unsigned int cert_key_der_len =
|
103
|
+
unsigned int cert_key_der_len = 1191;
|
data/example/bug5.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require_relative '../lib/opcua/client'
|
3
|
+
|
4
|
+
client = OPCUA::Client.new("opc.tcp://128.130.57.76:4840")
|
5
|
+
client.subscription_interval = 100 # default 500
|
6
|
+
|
7
|
+
if (node = client.get 1, 'DISPLAY_VOLTAGE') # get node from nodeid
|
8
|
+
p node
|
9
|
+
p node.value
|
10
|
+
else
|
11
|
+
p 'invalid nodeid'
|
12
|
+
end
|
data/example/client_method.rb
CHANGED
@@ -13,6 +13,9 @@ client.default_ns = 2
|
|
13
13
|
# p node.call 'abcde', Time.now
|
14
14
|
# client.disconnect
|
15
15
|
|
16
|
-
node = client.get
|
17
|
-
p node
|
18
|
-
p node.call
|
16
|
+
# node = client.get 1, 62541
|
17
|
+
# p node.to_s
|
18
|
+
# p node.call 'a'
|
19
|
+
|
20
|
+
node = client.get '/KalimatC34/Tools/Tool3/testRetMethod'
|
21
|
+
p node.call 'abcde'
|
data/example/server.rb
CHANGED
@@ -27,6 +27,14 @@ Daemonite.new do
|
|
27
27
|
p test2
|
28
28
|
puts '-' * 10
|
29
29
|
end
|
30
|
+
t.add_method :testRetMethod, test1: OPCUA::TYPES::STRING, return: OPCUA::TYPES::STRING do |node, test1|
|
31
|
+
ns, nid = node.id
|
32
|
+
puts '-' * 10
|
33
|
+
p nid
|
34
|
+
p test1
|
35
|
+
puts '-' * 10
|
36
|
+
"hello world"
|
37
|
+
end
|
30
38
|
t.add_object(:Measurements, opts['server'].types.folder).tap{ |u|
|
31
39
|
u.add_object :M, mt, OPCUA::OPTIONAL
|
32
40
|
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require_relative '../lib/opcua/server'
|
3
|
+
|
4
|
+
Daemonite.new do
|
5
|
+
on startup do |opts|
|
6
|
+
srv = opts['server'] = OPCUA::Server.new
|
7
|
+
srv.import_UA # FIX
|
8
|
+
srv.import_nodeset File::read('nodeset1.xml')
|
9
|
+
srv.import_nodeset File::read('nodeset1.xml')
|
10
|
+
srv.import_nodeset File::read('nodeset1.xml')
|
11
|
+
DI = srv.imports['http://xxxxx/DI']
|
12
|
+
AID = srv.imports['http://xxxxx/AutoID']
|
13
|
+
|
14
|
+
srv.objects
|
15
|
+
|
16
|
+
# ab 106 im nodesets.rb
|
17
|
+
x = srv.data_types.add(qualifiedname,referencetype=UA::HasSubtype,nodeid=rand())
|
18
|
+
x.displayname['en-US'] = 'rrr'
|
19
|
+
x.displayname['de'] = 'rrr'
|
20
|
+
x.displayname.delete('de')
|
21
|
+
|
22
|
+
srv.data_types.bla.blurg.add(wieheissts')
|
23
|
+
srv.data_types.bla.blurg.push(wieheissts')
|
24
|
+
srv.data_types.bla.blurg.<<('wieheissts')
|
25
|
+
x = srv.data_types.bla.find name: 'bla', type: SUBXXXX
|
26
|
+
[x] = srv.data_types.bla.find_all name: 'bla', type: SUBXXXX
|
27
|
+
[x] = srv.data_types.bla.select name: 'bla', type: SUBXXXX
|
28
|
+
srv.data_types.bla.parent
|
29
|
+
|
30
|
+
# srv.event_types
|
31
|
+
# srv.interfaces_types
|
32
|
+
|
33
|
+
srv.reference_types.add(qualifiedname,symmetric,referencetype,nodeid)
|
34
|
+
srv.reference_types.add_symmetric(qualifiedname,referencetype,nodeid)
|
35
|
+
|
36
|
+
srv.variable_types
|
37
|
+
srv.object_types
|
38
|
+
|
39
|
+
p server.add_namespace "https://centurio.work/kelch"
|
40
|
+
p server.active_namespace
|
41
|
+
server.active_namespace = 0
|
42
|
+
p server.active_namespace
|
43
|
+
p server.namespaces
|
44
|
+
|
45
|
+
|
46
|
+
tools = opts['server'].objects.manifest(:KalimatC34, pt).find(:Tools)
|
47
|
+
|
48
|
+
t1 = tools.manifest(:Tool1,tt)
|
49
|
+
t2 = tools.manifest(:Tool2,tt)
|
50
|
+
t3 = tools.manifest(:Tool3,tt)
|
51
|
+
|
52
|
+
opts[:tn] = t1.find(:ToolNumber)
|
53
|
+
opts[:tn].description = 'test test'
|
54
|
+
opts[:tn].value = [0,1]
|
55
|
+
p opts[:tn].description
|
56
|
+
p opts[:tn].to_s
|
57
|
+
p opts[:tn].name
|
58
|
+
|
59
|
+
measurments_t1 = t1.find(:Measurements)
|
60
|
+
measurments_t1.manifest(:M1,mt)
|
61
|
+
m2 = measurments_t1.manifest(:M2,mt)
|
62
|
+
rescue => e
|
63
|
+
puts e.message
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
counter = 0
|
68
|
+
run do |opts|
|
69
|
+
GC.start
|
70
|
+
sleep opts['server'].run
|
71
|
+
# if counter % 100 == 0
|
72
|
+
# opts[:tn].value = [counter, counter]
|
73
|
+
# # opts[:tn].value = 1
|
74
|
+
# p opts[:tn].value
|
75
|
+
# end
|
76
|
+
# counter += 1
|
77
|
+
rescue => e
|
78
|
+
puts e.message
|
79
|
+
end
|
80
|
+
|
81
|
+
on exit do
|
82
|
+
# we could disconnect here, but OPCUA::Server does not have an explicit disconnect
|
83
|
+
puts 'bye.'
|
84
|
+
end
|
85
|
+
end.loop!
|
data/ext/opcua/client/client.c
CHANGED
@@ -320,7 +320,7 @@ static VALUE client_init(VALUE self,VALUE url,VALUE user,VALUE pass) { //{{{
|
|
320
320
|
}
|
321
321
|
char *pstr = (char *)StringValuePtr(vpstr);
|
322
322
|
|
323
|
-
retval =
|
323
|
+
retval = UA_Client_connectUsername(pss->master, nstr, ustr, pstr);
|
324
324
|
}
|
325
325
|
if (retval != UA_STATUSCODE_GOOD) {
|
326
326
|
pss->started = false;
|
@@ -502,7 +502,11 @@ static VALUE node_call(int argc, VALUE* argv, VALUE self) { //{{{
|
|
502
502
|
Data_Get_Struct(self, node_struct, ns);
|
503
503
|
|
504
504
|
UA_NodeId parent;
|
505
|
-
client_node_get_reference_by_type(ns->master->master, ns->id, UA_NODEID_NUMERIC(0,UA_NS0ID_HASCOMPONENT), &parent, true)
|
505
|
+
if (!client_node_get_reference_by_type(ns->master->master, ns->id, UA_NODEID_NUMERIC(0,UA_NS0ID_HASCOMPONENT), &parent, true)) {
|
506
|
+
if (!client_node_get_reference_by_type(ns->master->master, ns->id, UA_NODEID_NUMERIC(0,UA_NS0ID_HASORDEREDCOMPONENT), &parent, true)) {
|
507
|
+
rb_raise(rb_eRuntimeError, "Cant find parent node, neither hascomponent nor hasorderedcomponent is there!");
|
508
|
+
}
|
509
|
+
}
|
506
510
|
|
507
511
|
UA_NodeId ia;
|
508
512
|
client_node_get_reference_by_name(ns->master->master, ns->id, UA_QUALIFIEDNAME(0,"InputArguments"), &ia, false);
|
@@ -525,21 +529,27 @@ static VALUE node_call(int argc, VALUE* argv, VALUE self) { //{{{
|
|
525
529
|
value_to_variant(RARRAY_AREF(splat, i),&inputArguments[i],proposal[i]);
|
526
530
|
}
|
527
531
|
|
532
|
+
size_t outputSize;
|
533
|
+
UA_Variant *output;
|
534
|
+
|
528
535
|
retval = UA_Client_call(
|
529
536
|
ns->master->master,
|
530
537
|
parent,
|
531
538
|
ns->id,
|
532
539
|
RARRAY_LEN(splat),
|
533
540
|
(UA_Variant *)&inputArguments,
|
534
|
-
|
535
|
-
|
541
|
+
&outputSize,
|
542
|
+
&output
|
536
543
|
);
|
537
544
|
|
538
|
-
|
539
|
-
|
540
|
-
|
545
|
+
if (retval == UA_STATUSCODE_GOOD && outputSize > 0) {
|
546
|
+
VALUE ret = rb_ary_new2(outputSize);
|
547
|
+
for (int i=0; i<outputSize; i++) {
|
548
|
+
rb_ary_store(ret,i,rb_ary_entry(extract_value(output[i]),0));
|
549
|
+
}
|
550
|
+
return rb_ary_entry(ret,0);
|
541
551
|
} else {
|
542
|
-
return
|
552
|
+
return Qnil;
|
543
553
|
}
|
544
554
|
} //}}}
|
545
555
|
|
@@ -621,7 +631,7 @@ void Init_client(void) {
|
|
621
631
|
cMethodNode = rb_define_class_under(cClient, "cMethodNode", cNode);
|
622
632
|
cVarNode = rb_define_class_under(cClient, "cVarNode", cNode);
|
623
633
|
|
624
|
-
Init_types();
|
634
|
+
Init_types(mOPCUA);
|
625
635
|
|
626
636
|
rb_define_alloc_func(cClient, client_alloc);
|
627
637
|
rb_define_method(cClient, "initialize", client_init, 3);
|
data/ext/opcua/helpers/finders.c
CHANGED
@@ -46,6 +46,34 @@ bool server_node_get_reference(UA_Server *server, UA_NodeId parent, UA_NodeId *r
|
|
46
46
|
return false;
|
47
47
|
}
|
48
48
|
|
49
|
+
bool server_node_get_reference_by_name(UA_Server *server, UA_NodeId parent, UA_QualifiedName name, UA_NodeId *result, bool inverse) {
|
50
|
+
UA_BrowseDescription bDes;
|
51
|
+
UA_BrowseDescription_init(&bDes);
|
52
|
+
bDes.nodeId = parent;
|
53
|
+
bDes.resultMask = UA_BROWSERESULTMASK_ALL;
|
54
|
+
bDes.browseDirection = inverse ? 1 : 0;
|
55
|
+
UA_BrowseResult bRes = UA_Server_browse(server, 999, &bDes);
|
56
|
+
|
57
|
+
for (int i=0; i < bRes.referencesSize; i++) {
|
58
|
+
UA_ReferenceDescription *ref = &(bRes.references[i]);
|
59
|
+
|
60
|
+
UA_QualifiedName qn; UA_QualifiedName_init(&qn);
|
61
|
+
UA_Server_readBrowseName(server, ref->nodeId.nodeId, &qn);
|
62
|
+
|
63
|
+
if (UA_QualifiedName_equal(&qn,&name)) {
|
64
|
+
UA_NodeId_copy(&ref->nodeId.nodeId,result);
|
65
|
+
|
66
|
+
UA_BrowseResult_deleteMembers(&bRes);
|
67
|
+
UA_BrowseResult_clear(&bRes);
|
68
|
+
return true;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
UA_BrowseResult_deleteMembers(&bRes);
|
73
|
+
UA_BrowseResult_clear(&bRes);
|
74
|
+
return false;
|
75
|
+
}
|
76
|
+
|
49
77
|
bool client_node_get_reference_by_name(UA_Client *client, UA_NodeId parent, UA_QualifiedName name, UA_NodeId *result, bool inverse) {
|
50
78
|
UA_BrowseRequest bReq;
|
51
79
|
UA_BrowseRequest_init(&bReq);
|
data/ext/opcua/helpers/finders.h
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
|
7
7
|
RUBY_EXTERN UA_BrowsePathResult node_browse_path(UA_Server *server, UA_NodeId relative, UA_NodeId ref, UA_QualifiedName mqn, bool inverse);
|
8
8
|
RUBY_EXTERN bool server_node_get_reference(UA_Server *server, UA_NodeId parent, UA_NodeId *result, bool inverse);
|
9
|
+
RUBY_EXTERN bool server_node_get_reference_by_name(UA_Server *server, UA_NodeId parent, UA_QualifiedName name, UA_NodeId *result, bool inverse);
|
9
10
|
RUBY_EXTERN bool client_node_get_reference_by_name(UA_Client *client, UA_NodeId parent, UA_QualifiedName name, UA_NodeId *result, bool inverse);
|
10
11
|
RUBY_EXTERN bool client_node_get_reference_by_type(UA_Client *client, UA_NodeId parent, UA_NodeId type, UA_NodeId *result, bool inverse);
|
11
12
|
RUBY_EXTERN bool client_node_list_references(UA_Client *client, UA_NodeId parent, bool inverse);
|
data/ext/opcua/helpers/values.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#include "values.h"
|
2
2
|
|
3
|
-
VALUE
|
3
|
+
VALUE mTYPES;
|
4
4
|
|
5
5
|
/* -- */
|
6
6
|
static void variant_set_one_dimension(UA_Variant *variant,UA_UInt32 len) { //{{{
|
@@ -154,8 +154,16 @@ bool value_to_variant(VALUE value, UA_Variant *variant, UA_UInt32 proposal) { //
|
|
154
154
|
case T_SYMBOL:
|
155
155
|
{
|
156
156
|
VALUE str = rb_obj_as_string(value);
|
157
|
-
|
158
|
-
|
157
|
+
if (proposal == UA_TYPES_STRING) {
|
158
|
+
UA_String tmp = UA_STRING(StringValuePtr(str));
|
159
|
+
UA_Variant_setScalarCopy(variant, &tmp, &UA_TYPES[UA_TYPES_STRING]);
|
160
|
+
} else if (proposal == UA_TYPES_NODEID) {
|
161
|
+
UA_NodeId tmp = UA_NODEID(StringValuePtr(str));
|
162
|
+
UA_Variant_setScalarCopy(variant, &tmp, &UA_TYPES[UA_TYPES_NODEID]);
|
163
|
+
} else if (proposal == UA_TYPES_BYTESTRING) {
|
164
|
+
UA_ByteString tmp = UA_BYTESTRING(StringValuePtr(str));
|
165
|
+
UA_Variant_setScalarCopy(variant, &tmp, &UA_TYPES[UA_TYPES_BYTESTRING]);
|
166
|
+
}
|
159
167
|
done = true;
|
160
168
|
break;
|
161
169
|
}
|
@@ -171,10 +179,11 @@ bool value_to_variant(VALUE value, UA_Variant *variant, UA_UInt32 proposal) { //
|
|
171
179
|
return done;
|
172
180
|
} //}}}
|
173
181
|
|
174
|
-
void Init_types() {/*{{{*/
|
182
|
+
void Init_types(VALUE mOPCUA) {/*{{{*/
|
175
183
|
mTYPES = rb_define_module_under(mOPCUA,"TYPES");
|
176
184
|
rb_define_const(mTYPES, "DATETIME", INT2NUM(UA_TYPES_DATETIME ));
|
177
185
|
rb_define_const(mTYPES, "BOOLEAN", INT2NUM(UA_TYPES_BOOLEAN ));
|
186
|
+
rb_define_const(mTYPES, "FLOAT", INT2NUM(UA_TYPES_FLOAT ));
|
178
187
|
rb_define_const(mTYPES, "DOUBLE", INT2NUM(UA_TYPES_DOUBLE ));
|
179
188
|
rb_define_const(mTYPES, "INT32", INT2NUM(UA_TYPES_INT32 ));
|
180
189
|
rb_define_const(mTYPES, "INT16", INT2NUM(UA_TYPES_INT16 ));
|
@@ -189,6 +198,9 @@ static VALUE UA_TYPES_DATETIME_to_value(UA_DateTime data) { //{{{
|
|
189
198
|
static VALUE UA_TYPES_BOOLEAN_to_value(UA_Boolean data) { //{{{
|
190
199
|
return data ? Qtrue : Qfalse;
|
191
200
|
} //}}}
|
201
|
+
static VALUE UA_TYPES_FLOAT_to_value(UA_Float data) { //{{{
|
202
|
+
return DBL2NUM((double)data);
|
203
|
+
} //}}}
|
192
204
|
static VALUE UA_TYPES_DOUBLE_to_value(UA_Double data) { //{{{
|
193
205
|
return DBL2NUM(data);
|
194
206
|
} //}}}
|
@@ -213,6 +225,9 @@ static VALUE UA_TYPES_UINT16_to_value(UA_UInt16 data) { //{{{
|
|
213
225
|
static VALUE UA_TYPES_STRING_to_value(UA_String data) { //{{{
|
214
226
|
return rb_str_export_locale(rb_str_new((char *)(data.data),data.length));
|
215
227
|
} //}}}
|
228
|
+
static VALUE UA_TYPES_BYTESTRING_to_value(UA_ByteString data) { //{{{
|
229
|
+
return rb_str_export_locale(rb_str_new((char *)(data.data),data.length));
|
230
|
+
} //}}}
|
216
231
|
|
217
232
|
VALUE extract_value(UA_Variant value) { //{{{
|
218
233
|
VALUE ret = rb_ary_new2(2);
|
@@ -228,6 +243,9 @@ VALUE extract_value(UA_Variant value) { //{{{
|
|
228
243
|
} else if (UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_BOOLEAN])) {
|
229
244
|
rb_ary_store(ret,0,UA_TYPES_BOOLEAN_to_value(*(UA_Boolean *)value.data));
|
230
245
|
rb_ary_store(ret,1,ID2SYM(rb_intern("VariantType.Boolean")));
|
246
|
+
} else if (UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_FLOAT])) {
|
247
|
+
rb_ary_store(ret,0,UA_TYPES_FLOAT_to_value(*(UA_Float *)value.data));
|
248
|
+
rb_ary_store(ret,1,ID2SYM(rb_intern("VariantType.Float")));
|
231
249
|
} else if (UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_DOUBLE])) {
|
232
250
|
rb_ary_store(ret,0,UA_TYPES_DOUBLE_to_value(*(UA_Double *)value.data));
|
233
251
|
rb_ary_store(ret,1,ID2SYM(rb_intern("VariantType.Double")));
|
@@ -252,6 +270,11 @@ VALUE extract_value(UA_Variant value) { //{{{
|
|
252
270
|
} else if (UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_STRING])) {
|
253
271
|
rb_ary_store(ret,0,UA_TYPES_STRING_to_value(*(UA_String *)value.data));
|
254
272
|
rb_ary_store(ret,1,ID2SYM(rb_intern("VariantType.String")));
|
273
|
+
} else if (UA_Variant_hasScalarType(&value, &UA_TYPES[UA_TYPES_BYTESTRING])) {
|
274
|
+
rb_ary_store(ret,0,UA_TYPES_BYTESTRING_to_value(*(UA_ByteString *)value.data));
|
275
|
+
rb_ary_store(ret,1,ID2SYM(rb_intern("VariantType.String")));
|
276
|
+
} else {
|
277
|
+
//printf("Unknown Datatype\n");
|
255
278
|
}
|
256
279
|
} else if (value.arrayDimensionsSize == 1 || (value.arrayDimensionsSize == 0 && value.arrayLength > 0)) {
|
257
280
|
if (UA_Variant_hasArrayType(&value, &UA_TYPES[UA_TYPES_DATETIME])) {
|
@@ -268,6 +291,13 @@ VALUE extract_value(UA_Variant value) { //{{{
|
|
268
291
|
for (int i=0; i < value.arrayLength; i++) {
|
269
292
|
rb_ary_push(res,UA_TYPES_BOOLEAN_to_value(((UA_Boolean *)value.data)[i]));
|
270
293
|
}
|
294
|
+
} else if (UA_Variant_hasArrayType(&value, &UA_TYPES[UA_TYPES_FLOAT])) {
|
295
|
+
VALUE res = rb_ary_new();
|
296
|
+
rb_ary_store(ret,0,res);
|
297
|
+
rb_ary_store(ret,1,ID2SYM(rb_intern("VariantType.Float")));
|
298
|
+
for (int i=0; i < value.arrayLength; i++) {
|
299
|
+
rb_ary_push(res,UA_TYPES_FLOAT_to_value(((UA_Float *)value.data)[i]));
|
300
|
+
}
|
271
301
|
} else if (UA_Variant_hasArrayType(&value, &UA_TYPES[UA_TYPES_DOUBLE])) {
|
272
302
|
VALUE res = rb_ary_new();
|
273
303
|
rb_ary_store(ret,0,res);
|
data/ext/opcua/helpers/values.h
CHANGED
@@ -4,9 +4,8 @@
|
|
4
4
|
#include <open62541.h>
|
5
5
|
#include <ruby.h>
|
6
6
|
|
7
|
-
VALUE mTYPES;
|
8
7
|
RUBY_EXTERN bool value_to_variant(VALUE value, UA_Variant *variant, UA_UInt32 proposal);
|
9
|
-
RUBY_EXTERN void Init_types();
|
8
|
+
RUBY_EXTERN void Init_types(VALUE mOPCUA);
|
10
9
|
RUBY_EXTERN VALUE extract_value(UA_Variant value);
|
11
10
|
|
12
11
|
#endif
|
data/ext/opcua/server/server.c
CHANGED
@@ -224,11 +224,15 @@ static UA_StatusCode node_add_method_callback( //{{{
|
|
224
224
|
rb_ary_push(args,rb_ary_entry(ret,0));
|
225
225
|
}
|
226
226
|
|
227
|
-
rb_proc_call(me->method,args);
|
227
|
+
VALUE ret = rb_proc_call(me->method,args);
|
228
|
+
|
229
|
+
if (outputSize == 1) {
|
230
|
+
value_to_variant(ret,output,-1);
|
231
|
+
}
|
228
232
|
|
229
233
|
return UA_STATUSCODE_GOOD;
|
230
234
|
} //}}}
|
231
|
-
static UA_NodeId node_add_method_ua(UA_NodeId n, UA_LocalizedText dn, UA_QualifiedName qn, node_struct *parent,size_t inputArgumentsSize,const UA_Argument *inputArguments, VALUE blk) { //{{{
|
235
|
+
static UA_NodeId node_add_method_ua(UA_NodeId n, UA_LocalizedText dn, UA_QualifiedName qn, node_struct *parent,size_t inputArgumentsSize,const UA_Argument *inputArguments,size_t outputArgumentsSize,const UA_Argument *outputArguments, VALUE blk) { //{{{
|
232
236
|
UA_MethodAttributes mnAttr = UA_MethodAttributes_default;
|
233
237
|
mnAttr.displayName = dn;
|
234
238
|
mnAttr.executable = true;
|
@@ -248,8 +252,8 @@ static UA_NodeId node_add_method_ua(UA_NodeId n, UA_LocalizedText dn, UA_Qualifi
|
|
248
252
|
&node_add_method_callback,
|
249
253
|
inputArgumentsSize,
|
250
254
|
inputArguments,
|
251
|
-
|
252
|
-
|
255
|
+
outputArgumentsSize,
|
256
|
+
outputArguments,
|
253
257
|
(void *)me,
|
254
258
|
NULL);
|
255
259
|
|
@@ -264,6 +268,8 @@ static UA_NodeId node_add_method_ua(UA_NodeId n, UA_LocalizedText dn, UA_Qualifi
|
|
264
268
|
} //}}}
|
265
269
|
static UA_NodeId node_add_method_ua_simple(char* nstr, node_struct *parent, VALUE opts, VALUE blk) { //{{{
|
266
270
|
UA_Argument inputArguments[RHASH_SIZE(opts)];
|
271
|
+
UA_Argument outputArguments[1];
|
272
|
+
int counter = 0;
|
267
273
|
|
268
274
|
VALUE ary = rb_funcall(opts, rb_intern("to_a"), 0);
|
269
275
|
for (long i=0; i<RARRAY_LEN(ary); i++) {
|
@@ -272,11 +278,20 @@ static UA_NodeId node_add_method_ua_simple(char* nstr, node_struct *parent, VALU
|
|
272
278
|
if (NIL_P(str) || TYPE(str) != T_STRING)
|
273
279
|
rb_raise(rb_eTypeError, "cannot convert obj to string");
|
274
280
|
char *nstr = (char *)StringValuePtr(str);
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
281
|
+
if (rb_str_cmp(str,rb_str_new2("return"))) {
|
282
|
+
UA_Argument_init(&inputArguments[counter]);
|
283
|
+
inputArguments[counter].description = UA_LOCALIZEDTEXT("en-US", nstr);
|
284
|
+
inputArguments[counter].name = UA_STRING(nstr);
|
285
|
+
inputArguments[counter].dataType = UA_TYPES[NUM2INT(RARRAY_AREF(item, 1))].typeId;
|
286
|
+
inputArguments[counter].valueRank = UA_VALUERANK_SCALAR;
|
287
|
+
counter++;
|
288
|
+
} else {
|
289
|
+
UA_Argument_init(&outputArguments[0]);
|
290
|
+
outputArguments[0].description = UA_LOCALIZEDTEXT("en-US", nstr);
|
291
|
+
outputArguments[0].name = UA_STRING(nstr);
|
292
|
+
outputArguments[0].dataType = UA_TYPES[NUM2INT(RARRAY_AREF(item, 1))].typeId;
|
293
|
+
outputArguments[0].valueRank = UA_VALUERANK_SCALAR;
|
294
|
+
}
|
280
295
|
}
|
281
296
|
int nodeid = nodecounter++;
|
282
297
|
|
@@ -288,8 +303,10 @@ static UA_NodeId node_add_method_ua_simple(char* nstr, node_struct *parent, VALU
|
|
288
303
|
UA_LOCALIZEDTEXT("en-US", nstr),
|
289
304
|
UA_QUALIFIEDNAME(parent->master->default_ns, nstr),
|
290
305
|
parent,
|
291
|
-
|
306
|
+
counter,
|
292
307
|
inputArguments,
|
308
|
+
RHASH_SIZE(opts)-counter,
|
309
|
+
outputArguments,
|
293
310
|
blk
|
294
311
|
);
|
295
312
|
} //}}}
|
@@ -556,16 +573,38 @@ static UA_StatusCode node_manifest_iter(UA_NodeId child_id, UA_Boolean is_invers
|
|
556
573
|
UA_BrowsePathResult_clear(&property);
|
557
574
|
}
|
558
575
|
if(nc == UA_NODECLASS_METHOD) {
|
559
|
-
UA_NodeId
|
576
|
+
UA_NodeId ia;
|
577
|
+
UA_NodeId oa;
|
560
578
|
VALUE blk = rb_hash_aref(parent->master->methods,INT2NUM(child_id.identifier.numeric));
|
561
|
-
|
579
|
+
|
580
|
+
bool iacheck = server_node_get_reference_by_name(parent->master->master, child_id, UA_QUALIFIEDNAME(0,"InputArguments"), &ia, false);
|
581
|
+
bool oacheck = server_node_get_reference_by_name(parent->master->master, child_id, UA_QUALIFIEDNAME(0,"OutputArguments"), &oa, false);
|
582
|
+
if (iacheck && oacheck) {
|
583
|
+
UA_Variant arv1; UA_Variant_init(&arv1);
|
584
|
+
UA_Variant arv2; UA_Variant_init(&arv2);
|
585
|
+
UA_Server_readValue(parent->master->master, ia, &arv1);
|
586
|
+
UA_Server_readValue(parent->master->master, oa, &arv2);
|
587
|
+
|
588
|
+
// todo differentiate between input and output reference
|
589
|
+
node_add_method_ua(UA_NODEID_STRING(parent->master->default_ns,buffer),dn,qn,newnode,arv1.arrayLength,(UA_Argument *)arv1.data,arv2.arrayLength,(UA_Argument *)arv2.data,blk);
|
590
|
+
UA_Variant_clear(&arv1);
|
591
|
+
UA_Variant_clear(&arv2);
|
592
|
+
} else if (iacheck) {
|
562
593
|
UA_Variant arv; UA_Variant_init(&arv);
|
563
|
-
UA_Server_readValue(parent->master->master,
|
594
|
+
UA_Server_readValue(parent->master->master, ia, &arv);
|
564
595
|
|
565
|
-
|
596
|
+
// todo differentiate between input and output reference
|
597
|
+
node_add_method_ua(UA_NODEID_STRING(parent->master->default_ns,buffer),dn,qn,newnode,arv.arrayLength,(UA_Argument *)arv.data,0,NULL,blk);
|
598
|
+
UA_Variant_clear(&arv);
|
599
|
+
} else if (oacheck) {
|
600
|
+
UA_Variant arv; UA_Variant_init(&arv);
|
601
|
+
UA_Server_readValue(parent->master->master, oa, &arv);
|
602
|
+
|
603
|
+
// todo differentiate between input and output reference
|
604
|
+
node_add_method_ua(UA_NODEID_STRING(parent->master->default_ns,buffer),dn,qn,newnode,0,NULL,arv.arrayLength,(UA_Argument *)arv.data,blk);
|
566
605
|
UA_Variant_clear(&arv);
|
567
606
|
} else {
|
568
|
-
node_add_method_ua(UA_NODEID_STRING(parent->master->default_ns,buffer),dn,qn,newnode,0,NULL,blk);
|
607
|
+
node_add_method_ua(UA_NODEID_STRING(parent->master->default_ns,buffer),dn,qn,newnode,0,NULL,0,NULL,blk);
|
569
608
|
}
|
570
609
|
}
|
571
610
|
}
|
@@ -861,7 +900,7 @@ static VALUE server_add_namespace(VALUE self, VALUE name) { //{{{
|
|
861
900
|
char *nstr = (char *)StringValuePtr(str);
|
862
901
|
|
863
902
|
pss->default_ns = UA_Server_addNamespace(pss->master, nstr);
|
864
|
-
return
|
903
|
+
return INT2NUM(pss->default_ns);
|
865
904
|
} //}}}
|
866
905
|
static VALUE server_types(VALUE self) { //{{{
|
867
906
|
server_struct *pss;
|
@@ -914,6 +953,21 @@ static VALUE server_namespaces(VALUE self) { //{{{
|
|
914
953
|
RB_OBJ_FREEZE(ret);
|
915
954
|
return rb_ary_entry(ret,0);
|
916
955
|
} //}}}
|
956
|
+
static VALUE server_active_namespace(VALUE self) { //{{{
|
957
|
+
server_struct *pss;
|
958
|
+
Data_Get_Struct(self, server_struct, pss);
|
959
|
+
return UINT2NUM(pss->default_ns);
|
960
|
+
} //}}}
|
961
|
+
static VALUE server_active_namespace_set(VALUE self, VALUE val) { //{{{
|
962
|
+
server_struct *pss;
|
963
|
+
Data_Get_Struct(self, server_struct, pss);
|
964
|
+
|
965
|
+
if (NIL_P(val) || TYPE(val) != T_FIXNUM)
|
966
|
+
rb_raise(rb_eTypeError, "namespace is not an integer");
|
967
|
+
|
968
|
+
pss->default_ns = NUM2UINT(val);
|
969
|
+
return self;
|
970
|
+
} //}}}
|
917
971
|
|
918
972
|
void Init_server(void) {
|
919
973
|
mOPCUA = rb_define_module("OPCUA");
|
@@ -924,7 +978,7 @@ void Init_server(void) {
|
|
924
978
|
rb_define_const(mOPCUA, "BASEDATAVARIABLETYPE", INT2NUM(UA_NS0ID_BASEDATAVARIABLETYPE));
|
925
979
|
rb_define_const(mOPCUA, "PROPERTYTYPE", INT2NUM(UA_NS0ID_PROPERTYTYPE));
|
926
980
|
|
927
|
-
Init_types();
|
981
|
+
Init_types(mOPCUA);
|
928
982
|
|
929
983
|
cServer = rb_define_class_under(mOPCUA, "Server", rb_cObject);
|
930
984
|
cNode = rb_define_class_under(cServer, "Node", rb_cObject);
|
@@ -941,6 +995,8 @@ void Init_server(void) {
|
|
941
995
|
rb_define_method(cServer, "initialize", server_init, 0);
|
942
996
|
rb_define_method(cServer, "run", server_run, 0);
|
943
997
|
rb_define_method(cServer, "add_namespace", server_add_namespace, 1);
|
998
|
+
rb_define_method(cServer, "active_namespace", server_active_namespace, 0);
|
999
|
+
rb_define_method(cServer, "active_namespace=", server_active_namespace_set, 1);
|
944
1000
|
rb_define_method(cServer, "types", server_types, 0);
|
945
1001
|
rb_define_method(cServer, "references", server_references, 0);
|
946
1002
|
rb_define_method(cServer, "objects", server_objects, 0);
|
@@ -957,7 +1013,7 @@ void Init_server(void) {
|
|
957
1013
|
rb_define_method(cNode, "exists?", node_exists, 0);
|
958
1014
|
|
959
1015
|
rb_define_method(cTypeTopNode, "add_object_type", node_add_object_type, 1);
|
960
|
-
rb_define_method(cTypeTopNode, "add_reference_type", node_add_reference_type,
|
1016
|
+
rb_define_method(cTypeTopNode, "add_reference_type", node_add_reference_type, 2);
|
961
1017
|
rb_define_method(cTypeTopNode, "folder", node_type_folder, 0);
|
962
1018
|
|
963
1019
|
rb_define_method(cTypeSubNode, "add_object_type", node_add_object_type, 1);
|
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.20"
|
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.20'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen eTM Mangler
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: tools
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: daemonite
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- cert/cert.h
|
75
75
|
- cert/cert_key.h
|
76
76
|
- example/bug5.rb
|
77
|
+
- example/client_get_float.rb
|
77
78
|
- example/client_get_sync.rb
|
78
79
|
- example/client_get_value.rb
|
79
80
|
- example/client_method.rb
|
@@ -83,6 +84,7 @@ files:
|
|
83
84
|
- example/server.rb
|
84
85
|
- example/server_deep.rb
|
85
86
|
- example/server_values.rb
|
87
|
+
- example/server_xml.rb
|
86
88
|
- example/test.rb
|
87
89
|
- ext/opcua/client/client.c
|
88
90
|
- ext/opcua/client/client.h
|
@@ -136,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
138
|
- !ruby/object:Gem::Version
|
137
139
|
version: '0'
|
138
140
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
141
|
+
rubygems_version: 3.1.2
|
140
142
|
signing_key:
|
141
143
|
specification_version: 4
|
142
144
|
summary: Preliminary release of opcua (open62541) ruby bindings. C performance, Ruby
|