ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
profile.hpp
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2020 - 2024 Pionix GmbH and Contributors to EVerest
3
4#include <ocpp/v2/ocpp_types.hpp>
5
6namespace ocpp {
7namespace v2 {
8
10 int32_t startPeriod;
11 float current_limit;
12 float power_limit;
13 std::optional<int32_t> numberPhases;
14 std::optional<int32_t> phaseToUse;
15};
16
17using IntermediateProfile = std::vector<IntermediatePeriod>;
18
28 void init(const ocpp::DateTime& in_start, int in_duration, const ChargingSchedulePeriod& in_period,
29 const ChargingProfile& in_profile);
30 bool validate(const ChargingProfile& profile, const ocpp::DateTime& now);
31
32 ocpp::DateTime start;
34 float limit;
35 std::optional<std::int32_t> number_phases;
36 std::optional<std::int32_t> phase_to_use;
37 std::int32_t stack_level;
38 ChargingRateUnitEnum charging_rate_unit;
39 std::optional<float> min_charging_rate;
40
41 bool equals(const period_entry_t& other) const {
42 return (start == other.end) && (end == other.end) && (limit == other.limit) &&
43 (number_phases == other.number_phases) && (stack_level == other.stack_level) &&
44 (charging_rate_unit == other.charging_rate_unit) && (min_charging_rate == other.min_charging_rate);
45 }
46};
47
49int32_t elapsed_seconds(const ocpp::DateTime& to, const ocpp::DateTime& from);
50
52ocpp::DateTime floor_seconds(const ocpp::DateTime& dt);
53
60std::vector<DateTime> calculate_start(const DateTime& now, const DateTime& end,
61 const std::optional<DateTime>& session_start, const ChargingProfile& profile);
62
71std::vector<period_entry_t> calculate_profile_entry(const DateTime& now, const DateTime& end,
72 const std::optional<DateTime>& session_start,
73 const ChargingProfile& profile, std::uint8_t period_index);
74
82std::vector<period_entry_t> calculate_profile(const DateTime& now, const DateTime& end,
83 const std::optional<DateTime>& session_start,
84 const ChargingProfile& profile);
85
94std::vector<period_entry_t> calculate_all_profiles(const DateTime& now, const DateTime& end,
95 const std::optional<DateTime>& session_start,
96 const std::vector<ChargingProfile>& profiles,
97 ChargingProfilePurposeEnum purpose);
98
107IntermediateProfile generate_profile_from_periods(std::vector<period_entry_t>& periods, const DateTime& now,
108 const DateTime& end);
109
113IntermediateProfile merge_tx_profile_with_tx_default_profile(const IntermediateProfile& tx_profile,
114 const IntermediateProfile& tx_default_profile);
115
117IntermediateProfile merge_profiles_by_lowest_limit(const std::vector<IntermediateProfile>& profiles);
118
121IntermediateProfile merge_profiles_by_summing_limits(const std::vector<IntermediateProfile>& profiles,
122 float current_default, float power_default);
123
125void fill_gaps_with_defaults(IntermediateProfile& schedule, float default_limit, int32_t default_number_phases);
126
130std::vector<ChargingSchedulePeriod>
131convert_intermediate_into_schedule(const IntermediateProfile& profile, ChargingRateUnitEnum charging_rate_unit,
132 float default_limit, int32_t default_number_phases, float supply_voltage);
133
134} // namespace v2
135} // namespace ocpp
Contains a DateTime implementation that can parse and create RFC 3339 compatible strings.
Definition: types.hpp:109
Definition: ocpp_types.hpp:755
Definition: ocpp_types.hpp:236
Definition: profile.hpp:9
Returns elements from a specific ChargingProfile and ChargingSchedulePeriod for use in the calculatio...
Definition: profile.hpp:27
void init(const ocpp::DateTime &in_start, int in_duration, const ChargingSchedulePeriod &in_period, const ChargingProfile &in_profile)
populate a schedule period
Definition: profile.cpp:27