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

Stores and monitors operational/effective states of the CS, EVSEs, and connectors. More...

#include <component_state_manager.hpp>

Inheritance diagram for ocpp::v2::ComponentStateManager:
ocpp::v2::ComponentStateManagerInterface

Public Member Functions

 ComponentStateManager (const std::map< int32_t, int32_t > &evse_connector_structure, std::shared_ptr< DatabaseHandler > db_handler, std::function< bool(const int32_t evse_id, const int32_t connector_id, const ConnectorStatusEnum new_status, const bool initiated_by_trigger_message)> send_connector_status_notification_callback)
 At construction time, the state of each component (CS, EVSEs, and connectors) is retrieved from the database. No callbacks are triggered at this stage. When the status of components is updated, corresponding callbacks are triggered to notify the user of libocpp. Additionally, the ComponentStateManager sends StatusNotifications to the CSMS when connector statuses change. Note: It is expected that ComponentStateManagerInterface::trigger_all_effective_availability_changed_callbacks is called on boot, and ComponentStateManagerInterface::send_status_notification_all_connectors is called when first connected to the CSMS. More...
 
void set_cs_effective_availability_changed_callback (const std::function< void(const OperationalStatusEnum new_status)> &callback)
 Set a callback to be called when the effective Operative/Inoperative state of the CS changes. More...
 
void set_evse_effective_availability_changed_callback (const std::function< void(const int32_t evse_id, const OperationalStatusEnum new_status)> &callback)
 Set a callback to be called when the effective Operative/Inoperative state of an EVSE changes. More...
 
void set_connector_effective_availability_changed_callback (const std::function< void(const int32_t evse_id, const int32_t connector_id, const OperationalStatusEnum new_status)> &callback)
 Set a callback to be called when the effective Operative/Inoperative state of a connector changes. More...
 
OperationalStatusEnum get_cs_individual_operational_status ()
 Get the individual status (Operative/Inoperative) of the CS, as set by the CSMS. More...
 
OperationalStatusEnum get_evse_individual_operational_status (int32_t evse_id)
 Get the individual status (Operative/Inoperative) of an EVSE, as set by the CSMS Note: This is not the same as the effective status. The EVSE might be effectively Inoperative if the CS is Inoperative. More...
 
OperationalStatusEnum get_connector_individual_operational_status (int32_t evse_id, int32_t connector_id)
 Get the individual status (Operative/Inoperative) of a connector, as set by the CSMS Note: This is not the same as the effective status. The connector might be effectively Inoperative if its EVSE or the CS is Inoperative. More...
 
OperationalStatusEnum get_cs_persisted_operational_status ()
 Get the individual status (Operative/Inoperative) of the CS, as persisted in the database This status is restored after reboot, and differs from the individual status if non-persistent status changes were made. More...
 
OperationalStatusEnum get_evse_persisted_operational_status (int32_t evse_id)
 Get the individual status (Operative/Inoperative) of an EVSE, as persisted in the database This status is restored after reboot, and differs from the individual status if non-persistent status changes were made. More...
 
OperationalStatusEnum get_connector_persisted_operational_status (int32_t evse_id, int32_t connector_id)
 Get the individual status (Operative/Inoperative) of a connector, as persisted in the database This status is restored after reboot, and differs from the individual status if non-persistent status changes were made. More...
 
void set_cs_individual_operational_status (OperationalStatusEnum new_status, bool persist)
 Set the individual status (Operative/Inoperative) of the CS. More...
 
void set_evse_individual_operational_status (int32_t evse_id, OperationalStatusEnum new_status, bool persist)
 Set the individual status (Operative/Inoperative) of an EVSE Note: This is not the same as the effective status. The EVSE might be effectively Inoperative if the CS is Inoperative. More...
 
void set_connector_individual_operational_status (int32_t evse_id, int32_t connector_id, OperationalStatusEnum new_status, bool persist)
 Set the individual status (Operative/Inoperative) of a connector Note: This is not the same as the effective status. The connector might be effectively Inoperative if its EVSE or the CS is Inoperative. More...
 
