FlybeatController 1.0.0
Additional Details
高危漏洞
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package FlybeatController --version 1.0.0
NuGet\Install-Package FlybeatController -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FlybeatController" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FlybeatController" Version="1.0.0" />
<PackageReference Include="FlybeatController" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FlybeatController --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FlybeatController, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FlybeatController@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FlybeatController&version=1.0.0
#tool nuget:?package=FlybeatController&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FlybeatController
用于控制相机和光源的命令构建和通信库。支持串口和TCP通信协议,提供流畅的链式API来构建命令。
功能特点
- 支持相机和光源命令的构建
- 支持串口和TCP通信
- 链式API设计
- 异步操作支持
- 类型安全的枚举值
- 资源自动管理
安装
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
使用示例
1. 相机命令
// 构建相机命令
var command = CameraCommandBuilder.CAM()
.SetStation("Station1") // 设置工位
.SetEnabled(true) // 设置启用状态
.SetTriggerPosition("Pos1") // 设置触发位置
.Build();
// 使用串口发送命令
using (var sender = new SerialCommandSender("COM1", 9600))
{
await sender.ConnectAsync();
await sender.SendCommandAsync(command);
}
// 或使用TCP发送命令
var tcpSender = new TcpCommandSender("localhost", 8080);
await tcpSender.ConnectAsync();
await tcpSender.SendCommandAsync(command);
2. 光源命令
// 构建光源命令
var command = LightCommandBuilder.LIGHT()
.SetLightId("Light1") // 设置光源ID
.SetLightTriggerSource("Source1") // 设置触发源
.SetWorkMode(LightWorkMode.LightMode) // 设置工作模式(使用枚举)
.SetBrightness("200") // 设置亮度
.SetLightingTime("1000") // 设置亮起时间
.SetEnabled(true) // 设置启用状态
.SetLightSignal(true) // 设置点亮信号
.Build();
// 发送命令
using (var sender = new SerialCommandSender("COM1", 9600))
{
await sender.ConnectAsync();
await sender.SendCommandAsync(command);
}
3. 从数据行构建命令
// 假设有一个包含配置的字典
Dictionary<string, object> rowData = new Dictionary<string, object>
{
{ "工位", "Station1" },
{ "启用状态", true },
{ "相机触发源", "Pos1" }
};
// 构建相机命令
var cameraCommand = CameraCommandBuilder.CAM()
.SetStation(rowData["工位"].ToString())
.SetEnabledFromDataRow(rowData["启用状态"])
.SetTriggerPosition(rowData["相机触发源"].ToString())
.Build();
// 光源配置数据
var lightData = new Dictionary<string, object>
{
{ "光源标识", "Light1" },
{ "光源触发源", "Source1" },
{ "启用状态", true },
{ "亮度", "200" },
{ "亮起时间", "1000" },
{ "工作模式", "点亮模式" },
{ "点亮状态", true }
};
// 构建光源命令(完整方式)
var lightCommand = LightCommandBuilder.LIGHT()
.SetLightId(lightData["光源标识"].ToString())
.SetLightTriggerSource(lightData["光源触发源"].ToString())
.SetEnabledFromDataRow(lightData["启用状态"])
.SetBrightnessIfExists(lightData["亮度"])
.SetLightingTimeIfExists(lightData["亮起时间"])
.SetWorkModeFromDataRow(lightData["工作模式"])
.SetLightSignalFromDataRow(lightData["点亮状态"])
.Build();
// 或使用简洁方式
var lightCommandConcise = LightCommandBuilder.LIGHT()
.SetLightId(lightData["光源标识"].ToString())
.SetLightTriggerSource(lightData["光源触发源"].ToString())
.SetWorkMode(LightWorkMode.LightMode) // 直接使用枚举
.SetBrightness("200")
.Build();
注意事项
- 串口通信使用了
SerialPortHelper类进行封装,提供了更好的异步支持和资源管理 - 所有的通信操作都是异步的,请使用
await等待操作完成 - 使用
using语句确保资源正确释放 - 工作模式使用枚举类型
LightWorkMode提供类型安全 - 支持从数据行直接构建命令,提供了多种便捷方法
错误处理
try
{
using (var sender = new SerialCommandSender("COM1", 9600))
{
await sender.ConnectAsync();
await sender.SendCommandAsync(command);
}
}
catch (InvalidOperationException ex)
{
// 处理串口未打开等错误
Console.WriteLine($"操作错误: {ex.Message}");
}
catch (Exception ex)
{
// 处理其他错误
Console.WriteLine($"发生错误: {ex.Message}");
}
扩展性
该库设计时考虑了扩展性,您可以:
- 实现自己的
ICommandSender来支持其他通信协议 - 创建新的命令类型,继承
BaseCommand - 添加新的命令构建器,继承
BaseCommandBuilder
贡献
欢迎提交问题和改进建议!
许可证
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- System.IO.Ports (>= 9.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
为飞拍控制器提供的SDK驱动