Skip to content

Commit b5362be

Browse files
committed
Clarify initialization sequence and configuration handling.
Make sure binding generates unique channel ids and propagate configured refresh/publish interval to subscription. Fixes #111. Signed-off-by: Łukasz Dywicki <luke@code-house.org>
1 parent c5874ae commit b5362be

File tree

9 files changed

+127
-96
lines changed

9 files changed

+127
-96
lines changed

bundles/org.connectorio.addons.binding.opcua/docs/opcua/descriptors/bridge-types.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ Below table contains complete configuration of `co7io-opcua:client`.
5555
| Request timeout
5656
|
5757

58-
| publishInterval
58+
| refreshInterval
5959
| INTEGER
60-
| Publish interval
61-
| Default publish interval for all subscriptions made through this connection.
60+
| Refresh interval
61+
| Time between subscription publish calls.
6262

6363
|===
6464

bundles/org.connectorio.addons.binding.opcua/docs/opcua/descriptors/channel-types.adoc

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ Below table contain configuration parameters which can be assigned to channels o
122122
| Identifier
123123
| Node identifier - value interpretation depends on identifier type.
124124

125-
| publishInterval
125+
| refreshInterval
126126
| INTEGER
127-
| Publish interval
127+
| Refresh interval
128128
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
129129

130130
|===
@@ -154,9 +154,9 @@ Below table contain configuration parameters which can be assigned to channels o
154154
| Identifier
155155
| Node identifier - value interpretation depends on identifier type.
156156

157-
| publishInterval
157+
| refreshInterval
158158
| INTEGER
159-
| Publish interval
159+
| Refresh interval
160160
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
161161

162162
|===
@@ -186,9 +186,9 @@ Below table contain configuration parameters which can be assigned to channels o
186186
| Identifier
187187
| Node identifier - value interpretation depends on identifier type.
188188

189-
| publishInterval
189+
| refreshInterval
190190
| INTEGER
191-
| Publish interval
191+
| Refresh interval
192192
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
193193

194194
|===
@@ -218,9 +218,9 @@ Below table contain configuration parameters which can be assigned to channels o
218218
| Identifier
219219
| Node identifier - value interpretation depends on identifier type.
220220

221-
| publishInterval
221+
| refreshInterval
222222
| INTEGER
223-
| Publish interval
223+
| Refresh interval
224224
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
225225

226226
|===
@@ -250,9 +250,9 @@ Below table contain configuration parameters which can be assigned to channels o
250250
| Identifier
251251
| Node identifier - value interpretation depends on identifier type.
252252

253-
| publishInterval
253+
| refreshInterval
254254
| INTEGER
255-
| Publish interval
255+
| Refresh interval
256256
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
257257

258258
|===
@@ -282,9 +282,9 @@ Below table contain configuration parameters which can be assigned to channels o
282282
| Identifier
283283
| Node identifier - value interpretation depends on identifier type.
284284

285-
| publishInterval
285+
| refreshInterval
286286
| INTEGER
287-
| Publish interval
287+
| Refresh interval
288288
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
289289

290290
|===
@@ -314,9 +314,9 @@ Below table contain configuration parameters which can be assigned to channels o
314314
| Identifier
315315
| Node identifier - value interpretation depends on identifier type.
316316

317-
| publishInterval
317+
| refreshInterval
318318
| INTEGER
319-
| Publish interval
319+
| Refresh interval
320320
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
321321

322322
|===
@@ -346,9 +346,9 @@ Below table contain configuration parameters which can be assigned to channels o
346346
| Identifier
347347
| Node identifier - value interpretation depends on identifier type.
348348

349-
| publishInterval
349+
| refreshInterval
350350
| INTEGER
351-
| Publish interval
351+
| Refresh interval
352352
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
353353

354354
|===
@@ -378,9 +378,9 @@ Below table contain configuration parameters which can be assigned to channels o
378378
| Identifier
379379
| Node identifier - value interpretation depends on identifier type.
380380

381-
| publishInterval
381+
| refreshInterval
382382
| INTEGER
383-
| Publish interval
383+
| Refresh interval
384384
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
385385

386386
|===
@@ -410,9 +410,9 @@ Below table contain configuration parameters which can be assigned to channels o
410410
| Identifier
411411
| Node identifier - value interpretation depends on identifier type.
412412

413-
| publishInterval
413+
| refreshInterval
414414
| INTEGER
415-
| Publish interval
415+
| Refresh interval
416416
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
417417

418418
|===
@@ -442,9 +442,9 @@ Below table contain configuration parameters which can be assigned to channels o
442442
| Identifier
443443
| Node identifier - value interpretation depends on identifier type.
444444

445-
| publishInterval
445+
| refreshInterval
446446
| INTEGER
447-
| Publish interval
447+
| Refresh interval
448448
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
449449

450450
|===
@@ -474,9 +474,9 @@ Below table contain configuration parameters which can be assigned to channels o
474474
| Identifier
475475
| Node identifier - value interpretation depends on identifier type.
476476

477-
| publishInterval
477+
| refreshInterval
478478
| INTEGER
479-
| Publish interval
479+
| Refresh interval
480480
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
481481

482482
|===
@@ -506,9 +506,9 @@ Below table contain configuration parameters which can be assigned to channels o
506506
| Identifier
507507
| Node identifier - value interpretation depends on identifier type.
508508

509-
| publishInterval
509+
| refreshInterval
510510
| INTEGER
511-
| Publish interval
511+
| Refresh interval
512512
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
513513

514514
|===
@@ -538,9 +538,9 @@ Below table contain configuration parameters which can be assigned to channels o
538538
| Identifier
539539
| Node identifier - value interpretation depends on identifier type.
540540

