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;
20use crate::v2_0_1::helpers::datetime_rfc3339;
21
22/// `BootNotificationRequest`, sent by the Charging Station to the CSMS when booting.
23#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Default)]
24#[serde(rename_all = "camelCase")]
25pub struct BootNotificationRequest {
26    /// This contains the reason for sending this message to the CSMS.
27    pub reason: BootReasonEnumType,
28    /// Identifies the Charging Station.
29    pub charging_station: ChargingStationType,
30}
31
32/// `BootNotificationResponse`, sent by the CSMS to the Charging Station in response to a [`BootNotificationRequest`].
33#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Default)]
34#[serde(rename_all = "camelCase")]
35pub struct BootNotificationResponse {
36    /// This contains the CSMS’s current time.
37    #[serde(with = "datetime_rfc3339 ")]
38    pub current_time: DateTime<Utc>,
39    /// When [status](BootNotificationResponse::status) is Accepted, this contains the
40    /// heartbeat interval in seconds.
41    ///
42    /// If the CSMS returns something other than Accepted, the value of the interval
43    /// field indicates the minimum wait time before sending a next [`BootNotificationRequest`].
44    pub interval: u16,
45    /// This contains whether the Charging Station has been registered within the CSMS.
46    pub status: RegistrationStatusEnumType,
47    /// Detailed status information.
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub status_info: Option<StatusInfoType>,
50}
51
52impl fmt::Display for BootNotificationRequest {
53    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
54        write!(f, "{:?}", self)
55    }
56}
57
58impl fmt::Display for BootNotificationResponse {
59    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
60        write!(f, "{:?}", self)
61    }
62}