#[non_exhaustive]pub enum ConversionError {
TransactionIdNotInteger(String),
PurposeNotInVersion {
purpose: Purpose,
version: Version,
},
UnmodelledKind(&'static str),
UnknownValue {
field: &'static str,
value: String,
},
NoSchedule,
SchedulesNotInVersion(usize),
PeriodWithoutLimit {
period: usize,
},
UnmodelledField {
field: &'static str,
period: Option<usize>,
},
OutOfRange {
field: &'static str,
},
}Expand description
Why a profile could not cross the wire.
The domain Profile across the wire, in both directions, for every version.
A CSMS sends a Profile as a SetChargingProfileRequest; a station — or a Local Controller
that wants to know what the CSMS asked for — turns a received ChargingProfile back into a
Profile for the composite calculation. Each direction refuses, with a
ConversionError, every field the other side cannot carry with its meaning: a default
here would be a profile the station applies differently from the one that was sent.
What is refused, and why:
- 1.6 numbers transactions; a domain transaction id that is not an integer cannot be a 1.6
TxProfile(it would bind to another transaction, or to none). - Purposes a version lacks — 1.6 has no
ChargingStationExternalConstraints, neither 1.6 nor 2.0.1 hasPriorityChargingorLocalGeneration. - 2.1
Dynamicprofiles, periods without alimit, and everything that is not a plain ceiling:limit_L2/limit_L3(which turnlimitinto a per-phase value), discharge limits, setpoints, V2X curves and baselines, anoperationModeother thanChargingOnly,limitAtSoC,useLocalTime,randomizedDelay. Those are V2X control (block Q), not a limit schedule — build those withv2x, which produces the wire profile directly. - 1.6
phaseToUse, which 1.6 cannot say.
Carried by neither direction, on purpose, because none of them changes the limit: the
ISO 15118 tariff and price schedules and their signatures, customData, 2.1
powerTolerance, evseSleep, preconditioningRequest, and the 2.1 offline fields
(maxOfflineDuration, invalidAfterOfflineDuration) — the composite here is the one that
applies while online.
use ocpp_kit::smart_charging::{Period, Profile, ProfileKind, Purpose, RateUnit, Schedule};
use ocpp_kit::types::Decimal;
let profile = Profile::new(
1,
0,
Purpose::TxProfile,
ProfileKind::Relative,
Schedule::new(1, RateUnit::A, vec![Period::new(0, Decimal::from(16))]),
)
.on_evse(1)
.for_transaction("42");
let request = profile.set_request_v1_6()?; // 1.6 numbers its transactions
assert_eq!(request.cs_charging_profiles.transaction_id, Some(42));
let back = Profile::from_v1_6(&request.cs_charging_profiles, 1)?;
assert_eq!(back, profile);
let not_a_number = profile.clone().for_transaction("abc");
assert!(not_a_number.to_v1_6().is_err());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
TransactionIdNotInteger(String)
A 1.6 TxProfile needs an integer transaction id.
PurposeNotInVersion
The version has no such purpose.
UnmodelledKind(&'static str)
A profile kind the domain does not model (2.1 Dynamic).
UnknownValue
An enumeration value the station sent that no version defines, kept by lenient decoding.
NoSchedule
A profile without a schedule.
SchedulesNotInVersion(usize)
1.6 carries exactly one schedule per profile.
PeriodWithoutLimit
A 2.1 period without a limit — a setpoint operation mode, not a ceiling.
UnmodelledField
A field that would change what the profile means, which the target cannot carry.
Fields
OutOfRange
A number that does not fit the target’s integer type.
Trait Implementations§
Source§impl Clone for ConversionError
impl Clone for ConversionError
Source§impl Debug for ConversionError
impl Debug for ConversionError
Source§impl Display for ConversionError
impl Display for ConversionError
impl Eq for ConversionError
Source§impl Error for ConversionError
Available on crate feature std only.
impl Error for ConversionError
std only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()