OperationalStatusEnum get_evse_effective_operational_status (int32_t evse_id)
 Get the effective Operative/Inoperative status of an EVSE This is computed from the EVSE's and the CS's individual statuses. More...
 
OperationalStatusEnum get_connector_effective_operational_status (int32_t evse_id, int32_t connector_id)
 Get the effective Operative/Inoperative status of a connector. This is computed from the connector's, the EVSE's, and the CS's individual statuses. More...
 
ConnectorStatusEnum get_connector_effective_status (int32_t evse_id, int32_t connector_id)
 Get the effective Available/Unavailable/Occupied/Faulted/Reserved status of a connector. If the EVSE or the CS is Inoperative, the connector will be effectively Unavailable. More...
 
void set_connector_occupied (int32_t evse_id, int32_t connector_id, bool is_occupied)
 Update the state of the connector when plugged in or out. More...
 
void set_connector_reserved (int32_t evse_id, int32_t connector_id, bool is_reserved)
 Update the state of the connector when reservations are made or expire. More...
 
void set_connector_faulted (int32_t evse_id, int32_t connector_id, bool is_faulted)
 Update the state of the connector when errors are raised and cleared. More...
 
void set_connector_unavailable (int32_t evse_id, int32_t connector_id, bool is_unavailable)
 Update the state of the connector when unavailable or enabled. More...
 
void trigger_all_effective_availability_changed_callbacks ()
 Call the {cs, evse, connector}_effective_availability_changed_callback callback once for every component. This is usually only done once on boot to notify the rest of the system what the state manager expects the operative state (Operative/Inoperative) of the CS, EVSEs, and connectors to be. More...
 
void send_status_notification_all_connectors ()
 Call the send_connector_status_notification_callback once for every connector. This is usually done on boot, and on reconnect after the station has been offline for a long time. More...
 
void send_status_notification_changed_connectors ()
 Call the send_connector_status_notification_callback once for every connector whose state has changed since it was last reported with a successful send_connector_status_notification_callback. This is usually done when the station has been offline for short time and comes back online. More...
 
void send_status_notification_single_connector (int32_t evse_id, int32_t connector_id)
 Call the send_connector_status_notification_callback for a single connector. This is usually done when the CSMS explicitly sends a TriggerMessage to send a StatusNotification. More...
 
virtual void set_cs_effective_availability_changed_callback (const std::function< void(const OperationalStatusEnum new_status)> &callback)=0
 Set a callback to be called when the effective Operative/Inoperative state of the CS changes. More...
 
virtual void set_evse_effective_availability_changed_callback (const std::function< void(const int32_t evse_id, const OperationalStatusEnum new_status)> &callback)=0
 Set a callback to be called when the effective Operative/Inoperative state of an EVSE changes. More...
 
virtual void set_connector_effective_availability_changed_callback (const std::function< void(const int32_t evse_id, const int32_t connector_id, const OperationalStatusEnum new_status)> &callback)=0
 Set a callback to be called when the effective Operative/Inoperative state of a connector changes. More...
 
virtual OperationalStatusEnum get_cs_individual_operational_status ()=0
 Get the individual status (Operative/Inoperative) of the CS, as set by the CSMS. More...
 
virtual OperationalStatusEnum get_evse_individual_operational_status (int32_t evse_id)=0
 Get the individual status (Operative/Inoperative) of an EVSE, as set by the CSMS Note: This is not the same as the effective status. The EVSE might be effectively Inoperative if the CS is Inoperative. More...
 
virtual OperationalStatusEnum get_connector_individual_operational_status (int32_t evse_id, int32_t connector_id)=0
 Get the individual status (Operative/Inoperative) of a connector, as set by the CSMS Note: This is not the same as the effective status. The connector might be effectively Inoperative if its EVSE or the CS is Inoperative. More...
 
virtual OperationalStatusEnum get_cs_persisted_operational_status ()=0
 Get the individual status (Operative/Inoperative) of the CS, as persisted in the database This status is restored after reboot, and differs from the individual status if non-persistent status changes were made. More...
 
virtual OperationalStatusEnum get_evse_persisted_operational_status (int32_t evse_id)=0
 Get the individual status (Operative/Inoperative) of an EVSE, as persisted in the database This status is restored after reboot, and differs from the individual status if non-persistent status changes were made. More...
 
