Skip to content

Update the driver after real world experience - #1253

Open
seveneleven wants to merge 7 commits into
devfrom
fix/opcua-driver-async-init
Open

Update the driver after real world experience#1253
seveneleven wants to merge 7 commits into
devfrom
fix/opcua-driver-async-init

Conversation

@seveneleven

Copy link
Copy Markdown
Contributor

The changes in this commit is the result of observations made within real world applications. It substantially addresses bugs and performance issues. Unfortunately the change set got quite big because many changes have been made in parallel or caused each other.

The two biggest changes are:

  • The async API has already been introduced with MORYX 10 and got implemented properly
  • NodeBrowsing got abandoned: It took too much time to read all nodes on the OPC UA server (depending on servers ~40s to serveral minutes). While most of the time, only a small subset is used in an application, there was no reason to browse them all (and keep them in memory) compared to lazy load them when needed.

Sorry for this being quite big. Please take into account, that this is not even ready yet and I also left some 'TODOs' here and there, where I did not have the time to further investigate.
I'd like this PR to get a review because these changes have been around for some time now and I also want to gather opinions on some of the decisions being made so far (there is a breaking change for example which I considered fine as the driver should be beta).

The changes in this commit is the result of observations made within real
world applications. It substantially addresses bugs and performance issues.
Unfortunately the change set got quite big because many changes have been
made in parallel or caused each other.

The two biggest changes are:

* The async API has already been introduced with MORYX 10 and got implemented
  properly
* NodeBrowsing got abandoned: It took too much time to read all nodes on the
  OPC UA server (depending on servers ~40s to serveral minutes). While most of
  the time, only a small subset is used in an application, there was no reason
  to browse them all (and keep them in memory) compared to lazy load them when
  needed.
@seveneleven
seveneleven requested a review from 1nf0rmagician June 8, 2026 13:49
@seveneleven seveneleven self-assigned this Jun 8, 2026

@dbeuchler dbeuchler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's draft... but I have scrolled through the changes and found some breaking changes for dev. Just keep in mind.


/// <inheritdoc />
public OpcUaNode(IOpcUaDriver driver, IModuleLogger logger, string identifier)
public OpcUaNode(IOpcUaDriver driver, IModuleLogger logger, string identifier, NodeClass nodeClass)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breaking change

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be easy to make minor conform, just add a commit after this PR is ready which can then be easily reverted on future 🙂

Comment thread src/Moryx.Drivers.OpcUa/IOpcUaDriver.cs Outdated
Comment on lines +21 to +22
Task AddSubscriptionAsync(OpcUaNode node, CancellationToken cancellationToken = default);
Task AddSubscriptionAsync(string nodeId, CancellationToken cancellationToken = default);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breaking change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] and I also want to gather opinions on some of the decisions being made so far (there is a breaking change for example which I considered fine as the driver should be beta).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a breaking change for example which I considered fine as the driver should be beta

What is beta? The driver was released several times and we should not break the API

Comment on lines +15 to +19
/// <param name="nodeId"></param>
/// <param name="namespaceTable"></param>
/// <param name="session"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fill or remove

@1nf0rmagician 1nf0rmagician added the enhancement New feature or request label Jun 9, 2026
@1nf0rmagician 1nf0rmagician added this to the Framework 10.x milestone Jun 9, 2026

@1nf0rmagician 1nf0rmagician left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All test I saw removed concerned the browse feature, or have I overlooked anything that I should have paid closer attention to?

public static Category ParentCategory(this Resource resource)
{
var parentType = resource.Parent?.GetType();
if (parentType == null)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a fix related to #1239, did it slip into this PR?

@@ -62,7 +62,7 @@ public class OpcUaNode : IMessageChannel
/// <summary>
/// List of all Subnodes. This property is null, when the node is no object node

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is a missmatch?


/// <inheritdoc />
public OpcUaNode(IOpcUaDriver driver, IModuleLogger logger, string identifier)
public OpcUaNode(IOpcUaDriver driver, IModuleLogger logger, string identifier, NodeClass nodeClass)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be easy to make minor conform, just add a commit after this PR is ready which can then be easily reverted on future 🙂

Comment thread src/Moryx.Drivers.OpcUa/States/BrowsingNodesOnServerState.cs
Context.ReadDeviceSet();
return Task.CompletedTask;
await base.OnEnterAsync(cancellationToken);
Context.RemoveSubscription();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't we done this on the disconnect?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will investigate and test that

}

internal override void AddSubscription(OpcUaNode node)
internal override OpcUaNode GetNode(string identifier)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you didn't make this async as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I browsed through some of the changes, I think, back then I decided to not update it because the name didn't fit the *Async convention (which is the same for AddSubscription). I'm open to change this, though.

Comment thread src/Moryx.Drivers.OpcUa/States/RunningState.cs
Comment thread src/Moryx.Drivers.OpcUa/OpcUaNodeReader.cs
<ItemGroup>
<ProjectReference Include="..\..\Moryx.Drivers.OpcUa\Moryx.Drivers.OpcUa.csproj" />
</ItemGroup>
<ItemGroup>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ncessary?

@seveneleven

Copy link
Copy Markdown
Contributor Author

All test I saw removed concerned the browse feature, or have I overlooked anything that I should have paid closer attention to?

Yes, they were mainly related to that.

@seveneleven
seveneleven marked this pull request as ready for review August 24, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants