ethercat_esi/
structs.rs

1pub use ethercat_types::{PdoEntryIdx, PdoIdx, SmIdx, SubIdx};
2
3/// EtherCAT Slave Information (ESI).
4#[derive(Debug, Clone)]
5pub struct EtherCatInfo {
6    pub version: Option<String>,
7    pub info_reference: Option<String>,
8    pub vendor: Vendor,
9    pub description: Description,
10}
11
12/// Vendor information.
13#[derive(Debug, Clone)]
14pub struct Vendor {
15    pub file_version: Option<u32>,
16    pub id: u32,
17    pub name: Option<String>,
18    pub comment: Option<String>,
19    pub url: Option<String>,
20    pub desc_url: Option<String>,
21    pub image: Option<Image>,
22}
23
24/// Further slave descriptions.
25#[derive(Debug, Clone, Default)]
26pub struct Description {
27    pub groups: Vec<Group>,
28    pub devices: Vec<Device>,
29    pub modules: Vec<Module>,
30}
31
32/// Image data (BMP file format).
33#[derive(Debug, Clone)]
34pub enum Image {
35    /// Obsolete
36    Image16x14(String),
37    ImageFile16x14(String),
38    ImageData16x14(HexBinary),
39}
40
41#[derive(Debug, Clone)]
42pub struct Group {
43    pub sort_order: Option<i32>,
44    pub parent_group: Option<String>,
45    pub r#type: String,
46    pub name: String,
47    pub comment: Option<String>,
48    pub image: Option<Image>,
49    // TODO: Optional 'VendorSpecific'
50}
51
52#[derive(Debug, Clone)]
53pub struct Device {
54    pub physics: Option<String>,
55    pub name: String,
56    pub desc: String,
57    pub product_code: u32,
58    pub revision_no: u32,
59    pub sm: Vec<Sm>,
60    pub rx_pdo: Vec<Pdo>,
61    pub tx_pdo: Vec<Pdo>,
62}
63
64/// Sync Manager (SM).
65#[derive(Debug, Clone)]
66pub struct Sm {
67    pub enable: bool,
68    pub start_address: u16,
69    pub control_byte: u8,
70    pub default_size: Option<usize>,
71}
72
73/// Process Data Object (PDO).
74#[derive(Debug, Clone)]
75pub struct Pdo {
76    pub sm: SmIdx,
77    pub fixed: bool,
78    pub mandatory: bool,
79    pub idx: PdoIdx,
80    pub name: Option<String>,
81    pub entries: Vec<PdoEntry>,
82}
83
84/// Service Data Object (SDO).
85#[derive(Debug, Clone)]
86pub struct Sdo {
87    // TODO
88}
89
90/// PDO Entry.
91#[derive(Debug, Clone)]
92pub struct PdoEntry {
93    pub entry_idx: PdoEntryIdx,
94    pub bit_len: usize,
95    pub name: Option<String>,
96    pub data_type: Option<String>,
97}
98
99#[derive(Debug, Clone)]
100pub struct Module {
101    pub r#type: String,
102    pub name: Option<String>,
103    pub tx_pdo: Option<Pdo>,
104    pub rx_pdo: Option<Pdo>,
105    pub mailbox: Mailbox,
106    pub profile: Profile,
107}
108
109#[derive(Debug, Clone)]
110pub struct Mailbox {
111    // TODO
112}
113
114#[derive(Debug, Clone)]
115pub struct Profile {
116    // TODO
117}
118
119/// HexBinary represents arbitrary hex-encoded binary data.
120///
121/// More info: https://www.w3.org/TR/xmlschema-2/#hexBinary
122#[derive(Debug, Clone, PartialEq)]
123pub struct HexBinary(pub String);