Skip to content

Commit

Permalink
Code improvements, added support for multiple companion specs in a si…
Browse files Browse the repository at this point in the history
…ngle WoT file, moved UA type out of Modbus protocol binding section, renamed UA methods to be spec compliant again.
  • Loading branch information
barnstee committed Feb 23, 2024
1 parent d0785a7 commit f9e4c09
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 247 deletions.
2 changes: 2 additions & 0 deletions Models/AssetTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ public class AssetTag
public string Entity { get; set; }

public string MappedUAExpandedNodeID { get; set; }

public string MappedUAFieldPath { get; set; }
}
}
33 changes: 15 additions & 18 deletions Models/ThingDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
namespace Opc.Ua.Edge.Translator.Models
{
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

public partial class ThingDescription
public class ThingDescription
{
[JsonProperty("@context")]
public object[] Context { get; set; }
Expand Down Expand Up @@ -34,21 +35,24 @@ public partial class ThingDescription
[JsonProperty("properties")]
public Dictionary<string, Property> Properties { get; set; }

[JsonProperty("opcua:nodeId")]
public string OpcUaObjectNode { get; set; }

[JsonProperty("opcua:type")]
public string OpcUaObjectType { get; set; }
public string OpcUaType { get; set; }
}

[JsonProperty("opcua:parent")]
public string OpcUaParentNode { get; set; }
public class OpcUaNamespaces
{
[JsonProperty("opcua")]
public Uri[] Namespaces { get; set; }
}

public partial class Property
public class Property
{
[JsonProperty("type")]
public TypeEnum Type { get; set; }

[JsonProperty("opcua:type")]
public string OpcUaType { get; set; }

[JsonProperty("readOnly")]
public bool ReadOnly { get; set; }

Expand All @@ -59,7 +63,7 @@ public partial class Property
public object[] Forms { get; set; }
}

public partial class ModbusForm
public class ModbusForm
{
[JsonProperty("href")]
public string Href { get; set; }
Expand All @@ -76,24 +80,17 @@ public partial class ModbusForm
[JsonProperty("modv:pollingTime")]
public long ModbusPollingTime { get; set; }


[JsonProperty("opcua:nodeId")]
public string OpcUaVariableNode { get; set; }

[JsonProperty("opcua:type")]
public string OpcUaType { get; set; }

[JsonProperty("opcua:fieldpath")]
public string OpcUaFieldPath { get; set; }
}

public partial class SecurityDefinitions
public class SecurityDefinitions
{
[JsonProperty("nosec_sc")]
public NosecSc NosecSc { get; set; }
}

public partial class NosecSc
public class NosecSc
{
[JsonProperty("scheme")]
public string Scheme { get; set; }
Expand Down
16 changes: 6 additions & 10 deletions Samples/pac4200.td.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"@context": [
"https://www.w3.org/2022/wot/td/v1.1",
{
"opcua": "http://opcfoundation.org/UA/PNEM/"
"opcua": [
"http://opcfoundation.org/UA/PNEM/"
]
}
],
"id": "urn:pac4200",
Expand All @@ -24,6 +26,7 @@
"properties": {
"VoltageL-N": {
"type": "number",
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"readOnly": true,
"observable": true,
"forms": [
Expand All @@ -33,7 +36,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "A",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -45,7 +47,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "B",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -57,7 +58,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "C",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand Down Expand Up @@ -118,6 +118,7 @@
},
"Current": {
"type": "number",
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"readOnly": true,
"observable": true,
"forms": [
Expand All @@ -127,7 +128,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "A",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -139,7 +139,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "B",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -151,7 +150,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "C",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -161,6 +159,7 @@
},
"PowerFactor": {
"type": "number",
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"readOnly": true,
"observable": true,
"forms": [
Expand All @@ -170,7 +169,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "A",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -182,7 +180,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "B",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -194,7 +191,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "C",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand Down
16 changes: 6 additions & 10 deletions Samples/pac4200.tm.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"@context": [
"https://www.w3.org/2022/wot/td/v1.1",
{
"opcua": "http://opcfoundation.org/UA/PNEM/"
"opcua": [
"http://opcfoundation.org/UA/PNEM/"
]
}
],
"id": "urn:pac4200",
Expand All @@ -24,6 +26,7 @@
"properties": {
"VoltageL-N": {
"type": "number",
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"readOnly": true,
"observable": true,
"forms": [
Expand All @@ -33,7 +36,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "A",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -45,7 +47,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "B",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -57,7 +58,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "C",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand Down Expand Up @@ -118,6 +118,7 @@
},
"Current": {
"type": "number",
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"readOnly": true,
"observable": true,
"forms": [
Expand All @@ -127,7 +128,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "A",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -139,7 +139,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "B",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -151,7 +150,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "C",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -161,6 +159,7 @@
},
"PowerFactor": {
"type": "number",
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"readOnly": true,
"observable": true,
"forms": [
Expand All @@ -170,7 +169,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "A",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -182,7 +180,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "B",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand All @@ -194,7 +191,6 @@
"readproperty",
"observeproperty"
],
"opcua:type": "nsu=http://opcfoundation.org/UA/PNEM/;i=3005",
"opcua:fieldpath": "C",
"modv:type": "xsd:float",
"modv:entity": "holdingRegister",
Expand Down
Loading

0 comments on commit f9e4c09

Please sign in to comment.