541-
| publishInterval
541+
| refreshInterval
542542
| INTEGER
543-
| Publish interval
543+
| Refresh interval
544544
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
545545

546546
|===
@@ -570,9 +570,9 @@ Below table contain configuration parameters which can be assigned to channels o
570570
| Identifier
571571
| Node identifier - value interpretation depends on identifier type.
572572

573-
| publishInterval
573+
| refreshInterval
574574
| INTEGER
575-
| Publish interval
575+
| Refresh interval
576576
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
577577

578578
|===

bundles/org.connectorio.addons.binding.opcua/docs/opcua/descriptors/config-descriptions.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
| Identifier
2424
| Node identifier - value interpretation depends on identifier type.
2525

26-
| publishInterval
26+
| refreshInterval
2727
| INTEGER
28-
| Publish interval
28+
| Refresh interval
2929
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
3030

3131
|===
@@ -66,10 +66,10 @@
6666
| Request timeout
6767
|
6868

69-
| publishInterval
69+
| refreshInterval
7070
| INTEGER
71-
| Publish interval
72-
| Default publish interval for all subscriptions made through this connection.
71+
| Refresh interval
72+
| Time between subscription publish calls.
7373

7474
|===
7575

bundles/org.connectorio.addons.binding.opcua/docs/opcua/descriptors/thing-types.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ Supported bridges:
4545
| Identifier
4646
| Node identifier - value interpretation depends on identifier type.
4747

48-
| publishInterval
48+
| refreshInterval
4949
| INTEGER
50-
| Publish interval
50+
| Refresh interval
5151
| Default publish interval for all subscriptions made for this node. By default, it is set to 0 to inherit value specified at connection level.
5252

5353
|===

bundles/org.connectorio.addons.binding.opcua/src/main/java/org/connectorio/addons/binding/opcua/internal/config/ClientConfig.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
*/
1818
package org.connectorio.addons.binding.opcua.internal.config;
1919

20-
import org.connectorio.addons.binding.config.Configuration;
20+
import org.connectorio.addons.binding.config.PollingConfiguration;
2121

22-
public class ClientConfig implements Configuration {
22+
public class ClientConfig extends PollingConfiguration {
2323

2424
public String host;
2525
public int port = 4848;
@@ -30,6 +30,4 @@ public class ClientConfig implements Configuration {
3030
public int requestTimeout = 10_000;
3131
public int connectTimeout = 10_000;
3232

33-
public long publishInterval = 1000L;
34-
3533
}

bundles/org.connectorio.addons.binding.opcua/src/main/java/org/connectorio/addons/binding/opcua/internal/config/NodeConfig.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,20 @@
1717
*/
1818
package org.connectorio.addons.binding.opcua.internal.config;
1919

20+
import java.math.BigDecimal;
2021
import java.util.HashMap;
2122
import java.util.Map;
2223
import java.util.UUID;
23-
import org.connectorio.addons.binding.config.Configuration;
24+
import org.connectorio.addons.binding.config.PollingConfiguration;
2425
import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString;
2526
import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
26-
import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger;
2727
import org.openhab.core.util.HexUtils;
2828

29-
public class NodeConfig implements Configuration {
29+
public class NodeConfig extends PollingConfiguration {
3030

3131
public int ns;
3232
public IdentifierType identifierType;
33-
public Integer identifier;
34-
public String stringIdentifier = "";
35-
public long publishInterval = 0L;
33+
public String identifier;
3634

3735
public enum IdentifierType {
3836
i, s, g, b;
@@ -41,36 +39,37 @@ public enum IdentifierType {
4139
public NodeId createNodeId() {
4240
switch (this.identifierType) {
4341
case i:
44-
return new NodeId(this.ns, UInteger.valueOf(this.identifier));
42+
try {
43+
return new NodeId(this.ns, new BigDecimal(this.identifier.trim()).intValue());
44+
} catch (NumberFormatException e) {
45+
return null;
46+
}
4547
case s:
46-
return new NodeId(this.ns, this.stringIdentifier);
48+
return new NodeId(this.ns, this.identifier);
4749
case g:
48-
return new NodeId(this.ns, UUID.fromString(this.stringIdentifier));
50+
return new NodeId(this.ns, UUID.fromString(this.identifier));
4951
case b:
50-
return new NodeId(this.ns, ByteString.of(HexUtils.hexToBytes(this.stringIdentifier)));
52+
return new NodeId(this.ns, ByteString.of(HexUtils.hexToBytes(this.identifier)));
5153
}
5254
return null;
5355
}
5456

5557
public static Map<String, Object> createNodeConfig(NodeId nodeId) {
5658
Map<String, Object> config = new HashMap<>();
5759
config.put("ns", nodeId.getNamespaceIndex().intValue());
60+
config.put("identifier", nodeId.getIdentifier().toString());
5861
switch (nodeId.getType()) {
5962
case Numeric:
6063
config.put("identifierType", IdentifierType.i.name());
61-
config.put("identifier", nodeId.getIdentifier());
6264
break;
6365
case String:
6466
config.put("identifierType", IdentifierType.s.name());
65-
config.put("stringIdentifier", nodeId.getIdentifier());
6667
break;
6768
case Guid:
6869
config.put("identifierType", IdentifierType.g.name());
69-
config.put("stringIdentifier", nodeId.getIdentifier());
7070
break;
7171
case Opaque:
7272
config.put("identifierType", IdentifierType.b.name());
73-
config.put("stringIdentifier", nodeId.getIdentifier());
7473
break;
7574
}
7675

0 commit comments

Comments
 (0)