Skip to content

Commit b51266c

Browse files
committed
Merge remote-tracking branch 'upstream/future' into remove/report-from-interrupt-operation
2 parents b3279d1 + 2fe2836 commit b51266c

File tree

3 files changed

+65
-90
lines changed

3 files changed

+65
-90
lines changed

Directory.Packages.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<dotnetVersion>8.0.1</dotnetVersion>
1212
<efCoreVersion>8.0.22</efCoreVersion>
1313

14-
<AspNetCoreVersion>8.0.21</AspNetCoreVersion>
14+
<AspNetCoreVersion>8.0.22</AspNetCoreVersion>
1515
</PropertyGroup>
1616

1717
<ItemGroup>
@@ -45,9 +45,9 @@
4545

4646
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.11" />
4747

48-
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.14.0" />
49-
<PackageVersion Include="Microsoft.Identity.Web" Version="4.0.1" />
50-
<PackageVersion Include="Microsoft.Identity.Web.DownstreamApi" Version="4.0.1" />
48+
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.15.0" />
49+
<PackageVersion Include="Microsoft.Identity.Web" Version="4.1.0" />
50+
<PackageVersion Include="Microsoft.Identity.Web.DownstreamApi" Version="4.1.0" />
5151

5252
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
5353

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) 2025, Phoenix Contact GmbH & Co. KG
22
// Licensed under the Apache License, Version 2.0
33

4-
using Moryx.AbstractionLayer.Drivers;
54
using Moryx.AbstractionLayer.Drivers.InOut;
65
using Moryx.AbstractionLayer.Drivers.Message;
76

@@ -10,7 +9,7 @@ namespace Moryx.Drivers.OpcUa;
109
/// <summary>
1110
/// Opc Ua Client
1211
/// </summary>
13-
public interface IOpcUaDriver : IDriver, IMessageDriver<object>, IMessageDriver<OpcUaMessage>, IInOutDriver<object, object>
12+
public interface IOpcUaDriver : IMessageDriver<object>, IMessageDriver<OpcUaMessage>, IInOutDriver<object, object>
1413
{
1514
// TODO 6.3: Subscriptions with different publishing and sampling intervals can be created
1615
// TODO 6.2: Subscriptions to ObjectNodes are possible
@@ -23,19 +22,24 @@ public interface IOpcUaDriver : IDriver, IMessageDriver<object>, IMessageDriver<
2322
/// <summary>
2423
/// Read the value of a Node
2524
/// </summary>
26-
/// <param name="NodeId">NodeId</param>
25+
/// <param name="nodeId">NodeId</param>
2726
/// <returns>If node doesn't exists or there was an error, when trying to read
28-
/// the node, the return value will be null</returns>
29-
object ReadNode(string NodeId);
27+
/// the node, the return value will be null</returns>
28+
object ReadNode(string nodeId);
29+
30+
/// <summary>
31+
/// Read the value of a Node
32+
/// </summary>
33+
/// <param name="nodeId">NodeId</param>
34+
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is None.</param>
35+
/// <returns>If node doesn't exists or there was an error, when trying to read
36+
/// the node, the return value will be null</returns>
37+
Task<object> ReadNodeAsync(string nodeId, CancellationToken cancellationToken = default);
3038

3139
/// <summary>
3240
/// Rebrowse Nodes
3341
/// </summary>
3442
void RebrowseNodes();
35-
}
36-
37-
public interface IOpcUaDriver2 : IOpcUaDriver
38-
{
3943

4044
/// <summary>
4145
/// Returns an opcUaNode to a string
@@ -52,50 +56,10 @@ public interface IOpcUaDriver2 : IOpcUaDriver
5256
void WriteNode(string nodeId, object payload);
5357

5458
/// <summary>
55-
/// Invokes the method of a method noe
59+
/// Write a value to a node
5660
/// </summary>
57-
/// <param name="nodeId"></param>
58-
/// <param name="parameters"></param>
59-
/// <returns>returns null, if type of the node doesn't fit or node not found</returns>
60-
List<object> InvokeMethod(string nodeId, object[] parameters);
61-
}
62-
63-
public static class OpcUaDriverExtensions
64-
{
65-
public static OpcUaNode GetNode(this IOpcUaDriver driver, string nodeId)
66-
{
67-
if (driver is IOpcUaDriver2 d2)
68-
{
69-
return d2.GetNode(nodeId);
70-
}
71-
else
72-
{
73-
throw new NotSupportedException();
74-
}
75-
}
76-
77-
public static void WriteNode(this IOpcUaDriver driver, string nodeId, object payload)
78-
{
79-
if (driver is IOpcUaDriver2 d2)
80-
{
81-
d2.WriteNode(nodeId, payload);
82-
}
83-
else
84-
{
85-
throw new NotSupportedException();
86-
}
87-
}
88-
89-
public static List<object> InvokeMethod(this IOpcUaDriver driver, string nodeId, object[] parameters)
90-
{
91-
if (driver is IOpcUaDriver2 d2)
92-
{
93-
return d2.InvokeMethod(nodeId, parameters);
94-
}
95-
else
96-
{
97-
throw new NotSupportedException();
98-
}
99-
}
100-
61+
/// <param name="nodeId">id of the representing OpcUaNode</param>
62+
/// <param name="payload">value to be written to the node</param>
63+
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is None.</param>
64+
Task WriteNodeAsync(string nodeId, object payload, CancellationToken cancellationToken = default);
10165
}

