Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
RoboPLC
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄新宇
RoboPLC
Commits
770c8162
提交
770c8162
authored
4月 21, 2024
作者:
Serhij S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cross-platform components
上级
a23fc2f4
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
11 行增加
和
2 行删除
+11
-2
Cargo.toml
Cargo.toml
+1
-1
Cargo.lock
roboplc-cli/Cargo.lock
+0
-0
Cargo.toml
roboplc-cli/Cargo.toml
+0
-1
lib.rs
src/lib.rs
+10
-0
没有找到文件。
Cargo.toml
浏览文件 @
770c8162
[package]
name
=
"roboplc"
version
=
"0.1.4
5
"
version
=
"0.1.4
6
"
edition
=
"2021"
authors
=
[
"Serhij S. <div@altertech.com>"
]
license
=
"Apache-2.0"
...
...
roboplc-cli/Cargo.lock
浏览文件 @
770c8162
差异被折叠。
点击展开。
roboplc-cli/Cargo.toml
浏览文件 @
770c8162
...
...
@@ -17,7 +17,6 @@ path = "src/main.rs"
clap
=
{
version
=
"=4.1"
,
features
=
[
"derive"
,
"env"
]
}
colored
=
"1"
prettytable-rs
=
"0.10.0"
roboplc
=
{
version
=
"0.1.43"
}
serde
=
{
version
=
"1.0.197"
,
features
=
["derive"]
}
serde_json
=
"1.0.115"
shlex
=
"1.3.0"
...
...
src/lib.rs
浏览文件 @
770c8162
...
...
@@ -5,6 +5,7 @@ use std::panic::PanicInfo;
use
std
::{
env
,
mem
,
str
::
FromStr
,
sync
::
Arc
,
time
::
Duration
};
use
colored
::
Colorize
as
_
;
#[cfg(target_os
=
"linux"
)]
use
thread_rt
::{
RTParams
,
Scheduling
};
pub
use
log
::
LevelFilter
;
...
...
@@ -18,6 +19,7 @@ pub mod buf;
/// Reliable TCP/Serial communications
pub
mod
comm
;
/// Controller and workers
#[cfg(target_os
=
"linux"
)]
pub
mod
controller
;
/// In-process data communication pub/sub hub, synchronous edition
pub
mod
hub
;
...
...
@@ -34,8 +36,10 @@ pub mod pdeque;
/// A lighweight real-time safe semaphore
pub
mod
semaphore
;
/// Task supervisor to manage real-time threads
#[cfg(target_os
=
"linux"
)]
pub
mod
supervisor
;
/// Real-time thread functions to work with [`supervisor::Supervisor`] and standalone
#[cfg(target_os
=
"linux"
)]
pub
mod
thread_rt
;
/// Various time tools for real-time applications
pub
mod
time
;
...
...
@@ -225,6 +229,7 @@ where
}
/// Immediately kills the current process and all its subprocesses with a message to stderr
#[cfg(target_os
=
"linux"
)]
pub
fn
critical
(
msg
:
&
str
)
->
!
{
eprintln!
(
"{}"
,
msg
.red
()
.bold
());
thread_rt
::
suicide_myself
(
Duration
::
from_secs
(
0
),
false
);
...
...
@@ -236,6 +241,7 @@ pub fn critical(msg: &str) -> ! {
/// period of time.
///
/// Prints warnings to STDOUT if warn is true
#[cfg(target_os
=
"linux"
)]
pub
fn
suicide
(
delay
:
Duration
,
warn
:
bool
)
{
let
mut
builder
=
thread_rt
::
Builder
::
new
()
.name
(
"suicide"
)
.rt_params
(
RTParams
::
new
()
...
...
@@ -270,12 +276,14 @@ pub fn metrics_exporter() -> metrics_exporter_prometheus::PrometheusBuilder {
}
/// Sets panic handler to immediately kill the process and its childs with SIGKILL
#[cfg(target_os
=
"linux"
)]
pub
fn
setup_panic
()
{
std
::
panic
::
set_hook
(
Box
::
new
(
move
|
info
:
&
PanicInfo
|
{
panic
(
info
);
}));
}
#[cfg(target_os
=
"linux"
)]
fn
panic
(
info
:
&
PanicInfo
)
->
!
{
eprintln!
(
"{}"
,
info
.to_string
()
.red
()
.bold
());
thread_rt
::
suicide_myself
(
Duration
::
from_secs
(
0
),
false
);
...
...
@@ -307,9 +315,11 @@ pub fn configure_logger(filter: LevelFilter) {
pub
mod
prelude
{
pub
use
super
::
suicide
;
#[cfg(target_os
=
"linux"
)]
pub
use
crate
::
controller
::
*
;
pub
use
crate
::
hub
::
prelude
::
*
;
pub
use
crate
::
io
::
prelude
::
*
;
#[cfg(target_os
=
"linux"
)]
pub
use
crate
::
supervisor
::
prelude
::
*
;
pub
use
crate
::
time
::
DurationRT
;
pub
use
crate
::
ttlcell
::
TtlCell
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论