-
-
Notifications
You must be signed in to change notification settings - Fork 362
doc(Modbu): add ModbusFactory documentation #6722
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 GuideThis PR enhances the ModbusFactories sample by replacing raw socket code examples with structured ModbusFactory documentation: it introduces protocol overviews, enumerates factory methods for creating/removing clients, details data operation methods, and includes minor formatting and configuration cleanups. Class diagram for ModbusFactory and related Modbus client typesclassDiagram
class IModbusFactory {
+GetOrCreateTcpMaster(name, options)
+GetOrCreateUdpMaster(name, options)
+GetOrCreateRtuMaster(name, options)
+GetOrCreateRtuOverTcpMaster(name, options)
+GetOrCreateRtuOverUdpMaster(name, options)
+RemoveTcpMaster(name)
+RemoveUdpMaster(name)
+RemoveRtuMaster(name)
+RemoveRtuOverTcpMaster(name)
+RemoveRtuOverUdpMaster(name)
}
class IModbusClient {
+ReadCoilsAsync()
+WriteCoilAsync()
+WriteMultipleCoilsAsync()
+ReadInputsAsync()
+ReadInputRegistersAsync()
+ReadHoldingRegistersAsync()
+WriteRegisterAsync()
+WriteMultipleRegistersAsync()
}
class IModbusTcpClient {
<<interface>>
}
class IModbusRtuClient {
<<interface>>
}
IModbusFactory --> IModbusTcpClient : creates
IModbusFactory --> IModbusRtuClient : creates
IModbusTcpClient --|> IModbusClient
IModbusRtuClient --|> IModbusClient
Class diagram for Modbus data types and operationsclassDiagram
class Coils {
<<data type>>
+ReadCoilsAsync()
+WriteCoilAsync()
+WriteMultipleCoilsAsync()
}
class DiscreteInputs {
<<data type>>
+ReadInputsAsync()
}
class InputRegisters {
<<data type>>
+ReadInputRegistersAsync()
}
class HoldingRegisters {
<<data type>>
+ReadHoldingRegistersAsync()
+WriteRegisterAsync()
+WriteMultipleRegistersAsync()
}
IModbusClient --> Coils
IModbusClient --> DiscreteInputs
IModbusClient --> InputRegisters
IModbusClient --> HoldingRegisters
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.
Pull Request Overview
This PR adds documentation for the ModbusFactory component, providing comprehensive guidance on Modbus protocol implementation and usage. The changes focus on replacing generic TCP socket documentation with specific Modbus communication examples and explanations.
- Adds new documentation page for ModbusFactory with detailed Modbus protocol coverage
- Updates package versions for Longbow.Modbus and Longbow.TcpSocket
- Registers the new ModbusFactory documentation in the docs navigation
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| docs.json | Adds routing entry for the new ModbusFactory documentation page |
| ModbusFactories.razor | Replaces TCP socket documentation with comprehensive Modbus protocol documentation covering RTU, TCP/IP variants and data operations |
| BootstrapBlazor.Server.csproj | Updates Longbow.Modbus from 9.0.0 to 9.0.2 and Longbow.TcpSocket from 9.0.3 to 9.0.4 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| <li><b>粘包</b>:比如我们期望收到 <b>1234</b> 四个字符,实际上我们接收到的是 <b>123412</b> 多出来的 <b>12</b> 其实是下一个数据包的内容,我们需要截取前 4 位数据作为一个数据包才能正确处理数据,这种相邻两个通讯数据包的粘连称为<b>粘包</b></li> | ||
| <li><b>分包</b>:比如我们期望收到 <b>1234</b> 四个字符,实际上我们可能分两次接收到,分别是 <b>12</b> 和 <b>34</b>,我们需要将两个数据包拼接成一个才能正确的处理数据。这种情况称为<b>分包</b></li> | ||
| <li>通过 <code>GetOrCreateTcpMaster</code> 方法得到 <code>IModbusTcpClient</code> 实例</li> | ||
| <li>通过 <code>GetOrCreateUdpMaster</code> 方法得到 <code>IModbusTcpClient</code> 实例</li> |
Copilot
AI
Sep 7, 2025
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.
The GetOrCreateUdpMaster method should return IModbusUdpClient, not IModbusTcpClient. UDP and TCP are different protocols and should have distinct client types.
| <li>通过 <code>GetOrCreateUdpMaster</code> 方法得到 <code>IModbusTcpClient</code> 实例</li> | |
| <li>通过 <code>GetOrCreateUdpMaster</code> 方法得到 <code>IModbusUdpClient</code> 实例</li> |
| <li>通过 <code>GetOrCreateUdpMaster</code> 方法得到 <code>IModbusTcpClient</code> 实例</li> | ||
| <li>通过 <code>GetOrCreateRtuMaster</code> 方法得到 <code>IModbusRtuClient</code> 实例</li> | ||
| <li>通过 <code>GetOrCreateRtuOverTcpMaster</code> 方法得到 <code>IModbusTcpClient</code> 实例</li> | ||
| <li>通过 <code>GetOrCreateRtuOverUdpMaster</code> 方法得到 <code>IModbusTcpClient</code> 实例</li> |
Copilot
AI
Sep 7, 2025
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.
The GetOrCreateRtuOverUdpMaster method should return IModbusUdpClient, not IModbusTcpClient. This method uses UDP protocol and should have the corresponding client type.
| <li>通过 <code>GetOrCreateRtuOverUdpMaster</code> 方法得到 <code>IModbusTcpClient</code> 实例</li> | |
| <li>通过 <code>GetOrCreateRtuOverUdpMaster</code> 方法得到 <code>IModbusUdpClient</code> 实例</li> |
| <li>通过 <code>GetOrCreateRtuMaster</code> 方法得到 <code>IModbusRtuClient</code> 实例</li> | ||
| <li>通过 <code>GetOrCreateRtuOverTcpMaster</code> 方法得到 <code>IModbusTcpClient</code> 实例</li> | ||
| <li>通过 <code>GetOrCreateRtuOverUdpMaster</code> 方法得到 <code>IModbusTcpClient</code> 实例</li> |
Copilot
AI
Sep 7, 2025
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.
Inconsistent indentation using tabs instead of spaces. The first line uses spaces while lines 35-36 use tabs. This should be consistent throughout the file.
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 there - I've reviewed your changes - here's some feedback:
- The ModbusFactories.razor.cs file is empty except for whitespace—either remove it or add the intended logic to avoid orphaned partial classes.
- Double-check that GetOrCreateUdpMaster and GetOrCreateRtuOverUdpMaster return the correct UDP client interface rather than IModbusTcpClient for clearer API semantics.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The ModbusFactories.razor.cs file is empty except for whitespace—either remove it or add the intended logic to avoid orphaned partial classes.
- Double-check that GetOrCreateUdpMaster and GetOrCreateRtuOverUdpMaster return the correct UDP client interface rather than IModbusTcpClient for clearer API semantics.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6722 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 739 739
Lines 31713 31713
Branches 4462 4462
=========================================
Hits 31713 31713
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 #6721
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add comprehensive ModbusFactory documentation to the sample page
Documentation: