-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom structures client #15
Open
oroulet
wants to merge
11
commits into
master
Choose a base branch
from
custom-struc-client
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d797841
remove more useless mut arg declarations
58a9d87
Simplify a bit creating RelativePath in a common case
a1c8f98
add example client to read custom structs and enums from server
1ed3684
Update samples/custom-structures-client/src/main.rs
oroulet 47edbf6
Update samples/custom-structures-client/src/main.rs
oroulet 5b2f57e
refactor partially Errors, make creating relative paths easy
4a1e02f
split client in two
0d24a32
some servers give a special meaning to numeric node_id set to 0. bett…
47dac10
add some simple constructor for WriteValues
2555dc0
Make writting a value with SimpleNodeManager work..
edffb9d
add writting in custom struct example client and server example
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "opcua-structure-client" | ||
version = "0.13.0" # OPCUARustVersion | ||
authors = ["Rust-OpcUa contributors"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
pico-args = "0.5" | ||
tokio = { version = "1.36.0", features = ["full"] } | ||
log = { workspace = true } | ||
|
||
[dependencies.async-opcua] | ||
path = "../../async-opcua" | ||
version = "0.13.0" # OPCUARustVersion | ||
features = ["client", "console-logging"] | ||
default-features = false | ||
|
||
[features] | ||
default = ["json", "xml"] | ||
json = ["async-opcua/json"] | ||
xml = ["async-opcua/xml"] |
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,6 @@ | ||
To run this sample: | ||
|
||
1. Launch `samples/demo-server` as that server exposes custom enums and variables | ||
2. Run as `cargo run` | ||
|
||
The client connects to the server, reads a variable and disconnects. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@einarmo when adding write to example client, I found out I would recevied BadNotWrittable . Looking at the code, it looks like only callbacks where supported for that SimpleNodeManager... So I added that as an exercise
I am doing something completely wrong or that code was really missing? Don't we have tests for that node manager?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused with how you changed the code here. There may have been a bug, but I don't think the old code was so wrong you needed to completely rewrite it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your issue may be that there's an unwritten assumption here. If you define a write callback you should also define a read callback. It's assumed that in this case the value is stored externally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no, reading your code, you added writing to the variable even without a callback. I don't want to support this, because IMO it never makes sense in a real server, only in a toy. In any real server you want all writes to somehow have a permanent effect, which means that you need a callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I added writing value to address space without callback, so in memory and no persistence.
I have been working with ua in at least 15 years now and we do that all the time. There are so many cases where you do not need persistence.
In that particular case I am writting a PLC emulator and I really do not care about persistence. I want it to restart as per the config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm.. Alright.., but I'll ask you to change the first bit of the code back, the line where I checked if it was a
Variable
node. Your code is semantically mostly the same, but I don't see a reason for the change.I still think my argument holds. OPC-UA is an interface, if you are interfacing with nothing then there's no real point to allowing writes at all. A PLC simulator would still want to actually simulate the PLC, meaning it would need to handle writes. Deferring that to the interface layer is, IMO, a misuse of the library.
Essentially you're abusing the fact that OPC-UA kinda looks like your PLC to use it to store simulation values, while what OPC-UA is actually used for is to allow access to values in some real system, simulation or not.
But it's fine, the simple node manager is not really the right choice for most real OPC-UA servers anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I checked again and you are right we are in fact not doing that for anything else than CI.
Maybe I can just remove that code and use some CB. In an example we should show best practices. but maybe in that case we should make that method return some clear error or at least log something for the developers.
that was to make borrow checker happy, since I reused some variables. but it will become obsolete if I remove that anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can make that work, you shouldn't be calling
set_attribute
anyway, but the more advancedset_value_range
, I think...I gave this some more thought and I think I'm fine with your change. The conflict I think comes from the fact that I consider an OPC-UA server something you build on top of an existing system, to provide an interface. If what you do is instead create something that acts as a client and reacts on changes instead of being directly triggered by writes, it would indeed make sense to store the value.
The users do still have control over whether values should be written, since they have the
AccessLevel
attribute.I'm at least open for looking into it more. Perhaps we could disallow writes if a read callback was defined? I'm open for opinions on this.