open_protocol/messages/
multi_spindle_result.rs

1use chrono::{DateTime, Local};
2use open_protocol_codec_proc_macro::{OpenProtocolDecode, OpenProtocolEncode, OpenProtocolMessage};
3
4/// A subscription for the multi-spindle result.
5/// For Power Focus, the subscription must be addressed to the sync Master.
6#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
7#[open_protocol_message(MID = 100, revision = 1)]
8pub struct MID0100rev1 {
9    // No additional fields for this MID.
10}
11
12/// This message is sent after each sync tightening.
13/// It contains the final result of the tightening for all spindles involved.
14#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
15#[open_protocol_message(MID = 101, revision = 1)]
16pub struct MID0101rev1 {
17    /// The number of spindles or presses involved in the tightening.
18    #[open_protocol_field(length = 2)]
19    pub number_of_spindles: u8,
20
21    /// The number of spindles currently running in the multiple.
22    #[open_protocol_field(length = 2)]
23    pub spindles_running: u8,
24
25    /// A unique ID for each sync tightening result.
26    #[open_protocol_field(length = 5)]
27    pub sync_tightening_id: u32,
28
29    /// The overall status of the sync tightening (1=OK, 0=NOK).
30    #[open_protocol_field(length = 1)]
31    pub sync_overall_status: u8,
32
33    /// The VIN (Vehicle Identification Number) associated with the tightening.
34    #[open_protocol_field(length = 25)]
35    pub vin_number: String,
36
37    /// The job ID associated with the tightening.
38    #[open_protocol_field(length = 2)]
39    pub job_id: u8,
40
41    /// The parameter set ID used in the tightening.
42    #[open_protocol_field(length = 3)]
43    pub parameter_set_id: u16,
44
45    /// The total number of tightenings required in the batch.
46    #[open_protocol_field(length = 4)]
47    pub batch_size: u16,
48
49    /// The current batch counter.
50    #[open_protocol_field(length = 4)]
51    pub batch_counter: u16,
52
53    /// The batch status (0=NOK, 1=OK, 2=Not used, 3=Running).
54    #[open_protocol_field(length = 1)]
55    pub batch_status: u8,
56
57    /// Timestamp for the multi-spindle result (YYYY-MM-DD:HH:MM:SS).
58    #[open_protocol_field(length = 19)]
59    pub timestamp: DateTime<Local>,
60
61    /// Status of each spindle in the multi-spindle tightening.
62    #[open_protocol_field(list, amount = "number_of_spindles", length = 5)]
63    pub spindle_statuses: Vec<SpindleResult>,
64}
65
66/// Acknowledges receipt of MID 0101 Multi-Spindle Result.
67#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
68#[open_protocol_message(MID = 102, revision = 1)]
69pub struct MID0102rev1 {
70    // No additional fields for this MID.
71}
72
73/// Cancels a previously subscribed multi-spindle result notification.
74#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
75#[open_protocol_message(MID = 103, revision = 1)]
76pub struct MID0103rev1 {
77    // No additional fields for this MID.
78}
79
80/// Requests an old multi-spindle tightening result by its unique ID.
81#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
82#[open_protocol_message(MID = 104, revision = 1)]
83pub struct MID0104rev1 {
84    /// The ID of the requested old multi-spindle result.
85    #[open_protocol_field(length = 10)]
86    pub old_sync_tightening_id: u32,
87}
88
89/// Status and data for an individual spindle in a multi-spindle tightening result.
90#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode)]
91pub struct SpindleResult {
92    /// The spindle number within the multiple.
93    #[open_protocol_field(length = 2)]
94    pub spindle_number: u8,
95
96    /// The channel ID of the spindle.
97    #[open_protocol_field(length = 2)]
98    pub channel_id: u8,
99
100    /// The overall status of the tightening for this spindle (0=NOK, 1=OK).
101    #[open_protocol_field(length = 1)]
102    pub overall_status: u8,
103}