virtual OperationalStatusEnum get_connector_persisted_operational_status (int32_t evse_id, int32_t connector_id)=0
 Get the individual status (Operative/Inoperative) of a connector, as persisted in the database This status is restored after reboot, and differs from the individual status if non-persistent status changes were made. More...
 
virtual void set_cs_individual_operational_status (OperationalStatusEnum new_status, bool persist)=0
 Set the individual status (Operative/Inoperative) of the CS. More...
 
virtual void set_evse_individual_operational_status (int32_t evse_id, OperationalStatusEnum new_status, bool persist)=0
 Set the individual status (Operative/Inoperative) of an EVSE Note: This is not the same as the effective status. The EVSE might be effectively Inoperative if the CS is Inoperative. More...
 
virtual void set_connector_individual_operational_status (int32_t evse_id, int32_t connector_id, OperationalStatusEnum new_status, bool persist)=0
 Set the individual status (Operative/Inoperative) of a connector Note: This is not the same as the effective status. The connector might be effectively Inoperative if its EVSE or the CS is Inoperative. More...
 
virtual OperationalStatusEnum get_evse_effective_operational_status (int32_t evse_id)=0
 Get the effective Operative/Inoperative status of an EVSE This is computed from the EVSE's and the CS's individual statuses. More...
 
virtual OperationalStatusEnum get_connector_effective_operational_status (int32_t evse_id, int32_t connector_id)=0
 Get the effective Operative/Inoperative status of a connector. This is computed from the connector's, the EVSE's, and the CS's individual statuses. More...
 
virtual ConnectorStatusEnum get_connector_effective_status (int32_t evse_id, int32_t connector_id)=0
 Get the effective Available/Unavailable/Occupied/Faulted/Reserved status of a connector. If the EVSE or the CS is Inoperative, the connector will be effectively Unavailable. More...
 
virtual void set_connector_occupied (int32_t evse_id, int32_t connector_id, bool is_occupied)=0
 Update the state of the connector when plugged in or out. More...
 
virtual void set_connector_reserved (int32_t evse_id, int32_t connector_id, bool is_reserved)=0
 Update the state of the connector when reservations are made or expire. More...
 
virtual void set_connector_faulted (int32_t evse_id, int32_t connector_id, bool is_faulted)=0
 Update the state of the connector when errors are raised and cleared. More...
 
virtual void set_connector_unavailable (int32_t evse_id, int32_t connector_id, bool is_unavailable)=0
 Update the state of the connector when unavailable or enabled. More...
 
virtual void trigger_all_effective_availability_changed_callbacks ()=0
 Call the {cs, evse, connector}_effective_availability_changed_callback callback once for every component. This is usually only done once on boot to notify the rest of the system what the state manager expects the operative state (Operative/Inoperative) of the CS, EVSEs, and connectors to be. More...
 
virtual void send_status_notification_all_connectors ()=0
 Call the send_connector_status_notification_callback once for every connector. This is usually done on boot, and on reconnect after the station has been offline for a long time. More...
 
virtual void send_status_notification_changed_connectors ()=0
 Call the send_connector_status_notification_callback once for every connector whose state has changed since it was last reported with a successful send_connector_status_notification_callback. This is usually done when the station has been offline for short time and comes back online. More...
 
virtual void send_status_notification_single_connector (int32_t evse_id, int32_t connector_id)=0
 Call the send_connector_status_notification_callback for a single connector. This is usually done when the CSMS explicitly sends a TriggerMessage to send a StatusNotification. More...
 

Detailed Description

Stores and monitors operational/effective states of the CS, EVSEs, and connectors.

Constructor & Destructor Documentation

◆ ComponentStateManager()

ocpp::v2::ComponentStateManager::ComponentStateManager ( const std::map< int32_t, int32_t > &  evse_connector_structure,
std::shared_ptr< DatabaseHandler db_handler,
std::function< bool(const int32_t evse_id, const int32_t connector_id, const ConnectorStatusEnum new_status, const bool initiated_by_trigger_message)>  send_connector_status_notification_callback 
)
explicit

