-
-
Notifications
You must be signed in to change notification settings - Fork 362
doc(SerialPort): add ISerialPortFactory documentation #6775
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
8 commits
Select commit
Hold shift + click to select a range
d02fbee
doc: 更新 ModbusFactory 文档
ArgoZhang 3ccdc1f
doc: 更新 SocketFactory 文档
ArgoZhang fc90832
doc: 更新 SocketClient 文档
ArgoZhang 0941dbf
doc: 增加菜单
ArgoZhang a462eb4
doc: 增加源码文件映射
ArgoZhang ddeba8a
doc: 增加串口通信服务文档
ArgoZhang e6859ba
doc: 更新注意事项
ArgoZhang 2a46e7b
doc: 增加串口参数配置类文档
ArgoZhang 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
12 changes: 6 additions & 6 deletions
12
src/BootstrapBlazor.Server/Components/Samples/Modbus/ModbusFactories.razor
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
50 changes: 50 additions & 0 deletions
50
src/BootstrapBlazor.Server/Components/Samples/SerialPorts/SerialPortFactories.razor
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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| @page "/serial-port-factory" | ||
| @inject IStringLocalizer<SerialPortFactories> Localizer | ||
|
|
||
| <h3>SerialPort 串行通信服务 <code>ISerialPortFactory</code></h3> | ||
| <h4>组件库内置了 SerialPort 串口通信服务</h4> | ||
|
|
||
| <PackageTips Name="Longbow.SerialPort" /> | ||
|
|
||
| <Tips><div>特别注意:本服务不支持 <code>wasm</code> 模式</div></Tips> | ||
|
|
||
| <p class="code-label">1. 服务注入</p> | ||
|
|
||
| <Pre>services.AddSerialPortFactory();</Pre> | ||
|
|
||
| <Pre>[Inject] | ||
| [NotNull] | ||
| private ISerialPortFactory? SerialPortFactory { get; set; }</Pre> | ||
|
|
||
| <p class="code-label">2. 使用服务</p> | ||
| <p>调用 <code>SerialPortFactory</code> 实例方法 <code>GetOrCreate</code> 即可得到一个 <code>ISerialPortClient</code> 实例。内部提供复用机制,调用两次得到的 <code>ISerialPortClient</code> 为同一对象</p> | ||
|
|
||
| <p class="code-label">3. 通过工厂获得相对应协议 <code>ISerialPortClient</code> 实例</p> | ||
|
|
||
| <p><code>ISerialPortFactory</code> 实例方法</p> | ||
|
|
||
| <ul class="ul-demo"> | ||
| <li>通过 <code>GetOrCreate</code> 获得 <code>ISerialPortClient</code> 实例</li> | ||
| <li>通过 <code>Remove</code> 移除指定名称的 <code>ISerialPortClient</code> 实例</li> | ||
| </ul> | ||
|
|
||
| <Pre>SerialPortFactory.Remove("test");</Pre> | ||
|
|
||
| <p>可以通过注入服务直接获得 <code>ISerialPortClient</code> 实例</p> | ||
|
|
||
| <Pre>[Inject] | ||
| [NotNull] | ||
| private ISerialPortClient? SerialPortClient { get; set; }</Pre> | ||
|
|
||
| <p><code>ISerialPortClient</code> 实例方法</p> | ||
|
|
||
| <ul class="ul-demo"> | ||
| <li>打开端口方法 <code>OpenAsync</code></li> | ||
| <li>发送数据方法 <code>SendAsync</code></li> | ||
| <li>接收数据方法 <code>ReceiveAsync</code></li> | ||
| <li>关闭端口方法 <code>CloseAsync</code></li> | ||
| </ul> | ||
|
|
||
| <p class="code-label">4. 串口参数配置类 <code>SerialPortOptions</code></p> | ||
|
|
||
| <p>通过此配置类对串口参数进行配置</p> | ||
14 changes: 14 additions & 0 deletions
14
src/BootstrapBlazor.Server/Components/Samples/SerialPorts/SerialPortFactories.razor.cs
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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the Apache 2.0 License | ||
| // See the LICENSE file in the project root for more information. | ||
| // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone | ||
|
|
||
| namespace BootstrapBlazor.Server.Components.Samples.SerialPorts; | ||
|
|
||
| /// <summary> | ||
| /// ISerialPortFactory 服务说明文档 | ||
| /// </summary> | ||
| public partial class SerialPortFactories | ||
| { | ||
|
|
||
ArgoZhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
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 |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| // See the LICENSE file in the project root for more information. | ||
| // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone | ||
|
|
||
| using Longbow.SerialPorts; | ||
| using Microsoft.AspNetCore.Components.Routing; | ||
|
|
||
| namespace BootstrapBlazor.Server.Extensions; | ||
|
|
@@ -97,6 +98,13 @@ public static List<MenuItem> GenerateMenus(this IStringLocalizer<NavMenu> Locali | |
| }; | ||
| AddModbus(item); | ||
|
|
||
| item = new DemoMenuItem() | ||
| { | ||
| Text = Localizer["SerialPortComponents"], | ||
| Icon = "fa-fw fa-solid fa-satellite-dish text-danger" | ||
| }; | ||
| AddSerialPort(item); | ||
|
|
||
| item = new DemoMenuItem() | ||
| { | ||
| Text = Localizer["Services"], | ||
|
|
@@ -266,6 +274,21 @@ void AddModbus(DemoMenuItem item) | |
| AddBadge(item, count: 2); | ||
| } | ||
|
|
||
| void AddSerialPort(DemoMenuItem item) | ||
| { | ||
| item.Items = new List<DemoMenuItem> | ||
| { | ||
| new() | ||
| { | ||
| IsNew = true, | ||
| Text = Localizer["SerialPortFactory"], | ||
| Url = "serial-port-factory" | ||
| } | ||
| }; | ||
|
|
||
| AddBadge(item, count: 2); | ||
ArgoZhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| void AddQuickStar(DemoMenuItem item) | ||
| { | ||
| item.Items = new List<DemoMenuItem> | ||
|
|
||
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
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.
suggestion: Consider providing a usage example for SerialPortOptions.
Including a short code example or listing common configuration parameters would clarify usage for users.