Skip to content

Commit e275b1a

Browse files
committed
Comments update
1 parent c9a4403 commit e275b1a

File tree

7 files changed

+99
-146
lines changed

7 files changed

+99
-146
lines changed

crates/powerlink-rs-xdc/src/model/app_layers.rs

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
// crates/powerlink-rs-xdc/src/model/app_layers.rs
2-
31
//! Contains model structs related to `<ApplicationLayers>`.
2+
//!
43
//! (Schema: `ProfileBody_CommunicationNetwork_Powerlink.xsd`)
54
65
use super::modular::ModuleManagementComm;
76
use alloc::string::String;
87
use alloc::vec::Vec;
9-
use serde::{Deserialize, Serialize}; // Added import
8+
use serde::{Deserialize, Serialize};
109

11-
/// Contains the ObjectList and DataTypeList.
10+
/// Contains the Object Dictionary definition (`ObjectList`) and Data Type definitions (`DataTypeList`).
1211
#[derive(Debug, Serialize, Deserialize, Default)]
1312
pub struct ApplicationLayers {
1413
/// This optional list defines the mapping from hex ID to type name.
@@ -42,7 +41,8 @@ pub struct ObjectList {
4241

4342
// --- Enums for Object/SubObject Attributes ---
4443

45-
/// Access types of an object / subobject (from XSD `t_ObjectAccessType`).
44+
/// Access types of an object / subobject.
45+
/// (from XSD `t_ObjectAccessType`)
4646
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
4747
pub enum ObjectAccessType {
4848
#[serde(rename = "ro")]
@@ -55,7 +55,8 @@ pub enum ObjectAccessType {
5555
Constant,
5656
}
5757

58-
/// Ability to map an object / subobject to a PDO (from XSD `t_ObjectPDOMapping`).
58+
/// Ability to map an object / subobject to a PDO.
59+
/// (from XSD `t_ObjectPDOMapping`)
5960
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
6061
pub enum ObjectPdoMapping {
6162
#[serde(rename = "no")]
@@ -70,84 +71,79 @@ pub enum ObjectPdoMapping {
7071
Rpdo,
7172
}
7273

73-
/// Represents an Object Dictionary index (e.g., <Object index="1F22"...>).
74-
/// This struct includes attributes from the `ag_Powerlink_Object` group.
74+
/// Represents an Object Dictionary index.
75+
///
76+
/// This struct includes attributes from the `ag_Powerlink_Object` attribute group.
7577
#[derive(Debug, Serialize, Deserialize, Default)]
7678
pub struct Object {
7779
/// The OD index as a hex string (e.g., "1F22").
7880
#[serde(rename = "@index")]
7981
pub index: String,
8082

8183
// --- Fields from ag_Powerlink_Object ---
82-
/// The name of the object.
84+
8385
#[serde(rename = "@name")]
8486
pub name: String,
8587

86-
/// The object type (e.g., "9" for RECORD).
88+
/// The object type (e.g., "7" for VAR, "8" for ARRAY, "9" for RECORD).
8789
#[serde(rename = "@objectType")]
8890
pub object_type: String,
8991

90-
/// The POWERLINK data type (e.g., "0006" for Unsigned16).
92+
/// The POWERLINK data type ID (e.g., "0006" for Unsigned16).
9193
#[serde(rename = "@dataType", default, skip_serializing_if = "Option::is_none")]
9294
pub data_type: Option<String>,
9395

94-
/// The lower limit of the object's value.
9596
#[serde(rename = "@lowLimit", default, skip_serializing_if = "Option::is_none")]
9697
pub low_limit: Option<String>,
9798

98-
/// The upper limit of the object's value.
9999
#[serde(
100100
rename = "@highLimit",
101101
default,
102102
skip_serializing_if = "Option::is_none"
103103
)]
104104
pub high_limit: Option<String>,
105105

106-
/// The access type (e.g., "ro", "rw").
107106
#[serde(
108107
rename = "@accessType",
109108
default,
110109
skip_serializing_if = "Option::is_none"
111110
)]
112111
pub access_type: Option<ObjectAccessType>,
113112

114-
/// The default value of the object.
113+
/// The default value of the object. Used primarily in Device Description (XDD) files.
115114
#[serde(
116115
rename = "@defaultValue",
117116
default,
118117
skip_serializing_if = "Option::is_none"
119118
)]
120119
pub default_value: Option<String>,
121120

