rust_ocpp/v2_0_1/messages/
boot_notification.rs

1//! BootNotification
2//!
3//! The objective of this use case is to enable a Charging Station that is
4//! powering up to register itself at a CSMS and provide the right state information.
5//!
6//! To be able to control Charging Stations connecting to a CSMS, Charging Stations
7//! are required to send [`BootNotificationRequest`]. This request contains some
8//! general information about the Charging Station.
9//!
10//!
11use std::fmt;
12
13use chrono::DateTime;
14use chrono::Utc;
15
16use crate::v2_0_1::datatypes::charging_station_type::ChargingStationType;
17use crate::v2_0_1::datatypes::status_info_type::StatusInfoType;
18use crate::v2_0_1::enumerations::boot_reason_enum_type::BootReasonEnumType;
19use crate::v2_0_1::enumerations::registration_status_enum_type::RegistrationStatusEnumType;
20
21/// `BootNotificationRequest`, sent by the Charging Station to the CSMS when booting.
22#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Default)]
23#[serde(rename_all = "camelCase")]
24pub struct BootNotificationRequest {
25    /// This contains the reason for sending this message to the CSMS.
26    pub reason: BootReasonEnumType,
27    /// Identifies the Charging Station.
28    pub charging_station: ChargingStationType,
29}
30
31/// `BootNotificationResponse`, sent by the CSMS to the Charging Station in response to a [`BootNotificationRequest`].
32#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Default)]
33#[serde(rename_all = "camelCase")]
34pub struct BootNotificationResponse {
35    /// This contains the CSMS’s current time.
36    pub current_time: DateTime<Utc>,
37    /// When [status](BootNotificationResponse::status) is Accepted, this contains the
38    /// heartbeat interval in seconds.
39    ///
40    /// If the CSMS returns something other than Accepted, the value of the interval
41    /// field indicates the minimum wait time before sending a next [`BootNotificationRequest`].
42    pub interval: u16,
43    /// This contains whether the Charging Station has been registered within the CSMS.
44    pub status: RegistrationStatusEnumType,
45    /// Detailed status information.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub status_info: Option<StatusInfoType>,
48}
49
50impl fmt::Display for BootNotificationRequest {
51    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
52        write!(f, "{:?}", self)
53    }
54}
55
56impl fmt::Display for BootNotificationResponse {
57    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
58        write!(f, "{:?}", self)
59    }
60}