At construction time, the state of each component (CS, EVSEs, and connectors) is retrieved from the database. No callbacks are triggered at this stage. When the status of components is updated, corresponding callbacks are triggered to notify the user of libocpp. Additionally, the ComponentStateManager sends StatusNotifications to the CSMS when connector statuses change. Note: It is expected that ComponentStateManagerInterface::trigger_all_effective_availability_changed_callbacks is called on boot, and ComponentStateManagerInterface::send_status_notification_all_connectors is called when first connected to the CSMS.

Parameters
evse_connector_structureMaps each EVSE ID to the number of connectors the EVSE has
db_handlerA shared reference to the persistent database
send_connector_status_notification_callbackThe callback through which to send StatusNotifications to the CSMS
initiated_by_trigger_messageIndicates if the StatusNotification was initiated by a TriggerMessage.req

Member Function Documentation

◆ get_connector_effective_operational_status()

OperationalStatusEnum ocpp::v2::ComponentStateManager::get_connector_effective_operational_status ( int32_t  evse_id,
int32_t  connector_id 
)
virtual

Get the effective Operative/Inoperative status of a connector. This is computed from the connector's, the EVSE's, and the CS's individual statuses.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ get_connector_effective_status()

ConnectorStatusEnum ocpp::v2::ComponentStateManager::get_connector_effective_status ( int32_t  evse_id,
int32_t  connector_id 
)
virtual

Get the effective Available/Unavailable/Occupied/Faulted/Reserved status of a connector. If the EVSE or the CS is Inoperative, the connector will be effectively Unavailable.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ get_connector_individual_operational_status()

OperationalStatusEnum ocpp::v2::ComponentStateManager::get_connector_individual_operational_status ( int32_t  evse_id,
int32_t  connector_id 
)
virtual

Get the individual status (Operative/Inoperative) of a connector, as set by the CSMS Note: This is not the same as the effective status. The connector might be effectively Inoperative if its EVSE or the CS is Inoperative.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ get_connector_persisted_operational_status()

OperationalStatusEnum ocpp::v2::ComponentStateManager::get_connector_persisted_operational_status ( int32_t  evse_id,
int32_t  connector_id 
)
virtual

Get the individual status (Operative/Inoperative) of a connector, as persisted in the database This status is restored after reboot, and differs from the individual status if non-persistent status changes were made.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ get_cs_individual_operational_status()

OperationalStatusEnum ocpp::v2::ComponentStateManager::get_cs_individual_operational_status ( )
virtual

Get the individual status (Operative/Inoperative) of the CS, as set by the CSMS.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ get_cs_persisted_operational_status()

OperationalStatusEnum ocpp::v2::ComponentStateManager::get_cs_persisted_operational_status ( )
virtual

Get the individual status (Operative/Inoperative) of the CS, as persisted in the database This status is restored after reboot, and differs from the individual status if non-persistent status changes were made.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ get_evse_effective_operational_status()

OperationalStatusEnum ocpp::v2::ComponentStateManager::get_evse_effective_operational_status ( int32_t  evse_id)
virtual

Get the effective Operative/Inoperative status of an EVSE This is computed from the EVSE's and the CS's individual statuses.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ get_evse_individual_operational_status()

OperationalStatusEnum ocpp::v2::ComponentStateManager::get_evse_individual_operational_status ( int32_t  evse_id)
virtual

Get the individual status (Operative/Inoperative) of an EVSE, as set by the CSMS Note: This is not the same as the effective status. The EVSE might be effectively Inoperative if the CS is Inoperative.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ get_evse_persisted_operational_status()

OperationalStatusEnum ocpp::v2::ComponentStateManager::get_evse_persisted_operational_status ( int32_t  evse_id)
virtual

Get the individual status (Operative/Inoperative) of an EVSE, as persisted in the database This status is restored after reboot, and differs from the individual status if non-persistent status changes were made.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ send_status_notification_all_connectors()

void ocpp::v2::ComponentStateManager::send_status_notification_all_connectors ( )
virtual

Call the send_connector_status_notification_callback once for every connector. This is usually done on boot, and on reconnect after the station has been offline for a long time.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ send_status_notification_changed_connectors()