122-
/// The actual value of the object (used in XDC).
121+
/// The actual value of the object. Used primarily in Configuration (XDC) files.
123122
#[serde(
124123
rename = "@actualValue",
125124
default,
126125
skip_serializing_if = "Option::is_none"
127126
)]
128127
pub actual_value: Option<String>,
129128

130-
/// A denotation for the object.
131129
#[serde(
132130
rename = "@denotation",
133131
default,
134132
skip_serializing_if = "Option::is_none"
135133
)]
136134
pub denotation: Option<String>,
137135

138-
/// The PDO mapping capability of the object.
139136
#[serde(
140137
rename = "@PDOmapping",
141138
default,
142139
skip_serializing_if = "Option::is_none"
143140
)]
144141
pub pdo_mapping: Option<ObjectPdoMapping>,
145142

146-
/// Object flags.
147143
#[serde(rename = "@objFlags", default, skip_serializing_if = "Option::is_none")]
148144
pub obj_flags: Option<String>,
149145

150-
/// This attribute references a Parameter's uniqueID in the ApplicationProcess.
146+
/// References a Parameter's `uniqueID` in the `ApplicationProcess`.
151147
#[serde(
152148
rename = "@uniqueIDRef",
153149
default,
@@ -156,6 +152,7 @@ pub struct Object {
156152
pub unique_id_ref: Option<String>,
157153

158154
// --- End of fields from ag_Powerlink_Object ---
155+
159156
/// This attribute is used by modular devices to reference an index range.
160157
/// (from `t_Object_Extension_Head` and `t_Object_Extension`)
161158
#[serde(
@@ -165,99 +162,86 @@ pub struct Object {
165162
)]
166163
pub range_selector: Option<String>,
167164

168-
/// A list of SubObjects (e.g., <SubObject subIndex="01"...>).
165+
/// A list of SubObjects (e.g., `<SubObject subIndex="01"...>`).
169166
#[serde(rename = "SubObject", default)]
170167
pub sub_object: Vec<SubObject>,
171168
}
172169

173170
/// Represents an Object Dictionary sub-index.
174-
/// This struct includes attributes from the `ag_Powerlink_Object` group.
175171
#[derive(Debug, Serialize, Deserialize, Default)]
176172
pub struct SubObject {
177173
/// The OD sub-index as a hex string (e.g., "01").
178174
#[serde(rename = "@subIndex")]
179175
pub sub_index: String,
180176

181177
// --- Fields from ag_Powerlink_Object ---
182-
/// The name of the sub-object.
178+
183179
#[serde(rename = "@name")]
184180
pub name: String,
185181

186-
/// The object type (e.t., "7" for VAR).
187182
#[serde(rename = "@objectType")]
188183
pub object_type: String,
189184

190-
/// The POWERLINK data type (e.g., "0006" for Unsigned16).
191185
#[serde(rename = "@dataType", default, skip_serializing_if = "Option::is_none")]
192186
pub data_type: Option<String>,
193187

194-
/// The lower limit of the sub-object's value.
195188
#[serde(rename = "@lowLimit", default, skip_serializing_if = "Option::is_none")]
196189
pub low_limit: Option<String>,
197190

198-
/// The upper limit of the sub-object's value.
199191
#[serde(
200192
rename = "@highLimit",
201193
default,
202194
skip_serializing_if = "Option::is_none"
203195
)]
204196
pub high_limit: Option<String>,
205197

206-
/// The access type (e.g., "ro", "rw").
207198
#[serde(
208199
rename = "@accessType",
209200
default,
210201
skip_serializing_if = "Option::is_none"
211202
)]
212203
pub access_type: Option<ObjectAccessType>,
213204

