// @generated by `cargo xtask codegen` from the vendored OCPP JSON schemas.
// DO NOT EDIT — re-run the generator instead. CI fails if this file is stale.
//! Data types shared between OCPP 2.1 messages, generated from the official JSON schemas.
#![allow(unused_imports, clippy::doc_markdown, clippy::struct_excessive_bools)]
#![allow(
clippy::too_many_lines,
clippy::too_many_arguments,
clippy::wildcard_imports
)]
#![allow(clippy::match_same_arms, clippy::fn_params_excessive_bools)]
use alloc::string::String;
use alloc::vec::Vec;
use serde::{Deserialize, Serialize};
use super::enums::*;
use crate::validate::{self, Validate, ValidationPath, Violations};
/// EV AC charging parameters for ISO 15118-2
///
/// The OCPP 2.1 `ACChargingParameters` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ACChargingParameters {
/// Amount of energy requested (in Wh). This includes energy required for preconditioning.
/// Relates to: +
/// *ISO 15118-2*: AC_EVChargeParameterType: EAmount +
/// *ISO 15118-20*: Dynamic/Scheduled_SEReqControlModeType: EVTargetEnergyRequest
#[serde(rename = "energyAmount")]
pub energy_amount: crate::types::Decimal,
/// Minimum current (amps) supported by the electric vehicle (per phase).
/// Relates to: +
/// *ISO 15118-2*: AC_EVChargeParameterType: EVMinCurrent
#[serde(rename = "evMinCurrent")]
pub ev_min_current: crate::types::Decimal,
/// Maximum current (amps) supported by the electric vehicle (per phase). Includes cable capacity.
/// Relates to: +
/// *ISO 15118-2*: AC_EVChargeParameterType: EVMaxCurrent
#[serde(rename = "evMaxCurrent")]
pub ev_max_current: crate::types::Decimal,
/// Maximum voltage supported by the electric vehicle.
/// Relates to: +
/// *ISO 15118-2*: AC_EVChargeParameterType: EVMaxVoltage
#[serde(rename = "evMaxVoltage")]
pub ev_max_voltage: crate::types::Decimal,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ACChargingParameters {
/// Creates a `ACChargingParameters` from its required fields.
#[must_use]
pub fn new(
energy_amount: impl Into<crate::types::Decimal>,
ev_min_current: impl Into<crate::types::Decimal>,
ev_max_current: impl Into<crate::types::Decimal>,
ev_max_voltage: impl Into<crate::types::Decimal>,
) -> Self {
Self {
energy_amount: energy_amount.into(),
ev_min_current: ev_min_current.into(),
ev_max_current: ev_max_current.into(),
ev_max_voltage: ev_max_voltage.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ACChargingParameters {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Collection of configuration data needed to make a data-connection over a cellular network.
///
/// NOTE: When asking a GSM modem to dial in, it is possible to specify which mobile operator should be used. This can be done with the mobile country code (MCC) in combination with a mobile network code (MNC). Example: If your preferred network is Vodafone Netherlands, the MCC=204 and the MNC=04 which means the key PreferredNetwork = 20404 Some modems allows to specify a preferred network, which means, if this network is not available, a different network is used. If you specify UseOnlyPreferredNetwork and this network is not available, the modem will not dial in.
///
/// The OCPP 2.1 `APN` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct APN {
/// The Access Point Name as an URL.
pub apn: String,
/// The `apnAuthentication` member.
#[serde(rename = "apnAuthentication")]
pub apn_authentication: APNAuthentication,
/// APN username.
#[serde(rename = "apnUserName")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub apn_user_name: Option<String>,
/// *(2.1)* APN Password.
#[serde(rename = "apnPassword")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub apn_password: Option<String>,
/// SIM card pin code.
#[serde(rename = "simPin")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub sim_pin: Option<i32>,
/// Preferred network, written as MCC and MNC concatenated. See note.
#[serde(rename = "preferredNetwork")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub preferred_network: Option<String>,
/// Default: false. Use only the preferred Network, do
/// not dial in when not available. See Note.
/// Schema default: `false`.
#[serde(rename = "useOnlyPreferredNetwork")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub use_only_preferred_network: Option<bool>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl APN {
/// Creates a `APN` from its required fields.
#[must_use]
pub fn new(apn: impl Into<String>, apn_authentication: APNAuthentication) -> Self {
Self {
apn: apn.into(),
apn_authentication,
apn_user_name: None,
apn_password: None,
sim_pin: None,
preferred_network: None,
use_only_preferred_network: None,
custom_data: None,
}
}
/// Sets the optional `apnUserName` field.
#[must_use]
pub fn with_apn_user_name(mut self, value: impl Into<String>) -> Self {
self.apn_user_name = Some(value.into());
self
}
/// Sets the optional `apnPassword` field.
#[must_use]
pub fn with_apn_password(mut self, value: impl Into<String>) -> Self {
self.apn_password = Some(value.into());
self
}
/// Sets the optional `simPin` field.
#[must_use]
pub fn with_sim_pin(mut self, value: i32) -> Self {
self.sim_pin = Some(value);
self
}
/// Sets the optional `preferredNetwork` field.
#[must_use]
pub fn with_preferred_network(mut self, value: impl Into<String>) -> Self {
self.preferred_network = Some(value.into());
self
}
/// Sets the optional `useOnlyPreferredNetwork` field.
#[must_use]
pub fn with_use_only_preferred_network(mut self, value: bool) -> Self {
self.use_only_preferred_network = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for APN {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("apn");
validate::string(self.apn.as_str(), None, Some(2000), path, out);
path.pop();
path.push_key("apnAuthentication");
Validate::validate_at(&self.apn_authentication, path, out);
path.pop();
path.push_key("apnUserName");
if let Some(value) = &self.apn_user_name {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("apnPassword");
if let Some(value) = &self.apn_password {
validate::string(value.as_str(), None, Some(64), path, out);
}
path.pop();
path.push_key("preferredNetwork");
if let Some(value) = &self.preferred_network {
validate::string(value.as_str(), None, Some(6), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The AbsolutePriceScheduleType is modeled after the same type that is defined in ISO 15118-20, such that if it is supplied by an EMSP as a signed EXI message, the conversion from EXI to JSON (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest and therefore does not invalidate the signature.
///
/// image::images/AbsolutePriceSchedule-Simple.png\[\]
///
/// The OCPP 2.1 `AbsolutePriceSchedule` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct AbsolutePriceSchedule {
/// Starting point of price schedule.
#[serde(rename = "timeAnchor")]
pub time_anchor: crate::types::DateTime,
/// Unique ID of price schedule
#[serde(rename = "priceScheduleID")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub price_schedule_id: i32,
/// Currency according to ISO 4217.
pub currency: String,
/// String that indicates what language is used for the human readable strings in the price schedule. Based on ISO 639.
pub language: String,
/// A string in URN notation which shall uniquely identify an algorithm that defines how to compute an energy fee sum for a specific power profile based on the EnergyFee information from the PriceRule elements.
#[serde(rename = "priceAlgorithm")]
pub price_algorithm: String,
/// The `priceRuleStacks` member.
#[serde(rename = "priceRuleStacks")]
pub price_rule_stacks: Vec<PriceRuleStack>,
/// Description of the price schedule.
#[serde(rename = "priceScheduleDescription")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub price_schedule_description: Option<String>,
/// The `minimumCost` member.
#[serde(rename = "minimumCost")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub minimum_cost: Option<RationalNumber>,
/// The `maximumCost` member.
#[serde(rename = "maximumCost")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub maximum_cost: Option<RationalNumber>,
/// The `taxRules` member.
#[serde(rename = "taxRules")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tax_rules: Option<Vec<TaxRule>>,
/// The `overstayRuleList` member.
#[serde(rename = "overstayRuleList")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub overstay_rule_list: Option<OverstayRuleList>,
/// The `additionalSelectedServices` member.
#[serde(rename = "additionalSelectedServices")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub additional_selected_services: Option<Vec<AdditionalSelectedServices>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl AbsolutePriceSchedule {
/// Creates a `AbsolutePriceSchedule` from its required fields.
#[must_use]
pub fn new(
time_anchor: impl Into<crate::types::DateTime>,
price_schedule_id: i32,
currency: impl Into<String>,
language: impl Into<String>,
price_algorithm: impl Into<String>,
price_rule_stacks: Vec<PriceRuleStack>,
) -> Self {
Self {
time_anchor: time_anchor.into(),
price_schedule_id,
currency: currency.into(),
language: language.into(),
price_algorithm: price_algorithm.into(),
price_rule_stacks,
price_schedule_description: None,
minimum_cost: None,
maximum_cost: None,
tax_rules: None,
overstay_rule_list: None,
additional_selected_services: None,
custom_data: None,
}
}
/// Sets the optional `priceScheduleDescription` field.
#[must_use]
pub fn with_price_schedule_description(mut self, value: impl Into<String>) -> Self {
self.price_schedule_description = Some(value.into());
self
}
/// Sets the optional `minimumCost` field.
#[must_use]
pub fn with_minimum_cost(mut self, value: RationalNumber) -> Self {
self.minimum_cost = Some(value);
self
}
/// Sets the optional `maximumCost` field.
#[must_use]
pub fn with_maximum_cost(mut self, value: RationalNumber) -> Self {
self.maximum_cost = Some(value);
self
}
/// Sets the optional `taxRules` field.
#[must_use]
pub fn with_tax_rules(mut self, value: Vec<TaxRule>) -> Self {
self.tax_rules = Some(value);
self
}
/// Sets the optional `overstayRuleList` field.
#[must_use]
pub fn with_overstay_rule_list(mut self, value: OverstayRuleList) -> Self {
self.overstay_rule_list = Some(value);
self
}
/// Sets the optional `additionalSelectedServices` field.
#[must_use]
pub fn with_additional_selected_services(
mut self,
value: Vec<AdditionalSelectedServices>,
) -> Self {
self.additional_selected_services = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for AbsolutePriceSchedule {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("priceScheduleID");
validate::int_range(i64::from(self.price_schedule_id), Some(0), None, path, out);
path.pop();
path.push_key("currency");
validate::string(self.currency.as_str(), None, Some(3), path, out);
path.pop();
path.push_key("language");
validate::string(self.language.as_str(), None, Some(8), path, out);
path.pop();
path.push_key("priceAlgorithm");
validate::string(self.price_algorithm.as_str(), None, Some(2000), path, out);
path.pop();
path.push_key("priceRuleStacks");
validate::list_len(self.price_rule_stacks.len(), Some(1), Some(1024), path, out);
for (index, item) in self.price_rule_stacks.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("priceScheduleDescription");
if let Some(value) = &self.price_schedule_description {
validate::string(value.as_str(), None, Some(160), path, out);
}
path.pop();
path.push_key("minimumCost");
if let Some(value) = &self.minimum_cost {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("maximumCost");
if let Some(value) = &self.maximum_cost {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("taxRules");
if let Some(value) = &self.tax_rules {
validate::list_len(value.len(), Some(1), Some(10), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("overstayRuleList");
if let Some(value) = &self.overstay_rule_list {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("additionalSelectedServices");
if let Some(value) = &self.additional_selected_services {
validate::list_len(value.len(), Some(1), Some(5), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.
///
/// The OCPP 2.1 `AdditionalInfo` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct AdditionalInfo {
/// *(2.1)* This field specifies the additional IdToken.
#[serde(rename = "additionalIdToken")]
pub additional_id_token: String,
/// _additionalInfo_ can be used to send extra information to CSMS in addition to the regular authorization with _IdToken_. _AdditionalInfo_ contains one or more custom _types_, which need to be agreed upon by all parties involved. When the _type_ is not supported, the CSMS/Charging Station MAY ignore the _additionalInfo_.
pub r#type: String,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl AdditionalInfo {
/// Creates a `AdditionalInfo` from its required fields.
#[must_use]
pub fn new(additional_id_token: impl Into<String>, r#type: impl Into<String>) -> Self {
Self {
additional_id_token: additional_id_token.into(),
r#type: r#type.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for AdditionalInfo {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("additionalIdToken");
validate::string(
self.additional_id_token.as_str(),
None,
Some(255),
path,
out,
);
path.pop();
path.push_key("type");
validate::string(self.r#type.as_str(), None, Some(50), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Part of ISO 15118-20 price schedule.
///
/// The OCPP 2.1 `AdditionalSelectedServices` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct AdditionalSelectedServices {
/// The `serviceFee` member.
#[serde(rename = "serviceFee")]
pub service_fee: RationalNumber,
/// Human readable string to identify this service.
#[serde(rename = "serviceName")]
pub service_name: String,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl AdditionalSelectedServices {
/// Creates a `AdditionalSelectedServices` from its required fields.
#[must_use]
pub fn new(service_fee: RationalNumber, service_name: impl Into<String>) -> Self {
Self {
service_fee,
service_name: service_name.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for AdditionalSelectedServices {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("serviceFee");
Validate::validate_at(&self.service_fee, path, out);
path.pop();
path.push_key("serviceName");
validate::string(self.service_name.as_str(), None, Some(80), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// *(2.1)* A generic address format.
///
/// The OCPP 2.1 `Address` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Address {
/// Name of person/company
pub name: String,
/// Address line 1
pub address1: String,
/// City
pub city: String,
/// Country name
pub country: String,
/// Address line 2
#[serde(default, skip_serializing_if = "Option::is_none")]
pub address2: Option<String>,
/// Postal code
#[serde(rename = "postalCode")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub postal_code: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl Address {
/// Creates a `Address` from its required fields.
#[must_use]
pub fn new(
name: impl Into<String>,
address1: impl Into<String>,
city: impl Into<String>,
country: impl Into<String>,
) -> Self {
Self {
name: name.into(),
address1: address1.into(),
city: city.into(),
country: country.into(),
address2: None,
postal_code: None,
custom_data: None,
}
}
/// Sets the optional `address2` field.
#[must_use]
pub fn with_address2(mut self, value: impl Into<String>) -> Self {
self.address2 = Some(value.into());
self
}
/// Sets the optional `postalCode` field.
#[must_use]
pub fn with_postal_code(mut self, value: impl Into<String>) -> Self {
self.postal_code = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for Address {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("name");
validate::string(self.name.as_str(), None, Some(50), path, out);
path.pop();
path.push_key("address1");
validate::string(self.address1.as_str(), None, Some(100), path, out);
path.pop();
path.push_key("city");
validate::string(self.city.as_str(), None, Some(100), path, out);
path.pop();
path.push_key("country");
validate::string(self.country.as_str(), None, Some(50), path, out);
path.pop();
path.push_key("address2");
if let Some(value) = &self.address2 {
validate::string(value.as_str(), None, Some(100), path, out);
}
path.pop();
path.push_key("postalCode");
if let Some(value) = &self.postal_code {
validate::string(value.as_str(), None, Some(20), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Contains the identifier to use for authorization.
///
/// The OCPP 2.1 `AuthorizationData` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct AuthorizationData {
/// The `idToken` member.
#[serde(rename = "idToken")]
pub id_token: IdToken,
/// The `idTokenInfo` member.
#[serde(rename = "idTokenInfo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub id_token_info: Option<IdTokenInfo>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl AuthorizationData {
/// Creates a `AuthorizationData` from its required fields.
#[must_use]
pub fn new(id_token: IdToken) -> Self {
Self {
id_token,
id_token_info: None,
custom_data: None,
}
}
/// Sets the optional `idTokenInfo` field.
#[must_use]
pub fn with_id_token_info(mut self, value: IdTokenInfo) -> Self {
self.id_token_info = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for AuthorizationData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("idToken");
Validate::validate_at(&self.id_token, path, out);
path.pop();
path.push_key("idTokenInfo");
if let Some(value) = &self.id_token_info {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `BatteryData` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct BatteryData {
/// Slot number where battery is inserted or removed.
#[serde(rename = "evseId")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub evse_id: i32,
/// Serial number of battery.
#[serde(rename = "serialNumber")]
pub serial_number: String,
/// State of charge
#[serde(rename = "soC")]
pub so_c: crate::types::Decimal,
/// State of health
#[serde(rename = "soH")]
pub so_h: crate::types::Decimal,
/// Production date of battery.
#[serde(rename = "productionDate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub production_date: Option<crate::types::DateTime>,
/// Vendor-specific info from battery in undefined format.
#[serde(rename = "vendorInfo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vendor_info: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl BatteryData {
/// Creates a `BatteryData` from its required fields.
#[must_use]
pub fn new(
evse_id: i32,
serial_number: impl Into<String>,
so_c: impl Into<crate::types::Decimal>,
so_h: impl Into<crate::types::Decimal>,
) -> Self {
Self {
evse_id,
serial_number: serial_number.into(),
so_c: so_c.into(),
so_h: so_h.into(),
production_date: None,
vendor_info: None,
custom_data: None,
}
}
/// Sets the optional `productionDate` field.
#[must_use]
pub fn with_production_date(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.production_date = Some(value.into());
self
}
/// Sets the optional `vendorInfo` field.
#[must_use]
pub fn with_vendor_info(mut self, value: impl Into<String>) -> Self {
self.vendor_info = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for BatteryData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("evseId");
validate::int_range(i64::from(self.evse_id), Some(0), None, path, out);
path.pop();
path.push_key("serialNumber");
validate::string(self.serial_number.as_str(), None, Some(50), path, out);
path.pop();
path.push_key("soC");
validate::range(
self.so_c,
Some(crate::types::Decimal::new(0, 0)),
Some(crate::types::Decimal::new(100, 0)),
path,
out,
);
path.pop();
path.push_key("soH");
validate::range(
self.so_h,
Some(crate::types::Decimal::new(0, 0)),
Some(crate::types::Decimal::new(100, 0)),
path,
out,
);
path.pop();
path.push_key("vendorInfo");
if let Some(value) = &self.vendor_info {
validate::string(value.as_str(), None, Some(500), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `CertificateHashData` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CertificateHashData {
/// The `hashAlgorithm` member.
#[serde(rename = "hashAlgorithm")]
pub hash_algorithm: HashAlgorithm,
/// The hash of the issuer’s distinguished
/// name (DN), that must be calculated over the DER
/// encoding of the issuer’s name field in the certificate
/// being checked.
#[serde(rename = "issuerNameHash")]
pub issuer_name_hash: String,
/// The hash of the DER encoded public key:
/// the value (excluding tag and length) of the subject
/// public key field in the issuer’s certificate.
#[serde(rename = "issuerKeyHash")]
pub issuer_key_hash: String,
/// The string representation of the
/// hexadecimal value of the serial number without the
/// prefix "0x" and without leading zeroes.
#[serde(rename = "serialNumber")]
pub serial_number: String,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl CertificateHashData {
/// Creates a `CertificateHashData` from its required fields.
#[must_use]
pub fn new(
hash_algorithm: HashAlgorithm,
issuer_name_hash: impl Into<String>,
issuer_key_hash: impl Into<String>,
serial_number: impl Into<String>,
) -> Self {
Self {
hash_algorithm,
issuer_name_hash: issuer_name_hash.into(),
issuer_key_hash: issuer_key_hash.into(),
serial_number: serial_number.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for CertificateHashData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("hashAlgorithm");
Validate::validate_at(&self.hash_algorithm, path, out);
path.pop();
path.push_key("issuerNameHash");
validate::string(self.issuer_name_hash.as_str(), None, Some(128), path, out);
path.pop();
path.push_key("issuerKeyHash");
validate::string(self.issuer_key_hash.as_str(), None, Some(128), path, out);
path.pop();
path.push_key("serialNumber");
validate::string(self.serial_number.as_str(), None, Some(40), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `CertificateHashDataChain` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CertificateHashDataChain {
/// The `certificateHashData` member.
#[serde(rename = "certificateHashData")]
pub certificate_hash_data: CertificateHashData,
/// The `certificateType` member.
#[serde(rename = "certificateType")]
pub certificate_type: GetCertificateIdUse,
/// The `childCertificateHashData` member.
#[serde(rename = "childCertificateHashData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub child_certificate_hash_data: Option<Vec<CertificateHashData>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl CertificateHashDataChain {
/// Creates a `CertificateHashDataChain` from its required fields.
#[must_use]
pub fn new(
certificate_hash_data: CertificateHashData,
certificate_type: GetCertificateIdUse,
) -> Self {
Self {
certificate_hash_data,
certificate_type,
child_certificate_hash_data: None,
custom_data: None,
}
}
/// Sets the optional `childCertificateHashData` field.
#[must_use]
pub fn with_child_certificate_hash_data(mut self, value: Vec<CertificateHashData>) -> Self {
self.child_certificate_hash_data = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for CertificateHashDataChain {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("certificateHashData");
Validate::validate_at(&self.certificate_hash_data, path, out);
path.pop();
path.push_key("certificateType");
Validate::validate_at(&self.certificate_type, path, out);
path.pop();
path.push_key("childCertificateHashData");
if let Some(value) = &self.child_certificate_hash_data {
validate::list_len(value.len(), Some(1), Some(4), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Revocation status of certificate
///
/// The OCPP 2.1 `CertificateStatus` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CertificateStatus {
/// The `certificateHashData` member.
#[serde(rename = "certificateHashData")]
pub certificate_hash_data: CertificateHashData,
/// The `source` member.
pub source: CertificateStatusSource,
/// The `status` member.
pub status: CertificateStatusEnum,
/// The `nextUpdate` member.
#[serde(rename = "nextUpdate")]
pub next_update: crate::types::DateTime,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl CertificateStatus {
/// Creates a `CertificateStatus` from its required fields.
#[must_use]
pub fn new(
certificate_hash_data: CertificateHashData,
source: CertificateStatusSource,
status: CertificateStatusEnum,
next_update: impl Into<crate::types::DateTime>,
) -> Self {
Self {
certificate_hash_data,
source,
status,
next_update: next_update.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for CertificateStatus {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("certificateHashData");
Validate::validate_at(&self.certificate_hash_data, path, out);
path.pop();
path.push_key("source");
Validate::validate_at(&self.source, path, out);
path.pop();
path.push_key("status");
Validate::validate_at(&self.status, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Data necessary to request the revocation status of a certificate.
///
/// The OCPP 2.1 `CertificateStatusRequestInfo` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CertificateStatusRequestInfo {
/// The `certificateHashData` member.
#[serde(rename = "certificateHashData")]
pub certificate_hash_data: CertificateHashData,
/// The `source` member.
pub source: CertificateStatusSource,
/// URL(s) of _source_.
pub urls: Vec<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl CertificateStatusRequestInfo {
/// Creates a `CertificateStatusRequestInfo` from its required fields.
#[must_use]
pub fn new(
certificate_hash_data: CertificateHashData,
source: CertificateStatusSource,
urls: impl IntoIterator<Item = impl Into<String>>,
) -> Self {
Self {
certificate_hash_data,
source,
urls: urls.into_iter().map(Into::into).collect(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for CertificateStatusRequestInfo {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("certificateHashData");
Validate::validate_at(&self.certificate_hash_data, path, out);
path.pop();
path.push_key("source");
Validate::validate_at(&self.source, path, out);
path.pop();
path.push_key("urls");
validate::list_len(self.urls.len(), Some(1), Some(5), path, out);
for (index, item) in self.urls.iter().enumerate() {
path.push_index(index);
validate::string(item.as_str(), None, Some(2000), path, out);
path.pop();
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `ChargingLimit` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChargingLimit {
/// Represents the source of the charging limit. Values defined in appendix as ChargingLimitSourceEnumStringType.
#[serde(rename = "chargingLimitSource")]
pub charging_limit_source: String,
/// *(2.1)* True when the reported limit concerns local generation that is providing extra capacity, instead of a limitation.
#[serde(rename = "isLocalGeneration")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub is_local_generation: Option<bool>,
/// Indicates whether the charging limit is critical for the grid.
#[serde(rename = "isGridCritical")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub is_grid_critical: Option<bool>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ChargingLimit {
/// Creates a `ChargingLimit` from its required fields.
#[must_use]
pub fn new(charging_limit_source: impl Into<String>) -> Self {
Self {
charging_limit_source: charging_limit_source.into(),
is_local_generation: None,
is_grid_critical: None,
custom_data: None,
}
}
/// Sets the optional `isLocalGeneration` field.
#[must_use]
pub fn with_is_local_generation(mut self, value: bool) -> Self {
self.is_local_generation = Some(value);
self
}
/// Sets the optional `isGridCritical` field.
#[must_use]
pub fn with_is_grid_critical(mut self, value: bool) -> Self {
self.is_grid_critical = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ChargingLimit {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("chargingLimitSource");
validate::string(
self.charging_limit_source.as_str(),
None,
Some(20),
path,
out,
);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `ChargingNeeds` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChargingNeeds {
/// The `requestedEnergyTransfer` member.
#[serde(rename = "requestedEnergyTransfer")]
pub requested_energy_transfer: EnergyTransferMode,
/// The `acChargingParameters` member.
#[serde(rename = "acChargingParameters")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ac_charging_parameters: Option<ACChargingParameters>,
/// The `derChargingParameters` member.
#[serde(rename = "derChargingParameters")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub der_charging_parameters: Option<DERChargingParameters>,
/// The `evEnergyOffer` member.
#[serde(rename = "evEnergyOffer")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_energy_offer: Option<EVEnergyOffer>,
/// The `dcChargingParameters` member.
#[serde(rename = "dcChargingParameters")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub dc_charging_parameters: Option<DCChargingParameters>,
/// The `v2xChargingParameters` member.
#[serde(rename = "v2xChargingParameters")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub v2x_charging_parameters: Option<V2XChargingParameters>,
/// *(2.1)* Modes of energy transfer that are marked as available by EV.
#[serde(rename = "availableEnergyTransfer")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub available_energy_transfer: Option<Vec<EnergyTransferMode>>,
/// The `controlMode` member.
#[serde(rename = "controlMode")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub control_mode: Option<ControlMode>,
/// The `mobilityNeedsMode` member.
#[serde(rename = "mobilityNeedsMode")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mobility_needs_mode: Option<MobilityNeedsMode>,
/// Estimated departure time of the EV. +
/// *ISO 15118-2:* AC/DC_EVChargeParameterType: DepartureTime +
/// *ISO 15118-20:* Dynamic/Scheduled_SEReqControlModeType: DepartureTIme
#[serde(rename = "departureTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub departure_time: Option<crate::types::DateTime>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ChargingNeeds {
/// Creates a `ChargingNeeds` from its required fields.
#[must_use]
pub fn new(requested_energy_transfer: EnergyTransferMode) -> Self {
Self {
requested_energy_transfer,
ac_charging_parameters: None,
der_charging_parameters: None,
ev_energy_offer: None,
dc_charging_parameters: None,
v2x_charging_parameters: None,
available_energy_transfer: None,
control_mode: None,
mobility_needs_mode: None,
departure_time: None,
custom_data: None,
}
}
/// Sets the optional `acChargingParameters` field.
#[must_use]
pub fn with_ac_charging_parameters(mut self, value: ACChargingParameters) -> Self {
self.ac_charging_parameters = Some(value);
self
}
/// Sets the optional `derChargingParameters` field.
#[must_use]
pub fn with_der_charging_parameters(mut self, value: DERChargingParameters) -> Self {
self.der_charging_parameters = Some(value);
self
}
/// Sets the optional `evEnergyOffer` field.
#[must_use]
pub fn with_ev_energy_offer(mut self, value: EVEnergyOffer) -> Self {
self.ev_energy_offer = Some(value);
self
}
/// Sets the optional `dcChargingParameters` field.
#[must_use]
pub fn with_dc_charging_parameters(mut self, value: DCChargingParameters) -> Self {
self.dc_charging_parameters = Some(value);
self
}
/// Sets the optional `v2xChargingParameters` field.
#[must_use]
pub fn with_v2x_charging_parameters(mut self, value: V2XChargingParameters) -> Self {
self.v2x_charging_parameters = Some(value);
self
}
/// Sets the optional `availableEnergyTransfer` field.
#[must_use]
pub fn with_available_energy_transfer(mut self, value: Vec<EnergyTransferMode>) -> Self {
self.available_energy_transfer = Some(value);
self
}
/// Sets the optional `controlMode` field.
#[must_use]
pub fn with_control_mode(mut self, value: ControlMode) -> Self {
self.control_mode = Some(value);
self
}
/// Sets the optional `mobilityNeedsMode` field.
#[must_use]
pub fn with_mobility_needs_mode(mut self, value: MobilityNeedsMode) -> Self {
self.mobility_needs_mode = Some(value);
self
}
/// Sets the optional `departureTime` field.
#[must_use]
pub fn with_departure_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.departure_time = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ChargingNeeds {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("requestedEnergyTransfer");
Validate::validate_at(&self.requested_energy_transfer, path, out);
path.pop();
path.push_key("acChargingParameters");
if let Some(value) = &self.ac_charging_parameters {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("derChargingParameters");
if let Some(value) = &self.der_charging_parameters {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("evEnergyOffer");
if let Some(value) = &self.ev_energy_offer {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("dcChargingParameters");
if let Some(value) = &self.dc_charging_parameters {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("v2xChargingParameters");
if let Some(value) = &self.v2x_charging_parameters {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("availableEnergyTransfer");
if let Some(value) = &self.available_energy_transfer {
validate::list_len(value.len(), Some(1), None, path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("controlMode");
if let Some(value) = &self.control_mode {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("mobilityNeedsMode");
if let Some(value) = &self.mobility_needs_mode {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// A ChargingPeriodType consists of a start time, and a list of possible values that influence this period, for example: amount of energy charged this period, maximum current during this period etc.
///
/// The OCPP 2.1 `ChargingPeriod` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChargingPeriod {
/// Start timestamp of charging period. A period ends when the next period starts. The last period ends when the session ends.
#[serde(rename = "startPeriod")]
pub start_period: crate::types::DateTime,
/// The `dimensions` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub dimensions: Option<Vec<CostDimension>>,
/// Unique identifier of the Tariff that was used to calculate cost. If not provided, then cost was calculated by some other means.
#[serde(rename = "tariffId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tariff_id: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ChargingPeriod {
/// Creates a `ChargingPeriod` from its required fields.
#[must_use]
pub fn new(start_period: impl Into<crate::types::DateTime>) -> Self {
Self {
start_period: start_period.into(),
dimensions: None,
tariff_id: None,
custom_data: None,
}
}
/// Sets the optional `dimensions` field.
#[must_use]
pub fn with_dimensions(mut self, value: Vec<CostDimension>) -> Self {
self.dimensions = Some(value);
self
}
/// Sets the optional `tariffId` field.
#[must_use]
pub fn with_tariff_id(mut self, value: impl Into<String>) -> Self {
self.tariff_id = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ChargingPeriod {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("dimensions");
if let Some(value) = &self.dimensions {
validate::list_len(value.len(), Some(1), None, path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("tariffId");
if let Some(value) = &self.tariff_id {
validate::string(value.as_str(), None, Some(60), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// A ChargingProfile consists of 1 to 3 ChargingSchedules with a list of ChargingSchedulePeriods, describing the amount of power or current that can be delivered per time interval.
///
/// image::images/ChargingProfile-Simple.png\[\]
///
/// The OCPP 2.1 `ChargingProfile` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChargingProfile {
/// Id of ChargingProfile. Unique within charging station. Id can have a negative value. This is useful to distinguish charging profiles from an external actor (external constraints) from charging profiles received from CSMS.
#[serde(deserialize_with = "crate::types::integer::one")]
pub id: i32,
/// Value determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0.
#[serde(rename = "stackLevel")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub stack_level: i32,
/// The `chargingProfilePurpose` member.
#[serde(rename = "chargingProfilePurpose")]
pub charging_profile_purpose: ChargingProfilePurpose,
/// The `chargingProfileKind` member.
#[serde(rename = "chargingProfileKind")]
pub charging_profile_kind: ChargingProfileKind,
/// The `chargingSchedule` member.
#[serde(rename = "chargingSchedule")]
pub charging_schedule: Vec<ChargingSchedule>,
/// The `recurrencyKind` member.
#[serde(rename = "recurrencyKind")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub recurrency_kind: Option<RecurrencyKind>,
/// Point in time at which the profile starts to be valid. If absent, the profile is valid as soon as it is received by the Charging Station.
#[serde(rename = "validFrom")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub valid_from: Option<crate::types::DateTime>,
/// Point in time at which the profile stops to be valid. If absent, the profile is valid until it is replaced by another profile.
#[serde(rename = "validTo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub valid_to: Option<crate::types::DateTime>,
/// SHALL only be included if ChargingProfilePurpose is set to TxProfile in a SetChargingProfileRequest. The transactionId is used to match the profile to a specific transaction.
#[serde(rename = "transactionId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub transaction_id: Option<String>,
/// *(2.1)* Period in seconds that this charging profile remains valid after the Charging Station has gone offline. After this period the charging profile becomes invalid for as long as it is offline and the Charging Station reverts back to a valid profile with a lower stack level.
/// If _invalidAfterOfflineDuration_ is true, then this charging profile will become permanently invalid.
/// A value of 0 means that the charging profile is immediately invalid while offline. When the field is absent, then no timeout applies and the charging profile remains valid when offline.
#[serde(rename = "maxOfflineDuration")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub max_offline_duration: Option<i32>,
/// *(2.1)* When set to true this charging profile will not be valid anymore after being offline for more than _maxOfflineDuration_. +
/// When absent defaults to false.
#[serde(rename = "invalidAfterOfflineDuration")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub invalid_after_offline_duration: Option<bool>,
/// *(2.1)* Interval in seconds after receipt of last update, when to request a profile update by sending a PullDynamicScheduleUpdateRequest message.
/// A value of 0 or no value means that no update interval applies. +
/// Only relevant in a dynamic charging profile.
#[serde(rename = "dynUpdateInterval")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub dyn_update_interval: Option<i32>,
/// *(2.1)* Time at which limits or setpoints in this charging profile were last updated by a PullDynamicScheduleUpdateRequest or UpdateDynamicScheduleRequest or by an external actor. +
/// Only relevant in a dynamic charging profile.
#[serde(rename = "dynUpdateTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub dyn_update_time: Option<crate::types::DateTime>,
/// *(2.1)* ISO 15118-20 signature for all price schedules in _chargingSchedules_. +
/// Note: for 256-bit elliptic curves (like secp256k1) the ECDSA signature is 512 bits (64 bytes) and for 521-bit curves (like secp521r1) the signature is 1042 bits. This equals 131 bytes, which can be encoded as base64 in 176 bytes.
#[serde(rename = "priceScheduleSignature")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub price_schedule_signature: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ChargingProfile {
/// Creates a `ChargingProfile` from its required fields.
#[must_use]
pub fn new(
id: i32,
stack_level: i32,
charging_profile_purpose: ChargingProfilePurpose,
charging_profile_kind: ChargingProfileKind,
charging_schedule: Vec<ChargingSchedule>,
) -> Self {
Self {
id,
stack_level,
charging_profile_purpose,
charging_profile_kind,
charging_schedule,
recurrency_kind: None,
valid_from: None,
valid_to: None,
transaction_id: None,
max_offline_duration: None,
invalid_after_offline_duration: None,
dyn_update_interval: None,
dyn_update_time: None,
price_schedule_signature: None,
custom_data: None,
}
}
/// Sets the optional `recurrencyKind` field.
#[must_use]
pub fn with_recurrency_kind(mut self, value: RecurrencyKind) -> Self {
self.recurrency_kind = Some(value);
self
}
/// Sets the optional `validFrom` field.
#[must_use]
pub fn with_valid_from(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.valid_from = Some(value.into());
self
}
/// Sets the optional `validTo` field.
#[must_use]
pub fn with_valid_to(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.valid_to = Some(value.into());
self
}
/// Sets the optional `transactionId` field.
#[must_use]
pub fn with_transaction_id(mut self, value: impl Into<String>) -> Self {
self.transaction_id = Some(value.into());
self
}
/// Sets the optional `maxOfflineDuration` field.
#[must_use]
pub fn with_max_offline_duration(mut self, value: i32) -> Self {
self.max_offline_duration = Some(value);
self
}
/// Sets the optional `invalidAfterOfflineDuration` field.
#[must_use]
pub fn with_invalid_after_offline_duration(mut self, value: bool) -> Self {
self.invalid_after_offline_duration = Some(value);
self
}
/// Sets the optional `dynUpdateInterval` field.
#[must_use]
pub fn with_dyn_update_interval(mut self, value: i32) -> Self {
self.dyn_update_interval = Some(value);
self
}
/// Sets the optional `dynUpdateTime` field.
#[must_use]
pub fn with_dyn_update_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.dyn_update_time = Some(value.into());
self
}
/// Sets the optional `priceScheduleSignature` field.
#[must_use]
pub fn with_price_schedule_signature(mut self, value: impl Into<String>) -> Self {
self.price_schedule_signature = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ChargingProfile {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("stackLevel");
validate::int_range(i64::from(self.stack_level), Some(0), None, path, out);
path.pop();
path.push_key("chargingProfilePurpose");
Validate::validate_at(&self.charging_profile_purpose, path, out);
path.pop();
path.push_key("chargingProfileKind");
Validate::validate_at(&self.charging_profile_kind, path, out);
path.pop();
path.push_key("chargingSchedule");
validate::list_len(self.charging_schedule.len(), Some(1), Some(3), path, out);
for (index, item) in self.charging_schedule.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("recurrencyKind");
if let Some(value) = &self.recurrency_kind {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("transactionId");
if let Some(value) = &self.transaction_id {
validate::string(value.as_str(), None, Some(36), path, out);
}
path.pop();
path.push_key("priceScheduleSignature");
if let Some(value) = &self.price_schedule_signature {
validate::string(value.as_str(), None, Some(256), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// A ChargingProfileCriterionType is a filter for charging profiles to be selected by a GetChargingProfilesRequest.
///
/// The OCPP 2.1 `ChargingProfileCriterion` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ChargingProfileCriterion {
/// The `chargingProfilePurpose` member.
#[serde(rename = "chargingProfilePurpose")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub charging_profile_purpose: Option<ChargingProfilePurpose>,
/// Value determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0.
#[serde(rename = "stackLevel")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub stack_level: Option<i32>,
/// List of all the chargingProfileIds requested. Any ChargingProfile that matches one of these profiles will be reported. If omitted, the Charging Station SHALL not filter on chargingProfileId. This field SHALL NOT contain more ids than set in <<configkey-charging-profile-entries,ChargingProfileEntries.maxLimit>>
#[serde(rename = "chargingProfileId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option_list")]
pub charging_profile_id: Option<Vec<i32>>,
/// For which charging limit sources, charging profiles SHALL be reported. If omitted, the Charging Station SHALL not filter on chargingLimitSource. Values defined in Appendix as ChargingLimitSourceEnumStringType.
#[serde(rename = "chargingLimitSource")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub charging_limit_source: Option<Vec<String>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ChargingProfileCriterion {
/// Creates an empty `ChargingProfileCriterion`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `chargingProfilePurpose` field.
#[must_use]
pub fn with_charging_profile_purpose(mut self, value: ChargingProfilePurpose) -> Self {
self.charging_profile_purpose = Some(value);
self
}
/// Sets the optional `stackLevel` field.
#[must_use]
pub fn with_stack_level(mut self, value: i32) -> Self {
self.stack_level = Some(value);
self
}
/// Sets the optional `chargingProfileId` field.
#[must_use]
pub fn with_charging_profile_id(mut self, value: Vec<i32>) -> Self {
self.charging_profile_id = Some(value);
self
}
/// Sets the optional `chargingLimitSource` field.
#[must_use]
pub fn with_charging_limit_source(
mut self,
value: impl IntoIterator<Item = impl Into<String>>,
) -> Self {
self.charging_limit_source = Some(value.into_iter().map(Into::into).collect());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ChargingProfileCriterion {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("chargingProfilePurpose");
if let Some(value) = &self.charging_profile_purpose {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("stackLevel");
if let Some(value) = &self.stack_level {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("chargingProfileId");
if let Some(value) = &self.charging_profile_id {
validate::list_len(value.len(), Some(1), None, path, out);
}
path.pop();
path.push_key("chargingLimitSource");
if let Some(value) = &self.charging_limit_source {
validate::list_len(value.len(), Some(1), Some(4), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
validate::string(item.as_str(), None, Some(20), path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Charging schedule structure defines a list of charging periods, as used in: NotifyEVChargingScheduleRequest and ChargingProfileType. When used in a NotifyEVChargingScheduleRequest only _duration_ and _chargingSchedulePeriod_ are relevant and _chargingRateUnit_ must be 'W'. +
/// An ISO 15118-20 session may provide either an _absolutePriceSchedule_ or a _priceLevelSchedule_. An ISO 15118-2 session can only provide a_salesTariff_ element. The field _digestValue_ is used when price schedule or sales tariff are signed.
///
/// image::images/ChargingSchedule-Simple.png\[\]
///
/// The OCPP 2.1 `ChargingSchedule` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChargingSchedule {
/// The `id` member.
#[serde(deserialize_with = "crate::types::integer::one")]
pub id: i32,
/// The `chargingRateUnit` member.
#[serde(rename = "chargingRateUnit")]
pub charging_rate_unit: ChargingRateUnit,
/// The `chargingSchedulePeriod` member.
#[serde(rename = "chargingSchedulePeriod")]
pub charging_schedule_period: Vec<ChargingSchedulePeriod>,
/// The `limitAtSoC` member.
#[serde(rename = "limitAtSoC")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub limit_at_so_c: Option<LimitAtSoC>,
/// Starting point of an absolute schedule or recurring schedule.
#[serde(rename = "startSchedule")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub start_schedule: Option<crate::types::DateTime>,
/// Duration of the charging schedule in seconds. If the duration is left empty, the last period will continue indefinitely or until end of the transaction in case startSchedule is absent.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub duration: Option<i32>,
/// Minimum charging rate supported by the EV. The unit of measure is defined by the chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to optimize the power allocation for in the case a charging process is inefficient at lower charging rates.
#[serde(rename = "minChargingRate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_charging_rate: Option<crate::types::Decimal>,
/// *(2.1)* Power tolerance when following EVPowerProfile.
#[serde(rename = "powerTolerance")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub power_tolerance: Option<crate::types::Decimal>,
/// *(2.1)* Id of this element for referencing in a signature.
#[serde(rename = "signatureId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub signature_id: Option<i32>,
/// *(2.1)* Base64 encoded hash (SHA256 for ISO 15118-2, SHA512 for ISO 15118-20) of the EXI price schedule element. Used in signature.
#[serde(rename = "digestValue")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub digest_value: Option<String>,
/// *(2.1)* Defaults to false. When true, disregard time zone offset in dateTime fields of _ChargingScheduleType_ and use unqualified local time at Charging Station instead.
/// This allows the same `Absolute` or `Recurring` charging profile to be used in both summer and winter time.
#[serde(rename = "useLocalTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub use_local_time: Option<bool>,
/// *(2.1)* Defaults to 0. When _randomizedDelay_ not equals zero, then the start of each <<cmn_chargingscheduleperiodtype,ChargingSchedulePeriodType>> is delayed by a randomly chosen number of seconds between 0 and _randomizedDelay_. Only allowed for TxProfile and TxDefaultProfile.
#[serde(rename = "randomizedDelay")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub randomized_delay: Option<i32>,
/// The `salesTariff` member.
#[serde(rename = "salesTariff")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sales_tariff: Option<SalesTariff>,
/// The `absolutePriceSchedule` member.
#[serde(rename = "absolutePriceSchedule")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub absolute_price_schedule: Option<AbsolutePriceSchedule>,
/// The `priceLevelSchedule` member.
#[serde(rename = "priceLevelSchedule")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub price_level_schedule: Option<PriceLevelSchedule>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ChargingSchedule {
/// Creates a `ChargingSchedule` from its required fields.
#[must_use]
pub fn new(
id: i32,
charging_rate_unit: ChargingRateUnit,
charging_schedule_period: Vec<ChargingSchedulePeriod>,
) -> Self {
Self {
id,
charging_rate_unit,
charging_schedule_period,
limit_at_so_c: None,
start_schedule: None,
duration: None,
min_charging_rate: None,
power_tolerance: None,
signature_id: None,
digest_value: None,
use_local_time: None,
randomized_delay: None,
sales_tariff: None,
absolute_price_schedule: None,
price_level_schedule: None,
custom_data: None,
}
}
/// Sets the optional `limitAtSoC` field.
#[must_use]
pub fn with_limit_at_so_c(mut self, value: LimitAtSoC) -> Self {
self.limit_at_so_c = Some(value);
self
}
/// Sets the optional `startSchedule` field.
#[must_use]
pub fn with_start_schedule(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.start_schedule = Some(value.into());
self
}
/// Sets the optional `duration` field.
#[must_use]
pub fn with_duration(mut self, value: i32) -> Self {
self.duration = Some(value);
self
}
/// Sets the optional `minChargingRate` field.
#[must_use]
pub fn with_min_charging_rate(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_charging_rate = Some(value.into());
self
}
/// Sets the optional `powerTolerance` field.
#[must_use]
pub fn with_power_tolerance(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.power_tolerance = Some(value.into());
self
}
/// Sets the optional `signatureId` field.
#[must_use]
pub fn with_signature_id(mut self, value: i32) -> Self {
self.signature_id = Some(value);
self
}
/// Sets the optional `digestValue` field.
#[must_use]
pub fn with_digest_value(mut self, value: impl Into<String>) -> Self {
self.digest_value = Some(value.into());
self
}
/// Sets the optional `useLocalTime` field.
#[must_use]
pub fn with_use_local_time(mut self, value: bool) -> Self {
self.use_local_time = Some(value);
self
}
/// Sets the optional `randomizedDelay` field.
#[must_use]
pub fn with_randomized_delay(mut self, value: i32) -> Self {
self.randomized_delay = Some(value);
self
}
/// Sets the optional `salesTariff` field.
#[must_use]
pub fn with_sales_tariff(mut self, value: SalesTariff) -> Self {
self.sales_tariff = Some(value);
self
}
/// Sets the optional `absolutePriceSchedule` field.
#[must_use]
pub fn with_absolute_price_schedule(mut self, value: AbsolutePriceSchedule) -> Self {
self.absolute_price_schedule = Some(value);
self
}
/// Sets the optional `priceLevelSchedule` field.
#[must_use]
pub fn with_price_level_schedule(mut self, value: PriceLevelSchedule) -> Self {
self.price_level_schedule = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ChargingSchedule {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("chargingRateUnit");
Validate::validate_at(&self.charging_rate_unit, path, out);
path.pop();
path.push_key("chargingSchedulePeriod");
validate::list_len(
self.charging_schedule_period.len(),
Some(1),
Some(1024),
path,
out,
);
for (index, item) in self.charging_schedule_period.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("limitAtSoC");
if let Some(value) = &self.limit_at_so_c {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("signatureId");
if let Some(value) = &self.signature_id {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("digestValue");
if let Some(value) = &self.digest_value {
validate::string(value.as_str(), None, Some(88), path, out);
}
path.pop();
path.push_key("randomizedDelay");
if let Some(value) = &self.randomized_delay {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("salesTariff");
if let Some(value) = &self.sales_tariff {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("absolutePriceSchedule");
if let Some(value) = &self.absolute_price_schedule {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("priceLevelSchedule");
if let Some(value) = &self.price_level_schedule {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Charging schedule period structure defines a time period in a charging schedule. It is used in: CompositeScheduleType and in ChargingScheduleType. When used in a NotifyEVChargingScheduleRequest only _startPeriod_, _limit_, _limit_L2_, _limit_L3_ are relevant.
///
/// The OCPP 2.1 `ChargingSchedulePeriod` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChargingSchedulePeriod {
/// Start of the period, in seconds from the start of schedule. The value of StartPeriod also defines the stop time of the previous period.
#[serde(rename = "startPeriod")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub start_period: i32,
/// Optional only when not required by the _operationMode_, as in CentralSetpoint, ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing. +
/// Charging rate limit during the schedule period, in the applicable _chargingRateUnit_.
/// This SHOULD be a non-negative value; a negative value is only supported for backwards compatibility with older systems that use a negative value to specify a discharging limit.
/// When using _chargingRateUnit_ = `W`, this field represents the sum of the power of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub limit: Option<crate::types::Decimal>,
/// *(2.1)* Charging rate limit on phase L2 in the applicable _chargingRateUnit_.
#[serde(rename = "limit_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub limit_l2: Option<crate::types::Decimal>,
/// *(2.1)* Charging rate limit on phase L3 in the applicable _chargingRateUnit_.
#[serde(rename = "limit_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub limit_l3: Option<crate::types::Decimal>,
/// The number of phases that can be used for charging. +
/// For a DC EVSE this field should be omitted. +
/// For an AC EVSE a default value of _numberPhases_ = 3 will be assumed if the field is absent.
#[serde(rename = "numberPhases")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub number_phases: Option<i32>,
/// Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, the Charging Station / EVSE will make the selection on its own.
#[serde(rename = "phaseToUse")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub phase_to_use: Option<i32>,
/// *(2.1)* Limit in _chargingRateUnit_ that the EV is allowed to discharge with. Note, these are negative values in order to be consistent with _setpoint_, which can be positive and negative. +
/// For AC this field represents the sum of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1.
#[serde(rename = "dischargeLimit")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub discharge_limit: Option<crate::types::Decimal>,
/// *(2.1)* Limit in _chargingRateUnit_ on phase L2 that the EV is allowed to discharge with.
#[serde(rename = "dischargeLimit_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub discharge_limit_l2: Option<crate::types::Decimal>,
/// *(2.1)* Limit in _chargingRateUnit_ on phase L3 that the EV is allowed to discharge with.
#[serde(rename = "dischargeLimit_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub discharge_limit_l3: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint in _chargingRateUnit_ that the EV should follow as close as possible. Use negative values for discharging. +
/// When a limit and/or _dischargeLimit_ are given the overshoot when following _setpoint_ must remain within these values.
/// This field represents the sum of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint in _chargingRateUnit_ that the EV should follow on phase L2 as close as possible.
#[serde(rename = "setpoint_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint_l2: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint in _chargingRateUnit_ that the EV should follow on phase L3 as close as possible.
#[serde(rename = "setpoint_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint_l3: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint for reactive power (or current) in _chargingRateUnit_ that the EV should follow as closely as possible. Positive values for inductive, negative for capacitive reactive power or current. +
/// This field represents the sum of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1.
#[serde(rename = "setpointReactive")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint_reactive: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint for reactive power (or current) in _chargingRateUnit_ that the EV should follow on phase L2 as closely as possible.
#[serde(rename = "setpointReactive_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint_reactive_l2: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint for reactive power (or current) in _chargingRateUnit_ that the EV should follow on phase L3 as closely as possible.
#[serde(rename = "setpointReactive_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint_reactive_l3: Option<crate::types::Decimal>,
/// *(2.1)* If true, the EV should attempt to keep the BMS preconditioned for this time interval.
#[serde(rename = "preconditioningRequest")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub preconditioning_request: Option<bool>,
/// *(2.1)* If true, the EVSE must turn off power electronics/modules associated with this transaction. Default value when absent is false.
#[serde(rename = "evseSleep")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub evse_sleep: Option<bool>,
/// *(2.1)* Power value that, when present, is used as a baseline on top of which values from _v2xFreqWattCurve_ and _v2xSignalWattCurve_ are added.
#[serde(rename = "v2xBaseline")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub v2x_baseline: Option<crate::types::Decimal>,
/// The `operationMode` member.
#[serde(rename = "operationMode")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub operation_mode: Option<OperationMode>,
/// The `v2xFreqWattCurve` member.
#[serde(rename = "v2xFreqWattCurve")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub v2x_freq_watt_curve: Option<Vec<V2XFreqWattPoint>>,
/// The `v2xSignalWattCurve` member.
#[serde(rename = "v2xSignalWattCurve")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub v2x_signal_watt_curve: Option<Vec<V2XSignalWattPoint>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ChargingSchedulePeriod {
/// Creates a `ChargingSchedulePeriod` from its required fields.
#[must_use]
pub fn new(start_period: i32) -> Self {
Self {
start_period,
limit: None,
limit_l2: None,
limit_l3: None,
number_phases: None,
phase_to_use: None,
discharge_limit: None,
discharge_limit_l2: None,
discharge_limit_l3: None,
setpoint: None,
setpoint_l2: None,
setpoint_l3: None,
setpoint_reactive: None,
setpoint_reactive_l2: None,
setpoint_reactive_l3: None,
preconditioning_request: None,
evse_sleep: None,
v2x_baseline: None,
operation_mode: None,
v2x_freq_watt_curve: None,
v2x_signal_watt_curve: None,
custom_data: None,
}
}
/// Sets the optional `limit` field.
#[must_use]
pub fn with_limit(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.limit = Some(value.into());
self
}
/// Sets the optional `limit_L2` field.
#[must_use]
pub fn with_limit_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.limit_l2 = Some(value.into());
self
}
/// Sets the optional `limit_L3` field.
#[must_use]
pub fn with_limit_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.limit_l3 = Some(value.into());
self
}
/// Sets the optional `numberPhases` field.
#[must_use]
pub fn with_number_phases(mut self, value: i32) -> Self {
self.number_phases = Some(value);
self
}
/// Sets the optional `phaseToUse` field.
#[must_use]
pub fn with_phase_to_use(mut self, value: i32) -> Self {
self.phase_to_use = Some(value);
self
}
/// Sets the optional `dischargeLimit` field.
#[must_use]
pub fn with_discharge_limit(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.discharge_limit = Some(value.into());
self
}
/// Sets the optional `dischargeLimit_L2` field.
#[must_use]
pub fn with_discharge_limit_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.discharge_limit_l2 = Some(value.into());
self
}
/// Sets the optional `dischargeLimit_L3` field.
#[must_use]
pub fn with_discharge_limit_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.discharge_limit_l3 = Some(value.into());
self
}
/// Sets the optional `setpoint` field.
#[must_use]
pub fn with_setpoint(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint = Some(value.into());
self
}
/// Sets the optional `setpoint_L2` field.
#[must_use]
pub fn with_setpoint_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint_l2 = Some(value.into());
self
}
/// Sets the optional `setpoint_L3` field.
#[must_use]
pub fn with_setpoint_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint_l3 = Some(value.into());
self
}
/// Sets the optional `setpointReactive` field.
#[must_use]
pub fn with_setpoint_reactive(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint_reactive = Some(value.into());
self
}
/// Sets the optional `setpointReactive_L2` field.
#[must_use]
pub fn with_setpoint_reactive_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint_reactive_l2 = Some(value.into());
self
}
/// Sets the optional `setpointReactive_L3` field.
#[must_use]
pub fn with_setpoint_reactive_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint_reactive_l3 = Some(value.into());
self
}
/// Sets the optional `preconditioningRequest` field.
#[must_use]
pub fn with_preconditioning_request(mut self, value: bool) -> Self {
self.preconditioning_request = Some(value);
self
}
/// Sets the optional `evseSleep` field.
#[must_use]
pub fn with_evse_sleep(mut self, value: bool) -> Self {
self.evse_sleep = Some(value);
self
}
/// Sets the optional `v2xBaseline` field.
#[must_use]
pub fn with_v2x_baseline(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.v2x_baseline = Some(value.into());
self
}
/// Sets the optional `operationMode` field.
#[must_use]
pub fn with_operation_mode(mut self, value: OperationMode) -> Self {
self.operation_mode = Some(value);
self
}
/// Sets the optional `v2xFreqWattCurve` field.
#[must_use]
pub fn with_v2x_freq_watt_curve(mut self, value: Vec<V2XFreqWattPoint>) -> Self {
self.v2x_freq_watt_curve = Some(value);
self
}
/// Sets the optional `v2xSignalWattCurve` field.
#[must_use]
pub fn with_v2x_signal_watt_curve(mut self, value: Vec<V2XSignalWattPoint>) -> Self {
self.v2x_signal_watt_curve = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ChargingSchedulePeriod {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("numberPhases");
if let Some(value) = &self.number_phases {
validate::int_range(i64::from(*value), Some(0), Some(3), path, out);
}
path.pop();
path.push_key("phaseToUse");
if let Some(value) = &self.phase_to_use {
validate::int_range(i64::from(*value), Some(0), Some(3), path, out);
}
path.pop();
path.push_key("dischargeLimit");
if let Some(value) = &self.discharge_limit {
validate::range(
*value,
None,
Some(crate::types::Decimal::new(0, 0)),
path,
out,
);
}
path.pop();
path.push_key("dischargeLimit_L2");
if let Some(value) = &self.discharge_limit_l2 {
validate::range(
*value,
None,
Some(crate::types::Decimal::new(0, 0)),
path,
out,
);
}
path.pop();
path.push_key("dischargeLimit_L3");
if let Some(value) = &self.discharge_limit_l3 {
validate::range(
*value,
None,
Some(crate::types::Decimal::new(0, 0)),
path,
out,
);
}
path.pop();
path.push_key("operationMode");
if let Some(value) = &self.operation_mode {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("v2xFreqWattCurve");
if let Some(value) = &self.v2x_freq_watt_curve {
validate::list_len(value.len(), Some(1), Some(20), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("v2xSignalWattCurve");
if let Some(value) = &self.v2x_signal_watt_curve {
validate::list_len(value.len(), Some(1), Some(20), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Updates to a ChargingSchedulePeriodType for dynamic charging profiles.
///
/// The OCPP 2.1 `ChargingScheduleUpdate` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ChargingScheduleUpdate {
/// Optional only when not required by the _operationMode_, as in CentralSetpoint, ExternalSetpoint, ExternalLimits, LocalFrequency, LocalLoadBalancing. +
/// Charging rate limit during the schedule period, in the applicable _chargingRateUnit_.
/// This SHOULD be a non-negative value; a negative value is only supported for backwards compatibility with older systems that use a negative value to specify a discharging limit.
/// For AC this field represents the sum of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub limit: Option<crate::types::Decimal>,
/// *(2.1)* Charging rate limit on phase L2 in the applicable _chargingRateUnit_.
#[serde(rename = "limit_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub limit_l2: Option<crate::types::Decimal>,
/// *(2.1)* Charging rate limit on phase L3 in the applicable _chargingRateUnit_.
#[serde(rename = "limit_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub limit_l3: Option<crate::types::Decimal>,
/// *(2.1)* Limit in _chargingRateUnit_ that the EV is allowed to discharge with. Note, these are negative values in order to be consistent with _setpoint_, which can be positive and negative. +
/// For AC this field represents the sum of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1.
#[serde(rename = "dischargeLimit")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub discharge_limit: Option<crate::types::Decimal>,
/// *(2.1)* Limit in _chargingRateUnit_ on phase L2 that the EV is allowed to discharge with.
#[serde(rename = "dischargeLimit_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub discharge_limit_l2: Option<crate::types::Decimal>,
/// *(2.1)* Limit in _chargingRateUnit_ on phase L3 that the EV is allowed to discharge with.
#[serde(rename = "dischargeLimit_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub discharge_limit_l3: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint in _chargingRateUnit_ that the EV should follow as close as possible. Use negative values for discharging. +
/// When a limit and/or _dischargeLimit_ are given the overshoot when following _setpoint_ must remain within these values.
/// This field represents the sum of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint in _chargingRateUnit_ that the EV should follow on phase L2 as close as possible.
#[serde(rename = "setpoint_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint_l2: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint in _chargingRateUnit_ that the EV should follow on phase L3 as close as possible.
#[serde(rename = "setpoint_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint_l3: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint for reactive power (or current) in _chargingRateUnit_ that the EV should follow as closely as possible. Positive values for inductive, negative for capacitive reactive power or current. +
/// This field represents the sum of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1.
#[serde(rename = "setpointReactive")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint_reactive: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint for reactive power (or current) in _chargingRateUnit_ that the EV should follow on phase L2 as closely as possible.
#[serde(rename = "setpointReactive_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint_reactive_l2: Option<crate::types::Decimal>,
/// *(2.1)* Setpoint for reactive power (or current) in _chargingRateUnit_ that the EV should follow on phase L3 as closely as possible.
#[serde(rename = "setpointReactive_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setpoint_reactive_l3: Option<crate::types::Decimal>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ChargingScheduleUpdate {
/// Creates an empty `ChargingScheduleUpdate`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `limit` field.
#[must_use]
pub fn with_limit(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.limit = Some(value.into());
self
}
/// Sets the optional `limit_L2` field.
#[must_use]
pub fn with_limit_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.limit_l2 = Some(value.into());
self
}
/// Sets the optional `limit_L3` field.
#[must_use]
pub fn with_limit_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.limit_l3 = Some(value.into());
self
}
/// Sets the optional `dischargeLimit` field.
#[must_use]
pub fn with_discharge_limit(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.discharge_limit = Some(value.into());
self
}
/// Sets the optional `dischargeLimit_L2` field.
#[must_use]
pub fn with_discharge_limit_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.discharge_limit_l2 = Some(value.into());
self
}
/// Sets the optional `dischargeLimit_L3` field.
#[must_use]
pub fn with_discharge_limit_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.discharge_limit_l3 = Some(value.into());
self
}
/// Sets the optional `setpoint` field.
#[must_use]
pub fn with_setpoint(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint = Some(value.into());
self
}
/// Sets the optional `setpoint_L2` field.
#[must_use]
pub fn with_setpoint_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint_l2 = Some(value.into());
self
}
/// Sets the optional `setpoint_L3` field.
#[must_use]
pub fn with_setpoint_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint_l3 = Some(value.into());
self
}
/// Sets the optional `setpointReactive` field.
#[must_use]
pub fn with_setpoint_reactive(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint_reactive = Some(value.into());
self
}
/// Sets the optional `setpointReactive_L2` field.
#[must_use]
pub fn with_setpoint_reactive_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint_reactive_l2 = Some(value.into());
self
}
/// Sets the optional `setpointReactive_L3` field.
#[must_use]
pub fn with_setpoint_reactive_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.setpoint_reactive_l3 = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ChargingScheduleUpdate {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("dischargeLimit");
if let Some(value) = &self.discharge_limit {
validate::range(
*value,
None,
Some(crate::types::Decimal::new(0, 0)),
path,
out,
);
}
path.pop();
path.push_key("dischargeLimit_L2");
if let Some(value) = &self.discharge_limit_l2 {
validate::range(
*value,
None,
Some(crate::types::Decimal::new(0, 0)),
path,
out,
);
}
path.pop();
path.push_key("dischargeLimit_L3");
if let Some(value) = &self.discharge_limit_l3 {
validate::range(
*value,
None,
Some(crate::types::Decimal::new(0, 0)),
path,
out,
);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The physical system where an Electrical Vehicle (EV) can be charged.
///
/// The OCPP 2.1 `ChargingStation` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChargingStation {
/// Defines the model of the device.
pub model: String,
/// Identifies the vendor (not necessarily in a unique manner).
#[serde(rename = "vendorName")]
pub vendor_name: String,
/// Vendor-specific device identifier.
#[serde(rename = "serialNumber")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub serial_number: Option<String>,
/// The `modem` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub modem: Option<Modem>,
/// This contains the firmware version of the Charging Station.
#[serde(rename = "firmwareVersion")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub firmware_version: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ChargingStation {
/// Creates a `ChargingStation` from its required fields.
#[must_use]
pub fn new(model: impl Into<String>, vendor_name: impl Into<String>) -> Self {
Self {
model: model.into(),
vendor_name: vendor_name.into(),
serial_number: None,
modem: None,
firmware_version: None,
custom_data: None,
}
}
/// Sets the optional `serialNumber` field.
#[must_use]
pub fn with_serial_number(mut self, value: impl Into<String>) -> Self {
self.serial_number = Some(value.into());
self
}
/// Sets the optional `modem` field.
#[must_use]
pub fn with_modem(mut self, value: Modem) -> Self {
self.modem = Some(value);
self
}
/// Sets the optional `firmwareVersion` field.
#[must_use]
pub fn with_firmware_version(mut self, value: impl Into<String>) -> Self {
self.firmware_version = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ChargingStation {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("model");
validate::string(self.model.as_str(), None, Some(20), path, out);
path.pop();
path.push_key("vendorName");
validate::string(self.vendor_name.as_str(), None, Some(50), path, out);
path.pop();
path.push_key("serialNumber");
if let Some(value) = &self.serial_number {
validate::string(value.as_str(), None, Some(25), path, out);
}
path.pop();
path.push_key("modem");
if let Some(value) = &self.modem {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("firmwareVersion");
if let Some(value) = &self.firmware_version {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// A ClearChargingProfileType is a filter for charging profiles to be cleared by ClearChargingProfileRequest.
///
/// The OCPP 2.1 `ClearChargingProfile` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ClearChargingProfile {
/// Specifies the id of the EVSE for which to clear charging profiles. An evseId of zero (0) specifies the charging profile for the overall Charging Station. Absence of this parameter means the clearing applies to all charging profiles that match the other criteria in the request.
#[serde(rename = "evseId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub evse_id: Option<i32>,
/// The `chargingProfilePurpose` member.
#[serde(rename = "chargingProfilePurpose")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub charging_profile_purpose: Option<ChargingProfilePurpose>,
/// Specifies the stackLevel for which charging profiles will be cleared, if they meet the other criteria in the request.
#[serde(rename = "stackLevel")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub stack_level: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ClearChargingProfile {
/// Creates an empty `ClearChargingProfile`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `evseId` field.
#[must_use]
pub fn with_evse_id(mut self, value: i32) -> Self {
self.evse_id = Some(value);
self
}
/// Sets the optional `chargingProfilePurpose` field.
#[must_use]
pub fn with_charging_profile_purpose(mut self, value: ChargingProfilePurpose) -> Self {
self.charging_profile_purpose = Some(value);
self
}
/// Sets the optional `stackLevel` field.
#[must_use]
pub fn with_stack_level(mut self, value: i32) -> Self {
self.stack_level = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ClearChargingProfile {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("evseId");
if let Some(value) = &self.evse_id {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("chargingProfilePurpose");
if let Some(value) = &self.charging_profile_purpose {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("stackLevel");
if let Some(value) = &self.stack_level {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `ClearMonitoringResult` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ClearMonitoringResult {
/// The `status` member.
pub status: ClearMonitoringStatus,
/// Id of the monitor of which a clear was requested.
#[serde(deserialize_with = "crate::types::integer::one")]
pub id: i32,
/// The `statusInfo` member.
#[serde(rename = "statusInfo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub status_info: Option<StatusInfo>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ClearMonitoringResult {
/// Creates a `ClearMonitoringResult` from its required fields.
#[must_use]
pub fn new(status: ClearMonitoringStatus, id: i32) -> Self {
Self {
status,
id,
status_info: None,
custom_data: None,
}
}
/// Sets the optional `statusInfo` field.
#[must_use]
pub fn with_status_info(mut self, value: StatusInfo) -> Self {
self.status_info = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ClearMonitoringResult {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("status");
Validate::validate_at(&self.status, path, out);
path.pop();
path.push_key("id");
validate::int_range(i64::from(self.id), Some(0), None, path, out);
path.pop();
path.push_key("statusInfo");
if let Some(value) = &self.status_info {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `ClearTariffsResult` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ClearTariffsResult {
/// The `status` member.
pub status: TariffClearStatus,
/// The `statusInfo` member.
#[serde(rename = "statusInfo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub status_info: Option<StatusInfo>,
/// Id of tariff for which _status_ is reported. If no tariffs were found, then this field is absent, and _status_ will be `NoTariff`.
#[serde(rename = "tariffId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tariff_id: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ClearTariffsResult {
/// Creates a `ClearTariffsResult` from its required fields.
#[must_use]
pub fn new(status: TariffClearStatus) -> Self {
Self {
status,
status_info: None,
tariff_id: None,
custom_data: None,
}
}
/// Sets the optional `statusInfo` field.
#[must_use]
pub fn with_status_info(mut self, value: StatusInfo) -> Self {
self.status_info = Some(value);
self
}
/// Sets the optional `tariffId` field.
#[must_use]
pub fn with_tariff_id(mut self, value: impl Into<String>) -> Self {
self.tariff_id = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ClearTariffsResult {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("status");
Validate::validate_at(&self.status, path, out);
path.pop();
path.push_key("statusInfo");
if let Some(value) = &self.status_info {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("tariffId");
if let Some(value) = &self.tariff_id {
validate::string(value.as_str(), None, Some(60), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// A physical or logical component
///
/// The OCPP 2.1 `Component` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Component {
/// Name of the component. Name should be taken from the list of standardized component names whenever possible. Case Insensitive. strongly advised to use Camel Case.
pub name: String,
/// The `evse` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub evse: Option<EVSE>,
/// Name of instance in case the component exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub instance: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl Component {
/// Creates a `Component` from its required fields.
#[must_use]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
evse: None,
instance: None,
custom_data: None,
}
}
/// Sets the optional `evse` field.
#[must_use]
pub fn with_evse(mut self, value: EVSE) -> Self {
self.evse = Some(value);
self
}
/// Sets the optional `instance` field.
#[must_use]
pub fn with_instance(mut self, value: impl Into<String>) -> Self {
self.instance = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for Component {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("name");
validate::string(self.name.as_str(), None, Some(50), path, out);
path.pop();
path.push_key("evse");
if let Some(value) = &self.evse {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("instance");
if let Some(value) = &self.instance {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Class to report components, variables and variable attributes and characteristics.
///
/// The OCPP 2.1 `ComponentVariable` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ComponentVariable {
/// The `component` member.
pub component: Component,
/// The `variable` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub variable: Option<Variable>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ComponentVariable {
/// Creates a `ComponentVariable` from its required fields.
#[must_use]
pub fn new(component: Component) -> Self {
Self {
component,
variable: None,
custom_data: None,
}
}
/// Sets the optional `variable` field.
#[must_use]
pub fn with_variable(mut self, value: Variable) -> Self {
self.variable = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ComponentVariable {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("component");
Validate::validate_at(&self.component, path, out);
path.pop();
path.push_key("variable");
if let Some(value) = &self.variable {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `CompositeSchedule` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CompositeSchedule {
/// The `evseId` member.
#[serde(rename = "evseId")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub evse_id: i32,
/// The `duration` member.
#[serde(deserialize_with = "crate::types::integer::one")]
pub duration: i32,
/// The `scheduleStart` member.
#[serde(rename = "scheduleStart")]
pub schedule_start: crate::types::DateTime,
/// The `chargingRateUnit` member.
#[serde(rename = "chargingRateUnit")]
pub charging_rate_unit: ChargingRateUnit,
/// The `chargingSchedulePeriod` member.
#[serde(rename = "chargingSchedulePeriod")]
pub charging_schedule_period: Vec<ChargingSchedulePeriod>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl CompositeSchedule {
/// Creates a `CompositeSchedule` from its required fields.
#[must_use]
pub fn new(
evse_id: i32,
duration: i32,
schedule_start: impl Into<crate::types::DateTime>,
charging_rate_unit: ChargingRateUnit,
charging_schedule_period: Vec<ChargingSchedulePeriod>,
) -> Self {
Self {
evse_id,
duration,
schedule_start: schedule_start.into(),
charging_rate_unit,
charging_schedule_period,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for CompositeSchedule {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("evseId");
validate::int_range(i64::from(self.evse_id), Some(0), None, path, out);
path.pop();
path.push_key("chargingRateUnit");
Validate::validate_at(&self.charging_rate_unit, path, out);
path.pop();
path.push_key("chargingSchedulePeriod");
validate::list_len(
self.charging_schedule_period.len(),
Some(1),
None,
path,
out,
);
for (index, item) in self.charging_schedule_period.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `ConstantStreamData` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ConstantStreamData {
/// Uniquely identifies the stream
#[serde(deserialize_with = "crate::types::integer::one")]
pub id: i32,
/// The `params` member.
pub params: PeriodicEventStreamParams,
/// Id of monitor used to report his event. It can be a preconfigured or hardwired monitor.
#[serde(rename = "variableMonitoringId")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub variable_monitoring_id: i32,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ConstantStreamData {
/// Creates a `ConstantStreamData` from its required fields.
#[must_use]
pub fn new(id: i32, params: PeriodicEventStreamParams, variable_monitoring_id: i32) -> Self {
Self {
id,
params,
variable_monitoring_id,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ConstantStreamData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("id");
validate::int_range(i64::from(self.id), Some(0), None, path, out);
path.pop();
path.push_key("params");
Validate::validate_at(&self.params, path, out);
path.pop();
path.push_key("variableMonitoringId");
validate::int_range(
i64::from(self.variable_monitoring_id),
Some(0),
None,
path,
out,
);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `ConsumptionCost` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ConsumptionCost {
/// The lowest level of consumption that defines the starting point of this consumption block. The block interval extends to the start of the next interval.
#[serde(rename = "startValue")]
pub start_value: crate::types::Decimal,
/// The `cost` member.
pub cost: Vec<Cost>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ConsumptionCost {
/// Creates a `ConsumptionCost` from its required fields.
#[must_use]
pub fn new(start_value: impl Into<crate::types::Decimal>, cost: Vec<Cost>) -> Self {
Self {
start_value: start_value.into(),
cost,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ConsumptionCost {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("cost");
validate::list_len(self.cost.len(), Some(1), Some(3), path, out);
for (index, item) in self.cost.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `Cost` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Cost {
/// The `costKind` member.
#[serde(rename = "costKind")]
pub cost_kind: CostKind,
/// The estimated or actual cost per kWh
#[serde(deserialize_with = "crate::types::integer::one")]
pub amount: i32,
/// Values: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value is determined by: amount * 10 ^ amountMultiplier
#[serde(rename = "amountMultiplier")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub amount_multiplier: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl Cost {
/// Creates a `Cost` from its required fields.
#[must_use]
pub fn new(cost_kind: CostKind, amount: i32) -> Self {
Self {
cost_kind,
amount,
amount_multiplier: None,
custom_data: None,
}
}
/// Sets the optional `amountMultiplier` field.
#[must_use]
pub fn with_amount_multiplier(mut self, value: i32) -> Self {
self.amount_multiplier = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for Cost {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("costKind");
Validate::validate_at(&self.cost_kind, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// CostDetailsType contains the cost as calculated by Charging Station based on provided TariffType.
///
/// NOTE: Reservation is not shown as a _chargingPeriod_, because it took place outside of the transaction.
///
/// The OCPP 2.1 `CostDetails` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CostDetails {
/// The `totalCost` member.
#[serde(rename = "totalCost")]
pub total_cost: TotalCost,
/// The `totalUsage` member.
#[serde(rename = "totalUsage")]
pub total_usage: TotalUsage,
/// The `chargingPeriods` member.
#[serde(rename = "chargingPeriods")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub charging_periods: Option<Vec<ChargingPeriod>>,
/// If set to true, then Charging Station has failed to calculate the cost.
#[serde(rename = "failureToCalculate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub failure_to_calculate: Option<bool>,
/// Optional human-readable reason text in case of failure to calculate.
#[serde(rename = "failureReason")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub failure_reason: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl CostDetails {
/// Creates a `CostDetails` from its required fields.
#[must_use]
pub fn new(total_cost: TotalCost, total_usage: TotalUsage) -> Self {
Self {
total_cost,
total_usage,
charging_periods: None,
failure_to_calculate: None,
failure_reason: None,
custom_data: None,
}
}
/// Sets the optional `chargingPeriods` field.
#[must_use]
pub fn with_charging_periods(mut self, value: Vec<ChargingPeriod>) -> Self {
self.charging_periods = Some(value);
self
}
/// Sets the optional `failureToCalculate` field.
#[must_use]
pub fn with_failure_to_calculate(mut self, value: bool) -> Self {
self.failure_to_calculate = Some(value);
self
}
/// Sets the optional `failureReason` field.
#[must_use]
pub fn with_failure_reason(mut self, value: impl Into<String>) -> Self {
self.failure_reason = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for CostDetails {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("totalCost");
Validate::validate_at(&self.total_cost, path, out);
path.pop();
path.push_key("totalUsage");
Validate::validate_at(&self.total_usage, path, out);
path.pop();
path.push_key("chargingPeriods");
if let Some(value) = &self.charging_periods {
validate::list_len(value.len(), Some(1), None, path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("failureReason");
if let Some(value) = &self.failure_reason {
validate::string(value.as_str(), None, Some(500), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Volume consumed of cost dimension.
///
/// The OCPP 2.1 `CostDimension` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CostDimension {
/// The `type` member.
pub r#type: CostDimensionEnum,
/// Volume of the dimension consumed, measured according to the dimension type.
pub volume: crate::types::Decimal,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl CostDimension {
/// Creates a `CostDimension` from its required fields.
#[must_use]
pub fn new(r#type: CostDimensionEnum, volume: impl Into<crate::types::Decimal>) -> Self {
Self {
r#type,
volume: volume.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for CostDimension {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("type");
Validate::validate_at(&self.r#type, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// EV DC charging parameters for ISO 15118-2
///
/// The OCPP 2.1 `DCChargingParameters` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct DCChargingParameters {
/// Maximum current (in A) supported by the electric vehicle. Includes cable capacity.
/// Relates to: +
/// *ISO 15118-2*: DC_EVChargeParameterType:EVMaximumCurrentLimit
#[serde(rename = "evMaxCurrent")]
pub ev_max_current: crate::types::Decimal,
/// Maximum voltage supported by the electric vehicle.
/// Relates to: +
/// *ISO 15118-2*: DC_EVChargeParameterType: EVMaximumVoltageLimit
#[serde(rename = "evMaxVoltage")]
pub ev_max_voltage: crate::types::Decimal,
/// Maximum power (in W) supported by the electric vehicle. Required for DC charging.
/// Relates to: +
/// *ISO 15118-2*: DC_EVChargeParameterType: EVMaximumPowerLimit
#[serde(rename = "evMaxPower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_max_power: Option<crate::types::Decimal>,
/// Capacity of the electric vehicle battery (in Wh).
/// Relates to: +
/// *ISO 15118-2*: DC_EVChargeParameterType: EVEnergyCapacity
#[serde(rename = "evEnergyCapacity")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_energy_capacity: Option<crate::types::Decimal>,
/// Amount of energy requested (in Wh). This inludes energy required for preconditioning.
/// Relates to: +
/// *ISO 15118-2*: DC_EVChargeParameterType: EVEnergyRequest
#[serde(rename = "energyAmount")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub energy_amount: Option<crate::types::Decimal>,
/// Energy available in the battery (in percent of the battery capacity)
/// Relates to: +
/// *ISO 15118-2*: DC_EVChargeParameterType: DC_EVStatus: EVRESSSOC
#[serde(rename = "stateOfCharge")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub state_of_charge: Option<i32>,
/// Percentage of SoC at which the EV considers the battery fully charged. (possible values: 0 - 100)
/// Relates to: +
/// *ISO 15118-2*: DC_EVChargeParameterType: FullSOC
#[serde(rename = "fullSoC")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub full_so_c: Option<i32>,
/// Percentage of SoC at which the EV considers a fast charging process to end. (possible values: 0 - 100)
/// Relates to: +
/// *ISO 15118-2*: DC_EVChargeParameterType: BulkSOC
#[serde(rename = "bulkSoC")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub bulk_so_c: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl DCChargingParameters {
/// Creates a `DCChargingParameters` from its required fields.
#[must_use]
pub fn new(
ev_max_current: impl Into<crate::types::Decimal>,
ev_max_voltage: impl Into<crate::types::Decimal>,
) -> Self {
Self {
ev_max_current: ev_max_current.into(),
ev_max_voltage: ev_max_voltage.into(),
ev_max_power: None,
ev_energy_capacity: None,
energy_amount: None,
state_of_charge: None,
full_so_c: None,
bulk_so_c: None,
custom_data: None,
}
}
/// Sets the optional `evMaxPower` field.
#[must_use]
pub fn with_ev_max_power(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.ev_max_power = Some(value.into());
self
}
/// Sets the optional `evEnergyCapacity` field.
#[must_use]
pub fn with_ev_energy_capacity(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.ev_energy_capacity = Some(value.into());
self
}
/// Sets the optional `energyAmount` field.
#[must_use]
pub fn with_energy_amount(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.energy_amount = Some(value.into());
self
}
/// Sets the optional `stateOfCharge` field.
#[must_use]
pub fn with_state_of_charge(mut self, value: i32) -> Self {
self.state_of_charge = Some(value);
self
}
/// Sets the optional `fullSoC` field.
#[must_use]
pub fn with_full_so_c(mut self, value: i32) -> Self {
self.full_so_c = Some(value);
self
}
/// Sets the optional `bulkSoC` field.
#[must_use]
pub fn with_bulk_so_c(mut self, value: i32) -> Self {
self.bulk_so_c = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for DCChargingParameters {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("stateOfCharge");
if let Some(value) = &self.state_of_charge {
validate::int_range(i64::from(*value), Some(0), Some(100), path, out);
}
path.pop();
path.push_key("fullSoC");
if let Some(value) = &self.full_so_c {
validate::int_range(i64::from(*value), Some(0), Some(100), path, out);
}
path.pop();
path.push_key("bulkSoC");
if let Some(value) = &self.bulk_so_c {
validate::int_range(i64::from(*value), Some(0), Some(100), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// *(2.1)* DERChargingParametersType is used in ChargingNeedsType during an ISO 15118-20 session for AC_BPT_DER to report the inverter settings related to DER control that were agreed between EVSE and EV.
///
/// Fields starting with "ev" contain values from the EV.
/// Other fields contain a value that is supported by both EV and EVSE.
///
/// DERChargingParametersType type is only relevant in case of an ISO 15118-20 AC_BPT_DER/AC_DER charging session.
///
/// NOTE: All these fields have values greater or equal to zero (i.e. are non-negative)
///
/// The OCPP 2.1 `DERChargingParameters` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DERChargingParameters {
/// DER control functions supported by EV. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType:DERControlFunctions (bitmap)
#[serde(rename = "evSupportedDERControl")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_supported_der_control: Option<Vec<DERControl>>,
/// Rated maximum injected active power by EV, at specified over-excited power factor (overExcitedPowerFactor). +
/// It can also be defined as the rated maximum discharge power at the rated minimum injected reactive power value. This means that if the EV is providing reactive power support, and it is requested to discharge at max power (e.g. to satisfy an EMS request), the EV may override the request and discharge up to overExcitedMaximumDischargePower to meet the minimum reactive power requirements. +
/// Corresponds to the WOvPF attribute in IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVOverExcitedMaximumDischargePower
#[serde(rename = "evOverExcitedMaxDischargePower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_over_excited_max_discharge_power: Option<crate::types::Decimal>,
/// EV power factor when injecting (over excited) the minimum reactive power. +
/// Corresponds to the OvPF attribute in IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVOverExcitedPowerFactor
#[serde(rename = "evOverExcitedPowerFactor")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_over_excited_power_factor: Option<crate::types::Decimal>,
/// Rated maximum injected active power by EV supported at specified under-excited power factor (EVUnderExcitedPowerFactor). +
/// It can also be defined as the rated maximum dischargePower at the rated minimum absorbed reactive power value.
/// This means that if the EV is providing reactive power support, and it is requested to discharge at max power (e.g. to satisfy an EMS request), the EV may override the request and discharge up to underExcitedMaximumDischargePower to meet the minimum reactive power requirements. +
/// This corresponds to the WUnPF attribute in the IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVUnderExcitedMaximumDischargePower
#[serde(rename = "evUnderExcitedMaxDischargePower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_under_excited_max_discharge_power: Option<crate::types::Decimal>,
/// EV power factor when injecting (under excited) the minimum reactive power. +
/// Corresponds to the OvPF attribute in IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVUnderExcitedPowerFactor
#[serde(rename = "evUnderExcitedPowerFactor")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_under_excited_power_factor: Option<crate::types::Decimal>,
/// Rated maximum total apparent power, defined by min(EV, EVSE) in va.
/// Corresponds to the VAMaxRtg in IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumApparentPower
#[serde(rename = "maxApparentPower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_apparent_power: Option<crate::types::Decimal>,
/// Rated maximum absorbed apparent power, defined by min(EV, EVSE) in va. +
/// This field represents the sum of all phases, unless values are provided for L2 and L3,
/// in which case this field represents phase L1. +
/// Corresponds to the ChaVAMaxRtg in IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumChargeApparentPower
#[serde(rename = "maxChargeApparentPower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_charge_apparent_power: Option<crate::types::Decimal>,
/// Rated maximum absorbed apparent power on phase L2, defined by min(EV, EVSE) in va.
/// Corresponds to the ChaVAMaxRtg in IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumChargeApparentPower_L2
#[serde(rename = "maxChargeApparentPower_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_charge_apparent_power_l2: Option<crate::types::Decimal>,
/// Rated maximum absorbed apparent power on phase L3, defined by min(EV, EVSE) in va.
/// Corresponds to the ChaVAMaxRtg in IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumChargeApparentPower_L3
#[serde(rename = "maxChargeApparentPower_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_charge_apparent_power_l3: Option<crate::types::Decimal>,
/// Rated maximum injected apparent power, defined by min(EV, EVSE) in va. +
/// This field represents the sum of all phases, unless values are provided for L2 and L3,
/// in which case this field represents phase L1. +
/// Corresponds to the DisVAMaxRtg in IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumDischargeApparentPower
#[serde(rename = "maxDischargeApparentPower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_discharge_apparent_power: Option<crate::types::Decimal>,
/// Rated maximum injected apparent power on phase L2, defined by min(EV, EVSE) in va. +
/// Corresponds to the DisVAMaxRtg in IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumDischargeApparentPower_L2
#[serde(rename = "maxDischargeApparentPower_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_discharge_apparent_power_l2: Option<crate::types::Decimal>,
/// Rated maximum injected apparent power on phase L3, defined by min(EV, EVSE) in va. +
/// Corresponds to the DisVAMaxRtg in IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumDischargeApparentPower_L3
#[serde(rename = "maxDischargeApparentPower_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_discharge_apparent_power_l3: Option<crate::types::Decimal>,
/// Rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars. +
/// This field represents the sum of all phases, unless values are provided for L2 and L3,
/// in which case this field represents phase L1. +
/// Corresponds to the AvarMax attribute in the IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumChargeReactivePower
#[serde(rename = "maxChargeReactivePower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_charge_reactive_power: Option<crate::types::Decimal>,
/// Rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L2. +
/// Corresponds to the AvarMax attribute in the IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumChargeReactivePower_L2
#[serde(rename = "maxChargeReactivePower_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_charge_reactive_power_l2: Option<crate::types::Decimal>,
/// Rated maximum absorbed reactive power, defined by min(EV, EVSE), in vars on phase L3. +
/// Corresponds to the AvarMax attribute in the IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumChargeReactivePower_L3
#[serde(rename = "maxChargeReactivePower_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_charge_reactive_power_l3: Option<crate::types::Decimal>,
/// Rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars. +
/// This field represents the sum of all phases, unless values are provided for L2 and L3,
/// in which case this field represents phase L1. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMinimumChargeReactivePower
#[serde(rename = "minChargeReactivePower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_charge_reactive_power: Option<crate::types::Decimal>,
/// Rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L2. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMinimumChargeReactivePower_L2
#[serde(rename = "minChargeReactivePower_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_charge_reactive_power_l2: Option<crate::types::Decimal>,
/// Rated minimum absorbed reactive power, defined by max(EV, EVSE), in vars on phase L3. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMinimumChargeReactivePower_L3
#[serde(rename = "minChargeReactivePower_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_charge_reactive_power_l3: Option<crate::types::Decimal>,
/// Rated maximum injected reactive power, defined by min(EV, EVSE), in vars. +
/// This field represents the sum of all phases, unless values are provided for L2 and L3,
/// in which case this field represents phase L1. +
/// Corresponds to the IvarMax attribute in the IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumDischargeReactivePower
#[serde(rename = "maxDischargeReactivePower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_discharge_reactive_power: Option<crate::types::Decimal>,
/// Rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L2. +
/// Corresponds to the IvarMax attribute in the IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumDischargeReactivePower_L2
#[serde(rename = "maxDischargeReactivePower_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_discharge_reactive_power_l2: Option<crate::types::Decimal>,
/// Rated maximum injected reactive power, defined by min(EV, EVSE), in vars on phase L3. +
/// Corresponds to the IvarMax attribute in the IEC 61850. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumDischargeReactivePower_L3
#[serde(rename = "maxDischargeReactivePower_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_discharge_reactive_power_l3: Option<crate::types::Decimal>,
/// Rated minimum injected reactive power, defined by max(EV, EVSE), in vars. +
/// This field represents the sum of all phases, unless values are provided for L2 and L3,
/// in which case this field represents phase L1. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMinimumDischargeReactivePower
#[serde(rename = "minDischargeReactivePower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_discharge_reactive_power: Option<crate::types::Decimal>,
/// Rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L2. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMinimumDischargeReactivePower_L2
#[serde(rename = "minDischargeReactivePower_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_discharge_reactive_power_l2: Option<crate::types::Decimal>,
/// Rated minimum injected reactive power, defined by max(EV, EVSE), in var on phase L3. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMinimumDischargeReactivePower_L3
#[serde(rename = "minDischargeReactivePower_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_discharge_reactive_power_l3: Option<crate::types::Decimal>,
/// Line voltage supported by EVSE and EV.
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVNominalVoltage
#[serde(rename = "nominalVoltage")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub nominal_voltage: Option<crate::types::Decimal>,
/// The nominal AC voltage (rms) offset between the Charging Station's electrical connection point and the utility’s point of common coupling. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVNominalVoltageOffset
#[serde(rename = "nominalVoltageOffset")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub nominal_voltage_offset: Option<crate::types::Decimal>,
/// Maximum AC rms voltage, as defined by min(EV, EVSE) to operate with. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumNominalVoltage
#[serde(rename = "maxNominalVoltage")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_nominal_voltage: Option<crate::types::Decimal>,
/// Minimum AC rms voltage, as defined by max(EV, EVSE) to operate with. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMinimumNominalVoltage
#[serde(rename = "minNominalVoltage")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_nominal_voltage: Option<crate::types::Decimal>,
/// Manufacturer of the EV inverter. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVInverterManufacturer
#[serde(rename = "evInverterManufacturer")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_inverter_manufacturer: Option<String>,
/// Model name of the EV inverter. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVInverterModel
#[serde(rename = "evInverterModel")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_inverter_model: Option<String>,
/// Serial number of the EV inverter. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVInverterSerialNumber
#[serde(rename = "evInverterSerialNumber")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_inverter_serial_number: Option<String>,
/// Software version of EV inverter. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVInverterSwVersion
#[serde(rename = "evInverterSwVersion")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_inverter_sw_version: Option<String>,
/// Hardware version of EV inverter. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVInverterHwVersion
#[serde(rename = "evInverterHwVersion")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_inverter_hw_version: Option<String>,
/// Type of islanding detection method. Only mandatory when islanding detection is required at the site, as set in the ISO 15118 Service Details configuration. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVIslandingDetectionMethod
#[serde(rename = "evIslandingDetectionMethod")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_islanding_detection_method: Option<Vec<IslandingDetection>>,
/// Time after which EV will trip if an island has been detected. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVIslandingTripTime
#[serde(rename = "evIslandingTripTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_islanding_trip_time: Option<crate::types::Decimal>,
/// Maximum injected DC current allowed at level 1 charging. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumLevel1DCInjection
#[serde(rename = "evMaximumLevel1DCInjection")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_maximum_level1_dc_injection: Option<crate::types::Decimal>,
/// Maximum allowed duration of DC injection at level 1 charging. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVDurationLevel1DCInjection
#[serde(rename = "evDurationLevel1DCInjection")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_duration_level1_dc_injection: Option<crate::types::Decimal>,
/// Maximum injected DC current allowed at level 2 charging. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVMaximumLevel2DCInjection
#[serde(rename = "evMaximumLevel2DCInjection")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_maximum_level2_dc_injection: Option<crate::types::Decimal>,
/// Maximum allowed duration of DC injection at level 2 charging. +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVDurationLevel2DCInjection
#[serde(rename = "evDurationLevel2DCInjection")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_duration_level2_dc_injection: Option<crate::types::Decimal>,
/// Measure of the susceptibility of the circuit to reactance, in Siemens (S). +
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVReactiveSusceptance
#[serde(rename = "evReactiveSusceptance")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_reactive_susceptance: Option<crate::types::Decimal>,
/// Total energy value, in Wh, that EV is allowed to provide during the entire V2G session. The value is independent of the V2X Cycling area. Once this value reaches the value of 0, the EV may block any attempt to discharge in order to protect the battery health.
/// *ISO 15118-20*: DER_BPT_AC_CPDReqEnergyTransferModeType: EVSessionTotalDischargeEnergyAvailable
#[serde(rename = "evSessionTotalDischargeEnergyAvailable")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_session_total_discharge_energy_available: Option<crate::types::Decimal>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl DERChargingParameters {
/// Creates an empty `DERChargingParameters`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `evSupportedDERControl` field.
#[must_use]
pub fn with_ev_supported_der_control(mut self, value: Vec<DERControl>) -> Self {
self.ev_supported_der_control = Some(value);
self
}
/// Sets the optional `evOverExcitedMaxDischargePower` field.
#[must_use]
pub fn with_ev_over_excited_max_discharge_power(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_over_excited_max_discharge_power = Some(value.into());
self
}
/// Sets the optional `evOverExcitedPowerFactor` field.
#[must_use]
pub fn with_ev_over_excited_power_factor(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_over_excited_power_factor = Some(value.into());
self
}
/// Sets the optional `evUnderExcitedMaxDischargePower` field.
#[must_use]
pub fn with_ev_under_excited_max_discharge_power(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_under_excited_max_discharge_power = Some(value.into());
self
}
/// Sets the optional `evUnderExcitedPowerFactor` field.
#[must_use]
pub fn with_ev_under_excited_power_factor(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_under_excited_power_factor = Some(value.into());
self
}
/// Sets the optional `maxApparentPower` field.
#[must_use]
pub fn with_max_apparent_power(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_apparent_power = Some(value.into());
self
}
/// Sets the optional `maxChargeApparentPower` field.
#[must_use]
pub fn with_max_charge_apparent_power(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_charge_apparent_power = Some(value.into());
self
}
/// Sets the optional `maxChargeApparentPower_L2` field.
#[must_use]
pub fn with_max_charge_apparent_power_l2(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_charge_apparent_power_l2 = Some(value.into());
self
}
/// Sets the optional `maxChargeApparentPower_L3` field.
#[must_use]
pub fn with_max_charge_apparent_power_l3(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_charge_apparent_power_l3 = Some(value.into());
self
}
/// Sets the optional `maxDischargeApparentPower` field.
#[must_use]
pub fn with_max_discharge_apparent_power(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_discharge_apparent_power = Some(value.into());
self
}
/// Sets the optional `maxDischargeApparentPower_L2` field.
#[must_use]
pub fn with_max_discharge_apparent_power_l2(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_discharge_apparent_power_l2 = Some(value.into());
self
}
/// Sets the optional `maxDischargeApparentPower_L3` field.
#[must_use]
pub fn with_max_discharge_apparent_power_l3(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_discharge_apparent_power_l3 = Some(value.into());
self
}
/// Sets the optional `maxChargeReactivePower` field.
#[must_use]
pub fn with_max_charge_reactive_power(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_charge_reactive_power = Some(value.into());
self
}
/// Sets the optional `maxChargeReactivePower_L2` field.
#[must_use]
pub fn with_max_charge_reactive_power_l2(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_charge_reactive_power_l2 = Some(value.into());
self
}
/// Sets the optional `maxChargeReactivePower_L3` field.
#[must_use]
pub fn with_max_charge_reactive_power_l3(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_charge_reactive_power_l3 = Some(value.into());
self
}
/// Sets the optional `minChargeReactivePower` field.
#[must_use]
pub fn with_min_charge_reactive_power(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.min_charge_reactive_power = Some(value.into());
self
}
/// Sets the optional `minChargeReactivePower_L2` field.
#[must_use]
pub fn with_min_charge_reactive_power_l2(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.min_charge_reactive_power_l2 = Some(value.into());
self
}
/// Sets the optional `minChargeReactivePower_L3` field.
#[must_use]
pub fn with_min_charge_reactive_power_l3(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.min_charge_reactive_power_l3 = Some(value.into());
self
}
/// Sets the optional `maxDischargeReactivePower` field.
#[must_use]
pub fn with_max_discharge_reactive_power(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_discharge_reactive_power = Some(value.into());
self
}
/// Sets the optional `maxDischargeReactivePower_L2` field.
#[must_use]
pub fn with_max_discharge_reactive_power_l2(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_discharge_reactive_power_l2 = Some(value.into());
self
}
/// Sets the optional `maxDischargeReactivePower_L3` field.
#[must_use]
pub fn with_max_discharge_reactive_power_l3(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.max_discharge_reactive_power_l3 = Some(value.into());
self
}
/// Sets the optional `minDischargeReactivePower` field.
#[must_use]
pub fn with_min_discharge_reactive_power(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.min_discharge_reactive_power = Some(value.into());
self
}
/// Sets the optional `minDischargeReactivePower_L2` field.
#[must_use]
pub fn with_min_discharge_reactive_power_l2(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.min_discharge_reactive_power_l2 = Some(value.into());
self
}
/// Sets the optional `minDischargeReactivePower_L3` field.
#[must_use]
pub fn with_min_discharge_reactive_power_l3(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.min_discharge_reactive_power_l3 = Some(value.into());
self
}
/// Sets the optional `nominalVoltage` field.
#[must_use]
pub fn with_nominal_voltage(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.nominal_voltage = Some(value.into());
self
}
/// Sets the optional `nominalVoltageOffset` field.
#[must_use]
pub fn with_nominal_voltage_offset(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.nominal_voltage_offset = Some(value.into());
self
}
/// Sets the optional `maxNominalVoltage` field.
#[must_use]
pub fn with_max_nominal_voltage(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_nominal_voltage = Some(value.into());
self
}
/// Sets the optional `minNominalVoltage` field.
#[must_use]
pub fn with_min_nominal_voltage(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_nominal_voltage = Some(value.into());
self
}
/// Sets the optional `evInverterManufacturer` field.
#[must_use]
pub fn with_ev_inverter_manufacturer(mut self, value: impl Into<String>) -> Self {
self.ev_inverter_manufacturer = Some(value.into());
self
}
/// Sets the optional `evInverterModel` field.
#[must_use]
pub fn with_ev_inverter_model(mut self, value: impl Into<String>) -> Self {
self.ev_inverter_model = Some(value.into());
self
}
/// Sets the optional `evInverterSerialNumber` field.
#[must_use]
pub fn with_ev_inverter_serial_number(mut self, value: impl Into<String>) -> Self {
self.ev_inverter_serial_number = Some(value.into());
self
}
/// Sets the optional `evInverterSwVersion` field.
#[must_use]
pub fn with_ev_inverter_sw_version(mut self, value: impl Into<String>) -> Self {
self.ev_inverter_sw_version = Some(value.into());
self
}
/// Sets the optional `evInverterHwVersion` field.
#[must_use]
pub fn with_ev_inverter_hw_version(mut self, value: impl Into<String>) -> Self {
self.ev_inverter_hw_version = Some(value.into());
self
}
/// Sets the optional `evIslandingDetectionMethod` field.
#[must_use]
pub fn with_ev_islanding_detection_method(mut self, value: Vec<IslandingDetection>) -> Self {
self.ev_islanding_detection_method = Some(value);
self
}
/// Sets the optional `evIslandingTripTime` field.
#[must_use]
pub fn with_ev_islanding_trip_time(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.ev_islanding_trip_time = Some(value.into());
self
}
/// Sets the optional `evMaximumLevel1DCInjection` field.
#[must_use]
pub fn with_ev_maximum_level1_dc_injection(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_maximum_level1_dc_injection = Some(value.into());
self
}
/// Sets the optional `evDurationLevel1DCInjection` field.
#[must_use]
pub fn with_ev_duration_level1_dc_injection(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_duration_level1_dc_injection = Some(value.into());
self
}
/// Sets the optional `evMaximumLevel2DCInjection` field.
#[must_use]
pub fn with_ev_maximum_level2_dc_injection(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_maximum_level2_dc_injection = Some(value.into());
self
}
/// Sets the optional `evDurationLevel2DCInjection` field.
#[must_use]
pub fn with_ev_duration_level2_dc_injection(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_duration_level2_dc_injection = Some(value.into());
self
}
/// Sets the optional `evReactiveSusceptance` field.
#[must_use]
pub fn with_ev_reactive_susceptance(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.ev_reactive_susceptance = Some(value.into());
self
}
/// Sets the optional `evSessionTotalDischargeEnergyAvailable` field.
#[must_use]
pub fn with_ev_session_total_discharge_energy_available(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_session_total_discharge_energy_available = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for DERChargingParameters {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("evSupportedDERControl");
if let Some(value) = &self.ev_supported_der_control {
validate::list_len(value.len(), Some(1), None, path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("evInverterManufacturer");
if let Some(value) = &self.ev_inverter_manufacturer {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("evInverterModel");
if let Some(value) = &self.ev_inverter_model {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("evInverterSerialNumber");
if let Some(value) = &self.ev_inverter_serial_number {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("evInverterSwVersion");
if let Some(value) = &self.ev_inverter_sw_version {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("evInverterHwVersion");
if let Some(value) = &self.ev_inverter_hw_version {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("evIslandingDetectionMethod");
if let Some(value) = &self.ev_islanding_detection_method {
validate::list_len(value.len(), Some(1), None, path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `DERCurve` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct DERCurve {
/// The `curveData` member.
#[serde(rename = "curveData")]
pub curve_data: Vec<DERCurvePoints>,
/// Priority of curve (0=highest)
#[serde(deserialize_with = "crate::types::integer::one")]
pub priority: i32,
/// The `yUnit` member.
#[serde(rename = "yUnit")]
pub y_unit: DERUnit,
/// The `hysteresis` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub hysteresis: Option<Hysteresis>,
/// The `reactivePowerParams` member.
#[serde(rename = "reactivePowerParams")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub reactive_power_params: Option<ReactivePowerParams>,
/// The `voltageParams` member.
#[serde(rename = "voltageParams")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub voltage_params: Option<VoltageParams>,
/// Open loop response time, the time to ramp up to 90% of the new target in response to the change in voltage, in seconds. A value of 0 is used to mean no limit. When not present, the device should follow its default behavior.
#[serde(rename = "responseTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub response_time: Option<crate::types::Decimal>,
/// Point in time when this curve will become activated. Only absent when _default_ is true.
#[serde(rename = "startTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub start_time: Option<crate::types::DateTime>,
/// Duration in seconds that this curve will be active. Only absent when _default_ is true.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub duration: Option<crate::types::Decimal>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl DERCurve {
/// Creates a `DERCurve` from its required fields.
#[must_use]
pub fn new(curve_data: Vec<DERCurvePoints>, priority: i32, y_unit: DERUnit) -> Self {
Self {
curve_data,
priority,
y_unit,
hysteresis: None,
reactive_power_params: None,
voltage_params: None,
response_time: None,
start_time: None,
duration: None,
custom_data: None,
}
}
/// Sets the optional `hysteresis` field.
#[must_use]
pub fn with_hysteresis(mut self, value: Hysteresis) -> Self {
self.hysteresis = Some(value);
self
}
/// Sets the optional `reactivePowerParams` field.
#[must_use]
pub fn with_reactive_power_params(mut self, value: ReactivePowerParams) -> Self {
self.reactive_power_params = Some(value);
self
}
/// Sets the optional `voltageParams` field.
#[must_use]
pub fn with_voltage_params(mut self, value: VoltageParams) -> Self {
self.voltage_params = Some(value);
self
}
/// Sets the optional `responseTime` field.
#[must_use]
pub fn with_response_time(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.response_time = Some(value.into());
self
}
/// Sets the optional `startTime` field.
#[must_use]
pub fn with_start_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.start_time = Some(value.into());
self
}
/// Sets the optional `duration` field.
#[must_use]
pub fn with_duration(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.duration = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for DERCurve {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("curveData");
validate::list_len(self.curve_data.len(), Some(1), Some(10), path, out);
for (index, item) in self.curve_data.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("priority");
validate::int_range(i64::from(self.priority), Some(0), None, path, out);
path.pop();
path.push_key("yUnit");
Validate::validate_at(&self.y_unit, path, out);
path.pop();
path.push_key("hysteresis");
if let Some(value) = &self.hysteresis {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("reactivePowerParams");
if let Some(value) = &self.reactive_power_params {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("voltageParams");
if let Some(value) = &self.voltage_params {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `DERCurveGet` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct DERCurveGet {
/// The `curve` member.
pub curve: DERCurve,
/// Id of DER curve
pub id: String,
/// The `curveType` member.
#[serde(rename = "curveType")]
pub curve_type: DERControl,
/// True if this is a default curve
#[serde(rename = "isDefault")]
pub is_default: bool,
/// True if this setting is superseded by a higher priority setting (i.e. lower value of _priority_)
#[serde(rename = "isSuperseded")]
pub is_superseded: bool,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl DERCurveGet {
/// Creates a `DERCurveGet` from its required fields.
#[must_use]
pub fn new(
curve: DERCurve,
id: impl Into<String>,
curve_type: DERControl,
is_default: bool,
is_superseded: bool,
) -> Self {
Self {
curve,
id: id.into(),
curve_type,
is_default,
is_superseded,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for DERCurveGet {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("curve");
Validate::validate_at(&self.curve, path, out);
path.pop();
path.push_key("id");
validate::string(self.id.as_str(), None, Some(36), path, out);
path.pop();
path.push_key("curveType");
Validate::validate_at(&self.curve_type, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `DERCurvePoints` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct DERCurvePoints {
/// The data value of the X-axis (independent) variable, depending on the curve type.
pub x: crate::types::Decimal,
/// The data value of the Y-axis (dependent) variable, depending on the <<cmn_derunitenumtype>> of the curve. If _y_ is power factor, then a positive value means DER is absorbing reactive power (under-excited), a negative value when DER is injecting reactive power (over-excited).
pub y: crate::types::Decimal,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl DERCurvePoints {
/// Creates a `DERCurvePoints` from its required fields.
#[must_use]
pub fn new(x: impl Into<crate::types::Decimal>, y: impl Into<crate::types::Decimal>) -> Self {
Self {
x: x.into(),
y: y.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for DERCurvePoints {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// *(2.1)* Price schedule of EV energy offer.
///
/// The OCPP 2.1 `EVAbsolutePriceSchedule` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EVAbsolutePriceSchedule {
/// Starting point in time of the EVEnergyOffer.
#[serde(rename = "timeAnchor")]
pub time_anchor: crate::types::DateTime,
/// Currency code according to ISO 4217.
pub currency: String,
/// The `evAbsolutePriceScheduleEntries` member.
#[serde(rename = "evAbsolutePriceScheduleEntries")]
pub ev_absolute_price_schedule_entries: Vec<EVAbsolutePriceScheduleEntry>,
/// ISO 15118-20 URN of price algorithm: Power, PeakPower, StackedEnergy.
#[serde(rename = "priceAlgorithm")]
pub price_algorithm: String,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl EVAbsolutePriceSchedule {
/// Creates a `EVAbsolutePriceSchedule` from its required fields.
#[must_use]
pub fn new(
time_anchor: impl Into<crate::types::DateTime>,
currency: impl Into<String>,
ev_absolute_price_schedule_entries: Vec<EVAbsolutePriceScheduleEntry>,
price_algorithm: impl Into<String>,
) -> Self {
Self {
time_anchor: time_anchor.into(),
currency: currency.into(),
ev_absolute_price_schedule_entries,
price_algorithm: price_algorithm.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for EVAbsolutePriceSchedule {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("currency");
validate::string(self.currency.as_str(), None, Some(3), path, out);
path.pop();
path.push_key("evAbsolutePriceScheduleEntries");
validate::list_len(
self.ev_absolute_price_schedule_entries.len(),
Some(1),
Some(1024),
path,
out,
);
for (index, item) in self.ev_absolute_price_schedule_entries.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("priceAlgorithm");
validate::string(self.price_algorithm.as_str(), None, Some(2000), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// *(2.1)* An entry in price schedule over time for which EV is willing to discharge.
///
/// The OCPP 2.1 `EVAbsolutePriceScheduleEntry` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EVAbsolutePriceScheduleEntry {
/// The amount of seconds of this entry.
#[serde(deserialize_with = "crate::types::integer::one")]
pub duration: i32,
/// The `evPriceRule` member.
#[serde(rename = "evPriceRule")]
pub ev_price_rule: Vec<EVPriceRule>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl EVAbsolutePriceScheduleEntry {
/// Creates a `EVAbsolutePriceScheduleEntry` from its required fields.
#[must_use]
pub fn new(duration: i32, ev_price_rule: Vec<EVPriceRule>) -> Self {
Self {
duration,
ev_price_rule,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for EVAbsolutePriceScheduleEntry {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("evPriceRule");
validate::list_len(self.ev_price_rule.len(), Some(1), Some(8), path, out);
for (index, item) in self.ev_price_rule.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// *(2.1)* A schedule of the energy amount over time that EV is willing to discharge. A negative value indicates the willingness to discharge under specific conditions, a positive value indicates that the EV currently is not able to offer energy to discharge.
///
/// The OCPP 2.1 `EVEnergyOffer` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EVEnergyOffer {
/// The `evPowerSchedule` member.
#[serde(rename = "evPowerSchedule")]
pub ev_power_schedule: EVPowerSchedule,
/// The `evAbsolutePriceSchedule` member.
#[serde(rename = "evAbsolutePriceSchedule")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_absolute_price_schedule: Option<EVAbsolutePriceSchedule>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl EVEnergyOffer {
/// Creates a `EVEnergyOffer` from its required fields.
#[must_use]
pub fn new(ev_power_schedule: EVPowerSchedule) -> Self {
Self {
ev_power_schedule,
ev_absolute_price_schedule: None,
custom_data: None,
}
}
/// Sets the optional `evAbsolutePriceSchedule` field.
#[must_use]
pub fn with_ev_absolute_price_schedule(mut self, value: EVAbsolutePriceSchedule) -> Self {
self.ev_absolute_price_schedule = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for EVEnergyOffer {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("evPowerSchedule");
Validate::validate_at(&self.ev_power_schedule, path, out);
path.pop();
path.push_key("evAbsolutePriceSchedule");
if let Some(value) = &self.ev_absolute_price_schedule {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// *(2.1)* Schedule of EV energy offer.
///
/// The OCPP 2.1 `EVPowerSchedule` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EVPowerSchedule {
/// The `evPowerScheduleEntries` member.
#[serde(rename = "evPowerScheduleEntries")]
pub ev_power_schedule_entries: Vec<EVPowerScheduleEntry>,
/// The time that defines the starting point for the EVEnergyOffer.
#[serde(rename = "timeAnchor")]
pub time_anchor: crate::types::DateTime,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl EVPowerSchedule {
/// Creates a `EVPowerSchedule` from its required fields.
#[must_use]
pub fn new(
ev_power_schedule_entries: Vec<EVPowerScheduleEntry>,
time_anchor: impl Into<crate::types::DateTime>,
) -> Self {
Self {
ev_power_schedule_entries,
time_anchor: time_anchor.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for EVPowerSchedule {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("evPowerScheduleEntries");
validate::list_len(
self.ev_power_schedule_entries.len(),
Some(1),
Some(1024),
path,
out,
);
for (index, item) in self.ev_power_schedule_entries.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// *(2.1)* An entry in schedule of the energy amount over time that EV is willing to discharge. A negative value indicates the willingness to discharge under specific conditions, a positive value indicates that the EV currently is not able to offer energy to discharge.
///
/// The OCPP 2.1 `EVPowerScheduleEntry` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EVPowerScheduleEntry {
/// The duration of this entry.
#[serde(deserialize_with = "crate::types::integer::one")]
pub duration: i32,
/// Defines maximum amount of power for the duration of this EVPowerScheduleEntry to be discharged from the EV battery through EVSE power outlet. Negative values are used for discharging.
pub power: crate::types::Decimal,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl EVPowerScheduleEntry {
/// Creates a `EVPowerScheduleEntry` from its required fields.
#[must_use]
pub fn new(duration: i32, power: impl Into<crate::types::Decimal>) -> Self {
Self {
duration,
power: power.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for EVPowerScheduleEntry {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// *(2.1)* An entry in price schedule over time for which EV is willing to discharge.
///
/// The OCPP 2.1 `EVPriceRule` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EVPriceRule {
/// Cost per kWh.
#[serde(rename = "energyFee")]
pub energy_fee: crate::types::Decimal,
/// The EnergyFee applies between this value and the value of the PowerRangeStart of the subsequent EVPriceRule. If the power is below this value, the EnergyFee of the previous EVPriceRule applies. Negative values are used for discharging.
#[serde(rename = "powerRangeStart")]
pub power_range_start: crate::types::Decimal,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl EVPriceRule {
/// Creates a `EVPriceRule` from its required fields.
#[must_use]
pub fn new(
energy_fee: impl Into<crate::types::Decimal>,
power_range_start: impl Into<crate::types::Decimal>,
) -> Self {
Self {
energy_fee: energy_fee.into(),
power_range_start: power_range_start.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for EVPriceRule {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Electric Vehicle Supply Equipment
///
/// The OCPP 2.1 `EVSE` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EVSE {
/// EVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.
#[serde(deserialize_with = "crate::types::integer::one")]
pub id: i32,
/// An id to designate a specific connector (on an EVSE) by connector index number.
#[serde(rename = "connectorId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub connector_id: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl EVSE {
/// Creates a `EVSE` from its required fields.
#[must_use]
pub fn new(id: i32) -> Self {
Self {
id,
connector_id: None,
custom_data: None,
}
}
/// Sets the optional `connectorId` field.
#[must_use]
pub fn with_connector_id(mut self, value: i32) -> Self {
self.connector_id = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for EVSE {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("id");
validate::int_range(i64::from(self.id), Some(0), None, path, out);
path.pop();
path.push_key("connectorId");
if let Some(value) = &self.connector_id {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `EnterService` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EnterService {
/// Priority of setting (0=highest)
#[serde(deserialize_with = "crate::types::integer::one")]
pub priority: i32,
/// Enter service voltage high
#[serde(rename = "highVoltage")]
pub high_voltage: crate::types::Decimal,
/// Enter service voltage low
#[serde(rename = "lowVoltage")]
pub low_voltage: crate::types::Decimal,
/// Enter service frequency high
#[serde(rename = "highFreq")]
pub high_freq: crate::types::Decimal,
/// Enter service frequency low
#[serde(rename = "lowFreq")]
pub low_freq: crate::types::Decimal,
/// Enter service delay
#[serde(default, skip_serializing_if = "Option::is_none")]
pub delay: Option<crate::types::Decimal>,
/// Enter service randomized delay
#[serde(rename = "randomDelay")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub random_delay: Option<crate::types::Decimal>,
/// Enter service ramp rate in seconds
#[serde(rename = "rampRate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ramp_rate: Option<crate::types::Decimal>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl EnterService {
/// Creates a `EnterService` from its required fields.
#[must_use]
pub fn new(
priority: i32,
high_voltage: impl Into<crate::types::Decimal>,
low_voltage: impl Into<crate::types::Decimal>,
high_freq: impl Into<crate::types::Decimal>,
low_freq: impl Into<crate::types::Decimal>,
) -> Self {
Self {
priority,
high_voltage: high_voltage.into(),
low_voltage: low_voltage.into(),
high_freq: high_freq.into(),
low_freq: low_freq.into(),
delay: None,
random_delay: None,
ramp_rate: None,
custom_data: None,
}
}
/// Sets the optional `delay` field.
#[must_use]
pub fn with_delay(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.delay = Some(value.into());
self
}
/// Sets the optional `randomDelay` field.
#[must_use]
pub fn with_random_delay(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.random_delay = Some(value.into());
self
}
/// Sets the optional `rampRate` field.
#[must_use]
pub fn with_ramp_rate(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.ramp_rate = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for EnterService {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("priority");
validate::int_range(i64::from(self.priority), Some(0), None, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `EnterServiceGet` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EnterServiceGet {
/// The `enterService` member.
#[serde(rename = "enterService")]
pub enter_service: EnterService,
/// Id of setting
pub id: String,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl EnterServiceGet {
/// Creates a `EnterServiceGet` from its required fields.
#[must_use]
pub fn new(enter_service: EnterService, id: impl Into<String>) -> Self {
Self {
enter_service,
id: id.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for EnterServiceGet {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("enterService");
Validate::validate_at(&self.enter_service, path, out);
path.pop();
path.push_key("id");
validate::string(self.id.as_str(), None, Some(36), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Class to report an event notification for a component-variable.
///
/// The OCPP 2.1 `EventData` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EventData {
/// Identifies the event. This field can be referred to as a cause by other events.
#[serde(rename = "eventId")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub event_id: i32,
/// Timestamp of the moment the report was generated.
pub timestamp: crate::types::DateTime,
/// The `trigger` member.
pub trigger: EventTrigger,
/// Actual value (_attributeType_ Actual) of the variable.
///
/// The Configuration Variable <<configkey-reporting-value-size,ReportingValueSize>> can be used to limit GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max size of these values will always remain equal.
#[serde(rename = "actualValue")]
pub actual_value: String,
/// The `component` member.
pub component: Component,
/// The `eventNotificationType` member.
#[serde(rename = "eventNotificationType")]
pub event_notification_type: EventNotification,
/// The `variable` member.
pub variable: Variable,
/// Refers to the Id of an event that is considered to be the cause for this event.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub cause: Option<i32>,
/// Technical (error) code as reported by component.
#[serde(rename = "techCode")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tech_code: Option<String>,
/// Technical detail information as reported by component.
#[serde(rename = "techInfo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tech_info: Option<String>,
/// _Cleared_ is set to true to report the clearing of a monitored situation, i.e. a 'return to normal'.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub cleared: Option<bool>,
/// If an event notification is linked to a specific transaction, this field can be used to specify its transactionId.
#[serde(rename = "transactionId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub transaction_id: Option<String>,
/// Identifies the VariableMonitoring which triggered the event.
#[serde(rename = "variableMonitoringId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub variable_monitoring_id: Option<i32>,
/// *(2.1)* Severity associated with the monitor in _variableMonitoringId_ or with the hardwired notification.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub severity: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl EventData {
/// Creates a `EventData` from its required fields.
#[must_use]
pub fn new(
event_id: i32,
timestamp: impl Into<crate::types::DateTime>,
trigger: EventTrigger,
actual_value: impl Into<String>,
component: Component,
event_notification_type: EventNotification,
variable: Variable,
) -> Self {
Self {
event_id,
timestamp: timestamp.into(),
trigger,
actual_value: actual_value.into(),
component,
event_notification_type,
variable,
cause: None,
tech_code: None,
tech_info: None,
cleared: None,
transaction_id: None,
variable_monitoring_id: None,
severity: None,
custom_data: None,
}
}
/// Sets the optional `cause` field.
#[must_use]
pub fn with_cause(mut self, value: i32) -> Self {
self.cause = Some(value);
self
}
/// Sets the optional `techCode` field.
#[must_use]
pub fn with_tech_code(mut self, value: impl Into<String>) -> Self {
self.tech_code = Some(value.into());
self
}
/// Sets the optional `techInfo` field.
#[must_use]
pub fn with_tech_info(mut self, value: impl Into<String>) -> Self {
self.tech_info = Some(value.into());
self
}
/// Sets the optional `cleared` field.
#[must_use]
pub fn with_cleared(mut self, value: bool) -> Self {
self.cleared = Some(value);
self
}
/// Sets the optional `transactionId` field.
#[must_use]
pub fn with_transaction_id(mut self, value: impl Into<String>) -> Self {
self.transaction_id = Some(value.into());
self
}
/// Sets the optional `variableMonitoringId` field.
#[must_use]
pub fn with_variable_monitoring_id(mut self, value: i32) -> Self {
self.variable_monitoring_id = Some(value);
self
}
/// Sets the optional `severity` field.
#[must_use]
pub fn with_severity(mut self, value: i32) -> Self {
self.severity = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for EventData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("eventId");
validate::int_range(i64::from(self.event_id), Some(0), None, path, out);
path.pop();
path.push_key("trigger");
Validate::validate_at(&self.trigger, path, out);
path.pop();
path.push_key("actualValue");
validate::string(self.actual_value.as_str(), None, Some(2500), path, out);
path.pop();
path.push_key("component");
Validate::validate_at(&self.component, path, out);
path.pop();
path.push_key("eventNotificationType");
Validate::validate_at(&self.event_notification_type, path, out);
path.pop();
path.push_key("variable");
Validate::validate_at(&self.variable, path, out);
path.pop();
path.push_key("cause");
if let Some(value) = &self.cause {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("techCode");
if let Some(value) = &self.tech_code {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("techInfo");
if let Some(value) = &self.tech_info {
validate::string(value.as_str(), None, Some(500), path, out);
}
path.pop();
path.push_key("transactionId");
if let Some(value) = &self.transaction_id {
validate::string(value.as_str(), None, Some(36), path, out);
}
path.pop();
path.push_key("variableMonitoringId");
if let Some(value) = &self.variable_monitoring_id {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("severity");
if let Some(value) = &self.severity {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Represents a copy of the firmware that can be loaded/updated on the Charging Station.
///
/// The OCPP 2.1 `Firmware` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Firmware {
/// URI defining the origin of the firmware.
pub location: String,
/// Date and time at which the firmware shall be retrieved.
#[serde(rename = "retrieveDateTime")]
pub retrieve_date_time: crate::types::DateTime,
/// Date and time at which the firmware shall be installed.
#[serde(rename = "installDateTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub install_date_time: Option<crate::types::DateTime>,
/// Certificate with which the firmware was signed.
/// PEM encoded X.509 certificate.
#[serde(rename = "signingCertificate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub signing_certificate: Option<String>,
/// Base64 encoded firmware signature.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub signature: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl Firmware {
/// Creates a `Firmware` from its required fields.
#[must_use]
pub fn new(
location: impl Into<String>,
retrieve_date_time: impl Into<crate::types::DateTime>,
) -> Self {
Self {
location: location.into(),
retrieve_date_time: retrieve_date_time.into(),
install_date_time: None,
signing_certificate: None,
signature: None,
custom_data: None,
}
}
/// Sets the optional `installDateTime` field.
#[must_use]
pub fn with_install_date_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.install_date_time = Some(value.into());
self
}
/// Sets the optional `signingCertificate` field.
#[must_use]
pub fn with_signing_certificate(mut self, value: impl Into<String>) -> Self {
self.signing_certificate = Some(value.into());
self
}
/// Sets the optional `signature` field.
#[must_use]
pub fn with_signature(mut self, value: impl Into<String>) -> Self {
self.signature = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for Firmware {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("location");
validate::string(self.location.as_str(), None, Some(2000), path, out);
path.pop();
path.push_key("signingCertificate");
if let Some(value) = &self.signing_certificate {
validate::string(value.as_str(), None, Some(5500), path, out);
}
path.pop();
path.push_key("signature");
if let Some(value) = &self.signature {
validate::string(value.as_str(), None, Some(800), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `FixedPF` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FixedPF {
/// Priority of setting (0=highest)
#[serde(deserialize_with = "crate::types::integer::one")]
pub priority: i32,
/// Power factor, cos(phi), as value between 0..1.
pub displacement: crate::types::Decimal,
/// True when absorbing reactive power (under-excited), false when injecting reactive power (over-excited).
pub excitation: bool,
/// Time when this setting becomes active
#[serde(rename = "startTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub start_time: Option<crate::types::DateTime>,
/// Duration in seconds that this setting is active.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub duration: Option<crate::types::Decimal>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl FixedPF {
/// Creates a `FixedPF` from its required fields.
#[must_use]
pub fn new(
priority: i32,
displacement: impl Into<crate::types::Decimal>,
excitation: bool,
) -> Self {
Self {
priority,
displacement: displacement.into(),
excitation,
start_time: None,
duration: None,
custom_data: None,
}
}
/// Sets the optional `startTime` field.
#[must_use]
pub fn with_start_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.start_time = Some(value.into());
self
}
/// Sets the optional `duration` field.
#[must_use]
pub fn with_duration(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.duration = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for FixedPF {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("priority");
validate::int_range(i64::from(self.priority), Some(0), None, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `FixedPFGet` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FixedPFGet {
/// The `fixedPF` member.
#[serde(rename = "fixedPF")]
pub fixed_pf: FixedPF,
/// Id of setting.
pub id: String,
/// True if setting is a default control.
#[serde(rename = "isDefault")]
pub is_default: bool,
/// True if this setting is superseded by a lower priority setting.
#[serde(rename = "isSuperseded")]
pub is_superseded: bool,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl FixedPFGet {
/// Creates a `FixedPFGet` from its required fields.
#[must_use]
pub fn new(
fixed_pf: FixedPF,
id: impl Into<String>,
is_default: bool,
is_superseded: bool,
) -> Self {
Self {
fixed_pf,
id: id.into(),
is_default,
is_superseded,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for FixedPFGet {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("fixedPF");
Validate::validate_at(&self.fixed_pf, path, out);
path.pop();
path.push_key("id");
validate::string(self.id.as_str(), None, Some(36), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `FixedVar` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FixedVar {
/// Priority of setting (0=highest)
#[serde(deserialize_with = "crate::types::integer::one")]
pub priority: i32,
/// The value specifies a target var output interpreted as a signed percentage (-100 to 100).
/// A negative value refers to charging, whereas a positive one refers to discharging.
/// The value type is determined by the unit field.
pub setpoint: crate::types::Decimal,
/// The `unit` member.
pub unit: DERUnit,
/// Time when this setting becomes active.
#[serde(rename = "startTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub start_time: Option<crate::types::DateTime>,
/// Duration in seconds that this setting is active.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub duration: Option<crate::types::Decimal>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl FixedVar {
/// Creates a `FixedVar` from its required fields.
#[must_use]
pub fn new(priority: i32, setpoint: impl Into<crate::types::Decimal>, unit: DERUnit) -> Self {
Self {
priority,
setpoint: setpoint.into(),
unit,
start_time: None,
duration: None,
custom_data: None,
}
}
/// Sets the optional `startTime` field.
#[must_use]
pub fn with_start_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.start_time = Some(value.into());
self
}
/// Sets the optional `duration` field.
#[must_use]
pub fn with_duration(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.duration = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for FixedVar {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("priority");
validate::int_range(i64::from(self.priority), Some(0), None, path, out);
path.pop();
path.push_key("unit");
Validate::validate_at(&self.unit, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `FixedVarGet` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FixedVarGet {
/// The `fixedVar` member.
#[serde(rename = "fixedVar")]
pub fixed_var: FixedVar,
/// Id of setting
pub id: String,
/// True if setting is a default control.
#[serde(rename = "isDefault")]
pub is_default: bool,
/// True if this setting is superseded by a lower priority setting
#[serde(rename = "isSuperseded")]
pub is_superseded: bool,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl FixedVarGet {
/// Creates a `FixedVarGet` from its required fields.
#[must_use]
pub fn new(
fixed_var: FixedVar,
id: impl Into<String>,
is_default: bool,
is_superseded: bool,
) -> Self {
Self {
fixed_var,
id: id.into(),
is_default,
is_superseded,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for FixedVarGet {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("fixedVar");
Validate::validate_at(&self.fixed_var, path, out);
path.pop();
path.push_key("id");
validate::string(self.id.as_str(), None, Some(36), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `FreqDroop` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FreqDroop {
/// Priority of setting (0=highest)
#[serde(deserialize_with = "crate::types::integer::one")]
pub priority: i32,
/// Over-frequency start of droop
#[serde(rename = "overFreq")]
pub over_freq: crate::types::Decimal,
/// Under-frequency start of droop
#[serde(rename = "underFreq")]
pub under_freq: crate::types::Decimal,
/// Over-frequency droop per unit, oFDroop
#[serde(rename = "overDroop")]
pub over_droop: crate::types::Decimal,
/// Under-frequency droop per unit, uFDroop
#[serde(rename = "underDroop")]
pub under_droop: crate::types::Decimal,
/// Open loop response time in seconds
#[serde(rename = "responseTime")]
pub response_time: crate::types::Decimal,
/// Time when this setting becomes active
#[serde(rename = "startTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub start_time: Option<crate::types::DateTime>,
/// Duration in seconds that this setting is active
#[serde(default, skip_serializing_if = "Option::is_none")]
pub duration: Option<crate::types::Decimal>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl FreqDroop {
/// Creates a `FreqDroop` from its required fields.
#[must_use]
pub fn new(
priority: i32,
over_freq: impl Into<crate::types::Decimal>,
under_freq: impl Into<crate::types::Decimal>,
over_droop: impl Into<crate::types::Decimal>,
under_droop: impl Into<crate::types::Decimal>,
response_time: impl Into<crate::types::Decimal>,
) -> Self {
Self {
priority,
over_freq: over_freq.into(),
under_freq: under_freq.into(),
over_droop: over_droop.into(),
under_droop: under_droop.into(),
response_time: response_time.into(),
start_time: None,
duration: None,
custom_data: None,
}
}
/// Sets the optional `startTime` field.
#[must_use]
pub fn with_start_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.start_time = Some(value.into());
self
}
/// Sets the optional `duration` field.
#[must_use]
pub fn with_duration(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.duration = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for FreqDroop {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("priority");
validate::int_range(i64::from(self.priority), Some(0), None, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `FreqDroopGet` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FreqDroopGet {
/// The `freqDroop` member.
#[serde(rename = "freqDroop")]
pub freq_droop: FreqDroop,
/// Id of setting
pub id: String,
/// True if setting is a default control.
#[serde(rename = "isDefault")]
pub is_default: bool,
/// True if this setting is superseded by a higher priority setting (i.e. lower value of _priority_)
#[serde(rename = "isSuperseded")]
pub is_superseded: bool,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl FreqDroopGet {
/// Creates a `FreqDroopGet` from its required fields.
#[must_use]
pub fn new(
freq_droop: FreqDroop,
id: impl Into<String>,
is_default: bool,
is_superseded: bool,
) -> Self {
Self {
freq_droop,
id: id.into(),
is_default,
is_superseded,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for FreqDroopGet {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("freqDroop");
Validate::validate_at(&self.freq_droop, path, out);
path.pop();
path.push_key("id");
validate::string(self.id.as_str(), None, Some(36), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Class to hold parameters for GetVariables request.
///
/// The OCPP 2.1 `GetVariableData` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct GetVariableData {
/// The `component` member.
pub component: Component,
/// The `variable` member.
pub variable: Variable,
/// The `attributeType` member.
#[serde(rename = "attributeType")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub attribute_type: Option<Attribute>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl GetVariableData {
/// Creates a `GetVariableData` from its required fields.
#[must_use]
pub fn new(component: Component, variable: Variable) -> Self {
Self {
component,
variable,
attribute_type: None,
custom_data: None,
}
}
/// Sets the optional `attributeType` field.
#[must_use]
pub fn with_attribute_type(mut self, value: Attribute) -> Self {
self.attribute_type = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for GetVariableData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("component");
Validate::validate_at(&self.component, path, out);
path.pop();
path.push_key("variable");
Validate::validate_at(&self.variable, path, out);
path.pop();
path.push_key("attributeType");
if let Some(value) = &self.attribute_type {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Class to hold results of GetVariables request.
///
/// The OCPP 2.1 `GetVariableResult` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct GetVariableResult {
/// The `attributeStatus` member.
#[serde(rename = "attributeStatus")]
pub attribute_status: GetVariableStatus,
/// The `component` member.
pub component: Component,
/// The `variable` member.
pub variable: Variable,
/// The `attributeStatusInfo` member.
#[serde(rename = "attributeStatusInfo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub attribute_status_info: Option<StatusInfo>,
/// The `attributeType` member.
#[serde(rename = "attributeType")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub attribute_type: Option<Attribute>,
/// Value of requested attribute type of component-variable. This field can only be empty when the given status is NOT accepted.
///
/// The Configuration Variable <<configkey-reporting-value-size,ReportingValueSize>> can be used to limit GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max size of these values will always remain equal.
#[serde(rename = "attributeValue")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub attribute_value: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl GetVariableResult {
/// Creates a `GetVariableResult` from its required fields.
#[must_use]
pub fn new(
attribute_status: GetVariableStatus,
component: Component,
variable: Variable,
) -> Self {
Self {
attribute_status,
component,
variable,
attribute_status_info: None,
attribute_type: None,
attribute_value: None,
custom_data: None,
}
}
/// Sets the optional `attributeStatusInfo` field.
#[must_use]
pub fn with_attribute_status_info(mut self, value: StatusInfo) -> Self {
self.attribute_status_info = Some(value);
self
}
/// Sets the optional `attributeType` field.
#[must_use]
pub fn with_attribute_type(mut self, value: Attribute) -> Self {
self.attribute_type = Some(value);
self
}
/// Sets the optional `attributeValue` field.
#[must_use]
pub fn with_attribute_value(mut self, value: impl Into<String>) -> Self {
self.attribute_value = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for GetVariableResult {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("attributeStatus");
Validate::validate_at(&self.attribute_status, path, out);
path.pop();
path.push_key("component");
Validate::validate_at(&self.component, path, out);
path.pop();
path.push_key("variable");
Validate::validate_at(&self.variable, path, out);
path.pop();
path.push_key("attributeStatusInfo");
if let Some(value) = &self.attribute_status_info {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("attributeType");
if let Some(value) = &self.attribute_type {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("attributeValue");
if let Some(value) = &self.attribute_value {
validate::string(value.as_str(), None, Some(2500), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `Gradient` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Gradient {
/// Id of setting
#[serde(deserialize_with = "crate::types::integer::one")]
pub priority: i32,
/// Default ramp rate in seconds (0 if not applicable)
pub gradient: crate::types::Decimal,
/// Soft-start ramp rate in seconds (0 if not applicable)
#[serde(rename = "softGradient")]
pub soft_gradient: crate::types::Decimal,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl Gradient {
/// Creates a `Gradient` from its required fields.
#[must_use]
pub fn new(
priority: i32,
gradient: impl Into<crate::types::Decimal>,
soft_gradient: impl Into<crate::types::Decimal>,
) -> Self {
Self {
priority,
gradient: gradient.into(),
soft_gradient: soft_gradient.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for Gradient {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("priority");
validate::int_range(i64::from(self.priority), Some(0), None, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `GradientGet` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct GradientGet {
/// The `gradient` member.
pub gradient: Gradient,
/// Id of setting
pub id: String,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl GradientGet {
/// Creates a `GradientGet` from its required fields.
#[must_use]
pub fn new(gradient: Gradient, id: impl Into<String>) -> Self {
Self {
gradient,
id: id.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for GradientGet {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("gradient");
Validate::validate_at(&self.gradient, path, out);
path.pop();
path.push_key("id");
validate::string(self.id.as_str(), None, Some(36), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `Hysteresis` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Hysteresis {
/// High value for return to normal operation after a grid event, in absolute value. This value adopts the same unit as defined by yUnit
#[serde(rename = "hysteresisHigh")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub hysteresis_high: Option<crate::types::Decimal>,
/// Low value for return to normal operation after a grid event, in absolute value. This value adopts the same unit as defined by yUnit
#[serde(rename = "hysteresisLow")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub hysteresis_low: Option<crate::types::Decimal>,
/// Delay in seconds, once grid parameter within HysteresisLow and HysteresisHigh, for the EV to return to normal operation after a grid event.
#[serde(rename = "hysteresisDelay")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub hysteresis_delay: Option<crate::types::Decimal>,
/// Set default rate of change (ramp rate %/s) for the EV to return to normal operation after a grid event
#[serde(rename = "hysteresisGradient")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub hysteresis_gradient: Option<crate::types::Decimal>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl Hysteresis {
/// Creates an empty `Hysteresis`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `hysteresisHigh` field.
#[must_use]
pub fn with_hysteresis_high(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.hysteresis_high = Some(value.into());
self
}
/// Sets the optional `hysteresisLow` field.
#[must_use]
pub fn with_hysteresis_low(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.hysteresis_low = Some(value.into());
self
}
/// Sets the optional `hysteresisDelay` field.
#[must_use]
pub fn with_hysteresis_delay(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.hysteresis_delay = Some(value.into());
self
}
/// Sets the optional `hysteresisGradient` field.
#[must_use]
pub fn with_hysteresis_gradient(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.hysteresis_gradient = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for Hysteresis {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.
///
/// The OCPP 2.1 `IdToken` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct IdToken {
/// *(2.1)* IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.
#[serde(rename = "idToken")]
pub id_token: String,
/// *(2.1)* Enumeration of possible idToken types. Values defined in Appendix as IdTokenEnumStringType.
pub r#type: String,
/// The `additionalInfo` member.
#[serde(rename = "additionalInfo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub additional_info: Option<Vec<AdditionalInfo>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl IdToken {
/// Creates a `IdToken` from its required fields.
#[must_use]
pub fn new(id_token: impl Into<String>, r#type: impl Into<String>) -> Self {
Self {
id_token: id_token.into(),
r#type: r#type.into(),
additional_info: None,
custom_data: None,
}
}
/// Sets the optional `additionalInfo` field.
#[must_use]
pub fn with_additional_info(mut self, value: Vec<AdditionalInfo>) -> Self {
self.additional_info = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for IdToken {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("idToken");
validate::string(self.id_token.as_str(), None, Some(255), path, out);
path.pop();
path.push_key("type");
validate::string(self.r#type.as_str(), None, Some(20), path, out);
path.pop();
path.push_key("additionalInfo");
if let Some(value) = &self.additional_info {
validate::list_len(value.len(), Some(1), None, path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Contains status information about an identifier.
/// It is advised to not stop charging for a token that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not given, the status has no end date.
///
/// The OCPP 2.1 `IdTokenInfo` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct IdTokenInfo {
/// The `status` member.
pub status: AuthorizationStatus,
/// Date and Time after which the token must be considered invalid.
#[serde(rename = "cacheExpiryDateTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub cache_expiry_date_time: Option<crate::types::DateTime>,
/// Priority from a business point of view. Default priority is 0, The range is from -9 to 9. Higher values indicate a higher priority. The chargingPriority in <<transactioneventresponse,TransactionEventResponse>> overrules this one.
#[serde(rename = "chargingPriority")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub charging_priority: Option<i32>,
/// The `groupIdToken` member.
#[serde(rename = "groupIdToken")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub group_id_token: Option<IdToken>,
/// Preferred user interface language of identifier user. Contains a language code as defined in <<ref-RFC5646,\[RFC5646\]>>.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub language1: Option<String>,
/// Second preferred user interface language of identifier user. Don’t use when language1 is omitted, has to be different from language1. Contains a language code as defined in <<ref-RFC5646,\[RFC5646\]>>.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub language2: Option<String>,
/// Only used when the IdToken is only valid for one or more specific EVSEs, not for the entire Charging Station.
#[serde(rename = "evseId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option_list")]
pub evse_id: Option<Vec<i32>>,
/// The `personalMessage` member.
#[serde(rename = "personalMessage")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub personal_message: Option<MessageContent>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl IdTokenInfo {
/// Creates a `IdTokenInfo` from its required fields.
#[must_use]
pub fn new(status: AuthorizationStatus) -> Self {
Self {
status,
cache_expiry_date_time: None,
charging_priority: None,
group_id_token: None,
language1: None,
language2: None,
evse_id: None,
personal_message: None,
custom_data: None,
}
}
/// Sets the optional `cacheExpiryDateTime` field.
#[must_use]
pub fn with_cache_expiry_date_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.cache_expiry_date_time = Some(value.into());
self
}
/// Sets the optional `chargingPriority` field.
#[must_use]
pub fn with_charging_priority(mut self, value: i32) -> Self {
self.charging_priority = Some(value);
self
}
/// Sets the optional `groupIdToken` field.
#[must_use]
pub fn with_group_id_token(mut self, value: IdToken) -> Self {
self.group_id_token = Some(value);
self
}
/// Sets the optional `language1` field.
#[must_use]
pub fn with_language1(mut self, value: impl Into<String>) -> Self {
self.language1 = Some(value.into());
self
}
/// Sets the optional `language2` field.
#[must_use]
pub fn with_language2(mut self, value: impl Into<String>) -> Self {
self.language2 = Some(value.into());
self
}
/// Sets the optional `evseId` field.
#[must_use]
pub fn with_evse_id(mut self, value: Vec<i32>) -> Self {
self.evse_id = Some(value);
self
}
/// Sets the optional `personalMessage` field.
#[must_use]
pub fn with_personal_message(mut self, value: MessageContent) -> Self {
self.personal_message = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for IdTokenInfo {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("status");
Validate::validate_at(&self.status, path, out);
path.pop();
path.push_key("groupIdToken");
if let Some(value) = &self.group_id_token {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("language1");
if let Some(value) = &self.language1 {
validate::string(value.as_str(), None, Some(8), path, out);
}
path.pop();
path.push_key("language2");
if let Some(value) = &self.language2 {
validate::string(value.as_str(), None, Some(8), path, out);
}
path.pop();
path.push_key("evseId");
if let Some(value) = &self.evse_id {
validate::list_len(value.len(), Some(1), None, path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
validate::int_range(i64::from(*item), Some(0), None, path, out);
path.pop();
}
}
path.pop();
path.push_key("personalMessage");
if let Some(value) = &self.personal_message {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `LimitAtSoC` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct LimitAtSoC {
/// The SoC value beyond which the charging rate limit should be applied.
#[serde(deserialize_with = "crate::types::integer::one")]
pub soc: i32,
/// Charging rate limit beyond the SoC value.
/// The unit is defined by _chargingSchedule.chargingRateUnit_.
pub limit: crate::types::Decimal,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl LimitAtSoC {
/// Creates a `LimitAtSoC` from its required fields.
#[must_use]
pub fn new(soc: i32, limit: impl Into<crate::types::Decimal>) -> Self {
Self {
soc,
limit: limit.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for LimitAtSoC {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("soc");
validate::int_range(i64::from(self.soc), Some(0), Some(100), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `LimitMaxDischarge` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct LimitMaxDischarge {
/// Priority of setting (0=highest)
#[serde(deserialize_with = "crate::types::integer::one")]
pub priority: i32,
/// Only for PowerMonitoring. +
/// The value specifies a percentage (0 to 100) of the rated maximum discharge power of EV.
/// The PowerMonitoring curve becomes active when power exceeds this percentage.
#[serde(rename = "pctMaxDischargePower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pct_max_discharge_power: Option<crate::types::Decimal>,
/// The `powerMonitoringMustTrip` member.
#[serde(rename = "powerMonitoringMustTrip")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub power_monitoring_must_trip: Option<DERCurve>,
/// Time when this setting becomes active
#[serde(rename = "startTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub start_time: Option<crate::types::DateTime>,
/// Duration in seconds that this setting is active
#[serde(default, skip_serializing_if = "Option::is_none")]
pub duration: Option<crate::types::Decimal>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl LimitMaxDischarge {
/// Creates a `LimitMaxDischarge` from its required fields.
#[must_use]
pub fn new(priority: i32) -> Self {
Self {
priority,
pct_max_discharge_power: None,
power_monitoring_must_trip: None,
start_time: None,
duration: None,
custom_data: None,
}
}
/// Sets the optional `pctMaxDischargePower` field.
#[must_use]
pub fn with_pct_max_discharge_power(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.pct_max_discharge_power = Some(value.into());
self
}
/// Sets the optional `powerMonitoringMustTrip` field.
#[must_use]
pub fn with_power_monitoring_must_trip(mut self, value: DERCurve) -> Self {
self.power_monitoring_must_trip = Some(value);
self
}
/// Sets the optional `startTime` field.
#[must_use]
pub fn with_start_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.start_time = Some(value.into());
self
}
/// Sets the optional `duration` field.
#[must_use]
pub fn with_duration(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.duration = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for LimitMaxDischarge {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("priority");
validate::int_range(i64::from(self.priority), Some(0), None, path, out);
path.pop();
path.push_key("powerMonitoringMustTrip");
if let Some(value) = &self.power_monitoring_must_trip {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `LimitMaxDischargeGet` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct LimitMaxDischargeGet {
/// Id of setting
pub id: String,
/// True if setting is a default control.
#[serde(rename = "isDefault")]
pub is_default: bool,
/// True if this setting is superseded by a higher priority setting (i.e. lower value of _priority_)
#[serde(rename = "isSuperseded")]
pub is_superseded: bool,
/// The `limitMaxDischarge` member.
#[serde(rename = "limitMaxDischarge")]
pub limit_max_discharge: LimitMaxDischarge,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl LimitMaxDischargeGet {
/// Creates a `LimitMaxDischargeGet` from its required fields.
#[must_use]
pub fn new(
id: impl Into<String>,
is_default: bool,
is_superseded: bool,
limit_max_discharge: LimitMaxDischarge,
) -> Self {
Self {
id: id.into(),
is_default,
is_superseded,
limit_max_discharge,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for LimitMaxDischargeGet {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("id");
validate::string(self.id.as_str(), None, Some(36), path, out);
path.pop();
path.push_key("limitMaxDischarge");
Validate::validate_at(&self.limit_max_discharge, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Generic class for the configuration of logging entries.
///
/// The OCPP 2.1 `LogParameters` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct LogParameters {
/// The URL of the location at the remote system where the log should be stored.
#[serde(rename = "remoteLocation")]
pub remote_location: String,
/// This contains the date and time of the oldest logging information to include in the diagnostics.
#[serde(rename = "oldestTimestamp")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub oldest_timestamp: Option<crate::types::DateTime>,
/// This contains the date and time of the latest logging information to include in the diagnostics.
#[serde(rename = "latestTimestamp")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub latest_timestamp: Option<crate::types::DateTime>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl LogParameters {
/// Creates a `LogParameters` from its required fields.
#[must_use]
pub fn new(remote_location: impl Into<String>) -> Self {
Self {
remote_location: remote_location.into(),
oldest_timestamp: None,
latest_timestamp: None,
custom_data: None,
}
}
/// Sets the optional `oldestTimestamp` field.
#[must_use]
pub fn with_oldest_timestamp(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.oldest_timestamp = Some(value.into());
self
}
/// Sets the optional `latestTimestamp` field.
#[must_use]
pub fn with_latest_timestamp(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.latest_timestamp = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for LogParameters {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("remoteLocation");
validate::string(self.remote_location.as_str(), None, Some(2000), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Contains message details, for a message to be displayed on a Charging Station.
///
/// The OCPP 2.1 `MessageContent` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageContent {
/// The `format` member.
pub format: MessageFormat,
/// *(2.1)* Required. Message contents. +
/// Maximum length supported by Charging Station is given in OCPPCommCtrlr.FieldLength\["MessageContentType.content"\].
/// Maximum length defaults to 1024.
pub content: String,
/// Message language identifier. Contains a language code as defined in <<ref-RFC5646,\[RFC5646\]>>.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl MessageContent {
/// Creates a `MessageContent` from its required fields.
#[must_use]
pub fn new(format: MessageFormat, content: impl Into<String>) -> Self {
Self {
format,
content: content.into(),
language: None,
custom_data: None,
}
}
/// Sets the optional `language` field.
#[must_use]
pub fn with_language(mut self, value: impl Into<String>) -> Self {
self.language = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for MessageContent {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("format");
Validate::validate_at(&self.format, path, out);
path.pop();
path.push_key("content");
validate::string(self.content.as_str(), None, Some(1024), path, out);
path.pop();
path.push_key("language");
if let Some(value) = &self.language {
validate::string(value.as_str(), None, Some(8), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Contains message details, for a message to be displayed on a Charging Station.
///
/// The OCPP 2.1 `MessageInfo` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageInfo {
/// Unique id within an exchange context. It is defined within the OCPP context as a positive Integer value (greater or equal to zero).
#[serde(deserialize_with = "crate::types::integer::one")]
pub id: i32,
/// The `priority` member.
pub priority: MessagePriority,
/// The `message` member.
pub message: MessageContent,
/// The `display` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub display: Option<Component>,
/// The `state` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub state: Option<MessageState>,
/// From what date-time should this message be shown. If omitted: directly.
#[serde(rename = "startDateTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub start_date_time: Option<crate::types::DateTime>,
/// Until what date-time should this message be shown, after this date/time this message SHALL be removed.
#[serde(rename = "endDateTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub end_date_time: Option<crate::types::DateTime>,
/// During which transaction shall this message be shown.
/// Message SHALL be removed by the Charging Station after transaction has
/// ended.
#[serde(rename = "transactionId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub transaction_id: Option<String>,
/// The `messageExtra` member.
#[serde(rename = "messageExtra")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub message_extra: Option<Vec<MessageContent>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl MessageInfo {
/// Creates a `MessageInfo` from its required fields.
#[must_use]
pub fn new(id: i32, priority: MessagePriority, message: MessageContent) -> Self {
Self {
id,
priority,
message,
display: None,
state: None,
start_date_time: None,
end_date_time: None,
transaction_id: None,
message_extra: None,
custom_data: None,
}
}
/// Sets the optional `display` field.
#[must_use]
pub fn with_display(mut self, value: Component) -> Self {
self.display = Some(value);
self
}
/// Sets the optional `state` field.
#[must_use]
pub fn with_state(mut self, value: MessageState) -> Self {
self.state = Some(value);
self
}
/// Sets the optional `startDateTime` field.
#[must_use]
pub fn with_start_date_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.start_date_time = Some(value.into());
self
}
/// Sets the optional `endDateTime` field.
#[must_use]
pub fn with_end_date_time(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.end_date_time = Some(value.into());
self
}
/// Sets the optional `transactionId` field.
#[must_use]
pub fn with_transaction_id(mut self, value: impl Into<String>) -> Self {
self.transaction_id = Some(value.into());
self
}
/// Sets the optional `messageExtra` field.
#[must_use]
pub fn with_message_extra(mut self, value: Vec<MessageContent>) -> Self {
self.message_extra = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for MessageInfo {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("id");
validate::int_range(i64::from(self.id), Some(0), None, path, out);
path.pop();
path.push_key("priority");
Validate::validate_at(&self.priority, path, out);
path.pop();
path.push_key("message");
Validate::validate_at(&self.message, path, out);
path.pop();
path.push_key("display");
if let Some(value) = &self.display {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("state");
if let Some(value) = &self.state {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("transactionId");
if let Some(value) = &self.transaction_id {
validate::string(value.as_str(), None, Some(36), path, out);
}
path.pop();
path.push_key("messageExtra");
if let Some(value) = &self.message_extra {
validate::list_len(value.len(), Some(1), Some(4), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All sampled values in a MeterValue are sampled at the same point in time.
///
/// The OCPP 2.1 `MeterValue` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MeterValue {
/// The `sampledValue` member.
#[serde(rename = "sampledValue")]
pub sampled_value: Vec<SampledValue>,
/// Timestamp for measured value(s).
pub timestamp: crate::types::DateTime,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl MeterValue {
/// Creates a `MeterValue` from its required fields.
#[must_use]
pub fn new(
sampled_value: Vec<SampledValue>,
timestamp: impl Into<crate::types::DateTime>,
) -> Self {
Self {
sampled_value,
timestamp: timestamp.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for MeterValue {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("sampledValue");
validate::list_len(self.sampled_value.len(), Some(1), None, path, out);
for (index, item) in self.sampled_value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Defines parameters required for initiating and maintaining wireless communication with other devices.
///
/// The OCPP 2.1 `Modem` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Modem {
/// This contains the ICCID of the modem’s SIM card.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub iccid: Option<String>,
/// This contains the IMSI of the modem’s SIM card.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub imsi: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl Modem {
/// Creates an empty `Modem`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `iccid` field.
#[must_use]
pub fn with_iccid(mut self, value: impl Into<String>) -> Self {
self.iccid = Some(value.into());
self
}
/// Sets the optional `imsi` field.
#[must_use]
pub fn with_imsi(mut self, value: impl Into<String>) -> Self {
self.imsi = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for Modem {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("iccid");
if let Some(value) = &self.iccid {
validate::string(value.as_str(), None, Some(20), path, out);
}
path.pop();
path.push_key("imsi");
if let Some(value) = &self.imsi {
validate::string(value.as_str(), None, Some(20), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Class to hold parameters of SetVariableMonitoring request.
///
/// The OCPP 2.1 `MonitoringData` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MonitoringData {
/// The `component` member.
pub component: Component,
/// The `variable` member.
pub variable: Variable,
/// The `variableMonitoring` member.
#[serde(rename = "variableMonitoring")]
pub variable_monitoring: Vec<VariableMonitoring>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl MonitoringData {
/// Creates a `MonitoringData` from its required fields.
#[must_use]
pub fn new(
component: Component,
variable: Variable,
variable_monitoring: Vec<VariableMonitoring>,
) -> Self {
Self {
component,
variable,
variable_monitoring,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for MonitoringData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("component");
Validate::validate_at(&self.component, path, out);
path.pop();
path.push_key("variable");
Validate::validate_at(&self.variable, path, out);
path.pop();
path.push_key("variableMonitoring");
validate::list_len(self.variable_monitoring.len(), Some(1), None, path, out);
for (index, item) in self.variable_monitoring.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The NetworkConnectionProfile defines the functional and technical parameters of a communication link.
///
/// The OCPP 2.1 `NetworkConnectionProfile` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct NetworkConnectionProfile {
/// The `ocppInterface` member.
#[serde(rename = "ocppInterface")]
pub ocpp_interface: OCPPInterface,
/// The `ocppTransport` member.
#[serde(rename = "ocppTransport")]
pub ocpp_transport: OCPPTransport,
/// Duration in seconds before a message send by the Charging Station via this network connection times-out.
/// The best setting depends on the underlying network and response times of the CSMS.
/// If you are looking for a some guideline: use 30 seconds as a starting point.
#[serde(rename = "messageTimeout")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub message_timeout: i32,
/// URL of the CSMS(s) that this Charging Station communicates with, without the Charging Station identity part. +
/// The SecurityCtrlr.Identity field is appended to _ocppCsmsUrl_ to provide the full websocket URL.
#[serde(rename = "ocppCsmsUrl")]
pub ocpp_csms_url: String,
/// This field specifies the security profile used when connecting to the CSMS with this NetworkConnectionProfile.
#[serde(rename = "securityProfile")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub security_profile: i32,
/// The `apn` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub apn: Option<APN>,
/// The `ocppVersion` member.
#[serde(rename = "ocppVersion")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ocpp_version: Option<OCPPVersion>,
/// *(2.1)* Charging Station identity to be used as the basic authentication username.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub identity: Option<String>,
/// *(2.1)* BasicAuthPassword to use for security profile 1 or 2.
#[serde(rename = "basicAuthPassword")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub basic_auth_password: Option<String>,
/// The `vpn` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vpn: Option<VPN>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl NetworkConnectionProfile {
/// Creates a `NetworkConnectionProfile` from its required fields.
#[must_use]
pub fn new(
ocpp_interface: OCPPInterface,
ocpp_transport: OCPPTransport,
message_timeout: i32,
ocpp_csms_url: impl Into<String>,
security_profile: i32,
) -> Self {
Self {
ocpp_interface,
ocpp_transport,
message_timeout,
ocpp_csms_url: ocpp_csms_url.into(),
security_profile,
apn: None,
ocpp_version: None,
identity: None,
basic_auth_password: None,
vpn: None,
custom_data: None,
}
}
/// Sets the optional `apn` field.
#[must_use]
pub fn with_apn(mut self, value: APN) -> Self {
self.apn = Some(value);
self
}
/// Sets the optional `ocppVersion` field.
#[must_use]
pub fn with_ocpp_version(mut self, value: OCPPVersion) -> Self {
self.ocpp_version = Some(value);
self
}
/// Sets the optional `identity` field.
#[must_use]
pub fn with_identity(mut self, value: impl Into<String>) -> Self {
self.identity = Some(value.into());
self
}
/// Sets the optional `basicAuthPassword` field.
#[must_use]
pub fn with_basic_auth_password(mut self, value: impl Into<String>) -> Self {
self.basic_auth_password = Some(value.into());
self
}
/// Sets the optional `vpn` field.
#[must_use]
pub fn with_vpn(mut self, value: VPN) -> Self {
self.vpn = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for NetworkConnectionProfile {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("ocppInterface");
Validate::validate_at(&self.ocpp_interface, path, out);
path.pop();
path.push_key("ocppTransport");
Validate::validate_at(&self.ocpp_transport, path, out);
path.pop();
path.push_key("ocppCsmsUrl");
validate::string(self.ocpp_csms_url.as_str(), None, Some(2000), path, out);
path.pop();
path.push_key("securityProfile");
validate::int_range(i64::from(self.security_profile), Some(0), None, path, out);
path.pop();
path.push_key("apn");
if let Some(value) = &self.apn {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("ocppVersion");
if let Some(value) = &self.ocpp_version {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("identity");
if let Some(value) = &self.identity {
validate::string(value.as_str(), None, Some(48), path, out);
}
path.pop();
path.push_key("basicAuthPassword");
if let Some(value) = &self.basic_auth_password {
validate::string(value.as_str(), None, Some(64), path, out);
}
path.pop();
path.push_key("vpn");
if let Some(value) = &self.vpn {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Information about a certificate for an OCSP check.
///
/// The OCPP 2.1 `OCSPRequestData` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct OCSPRequestData {
/// The `hashAlgorithm` member.
#[serde(rename = "hashAlgorithm")]
pub hash_algorithm: HashAlgorithm,
/// The hash of the issuer’s distinguished
/// name (DN), that must be calculated over the DER
/// encoding of the issuer’s name field in the certificate
/// being checked.
#[serde(rename = "issuerNameHash")]
pub issuer_name_hash: String,
/// The hash of the DER encoded public key:
/// the value (excluding tag and length) of the subject
/// public key field in the issuer’s certificate.
#[serde(rename = "issuerKeyHash")]
pub issuer_key_hash: String,
/// The string representation of the
/// hexadecimal value of the serial number without the
/// prefix "0x" and without leading zeroes.
#[serde(rename = "serialNumber")]
pub serial_number: String,
/// This contains the responder URL (Case insensitive).
#[serde(rename = "responderURL")]
pub responder_url: String,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl OCSPRequestData {
/// Creates a `OCSPRequestData` from its required fields.
#[must_use]
pub fn new(
hash_algorithm: HashAlgorithm,
issuer_name_hash: impl Into<String>,
issuer_key_hash: impl Into<String>,
serial_number: impl Into<String>,
responder_url: impl Into<String>,
) -> Self {
Self {
hash_algorithm,
issuer_name_hash: issuer_name_hash.into(),
issuer_key_hash: issuer_key_hash.into(),
serial_number: serial_number.into(),
responder_url: responder_url.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for OCSPRequestData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("hashAlgorithm");
Validate::validate_at(&self.hash_algorithm, path, out);
path.pop();
path.push_key("issuerNameHash");
validate::string(self.issuer_name_hash.as_str(), None, Some(128), path, out);
path.pop();
path.push_key("issuerKeyHash");
validate::string(self.issuer_key_hash.as_str(), None, Some(128), path, out);
path.pop();
path.push_key("serialNumber");
validate::string(self.serial_number.as_str(), None, Some(40), path, out);
path.pop();
path.push_key("responderURL");
validate::string(self.responder_url.as_str(), None, Some(2000), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Part of ISO 15118-20 price schedule.
///
/// The OCPP 2.1 `OverstayRule` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct OverstayRule {
/// The `overstayFee` member.
#[serde(rename = "overstayFee")]
pub overstay_fee: RationalNumber,
/// Time in seconds after trigger of the parent Overstay Rules for this particular fee to apply.
#[serde(rename = "startTime")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub start_time: i32,
/// Time till overstay will be reapplied
#[serde(rename = "overstayFeePeriod")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub overstay_fee_period: i32,
/// Human readable string to identify the overstay rule.
#[serde(rename = "overstayRuleDescription")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub overstay_rule_description: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl OverstayRule {
/// Creates a `OverstayRule` from its required fields.
#[must_use]
pub fn new(overstay_fee: RationalNumber, start_time: i32, overstay_fee_period: i32) -> Self {
Self {
overstay_fee,
start_time,
overstay_fee_period,
overstay_rule_description: None,
custom_data: None,
}
}
/// Sets the optional `overstayRuleDescription` field.
#[must_use]
pub fn with_overstay_rule_description(mut self, value: impl Into<String>) -> Self {
self.overstay_rule_description = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for OverstayRule {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("overstayFee");
Validate::validate_at(&self.overstay_fee, path, out);
path.pop();
path.push_key("overstayRuleDescription");
if let Some(value) = &self.overstay_rule_description {
validate::string(value.as_str(), None, Some(32), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Part of ISO 15118-20 price schedule.
///
/// The OCPP 2.1 `OverstayRuleList` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct OverstayRuleList {
/// The `overstayRule` member.
#[serde(rename = "overstayRule")]
pub overstay_rule: Vec<OverstayRule>,
/// The `overstayPowerThreshold` member.
#[serde(rename = "overstayPowerThreshold")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub overstay_power_threshold: Option<RationalNumber>,
/// Time till overstay is applied in seconds.
#[serde(rename = "overstayTimeThreshold")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub overstay_time_threshold: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl OverstayRuleList {
/// Creates a `OverstayRuleList` from its required fields.
#[must_use]
pub fn new(overstay_rule: Vec<OverstayRule>) -> Self {
Self {
overstay_rule,
overstay_power_threshold: None,
overstay_time_threshold: None,
custom_data: None,
}
}
/// Sets the optional `overstayPowerThreshold` field.
#[must_use]
pub fn with_overstay_power_threshold(mut self, value: RationalNumber) -> Self {
self.overstay_power_threshold = Some(value);
self
}
/// Sets the optional `overstayTimeThreshold` field.
#[must_use]
pub fn with_overstay_time_threshold(mut self, value: i32) -> Self {
self.overstay_time_threshold = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for OverstayRuleList {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("overstayRule");
validate::list_len(self.overstay_rule.len(), Some(1), Some(5), path, out);
for (index, item) in self.overstay_rule.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("overstayPowerThreshold");
if let Some(value) = &self.overstay_power_threshold {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `PeriodicEventStreamParams` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PeriodicEventStreamParams {
/// Time in seconds after which stream data is sent.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub interval: Option<i32>,
/// Number of items to be sent together in stream.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub values: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl PeriodicEventStreamParams {
/// Creates an empty `PeriodicEventStreamParams`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `interval` field.
#[must_use]
pub fn with_interval(mut self, value: i32) -> Self {
self.interval = Some(value);
self
}
/// Sets the optional `values` field.
#[must_use]
pub fn with_values(mut self, value: i32) -> Self {
self.values = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for PeriodicEventStreamParams {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("interval");
if let Some(value) = &self.interval {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("values");
if let Some(value) = &self.values {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Price with and without tax. At least one of _exclTax_, _inclTax_ must be present.
///
/// The OCPP 2.1 `Price` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Price {
/// Price/cost excluding tax. Can be absent if _inclTax_ is present.
#[serde(rename = "exclTax")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub excl_tax: Option<crate::types::Decimal>,
/// Price/cost including tax. Can be absent if _exclTax_ is present.
#[serde(rename = "inclTax")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub incl_tax: Option<crate::types::Decimal>,
/// The `taxRates` member.
#[serde(rename = "taxRates")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tax_rates: Option<Vec<TaxRate>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl Price {
/// Creates an empty `Price`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `exclTax` field.
#[must_use]
pub fn with_excl_tax(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.excl_tax = Some(value.into());
self
}
/// Sets the optional `inclTax` field.
#[must_use]
pub fn with_incl_tax(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.incl_tax = Some(value.into());
self
}
/// Sets the optional `taxRates` field.
#[must_use]
pub fn with_tax_rates(mut self, value: Vec<TaxRate>) -> Self {
self.tax_rates = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for Price {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("taxRates");
if let Some(value) = &self.tax_rates {
validate::list_len(value.len(), Some(1), Some(5), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The PriceLevelScheduleType is modeled after the same type that is defined in ISO 15118-20, such that if it is supplied by an EMSP as a signed EXI message, the conversion from EXI to JSON (in OCPP) and back to EXI (for ISO 15118-20) does not change the digest and therefore does not invalidate the signature.
///
/// The OCPP 2.1 `PriceLevelSchedule` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct PriceLevelSchedule {
/// The `priceLevelScheduleEntries` member.
#[serde(rename = "priceLevelScheduleEntries")]
pub price_level_schedule_entries: Vec<PriceLevelScheduleEntry>,
/// Starting point of this price schedule.
#[serde(rename = "timeAnchor")]
pub time_anchor: crate::types::DateTime,
/// Unique ID of this price schedule.
#[serde(rename = "priceScheduleId")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub price_schedule_id: i32,
/// Defines the overall number of distinct price level elements used across all PriceLevelSchedules.
#[serde(rename = "numberOfPriceLevels")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub number_of_price_levels: i32,
/// Description of the price schedule.
#[serde(rename = "priceScheduleDescription")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub price_schedule_description: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl PriceLevelSchedule {
/// Creates a `PriceLevelSchedule` from its required fields.
#[must_use]
pub fn new(
price_level_schedule_entries: Vec<PriceLevelScheduleEntry>,
time_anchor: impl Into<crate::types::DateTime>,
price_schedule_id: i32,
number_of_price_levels: i32,
) -> Self {
Self {
price_level_schedule_entries,
time_anchor: time_anchor.into(),
price_schedule_id,
number_of_price_levels,
price_schedule_description: None,
custom_data: None,
}
}
/// Sets the optional `priceScheduleDescription` field.
#[must_use]
pub fn with_price_schedule_description(mut self, value: impl Into<String>) -> Self {
self.price_schedule_description = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for PriceLevelSchedule {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("priceLevelScheduleEntries");
validate::list_len(
self.price_level_schedule_entries.len(),
Some(1),
Some(100),
path,
out,
);
for (index, item) in self.price_level_schedule_entries.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("priceScheduleId");
validate::int_range(i64::from(self.price_schedule_id), Some(0), None, path, out);
path.pop();
path.push_key("numberOfPriceLevels");
validate::int_range(
i64::from(self.number_of_price_levels),
Some(0),
None,
path,
out,
);
path.pop();
path.push_key("priceScheduleDescription");
if let Some(value) = &self.price_schedule_description {
validate::string(value.as_str(), None, Some(32), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Part of ISO 15118-20 price schedule.
///
/// The OCPP 2.1 `PriceLevelScheduleEntry` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct PriceLevelScheduleEntry {
/// The amount of seconds that define the duration of this given PriceLevelScheduleEntry.
#[serde(deserialize_with = "crate::types::integer::one")]
pub duration: i32,
/// Defines the price level of this PriceLevelScheduleEntry (referring to NumberOfPriceLevels). Small values for the PriceLevel represent a cheaper PriceLevelScheduleEntry. Large values for the PriceLevel represent a more expensive PriceLevelScheduleEntry.
#[serde(rename = "priceLevel")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub price_level: i32,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl PriceLevelScheduleEntry {
/// Creates a `PriceLevelScheduleEntry` from its required fields.
#[must_use]
pub fn new(duration: i32, price_level: i32) -> Self {
Self {
duration,
price_level,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for PriceLevelScheduleEntry {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("priceLevel");
validate::int_range(i64::from(self.price_level), Some(0), None, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Part of ISO 15118-20 price schedule.
///
/// The OCPP 2.1 `PriceRule` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct PriceRule {
/// The `energyFee` member.
#[serde(rename = "energyFee")]
pub energy_fee: RationalNumber,
/// The `powerRangeStart` member.
#[serde(rename = "powerRangeStart")]
pub power_range_start: RationalNumber,
/// The duration of the parking fee period (in seconds).
/// When the time enters into a ParkingFeePeriod, the ParkingFee will apply to the session. .
#[serde(rename = "parkingFeePeriod")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub parking_fee_period: Option<i32>,
/// Number of grams of CO2 per kWh.
#[serde(rename = "carbonDioxideEmission")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub carbon_dioxide_emission: Option<i32>,
/// Percentage of the power that is created by renewable resources.
#[serde(rename = "renewableGenerationPercentage")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub renewable_generation_percentage: Option<i32>,
/// The `parkingFee` member.
#[serde(rename = "parkingFee")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub parking_fee: Option<RationalNumber>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl PriceRule {
/// Creates a `PriceRule` from its required fields.
#[must_use]
pub fn new(energy_fee: RationalNumber, power_range_start: RationalNumber) -> Self {
Self {
energy_fee,
power_range_start,
parking_fee_period: None,
carbon_dioxide_emission: None,
renewable_generation_percentage: None,
parking_fee: None,
custom_data: None,
}
}
/// Sets the optional `parkingFeePeriod` field.
#[must_use]
pub fn with_parking_fee_period(mut self, value: i32) -> Self {
self.parking_fee_period = Some(value);
self
}
/// Sets the optional `carbonDioxideEmission` field.
#[must_use]
pub fn with_carbon_dioxide_emission(mut self, value: i32) -> Self {
self.carbon_dioxide_emission = Some(value);
self
}
/// Sets the optional `renewableGenerationPercentage` field.
#[must_use]
pub fn with_renewable_generation_percentage(mut self, value: i32) -> Self {
self.renewable_generation_percentage = Some(value);
self
}
/// Sets the optional `parkingFee` field.
#[must_use]
pub fn with_parking_fee(mut self, value: RationalNumber) -> Self {
self.parking_fee = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for PriceRule {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("energyFee");
Validate::validate_at(&self.energy_fee, path, out);
path.pop();
path.push_key("powerRangeStart");
Validate::validate_at(&self.power_range_start, path, out);
path.pop();
path.push_key("carbonDioxideEmission");
if let Some(value) = &self.carbon_dioxide_emission {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("renewableGenerationPercentage");
if let Some(value) = &self.renewable_generation_percentage {
validate::int_range(i64::from(*value), Some(0), Some(100), path, out);
}
path.pop();
path.push_key("parkingFee");
if let Some(value) = &self.parking_fee {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Part of ISO 15118-20 price schedule.
///
/// The OCPP 2.1 `PriceRuleStack` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct PriceRuleStack {
/// Duration of the stack of price rules. he amount of seconds that define the duration of the given PriceRule(s).
#[serde(deserialize_with = "crate::types::integer::one")]
pub duration: i32,
/// The `priceRule` member.
#[serde(rename = "priceRule")]
pub price_rule: Vec<PriceRule>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl PriceRuleStack {
/// Creates a `PriceRuleStack` from its required fields.
#[must_use]
pub fn new(duration: i32, price_rule: Vec<PriceRule>) -> Self {
Self {
duration,
price_rule,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for PriceRuleStack {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("priceRule");
validate::list_len(self.price_rule.len(), Some(1), Some(8), path, out);
for (index, item) in self.price_rule.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Part of ISO 15118-20 price schedule.
///
/// The OCPP 2.1 `RationalNumber` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RationalNumber {
/// The exponent to base 10 (dec)
#[serde(deserialize_with = "crate::types::integer::one")]
pub exponent: i32,
/// Value which shall be multiplied.
#[serde(deserialize_with = "crate::types::integer::one")]
pub value: i32,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl RationalNumber {
/// Creates a `RationalNumber` from its required fields.
#[must_use]
pub fn new(exponent: i32, value: i32) -> Self {
Self {
exponent,
value,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for RationalNumber {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `ReactivePowerParams` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ReactivePowerParams {
/// Only for VoltVar curve: The nominal ac voltage (rms) adjustment to the voltage curve points for Volt-Var curves (percentage).
#[serde(rename = "vRef")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub v_ref: Option<crate::types::Decimal>,
/// Only for VoltVar: Enable/disable autonomous VRef adjustment
#[serde(rename = "autonomousVRefEnable")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub autonomous_v_ref_enable: Option<bool>,
/// Only for VoltVar: Adjustment range for VRef time constant
#[serde(rename = "autonomousVRefTimeConstant")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub autonomous_v_ref_time_constant: Option<crate::types::Decimal>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ReactivePowerParams {
/// Creates an empty `ReactivePowerParams`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `vRef` field.
#[must_use]
pub fn with_v_ref(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.v_ref = Some(value.into());
self
}
/// Sets the optional `autonomousVRefEnable` field.
#[must_use]
pub fn with_autonomous_v_ref_enable(mut self, value: bool) -> Self {
self.autonomous_v_ref_enable = Some(value);
self
}
/// Sets the optional `autonomousVRefTimeConstant` field.
#[must_use]
pub fn with_autonomous_v_ref_time_constant(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.autonomous_v_ref_time_constant = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ReactivePowerParams {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `RelativeTimeInterval` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RelativeTimeInterval {
/// Start of the interval, in seconds from NOW.
#[serde(deserialize_with = "crate::types::integer::one")]
pub start: i32,
/// Duration of the interval, in seconds.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub duration: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl RelativeTimeInterval {
/// Creates a `RelativeTimeInterval` from its required fields.
#[must_use]
pub fn new(start: i32) -> Self {
Self {
start,
duration: None,
custom_data: None,
}
}
/// Sets the optional `duration` field.
#[must_use]
pub fn with_duration(mut self, value: i32) -> Self {
self.duration = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for RelativeTimeInterval {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Class to report components, variables and variable attributes and characteristics.
///
/// The OCPP 2.1 `ReportData` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ReportData {
/// The `component` member.
pub component: Component,
/// The `variable` member.
pub variable: Variable,
/// The `variableAttribute` member.
#[serde(rename = "variableAttribute")]
pub variable_attribute: Vec<VariableAttribute>,
/// The `variableCharacteristics` member.
#[serde(rename = "variableCharacteristics")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub variable_characteristics: Option<VariableCharacteristics>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl ReportData {
/// Creates a `ReportData` from its required fields.
#[must_use]
pub fn new(
component: Component,
variable: Variable,
variable_attribute: Vec<VariableAttribute>,
) -> Self {
Self {
component,
variable,
variable_attribute,
variable_characteristics: None,
custom_data: None,
}
}
/// Sets the optional `variableCharacteristics` field.
#[must_use]
pub fn with_variable_characteristics(mut self, value: VariableCharacteristics) -> Self {
self.variable_characteristics = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for ReportData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("component");
Validate::validate_at(&self.component, path, out);
path.pop();
path.push_key("variable");
Validate::validate_at(&self.variable, path, out);
path.pop();
path.push_key("variableAttribute");
validate::list_len(self.variable_attribute.len(), Some(1), Some(4), path, out);
for (index, item) in self.variable_attribute.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("variableCharacteristics");
if let Some(value) = &self.variable_characteristics {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// A SalesTariff provided by a Mobility Operator (EMSP) .
/// NOTE: This dataType is based on dataTypes from <<ref-ISOIEC15118-2,ISO 15118-2>>.
///
/// The OCPP 2.1 `SalesTariff` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SalesTariff {
/// SalesTariff identifier used to identify one sales tariff. An SAID remains a unique identifier for one schedule throughout a charging session.
#[serde(deserialize_with = "crate::types::integer::one")]
pub id: i32,
/// The `salesTariffEntry` member.
#[serde(rename = "salesTariffEntry")]
pub sales_tariff_entry: Vec<SalesTariffEntry>,
/// A human readable title/short description of the sales tariff e.g. for HMI display purposes.
#[serde(rename = "salesTariffDescription")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sales_tariff_description: Option<String>,
/// Defines the overall number of distinct price levels used across all provided SalesTariff elements.
#[serde(rename = "numEPriceLevels")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub num_e_price_levels: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl SalesTariff {
/// Creates a `SalesTariff` from its required fields.
#[must_use]
pub fn new(id: i32, sales_tariff_entry: Vec<SalesTariffEntry>) -> Self {
Self {
id,
sales_tariff_entry,
sales_tariff_description: None,
num_e_price_levels: None,
custom_data: None,
}
}
/// Sets the optional `salesTariffDescription` field.
#[must_use]
pub fn with_sales_tariff_description(mut self, value: impl Into<String>) -> Self {
self.sales_tariff_description = Some(value.into());
self
}
/// Sets the optional `numEPriceLevels` field.
#[must_use]
pub fn with_num_e_price_levels(mut self, value: i32) -> Self {
self.num_e_price_levels = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for SalesTariff {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("id");
validate::int_range(i64::from(self.id), Some(0), None, path, out);
path.pop();
path.push_key("salesTariffEntry");
validate::list_len(
self.sales_tariff_entry.len(),
Some(1),
Some(1024),
path,
out,
);
for (index, item) in self.sales_tariff_entry.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("salesTariffDescription");
if let Some(value) = &self.sales_tariff_description {
validate::string(value.as_str(), None, Some(32), path, out);
}
path.pop();
path.push_key("numEPriceLevels");
if let Some(value) = &self.num_e_price_levels {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `SalesTariffEntry` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SalesTariffEntry {
/// The `relativeTimeInterval` member.
#[serde(rename = "relativeTimeInterval")]
pub relative_time_interval: RelativeTimeInterval,
/// Defines the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a more expensive TariffEntry.
#[serde(rename = "ePriceLevel")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub e_price_level: Option<i32>,
/// The `consumptionCost` member.
#[serde(rename = "consumptionCost")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub consumption_cost: Option<Vec<ConsumptionCost>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl SalesTariffEntry {
/// Creates a `SalesTariffEntry` from its required fields.
#[must_use]
pub fn new(relative_time_interval: RelativeTimeInterval) -> Self {
Self {
relative_time_interval,
e_price_level: None,
consumption_cost: None,
custom_data: None,
}
}
/// Sets the optional `ePriceLevel` field.
#[must_use]
pub fn with_e_price_level(mut self, value: i32) -> Self {
self.e_price_level = Some(value);
self
}
/// Sets the optional `consumptionCost` field.
#[must_use]
pub fn with_consumption_cost(mut self, value: Vec<ConsumptionCost>) -> Self {
self.consumption_cost = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for SalesTariffEntry {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("relativeTimeInterval");
Validate::validate_at(&self.relative_time_interval, path, out);
path.pop();
path.push_key("ePriceLevel");
if let Some(value) = &self.e_price_level {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("consumptionCost");
if let Some(value) = &self.consumption_cost {
validate::list_len(value.len(), Some(1), Some(3), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Single sampled value in MeterValues. Each value can be accompanied by optional fields.
///
/// To save on mobile data usage, default values of all of the optional fields are such that. The value without any additional fields will be interpreted, as a register reading of active import energy in Wh (Watt-hour) units.
///
/// The OCPP 2.1 `SampledValue` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SampledValue {
/// Indicates the measured value.
pub value: crate::types::Decimal,
/// The `measurand` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub measurand: Option<Measurand>,
/// The `context` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub context: Option<ReadingContext>,
/// The `phase` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub phase: Option<Phase>,
/// The `location` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub location: Option<Location>,
/// The `signedMeterValue` member.
#[serde(rename = "signedMeterValue")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub signed_meter_value: Option<SignedMeterValue>,
/// The `unitOfMeasure` member.
#[serde(rename = "unitOfMeasure")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub unit_of_measure: Option<UnitOfMeasure>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl SampledValue {
/// Creates a `SampledValue` from its required fields.
#[must_use]
pub fn new(value: impl Into<crate::types::Decimal>) -> Self {
Self {
value: value.into(),
measurand: None,
context: None,
phase: None,
location: None,
signed_meter_value: None,
unit_of_measure: None,
custom_data: None,
}
}
/// Sets the optional `measurand` field.
#[must_use]
pub fn with_measurand(mut self, value: Measurand) -> Self {
self.measurand = Some(value);
self
}
/// Sets the optional `context` field.
#[must_use]
pub fn with_context(mut self, value: ReadingContext) -> Self {
self.context = Some(value);
self
}
/// Sets the optional `phase` field.
#[must_use]
pub fn with_phase(mut self, value: Phase) -> Self {
self.phase = Some(value);
self
}
/// Sets the optional `location` field.
#[must_use]
pub fn with_location(mut self, value: Location) -> Self {
self.location = Some(value);
self
}
/// Sets the optional `signedMeterValue` field.
#[must_use]
pub fn with_signed_meter_value(mut self, value: SignedMeterValue) -> Self {
self.signed_meter_value = Some(value);
self
}
/// Sets the optional `unitOfMeasure` field.
#[must_use]
pub fn with_unit_of_measure(mut self, value: UnitOfMeasure) -> Self {
self.unit_of_measure = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for SampledValue {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("measurand");
if let Some(value) = &self.measurand {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("context");
if let Some(value) = &self.context {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("phase");
if let Some(value) = &self.phase {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("location");
if let Some(value) = &self.location {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("signedMeterValue");
if let Some(value) = &self.signed_meter_value {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("unitOfMeasure");
if let Some(value) = &self.unit_of_measure {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Class to hold parameters of SetVariableMonitoring request.
///
/// The OCPP 2.1 `SetMonitoringData` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SetMonitoringData {
/// Value for threshold or delta monitoring.
/// For Periodic or PeriodicClockAligned this is the interval in seconds.
pub value: crate::types::Decimal,
/// The `type` member.
pub r#type: Monitor,
/// The severity that will be assigned to an event that is triggered by this monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity level.
///
/// The severity levels have the following meaning: +
/// *0-Danger* +
/// Indicates lives are potentially in danger. Urgent attention is needed and action should be taken immediately. +
/// *1-Hardware Failure* +
/// Indicates that the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. +
/// *2-System Failure* +
/// Indicates that the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. +
/// *3-Critical* +
/// Indicates a critical error. Action is required. +
/// *4-Error* +
/// Indicates a non-urgent error. Action is required. +
/// *5-Alert* +
/// Indicates an alert event. Default severity for any type of monitoring event. +
/// *6-Warning* +
/// Indicates a warning event. Action may be required. +
/// *7-Notice* +
/// Indicates an unusual event. No immediate action is required. +
/// *8-Informational* +
/// Indicates a regular operational event. May be used for reporting, measuring throughput, etc. No action is required. +
/// *9-Debug* +
/// Indicates information useful to developers for debugging, not useful during operations.
#[serde(deserialize_with = "crate::types::integer::one")]
pub severity: i32,
/// The `component` member.
pub component: Component,
/// The `variable` member.
pub variable: Variable,
/// An id SHALL only be given to replace an existing monitor. The Charging Station handles the generation of id's for new monitors.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub id: Option<i32>,
/// The `periodicEventStream` member.
#[serde(rename = "periodicEventStream")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub periodic_event_stream: Option<PeriodicEventStreamParams>,
/// Monitor only active when a transaction is ongoing on a component relevant to this transaction. Default = false.
/// Schema default: `false`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub transaction: Option<bool>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl SetMonitoringData {
/// Creates a `SetMonitoringData` from its required fields.
#[must_use]
pub fn new(
value: impl Into<crate::types::Decimal>,
r#type: Monitor,
severity: i32,
component: Component,
variable: Variable,
) -> Self {
Self {
value: value.into(),
r#type,
severity,
component,
variable,
id: None,
periodic_event_stream: None,
transaction: None,
custom_data: None,
}
}
/// Sets the optional `id` field.
#[must_use]
pub fn with_id(mut self, value: i32) -> Self {
self.id = Some(value);
self
}
/// Sets the optional `periodicEventStream` field.
#[must_use]
pub fn with_periodic_event_stream(mut self, value: PeriodicEventStreamParams) -> Self {
self.periodic_event_stream = Some(value);
self
}
/// Sets the optional `transaction` field.
#[must_use]
pub fn with_transaction(mut self, value: bool) -> Self {
self.transaction = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for SetMonitoringData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("type");
Validate::validate_at(&self.r#type, path, out);
path.pop();
path.push_key("severity");
validate::int_range(i64::from(self.severity), Some(0), None, path, out);
path.pop();
path.push_key("component");
Validate::validate_at(&self.component, path, out);
path.pop();
path.push_key("variable");
Validate::validate_at(&self.variable, path, out);
path.pop();
path.push_key("id");
if let Some(value) = &self.id {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("periodicEventStream");
if let Some(value) = &self.periodic_event_stream {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Class to hold result of SetVariableMonitoring request.
///
/// The OCPP 2.1 `SetMonitoringResult` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SetMonitoringResult {
/// The `status` member.
pub status: SetMonitoringStatus,
/// The `type` member.
pub r#type: Monitor,
/// The `component` member.
pub component: Component,
/// The `variable` member.
pub variable: Variable,
/// The severity that will be assigned to an event that is triggered by this monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity level.
///
/// The severity levels have the following meaning: +
/// *0-Danger* +
/// Indicates lives are potentially in danger. Urgent attention is needed and action should be taken immediately. +
/// *1-Hardware Failure* +
/// Indicates that the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. +
/// *2-System Failure* +
/// Indicates that the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. +
/// *3-Critical* +
/// Indicates a critical error. Action is required. +
/// *4-Error* +
/// Indicates a non-urgent error. Action is required. +
/// *5-Alert* +
/// Indicates an alert event. Default severity for any type of monitoring event. +
/// *6-Warning* +
/// Indicates a warning event. Action may be required. +
/// *7-Notice* +
/// Indicates an unusual event. No immediate action is required. +
/// *8-Informational* +
/// Indicates a regular operational event. May be used for reporting, measuring throughput, etc. No action is required. +
/// *9-Debug* +
/// Indicates information useful to developers for debugging, not useful during operations.
#[serde(deserialize_with = "crate::types::integer::one")]
pub severity: i32,
/// Id given to the VariableMonitor by the Charging Station. The Id is only returned when status is accepted. Installed VariableMonitors should have unique id's but the id's of removed Installed monitors should have unique id's but the id's of removed monitors MAY be reused.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub id: Option<i32>,
/// The `statusInfo` member.
#[serde(rename = "statusInfo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub status_info: Option<StatusInfo>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl SetMonitoringResult {
/// Creates a `SetMonitoringResult` from its required fields.
#[must_use]
pub fn new(
status: SetMonitoringStatus,
r#type: Monitor,
component: Component,
variable: Variable,
severity: i32,
) -> Self {
Self {
status,
r#type,
component,
variable,
severity,
id: None,
status_info: None,
custom_data: None,
}
}
/// Sets the optional `id` field.
#[must_use]
pub fn with_id(mut self, value: i32) -> Self {
self.id = Some(value);
self
}
/// Sets the optional `statusInfo` field.
#[must_use]
pub fn with_status_info(mut self, value: StatusInfo) -> Self {
self.status_info = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for SetMonitoringResult {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("status");
Validate::validate_at(&self.status, path, out);
path.pop();
path.push_key("type");
Validate::validate_at(&self.r#type, path, out);
path.pop();
path.push_key("component");
Validate::validate_at(&self.component, path, out);
path.pop();
path.push_key("variable");
Validate::validate_at(&self.variable, path, out);
path.pop();
path.push_key("severity");
validate::int_range(i64::from(self.severity), Some(0), None, path, out);
path.pop();
path.push_key("id");
if let Some(value) = &self.id {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("statusInfo");
if let Some(value) = &self.status_info {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `SetVariableData` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SetVariableData {
/// Value to be assigned to attribute of variable.
/// This value is allowed to be an empty string ("").
///
/// The Configuration Variable <<configkey-configuration-value-size,ConfigurationValueSize>> can be used to limit SetVariableData.attributeValue and VariableCharacteristics.valuesList. The max size of these values will always remain equal.
#[serde(rename = "attributeValue")]
pub attribute_value: String,
/// The `component` member.
pub component: Component,
/// The `variable` member.
pub variable: Variable,
/// The `attributeType` member.
#[serde(rename = "attributeType")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub attribute_type: Option<Attribute>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl SetVariableData {
/// Creates a `SetVariableData` from its required fields.
#[must_use]
pub fn new(
attribute_value: impl Into<String>,
component: Component,
variable: Variable,
) -> Self {
Self {
attribute_value: attribute_value.into(),
component,
variable,
attribute_type: None,
custom_data: None,
}
}
/// Sets the optional `attributeType` field.
#[must_use]
pub fn with_attribute_type(mut self, value: Attribute) -> Self {
self.attribute_type = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for SetVariableData {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("attributeValue");
validate::string(self.attribute_value.as_str(), None, Some(2500), path, out);
path.pop();
path.push_key("component");
Validate::validate_at(&self.component, path, out);
path.pop();
path.push_key("variable");
Validate::validate_at(&self.variable, path, out);
path.pop();
path.push_key("attributeType");
if let Some(value) = &self.attribute_type {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `SetVariableResult` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SetVariableResult {
/// The `attributeStatus` member.
#[serde(rename = "attributeStatus")]
pub attribute_status: SetVariableStatus,
/// The `component` member.
pub component: Component,
/// The `variable` member.
pub variable: Variable,
/// The `attributeType` member.
#[serde(rename = "attributeType")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub attribute_type: Option<Attribute>,
/// The `attributeStatusInfo` member.
#[serde(rename = "attributeStatusInfo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub attribute_status_info: Option<StatusInfo>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl SetVariableResult {
/// Creates a `SetVariableResult` from its required fields.
#[must_use]
pub fn new(
attribute_status: SetVariableStatus,
component: Component,
variable: Variable,
) -> Self {
Self {
attribute_status,
component,
variable,
attribute_type: None,
attribute_status_info: None,
custom_data: None,
}
}
/// Sets the optional `attributeType` field.
#[must_use]
pub fn with_attribute_type(mut self, value: Attribute) -> Self {
self.attribute_type = Some(value);
self
}
/// Sets the optional `attributeStatusInfo` field.
#[must_use]
pub fn with_attribute_status_info(mut self, value: StatusInfo) -> Self {
self.attribute_status_info = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for SetVariableResult {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("attributeStatus");
Validate::validate_at(&self.attribute_status, path, out);
path.pop();
path.push_key("component");
Validate::validate_at(&self.component, path, out);
path.pop();
path.push_key("variable");
Validate::validate_at(&self.variable, path, out);
path.pop();
path.push_key("attributeType");
if let Some(value) = &self.attribute_type {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("attributeStatusInfo");
if let Some(value) = &self.attribute_status_info {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Represent a signed version of the meter value.
///
/// The OCPP 2.1 `SignedMeterValue` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SignedMeterValue {
/// Base64 encoded, contains the signed data from the meter in the format specified in _encodingMethod_, which might contain more then just the meter value. It can contain information like timestamps, reference to a customer etc.
#[serde(rename = "signedMeterData")]
pub signed_meter_data: String,
/// Format used by the energy meter to encode the meter data. For example: OCMF or EDL.
#[serde(rename = "encodingMethod")]
pub encoding_method: String,
/// *(2.1)* Method used to create the digital signature. Optional, if already included in _signedMeterData_. Standard values for this are defined in Appendix as SigningMethodEnumStringType.
#[serde(rename = "signingMethod")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub signing_method: Option<String>,
/// *(2.1)* Base64 encoded, sending depends on configuration variable _PublicKeyWithSignedMeterValue_.
#[serde(rename = "publicKey")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub public_key: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl SignedMeterValue {
/// Creates a `SignedMeterValue` from its required fields.
#[must_use]
pub fn new(signed_meter_data: impl Into<String>, encoding_method: impl Into<String>) -> Self {
Self {
signed_meter_data: signed_meter_data.into(),
encoding_method: encoding_method.into(),
signing_method: None,
public_key: None,
custom_data: None,
}
}
/// Sets the optional `signingMethod` field.
#[must_use]
pub fn with_signing_method(mut self, value: impl Into<String>) -> Self {
self.signing_method = Some(value.into());
self
}
/// Sets the optional `publicKey` field.
#[must_use]
pub fn with_public_key(mut self, value: impl Into<String>) -> Self {
self.public_key = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for SignedMeterValue {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("signedMeterData");
validate::string(
self.signed_meter_data.as_str(),
None,
Some(32768),
path,
out,
);
path.pop();
path.push_key("encodingMethod");
validate::string(self.encoding_method.as_str(), None, Some(50), path, out);
path.pop();
path.push_key("signingMethod");
if let Some(value) = &self.signing_method {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("publicKey");
if let Some(value) = &self.public_key {
validate::string(value.as_str(), None, Some(2500), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Element providing more information about the status.
///
/// The OCPP 2.1 `StatusInfo` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct StatusInfo {
/// A predefined code for the reason why the status is returned in this response. The string is case-insensitive.
#[serde(rename = "reasonCode")]
pub reason_code: String,
/// Additional text to provide detailed information.
#[serde(rename = "additionalInfo")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub additional_info: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl StatusInfo {
/// Creates a `StatusInfo` from its required fields.
#[must_use]
pub fn new(reason_code: impl Into<String>) -> Self {
Self {
reason_code: reason_code.into(),
additional_info: None,
custom_data: None,
}
}
/// Sets the optional `additionalInfo` field.
#[must_use]
pub fn with_additional_info(mut self, value: impl Into<String>) -> Self {
self.additional_info = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for StatusInfo {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("reasonCode");
validate::string(self.reason_code.as_str(), None, Some(20), path, out);
path.pop();
path.push_key("additionalInfo");
if let Some(value) = &self.additional_info {
validate::string(value.as_str(), None, Some(1024), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `StreamDataElement` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct StreamDataElement {
/// Offset relative to _basetime_ of this message. _basetime_ + _t_ is timestamp of recorded value.
pub t: crate::types::Decimal,
/// The `v` member.
pub v: String,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl StreamDataElement {
/// Creates a `StreamDataElement` from its required fields.
#[must_use]
pub fn new(t: impl Into<crate::types::Decimal>, v: impl Into<String>) -> Self {
Self {
t: t.into(),
v: v.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for StreamDataElement {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("v");
validate::string(self.v.as_str(), None, Some(2500), path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// A tariff is described by fields with prices for:
/// energy,
/// charging time,
/// idle time,
/// fixed fee,
/// reservation time,
/// reservation fixed fee. +
/// Each of these fields may have (optional) conditions that specify when a price is applicable. +
/// The _description_ contains a human-readable explanation of the tariff to be shown to the user. +
/// The other fields are parameters that define the tariff. These are used by the charging station to calculate the price.
///
/// The OCPP 2.1 `Tariff` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Tariff {
/// Unique id of tariff
#[serde(rename = "tariffId")]
pub tariff_id: String,
/// Currency code according to ISO 4217
pub currency: String,
/// The `description` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<Vec<MessageContent>>,
/// The `energy` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub energy: Option<TariffEnergy>,
/// Time when this tariff becomes active. When absent, it is immediately active.
#[serde(rename = "validFrom")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub valid_from: Option<crate::types::DateTime>,
/// The `chargingTime` member.
#[serde(rename = "chargingTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub charging_time: Option<TariffTime>,
/// The `idleTime` member.
#[serde(rename = "idleTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub idle_time: Option<TariffTime>,
/// The `fixedFee` member.
#[serde(rename = "fixedFee")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub fixed_fee: Option<TariffFixed>,
/// The `reservationTime` member.
#[serde(rename = "reservationTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub reservation_time: Option<TariffTime>,
/// The `reservationFixed` member.
#[serde(rename = "reservationFixed")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub reservation_fixed: Option<TariffFixed>,
/// The `minCost` member.
#[serde(rename = "minCost")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_cost: Option<Price>,
/// The `maxCost` member.
#[serde(rename = "maxCost")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_cost: Option<Price>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl Tariff {
/// Creates a `Tariff` from its required fields.
#[must_use]
pub fn new(tariff_id: impl Into<String>, currency: impl Into<String>) -> Self {
Self {
tariff_id: tariff_id.into(),
currency: currency.into(),
description: None,
energy: None,
valid_from: None,
charging_time: None,
idle_time: None,
fixed_fee: None,
reservation_time: None,
reservation_fixed: None,
min_cost: None,
max_cost: None,
custom_data: None,
}
}
/// Sets the optional `description` field.
#[must_use]
pub fn with_description(mut self, value: Vec<MessageContent>) -> Self {
self.description = Some(value);
self
}
/// Sets the optional `energy` field.
#[must_use]
pub fn with_energy(mut self, value: TariffEnergy) -> Self {
self.energy = Some(value);
self
}
/// Sets the optional `validFrom` field.
#[must_use]
pub fn with_valid_from(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.valid_from = Some(value.into());
self
}
/// Sets the optional `chargingTime` field.
#[must_use]
pub fn with_charging_time(mut self, value: TariffTime) -> Self {
self.charging_time = Some(value);
self
}
/// Sets the optional `idleTime` field.
#[must_use]
pub fn with_idle_time(mut self, value: TariffTime) -> Self {
self.idle_time = Some(value);
self
}
/// Sets the optional `fixedFee` field.
#[must_use]
pub fn with_fixed_fee(mut self, value: TariffFixed) -> Self {
self.fixed_fee = Some(value);
self
}
/// Sets the optional `reservationTime` field.
#[must_use]
pub fn with_reservation_time(mut self, value: TariffTime) -> Self {
self.reservation_time = Some(value);
self
}
/// Sets the optional `reservationFixed` field.
#[must_use]
pub fn with_reservation_fixed(mut self, value: TariffFixed) -> Self {
self.reservation_fixed = Some(value);
self
}
/// Sets the optional `minCost` field.
#[must_use]
pub fn with_min_cost(mut self, value: Price) -> Self {
self.min_cost = Some(value);
self
}
/// Sets the optional `maxCost` field.
#[must_use]
pub fn with_max_cost(mut self, value: Price) -> Self {
self.max_cost = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for Tariff {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("tariffId");
validate::string(self.tariff_id.as_str(), None, Some(60), path, out);
path.pop();
path.push_key("currency");
validate::string(self.currency.as_str(), None, Some(3), path, out);
path.pop();
path.push_key("description");
if let Some(value) = &self.description {
validate::list_len(value.len(), Some(1), Some(10), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("energy");
if let Some(value) = &self.energy {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("chargingTime");
if let Some(value) = &self.charging_time {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("idleTime");
if let Some(value) = &self.idle_time {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("fixedFee");
if let Some(value) = &self.fixed_fee {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("reservationTime");
if let Some(value) = &self.reservation_time {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("reservationFixed");
if let Some(value) = &self.reservation_fixed {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("minCost");
if let Some(value) = &self.min_cost {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("maxCost");
if let Some(value) = &self.max_cost {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Shows assignment of tariffs to EVSE or IdToken.
///
/// The OCPP 2.1 `TariffAssignment` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TariffAssignment {
/// Tariff id.
#[serde(rename = "tariffId")]
pub tariff_id: String,
/// The `tariffKind` member.
#[serde(rename = "tariffKind")]
pub tariff_kind: TariffKind,
/// Date/time when this tariff become active.
#[serde(rename = "validFrom")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub valid_from: Option<crate::types::DateTime>,
/// The `evseIds` member.
#[serde(rename = "evseIds")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option_list")]
pub evse_ids: Option<Vec<i32>>,
/// IdTokens related to tariff
#[serde(rename = "idTokens")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub id_tokens: Option<Vec<String>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TariffAssignment {
/// Creates a `TariffAssignment` from its required fields.
#[must_use]
pub fn new(tariff_id: impl Into<String>, tariff_kind: TariffKind) -> Self {
Self {
tariff_id: tariff_id.into(),
tariff_kind,
valid_from: None,
evse_ids: None,
id_tokens: None,
custom_data: None,
}
}
/// Sets the optional `validFrom` field.
#[must_use]
pub fn with_valid_from(mut self, value: impl Into<crate::types::DateTime>) -> Self {
self.valid_from = Some(value.into());
self
}
/// Sets the optional `evseIds` field.
#[must_use]
pub fn with_evse_ids(mut self, value: Vec<i32>) -> Self {
self.evse_ids = Some(value);
self
}
/// Sets the optional `idTokens` field.
#[must_use]
pub fn with_id_tokens(mut self, value: impl IntoIterator<Item = impl Into<String>>) -> Self {
self.id_tokens = Some(value.into_iter().map(Into::into).collect());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TariffAssignment {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("tariffId");
validate::string(self.tariff_id.as_str(), None, Some(60), path, out);
path.pop();
path.push_key("tariffKind");
Validate::validate_at(&self.tariff_kind, path, out);
path.pop();
path.push_key("evseIds");
if let Some(value) = &self.evse_ids {
validate::list_len(value.len(), Some(1), None, path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
validate::int_range(i64::from(*item), Some(0), None, path, out);
path.pop();
}
}
path.pop();
path.push_key("idTokens");
if let Some(value) = &self.id_tokens {
validate::list_len(value.len(), Some(1), None, path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
validate::string(item.as_str(), None, Some(255), path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// These conditions describe if and when a TariffEnergyType or TariffTimeType applies during a transaction.
///
/// When more than one restriction is set, they are to be treated as a logical AND. All need to be valid before this price is active.
///
/// For reverse energy flow (discharging) negative values of energy, power and current are used.
///
/// NOTE: _minXXX_ (where XXX = Kwh/A/Kw) must be read as "closest to zero", and _maxXXX_ as "furthest from zero". For example, a *charging* power range from 10 kW to 50 kWh is given by _minPower_ = 10000 and _maxPower_ = 50000, and a *discharging* power range from -10 kW to -50 kW is given by _minPower_ = -10 and _maxPower_ = -50.
///
/// NOTE: _startTimeOfDay_ and _endTimeOfDay_ are in local time, because it is the time in the tariff as it is shown to the EV driver at the Charging Station.
/// A Charging Station will convert this to the internal time zone that it uses (which is recommended to be UTC, see section Generic chapter 3.1) when performing cost calculation.
///
/// The OCPP 2.1 `TariffConditions` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TariffConditions {
/// Start time of day in local time. +
/// Format as per RFC 3339: time-hour ":" time-minute +
/// Must be in 24h format with leading zeros. Hour/Minute separator: ":"
/// Regex: (\[0-1\]\[0-9\]\|2\[0-3\]):\[0-5\]\[0-9\]
#[serde(rename = "startTimeOfDay")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub start_time_of_day: Option<String>,
/// End time of day in local time. Same syntax as _startTimeOfDay_. +
/// If end time < start time then the period wraps around to the next day. +
/// To stop at end of the day use: 00:00.
#[serde(rename = "endTimeOfDay")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub end_time_of_day: Option<String>,
/// Day(s) of the week this is tariff applies.
#[serde(rename = "dayOfWeek")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub day_of_week: Option<Vec<DayOfWeek>>,
/// Start date in local time, for example: 2015-12-24.
/// Valid from this day (inclusive). +
/// Format as per RFC 3339: full-date +
///
/// Regex: (\[12\]\[0-9\]{3})-(0\[1-9\]\|1\[0-2\])-(0\[1-9\]\|\[12\]\[0-9\]\|3\[01\])
#[serde(rename = "validFromDate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub valid_from_date: Option<String>,
/// End date in local time, for example: 2015-12-27.
/// Valid until this day (exclusive). Same syntax as _validFromDate_.
#[serde(rename = "validToDate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub valid_to_date: Option<String>,
/// The `evseKind` member.
#[serde(rename = "evseKind")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub evse_kind: Option<EvseKind>,
/// Minimum consumed energy in Wh, for example 20000 Wh.
/// Valid from this amount of energy (inclusive) being used.
#[serde(rename = "minEnergy")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_energy: Option<crate::types::Decimal>,
/// Maximum consumed energy in Wh, for example 50000 Wh.
/// Valid until this amount of energy (exclusive) being used.
#[serde(rename = "maxEnergy")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_energy: Option<crate::types::Decimal>,
/// Sum of the minimum current (in Amperes) over all phases, for example 5 A.
/// When the EV is charging with more than, or equal to, the defined amount of current, this price is/becomes active. If the charging current is or becomes lower, this price is not or no longer valid and becomes inactive. +
/// This is NOT about the minimum current over the entire transaction.
#[serde(rename = "minCurrent")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_current: Option<crate::types::Decimal>,
/// Sum of the maximum current (in Amperes) over all phases, for example 20 A.
/// When the EV is charging with less than the defined amount of current, this price becomes/is active. If the charging current is or becomes higher, this price is not or no longer valid and becomes inactive.
/// This is NOT about the maximum current over the entire transaction.
#[serde(rename = "maxCurrent")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_current: Option<crate::types::Decimal>,
/// Minimum power in W, for example 5000 W.
/// When the EV is charging with more than, or equal to, the defined amount of power, this price is/becomes active.
/// If the charging power is or becomes lower, this price is not or no longer valid and becomes inactive.
/// This is NOT about the minimum power over the entire transaction.
#[serde(rename = "minPower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_power: Option<crate::types::Decimal>,
/// Maximum power in W, for example 20000 W.
/// When the EV is charging with less than the defined amount of power, this price becomes/is active.
/// If the charging power is or becomes higher, this price is not or no longer valid and becomes inactive.
/// This is NOT about the maximum power over the entire transaction.
#[serde(rename = "maxPower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_power: Option<crate::types::Decimal>,
/// Minimum duration in seconds the transaction (charging & idle) MUST last (inclusive).
/// When the duration of a transaction is longer than the defined value, this price is or becomes active.
/// Before that moment, this price is not yet active.
#[serde(rename = "minTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub min_time: Option<i32>,
/// Maximum duration in seconds the transaction (charging & idle) MUST last (exclusive).
/// When the duration of a transaction is shorter than the defined value, this price is or becomes active.
/// After that moment, this price is no longer active.
#[serde(rename = "maxTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub max_time: Option<i32>,
/// Minimum duration in seconds the charging MUST last (inclusive).
/// When the duration of a charging is longer than the defined value, this price is or becomes active.
/// Before that moment, this price is not yet active.
#[serde(rename = "minChargingTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub min_charging_time: Option<i32>,
/// Maximum duration in seconds the charging MUST last (exclusive).
/// When the duration of a charging is shorter than the defined value, this price is or becomes active.
/// After that moment, this price is no longer active.
#[serde(rename = "maxChargingTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub max_charging_time: Option<i32>,
/// Minimum duration in seconds the idle period (i.e. not charging) MUST last (inclusive).
/// When the duration of the idle time is longer than the defined value, this price is or becomes active.
/// Before that moment, this price is not yet active.
#[serde(rename = "minIdleTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub min_idle_time: Option<i32>,
/// Maximum duration in seconds the idle period (i.e. not charging) MUST last (exclusive).
/// When the duration of idle time is shorter than the defined value, this price is or becomes active.
/// After that moment, this price is no longer active.
#[serde(rename = "maxIdleTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub max_idle_time: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TariffConditions {
/// Creates an empty `TariffConditions`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `startTimeOfDay` field.
#[must_use]
pub fn with_start_time_of_day(mut self, value: impl Into<String>) -> Self {
self.start_time_of_day = Some(value.into());
self
}
/// Sets the optional `endTimeOfDay` field.
#[must_use]
pub fn with_end_time_of_day(mut self, value: impl Into<String>) -> Self {
self.end_time_of_day = Some(value.into());
self
}
/// Sets the optional `dayOfWeek` field.
#[must_use]
pub fn with_day_of_week(mut self, value: Vec<DayOfWeek>) -> Self {
self.day_of_week = Some(value);
self
}
/// Sets the optional `validFromDate` field.
#[must_use]
pub fn with_valid_from_date(mut self, value: impl Into<String>) -> Self {
self.valid_from_date = Some(value.into());
self
}
/// Sets the optional `validToDate` field.
#[must_use]
pub fn with_valid_to_date(mut self, value: impl Into<String>) -> Self {
self.valid_to_date = Some(value.into());
self
}
/// Sets the optional `evseKind` field.
#[must_use]
pub fn with_evse_kind(mut self, value: EvseKind) -> Self {
self.evse_kind = Some(value);
self
}
/// Sets the optional `minEnergy` field.
#[must_use]
pub fn with_min_energy(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_energy = Some(value.into());
self
}
/// Sets the optional `maxEnergy` field.
#[must_use]
pub fn with_max_energy(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_energy = Some(value.into());
self
}
/// Sets the optional `minCurrent` field.
#[must_use]
pub fn with_min_current(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_current = Some(value.into());
self
}
/// Sets the optional `maxCurrent` field.
#[must_use]
pub fn with_max_current(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_current = Some(value.into());
self
}
/// Sets the optional `minPower` field.
#[must_use]
pub fn with_min_power(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_power = Some(value.into());
self
}
/// Sets the optional `maxPower` field.
#[must_use]
pub fn with_max_power(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_power = Some(value.into());
self
}
/// Sets the optional `minTime` field.
#[must_use]
pub fn with_min_time(mut self, value: i32) -> Self {
self.min_time = Some(value);
self
}
/// Sets the optional `maxTime` field.
#[must_use]
pub fn with_max_time(mut self, value: i32) -> Self {
self.max_time = Some(value);
self
}
/// Sets the optional `minChargingTime` field.
#[must_use]
pub fn with_min_charging_time(mut self, value: i32) -> Self {
self.min_charging_time = Some(value);
self
}
/// Sets the optional `maxChargingTime` field.
#[must_use]
pub fn with_max_charging_time(mut self, value: i32) -> Self {
self.max_charging_time = Some(value);
self
}
/// Sets the optional `minIdleTime` field.
#[must_use]
pub fn with_min_idle_time(mut self, value: i32) -> Self {
self.min_idle_time = Some(value);
self
}
/// Sets the optional `maxIdleTime` field.
#[must_use]
pub fn with_max_idle_time(mut self, value: i32) -> Self {
self.max_idle_time = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TariffConditions {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("dayOfWeek");
if let Some(value) = &self.day_of_week {
validate::list_len(value.len(), Some(1), Some(7), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("evseKind");
if let Some(value) = &self.evse_kind {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// These conditions describe if a FixedPrice applies at start of the transaction.
///
/// When more than one restriction is set, they are to be treated as a logical AND. All need to be valid before this price is active.
///
/// NOTE: _startTimeOfDay_ and _endTimeOfDay_ are in local time, because it is the time in the tariff as it is shown to the EV driver at the Charging Station.
/// A Charging Station will convert this to the internal time zone that it uses (which is recommended to be UTC, see section Generic chapter 3.1) when performing cost calculation.
///
/// The OCPP 2.1 `TariffConditionsFixed` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TariffConditionsFixed {
/// Start time of day in local time. +
/// Format as per RFC 3339: time-hour ":" time-minute +
/// Must be in 24h format with leading zeros. Hour/Minute separator: ":"
/// Regex: (\[0-1\]\[0-9\]\|2\[0-3\]):\[0-5\]\[0-9\]
#[serde(rename = "startTimeOfDay")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub start_time_of_day: Option<String>,
/// End time of day in local time. Same syntax as _startTimeOfDay_. +
/// If end time < start time then the period wraps around to the next day. +
/// To stop at end of the day use: 00:00.
#[serde(rename = "endTimeOfDay")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub end_time_of_day: Option<String>,
/// Day(s) of the week this is tariff applies.
#[serde(rename = "dayOfWeek")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub day_of_week: Option<Vec<DayOfWeek>>,
/// Start date in local time, for example: 2015-12-24.
/// Valid from this day (inclusive). +
/// Format as per RFC 3339: full-date +
///
/// Regex: (\[12\]\[0-9\]{3})-(0\[1-9\]\|1\[0-2\])-(0\[1-9\]\|\[12\]\[0-9\]\|3\[01\])
#[serde(rename = "validFromDate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub valid_from_date: Option<String>,
/// End date in local time, for example: 2015-12-27.
/// Valid until this day (exclusive). Same syntax as _validFromDate_.
#[serde(rename = "validToDate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub valid_to_date: Option<String>,
/// The `evseKind` member.
#[serde(rename = "evseKind")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub evse_kind: Option<EvseKind>,
/// For which payment brand this (adhoc) tariff applies. Can be used to add a surcharge for certain payment brands.
/// Based on value of _additionalIdToken_ from _idToken.additionalInfo.type_ = "PaymentBrand".
#[serde(rename = "paymentBrand")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub payment_brand: Option<String>,
/// Type of adhoc payment, e.g. CC, Debit.
/// Based on value of _additionalIdToken_ from _idToken.additionalInfo.type_ = "PaymentRecognition".
#[serde(rename = "paymentRecognition")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub payment_recognition: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TariffConditionsFixed {
/// Creates an empty `TariffConditionsFixed`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `startTimeOfDay` field.
#[must_use]
pub fn with_start_time_of_day(mut self, value: impl Into<String>) -> Self {
self.start_time_of_day = Some(value.into());
self
}
/// Sets the optional `endTimeOfDay` field.
#[must_use]
pub fn with_end_time_of_day(mut self, value: impl Into<String>) -> Self {
self.end_time_of_day = Some(value.into());
self
}
/// Sets the optional `dayOfWeek` field.
#[must_use]
pub fn with_day_of_week(mut self, value: Vec<DayOfWeek>) -> Self {
self.day_of_week = Some(value);
self
}
/// Sets the optional `validFromDate` field.
#[must_use]
pub fn with_valid_from_date(mut self, value: impl Into<String>) -> Self {
self.valid_from_date = Some(value.into());
self
}
/// Sets the optional `validToDate` field.
#[must_use]
pub fn with_valid_to_date(mut self, value: impl Into<String>) -> Self {
self.valid_to_date = Some(value.into());
self
}
/// Sets the optional `evseKind` field.
#[must_use]
pub fn with_evse_kind(mut self, value: EvseKind) -> Self {
self.evse_kind = Some(value);
self
}
/// Sets the optional `paymentBrand` field.
#[must_use]
pub fn with_payment_brand(mut self, value: impl Into<String>) -> Self {
self.payment_brand = Some(value.into());
self
}
/// Sets the optional `paymentRecognition` field.
#[must_use]
pub fn with_payment_recognition(mut self, value: impl Into<String>) -> Self {
self.payment_recognition = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TariffConditionsFixed {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("dayOfWeek");
if let Some(value) = &self.day_of_week {
validate::list_len(value.len(), Some(1), Some(7), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("evseKind");
if let Some(value) = &self.evse_kind {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("paymentBrand");
if let Some(value) = &self.payment_brand {
validate::string(value.as_str(), None, Some(20), path, out);
}
path.pop();
path.push_key("paymentRecognition");
if let Some(value) = &self.payment_recognition {
validate::string(value.as_str(), None, Some(20), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Price elements and tax for energy
///
/// The OCPP 2.1 `TariffEnergy` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TariffEnergy {
/// The `prices` member.
pub prices: Vec<TariffEnergyPrice>,
/// The `taxRates` member.
#[serde(rename = "taxRates")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tax_rates: Option<Vec<TaxRate>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TariffEnergy {
/// Creates a `TariffEnergy` from its required fields.
#[must_use]
pub fn new(prices: Vec<TariffEnergyPrice>) -> Self {
Self {
prices,
tax_rates: None,
custom_data: None,
}
}
/// Sets the optional `taxRates` field.
#[must_use]
pub fn with_tax_rates(mut self, value: Vec<TaxRate>) -> Self {
self.tax_rates = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TariffEnergy {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("prices");
validate::list_len(self.prices.len(), Some(1), None, path, out);
for (index, item) in self.prices.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("taxRates");
if let Some(value) = &self.tax_rates {
validate::list_len(value.len(), Some(1), Some(5), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Tariff with optional conditions for an energy price.
///
/// The OCPP 2.1 `TariffEnergyPrice` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TariffEnergyPrice {
/// Price per kWh (excl. tax) for this element.
#[serde(rename = "priceKwh")]
pub price_kwh: crate::types::Decimal,
/// The `conditions` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub conditions: Option<TariffConditions>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TariffEnergyPrice {
/// Creates a `TariffEnergyPrice` from its required fields.
#[must_use]
pub fn new(price_kwh: impl Into<crate::types::Decimal>) -> Self {
Self {
price_kwh: price_kwh.into(),
conditions: None,
custom_data: None,
}
}
/// Sets the optional `conditions` field.
#[must_use]
pub fn with_conditions(mut self, value: TariffConditions) -> Self {
self.conditions = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TariffEnergyPrice {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("conditions");
if let Some(value) = &self.conditions {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `TariffFixed` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TariffFixed {
/// The `prices` member.
pub prices: Vec<TariffFixedPrice>,
/// The `taxRates` member.
#[serde(rename = "taxRates")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tax_rates: Option<Vec<TaxRate>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TariffFixed {
/// Creates a `TariffFixed` from its required fields.
#[must_use]
pub fn new(prices: Vec<TariffFixedPrice>) -> Self {
Self {
prices,
tax_rates: None,
custom_data: None,
}
}
/// Sets the optional `taxRates` field.
#[must_use]
pub fn with_tax_rates(mut self, value: Vec<TaxRate>) -> Self {
self.tax_rates = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TariffFixed {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("prices");
validate::list_len(self.prices.len(), Some(1), None, path, out);
for (index, item) in self.prices.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("taxRates");
if let Some(value) = &self.tax_rates {
validate::list_len(value.len(), Some(1), Some(5), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Tariff with optional conditions for a fixed price.
///
/// The OCPP 2.1 `TariffFixedPrice` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TariffFixedPrice {
/// Fixed price for this element e.g. a start fee.
#[serde(rename = "priceFixed")]
pub price_fixed: crate::types::Decimal,
/// The `conditions` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub conditions: Option<TariffConditionsFixed>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TariffFixedPrice {
/// Creates a `TariffFixedPrice` from its required fields.
#[must_use]
pub fn new(price_fixed: impl Into<crate::types::Decimal>) -> Self {
Self {
price_fixed: price_fixed.into(),
conditions: None,
custom_data: None,
}
}
/// Sets the optional `conditions` field.
#[must_use]
pub fn with_conditions(mut self, value: TariffConditionsFixed) -> Self {
self.conditions = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TariffFixedPrice {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("conditions");
if let Some(value) = &self.conditions {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Price elements and tax for time
///
/// The OCPP 2.1 `TariffTime` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TariffTime {
/// The `prices` member.
pub prices: Vec<TariffTimePrice>,
/// The `taxRates` member.
#[serde(rename = "taxRates")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tax_rates: Option<Vec<TaxRate>>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TariffTime {
/// Creates a `TariffTime` from its required fields.
#[must_use]
pub fn new(prices: Vec<TariffTimePrice>) -> Self {
Self {
prices,
tax_rates: None,
custom_data: None,
}
}
/// Sets the optional `taxRates` field.
#[must_use]
pub fn with_tax_rates(mut self, value: Vec<TaxRate>) -> Self {
self.tax_rates = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TariffTime {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("prices");
validate::list_len(self.prices.len(), Some(1), None, path, out);
for (index, item) in self.prices.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
path.pop();
path.push_key("taxRates");
if let Some(value) = &self.tax_rates {
validate::list_len(value.len(), Some(1), Some(5), path, out);
for (index, item) in value.iter().enumerate() {
path.push_index(index);
Validate::validate_at(item, path, out);
path.pop();
}
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Tariff with optional conditions for a time duration price.
///
/// The OCPP 2.1 `TariffTimePrice` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TariffTimePrice {
/// Price per minute (excl. tax) for this element.
#[serde(rename = "priceMinute")]
pub price_minute: crate::types::Decimal,
/// The `conditions` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub conditions: Option<TariffConditions>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TariffTimePrice {
/// Creates a `TariffTimePrice` from its required fields.
#[must_use]
pub fn new(price_minute: impl Into<crate::types::Decimal>) -> Self {
Self {
price_minute: price_minute.into(),
conditions: None,
custom_data: None,
}
}
/// Sets the optional `conditions` field.
#[must_use]
pub fn with_conditions(mut self, value: TariffConditions) -> Self {
self.conditions = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TariffTimePrice {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("conditions");
if let Some(value) = &self.conditions {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Tax percentage
///
/// The OCPP 2.1 `TaxRate` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TaxRate {
/// Type of this tax, e.g. "Federal ", "State", for information on receipt.
pub r#type: String,
/// Tax percentage
pub tax: crate::types::Decimal,
/// Stack level for this type of tax. Default value, when absent, is 0. +
/// _stack_ = 0: tax on net price; +
/// _stack_ = 1: tax added on top of _stack_ 0; +
/// _stack_ = 2: tax added on top of _stack_ 1, etc.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub stack: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TaxRate {
/// Creates a `TaxRate` from its required fields.
#[must_use]
pub fn new(r#type: impl Into<String>, tax: impl Into<crate::types::Decimal>) -> Self {
Self {
r#type: r#type.into(),
tax: tax.into(),
stack: None,
custom_data: None,
}
}
/// Sets the optional `stack` field.
#[must_use]
pub fn with_stack(mut self, value: i32) -> Self {
self.stack = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TaxRate {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("type");
validate::string(self.r#type.as_str(), None, Some(20), path, out);
path.pop();
path.push_key("stack");
if let Some(value) = &self.stack {
validate::int_range(i64::from(*value), Some(0), None, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Part of ISO 15118-20 price schedule.
///
/// The OCPP 2.1 `TaxRule` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TaxRule {
/// Id for the tax rule.
#[serde(rename = "taxRuleID")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub tax_rule_id: i32,
/// Indicates whether this tax applies to Energy Fees.
#[serde(rename = "appliesToEnergyFee")]
pub applies_to_energy_fee: bool,
/// Indicates whether this tax applies to Parking Fees.
#[serde(rename = "appliesToParkingFee")]
pub applies_to_parking_fee: bool,
/// Indicates whether this tax applies to Overstay Fees.
#[serde(rename = "appliesToOverstayFee")]
pub applies_to_overstay_fee: bool,
/// Indicates whether this tax applies to Minimum/Maximum Cost.
#[serde(rename = "appliesToMinimumMaximumCost")]
pub applies_to_minimum_maximum_cost: bool,
/// The `taxRate` member.
#[serde(rename = "taxRate")]
pub tax_rate: RationalNumber,
/// Human readable string to identify the tax rule.
#[serde(rename = "taxRuleName")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tax_rule_name: Option<String>,
/// Indicates whether the tax is included in any price or not.
#[serde(rename = "taxIncludedInPrice")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tax_included_in_price: Option<bool>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TaxRule {
/// Creates a `TaxRule` from its required fields.
#[must_use]
pub fn new(
tax_rule_id: i32,
applies_to_energy_fee: bool,
applies_to_parking_fee: bool,
applies_to_overstay_fee: bool,
applies_to_minimum_maximum_cost: bool,
tax_rate: RationalNumber,
) -> Self {
Self {
tax_rule_id,
applies_to_energy_fee,
applies_to_parking_fee,
applies_to_overstay_fee,
applies_to_minimum_maximum_cost,
tax_rate,
tax_rule_name: None,
tax_included_in_price: None,
custom_data: None,
}
}
/// Sets the optional `taxRuleName` field.
#[must_use]
pub fn with_tax_rule_name(mut self, value: impl Into<String>) -> Self {
self.tax_rule_name = Some(value.into());
self
}
/// Sets the optional `taxIncludedInPrice` field.
#[must_use]
pub fn with_tax_included_in_price(mut self, value: bool) -> Self {
self.tax_included_in_price = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TaxRule {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("taxRuleID");
validate::int_range(i64::from(self.tax_rule_id), Some(0), None, path, out);
path.pop();
path.push_key("taxRate");
Validate::validate_at(&self.tax_rate, path, out);
path.pop();
path.push_key("taxRuleName");
if let Some(value) = &self.tax_rule_name {
validate::string(value.as_str(), None, Some(100), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// This contains the cost calculated during a transaction. It is used both for running cost and final cost of the transaction.
///
/// The OCPP 2.1 `TotalCost` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TotalCost {
/// Currency of the costs in ISO 4217 Code.
pub currency: String,
/// The `typeOfCost` member.
#[serde(rename = "typeOfCost")]
pub type_of_cost: TariffCost,
/// The `total` member.
pub total: TotalPrice,
/// The `fixed` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub fixed: Option<Price>,
/// The `energy` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub energy: Option<Price>,
/// The `chargingTime` member.
#[serde(rename = "chargingTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub charging_time: Option<Price>,
/// The `idleTime` member.
#[serde(rename = "idleTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub idle_time: Option<Price>,
/// The `reservationTime` member.
#[serde(rename = "reservationTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub reservation_time: Option<Price>,
/// The `reservationFixed` member.
#[serde(rename = "reservationFixed")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub reservation_fixed: Option<Price>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TotalCost {
/// Creates a `TotalCost` from its required fields.
#[must_use]
pub fn new(currency: impl Into<String>, type_of_cost: TariffCost, total: TotalPrice) -> Self {
Self {
currency: currency.into(),
type_of_cost,
total,
fixed: None,
energy: None,
charging_time: None,
idle_time: None,
reservation_time: None,
reservation_fixed: None,
custom_data: None,
}
}
/// Sets the optional `fixed` field.
#[must_use]
pub fn with_fixed(mut self, value: Price) -> Self {
self.fixed = Some(value);
self
}
/// Sets the optional `energy` field.
#[must_use]
pub fn with_energy(mut self, value: Price) -> Self {
self.energy = Some(value);
self
}
/// Sets the optional `chargingTime` field.
#[must_use]
pub fn with_charging_time(mut self, value: Price) -> Self {
self.charging_time = Some(value);
self
}
/// Sets the optional `idleTime` field.
#[must_use]
pub fn with_idle_time(mut self, value: Price) -> Self {
self.idle_time = Some(value);
self
}
/// Sets the optional `reservationTime` field.
#[must_use]
pub fn with_reservation_time(mut self, value: Price) -> Self {
self.reservation_time = Some(value);
self
}
/// Sets the optional `reservationFixed` field.
#[must_use]
pub fn with_reservation_fixed(mut self, value: Price) -> Self {
self.reservation_fixed = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TotalCost {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("currency");
validate::string(self.currency.as_str(), None, Some(3), path, out);
path.pop();
path.push_key("typeOfCost");
Validate::validate_at(&self.type_of_cost, path, out);
path.pop();
path.push_key("total");
Validate::validate_at(&self.total, path, out);
path.pop();
path.push_key("fixed");
if let Some(value) = &self.fixed {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("energy");
if let Some(value) = &self.energy {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("chargingTime");
if let Some(value) = &self.charging_time {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("idleTime");
if let Some(value) = &self.idle_time {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("reservationTime");
if let Some(value) = &self.reservation_time {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("reservationFixed");
if let Some(value) = &self.reservation_fixed {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Total cost with and without tax. Contains the total of energy, charging time, idle time, fixed and reservation costs including and/or excluding tax.
///
/// The OCPP 2.1 `TotalPrice` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TotalPrice {
/// Price/cost excluding tax. Can be absent if _inclTax_ is present.
#[serde(rename = "exclTax")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub excl_tax: Option<crate::types::Decimal>,
/// Price/cost including tax. Can be absent if _exclTax_ is present.
#[serde(rename = "inclTax")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub incl_tax: Option<crate::types::Decimal>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TotalPrice {
/// Creates an empty `TotalPrice`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `exclTax` field.
#[must_use]
pub fn with_excl_tax(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.excl_tax = Some(value.into());
self
}
/// Sets the optional `inclTax` field.
#[must_use]
pub fn with_incl_tax(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.incl_tax = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TotalPrice {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// This contains the calculated usage of energy, charging time and idle time during a transaction.
///
/// The OCPP 2.1 `TotalUsage` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TotalUsage {
/// The `energy` member.
pub energy: crate::types::Decimal,
/// Total duration of the charging session (including the duration of charging and not charging), in seconds.
#[serde(rename = "chargingTime")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub charging_time: i32,
/// Total duration of the charging session where the EV was not charging (no energy was transferred between EVSE and EV), in seconds.
#[serde(rename = "idleTime")]
#[serde(deserialize_with = "crate::types::integer::one")]
pub idle_time: i32,
/// Total time of reservation in seconds.
#[serde(rename = "reservationTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub reservation_time: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TotalUsage {
/// Creates a `TotalUsage` from its required fields.
#[must_use]
pub fn new(
energy: impl Into<crate::types::Decimal>,
charging_time: i32,
idle_time: i32,
) -> Self {
Self {
energy: energy.into(),
charging_time,
idle_time,
reservation_time: None,
custom_data: None,
}
}
/// Sets the optional `reservationTime` field.
#[must_use]
pub fn with_reservation_time(mut self, value: i32) -> Self {
self.reservation_time = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TotalUsage {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `Transaction` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Transaction {
/// This contains the Id of the transaction.
#[serde(rename = "transactionId")]
pub transaction_id: String,
/// The `chargingState` member.
#[serde(rename = "chargingState")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub charging_state: Option<ChargingState>,
/// Contains the total time that energy flowed from EVSE to EV during the transaction (in seconds). Note that timeSpentCharging is smaller or equal to the duration of the transaction.
#[serde(rename = "timeSpentCharging")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub time_spent_charging: Option<i32>,
/// The `stoppedReason` member.
#[serde(rename = "stoppedReason")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub stopped_reason: Option<Reason>,
/// The ID given to remote start request (<<requeststarttransactionrequest, RequestStartTransactionRequest>>. This enables to CSMS to match the started transaction to the given start request.
#[serde(rename = "remoteStartId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub remote_start_id: Option<i32>,
/// The `operationMode` member.
#[serde(rename = "operationMode")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub operation_mode: Option<OperationMode>,
/// *(2.1)* Id of tariff in use for transaction
#[serde(rename = "tariffId")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tariff_id: Option<String>,
/// The `transactionLimit` member.
#[serde(rename = "transactionLimit")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub transaction_limit: Option<TransactionLimit>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl Transaction {
/// Creates a `Transaction` from its required fields.
#[must_use]
pub fn new(transaction_id: impl Into<String>) -> Self {
Self {
transaction_id: transaction_id.into(),
charging_state: None,
time_spent_charging: None,
stopped_reason: None,
remote_start_id: None,
operation_mode: None,
tariff_id: None,
transaction_limit: None,
custom_data: None,
}
}
/// Sets the optional `chargingState` field.
#[must_use]
pub fn with_charging_state(mut self, value: ChargingState) -> Self {
self.charging_state = Some(value);
self
}
/// Sets the optional `timeSpentCharging` field.
#[must_use]
pub fn with_time_spent_charging(mut self, value: i32) -> Self {
self.time_spent_charging = Some(value);
self
}
/// Sets the optional `stoppedReason` field.
#[must_use]
pub fn with_stopped_reason(mut self, value: Reason) -> Self {
self.stopped_reason = Some(value);
self
}
/// Sets the optional `remoteStartId` field.
#[must_use]
pub fn with_remote_start_id(mut self, value: i32) -> Self {
self.remote_start_id = Some(value);
self
}
/// Sets the optional `operationMode` field.
#[must_use]
pub fn with_operation_mode(mut self, value: OperationMode) -> Self {
self.operation_mode = Some(value);
self
}
/// Sets the optional `tariffId` field.
#[must_use]
pub fn with_tariff_id(mut self, value: impl Into<String>) -> Self {
self.tariff_id = Some(value.into());
self
}
/// Sets the optional `transactionLimit` field.
#[must_use]
pub fn with_transaction_limit(mut self, value: TransactionLimit) -> Self {
self.transaction_limit = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for Transaction {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("transactionId");
validate::string(self.transaction_id.as_str(), None, Some(36), path, out);
path.pop();
path.push_key("chargingState");
if let Some(value) = &self.charging_state {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("stoppedReason");
if let Some(value) = &self.stopped_reason {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("operationMode");
if let Some(value) = &self.operation_mode {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("tariffId");
if let Some(value) = &self.tariff_id {
validate::string(value.as_str(), None, Some(60), path, out);
}
path.pop();
path.push_key("transactionLimit");
if let Some(value) = &self.transaction_limit {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Cost, energy, time or SoC limit for a transaction.
///
/// The OCPP 2.1 `TransactionLimit` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TransactionLimit {
/// Maximum allowed cost of transaction in currency of tariff.
#[serde(rename = "maxCost")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_cost: Option<crate::types::Decimal>,
/// Maximum allowed energy in Wh to charge in transaction.
#[serde(rename = "maxEnergy")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_energy: Option<crate::types::Decimal>,
/// Maximum duration of transaction in seconds from start to end.
#[serde(rename = "maxTime")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub max_time: Option<i32>,
/// Maximum State of Charge of EV in percentage.
#[serde(rename = "maxSoC")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub max_so_c: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl TransactionLimit {
/// Creates an empty `TransactionLimit`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `maxCost` field.
#[must_use]
pub fn with_max_cost(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_cost = Some(value.into());
self
}
/// Sets the optional `maxEnergy` field.
#[must_use]
pub fn with_max_energy(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_energy = Some(value.into());
self
}
/// Sets the optional `maxTime` field.
#[must_use]
pub fn with_max_time(mut self, value: i32) -> Self {
self.max_time = Some(value);
self
}
/// Sets the optional `maxSoC` field.
#[must_use]
pub fn with_max_so_c(mut self, value: i32) -> Self {
self.max_so_c = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for TransactionLimit {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("maxSoC");
if let Some(value) = &self.max_so_c {
validate::int_range(i64::from(*value), Some(0), Some(100), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Represents a UnitOfMeasure with a multiplier
///
/// The OCPP 2.1 `UnitOfMeasure` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct UnitOfMeasure {
/// Unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type.
/// This field SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices.
/// If an applicable unit is available in that list, otherwise a "custom" unit might be used.
/// Schema default: `"Wh"`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub unit: Option<String>,
/// Multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 raised to the 3rd power. Default is 0. +
/// The _multiplier_ only multiplies the value of the measurand. It does not specify a conversion between units, for example, kW and W.
/// Schema default: `0`.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub multiplier: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl UnitOfMeasure {
/// Creates an empty `UnitOfMeasure`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `unit` field.
#[must_use]
pub fn with_unit(mut self, value: impl Into<String>) -> Self {
self.unit = Some(value.into());
self
}
/// Sets the optional `multiplier` field.
#[must_use]
pub fn with_multiplier(mut self, value: i32) -> Self {
self.multiplier = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for UnitOfMeasure {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("unit");
if let Some(value) = &self.unit {
validate::string(value.as_str(), None, Some(20), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Charging parameters for ISO 15118-20, also supporting V2X charging/discharging.+
/// All values are greater or equal to zero, with the exception of EVMinEnergyRequest, EVMaxEnergyRequest, EVTargetEnergyRequest, EVMinV2XEnergyRequest and EVMaxV2XEnergyRequest.
///
/// The OCPP 2.1 `V2XChargingParameters` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct V2XChargingParameters {
/// Minimum charge power in W, defined by max(EV, EVSE).
/// This field represents the sum of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1.
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMinimumChargePower
#[serde(rename = "minChargePower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_charge_power: Option<crate::types::Decimal>,
/// Minimum charge power on phase L2 in W, defined by max(EV, EVSE).
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMinimumChargePower_L2
#[serde(rename = "minChargePower_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_charge_power_l2: Option<crate::types::Decimal>,
/// Minimum charge power on phase L3 in W, defined by max(EV, EVSE).
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMinimumChargePower_L3
#[serde(rename = "minChargePower_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_charge_power_l3: Option<crate::types::Decimal>,
/// Maximum charge (absorbed) power in W, defined by min(EV, EVSE) at unity power factor. +
/// This field represents the sum of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1.
/// It corresponds to the ChaWMax attribute in the IEC 61850.
/// It is usually equivalent to the rated apparent power of the EV when discharging (ChaVAMax) in IEC 61850. +
///
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMaximumChargePower
#[serde(rename = "maxChargePower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_charge_power: Option<crate::types::Decimal>,
/// Maximum charge power on phase L2 in W, defined by min(EV, EVSE)
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMaximumChargePower_L2
#[serde(rename = "maxChargePower_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_charge_power_l2: Option<crate::types::Decimal>,
/// Maximum charge power on phase L3 in W, defined by min(EV, EVSE)
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMaximumChargePower_L3
#[serde(rename = "maxChargePower_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_charge_power_l3: Option<crate::types::Decimal>,
/// Minimum discharge (injected) power in W, defined by max(EV, EVSE) at unity power factor. Value >= 0. +
/// This field represents the sum of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1. +
/// It corresponds to the WMax attribute in the IEC 61850.
/// It is usually equivalent to the rated apparent power of the EV when discharging (VAMax attribute in the IEC 61850).
///
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMinimumDischargePower
#[serde(rename = "minDischargePower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_discharge_power: Option<crate::types::Decimal>,
/// Minimum discharge power on phase L2 in W, defined by max(EV, EVSE). Value >= 0.
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMinimumDischargePower_L2
#[serde(rename = "minDischargePower_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_discharge_power_l2: Option<crate::types::Decimal>,
/// Minimum discharge power on phase L3 in W, defined by max(EV, EVSE). Value >= 0.
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMinimumDischargePower_L3
#[serde(rename = "minDischargePower_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_discharge_power_l3: Option<crate::types::Decimal>,
/// Maximum discharge (injected) power in W, defined by min(EV, EVSE) at unity power factor. Value >= 0.
/// This field represents the sum of all phases, unless values are provided for L2 and L3, in which case this field represents phase L1.
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMaximumDischargePower
#[serde(rename = "maxDischargePower")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_discharge_power: Option<crate::types::Decimal>,
/// Maximum discharge power on phase L2 in W, defined by min(EV, EVSE). Value >= 0.
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMaximumDischargePowe_L2
#[serde(rename = "maxDischargePower_L2")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_discharge_power_l2: Option<crate::types::Decimal>,
/// Maximum discharge power on phase L3 in W, defined by min(EV, EVSE). Value >= 0.
/// Relates to:
/// *ISO 15118-20*: BPT_AC/DC_CPDReqEnergyTransferModeType: EVMaximumDischargePower_L3
#[serde(rename = "maxDischargePower_L3")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_discharge_power_l3: Option<crate::types::Decimal>,
/// Minimum charge current in A, defined by max(EV, EVSE)
/// Relates to:
/// *ISO 15118-20*: BPT_DC_CPDReqEnergyTransferModeType: EVMinimumChargeCurrent
#[serde(rename = "minChargeCurrent")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_charge_current: Option<crate::types::Decimal>,
/// Maximum charge current in A, defined by min(EV, EVSE)
/// Relates to:
/// *ISO 15118-20*: BPT_DC_CPDReqEnergyTransferModeType: EVMaximumChargeCurrent
#[serde(rename = "maxChargeCurrent")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_charge_current: Option<crate::types::Decimal>,
/// Minimum discharge current in A, defined by max(EV, EVSE). Value >= 0.
/// Relates to:
/// *ISO 15118-20*: BPT_DC_CPDReqEnergyTransferModeType: EVMinimumDischargeCurrent
#[serde(rename = "minDischargeCurrent")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_discharge_current: Option<crate::types::Decimal>,
/// Maximum discharge current in A, defined by min(EV, EVSE). Value >= 0.
/// Relates to:
/// *ISO 15118-20*: BPT_DC_CPDReqEnergyTransferModeType: EVMaximumDischargeCurrent
#[serde(rename = "maxDischargeCurrent")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_discharge_current: Option<crate::types::Decimal>,
/// Minimum voltage in V, defined by max(EV, EVSE)
/// Relates to:
/// *ISO 15118-20*: BPT_DC_CPDReqEnergyTransferModeType: EVMinimumVoltage
#[serde(rename = "minVoltage")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_voltage: Option<crate::types::Decimal>,
/// Maximum voltage in V, defined by min(EV, EVSE)
/// Relates to:
/// *ISO 15118-20*: BPT_DC_CPDReqEnergyTransferModeType: EVMaximumVoltage
#[serde(rename = "maxVoltage")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_voltage: Option<crate::types::Decimal>,
/// Energy to requested state of charge in Wh
/// Relates to:
/// *ISO 15118-20*: Dynamic/Scheduled_SEReqControlModeType: EVTargetEnergyRequest
#[serde(rename = "evTargetEnergyRequest")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_target_energy_request: Option<crate::types::Decimal>,
/// Energy to minimum allowed state of charge in Wh
/// Relates to:
/// *ISO 15118-20*: Dynamic/Scheduled_SEReqControlModeType: EVMinimumEnergyRequest
#[serde(rename = "evMinEnergyRequest")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_min_energy_request: Option<crate::types::Decimal>,
/// Energy to maximum state of charge in Wh
/// Relates to:
/// *ISO 15118-20*: Dynamic/Scheduled_SEReqControlModeType: EVMaximumEnergyRequest
#[serde(rename = "evMaxEnergyRequest")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_max_energy_request: Option<crate::types::Decimal>,
/// Energy (in Wh) to minimum state of charge for cycling (V2X) activity.
/// Positive value means that current state of charge is below V2X range.
/// Relates to:
/// *ISO 15118-20*: Dynamic_SEReqControlModeType: EVMinimumV2XEnergyRequest
#[serde(rename = "evMinV2XEnergyRequest")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_min_v2_x_energy_request: Option<crate::types::Decimal>,
/// Energy (in Wh) to maximum state of charge for cycling (V2X) activity.
/// Negative value indicates that current state of charge is above V2X range.
/// Relates to:
/// *ISO 15118-20*: Dynamic_SEReqControlModeType: EVMaximumV2XEnergyRequest
#[serde(rename = "evMaxV2XEnergyRequest")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ev_max_v2_x_energy_request: Option<crate::types::Decimal>,
/// Target state of charge at departure as percentage.
/// Relates to:
/// *ISO 15118-20*: BPT_DC_CPDReqEnergyTransferModeType: TargetSOC
#[serde(rename = "targetSoC")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub target_so_c: Option<i32>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl V2XChargingParameters {
/// Creates an empty `V2XChargingParameters`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `minChargePower` field.
#[must_use]
pub fn with_min_charge_power(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_charge_power = Some(value.into());
self
}
/// Sets the optional `minChargePower_L2` field.
#[must_use]
pub fn with_min_charge_power_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_charge_power_l2 = Some(value.into());
self
}
/// Sets the optional `minChargePower_L3` field.
#[must_use]
pub fn with_min_charge_power_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_charge_power_l3 = Some(value.into());
self
}
/// Sets the optional `maxChargePower` field.
#[must_use]
pub fn with_max_charge_power(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_charge_power = Some(value.into());
self
}
/// Sets the optional `maxChargePower_L2` field.
#[must_use]
pub fn with_max_charge_power_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_charge_power_l2 = Some(value.into());
self
}
/// Sets the optional `maxChargePower_L3` field.
#[must_use]
pub fn with_max_charge_power_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_charge_power_l3 = Some(value.into());
self
}
/// Sets the optional `minDischargePower` field.
#[must_use]
pub fn with_min_discharge_power(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_discharge_power = Some(value.into());
self
}
/// Sets the optional `minDischargePower_L2` field.
#[must_use]
pub fn with_min_discharge_power_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_discharge_power_l2 = Some(value.into());
self
}
/// Sets the optional `minDischargePower_L3` field.
#[must_use]
pub fn with_min_discharge_power_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_discharge_power_l3 = Some(value.into());
self
}
/// Sets the optional `maxDischargePower` field.
#[must_use]
pub fn with_max_discharge_power(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_discharge_power = Some(value.into());
self
}
/// Sets the optional `maxDischargePower_L2` field.
#[must_use]
pub fn with_max_discharge_power_l2(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_discharge_power_l2 = Some(value.into());
self
}
/// Sets the optional `maxDischargePower_L3` field.
#[must_use]
pub fn with_max_discharge_power_l3(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_discharge_power_l3 = Some(value.into());
self
}
/// Sets the optional `minChargeCurrent` field.
#[must_use]
pub fn with_min_charge_current(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_charge_current = Some(value.into());
self
}
/// Sets the optional `maxChargeCurrent` field.
#[must_use]
pub fn with_max_charge_current(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_charge_current = Some(value.into());
self
}
/// Sets the optional `minDischargeCurrent` field.
#[must_use]
pub fn with_min_discharge_current(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_discharge_current = Some(value.into());
self
}
/// Sets the optional `maxDischargeCurrent` field.
#[must_use]
pub fn with_max_discharge_current(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_discharge_current = Some(value.into());
self
}
/// Sets the optional `minVoltage` field.
#[must_use]
pub fn with_min_voltage(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_voltage = Some(value.into());
self
}
/// Sets the optional `maxVoltage` field.
#[must_use]
pub fn with_max_voltage(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_voltage = Some(value.into());
self
}
/// Sets the optional `evTargetEnergyRequest` field.
#[must_use]
pub fn with_ev_target_energy_request(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_target_energy_request = Some(value.into());
self
}
/// Sets the optional `evMinEnergyRequest` field.
#[must_use]
pub fn with_ev_min_energy_request(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.ev_min_energy_request = Some(value.into());
self
}
/// Sets the optional `evMaxEnergyRequest` field.
#[must_use]
pub fn with_ev_max_energy_request(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.ev_max_energy_request = Some(value.into());
self
}
/// Sets the optional `evMinV2XEnergyRequest` field.
#[must_use]
pub fn with_ev_min_v2_x_energy_request(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_min_v2_x_energy_request = Some(value.into());
self
}
/// Sets the optional `evMaxV2XEnergyRequest` field.
#[must_use]
pub fn with_ev_max_v2_x_energy_request(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.ev_max_v2_x_energy_request = Some(value.into());
self
}
/// Sets the optional `targetSoC` field.
#[must_use]
pub fn with_target_so_c(mut self, value: i32) -> Self {
self.target_so_c = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for V2XChargingParameters {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("targetSoC");
if let Some(value) = &self.target_so_c {
validate::int_range(i64::from(*value), Some(0), Some(100), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// *(2.1)* A point of a frequency-watt curve.
///
/// The OCPP 2.1 `V2XFreqWattPoint` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct V2XFreqWattPoint {
/// Net frequency in Hz.
pub frequency: crate::types::Decimal,
/// Power in W to charge (positive) or discharge (negative) at specified frequency.
pub power: crate::types::Decimal,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl V2XFreqWattPoint {
/// Creates a `V2XFreqWattPoint` from its required fields.
#[must_use]
pub fn new(
frequency: impl Into<crate::types::Decimal>,
power: impl Into<crate::types::Decimal>,
) -> Self {
Self {
frequency: frequency.into(),
power: power.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for V2XFreqWattPoint {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// *(2.1)* A point of a signal-watt curve.
///
/// The OCPP 2.1 `V2XSignalWattPoint` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct V2XSignalWattPoint {
/// Signal value from an AFRRSignalRequest.
#[serde(deserialize_with = "crate::types::integer::one")]
pub signal: i32,
/// Power in W to charge (positive) or discharge (negative) at specified frequency.
pub power: crate::types::Decimal,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl V2XSignalWattPoint {
/// Creates a `V2XSignalWattPoint` from its required fields.
#[must_use]
pub fn new(signal: i32, power: impl Into<crate::types::Decimal>) -> Self {
Self {
signal,
power: power.into(),
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for V2XSignalWattPoint {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// VPN Configuration settings
///
/// The OCPP 2.1 `VPN` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct VPN {
/// VPN Server Address
pub server: String,
/// VPN User
pub user: String,
/// *(2.1)* VPN Password.
pub password: String,
/// VPN shared secret.
pub key: String,
/// The `type` member.
pub r#type: VPNEnum,
/// VPN group.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub group: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl VPN {
/// Creates a `VPN` from its required fields.
#[must_use]
pub fn new(
server: impl Into<String>,
user: impl Into<String>,
password: impl Into<String>,
key: impl Into<String>,
r#type: VPNEnum,
) -> Self {
Self {
server: server.into(),
user: user.into(),
password: password.into(),
key: key.into(),
r#type,
group: None,
custom_data: None,
}
}
/// Sets the optional `group` field.
#[must_use]
pub fn with_group(mut self, value: impl Into<String>) -> Self {
self.group = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for VPN {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("server");
validate::string(self.server.as_str(), None, Some(2000), path, out);
path.pop();
path.push_key("user");
validate::string(self.user.as_str(), None, Some(50), path, out);
path.pop();
path.push_key("password");
validate::string(self.password.as_str(), None, Some(64), path, out);
path.pop();
path.push_key("key");
validate::string(self.key.as_str(), None, Some(255), path, out);
path.pop();
path.push_key("type");
Validate::validate_at(&self.r#type, path, out);
path.pop();
path.push_key("group");
if let Some(value) = &self.group {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Reference key to a component-variable.
///
/// The OCPP 2.1 `Variable` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Variable {
/// Name of the variable. Name should be taken from the list of standardized variable names whenever possible. Case Insensitive. strongly advised to use Camel Case.
pub name: String,
/// Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly advised to use Camel Case.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub instance: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl Variable {
/// Creates a `Variable` from its required fields.
#[must_use]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
instance: None,
custom_data: None,
}
}
/// Sets the optional `instance` field.
#[must_use]
pub fn with_instance(mut self, value: impl Into<String>) -> Self {
self.instance = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for Variable {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("name");
validate::string(self.name.as_str(), None, Some(50), path, out);
path.pop();
path.push_key("instance");
if let Some(value) = &self.instance {
validate::string(value.as_str(), None, Some(50), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Attribute data of a variable.
///
/// The OCPP 2.1 `VariableAttribute` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct VariableAttribute {
/// The `type` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub r#type: Option<Attribute>,
/// Value of the attribute. May only be omitted when mutability is set to 'WriteOnly'.
///
/// The Configuration Variable <<configkey-reporting-value-size,ReportingValueSize>> can be used to limit GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max size of these values will always remain equal.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
/// The `mutability` member.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub mutability: Option<Mutability>,
/// If true, value will be persistent across system reboots or power down. Default when omitted is false.
/// Schema default: `false`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub persistent: Option<bool>,
/// If true, value that will never be changed by the Charging Station at runtime. Default when omitted is false.
/// Schema default: `false`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub constant: Option<bool>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl VariableAttribute {
/// Creates an empty `VariableAttribute`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `type` field.
#[must_use]
pub fn with_type(mut self, value: Attribute) -> Self {
self.r#type = Some(value);
self
}
/// Sets the optional `value` field.
#[must_use]
pub fn with_value(mut self, value: impl Into<String>) -> Self {
self.value = Some(value.into());
self
}
/// Sets the optional `mutability` field.
#[must_use]
pub fn with_mutability(mut self, value: Mutability) -> Self {
self.mutability = Some(value);
self
}
/// Sets the optional `persistent` field.
#[must_use]
pub fn with_persistent(mut self, value: bool) -> Self {
self.persistent = Some(value);
self
}
/// Sets the optional `constant` field.
#[must_use]
pub fn with_constant(mut self, value: bool) -> Self {
self.constant = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for VariableAttribute {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("type");
if let Some(value) = &self.r#type {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("value");
if let Some(value) = &self.value {
validate::string(value.as_str(), None, Some(2500), path, out);
}
path.pop();
path.push_key("mutability");
if let Some(value) = &self.mutability {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// Fixed read-only parameters of a variable.
///
/// The OCPP 2.1 `VariableCharacteristics` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct VariableCharacteristics {
/// The `dataType` member.
#[serde(rename = "dataType")]
pub data_type: Data,
/// Flag indicating if this variable supports monitoring.
#[serde(rename = "supportsMonitoring")]
pub supports_monitoring: bool,
/// Unit of the variable. When the transmitted value has a unit, this field SHALL be included.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub unit: Option<String>,
/// Minimum possible value of this variable.
#[serde(rename = "minLimit")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub min_limit: Option<crate::types::Decimal>,
/// Maximum possible value of this variable. When the datatype of this Variable is String, OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) string.
#[serde(rename = "maxLimit")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_limit: Option<crate::types::Decimal>,
/// *(2.1)* Maximum number of elements from _valuesList_ that are supported as _attributeValue_.
#[serde(rename = "maxElements")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "crate::types::integer::option")]
pub max_elements: Option<i32>,
/// Mandatory when _dataType_ = OptionList, MemberList or SequenceList. In that case _valuesList_ specifies the allowed values for the type.
///
/// The length of this field can be limited by DeviceDataCtrlr.ConfigurationValueSize.
///
/// * OptionList: The (Actual) Variable value must be a single value from the reported (CSV) enumeration list.
///
/// * MemberList: The (Actual) Variable value may be an (unordered) (sub-)set of the reported (CSV) valid values list.
///
/// * SequenceList: The (Actual) Variable value may be an ordered (priority, etc) (sub-)set of the reported (CSV) valid values.
///
/// This is a comma separated list.
///
/// The Configuration Variable <<configkey-configuration-value-size,ConfigurationValueSize>> can be used to limit SetVariableData.attributeValue and VariableCharacteristics.valuesList. The max size of these values will always remain equal.
#[serde(rename = "valuesList")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub values_list: Option<String>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl VariableCharacteristics {
/// Creates a `VariableCharacteristics` from its required fields.
#[must_use]
pub fn new(data_type: Data, supports_monitoring: bool) -> Self {
Self {
data_type,
supports_monitoring,
unit: None,
min_limit: None,
max_limit: None,
max_elements: None,
values_list: None,
custom_data: None,
}
}
/// Sets the optional `unit` field.
#[must_use]
pub fn with_unit(mut self, value: impl Into<String>) -> Self {
self.unit = Some(value.into());
self
}
/// Sets the optional `minLimit` field.
#[must_use]
pub fn with_min_limit(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.min_limit = Some(value.into());
self
}
/// Sets the optional `maxLimit` field.
#[must_use]
pub fn with_max_limit(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.max_limit = Some(value.into());
self
}
/// Sets the optional `maxElements` field.
#[must_use]
pub fn with_max_elements(mut self, value: i32) -> Self {
self.max_elements = Some(value);
self
}
/// Sets the optional `valuesList` field.
#[must_use]
pub fn with_values_list(mut self, value: impl Into<String>) -> Self {
self.values_list = Some(value.into());
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for VariableCharacteristics {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("dataType");
Validate::validate_at(&self.data_type, path, out);
path.pop();
path.push_key("unit");
if let Some(value) = &self.unit {
validate::string(value.as_str(), None, Some(16), path, out);
}
path.pop();
path.push_key("maxElements");
if let Some(value) = &self.max_elements {
validate::int_range(i64::from(*value), Some(1), None, path, out);
}
path.pop();
path.push_key("valuesList");
if let Some(value) = &self.values_list {
validate::string(value.as_str(), None, Some(1000), path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// A monitoring setting for a variable.
///
/// The OCPP 2.1 `VariableMonitoring` data type.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct VariableMonitoring {
/// Identifies the monitor.
#[serde(deserialize_with = "crate::types::integer::one")]
pub id: i32,
/// Monitor only active when a transaction is ongoing on a component relevant to this transaction.
pub transaction: bool,
/// Value for threshold or delta monitoring.
/// For Periodic or PeriodicClockAligned this is the interval in seconds.
pub value: crate::types::Decimal,
/// The `type` member.
pub r#type: Monitor,
/// The severity that will be assigned to an event that is triggered by this monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity level.
///
/// The severity levels have the following meaning: +
/// *0-Danger* +
/// Indicates lives are potentially in danger. Urgent attention is needed and action should be taken immediately. +
/// *1-Hardware Failure* +
/// Indicates that the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. +
/// *2-System Failure* +
/// Indicates that the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. +
/// *3-Critical* +
/// Indicates a critical error. Action is required. +
/// *4-Error* +
/// Indicates a non-urgent error. Action is required. +
/// *5-Alert* +
/// Indicates an alert event. Default severity for any type of monitoring event. +
/// *6-Warning* +
/// Indicates a warning event. Action may be required. +
/// *7-Notice* +
/// Indicates an unusual event. No immediate action is required. +
/// *8-Informational* +
/// Indicates a regular operational event. May be used for reporting, measuring throughput, etc. No action is required. +
/// *9-Debug* +
/// Indicates information useful to developers for debugging, not useful during operations.
#[serde(deserialize_with = "crate::types::integer::one")]
pub severity: i32,
/// The `eventNotificationType` member.
#[serde(rename = "eventNotificationType")]
pub event_notification_type: EventNotification,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl VariableMonitoring {
/// Creates a `VariableMonitoring` from its required fields.
#[must_use]
pub fn new(
id: i32,
transaction: bool,
value: impl Into<crate::types::Decimal>,
r#type: Monitor,
severity: i32,
event_notification_type: EventNotification,
) -> Self {
Self {
id,
transaction,
value: value.into(),
r#type,
severity,
event_notification_type,
custom_data: None,
}
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for VariableMonitoring {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("id");
validate::int_range(i64::from(self.id), Some(0), None, path, out);
path.pop();
path.push_key("type");
Validate::validate_at(&self.r#type, path, out);
path.pop();
path.push_key("severity");
validate::int_range(i64::from(self.severity), Some(0), None, path, out);
path.pop();
path.push_key("eventNotificationType");
Validate::validate_at(&self.event_notification_type, path, out);
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}
/// The OCPP 2.1 `VoltageParams` data type.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct VoltageParams {
/// EN 50549-1 chapter 4.9.3.4
/// Voltage threshold for the 10 min time window mean value monitoring.
/// The 10 min mean is recalculated up to every 3 s.
/// If the present voltage is above this threshold for more than the time defined by _hv10MinMeanValue_, the EV must trip.
/// This value is mandatory if _hv10MinMeanTripDelay_ is set.
#[serde(rename = "hv10MinMeanValue")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub hv10_min_mean_value: Option<crate::types::Decimal>,
/// Time for which the voltage is allowed to stay above the 10 min mean value.
/// After this time, the EV must trip.
/// This value is mandatory if OverVoltageMeanValue10min is set.
#[serde(rename = "hv10MinMeanTripDelay")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub hv10_min_mean_trip_delay: Option<crate::types::Decimal>,
/// The `powerDuringCessation` member.
#[serde(rename = "powerDuringCessation")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub power_during_cessation: Option<PowerDuringCessation>,
/// The `customData` member.
#[serde(rename = "customData")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub custom_data: Option<crate::types::CustomData>,
}
impl VoltageParams {
/// Creates an empty `VoltageParams`. Every field of this type is optional.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Sets the optional `hv10MinMeanValue` field.
#[must_use]
pub fn with_hv10_min_mean_value(mut self, value: impl Into<crate::types::Decimal>) -> Self {
self.hv10_min_mean_value = Some(value.into());
self
}
/// Sets the optional `hv10MinMeanTripDelay` field.
#[must_use]
pub fn with_hv10_min_mean_trip_delay(
mut self,
value: impl Into<crate::types::Decimal>,
) -> Self {
self.hv10_min_mean_trip_delay = Some(value.into());
self
}
/// Sets the optional `powerDuringCessation` field.
#[must_use]
pub fn with_power_during_cessation(mut self, value: PowerDuringCessation) -> Self {
self.power_during_cessation = Some(value);
self
}
/// Sets the optional `customData` field.
#[must_use]
pub fn with_custom_data(mut self, value: crate::types::CustomData) -> Self {
self.custom_data = Some(value);
self
}
}
impl Validate for VoltageParams {
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
path.push_key("powerDuringCessation");
if let Some(value) = &self.power_during_cessation {
Validate::validate_at(value, path, out);
}
path.pop();
path.push_key("customData");
if let Some(value) = &self.custom_data {
Validate::validate_at(value, path, out);
}
path.pop();
}
}