Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
RoboPLC
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄新宇
RoboPLC
Commits
643a010e
提交
643a010e
authored
5月 02, 2025
作者:
黄新宇
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs: 更新 README.md 并删除 README.zh.md
- 更新 README.md 文件,增加更多技术细节和示例 - 删除过时的 README.zh.md 文件,内容已过时且未维护
上级
e8c7e248
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
81 行增加
和
354 行删除
+81
-354
README.md
README.md
+81
-156
README.zh.md
README.zh.md
+0
-198
没有找到文件。
README.md
浏览文件 @
643a010e
...
@@ -7,116 +7,87 @@
...
@@ -7,116 +7,87 @@
<img src="https://raw.githubusercontent.com/roboplc/roboplc/main/roboplcline_.png"
<img src="https://raw.githubusercontent.com/roboplc/roboplc/main/roboplcline_.png"
width="200" />
width="200" />
[
RoboPLC
](
https://www.bohemia-automation.com/software/roboplc/
)
is an ultimate
[
RoboPLC
](
https://www.bohemia-automation.com/software/roboplc/
)
是一套完整的框架和工具集,用于使用Rust语言创建实时微服务、PLC和工业级机器人。
pack of a framework and tools for creating real-time micro-services, PLCs and
industrial-grade robots in Rust.
The crate is designed to let using all its components both separately and
该crate设计为既可以单独使用其所有组件,也可以一起使用。
together.
RoboPLC is a part of
[
EVA ICS
](
https://www.eva-ics.com/
)
industrial
RoboPLC是
[
EVA ICS
](
https://www.eva-ics.com/
)
工业自动化平台的一部分。
automation platform.
Real-time-safe data synchronization components are re-exported from the
实时安全的数据同步组件从
[
RTSC
](
https://docs.rs/rtsc
)
crate中重新导出,RTSC是RoboPLC项目的一部分,可以直接使用,无需使用RoboPLC。
[
RTSC
](
https://docs.rs/rtsc
)
crate which is a part of RoboPLC project and can
be used directly, with no requirement to use RoboPLC.
RoboPLC
eco-system provides:
RoboPLC
生态系统提供:
*
[
roboplc-cli (robo)
](
https://info.bma.ai/en/actual/roboplc/flashing.html
)
- a
*
[
roboplc-cli (robo)
](
https://info.bma.ai/en/actual/roboplc/flashing.html
)
- 用于创建和管理RoboPLC项目的CLI工具
CLI tool to create and manage RoboPLC projects
*
[
RoboPLC manager
](
https://info.bma.ai/en/actual/roboplc/config.html
)
- a web
*
[
RoboPLC manager
](
https://info.bma.ai/en/actual/roboplc/config.html
)
- 用于监控和管理基于RoboPLC的系统的Web界面和HTTP API
interface and HTTP API to monitor and manage RoboPLC-based systems
<img
src=
"https://info.bma.ai/en/actual/_images/manager-program.png"
width=
"550"
/>
<img
src=
"https://info.bma.ai/en/actual/_images/manager-program.png"
width=
"550"
/>
##
Technical documentation
##
技术文档
Available at
<https://info.bma.ai/en/actual/roboplc/index.html>
可在
<https://info.bma.ai/en/actual/roboplc/index.html>
获取
##
Examples
##
示例
Can be found at
<https://github.com/roboplc/roboplc/tree/main/examples>
可在
<https://github.com/roboplc/roboplc/tree/main/examples>
找到
## DataBuffer
## DataBuffer
[
`buf::DataBuffer`
]
covers a typical data exchange pattern when data
[
`buf::DataBuffer`
]
涵盖了一种典型的数据交换模式,即从单个或多个生产者收集(缓存)数据帧,然后由单个消费者批量获取并提交,例如提交到本地数据库或外部总线。
frames are collected (cached) from a single or multiple producers, then taken
by a single consumer in bulk and submitted, e.g. into a local database or into
an external bus.
<img
<img
src="https://raw.githubusercontent.com/roboplc/roboplc/main/schemas/databuffer.png"
src="https://raw.githubusercontent.com/roboplc/roboplc/main/schemas/databuffer.png"
width="350" />
width="350" />
*
always has got a fixed capacity
*
始终具有固定容量
*
thread-safe out-of-the-box
*
开箱即用的线程安全
*
frames may be forcibly pushed, overriding the previous ones, like in a ring-buffer.
*
可以强制推送帧,覆盖之前的帧,类似环形缓冲区。
## Hub
## Hub
[
`hub::Hub`
]
implements a data-hub (in-process pub/sub) model, when multiple
[
`hub::Hub`
]
实现了数据中心(进程内发布/订阅)模型,多个客户端(通常是线程工作者)通过单个虚拟总线交换数据,而不是使用直接通道。
clients (usually thread workers) exchange data via a single virtual bus instead
of using direct channels.
This brings some additional overhead into data exchange, however makes the
这给数据交换带来了一些额外的开销,但使架构明显更清晰,降低了代码维护成本并带来了额外的功能。
architecture significantly clearer, lowers code support costs and brings
additional features.
<img
<img
src="https://raw.githubusercontent.com/roboplc/roboplc/main/schemas/hub.png"
src="https://raw.githubusercontent.com/roboplc/roboplc/main/schemas/hub.png"
width="550" />
width="550" />
*
classic pub/sub patterns with no data serialization overhead
*
经典的发布/订阅模式,没有数据序列化开销
*
based on
[
`policy_channel`
]
which allows to mix different kinds of data and
*
基于
[
`policy_channel`
]
,允许混合不同类型的数据并在需要时应用额外的策略
apply additional policies if required
*
a fully passive model with no "server" thread.
*
完全被动模型,没有"服务器"线程。
## pdeque
and
policy_channel
## pdeque
和
policy_channel
A policy-based deque
[
`rtsc::pdeque::Deque`
]
is a component to build policy-based
基于策略的双端队列
[
`rtsc::pdeque::Deque`
]
是构建基于策略的通道的组件。
channels.
[
`policy_channel`
]
is a channel module, based on the policy-based deque.
[
`policy_channel`
]
是基于策略双端队列的通道模块。
Data policies supported:
支持的数据策略:
*
**Always**
a frame is always delivered
*
**Always**
帧总是被传递
*
**Latest**
a frame is always delivered, previous are dropped if no room
*
**Latest**
帧总是被传递,如果没有空间则丢弃之前的帧(类似环形缓冲区)
(acts like a ring-buffer)
*
**Optional**
如果没有空间,帧可以被跳过
*
**Optional**
a frame can be skipped if no room
*
**Single**
帧必须只传递一次(最新的一个)
*
**Single**
a frame must be delivered only once (the latest one)
*
**SingleOptional**
帧必须只传递一次(最新的一个)且是可选的
*
**SingleOptional**
a frame must be delivered only once (the latest one) and
is optional
Additionally, components support ordering by data priority and automatically
此外,组件支持按数据优先级排序,如果数据类型实现了过期标记方法,则自动丢弃过期数据。
drop expired data if the data type has got an expiration marker method
implemented.
[
`policy_channel`
]
is a real-time safe channel, mean it may be not so fast as
[
`policy_channel`
]
是一个实时安全的通道,这意味着它可能不如流行的通道实现那么快(甚至可能比
[
`std::sync::mpsc`
]
提供的通道更慢)。但它对实时应用程序
**完全安全**
,意味着没有自旋循环,数据总是以最小延迟传递,线程不会相互阻塞。
popular channel implementations (it may be even slower than channels provided
by
[
`std::sync::mpsc`
]
). But it is
**
completely safe for real-time
applications
**
, mean there are no spin loops, data is always delivered with
minimal latency and threads do not block each other.
##
Real-time
##
实时
[
`thread_rt::Builder`
]
provides a thread builder component, which extends the
[
`thread_rt::Builder`
]
提供了一个线程构建器组件,它扩展了标准线程构建器,具有实时功能:调度策略和CPU亲和性(仅限Linux)。
standard thread builder with real-time capabilities: scheduler policies and CPU
affinity (Linux only).
[
`supervisor::Supervisor`
]
provides a lightweight task supervisor to manage
[
`supervisor::Supervisor`
]
提供了一个轻量级任务监督器来管理已启动的线程。
launched threads.
## Controller
## Controller
[
`controller::Controller`
]
is the primary component of mixing up all the
[
`controller::Controller`
]
是将所有功能混合在一起的主要组件。
functionality together.
<img
<img
src="https://raw.githubusercontent.com/roboplc/roboplc/main/schemas/controller.png"
src="https://raw.githubusercontent.com/roboplc/roboplc/main/schemas/controller.png"
...
@@ -124,103 +95,73 @@ width="550" />
...
@@ -124,103 +95,73 @@ width="550" />
## I/O
## I/O
[
`io`
]
module provides a set of tools to work with field devices and SCADA
[
`io`
]
模块提供了一套工具,用于与现场设备和SCADA总线一起工作。
buses.
Currently supported:
目前支持:
*
Modbus (RTU/TCP) via
[
`io::modbus`
]
(
[Modbus
client/master
*
通过
[
`io::modbus`
]
的Modbus(RTU/TCP)(
[
Modbus客户端/主站示例
](
https://github.com/roboplc/roboplc/blob/main/examples/modbus-master.rs
)
,
[
Modbus服务器/从站示例
](
https://github.com/roboplc/roboplc/blob/main/examples/modbus-slave.rs
)
),需要
`modbus`
crate特性。
example](https://github.com/roboplc/roboplc/blob/main/examples/modbus-master.rs),
[
Modbus server/slave
example](https://github.com/roboplc/roboplc/blob/main/examples/modbus-slave.rs)),
requires
`modbus`
crate feature.
*
Raw UDP in/out via
[
`io::raw_udp`
]
*
通过
[
`io::raw_udp`
]
的原始UDP输入/输出(
[
原始UDP输入/输出示例
](
https://github.com/roboplc/roboplc/blob/main/examples/raw-udp.rs
)
)
(
[
Raw UDP in/out example
](
https://github.com/roboplc/roboplc/blob/main/examples/raw-udp.rs
)
)
*
Subprocess pipes via
[
`io::pipe`
]
*
通过
[
`io::pipe`
]
的子进程管道(
[
子进程管道示例
](
https://github.com/roboplc/roboplc/blob/main/examples/pipe.rs
)
)
(
[
Subprocess pipe example
](
https://github.com/roboplc/roboplc/blob/main/examples/pipe.rs
)
)
*
[
EVA ICS
](
https://www.eva-ics.com/
)
EAPI in/out via
[
`io::eapi`
]
(
[EVA
ICS
*
通过
[
`io::eapi`
]
的
[
EVA ICS
](
https://www.eva-ics.com/
)
EAPI输入/输出(
[
EVA ICS示例
](
https://github.com/roboplc/roboplc/blob/main/examples/eapi.rs
)
),需要
`eapi`
crate特性
example](https://github.com/roboplc/roboplc/blob/main/examples/eapi.rs)),
requires
`eapi`
crate feature
*
SNMP v1/2/3 via
[
`snmp2`
](
https://crates.io/crates/snmp2
)
external crate.
*
通过
[
`snmp2`
](
https://crates.io/crates/snmp2
)
外部crate的SNMP v1/2/3。
*
[
ADS
](
https://crates.io/crates/roboplc-io-ads
)
connector for
[
Beckhoff
*
[
ADS
](
https://crates.io/crates/roboplc-io-ads
)
连接器,用于
[
Beckhoff TwinCAT
](
https://infosys.beckhoff.com/english.php?content=../content/1033/tcinfosys3/11291871243.html&id=
)
,商业使用需要许可证
TwinCAT](https://infosys.beckhoff.com/english.php?content=../content/1033/tcinfosys3/11291871243.html&id=),
requires a license for commercial use
*
[
IEC 60870-5
](
https://crates.io/crates/roboplc-io-iec60870-5
)
client,
*
[
IEC 60870-5
](
https://crates.io/crates/roboplc-io-iec60870-5
)
客户端,商业使用需要许可证
requires a license for commercial use
##
Related crates
##
相关crate
RoboPLC project provides additional crates, which can be used both with RoboPLC
RoboPLC项目提供了额外的crate,可以与RoboPLC一起使用,也可以单独使用:
and separately:
*
[
RTSC
](
https://crates.io/crates/rtsc
)
- Real-Time Synchronization Components,
*
[
RTSC
](
https://crates.io/crates/rtsc
)
- 实时同步组件,一套实时安全的数据同步组件,RoboPLC的核心组件
a set of real-time safe data synchronization components, the core components
of RoboPLC
*
[
atomic-timer
](
https://crates.io/crates/atomic-timer
)
- an atomic timer
*
[
atomic-timer
](
https://crates.io/crates/atomic-timer
)
- 用于典型自动化任务的原子计时器组件
component for typical automation tasks
*
[
rpdo
](
https://crates.io/crates/rpdo
)
- RoboPLC Data Objects protocol for
*
[
rpdo
](
https://crates.io/crates/rpdo
)
- RoboPLC数据对象协议,用于进程和设备之间的数据同步
data synchronization between processes and devices
*
[
ehmi
](
https://crates.io/crates/ehmi
)
-
HMI components for
`egui`
interfaces.
*
[
ehmi
](
https://crates.io/crates/ehmi
)
-
用于
`egui`
界面的HMI组件。
*
[
metrics-exporter-scope
](
https://crates.io/crates/metrics-exporter-scope
)
-
*
[
metrics-exporter-scope
](
https://crates.io/crates/metrics-exporter-scope
)
- 用于
[
metrics
](
https://crates.io/crates/metrics
)
生态系统的示波器式导出器
an oscilloscope-like exporter for
[
metrics
](
https://crates.io/crates/metrics
)
eco-system
*
[
heartbeat-watchdog
](
https://crates.io/crates/heartbeat-watchdog
)
- heartbeat
*
[
heartbeat-watchdog
](
https://crates.io/crates/heartbeat-watchdog
)
- 用于关键任务系统监控的心跳和看门狗组件
and watchdog components for mission-critical systems monitoring
*
[
rvideo
](
https://crates.io/crates/rvideo
)
-
video stream debugging
*
[
rvideo
](
https://crates.io/crates/rvideo
)
-
视频流调试
*
[
rflow
](
https://crates.io/crates/rflow
)
- allows quickly create chat-like
*
[
rflow
](
https://crates.io/crates/rflow
)
- 允许快速为无头程序创建类聊天的诊断界面
diagnostic interfaces for headless programs
##
Locking safety
##
锁定安全
Note: the asynchronous components use
`parking_lot_rt`
locking only.
注意:异步组件仅使用
`parking_lot_rt`
锁定。
By default, the crate uses
[
parking_lot
](
https://crates.io/crates/parking_lot
)
默认情况下,该crate使用
[
parking_lot
](
https://crates.io/crates/parking_lot
)
进行锁定。对于实时应用程序,可以使用以下特性:
for locking. For real-time applications, the following features are available:
*
`locking-rt`
- use
[
parking_lot_rt
](
https://crates.io/crates/parking_lot_rt
)
*
`locking-rt`
- 使用
[
parking_lot_rt
](
https://crates.io/crates/parking_lot_rt
)
crate,这是parking_lot的无自旋分支。
crate which is a spin-free fork of parking_lot.
*
`locking-rt-safe`
- use
[
RTSC
](
https://crates.io/crates/rtsc
)
*
`locking-rt-safe`
- 使用
[
RTSC
](
https://crates.io/crates/rtsc
)
优先级继承锁定,不受优先级反转影响(仅限Linux,推荐内核5.14+)。
priority-inheritance locking, which is not affected by priority inversion
(Linux only, recommended Kernel 5.14+).
Note: to switch locking policy, disable the crate default features.
注意:要切换锁定策略,请禁用crate的默认特性。
The locking policy can be also selected in CLI when creating a new project:
在使用CLI创建新项目时也可以选择锁定策略:
```
shell
```
shell
robo new
--locking
rt-safe
#
the default for CLI-created projects is
rt-safe
robo new
--locking
rt-safe
#
CLI创建的项目默认为
rt-safe
```
```
##
Using on other platforms
##
在其他平台上使用
The components
[
`thread_rt`
]
,
[
`supervisor`
]
and
[
`controller`
]
can work on
组件
[
`thread_rt`
]
、
[
`supervisor`
]
和
[
`controller`
]
只能在Linux机器上工作。
Linux machines only.
Despite of that, "cargo check" should work on Windows and OSX to let developers
尽管如此,"cargo check"应该可以在Windows和OSX上工作,以便开发人员在这些平台上编写基于RoboPLC的程序。如果任何crate特性失败,请报告问题。
code RoboPLC-based programs on these platforms. In case if this fails with any
crate feature, please report an issue.
##
Migration from 0.5.x
##
从0.5.x迁移
*
In case if
`io::eapi`
is used, action handlers must now return a serializable
*
如果使用
`io::eapi`
,动作处理程序现在必须返回可序列化的值。
value.
*
For proper
`hmi`
support, ensure that
`RuntimeDirectory`
is configured in
*
为了正确支持
`hmi`
,确保在
`roboplc.program`
服务(
`/lib/systemd/system/roboplc.program.service`
)中配置了
`RuntimeDirectory`
:
`roboplc.program`
service (
`/lib/systemd/system/roboplc.program.service`
):
```
ini
```
ini
[Service]
[Service]
...
@@ -229,45 +170,28 @@ RuntimeDirectory=roboplc
...
@@ -229,45 +170,28 @@ RuntimeDirectory=roboplc
RuntimeDirectoryMode
=
700
RuntimeDirectoryMode
=
700
```
```
##
Migration from 0.4.x
##
从0.4.x迁移
*
Certain
`thread-rt`
module components have been moved to
*
某些
`thread-rt`
模块组件已移至
[
`rtsc`
](
https://crates.io/crates/rtsc
)
crate。RoboPLC重新导出它们,增加了与模拟模式的兼容性。
[
`rtsc`
](
https://crates.io/crates/rtsc
)
crate. RoboPLC re-exports them,
adding compatibility with simulated mode.
*
`thread_rt::set_simulated`
has been moved to
[
`set_simulated`
]
.
*
`thread_rt::set_simulated`
已移至
[
`set_simulated`
]
。
*
`thread_rt`
components
`CpuGovernor`
and
`SystemConfig`
have been moved to
*
`thread_rt`
组件
`CpuGovernor`
和
`SystemConfig`
已移至
[
`system`
]
crate模块。
[
`system`
]
crate module.
*
`openssl-vendored`
feature has been removed, as
[
EVA
*
`openssl-vendored`
特性已被移除,因为
[
EVA ICS
](
https://www.eva-ics.com/
)
EAPI现在只有某些特定功能才需要
`openssl`
作为可选依赖项。
ICS](https://www.eva-ics.com/) EAPI has got now
`openssl`
as an optional
dependency for certain specific features only.
##
Migration from 0.3.x
##
从0.3.x迁移
*
`pchannel`
and
`pchannel_async`
have been renamed to
[
`policy_channel`
]
and
*
`pchannel`
和
`pchannel_async`
已分别重命名为
[
`policy_channel`
]
和
[
`policy_channel_async`
]
。
[
`policy_channel_async`
]
respectively.
*
By default, the crate uses
*
默认情况下,该crate使用
[
parking_lot
](
https://crates.io/crates/parking_lot
)
进行锁定。要切换到更安全的实时锁定,请禁用crate的默认特性,并启用
`locking-rt`
或
`locking-rt-safe`
。
**这对实时应用程序很重要,必须手动启用**
。
[
parking_lot
](
https://crates.io/crates/parking_lot
)
for locking. To switch to
more safe real-time locking, disable the crate default features and enable
either
`locking-rt`
or
`locking-rt-safe`
.
**
This is important for real-time
applications and must be enabled manually
**
.
*
As
[
RTSC
](
https://crates.io/crates/rtsc
)
components are lock-agnostic, which
*
由于
[
RTSC
](
https://crates.io/crates/rtsc
)
组件与锁无关,这需要指定通用锁定类型,模块
[
`channel`
]
、
[
`policy_channel`
]
、
[
`buf`
]
和
[
`semaphore`
]
现在是RTSC模块的包装器,具有所选的锁定策略。
requires to specify generic locking types, the modules
[
`channel`
]
,
[
`policy_channel`
]
,
[
`buf`
]
and
[
`semaphore`
]
are now wrappers around RTSC
modules with the chosen locking policy.
*
[
`hub_async`
]
now requires
`async`
feature to be enabled.
*
[
`hub_async`
]
现在需要启用
`async`
特性。
## MSRV
## MSRV
Minimum supported mainstream Rust version of RoboPLC is synchronized with the
RoboPLC支持的最低主流Rust版本与
[
Ferrocene
](
https://ferrocene.dev/
)
Rust编译器同步。这允许创建符合ISO 26262(TCL 3/ASIL D)、IEC 61508(T3)和IEC 62304的关键任务软件。
[
Ferrocene
](
https://ferrocene.dev/
)
Rust compiler. This allows to create
mission-critical software, compliant with ISO 26262 (TCL 3/ASIL D), IEC 61508
(T3) and IEC 62304.
Current MSRV: mainstream 1.81.0, Ferrocene 24.11.0. Certain features may work
当前MSRV:主流1.81.0,Ferrocene 24.11.0。某些功能可能适用于较旧的Rust版本。
with older Rust versions.
\ No newline at end of file
README.zh.md
deleted
100644 → 0
浏览文件 @
e8c7e248
<h2>
RoboPLC
<a
href=
"https://crates.io/crates/roboplc"
><img
alt=
"crates.io page"
src=
"https://img.shields.io/crates/v/roboplc.svg"
></img></a>
<a
href=
"https://docs.rs/roboplc"
><img
alt=
"docs.rs page"
src=
"https://docs.rs/roboplc/badge.svg"
></img></a>
</h2>
<img src="https://raw.githubusercontent.com/roboplc/roboplc/main/roboplcline_.png"
width="200" />
[
RoboPLC
](
https://www.bohemia-automation.com/software/roboplc/
)
是一套完整的框架和工具集,用于使用Rust语言创建实时微服务、PLC和工业级机器人。
该crate设计为既可以单独使用其所有组件,也可以一起使用。
RoboPLC是
[
EVA ICS
](
https://www.eva-ics.com/
)
工业自动化平台的一部分。
实时安全的数据同步组件从
[
RTSC
](
https://docs.rs/rtsc
)
crate中重新导出,RTSC是RoboPLC项目的一部分,可以直接使用,无需使用RoboPLC。
RoboPLC生态系统提供:
*
[
roboplc-cli (robo)
](
https://info.bma.ai/en/actual/roboplc/flashing.html
)
- 用于创建和管理RoboPLC项目的CLI工具
*
[
RoboPLC manager
](
https://info.bma.ai/en/actual/roboplc/config.html
)
- 用于监控和管理基于RoboPLC的系统的Web界面和HTTP API
<img
src=
"https://info.bma.ai/en/actual/_images/manager-program.png"
width=
"550"
/>
## 技术文档
可在
<https://info.bma.ai/en/actual/roboplc/index.html>
获取
## 示例
可在
<https://github.com/roboplc/roboplc/tree/main/examples>
找到
## DataBuffer
[
`buf::DataBuffer`
]
涵盖了一种典型的数据交换模式,即从单个或多个生产者收集(缓存)数据帧,然后由单个消费者批量获取并提交,例如提交到本地数据库或外部总线。
<img
src="https://raw.githubusercontent.com/roboplc/roboplc/main/schemas/databuffer.png"
width="350" />
*
始终具有固定容量
*
开箱即用的线程安全
*
可以强制推送帧,覆盖之前的帧,类似环形缓冲区。
## Hub
[
`hub::Hub`
]
实现了数据中心(进程内发布/订阅)模型,多个客户端(通常是线程工作者)通过单个虚拟总线交换数据,而不是使用直接通道。
这给数据交换带来了一些额外的开销,但使架构明显更清晰,降低了代码维护成本并带来了额外的功能。
<img
src="https://raw.githubusercontent.com/roboplc/roboplc/main/schemas/hub.png"
width="550" />
*
经典的发布/订阅模式,没有数据序列化开销
*
基于
[
`policy_channel`
]
,允许混合不同类型的数据并在需要时应用额外的策略
*
完全被动模型,没有"服务器"线程。
## pdeque 和 policy_channel
基于策略的双端队列
[
`rtsc::pdeque::Deque`
]
是构建基于策略的通道的组件。
[
`policy_channel`
]
是基于策略双端队列的通道模块。
支持的数据策略:
*
**Always**
帧总是被传递
*
**Latest**
帧总是被传递,如果没有空间则丢弃之前的帧(类似环形缓冲区)
*
**Optional**
如果没有空间,帧可以被跳过
*
**Single**
帧必须只传递一次(最新的一个)
*
**SingleOptional**
帧必须只传递一次(最新的一个)且是可选的
此外,组件支持按数据优先级排序,如果数据类型实现了过期标记方法,则自动丢弃过期数据。
[
`policy_channel`
]
是一个实时安全的通道,这意味着它可能不如流行的通道实现那么快(甚至可能比
[
`std::sync::mpsc`
]
提供的通道更慢)。但它对实时应用程序
**完全安全**
,意味着没有自旋循环,数据总是以最小延迟传递,线程不会相互阻塞。
## 实时
[
`thread_rt::Builder`
]
提供了一个线程构建器组件,它扩展了标准线程构建器,具有实时功能:调度策略和CPU亲和性(仅限Linux)。
[
`supervisor::Supervisor`
]
提供了一个轻量级任务监督器来管理已启动的线程。
## Controller
[
`controller::Controller`
]
是将所有功能混合在一起的主要组件。
<img
src="https://raw.githubusercontent.com/roboplc/roboplc/main/schemas/controller.png"
width="550" />
## I/O
[
`io`
]
模块提供了一套工具,用于与现场设备和SCADA总线一起工作。
目前支持:
*
通过
[
`io::modbus`
]
的Modbus(RTU/TCP)(
[
Modbus客户端/主站示例
](
https://github.com/roboplc/roboplc/blob/main/examples/modbus-master.rs
)
,
[
Modbus服务器/从站示例
](
https://github.com/roboplc/roboplc/blob/main/examples/modbus-slave.rs
)
),需要
`modbus`
crate特性。
*
通过
[
`io::raw_udp`
]
的原始UDP输入/输出(
[
原始UDP输入/输出示例
](
https://github.com/roboplc/roboplc/blob/main/examples/raw-udp.rs
)
)
*
通过
[
`io::pipe`
]
的子进程管道(
[
子进程管道示例
](
https://github.com/roboplc/roboplc/blob/main/examples/pipe.rs
)
)
*
通过
[
`io::eapi`
]
的
[
EVA ICS
](
https://www.eva-ics.com/
)
EAPI输入/输出(
[
EVA ICS示例
](
https://github.com/roboplc/roboplc/blob/main/examples/eapi.rs
)
),需要
`eapi`
crate特性
*
通过
[
`snmp2`
](
https://crates.io/crates/snmp2
)
外部crate的SNMP v1/2/3。
*
[
ADS
](
https://crates.io/crates/roboplc-io-ads
)
连接器,用于
[
Beckhoff TwinCAT
](
https://infosys.beckhoff.com/english.php?content=../content/1033/tcinfosys3/11291871243.html&id=
)
,商业使用需要许可证
*
[
IEC 60870-5
](
https://crates.io/crates/roboplc-io-iec60870-5
)
客户端,商业使用需要许可证
## 相关crate
RoboPLC项目提供了额外的crate,可以与RoboPLC一起使用,也可以单独使用:
*
[
RTSC
](
https://crates.io/crates/rtsc
)
- 实时同步组件,一套实时安全的数据同步组件,RoboPLC的核心组件
*
[
atomic-timer
](
https://crates.io/crates/atomic-timer
)
- 用于典型自动化任务的原子计时器组件
*
[
rpdo
](
https://crates.io/crates/rpdo
)
- RoboPLC数据对象协议,用于进程和设备之间的数据同步
*
[
ehmi
](
https://crates.io/crates/ehmi
)
- 用于
`egui`
界面的HMI组件。
*
[
metrics-exporter-scope
](
https://crates.io/crates/metrics-exporter-scope
)
- 用于
[
metrics
](
https://crates.io/crates/metrics
)
生态系统的示波器式导出器
*
[
heartbeat-watchdog
](
https://crates.io/crates/heartbeat-watchdog
)
- 用于关键任务系统监控的心跳和看门狗组件
*
[
rvideo
](
https://crates.io/crates/rvideo
)
- 视频流调试
*
[
rflow
](
https://crates.io/crates/rflow
)
- 允许快速为无头程序创建类聊天的诊断界面
## 锁定安全
注意:异步组件仅使用
`parking_lot_rt`
锁定。
默认情况下,该crate使用
[
parking_lot
](
https://crates.io/crates/parking_lot
)
进行锁定。对于实时应用程序,可以使用以下特性:
*
`locking-rt`
- 使用
[
parking_lot_rt
](
https://crates.io/crates/parking_lot_rt
)
crate,这是parking_lot的无自旋分支。
*
`locking-rt-safe`
- 使用
[
RTSC
](
https://crates.io/crates/rtsc
)
优先级继承锁定,不受优先级反转影响(仅限Linux,推荐内核5.14+)。
注意:要切换锁定策略,请禁用crate的默认特性。
在使用CLI创建新项目时也可以选择锁定策略:
```
shell
robo new
--locking
rt-safe
# CLI创建的项目默认为rt-safe
```
## 在其他平台上使用
组件
[
`thread_rt`
]
、
[
`supervisor`
]
和
[
`controller`
]
只能在Linux机器上工作。
尽管如此,"cargo check"应该可以在Windows和OSX上工作,以便开发人员在这些平台上编写基于RoboPLC的程序。如果任何crate特性失败,请报告问题。
## 从0.5.x迁移
*
如果使用
`io::eapi`
,动作处理程序现在必须返回可序列化的值。
*
为了正确支持
`hmi`
,确保在
`roboplc.program`
服务(
`/lib/systemd/system/roboplc.program.service`
)中配置了
`RuntimeDirectory`
:
```
ini
[Service]
# ...
RuntimeDirectory
=
roboplc
RuntimeDirectoryMode
=
700
```
## 从0.4.x迁移
*
某些
`thread-rt`
模块组件已移至
[
`rtsc`
](
https://crates.io/crates/rtsc
)
crate。RoboPLC重新导出它们,增加了与模拟模式的兼容性。
*
`thread_rt::set_simulated`
已移至
[
`set_simulated`
]
。
*
`thread_rt`
组件
`CpuGovernor`
和
`SystemConfig`
已移至
[
`system`
]
crate模块。
*
`openssl-vendored`
特性已被移除,因为
[
EVA ICS
](
https://www.eva-ics.com/
)
EAPI现在只有某些特定功能才需要
`openssl`
作为可选依赖项。
## 从0.3.x迁移
*
`pchannel`
和
`pchannel_async`
已分别重命名为
[
`policy_channel`
]
和
[
`policy_channel_async`
]
。
*
默认情况下,该crate使用
[
parking_lot
](
https://crates.io/crates/parking_lot
)
进行锁定。要切换到更安全的实时锁定,请禁用crate的默认特性,并启用
`locking-rt`
或
`locking-rt-safe`
。
**这对实时应用程序很重要,必须手动启用**
。
*
由于
[
RTSC
](
https://crates.io/crates/rtsc
)
组件与锁无关,这需要指定通用锁定类型,模块
[
`channel`
]
、
[
`policy_channel`
]
、
[
`buf`
]
和
[
`semaphore`
]
现在是RTSC模块的包装器,具有所选的锁定策略。
*
[
`hub_async`
]
现在需要启用
`async`
特性。
## MSRV
RoboPLC支持的最低主流Rust版本与
[
Ferrocene
](
https://ferrocene.dev/
)
Rust编译器同步。这允许创建符合ISO 26262(TCL 3/ASIL D)、IEC 61508(T3)和IEC 62304的关键任务软件。
当前MSRV:主流1.81.0,Ferrocene 24.11.0。某些功能可能适用于较旧的Rust版本。
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论