-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Smart Charging - SetChargingProfile object and data types (#26)
* Objects for Tokens authorization logic * add new lines at end of files * Smart Charging - SetChargingProfile object and data types * new lines at end of files * add ToString Methods * improve ToString * Name fix * Align class names with lib conventaion * CR fixes * remove required attribute and make all properties nullable --------- Co-authored-by: Lior Ben Ari <[email protected]>
- Loading branch information
1 parent
045ba08
commit 94301a3
Showing
8 changed files
with
210 additions
and
3 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System.Text; | ||
using System.Text.Json.Serialization; | ||
using OCPI.Enums.SmartCharging; | ||
|
||
namespace OCPI.Contracts.ChargingProfiles; | ||
|
||
public class OcpiChargingProfile | ||
{ | ||
/// <summary> | ||
/// Starting point of an absolute profile. If absent the profile | ||
/// will be relative to start of charging. | ||
/// </summary> | ||
[JsonPropertyName("start_date_time")] | ||
public DateTime? StartDateTime { get; set; } | ||
|
||
/// <summary> | ||
/// 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. | ||
/// </summary> | ||
[JsonPropertyName("duration")] | ||
public int? Duration { get; set; } | ||
|
||
/// <summary> | ||
/// The unit of measure. | ||
/// </summary> | ||
[JsonPropertyName("charging_rate_unit")] | ||
public ChargingRateUnit? ChargingRateUnit { get; set; } | ||
|
||
/// <summary> | ||
/// 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. | ||
/// </summary> | ||
[JsonPropertyName("min_charging_rate")] | ||
public decimal? MinChargingRate { get; set; } | ||
|
||
/// <summary> | ||
/// List of ChargingProfilePeriod elements defining | ||
/// maximum power or current usage over time. | ||
/// </summary> | ||
[JsonPropertyName("charging_profile_period")] | ||
public IEnumerable<OcpiChargingProfilePeriod>? 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(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfilePeriod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace OCPI.Contracts.ChargingProfiles; | ||
|
||
public class OcpiChargingProfilePeriod | ||
{ | ||
/// <summary> | ||
/// Start of the period, in seconds from the start of profile. The value of StartPeriod | ||
/// also defines the stop time of the previous period. | ||
/// </summary> | ||
[JsonPropertyName("start_period")] | ||
public int? StartPeriod { get; set; } | ||
|
||
/// <summary> | ||
/// 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. | ||
/// </summary> | ||
[JsonPropertyName("limit")] | ||
public decimal? Limit { get; set; } | ||
|
||
public override string ToString() => $"Start Period: {StartPeriod}, Limit: {Limit}"; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/OCPI.Net.Contracts/ChargingProfiles/OcpiChargingProfileResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Text.Json.Serialization; | ||
using OCPI.Enums.SmartCharging; | ||
|
||
namespace OCPI.Contracts.ChargingProfiles; | ||
public class OcpiChargingProfileResponse | ||
{ | ||
/// <summary> | ||
/// Response from the CPO on the ChargingProfile request. | ||
/// </summary> | ||
[JsonPropertyName("result")] | ||
public ChargingProfileResponseType? Result { get; set; } | ||
|
||
/// <summary> | ||
/// Response from the CPO on the ChargingProfile request. | ||
/// </summary> | ||
[JsonPropertyName("timeout")] | ||
public int? Timeout { get; set; } | ||
} |
19 changes: 19 additions & 0 deletions
19
src/OCPI.Net.Contracts/ChargingProfiles/OcpiSetChargingProfileRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace OCPI.Contracts.ChargingProfiles; | ||
public class OcpiSetChargingProfileRequest | ||
{ | ||
/// <summary> | ||
/// Contains limits for the available power or current over time. | ||
/// </summary> | ||
[JsonPropertyName("charging_profile")] | ||
public OcpiChargingProfile? ChargingProfile { get; set; } | ||
|
||
/// <summary> | ||
/// 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. | ||
/// </summary> | ||
[JsonPropertyName("response_url")] | ||
public string? ResponseUrl { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/OCPI.Net.Core/Enums/ChargingProfiles/ChargingProfileResponseType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace OCPI.Enums.SmartCharging; | ||
|
||
public enum ChargingProfileResponseType : byte | ||
{ | ||
//====================1x: Success======================== | ||
|
||
/// <summary> | ||
/// ChargingProfile request accepted by the CPO, request will be forwarded to the EVSE. | ||
/// </summary> | ||
[EnumMember(Value = "ACCEPTED")] | ||
Accepted = 11, | ||
|
||
//====================2x: Rejected======================== | ||
|
||
/// <summary> | ||
/// ChargingProfile request rejected by the CPO. (Session might not be from a customer of the eMSP | ||
/// that send this request) | ||
/// </summary> | ||
[EnumMember(Value = "REJECTED")] | ||
Rejected = 21, | ||
|
||
/// <summary> | ||
/// ChargingProfile request rejected by the CPO, requests are send more often then allowed. | ||
/// </summary> | ||
[EnumMember(Value = "TOO_OFTEN")] | ||
TooOften = 22, | ||
|
||
//====================3x: Fail======================== | ||
|
||
/// <summary> | ||
/// The ChargingProfiles not supported by this CPO, Charge Point, EVSE etc. | ||
/// </summary> | ||
[EnumMember(Value = "NOT_SUPPORTED")] | ||
NotSupported = 31, | ||
|
||
/// <summary> | ||
/// The Session in the requested command is not known by this CPO. | ||
/// </summary> | ||
[EnumMember(Value = "UNKNOWN_SESSION")] | ||
UnknownSession = 32, | ||
} |
27 changes: 27 additions & 0 deletions
27
src/OCPI.Net.Core/Enums/ChargingProfiles/ChargingRateUnit.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace OCPI.Enums.SmartCharging; | ||
|
||
public enum ChargingRateUnit : byte | ||
{ | ||
/// <summary> | ||
/// 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. | ||
/// </summary> | ||
[EnumMember(Value = "W")] | ||
Watts = 11, | ||
|
||
/// <summary> | ||
/// 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. | ||
/// </summary> | ||
[EnumMember(Value = "A")] | ||
Amperes = 12, | ||
} |