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

Represents an EVSE. An EVSE can contain multiple Connector objects, but can only supply energy to one of them. More...

#include <evse.hpp>

Inheritance diagram for ocpp::v2::Evse:
ocpp::v2::EvseInterface

Public Member Functions

 Evse (const int32_t evse_id, const int32_t number_of_connectors, DeviceModel &device_model, std::shared_ptr< DatabaseHandler > database_handler, std::shared_ptr< ComponentStateManagerInterface > component_state_manager, const std::function< void(const MeterValue &meter_value, EnhancedTransaction &transaction)> &transaction_meter_value_req, const std::function< void(int32_t evse_id)> &pause_charging_callback)
 Construct a new Evse object. More...
 
int32_t get_id () const
 Return the evse_id of this EVSE. More...
 
uint32_t get_number_of_connectors () const
 Returns the number of connectors of this EVSE. More...
 
bool does_connector_exist (const ConnectorEnum connector_type) const override
 Check if the given connector type exists on this evse. More...
 
std::optional< ConnectorStatusEnum > get_connector_status (std::optional< ConnectorEnum > connector_type) override
 Get connector status. More...
 
void open_transaction (const std::string &transaction_id, const int32_t connector_id, const DateTime &timestamp, const MeterValue &meter_start, const std::optional< IdToken > &id_token, const std::optional< IdToken > &group_id_token, const std::optional< int32_t > reservation_id, const ChargingStateEnum charging_state)
 Opens a new transaction. More...
 
void close_transaction (const DateTime &timestamp, const MeterValue &meter_stop, const ReasonEnum &reason)
 Closes the transaction on this evse by adding the given timestamp meter_stop and reason . More...
 
void start_checking_max_energy_on_invalid_id ()
 Start checking if the max energy on invalid id has exceeded. Will call pause_charging_callback when that happens. More...
 
bool has_active_transaction () const
 Indicates if a transaction is active at this evse. More...
 
bool has_active_transaction (const int32_t connector_id) const
 Indicates if a transaction is active at this evse at the given connector_id. More...
 
void release_transaction ()
 Releases the reference of the transaction on this evse. More...
 
std::unique_ptr< EnhancedTransaction > & get_transaction ()
 Returns a pointer to the EnhancedTransaction of this evse. More...
 
void submit_event (const int32_t connector_id, ConnectorEvent event)
 Submits the given event to the state machine controller of the connector with the given connector_id. More...
 
void on_meter_value (const MeterValue &meter_value)
 Event handler that should be called when a new meter_value for this evse is present. More...
 
MeterValue get_meter_value ()
 Returns the last present meter value for this evse. More...
 
MeterValue get_idle_meter_value ()
 Return the idle meter values for this evse. More...
 
void clear_idle_meter_values ()
 Clear the idle meter values for this evse. More...
 
Connectorget_connector (int32_t connector_id) const
 Returns a pointer to the connector with ID. More...
 
OperationalStatusEnum get_effective_operational_status ()
 Gets the effective Operative/Inoperative status of this EVSE. More...
 
void set_evse_operative_status (OperationalStatusEnum new_status, bool persist)
 Switches the operative status of the EVSE. More...
 
void set_connector_operative_status (int32_t connector_id, OperationalStatusEnum new_status, bool persist)
 Switches the operative status of a connector within this EVSE. More...
 
void restore_connector_operative_status (int32_t connector_id)
 Restores the operative status of a connector within this EVSE to the persisted status and recomputes its effective status. More...
 
OperationalStatusEnum get_connector_effective_operational_status (const int32_t connector_id) override
 Get the operational status of a connector within this evse. More...
 
CurrentPhaseType get_current_phase_type ()
 Returns the phase type for the EVSE based on its SupplyPhases. It can be AC, DC, or Unknown. More...
 
void set_meter_value_pricing_triggers (std::optional< double > trigger_metervalue_on_power_kw, std::optional< double > trigger_metervalue_on_energy_kwh, std::optional< DateTime > trigger_metervalue_at_time, std::function< void(const std::vector< MeterValue > &meter_values)> send_metervalue_function, boost::asio::io_service &io_service)
 Set pricing triggers to send the meter value. More...
 
virtual int32_t get_id () const =0
 Return the evse_id of this EVSE. More...
 
