Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
RoboPLC
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄新宇
RoboPLC
Commits
66c0aaa2
提交
66c0aaa2
authored
4月 05, 2024
作者:
Serhij S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
0.1.28
上级
d1c3dc64
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
31 行增加
和
1 行删除
+31
-1
Cargo.toml
Cargo.toml
+1
-1
eapi.rs
src/io/eapi.rs
+6
-0
mod.rs
src/io/mod.rs
+6
-0
mod.rs
src/io/modbus/mod.rs
+9
-0
regs.rs
src/io/modbus/regs.rs
+2
-0
server.rs
src/io/modbus/server.rs
+2
-0
raw_udp.rs
src/io/raw_udp.rs
+5
-0
没有找到文件。
Cargo.toml
浏览文件 @
66c0aaa2
[package]
name
=
"roboplc"
version
=
"0.1.2
7
"
version
=
"0.1.2
8
"
edition
=
"2021"
authors
=
[
"Serhij S. <div@altertech.com>"
]
license
=
"Apache-2.0"
...
...
src/io/eapi.rs
浏览文件 @
66c0aaa2
//!
//! [EAPI communication example](https://github.com/eva-ics/roboplc/blob/main/examples/eapi.rs)
use
binrw
::
BinWrite
;
use
busrt
::
rpc
::{
RpcError
,
RpcEvent
,
RpcHandlers
,
RpcResult
};
use
busrt
::{
async_trait
,
QoS
};
...
...
@@ -61,6 +63,7 @@ impl DataDeliveryPolicy for PushPayload {
}
}
/// EAPI connection configuration
#[derive(Debug,
Clone,
Serialize,
Deserialize)]
pub
struct
EAPIConfig
<
D
,
V
>
where
...
...
@@ -147,7 +150,9 @@ where
}
}
/// Action handler functions type
pub
type
ActionHandlerFn
<
D
,
V
>
=
fn
(
&
mut
Action
,
context
:
&
Context
<
D
,
V
>
)
->
ActionResult
;
/// The result type of action handler functions
pub
type
ActionResult
=
std
::
result
::
Result
<
(),
Box
<
dyn
std
::
error
::
Error
>>
;
type
ActionHandlers
<
D
,
V
>
=
Arc
<
BTreeMap
<
OID
,
ActionHandlerFn
<
D
,
V
>>>
;
...
...
@@ -276,6 +281,7 @@ where
}
}
/// EAPI connector, requires to be run in a separate thread manually
pub
struct
EAPI
<
D
,
V
>
where
D
:
DataDeliveryPolicy
+
Clone
+
Send
+
Sync
+
'static
,
...
...
src/io/mod.rs
浏览文件 @
66c0aaa2
//!
//! The module provides mapping for various protocols. Structural mapping is built on top of
//! the [binrw](https://crates.io/search?q=binrw) crate.
pub
use
binrw
;
use
binrw
::{
BinRead
,
BinWrite
};
use
crate
::
Result
;
#[cfg(feature
=
"eapi"
)]
/// EVA ICS local bus API
pub
mod
eapi
;
#[cfg(feature
=
"modbus"
)]
/// Modbus communication
pub
mod
modbus
;
/// Raw UDP communication
pub
mod
raw_udp
;
#[allow(clippy
::
module_name_repetitions)]
...
...
src/io/modbus/mod.rs
浏览文件 @
66c0aaa2
//!
//! Contains Modbus client/server implementations.
//!
//! Examples: [modbus
//! master(client)](https://github.com/eva-ics/roboplc/blob/main/examples/modbus-master.rs),
//! [modbus slave(server)](https://github.com/eva-ics/roboplc/blob/main/examples/modbus-slave.rs)
use
std
::
io
::
Cursor
;
use
crate
::
comm
::{
Client
,
Protocol
};
...
...
@@ -22,6 +28,7 @@ pub mod prelude {
};
}
/// Swaps endianess of floating point numbers in case of non-standard IEEE 754 layout.
pub
trait
SwapModbusEndianess
{
fn
to_swapped_modbus_endianness
(
&
self
)
->
Self
;
}
...
...
@@ -49,6 +56,7 @@ impl From<Protocol> for ModbusProto {
}
}
/// Mapping options for Modbus client
#[allow(clippy
::
module_name_repetitions)]
#[derive(Clone)]
pub
struct
ModbusMappingOptions
{
...
...
@@ -71,6 +79,7 @@ impl Default for ModbusMappingOptions {
}
}
/// Mapping for Modbus client
#[allow(clippy
::
module_name_repetitions)]
pub
struct
ModbusMapping
{
client
:
Client
,
...
...
src/io/modbus/regs.rs
浏览文件 @
66c0aaa2
...
...
@@ -2,6 +2,7 @@ use std::str::FromStr;
use
crate
::{
Error
,
Result
};
/// A Modbus register kind.
#[derive(Eq,
PartialEq,
Copy,
Clone,
Debug)]
pub
enum
Kind
{
Coil
,
...
...
@@ -10,6 +11,7 @@ pub enum Kind {
Holding
,
}
/// A Modbus register type, contains the kind and the offset.
#[derive(Debug,
Clone,
Copy,
Eq,
PartialEq)]
pub
struct
Register
{
pub
kind
:
Kind
,
...
...
src/io/modbus/server.rs
浏览文件 @
66c0aaa2
...
...
@@ -65,6 +65,7 @@ fn handle_client<
Ok
(())
}
/// Modbus server. Requires to be run in a separate thread manually.
#[allow(clippy
::
module_name_repetitions)]
pub
struct
ModbusServer
<
const
C
:
usize
,
const
D
:
usize
,
const
I
:
usize
,
const
H
:
usize
>
{
storage
:
Arc
<
Mutex
<
ModbusStorage
<
C
,
D
,
I
,
H
>>>
,
...
...
@@ -145,6 +146,7 @@ fn prepare_tcp_stream(stream: &TcpStream, timeout: Duration) -> Result<()> {
Ok
(())
}
/// Server storage context mapping.
pub
struct
ModbusServerMapping
<
const
C
:
usize
,
const
D
:
usize
,
const
I
:
usize
,
const
H
:
usize
>
{
storage
:
Arc
<
Mutex
<
ModbusStorage
<
C
,
D
,
I
,
H
>>>
,
register
:
ModbusRegister
,
...
...
src/io/raw_udp.rs
浏览文件 @
66c0aaa2
//!
//! Can be used to communicate between processes on different machines or with various 3rd party
//! devices and software, such as Matlab, LabView, etc.
//!
//! [Raw UDP example](https://github.com/eva-ics/roboplc/blob/main/examples/raw-udp.rs)
use
binrw
::{
BinRead
,
BinWrite
};
use
std
::{
io
::
Cursor
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论