-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix UseSecurity * Update nugets * Update version * Add and use NodeIdTypePrefix * Fix boiler by using NodeIdTypePrefix * Fix D-GUID by using NodeIdTypePrefix * Cosmetic * Add plugin nodes helper * Fix opaque by using NodeIdTypePrefix
- Loading branch information
1 parent
48097b9
commit f4ae203
Showing
17 changed files
with
217 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
| ||
namespace OpcPlc.Helpers; | ||
|
||
using Opc.Ua; | ||
using OpcPlc.PluginNodes.Models; | ||
using System; | ||
|
||
/// <summary> | ||
/// Helper class for plugin nodes. | ||
/// </summary> | ||
public class PluginNodesHelpers | ||
{ | ||
/// <summary> | ||
/// Get node with correct type prefix, id, namespace, and intervals. | ||
/// </summary> | ||
public static NodeWithIntervals GetNodeWithIntervals(NodeId nodeId, PlcNodeManager plcNodeManager) | ||
{ | ||
ExpandedNodeId expandedNodeId = NodeId.ToExpandedNodeId(nodeId, plcNodeManager.Server.NamespaceUris); | ||
|
||
return new NodeWithIntervals | ||
{ | ||
NodeId = expandedNodeId.IdType == IdType.Opaque | ||
? Convert.ToBase64String((byte[])expandedNodeId.Identifier) | ||
: expandedNodeId.Identifier.ToString(), | ||
NodeIdTypePrefix = GetTypePrefix(expandedNodeId.IdType), | ||
Namespace = expandedNodeId.NamespaceUri, | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// Get a single lowercase character that represents the type of the node. | ||
/// </summary> | ||
/// <exception cref="ArgumentOutOfRangeException"></exception> | ||
private static string GetTypePrefix(IdType idType) | ||
{ | ||
return idType switch | ||
{ | ||
IdType.Numeric => "i", | ||
IdType.String => "s", | ||
IdType.Guid => "g", | ||
IdType.Opaque => "b", | ||
_ => throw new ArgumentOutOfRangeException(nameof(idType), idType.ToString(), message: null), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.