virtual uint32_t get_number_of_connectors () const =0
 Returns the number of connectors of this EVSE. More...
 
virtual bool does_connector_exist (ConnectorEnum connector_type) const =0
 Check if the given connector type exists on this evse. More...
 
virtual std::optional< ConnectorStatusEnum > get_connector_status (std::optional< ConnectorEnum > connector_type)=0
 Get connector status. More...
 
virtual void open_transaction (const std::string &transaction_id, const int32_t connector_id, const DateTime &timestamp, const MeterValue &meter_start, const std::optional< IdToken > &id_token, const std::optional< IdToken > &group_id_token, const std::optional< int32_t > reservation_id, const ChargingStateEnum charging_state)=0
 Opens a new transaction. More...
 
virtual void close_transaction (const DateTime &timestamp, const MeterValue &meter_stop, const ReasonEnum &reason)=0
 Closes the transaction on this evse by adding the given timestamp meter_stop and reason . More...
 
virtual void start_checking_max_energy_on_invalid_id ()=0
 Start checking if the max energy on invalid id has exceeded. Will call pause_charging_callback when that happens. More...
 
virtual bool has_active_transaction () const =0
 Indicates if a transaction is active at this evse. More...
 
virtual bool has_active_transaction (const int32_t connector_id) const =0
 Indicates if a transaction is active at this evse at the given connector_id. More...
 
virtual void release_transaction ()=0
 Releases the reference of the transaction on this evse. More...
 
virtual std::unique_ptr< EnhancedTransaction > & get_transaction ()=0
 Returns a pointer to the EnhancedTransaction of this evse. More...
 
virtual void submit_event (const int32_t connector_id, ConnectorEvent event)=0
 Submits the given event to the state machine controller of the connector with the given connector_id. More...
 
virtual void on_meter_value (const MeterValue &meter_value)=0
 Event handler that should be called when a new meter_value for this evse is present. More...
 
virtual MeterValue get_meter_value ()=0
 Returns the last present meter value for this evse. More...
 
virtual MeterValue get_idle_meter_value ()=0
 Return the idle meter values for this evse. More...
 
virtual void clear_idle_meter_values ()=0
 Clear the idle meter values for this evse. More...
 
virtual Connectorget_connector (int32_t connector_id) const =0
 Returns a pointer to the connector with ID. More...
 
virtual OperationalStatusEnum get_effective_operational_status ()=0
 Gets the effective Operative/Inoperative status of this EVSE. More...
 
virtual void set_evse_operative_status (OperationalStatusEnum new_status, bool persist)=0
 Switches the operative status of the EVSE. More...
 
virtual void set_connector_operative_status (int32_t connector_id, OperationalStatusEnum new_status, bool persist)=0
 Switches the operative status of a connector within this EVSE. More...
 
virtual void restore_connector_operative_status (int32_t connector_id)=0
 Restores the operative status of a connector within this EVSE to the persisted status and recomputes its effective status. More...
 
virtual OperationalStatusEnum get_connector_effective_operational_status (const int32_t connector_id)=0
 Get the operational status of a connector within this evse. More...
 
virtual CurrentPhaseType get_current_phase_type ()=0
 Returns the phase type for the EVSE based on its SupplyPhases. It can be AC, DC, or Unknown. More...
 
virtual void set_meter_value_pricing_triggers (std::optional< double > trigger_metervalue_on_power_kw, std::optional< double > trigger_metervalue_on_energy_kwh, std::optional< DateTime > trigger_metervalue_at_time, std::function< void(const std::vector< MeterValue > &meter_values)> send_metervalue_function, boost::asio::io_service &io_service)=0
 Set metervalue triggers for California Pricing. More...
 

Detailed Description

Represents an EVSE. An EVSE can contain multiple Connector objects, but can only supply energy to one of them.

Constructor & Destructor Documentation

◆ Evse()

ocpp::v2::Evse::Evse ( const int32_t  evse_id,
const int32_t  number_of_connectors,
DeviceModel device_model,
std::shared_ptr< DatabaseHandler database_handler,
std::shared_ptr< ComponentStateManagerInterface component_state_manager,
const std::function< void(const MeterValue &meter_value, EnhancedTransaction &transaction)> &  transaction_meter_value_req,
const std::function< void(int32_t evse_id)> &  pause_charging_callback 
)

Construct a new Evse object.

Parameters
evse_idid of the evse
number_of_connectorsof the evse
device_modelreference to the device model
database_handlershared_ptr to the database handler
component_state_managershared_ptr to the component state manager
transaction_meter_value_reqthat is called to transmit a meter value request related to a transaction
pause_charging_callbackthat is called when the charging should be paused due to max energy on invalid id being exceeded

Member Function Documentation

◆ clear_idle_meter_values()

void ocpp::v2::Evse::clear_idle_meter_values ( )
virtual

Clear the idle meter values for this evse.

Implements ocpp::v2::EvseInterface.

◆ close_transaction()

void ocpp::v2::Evse::close_transaction ( const DateTime timestamp,
const MeterValue meter_stop,
const ReasonEnum &  reason 
)
virtual

Closes the transaction on this evse by adding the given timestamp meter_stop and reason .

Parameters
timestamp
meter_stop
reason

Implements ocpp::v2::EvseInterface.

◆ does_connector_exist()

bool ocpp::v2::Evse::does_connector_exist ( const ConnectorEnum  connector_type) const
overridevirtual

Check if the given connector type exists on this evse.

Parameters
connector_typeThe connector type to check.
Returns
True if connector type is unknown or this evse has the given connector type.

Implements ocpp::v2::EvseInterface.

◆ get_connector()

Connector * ocpp::v2::Evse::get_connector ( int32_t  connector_id) const
virtual

Returns a pointer to the connector with ID.

Parameters
connector_idin this EVSE.

Implements ocpp::v2::EvseInterface.

◆ get_connector_effective_operational_status()

OperationalStatusEnum ocpp::v2::Evse::get_connector_effective_operational_status ( const int32_t  connector_id)
overridevirtual

Get the operational status of a connector within this evse.

Parameters
connector_idThe id of the connector.
Returns
The operational status.

Implements ocpp::v2::EvseInterface.

◆ get_connector_status()

std::optional< ConnectorStatusEnum > ocpp::v2::Evse::get_connector_status ( std::optional< ConnectorEnum >  connector_type)
overridevirtual

Get connector status.

This will search if there is a connector on this evse with status 'Available'. It will search through all connectors, optionally filtering by connector type, and return on the first connector that is 'Available'. If there is no 'Available' connector, it will return the status of the last found connector with the given connector type.

Parameters
connector_typeThe connector type to filter on (optional).
Returns
Connector status. If connector type is given and does not exist, std::nullopt.

Implements ocpp::v2::EvseInterface.

◆ get_current_phase_type()

CurrentPhaseType ocpp::v2::Evse::get_current_phase_type ( )
virtual

Returns the phase type for the EVSE based on its SupplyPhases. It can be AC, DC, or Unknown.

Implements ocpp::v2::EvseInterface.

◆ get_effective_operational_status()

OperationalStatusEnum ocpp::v2::Evse::get_effective_operational_status ( )
virtual

Gets the effective Operative/Inoperative status of this EVSE.

Implements ocpp::v2::EvseInterface.

◆ get_id()

int32_t ocpp::v2::Evse::get_id ( ) const
virtual

Return the evse_id of this EVSE.

Returns

Implements ocpp::v2::EvseInterface.

◆ get_idle_meter_value()

MeterValue ocpp::v2::Evse::get_idle_meter_value ( )
virtual

Return the idle meter values for this evse.

Returns
MeterValue type

Implements ocpp::v2::EvseInterface.

◆ get_meter_value()

MeterValue ocpp::v2::Evse::get_meter_value ( )
virtual

Returns the last present meter value for this evse.

Returns

Implements ocpp::v2::EvseInterface.

◆ get_number_of_connectors()

uint32_t ocpp::v2::Evse::get_number_of_connectors ( ) const
virtual

Returns the number of connectors of this EVSE.

Returns

Implements ocpp::v2::EvseInterface.

◆ get_transaction()

std::unique_ptr< EnhancedTransaction > & ocpp::v2::Evse::get_transaction ( )
virtual

Returns a pointer to the EnhancedTransaction of this evse.

Returns
pointer to transaction (nullptr if no transaction is active)

Implements ocpp::v2::EvseInterface.

◆ has_active_transaction() [1/2]

bool ocpp::v2::Evse::has_active_transaction ( ) const
virtual

Indicates if a transaction is active at this evse.

Returns

Implements ocpp::v2::EvseInterface.

◆ has_active_transaction() [2/2]

bool ocpp::v2::Evse::has_active_transaction ( const int32_t  connector_id) const
virtual

Indicates if a transaction is active at this evse at the given connector_id.

Parameters
connector_idid of the connector of the evse
Returns

Implements ocpp::v2::EvseInterface.

◆ on_meter_value()

void ocpp::v2::Evse::on_meter_value ( const MeterValue meter_value)
virtual

Event handler that should be called when a new meter_value for this evse is present.

Parameters
meter_value

Implements ocpp::v2::EvseInterface.

◆ open_transaction()

void ocpp::v2::Evse::open_transaction ( const std::string &  transaction_id,
const int32_t  connector_id,
const DateTime timestamp,
const MeterValue meter_start,
const std::optional< IdToken > &  id_token,
const std::optional< IdToken > &  group_id_token,
const std::optional< int32_t >  reservation_id,
const ChargingStateEnum  charging_state 
)
virtual

Opens a new transaction.

Parameters
transaction_idid of the transaction
connector_idid of the connector
timestamptimestamp of the start of the transaction
meter_startstart meter value of the transaction
id_tokenid_token with which the transaction was authorized / started
group_id_tokenoptional group id_token
reservationoptional reservation_id if evse was reserved
sampled_data_tx_updated_intervalInterval between sampling of metering (or other) data, intended to be transmitted via TransactionEventRequest (eventType = Updated) messages

Implements ocpp::v2::EvseInterface.

◆ release_transaction()

void ocpp::v2::Evse::release_transaction ( )
virtual

Releases the reference of the transaction on this evse.

Implements ocpp::v2::EvseInterface.

◆ restore_connector_operative_status()

void ocpp::v2::Evse::restore_connector_operative_status ( int32_t  connector_id)
virtual

Restores the operative status of a connector within this EVSE to the persisted status and recomputes its effective status.

Parameters
connector_idThe ID of the connector

Implements ocpp::v2::EvseInterface.

◆ set_connector_operative_status()

void ocpp::v2::Evse::set_connector_operative_status ( int32_t  connector_id,
OperationalStatusEnum  new_status,
bool  persist 
)
virtual

Switches the operative status of a connector within this EVSE.

Parameters
connector_idThe ID of the connector
new_statusThe operative status to switch to
persistTrue the updated operative state should be persisted

Implements ocpp::v2::EvseInterface.

◆ set_evse_operative_status()

void ocpp::v2::Evse::set_evse_operative_status ( OperationalStatusEnum  new_status,
bool  persist 
)
virtual

Switches the operative status of the EVSE.

Parameters
new_statusThe operative status to switch to
persistTrue the updated operative state should be persisted

Implements ocpp::v2::EvseInterface.

◆ set_meter_value_pricing_triggers()

void ocpp::v2::Evse::set_meter_value_pricing_triggers ( std::optional< double >  trigger_metervalue_on_power_kw,
std::optional< double >  trigger_metervalue_on_energy_kwh,
std::optional< DateTime trigger_metervalue_at_time,
std::function< void(const std::vector< MeterValue > &meter_values)>  send_metervalue_function,
boost::asio::io_service &  io_service 
)
virtual

Set pricing triggers to send the meter value.

Parameters
trigger_metervalue_on_power_kwTrigger for this amount of kw
trigger_metervalue_on_energy_kwhTrigger when amount of kwh is reached
trigger_metervalue_at_timeTrigger for a specific time
send_metervalue_functionFunction to send metervalues when trigger 'fires'
io_serviceIo service needed for the timer

Implements ocpp::v2::EvseInterface.

◆ start_checking_max_energy_on_invalid_id()

void ocpp::v2::Evse::start_checking_max_energy_on_invalid_id ( )
virtual

Start checking if the max energy on invalid id has exceeded. Will call pause_charging_callback when that happens.

Implements ocpp::v2::EvseInterface.

◆ submit_event()

void ocpp::v2::Evse::submit_event ( const int32_t  connector_id,
ConnectorEvent  event 
)
virtual

Submits the given event to the state machine controller of the connector with the given connector_id.

Parameters
connector_idid of the connector of the evse
event

Implements ocpp::v2::EvseInterface.


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