Darra.PnS.SDK
1.0.3
dotnet add package Darra.PnS.SDK --version 1.0.3
NuGet\Install-Package Darra.PnS.SDK -Version 1.0.3
<PackageReference Include="Darra.PnS.SDK" Version="1.0.3" />
<PackageVersion Include="Darra.PnS.SDK" Version="1.0.3" />
<PackageReference Include="Darra.PnS.SDK" />
paket add Darra.PnS.SDK --version 1.0.3
#r "nuget: Darra.PnS.SDK, 1.0.3"
#:package Darra.PnS.SDK@1.0.3
#addin nuget:?package=Darra.PnS.SDK&version=1.0.3
#tool nuget:?package=Darra.PnS.SDK&version=1.0.3
Darra Profinet Slave · C# SDK
PROFINET IO Device(从站)C# SDK。程序集 DarraPnS,NuGet 包名 Darra.PnS.SDK(未上架 NuGet 公共源)。RT Class 1,不支持 IRT。程序集目标框架 netstandard2.0(.NET Framework 4.7.2 及更高、.NET 6/8 均可直接引用)。
运行需要先安装 Darra Profinet Slave 安装包。
对照 ETH:状态用 static 属性随时看;IO 才 new 实例。C# static 成员与实例成员不能同名,所以 static 属性叫 ServiceConnected / ServiceState,循环里用 device.Connected。
static vs 实例
static DarraPnS.* |
实例 device.* |
|
|---|---|---|
| 何时 | 随时,不必 new |
IO 会话:new → Start → 读写 → Stop |
| 占唯一实时门 | 否 | 否(构造不占);Start() 才占 |
| 启用 IO 设备 | 否 | Start() 才启用 IO |
| 能力 | LastError / LastErrorCode / IsServiceReady / ServiceConnected / ServiceState / ServiceWaitReason / ServiceStatusMessage |
Start / Stop / 读 I / 写 Q / Connected / State / WaitReason / LastServiceError |
| 服务没起来 | Connected=false,State=Unknown,文案「服务未就绪」,写 LastError,不抛 |
可构造;Start() 再占门 + 启用 IO |
不要把读写 I/Q、Start / Stop 做成 static(必须有会话)。
安装 · Install
未上架 NuGet 公共源,从本地 nupkg 安装。两条渠道:官网下载页取 Darra.PnS.SDK.nupkg;或安装包自带 C:\DARRA\Profinet_Slave\SDK\SDK_CSharp\(Darra.PnS.SDK.1.0.2.nupkg)。
dotnet add package Darra.PnS.SDK --source <nupkg 所在目录>
Install-Package Darra.PnS.SDK -Source <nupkg 所在目录>
官方 CDN:
Invoke-WebRequest https://download.darra.xyz/profinet/csharp/Darra.PnS.SDK.nupkg -OutFile Darra.PnS.SDK.nupkg
包内 runtimes/win-x64/native/Core.dll 为运行库,需随程序一起分发。
示例 · Example
看状态用 static 属性(GUI 占着唯一门时别的程序仍能看):
using Darra.PnS;
bool ready = DarraPnS.IsServiceReady;
bool master = DarraPnS.ServiceConnected;
PnSState st = DarraPnS.ServiceState;
string wait = DarraPnS.ServiceWaitReason;
string msg = DarraPnS.ServiceStatusMessage;
string err = DarraPnS.LastError;
IO 才 new(Start 才占门 + 启用 IO)。产品是 写 Q、读 I:
using Darra.PnS;
using (var device = new DarraPnS())
{
device.Start();
device.Write(new byte[] { 0x11, 0x22, 0x33, 0x44 }); // 写 Q(设备 → 控制器)
device.Read(out byte[] fromPlc); // 读 I(控制器 → 设备)
device.Stop();
}
写 Q 的交付语义(Success = 已在共享区)
Q 区(设备 → 控制器)的单一权威是驱动共享区过程映像。地址化写(Write / WriteBool / WriteInt16 / WriteInt32 / WriteArea / ProcessData.Write)在调用内当场提交到共享区,返回 PnSErrorCode.Success 当且仅当字节已落共享区;写路径不按节拍延迟提交,不存在"先攒着、稍后补交"却报成功。
| 情况 | 返回 | LastServiceError |
说明 |
|---|---|---|---|
| 已写入共享区 | Success |
不变 | 字节已在共享区,驱动按周期组帧发出 |
| 过程数据通道未就绪 / 提交异常 | NativeError |
失败原因 | 该值只在 SDK 内存,未到共享区 |
地址非法 / 未 Start / 写 I 区 |
InvalidArgument / InvalidHandle / NotSupported |
不变 | 未尝试提交 |
判据(IoStatus.OutputValid 与服务端 GET /api/io 的 outputValid = 写过 且 已送达 同口径):
PnSErrorCode rc = device.WriteInt16("QW2", 100);
if (rc != PnSErrorCode.Success)
{
// 未到共享区,原因在 device.LastServiceError;不要当成已下发
}
bool inShared = device.IoStatus.OutputValid; // true = 本会话已提交且无未提交的本地写
读 Q(ReadArea(PnSAddressArea.Output, out …) / ReadBool("Q0.0") …)读回共享区现值,不是 SDK 侧自留的副本。
其它语言
SDK 未上架公共包源(PyPI / Maven Central / crates.io 均无)。取得只有两条渠道:官网下载页(CDN 前缀 https://download.darra.xyz/profinet/<语言>/),或安装包自带 C:\DARRA\Profinet_Slave\SDK\。
| 语言 | 下载页文件 | 安装包自带 |
|---|---|---|
| C | darra_pns_c-win-x64.zip |
SDK\SDK_C\darra_pns_c-1.0.2-win-x64\ |
| C++ | darra_pns_cpp-win-x64.zip |
SDK\SDK_Cpp\darra_pns_cpp-1.0.2-win-x64\ |
| Java | darra-pns-slave.jar |
SDK\SDK_Java\(darra-pns-slave-1.0.2.jar) |
| Python | darra_pns-cp312-cp312-win_amd64.whl |
SDK\SDK_Python\(darra_pns-1.0.2-cp312-cp312-win_amd64.whl) |
| Rust | darra_pns.crate |
SDK\SDK_Rust\(darra_pns-1.0.2.crate) |
文档:https://profinet.darra.xyz/docs/sdk/csharp · 下载:https://profinet.darra.xyz/docs/download
| 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|