-
-
Notifications
You must be signed in to change notification settings - Fork 355
doc(OpcDa): add MockOpcDaServer sample code #6563
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
Conversation
Reviewer's GuideIntroduce a new OPC DA sample by registering a real or mock server in the DI container based on OS, adding a demo menu entry with localization and documentation, and providing a Razor component showcasing connect, read, and subscription workflows Class diagram for OpcDa sample component and server registrationclassDiagram
class OpcDa {
- IOpcDaServer OpcDaServer
- string _serverName
- string Tag1
- string Tag2
- string Tag3
- string Tag4
- string _tagValue1
- string _tagValue2
- string _tagValue3
- string _tagValue4
- IOpcSubscription _subscription
- bool _subscribed
+ OnConnect()
+ OnDisConnect()
+ OnRead()
+ OnCreateSubscription()
+ OnCancelSubscription()
+ UpdateValues(List<OpcReadItem>)
}
class IOpcDaServer {
+ Connect(serverName)
+ Disconnect()
+ Read(tags)
+ CreateSubscription(name, interval, active)
+ CancelSubscription(subscription)
+ IsConnected
}
class IOpcSubscription {
+ AddItems(tags)
+ DataChanged
}
class OpcReadItem {
+ Value
}
OpcDa --> IOpcDaServer
OpcDa --> IOpcSubscription
IOpcSubscription --> OpcReadItem
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @ArgoZhang - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor.Server/Components/Samples/OpcDa.razor.cs:55` </location>
<code_context>
+ 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);
+ }
</code_context>
<issue_to_address>
Potential InvalidCastException if Value is not int.
Casting values.ElementAt(1).Value to int without checking its type can cause a runtime exception if the value is not an int. Use a type check or safe conversion to prevent this.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
var values = OpcDaServer.Read(Tag1, Tag2); | ||
_tagValue1 = values.ElementAt(0).Value?.ToString(); | ||
|
||
var v = (int)values.ElementAt(1).Value! / 100d; |
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.
issue (bug_risk): Potential InvalidCastException if Value is not int.
Casting values.ElementAt(1).Value to int without checking its type can cause a runtime exception if the value is not an int. Use a type check or safe conversion to prevent this.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6563 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 719 719
Lines 31560 31560
Branches 4450 4450
=========================================
Hits 31560 31560
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6562
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add a new OPC DA sample page and integrate a mock or real OPC DA server registration based on the operating system.
New Features:
Documentation: