Skip to content

Commit d1af3e2

Browse files
authored
Reintroduce getter function for transaction id (#992)
* Add back get_evse_transaction_id Signed-off-by: Marc Emmers <m.emmers@alfen.com> * Remove method with no implementation Signed-off-by: Marc Emmers <m.emmers@alfen.com> * Fix clang-format Signed-off-by: Marc Emmers <m.emmers@alfen.com> * Apply suggestions from code review Signed-off-by: Marc Emmers <35759328+marcemmers@users.noreply.github.com> --------- Signed-off-by: Marc Emmers <m.emmers@alfen.com> Signed-off-by: Marc Emmers <35759328+marcemmers@users.noreply.github.com>
1 parent 260bcec commit d1af3e2

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

include/ocpp/v201/charge_point.hpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ class ChargePointInterface {
195195
on_charging_state_changed(const uint32_t evse_id, const ChargingStateEnum charging_state,
196196
const TriggerReasonEnum trigger_reason = TriggerReasonEnum::ChargingStateChanged) = 0;
197197

198+
/// \brief Gets the transaction id for a certain \p evse_id if there is an active transaction
199+
/// \param evse_id The evse to get the transaction for
200+
/// \return The transaction id if a transaction is active, otherwise nullopt
201+
virtual std::optional<std::string> get_evse_transaction_id(int32_t evse_id) = 0;
202+
198203
/// \brief Event handler that can be called to trigger a NotifyEvent.req with the given \p events
199204
/// \param events
200205
virtual void on_event(const std::vector<EventData>& events) = 0;
@@ -399,14 +404,6 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
399404

400405
void message_callback(const std::string& message);
401406

402-
///
403-
/// \brief Check if the connector exists on the given evse id.
404-
/// \param evse_id The evse id to check for.
405-
/// \param connector_type The connector type.
406-
/// \return False if evse id does not exist or evse does not have the given connector type.
407-
///
408-
bool does_connector_exist(const uint32_t evse_id, std::optional<ConnectorEnum> connector_type);
409-
410407
/// \brief Get the value optional offline flag
411408
/// \return true if the charge point is offline. std::nullopt if it is online;
412409
bool is_offline();
@@ -558,6 +555,8 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
558555
const uint32_t evse_id, const ChargingStateEnum charging_state,
559556
const TriggerReasonEnum trigger_reason = TriggerReasonEnum::ChargingStateChanged) override;
560557

558+
std::optional<std::string> get_evse_transaction_id(int32_t evse_id) override;
559+
561560
AuthorizeResponse validate_token(const IdToken id_token, const std::optional<CiString<5500>>& certificate,
562561
const std::optional<std::vector<OCSPRequestData>>& ocsp_request_data) override;
563562

lib/ocpp/v201/charge_point.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,16 @@ bool ChargePoint::on_charging_state_changed(const uint32_t evse_id, const Chargi
333333
return true;
334334
}
335335

336+
std::optional<std::string> ChargePoint::get_evse_transaction_id(int32_t evse_id) {
337+
const auto& tx = this->evse_manager->get_evse(evse_id).get_transaction();
338+
339+
if (tx != nullptr) {
340+
return tx->transactionId.get();
341+
}
342+
343+
return std::nullopt;
344+
}
345+
336346
AuthorizeResponse ChargePoint::validate_token(const IdToken id_token, const std::optional<CiString<5500>>& certificate,
337347
const std::optional<std::vector<OCSPRequestData>>& ocsp_request_data) {
338348
return this->authorization->validate_token(id_token, certificate, ocsp_request_data);

0 commit comments

Comments
 (0)