ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
Public Member Functions | List of all members
ocpp::v16::Transaction Class Reference

Contains all transaction related data, such as the ID and power meter values. More...

#include <transaction.hpp>

Public Member Functions

 Transaction (const int32_t transaction_id, const int32_t &connector, const std::string &session_id, const CiString< 20 > &id_token, const double meter_start, std::optional< int32_t > reservation_id, const ocpp::DateTime &timestamp, std::unique_ptr< Everest::SteadyTimer > meter_values_sample_timer)
 Creates a new Transaction object, taking ownership of the provided meter_values_sample_timer on the provided connector.
 
std::shared_ptr< StampedEnergyWhget_start_energy_wh ()
 Provides the energy in Wh at the start of the transaction. More...
 
void add_stop_energy_wh (std::shared_ptr< StampedEnergyWh > stop_energy_wh)
 Adds the energy in Wh stop_energy_wh to the transaction. This also stops the collection of further meter values.
 
std::shared_ptr< StampedEnergyWhget_stop_energy_wh ()
 Provides the energy in Wh at the end of the transaction. More...
 
std::optional< int32_t > get_reservation_id ()
 Provides the reservation id of the transaction if present. More...
 
int32_t get_connector ()
 Provides the connector of this transaction. More...
 
CiString< 20 > get_id_tag ()
 Provides the authorized id tag of this Transaction. More...
 
void add_meter_value (MeterValue meter_value)
 Adds the provided meter_value to a chronological list of powermeter values.
 
std::vector< MeterValueget_meter_values ()
 Provides all recorded powermeter values. More...
 
bool change_meter_values_sample_interval (int32_t interval)
 Changes the sample interval of the powermeter values sampling timer. More...
 
void add_clock_aligned_meter_value (MeterValue meter_value)
 Adds the provided meter_value to a chronological list of clock aligned powermeter values.
 
std::optional< int32_t > get_transaction_id ()
 Provides the id of this transaction. More...
 
int32_t get_internal_transaction_id ()
 Returns the internal transaction id.
 
std::string get_session_id ()
 Provides the id of this session. More...
 
void set_start_transaction_message_id (const std::string &message_id)
 Sets the start transaction message id using the provides message_id.
 
std::string get_start_transaction_message_id ()
 Provides the start transaction message id.
 
void set_stop_transaction_message_id (const std::string &message_id)
 Sets the stop transaction message id using the provides message_id.
 
std::string get_stop_transaction_message_id ()
 Provides the stop transaction message id.
 
void set_transaction_id (int32_t transaction_id)
 Sets the transaction id.
 
std::vector< TransactionDataget_transaction_data ()
 Provides all recorded sampled and clock aligned powermeter values. More...
 
void stop ()
 Marks the transaction as stopped/inactive.
 
bool is_active ()
 Indicates if the transaction is active. Active means that the transaction for this session is not null and no StopTransaction.req has been pushed to the message queue yet.
 
bool is_finished ()
 Indicates if a StopTransaction.req for this transaction has already been pushed to the message queue.
 
void set_finished ()
 Sets the finished flag for this transaction. This is done when a StopTransaction.req has been pushed to the message queue.
 
void set_has_signed_meter_values ()
 Sets the has_signed_meter_value flag for this transaction, this function is called from on_transaction_started and on_transaction_stopped.
 
bool get_has_signed_meter_values ()
 Indicates if this transaction has signed meter values or not, this function is called from on_transaction_started and on_transaction_stopped. More...
 

Detailed Description

Contains all transaction related data, such as the ID and power meter values.

Member Function Documentation

◆ change_meter_values_sample_interval()

bool ocpp::v16::Transaction::change_meter_values_sample_interval ( int32_t  interval)

Changes the sample interval of the powermeter values sampling timer.

Returns
true if successful

◆ get_connector()

int32_t ocpp::v16::Transaction::get_connector ( )

Provides the connector of this transaction.

Returns
the connector

◆ get_has_signed_meter_values()

bool ocpp::v16::Transaction::get_has_signed_meter_values ( )

Indicates if this transaction has signed meter values or not, this function is called from on_transaction_started and on_transaction_stopped.

Returns
a boolean value indicating if this transaction has signed meter values or not

◆ get_id_tag()

CiString< 20 > ocpp::v16::Transaction::get_id_tag ( )

Provides the authorized id tag of this Transaction.

Returns
the authorized id tag

◆ get_meter_values()

std::vector< MeterValue > ocpp::v16::Transaction::get_meter_values ( )

Provides all recorded powermeter values.

Returns
a vector of powermeter values

◆ get_reservation_id()

std::optional< int32_t > ocpp::v16::Transaction::get_reservation_id ( )

Provides the reservation id of the transaction if present.

Returns
the reservation id

◆ get_session_id()

std::string ocpp::v16::Transaction::get_session_id ( )

Provides the id of this session.

Returns
the session_id

◆ get_start_energy_wh()

std::shared_ptr< StampedEnergyWh > ocpp::v16::Transaction::get_start_energy_wh ( )

Provides the energy in Wh at the start of the transaction.

Returns
the energy in Wh combined with a timestamp

◆ get_stop_energy_wh()

std::shared_ptr< StampedEnergyWh > ocpp::v16::Transaction::get_stop_energy_wh ( )

Provides the energy in Wh at the end of the transaction.

Returns
the energy in Wh combined with a timestamp

◆ get_transaction_data()

std::vector< TransactionData > ocpp::v16::Transaction::get_transaction_data ( )

Provides all recorded sampled and clock aligned powermeter values.

Returns
a vector of sampled and clock aligned powermeter values packaged into a TransactionData object

◆ get_transaction_id()

std::optional< int32_t > ocpp::v16::Transaction::get_transaction_id ( )

Provides the id of this transaction.

Returns
the transaction id

The documentation for this class was generated from the following files: