diff --git a/src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfile.cs b/src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfile.cs new file mode 100644 index 0000000..058c4da --- /dev/null +++ b/src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfile.cs @@ -0,0 +1,78 @@ +using System.Text; +using System.Text.Json.Serialization; +using OCPI.Enums.SmartCharging; + +namespace OCPI.Contracts.ChargingProfiles; + +public class OcpiChargingProfile +{ + /// + /// Starting point of an absolute profile. If absent the profile + /// will be relative to start of charging. + /// + [JsonPropertyName("start_date_time")] + public DateTime? StartDateTime { get; set; } + + /// + /// Duration of the charging profile in seconds. If the + /// duration is left empty, the last period will continue + /// indefinitely or until end of the transaction in case + /// start_date_time is absent. + /// + [JsonPropertyName("duration")] + public int? Duration { get; set; } + + /// + /// The unit of measure. + /// + [JsonPropertyName("charging_rate_unit")] + public ChargingRateUnit? ChargingRateUnit { get; set; } + + /// + /// 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.Accepts at most one digit fraction. + /// + [JsonPropertyName("min_charging_rate")] + public decimal? MinChargingRate { get; set; } + + /// + /// List of ChargingProfilePeriod elements defining + /// maximum power or current usage over time. + /// + [JsonPropertyName("charging_profile_period")] + public IEnumerable? ChargingProfilePeriods { get; set; } + + public override string ToString() + { + var toStringBuilder = new StringBuilder(); + + toStringBuilder.Append($"Start date time: {StartDateTime}, "); + toStringBuilder.AppendLine($"Duration: {Duration},"); + toStringBuilder.Append($"Charging rate unit: {ChargingRateUnit}, "); + toStringBuilder.AppendLine($"Minimum charging rate: {MinChargingRate},"); + + var chargingProfilePeriodToString = ChargingProfilePeriodsToString(); + toStringBuilder.Append(chargingProfilePeriodToString); + + return toStringBuilder.ToString(); + } + + private string ChargingProfilePeriodsToString() + { + if (ChargingProfilePeriods is null || !ChargingProfilePeriods.Any()) + return string.Empty; + + var toStringBuilder = new StringBuilder(); + toStringBuilder.AppendLine("ChargingProfilePeriods:"); + + var periodNum = 1; + foreach (var period in ChargingProfilePeriods) + toStringBuilder.Append($"Period #{periodNum++}: {period}; "); + + return toStringBuilder.ToString(); + } +} diff --git a/src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfilePeriod.cs b/src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfilePeriod.cs new file mode 100644 index 0000000..0f73d5b --- /dev/null +++ b/src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfilePeriod.cs @@ -0,0 +1,22 @@ +using System.Text.Json.Serialization; + +namespace OCPI.Contracts.ChargingProfiles; + +public class OcpiChargingProfilePeriod +{ + /// + /// Start of the period, in seconds from the start of profile. The value of StartPeriod + /// also defines the stop time of the previous period. + /// + [JsonPropertyName("start_period")] + public int? StartPeriod { get; set; } + + /// + /// Charging rate limit during the profile period, in the applicable chargingRateUnit, + /// for example in Amperes(A) or Watts(W). Accepts at most one digit fraction. + /// + [JsonPropertyName("limit")] + public decimal? Limit { get; set; } + + public override string ToString() => $"Start Period: {StartPeriod}, Limit: {Limit}"; +} diff --git a/src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfileResponse.cs b/src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfileResponse.cs new file mode 100644 index 0000000..3406674 --- /dev/null +++ b/src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfileResponse.cs @@ -0,0 +1,18 @@ +using System.Text.Json.Serialization; +using OCPI.Enums.SmartCharging; + +namespace OCPI.Contracts.ChargingProfiles; +public class OcpiChargingProfileResponse +{ + /// + /// Response from the CPO on the ChargingProfile request. + /// + [JsonPropertyName("result")] + public ChargingProfileResponseType? Result { get; set; } + + /// + /// Response from the CPO on the ChargingProfile request. + /// + [JsonPropertyName("timeout")] + public int? Timeout { get; set; } +} diff --git a/src/OCPI.Net.Contracts/ChargingProfiles/OcpiSetChargingProfileRequest.cs b/src/OCPI.Net.Contracts/ChargingProfiles/OcpiSetChargingProfileRequest.cs new file mode 100644 index 0000000..8a05855 --- /dev/null +++ b/src/OCPI.Net.Contracts/ChargingProfiles/OcpiSetChargingProfileRequest.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +namespace OCPI.Contracts.ChargingProfiles; +public class OcpiSetChargingProfileRequest +{ + /// + /// Contains limits for the available power or current over time. + /// + [JsonPropertyName("charging_profile")] + public OcpiChargingProfile? ChargingProfile { get; set; } + + /// + /// URL that the ChargingProfileResult POST should be send to. This + /// URL might contain an unique ID to be able to distinguish between + /// GET ActiveChargingProfile requests. + /// + [JsonPropertyName("response_url")] + public string? ResponseUrl { get; set; } +} diff --git a/src/OCPI.Net.Contracts/Token/AuthorizationInfo.cs b/src/OCPI.Net.Contracts/Token/OcpiAuthorizationInfo.cs similarity index 92% rename from src/OCPI.Net.Contracts/Token/AuthorizationInfo.cs rename to src/OCPI.Net.Contracts/Token/OcpiAuthorizationInfo.cs index dcf3d54..57e6904 100644 --- a/src/OCPI.Net.Contracts/Token/AuthorizationInfo.cs +++ b/src/OCPI.Net.Contracts/Token/OcpiAuthorizationInfo.cs @@ -2,7 +2,7 @@ namespace OCPI.Contracts; -public class AuthorizationInfo +public class OcpiAuthorizationInfo { /// /// Status of the Token, and whether charging is allowed at the optionally @@ -23,7 +23,7 @@ public class AuthorizationInfo /// EV driver is allowed to charge at are returned. /// [JsonPropertyName("location")] - public LocationReferences? LocationReferences { get; set; } + public OcpiLocationReferences? LocationReferences { get; set; } /// /// Reference to the authorization given by the eMSP, when given, this diff --git a/src/OCPI.Net.Contracts/Token/LocationReferences.cs b/src/OCPI.Net.Contracts/Token/OcpiLocationReferences.cs similarity index 95% rename from src/OCPI.Net.Contracts/Token/LocationReferences.cs rename to src/OCPI.Net.Contracts/Token/OcpiLocationReferences.cs index 56a8434..72e44e1 100644 --- a/src/OCPI.Net.Contracts/Token/LocationReferences.cs +++ b/src/OCPI.Net.Contracts/Token/OcpiLocationReferences.cs @@ -2,7 +2,7 @@ namespace OCPI.Contracts; -public class LocationReferences +public class OcpiLocationReferences { /// /// Unique identifier for the location. diff --git a/src/OCPI.Net.Core/Enums/ChargingProfiles/ChargingProfileResponseType.cs b/src/OCPI.Net.Core/Enums/ChargingProfiles/ChargingProfileResponseType.cs new file mode 100644 index 0000000..c072a39 --- /dev/null +++ b/src/OCPI.Net.Core/Enums/ChargingProfiles/ChargingProfileResponseType.cs @@ -0,0 +1,43 @@ +using System.Runtime.Serialization; + +namespace OCPI.Enums.SmartCharging; + +public enum ChargingProfileResponseType : byte +{ + //====================1x: Success======================== + + /// + /// ChargingProfile request accepted by the CPO, request will be forwarded to the EVSE. + /// + [EnumMember(Value = "ACCEPTED")] + Accepted = 11, + + //====================2x: Rejected======================== + + /// + /// ChargingProfile request rejected by the CPO. (Session might not be from a customer of the eMSP + /// that send this request) + /// + [EnumMember(Value = "REJECTED")] + Rejected = 21, + + /// + /// ChargingProfile request rejected by the CPO, requests are send more often then allowed. + /// + [EnumMember(Value = "TOO_OFTEN")] + TooOften = 22, + + //====================3x: Fail======================== + + /// + /// The ChargingProfiles not supported by this CPO, Charge Point, EVSE etc. + /// + [EnumMember(Value = "NOT_SUPPORTED")] + NotSupported = 31, + + /// + /// The Session in the requested command is not known by this CPO. + /// + [EnumMember(Value = "UNKNOWN_SESSION")] + UnknownSession = 32, +} diff --git a/src/OCPI.Net.Core/Enums/ChargingProfiles/ChargingRateUnit.cs b/src/OCPI.Net.Core/Enums/ChargingProfiles/ChargingRateUnit.cs new file mode 100644 index 0000000..1f06870 --- /dev/null +++ b/src/OCPI.Net.Core/Enums/ChargingProfiles/ChargingRateUnit.cs @@ -0,0 +1,27 @@ +using System.Runtime.Serialization; + +namespace OCPI.Enums.SmartCharging; + +public enum ChargingRateUnit : byte +{ + /// + /// Watts (power) + /// This is the TOTAL allowed charging power. If used for AC Charging, the phase current should be + /// calculated via: Current per phase = Power / (Line Voltage * Number of Phases). The "Line Voltage" + /// used in the calculation is the Line to Neutral Voltage (VLN). In Europe and Asia VLN is typically + /// 220V or 230V and the corresponding Line to Line Voltage (VLL) is 380V and 400V. The "Number of + /// Phases" is the numberPhases from the ChargingProfilePeriod. It is usually more convenient to use + /// this for DC charging. Note that if numberPhases in a ChargingProfilePeriod is absent, 3 SHALL be + /// assumed. + /// + [EnumMember(Value = "W")] + Watts = 11, + + /// + /// Amperes (current) + /// The amount of Ampere per phase, not the sum of all phases. It is usually more convenient to use + /// this for AC charging. + /// + [EnumMember(Value = "A")] + Amperes = 12, +}