Metadata-Version: 2.4
Name: Darra-Profinet-Slave
Version: 1.1.0
Summary: PROFINET IO 从站协议栈 Python SDK —— 把 Windows 主机变为 PROFINET IO 从站设备，受主站系统（如西门子 PLC）控制：RT Class 1 · DCP · 过程数据 IO · 报警 + 诊断 + I&M · GSDML 导入 TIA V15+ · 搭配 DarraRT 实时内核驱动 · Windows x64 · Python SDK for the Darra PROFINET IO device stack — use a Windows host as a PROFINET IO device under a master system (e.g. a Siemens PLC): RT Class 1, DCP, process-data IO, alarms, diagnostics; DarraRT kernel driver; Windows x64.
Author-email: Darra Technology <dev@darra.xyz>
License: Proprietary
Project-URL: Homepage, https://profinet.darra.xyz
Project-URL: Documentation, https://profinet.darra.xyz/docs/sdk/python
Project-URL: Repository, https://profinet.darra.xyz
Keywords: profinet,pnio,io-device,slave,industrial-automation,fieldbus,darra,dcp,gsdml
Classifier: Development Status :: 4 - Beta
Classifier: License :: Other/Proprietary License
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Manufacturing
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: System :: Hardware :: Hardware Drivers
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.12
Description-Content-Type: text/markdown

<p align="center"><img src="https://download.darra.xyz/profinet/static/icon.png" alt="Darra Profinet Slave" width="96" height="96"></p>

# Darra Profinet Slave · Python SDK

把 Windows 主机作为 PROFINET IO 从站设备使用，受主站系统（如西门子 PLC）控制：RT Class 1 实时周期，DCP 设备发现 / 命名 / 地址分配，过程数据 IO，报警与诊断（含 I&M），GSDML 导入 TIA V15+；搭配 DarraRT 实时内核驱动，SDK 以服务模式使用（过程映像共享内存映射）。

*Use a Windows host as a PROFINET IO device under a master (e.g. a Siemens PLC) — RT Class 1, DCP, process-data IO, alarms and diagnostics (I&M), GSDML for TIA V15+; with the DarraRT kernel driver. The SDK is used in service mode (process image mapped from shared memory).*

---

## 能力 · Capabilities

- **从站设备** — Windows 主机作为 PROFINET IO Device，受 PLC 等主站控制
- **实时周期** — RT Class 1，搭配 DarraRT 实时内核驱动
- **发现与组态** — DCP 发现 / 命名 / 地址；GSDML 导入 TIA V15+
- **过程数据** — 写 Q、读 I；报警、诊断、I&M
- **0 拷贝** — 过程映像映射成结构体，供高性能直接读写（读可并发；写请调用方串行化）
- **同一 Core** — 过程数据由 DarraRT 实时内核周期搬运，SDK 侧零拷贝映射共享映像

---

## 开始 · Get started

1. 先安装官方安装包（实时内核驱动 + 配置工具 + SDK）：[下载页](https://profinet.darra.xyz/docs/download) · https://download.darra.xyz/profinet/client/Darra-Profinet-Setup.exe
2. 本包是 Python SDK：

```bash
pip install darra-profinet-slave
```

3. 新人：[基础知识](https://profinet.darra.xyz/docs/profinet/beginner-guide) · [从 SDK 继续](https://profinet.darra.xyz/docs/guide/from-sdk) · [Python 文档](https://profinet.darra.xyz/docs/sdk/python)

---

## 最佳用法 · 0 拷贝

总线周期由内核完成。Start 后把 I / Q 映射成结构体，之后当普通变量读写即可——读是当前周期，写下个周期发出。

```python
import ctypes
from darra_pns import PnSService

class FromPlc(ctypes.BigEndianStructure):   # I：控制器 → 设备
    _pack_ = 1
    _fields_ = [("present", ctypes.c_uint8),
                ("recipe", ctypes.c_int16)]

class ToPlc(ctypes.BigEndianStructure):     # Q：设备 → 控制器
    _pack_ = 1
    _fields_ = [("ready", ctypes.c_uint8),
                ("busy", ctypes.c_uint8)]

svc = PnSService()                          # 构造随时可调
svc.start()                                 # 启动服务 + 建立过程数据通道

inp = svc.process_data.inputs_mapping(FromPlc)   # 映射一次（I 只读）
outp = svc.process_data.outputs_mapping(ToPlc)   # 映射一次（Q 可写）

outp.ready = 1                              # 写下的下个周期发出
present = inp.present                       # 读到的永远是当前周期
```

要整段一次读出用 `svc.read()`（一次调用取一份，同一拍自洽）。

```python
i = svc.read()   # I 区整段字节
```

---

## 其它语言 · Other SDKs

| 语言 / Language | 包 / Package | 来源 / Source |
|---|---|---|
| C | `darra_profinet_c-win-x64.zip` | [下载页](https://profinet.darra.xyz/docs/download) |
| C++ | `darra_profinet_cpp-win-x64.zip` | [下载页](https://profinet.darra.xyz/docs/download) |
| C# | `Darra.Profinet.Slave` | NuGet |
| Java | `xyz.darra:darra-profinet-slave` | Maven Central |
| Python | `darra-profinet-slave` | PyPI（本包 / this SDK） |
| Rust | `darra-profinet-slave` | crates.io |

## 许可 · License

专有软件 · Proprietary — © Darra Technology，使用须遵守随产品提供的许可协议。