void ocpp::v2::ComponentStateManager::send_status_notification_changed_connectors ( )
virtual

Call the send_connector_status_notification_callback once for every connector whose state has changed since it was last reported with a successful send_connector_status_notification_callback. This is usually done when the station has been offline for short time and comes back online.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ send_status_notification_single_connector()

void ocpp::v2::ComponentStateManager::send_status_notification_single_connector ( int32_t  evse_id,
int32_t  connector_id 
)
virtual

Call the send_connector_status_notification_callback for a single connector. This is usually done when the CSMS explicitly sends a TriggerMessage to send a StatusNotification.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ set_connector_effective_availability_changed_callback()

void ocpp::v2::ComponentStateManager::set_connector_effective_availability_changed_callback ( const std::function< void(const int32_t evse_id, const int32_t connector_id, const OperationalStatusEnum new_status)> &  callback)
virtual

Set a callback to be called when the effective Operative/Inoperative state of a connector changes.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ set_connector_faulted()

void ocpp::v2::ComponentStateManager::set_connector_faulted ( int32_t  evse_id,
int32_t  connector_id,
bool  is_faulted 
)
virtual

Update the state of the connector when errors are raised and cleared.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ set_connector_individual_operational_status()

void ocpp::v2::ComponentStateManager::set_connector_individual_operational_status ( int32_t  evse_id,
int32_t  connector_id,
OperationalStatusEnum  new_status,
bool  persist 
)
virtual

Set the individual status (Operative/Inoperative) of a connector Note: This is not the same as the effective status. The connector might be effectively Inoperative if its EVSE or the CS is Inoperative.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ set_connector_occupied()

void ocpp::v2::ComponentStateManager::set_connector_occupied ( int32_t  evse_id,
int32_t  connector_id,
bool  is_occupied 
)
virtual

Update the state of the connector when plugged in or out.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ set_connector_reserved()

void ocpp::v2::ComponentStateManager::set_connector_reserved ( int32_t  evse_id,
int32_t  connector_id,
bool  is_reserved 
)
virtual

Update the state of the connector when reservations are made or expire.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ set_connector_unavailable()

void ocpp::v2::ComponentStateManager::set_connector_unavailable ( int32_t  evse_id,
int32_t  connector_id,
bool  is_unavailable 
)
virtual

Update the state of the connector when unavailable or enabled.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ set_cs_effective_availability_changed_callback()

void ocpp::v2::ComponentStateManager::set_cs_effective_availability_changed_callback ( const std::function< void(const OperationalStatusEnum new_status)> &  callback)
virtual

Set a callback to be called when the effective Operative/Inoperative state of the CS changes.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ set_cs_individual_operational_status()

void ocpp::v2::ComponentStateManager::set_cs_individual_operational_status ( OperationalStatusEnum  new_status,
bool  persist 
)
virtual

Set the individual status (Operative/Inoperative) of the CS.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ set_evse_effective_availability_changed_callback()

void ocpp::v2::ComponentStateManager::set_evse_effective_availability_changed_callback ( const std::function< void(const int32_t evse_id, const OperationalStatusEnum new_status)> &  callback)
virtual

Set a callback to be called when the effective Operative/Inoperative state of an EVSE changes.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ set_evse_individual_operational_status()

void ocpp::v2::ComponentStateManager::set_evse_individual_operational_status ( int32_t  evse_id,
OperationalStatusEnum  new_status,
bool  persist 
)
virtual

Set the individual status (Operative/Inoperative) of an EVSE Note: This is not the same as the effective status. The EVSE might be effectively Inoperative if the CS is Inoperative.

Implements ocpp::v2::ComponentStateManagerInterface.

◆ trigger_all_effective_availability_changed_callbacks()

void ocpp::v2::ComponentStateManager::trigger_all_effective_availability_changed_callbacks ( )
virtual

Call the {cs, evse, connector}_effective_availability_changed_callback callback once for every component. This is usually only done once on boot to notify the rest of the system what the state manager expects the operative state (Operative/Inoperative) of the CS, EVSEs, and connectors to be.

Implements ocpp::v2::ComponentStateManagerInterface.


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