Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
RoboPLC
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄新宇
RoboPLC
Commits
8992d4d5
提交
8992d4d5
authored
7月 20, 2024
作者:
Serhij S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
copy program info to eapi module
上级
2d5f8a53
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
40 行增加
和
8 行删除
+40
-8
Cargo.toml
Cargo.toml
+2
-1
eapi.rs
examples/eapi.rs
+3
-0
eapi.rs
src/io/eapi.rs
+35
-7
没有找到文件。
Cargo.toml
浏览文件 @
8992d4d5
...
@@ -46,9 +46,10 @@ snmp = { version = "0.2.2", optional = true }
...
@@ -46,9 +46,10 @@ snmp = { version = "0.2.2", optional = true }
rtsc
=
"0.2"
rtsc
=
"0.2"
rvideo
=
{
version
=
"0.4"
,
optional
=
true
}
rvideo
=
{
version
=
"0.4"
,
optional
=
true
}
rflow
=
{
version
=
"0"
,
optional
=
true
}
rflow
=
{
version
=
"0"
,
optional
=
true
}
once_cell
=
{
version
=
"1.19.0"
,
optional
=
true
}
[features]
[features]
eapi
=
[
"eva-common"
,
"eva-sdk"
,
"busrt"
,
"tokio"
,
"hostname"
]
eapi
=
[
"eva-common"
,
"eva-sdk"
,
"busrt"
,
"tokio"
,
"hostname"
,
"once_cell"
]
pipe
=
[
"tokio/process"
,
"tokio/io-util"
,
"tokio/macros"
,
"tokio/rt"
,
"tokio/time"
]
pipe
=
[
"tokio/process"
,
"tokio/io-util"
,
"tokio/macros"
,
"tokio/rt"
,
"tokio/time"
]
rvideo
=
["dep:rvideo"]
rvideo
=
["dep:rvideo"]
rflow
=
["dep:rflow"]
rflow
=
["dep:rflow"]
...
...
examples/eapi.rs
浏览文件 @
8992d4d5
...
@@ -82,6 +82,9 @@ impl Worker<Message, Variables> for EAPIConnector {
...
@@ -82,6 +82,9 @@ impl Worker<Message, Variables> for EAPIConnector {
}
}
fn
main
()
->
std
::
result
::
Result
<
(),
Box
<
dyn
std
::
error
::
Error
>>
{
fn
main
()
->
std
::
result
::
Result
<
(),
Box
<
dyn
std
::
error
::
Error
>>
{
// This macro call copies AUTHOR, VERSION and DESCRIPTION from program's Cargo.toml to the EAPI
// I/O module.
roboplc
::
init_eapi!
();
roboplc
::
setup_panic
();
roboplc
::
setup_panic
();
roboplc
::
configure_logger
(
roboplc
::
LevelFilter
::
Info
);
roboplc
::
configure_logger
(
roboplc
::
LevelFilter
::
Info
);
let
eapi_config
:
EAPIConfig
<
Message
,
Variables
>
=
EAPIConfig
::
new
(
"/opt/eva4/var/bus.ipc"
)
let
eapi_config
:
EAPIConfig
<
Message
,
Variables
>
=
EAPIConfig
::
new
(
"/opt/eva4/var/bus.ipc"
)
...
...
src/io/eapi.rs
浏览文件 @
8992d4d5
...
@@ -19,6 +19,34 @@ use std::mem;
...
@@ -19,6 +19,34 @@ use std::mem;
use
std
::
sync
::
Arc
;
use
std
::
sync
::
Arc
;
use
std
::
time
::
Duration
;
use
std
::
time
::
Duration
;
use
once_cell
::
sync
::
OnceCell
;
// Filled from the main program values
static
CARGO_PKG_AUTHORS
:
OnceCell
<
String
>
=
OnceCell
::
new
();
static
CARGO_PKG_DESCRIPTION
:
OnceCell
<
String
>
=
OnceCell
::
new
();
static
CARGO_PKG_VERSION
:
OnceCell
<
String
>
=
OnceCell
::
new
();
/// Sets the EAPI module information. Must be called only once. Usually not needed to be called
/// directly, as executed by the `init_eapi!` macro.
pub
fn
set_program_info
(
authors
:
&
str
,
description
:
&
str
,
version
:
&
str
)
{
CARGO_PKG_AUTHORS
.set
(
authors
.to_owned
())
.unwrap
();
CARGO_PKG_DESCRIPTION
.set
(
description
.to_owned
())
.unwrap
();
CARGO_PKG_VERSION
.set
(
version
.to_owned
())
.unwrap
();
}
#[macro_export]
/// Initializes the EAPI module
#[allow(clippy
::
module_name_repetitions)]
macro_rules!
init_eapi
{
()
=>
{
$crate
::
io
::
eapi
::
set_program_info
(
env!
(
"CARGO_PKG_AUTHORS"
),
env!
(
"CARGO_PKG_DESCRIPTION"
),
env!
(
"CARGO_PKG_VERSION"
),
);
};
}
use
crate
::
controller
::{
Context
,
SLEEP_STEP
};
use
crate
::
controller
::{
Context
,
SLEEP_STEP
};
use
crate
::{
pchannel_async
,
DataDeliveryPolicy
,
DeliveryPolicy
};
use
crate
::{
pchannel_async
,
DataDeliveryPolicy
,
DeliveryPolicy
};
use
crate
::{
use
crate
::{
...
@@ -231,15 +259,15 @@ where
...
@@ -231,15 +259,15 @@ where
"info"
=>
{
"info"
=>
{
if
payload
.is_empty
()
{
if
payload
.is_empty
()
{
#[derive(Serialize)]
#[derive(Serialize)]
struct
Payload
{
struct
Payload
<
'a
>
{
author
:
&
'
static
str
,
author
:
&
'
a
str
,
description
:
&
'
static
str
,
description
:
&
'
a
str
,
version
:
&
'
static
str
,
version
:
&
'
a
str
,
}
}
let
payload
=
Payload
{
let
payload
=
Payload
{
author
:
env!
(
"CARGO_PKG_AUTHORS"
),
author
:
CARGO_PKG_AUTHORS
.get
()
.map_or
(
""
,
|
s
|
s
.as_str
()
),
description
:
env!
(
"CARGO_PKG_DESCRIPTION"
),
description
:
CARGO_PKG_DESCRIPTION
.get
()
.map_or
(
""
,
|
s
|
s
.as_str
()
),
version
:
env!
(
"CARGO_PKG_VERSION"
),
version
:
CARGO_PKG_VERSION
.get
()
.map_or
(
""
,
|
s
|
s
.as_str
()
),
};
};
Ok
(
Some
(
pack
(
&
payload
)
?
))
Ok
(
Some
(
pack
(
&
payload
)
?
))
}
else
{
}
else
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论