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

This class handles the connection and operations of the SQLite database. More...

#include <database_handler.hpp>

Inheritance diagram for ocpp::v16::DatabaseHandler:
ocpp::common::DatabaseHandlerCommon

Public Member Functions

 DatabaseHandler (std::unique_ptr< common::DatabaseConnectionInterface > database, const fs::path &sql_migration_files_path, int32_t number_of_connectors)
 
void insert_transaction (const std::string &session_id, const int32_t transaction_id, const int32_t connector, const std::string &id_tag_start, const std::string &time_start, const int32_t meter_start, const bool csms_ack, const std::optional< int32_t > reservation_id, const std::string &start_transaction_message_id)
 Inserts a transaction with the given parameter to the TRANSACTIONS table.
 
void update_transaction (const std::string &session_id, int32_t transaction_id, std::optional< CiString< 20 > > parent_id_tag=std::nullopt)
 Updates the given parameters for the transaction with the given session_id in the TRANSACTIONS table.
 
void update_transaction (const std::string &session_id, int32_t meter_stop, const std::string &time_end, std::optional< CiString< 20 > > id_tag_end, std::optional< v16::Reason > stop_reason, const std::string &stop_transaction_message_id)
 Updates the given parameters for the transaction with the given session_id in the TRANSACTIONS table.
 
void update_transaction_csms_ack (const int32_t transaction_id)
 Updates the CSMS_ACK column for the transaction with the given transaction_id in the TRANSACTIONS table.
 
void update_start_transaction_message_id (const std::string &session_id, const std::string &start_transaction_message_id)
 Updates the START_TRANSACTION_MESSAGE_ID column for the transaction with the given session_id in the TRANSACTIONS table.
 
void update_transaction_meter_value (const std::string &session_id, const int32_t value, const std::string &timestamp)
 Updates the METER_LAST and METER_LAST_TIME column for the transaction with the given session_id in the TRANSACTIONS table.
 
std::vector< TransactionEntryget_transactions (bool filter_incomplete=false)
 Returns a list of all transactions in the database. If filter_complete is true, only incomplete transactions will be return. If filter_complete is false, all transactions will be returned.
 
void insert_or_update_authorization_cache_entry (const CiString< 20 > &id_tag, const v16::IdTagInfo &id_tag_info)
 Inserts or updates an authorization cache entry to the AUTH_CACHE table.
 
std::optional< v16::IdTagInfoget_authorization_cache_entry (const CiString< 20 > &id_tag)
 Returns the IdTagInfo of the given id_tag if it exists in the AUTH_CACHE table, else std::nullopt.
 
void clear_authorization_cache ()
 Deletes all entries of the AUTH_CACHE table.
 
void insert_or_update_connector_availability (int32_t connector, const v16::AvailabilityType &availability_type)
 Inserts or updates the given availability_type of the given connector to the CONNECTORS table.
 
void insert_or_update_connector_availability (const std::vector< int32_t > &connectors, const v16::AvailabilityType &availability_type)
 Inserts or updates the given availability_type of the given connectors to the CONNECTORS table.
 
v16::AvailabilityType get_connector_availability (int32_t connector)
 Returns the AvailabilityType of the given connector of the CONNECTORS table.
 
std::map< int32_t, v16::AvailabilityType > get_connector_availability ()
 Returns a map of all connectors and its AvailabilityTypes of the CONNECTORS table.
 
void insert_or_ignore_local_list_version (int32_t version)
 Inserts or ignores the given version in the AUTH_LIST_VERSION table.
 
void insert_or_update_local_list_version (int32_t version)
 Inserts or updates the given version in the AUTH_LIST_VERSION table.
 
int32_t get_local_list_version ()
 Returns the version in the AUTH_LIST_VERSION table.
 
void insert_or_update_local_authorization_list_entry (const CiString< 20 > &id_tag, const v16::IdTagInfo &id_tag_info)
 Inserts or updates a local authorization list entry to the AUTH_LIST table.
 
void insert_or_update_local_authorization_list (std::vector< v16::LocalAuthorizationList > local_authorization_list)
 Inserts or updates a local authorization list entries local_authorization_list to the AUTH_LIST table.
 
void delete_local_authorization_list_entry (const std::string &id_tag)
 Deletes the authorization list entry with the given id_tag.
 
std::optional< v16::IdTagInfoget_local_authorization_list_entry (const CiString< 20 > &id_tag)
 Returns the IdTagInfo of the given id_tag if it exists in the AUTH_LIST table, else std::nullopt.
 
void clear_local_authorization_list ()
 Deletes all entries of the AUTH_LIST table.
 
int32_t get_local_authorization_list_number_of_entries ()
 Get the number of entries currently in the authorization list.
 
virtual void insert_or_update_charging_profile (const int connector_id, const v16::ChargingProfile &profile)
 Inserts or updates the given profile to CHARGING_PROFILES table.
 
virtual void delete_charging_profile (const int profile_id)
 Deletes the profile with the given profile_id.
 
void delete_charging_profiles ()
 Deletes all profiles from table CHARGING_PROFILES.
 
std::vector< v16::ChargingProfileget_charging_profiles ()
 Returns a list of all charging profiles in the CHARGING_PROFILES table.
 
int get_connector_id (const int profile_id)
 Returns the connector_id of the given profile_id.
 
void insert_ocsp_update ()
 Updates the ocsp entry in the OCSP_REQUEST table.
 
std::optional< DateTimeget_last_ocsp_update ()
 Gets the only entry in the OCSP_REQUEST table.
 
- Public Member Functions inherited from ocpp::common::DatabaseHandlerCommon
 DatabaseHandlerCommon (std::unique_ptr< DatabaseConnectionInterface > database, const fs::path &sql_migration_files_path, uint32_t target_schema_version) noexcept
 Common database handler class Class handles some common database functionality like inserting and removing transaction messages. More...
 
void open_connection ()
 Opens connection to database file and performs the initialization by calling init_sql()
 
void close_connection ()
 Closes the database connection.
 
virtual std::vector< DBTransactionMessageget_message_queue_messages (const QueueType queue_type=QueueType::Transaction)
 Get messages from messages queue table specified by queue_type. More...
 
virtual void insert_message_queue_message (const DBTransactionMessage &message, const QueueType queue_type=QueueType::Transaction)
 Insert a new message into messages queue table specified by queue_type. More...
 
virtual void remove_message_queue_message (const std::string &unique_id, const QueueType queue_type=QueueType::Transaction)
 Remove a message from the messages queue table specified by queue_type. More...
 
virtual void clear_message_queue (const QueueType queue_type=QueueType::Transaction)
 Deletes all entries from message queue table specified by queue_type. More...
 

Additional Inherited Members

virtual void init_sql ()=0
 Perform the initialization needed to use the database. Will be called by open_connection() More...
 
- Protected Attributes inherited from ocpp::common::DatabaseHandlerCommon
std::unique_ptr< DatabaseConnectionInterfacedatabase
 
const fs::path sql_migration_files_path
 
const uint32_t target_schema_version
 

Detailed Description

This class handles the connection and operations of the SQLite database.


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