214-
/// The `defaultValue` is the key data for an XDD file.
215205
#[serde(
216206
rename = "@defaultValue",
217207
default,
218208
skip_serializing_if = "Option::is_none"
219209
)]
220210
pub default_value: Option<String>,
221211

222-
/// The `actualValue` is the key data for an XDC file.
223212
#[serde(
224213
rename = "@actualValue",
225214
default,
226215
skip_serializing_if = "Option::is_none"
227216
)]
228217
pub actual_value: Option<String>,
229218

230-
/// A denotation for the sub-object.
231219
#[serde(
232220
rename = "@denotation",
233221
default,
234222
skip_serializing_if = "Option::is_none"
235223
)]
236224
pub denotation: Option<String>,
237225

238-
/// The PDO mapping capability of the sub-object.
239226
#[serde(
240227
rename = "@PDOmapping",
241228
default,
242229
skip_serializing_if = "Option::is_none"
243230
)]
244231
pub pdo_mapping: Option<ObjectPdoMapping>,
245232

246-
/// Object flags.
247233
#[serde(rename = "@objFlags", default, skip_serializing_if = "Option::is_none")]
248234
pub obj_flags: Option<String>,
249235

250-
/// This attribute references a Parameter's uniqueID in the ApplicationProcess.
251236
#[serde(
252237
rename = "@uniqueIDRef",
253238
default,
254239
skip_serializing_if = "Option::is_none"
255240
)]
256241
pub unique_id_ref: Option<String>,
257-
// --- End of fields from ag_Powerlink_Object ---
258242
}
259243

260-
// --- STRUCTS for DataTypeList (Comm Profile) ---
244+
// --- STRUCTS for DataTypeList ---
261245

262246
/// Represents `<DataTypeList>` (EPSG 311, 7.5.4.3).
263247
#[derive(Debug, Serialize, Deserialize, Default)]
@@ -278,7 +262,7 @@ pub struct DefType {
278262
pub type_name: DataTypeName,
279263
}
280264

281-
/// Represents the tag name of the child of `<defType>`.
265+
/// Enumeration of standard POWERLINK data type tags.
282266
/// (Based on EPSG 311, Table 56).
283267
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
284268
pub enum DataTypeName {
@@ -317,4 +301,4 @@ pub enum DataTypeName {
317301
#[serde(rename = "IP_ADDRESS")]
318302
IpAddress,
319303
NETTIME,
320-
}
304+
}

crates/powerlink-rs-xdc/src/model/app_process.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
// crates/powerlink-rs-xdc/src/model/app_process.rs
2-
31
//! Contains model structs related to `<ApplicationProcess>`.
2+
//!
43
//! (Schema: `ProfileBody_Device_Powerlink.xsd`)
54
6-
use super::common::{DataTypeIDRef, Glabels, bool_false, is_false};
5+
use super::common::{bool_false, is_false, DataTypeIDRef, Glabels};
76
use alloc::string::String;
87
use alloc::vec::Vec;
98
use serde::{Deserialize, Serialize};
109

