struct ChargingProfile {
int32_t id;
int32_t stackLevel;
ChargingProfilePurposeEnum chargingProfilePurpose;
ChargingProfileKindEnum chargingProfileKind;
std::vector<ChargingSchedule> chargingSchedule; // 1..3
std::optional<CustomData> customData;
std::optional<RecurrencyKindEnum> recurrencyKind;
std::optional<ocpp::DateTime> validFrom;
std::optional<ocpp::DateTime> validTo;
std::optional<CiString<36>> transactionId;
};
struct ChargingSchedule {
int32_t id;
ChargingRateUnitEnum chargingRateUnit;
std::vector<ChargingSchedulePeriod> chargingSchedulePeriod; // 1..1024
std::optional<CustomData> customData;
std::optional<ocpp::DateTime> startSchedule;
std::optional<int32_t> duration;
std::optional<float> minChargingRate;
std::optional<SalesTariff> salesTariff;
};
struct ChargingSchedule {
int32_t id;
ChargingRateUnitEnum chargingRateUnit;
std::vector<ChargingSchedulePeriod> chargingSchedulePeriod; // 1..1024
std::optional<CustomData> customData;
std::optional<ocpp::DateTime> startSchedule;
std::optional<int32_t> duration;
std::optional<float> minChargingRate;
std::optional<SalesTariff> salesTariff;
};
struct CompositeSchedule {
std::vector<ChargingSchedulePeriod> chargingSchedulePeriod;
int32_t evseId;
int32_t duration;
ocpp::DateTime scheduleStart;
ChargingRateUnitEnum chargingRateUnit;
std::optional<CustomData> customData;
};
struct ChargingSchedulePeriod {
int32_t startPeriod;
float limit;
std::optional<CustomData> customData;
std::optional<int32_t> numberPhases;
std::optional<int32_t> phaseToUse; // TODO Phase to use
};
struct period_entry_t {
ocpp::DateTime start;
ocpp::DateTime end;
float limit;
std::optional<std::int32_t> number_phases;
std::int32_t stack_level;
ChargingRateUnitEnum charging_rate_unit;
std::optional<float> min_charging_rate;
};
struct EnhancedTransaction : public Transaction {
std::optional<IdToken> id_token;
std::optional<IdToken> group_id_token;
std::optional<int32_t> reservation_id;
int32_t connector_id;
int32_t seq_no = 0;
std::optional<float> active_energy_import_start_value;
bool check_max_active_import_energy;
ClockAlignedTimer sampled_tx_updated_meter_values_timer;
ClockAlignedTimer sampled_tx_ended_meter_values_timer;
ClockAlignedTimer aligned_tx_updated_meter_values_timer;
ClockAlignedTimer aligned_tx_ended_meter_values_timer;
int32_t get_seq_no();
Transaction get_transaction();
};
struct Transaction {
CiString<36> transactionId;
std::optional<CustomData> customData;
std::optional<ChargingStateEnum> chargingState;
std::optional<int32_t> timeSpentCharging;
std::optional<ReasonEnum> stoppedReason;
std::optional<int32_t> remoteStartId;
};
#####################################################
// 1. chose profile with highest stack level // 2. chose ChargingSchedulePeriods within time window // 3. Whichever one has the lowest limit wins
struct period_entry_t {
void init(const DateTime& in_start, int in_duration, const ChargingSchedulePeriod& in_period,
const ChargingProfile& in_profile);
bool validate(const ChargingProfile& profile, const DateTime& now);
DateTime start;
DateTime end;
float limit;
std::optional<std::int32_t> number_phases;
std::int32_t stack_level;
ChargingRateUnit charging_rate_unit;
std::optional<float> min_charging_rate;
};
struct ChargingProfile {
int32_t chargingProfileId;
int32_t stackLevel;
ChargingProfilePurposeType chargingProfilePurpose;
ChargingProfileKindType chargingProfileKind;
ChargingSchedule chargingSchedule;
std::optional<int32_t> transactionId;
std::optional<RecurrencyKindType> recurrencyKind;
std::optional<ocpp::DateTime> validFrom;
std::optional<ocpp::DateTime> validTo;
};
struct ChargingSchedule {
ChargingRateUnit chargingRateUnit;
std::vector<ChargingSchedulePeriod> chargingSchedulePeriod;
std::optional<int32_t> duration;
std::optional<ocpp::DateTime> startSchedule;
std::optional<float> minChargingRate;
};
struct EnhancedChargingSchedule {
ChargingRateUnit chargingRateUnit;
std::vector<EnhancedChargingSchedulePeriod> chargingSchedulePeriod;
std::optional<int32_t> duration;
std::optional<ocpp::DateTime> startSchedule;
std::optional<float> minChargingRate;
};
struct ChargingSchedulePeriod {
int32_t startPeriod;
float limit;
std::optional<int32_t> numberPhases;
};
struct EnhancedChargingSchedulePeriod {
int32_t startPeriod;
float limit;
std::optional<int32_t> numberPhases;
int32_t stackLevel;
};
struct Connector {
int32_t id;
std::optional<Measurement> measurement;
double max_current_offered = 0;
double max_power_offered = 0;
std::shared_ptr<Transaction> transaction = nullptr;
std::map<int, ChargingProfile> stack_level_tx_default_profiles_map;
std::map<int, ChargingProfile> stack_level_tx_profiles_map;
explicit Connector(const int id) : id(id){};
};
struct EnhancedTransaction : public Transaction {
std::optional<IdToken> id_token;
std::optional<IdToken> group_id_token;
std::optional<int32_t> reservation_id;
int32_t connector_id;
int32_t seq_no = 0;
std::optional<float> active_energy_import_start_value;
bool check_max_active_import_energy;
ClockAlignedTimer sampled_tx_updated_meter_values_timer;
ClockAlignedTimer sampled_tx_ended_meter_values_timer;
ClockAlignedTimer aligned_tx_updated_meter_values_timer;
ClockAlignedTimer aligned_tx_ended_meter_values_timer;
int32_t get_seq_no();
Transaction get_transaction();
};
struct Transaction {
CiString<36> transactionId;
std::optional<CustomData> customData;
std::optional<ChargingStateEnum> chargingState;
std::optional<int32_t> timeSpentCharging;
std::optional<ReasonEnum> stoppedReason;
std::optional<int32_t> remoteStartId;
};
struct StampedEnergyWh {
ocpp::DateTime timestamp; ///< A timestamp associated with the energy value
double energy_Wh; ///< The energy value in Wh
StampedEnergyWh(ocpp::DateTime timestamp, double energy_Wh) {
this->timestamp = timestamp;
this->energy_Wh = energy_Wh;
}
};