-
-
Notifications
You must be signed in to change notification settings - Fork 362
feat(OpcDa): bump version 9.0.3 #6600
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ | |
| // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone | ||
|
|
||
| using BootstrapBlazor.OpcDa; | ||
| using System.Globalization; | ||
|
|
||
| namespace BootstrapBlazor.Server.Components.Samples; | ||
|
|
||
|
|
@@ -17,12 +16,10 @@ public partial class OpcDa : ComponentBase | |
| [NotNull] | ||
| private IOpcDaServer? OpcDaServer { get; set; } | ||
|
|
||
| private string? _serverName = "opcda://localhost/Kepware.KEPServerEX.V6/Mock"; | ||
| private string? _serverName = "opcda://localhost/Kepware.KEPServerEX.V6"; | ||
|
|
||
| private const string Tag1 = "Channel1.Device1.Tag1"; | ||
| private const string Tag2 = "Channel1.Device1.Tag2"; | ||
| private const string Tag3 = "Channel1.Device1.Tag3"; | ||
| private const string Tag4 = "Channel1.Device1.Tag4"; | ||
|
|
||
| private string? _tagValue1; | ||
| private string? _tagValue2; | ||
|
|
@@ -49,19 +46,25 @@ private void OnDisConnect() | |
|
|
||
| private void OnRead() | ||
| { | ||
| var values = OpcDaServer.Read(Tag1, Tag2); | ||
| _tagValue1 = values.ElementAt(0).Value?.ToString(); | ||
|
|
||
| var v = (int)values.ElementAt(1).Value! / 100d; | ||
| _tagValue2 = v.ToString(CultureInfo.InvariantCulture); | ||
| var items = OpcDaServer.Read(Tag1, Tag2); | ||
| var value1 = items.FirstOrDefault(i => i.Name == Tag1).Value; | ||
| if (value1 != null) | ||
| { | ||
| _tagValue1 = value1.ToString(); | ||
| } | ||
| var value2 = items.FirstOrDefault(i => i.Name == Tag2).Value; | ||
| if (value2 != null) | ||
| { | ||
| _tagValue2 = value2.ToString(); | ||
| } | ||
| } | ||
|
|
||
| private void OnCreateSubscription() | ||
| { | ||
| _subscribed = true; | ||
| _subscription = OpcDaServer.CreateSubscription("Subscription1", 1000, true); | ||
| _subscription.DataChanged += UpdateValues; | ||
| _subscription.AddItems([Tag3, Tag4]); | ||
| _subscription.AddItems([Tag1, Tag2]); | ||
| } | ||
|
|
||
| private void OnCancelSubscription() | ||
|
|
@@ -76,9 +79,16 @@ private void OnCancelSubscription() | |
|
|
||
| private void UpdateValues(List<OpcReadItem> items) | ||
| { | ||
| _tagValue3 = items[0].Value?.ToString(); | ||
| var v = (int)items[1].Value! / 100d; | ||
| _tagValue4 = v.ToString(CultureInfo.InvariantCulture); | ||
| var value1 = items.Find(i => i.Name == Tag1).Value; | ||
| if (value1 != null) | ||
| { | ||
| _tagValue3 = value1.ToString(); | ||
| } | ||
| var value2 = items.Find(i => i.Name == Tag2).Value; | ||
| if (value2 != null) | ||
| { | ||
| _tagValue4 = value2.ToString(); | ||
| } | ||
|
|
||
| InvokeAsync(StateHasChanged); | ||
| } | ||
|
|
@@ -88,12 +98,12 @@ private void UpdateValues(List<OpcReadItem> items) | |
| private void OnBrowse() | ||
| { | ||
| var elements = OpcDaServer.Browse("", new OpcBrowseFilters(), out _); | ||
| _roots = elements.Select(element => new TreeViewItem<OpcBrowseElement>(element) | ||
| _roots = [.. elements.Select(element => new TreeViewItem<OpcBrowseElement>(element) | ||
| { | ||
| Text = element.Name, | ||
| HasChildren = element.HasChildren, | ||
| Icon = "fa-solid fa-fw fa-cubes" | ||
| }).ToList(); | ||
| })]; | ||
| } | ||
|
|
||
| private Task<IEnumerable<TreeViewItem<OpcBrowseElement>>> OnExpandNodeAsync(TreeViewItem<OpcBrowseElement> element) | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.