src/Moryx.Drivers.OpcUa/OpcUaDriver.cs

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ namespace Moryx.Drivers.OpcUa;
2727
/// </summary>
2828
[ResourceRegistration]
2929
[Display(Name = nameof(Strings.OpcUaDriver_DisplayName), Description = nameof(Strings.OpcUaDriver_Description), ResourceType = typeof(Strings))]
30-
public class OpcUaDriver : Driver, IOpcUaDriver2
30+
public class OpcUaDriver : Driver, IOpcUaDriver
3131
{
3232
//TODO 6.1 Invoke Methods
3333

34-
private const int NODE_LAYERS_SHOWN = 5;
34+
private const int NodeLayersShown = 5;
3535
/// <summary>
3636
/// Current tate of the driver
3737
/// </summary>
@@ -808,7 +808,7 @@ private void BrowseNodes(NodeId nodeId, NamespaceTable namespaceTable, List<OpcU
808808
_nodesFlat.Add(node.Identifier, node);
809809
}
810810

811-
if (layer < NODE_LAYERS_SHOWN)
811+
if (layer < NodeLayersShown)
812812
{
813813
list.Add(node);
814814
}
@@ -843,7 +843,7 @@ private OpcUaNode ConvertToNode(ReferenceDescription referenceDescription, Names
843843
#endregion
844844

845845
#region Read and write nodes
846-
/// <inheritdoc/>
846+
847847
public void WriteNode(OpcUaNode node, object payload)
848848
{
849849
State.WriteNode(node, payload);
@@ -855,6 +855,12 @@ public void WriteNode(string nodeId, object payload)
855855
WriteNode(node, payload);
856856
}
857857

858+
/// <inheritdoc />
859+
public Task WriteNodeAsync(string nodeId, object payload, CancellationToken cancellationToken = default)
860+
{
861+
throw new NotImplementedException();
862+
}
863+
858864
internal void OnWriteNode(OpcUaNode node, object payload)
859865
{
860866

@@ -879,9 +885,15 @@ internal void OnWriteNode(OpcUaNode node, object payload)
879885
}
880886
}
881887
/// <inheritdoc/>
882-
public object ReadNode(string NodeId)
888+
public object ReadNode(string nodeId)
883889
{
884-
return ReadNodeDataValue(NodeId).Result.Value;
890+
return ReadNodeDataValue(nodeId).Result.Value;
891+
}
892+
893+
/// <inheritdoc />
894+
public Task<object> ReadNodeAsync(string nodeId, CancellationToken cancellationToken = default)
895+
{
896+
throw new NotImplementedException();
885897
}
886898

887899
private DataValueResult ReadNodeDataValue(string nodeId)
@@ -978,12 +990,12 @@ public Task SendAsync(OpcUaMessage payload, CancellationToken cancellationToken
978990
/// <summary>
979991
/// Method to read nodes from the ui for testing
980992
/// </summary>
981-
/// <param name="NodeId"></param>
993+
/// <param name="nodeId"></param>
982994
/// <returns></returns>
983995
[EntrySerialize]
984-
public string ReadNodeAsString(string NodeId)
996+
public string ReadNodeAsString(string nodeId)
985997
{
986-
var value = ReadNodeDataValue(NodeId);
998+
var value = ReadNodeDataValue(nodeId);
987999
if (value == null)
9881000
{
9891001
return "There was an error, when trying to read the value of the node. Please look into the log for further information";
@@ -1027,29 +1039,34 @@ private object CreateValue(BuiltInType type, string stringValue)
10271039
{
10281040
switch (type)
10291041
{
1030-
case BuiltInType.Boolean: return bool.Parse(stringValue);
1031-
1032-
case BuiltInType.Int16: return short.Parse(stringValue);
1042+
case BuiltInType.Boolean:
1043+
return bool.Parse(stringValue);
1044+
case BuiltInType.Int16:
1045+
return short.Parse(stringValue);
10331046
case BuiltInType.Enumeration:
10341047
case BuiltInType.Integer:
1035-
case BuiltInType.Int32: return int.Parse(stringValue);
1036-
case BuiltInType.Int64: return long.Parse(stringValue);
1037-
case BuiltInType.UInt16: return ushort.Parse(stringValue);
1048+
case BuiltInType.Int32:
1049+
return int.Parse(stringValue);
1050+
case BuiltInType.Int64:
1051+
return long.Parse(stringValue);
1052+
case BuiltInType.UInt16:
1053+
return ushort.Parse(stringValue);
10381054
case BuiltInType.UInteger:
1039-
case BuiltInType.UInt32: return uint.Parse(stringValue);
1040-
case BuiltInType.UInt64: return ulong.Parse(stringValue);
1041-
case BuiltInType.DateTime: return DateTime.Parse(stringValue);
1042-
1055+
case BuiltInType.UInt32:
1056+
return uint.Parse(stringValue);
1057+
case BuiltInType.UInt64:
1058+
return ulong.Parse(stringValue);
1059+
case BuiltInType.DateTime:
1060+
return DateTime.Parse(stringValue);
10431061
case BuiltInType.Guid:
1044-
case BuiltInType.String: return stringValue;
1045-
1062+
case BuiltInType.String:
1063+
return stringValue;
10461064
case BuiltInType.Number:
10471065
case BuiltInType.Float:
10481066
case BuiltInType.Double:
10491067
return double.Parse(stringValue);
1050-
1051-
case BuiltInType.Byte: return byte.Parse(stringValue);
1052-
1068+
case BuiltInType.Byte:
1069+
return byte.Parse(stringValue);
10531070
}
10541071
}
10551072
catch (Exception ex)
@@ -1063,9 +1080,9 @@ private object CreateValue(BuiltInType type, string stringValue)
10631080
}
10641081

10651082
[EntrySerialize]
1066-
public List<string> FindNodeId(string Displayname)
1083+
public List<string> FindNodeId(string displayName)
10671084
{
1068-
var result = _nodesFlat.Where(x => x.Value.DisplayName.ToLower().Contains(Displayname.ToLower()) || x.Value.DisplayName.ToLower().Equals(Displayname.ToLower()))
1085+
var result = _nodesFlat.Where(x => x.Value.DisplayName.ToLower().Contains(displayName.ToLower()) || x.Value.DisplayName.ToLower().Equals(displayName.ToLower()))
10691086
.Select(x => x.Key).ToList();
10701087

10711088
return result;
@@ -1145,11 +1162,5 @@ internal void ReadDeviceSet()
11451162
DeviceSet.Add(deviceType);
11461163

11471164
}
1148-
1149-
}
1150-
1151-
public List<object> InvokeMethod(string nodeId, object[] parameters)
1152-
{
1153-
throw new NotImplementedException();
11541165
}
11551166
}

0 commit comments

Comments
 (0)