11-
// --- STRUCTS for ApplicationProcess (Task 5) ---
12-
13-
/// Represents the `<ApplicationProcess>` block (EPSG 311, 7.4.7).
14-
/// This contains the device parameters, which are the source of default values.
10+
/// Represents the `<ApplicationProcess>` block.
11+
///
12+
/// This contains the device parameters, which serve as the source of default values.
1513
#[derive(Debug, Serialize, Deserialize, Default)]
1614
pub struct ApplicationProcess {
1715
/// Contains user-defined data types (EPSG 311, 7.4.7.2).
@@ -47,7 +45,7 @@ pub struct ApplicationProcess {
4745
pub template_list: Option<TemplateList>,
4846

4947
/// Contains parameter definitions (EPSG 311, 7.4.7.7).
50-
#[serde(rename = "parameterList")] // Required
48+
#[serde(rename = "parameterList")]
5149
pub parameter_list: ParameterList,
5250

5351
/// Contains parameter groupings (EPSG 311, 7.4.7.8).
@@ -67,7 +65,7 @@ pub struct TemplateList {
6765
default,
6866
skip_serializing_if = "Vec::is_empty"
6967
)]
70-
pub parameter_template: Vec<Parameter>, // Use Parameter struct, as it's identical
68+
pub parameter_template: Vec<Parameter>, // Identical to Parameter structure
7169

7270
#[serde(
7371
rename = "allowedValuesTemplate",
@@ -168,10 +166,9 @@ pub struct MemberRef {
168166
}
169167

170168
/// Represents the choice of data type for a Parameter.
171-
/// (Fix for serde `flatten` on enum variant error)
172169
#[derive(Debug, Serialize, Deserialize, Clone)]
173170
pub enum ParameterDataType {
174-
// Variants from GSimple (inlined)
171+
// Simple types from GSimple (inlined)
175172
BOOL,
176173
BITSTRING,
177174
BYTE,
@@ -192,14 +189,13 @@ pub enum ParameterDataType {
192189
STRING,
193190
WSTRING,
194191

195-
// Other choices
196-
#[serde(rename = "dataTypeIDRef")] // Fix: Add rename attribute
192+
// Complex choices
193+
#[serde(rename = "dataTypeIDRef")]
197194
DataTypeIDRef(DataTypeIDRef),
198-
#[serde(rename = "variableRef")] // Fix: Add rename attribute
195+
#[serde(rename = "variableRef")]
199196
VariableRef(VariableRef),
200197
}
201198

202-
// Add Default implementation
203199
impl Default for ParameterDataType {
204200
fn default() -> Self {
205201
ParameterDataType::BOOL
@@ -273,10 +269,9 @@ pub struct Property {
273269
}
274270

275271
/// Represents a `<parameter>` (EPSG 311, 7.4.7.7.2).
276-
/// (Updated for Task 5)
277272
#[derive(Debug, Serialize, Deserialize, Default)]
278273
pub struct Parameter {
279-
/// The unique ID (e.g., "Param1_Vendor_Specific") that `uniqueIDRef` points to.
274+
/// The unique ID (e.g., "Param1_Vendor_Specific").
280275
#[serde(rename = "@uniqueID")]
281276
pub unique_id: String,
282277

@@ -332,15 +327,15 @@ pub struct Parameter {
332327
)]
333328
pub denotation: Option<Denotation>,
334329

335-
/// The `actualValue` element, if present (less common for defaults).
330+
/// The `actualValue` element (prioritized in XDC).
336331
#[serde(
337332
rename = "actualValue",
338333
default,
339334
skip_serializing_if = "Option::is_none"
340335
)]
341336
pub actual_value: Option<Value>,
342337

343-
/// The `defaultValue` element, if present.
338+
/// The `defaultValue` element (prioritized in XDD).
344339
#[serde(
345340
rename = "defaultValue",
346341
default,
@@ -371,7 +366,6 @@ pub struct Parameter {
371366

372367
/// Represents a simple value-holding element like `<defaultValue value="0x01"/>`.
373368
/// (EPSG 311, 7.4.7.7.2.4, 7.4.7.7.2.5).
374-
/// (Updated for Task 5 to `t_value`)
375369
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
376370
pub struct Value {
377371
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
@@ -528,7 +522,7 @@ pub struct Count {
528522
#[serde(rename = "@uniqueID")]
529523
pub unique_id: String,
530524
#[serde(rename = "@access", default, skip_serializing_if = "Option::is_none")]
531-
pub access: Option<ParameterAccess>, // Simplified from schema's subset
525+
pub access: Option<ParameterAccess>,
532526
#[serde(flatten)]
533527
pub labels: Glabels,
534528
#[serde(rename = "defaultValue")]
@@ -763,4 +757,4 @@ pub struct ParameterRef {
763757
skip_serializing_if = "Option::is_none"
764758
)]
765759
pub bit_offset: Option<String>, // xsd:nonNegativeInteger
766-
}
760+
}

0 commit comments

Comments
 (0)