ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
Public Member Functions | List of all members
ocpp::v2::DeviceModelStorageSqlite Class Reference
Inheritance diagram for ocpp::v2::DeviceModelStorageSqlite:
ocpp::v2::DeviceModelStorageInterface

Public Member Functions

 DeviceModelStorageSqlite (const fs::path &db_path, const std::filesystem::path &migration_files_path="", const std::filesystem::path &config_path="", const bool init_db=false)
 Opens SQLite connection at given db_path. More...
 
std::map< Component, std::map< Variable, VariableMetaData > > get_device_model () final
 Gets the device model from the device model interface. More...
 
std::optional< VariableAttributeget_variable_attribute (const Component &component_id, const Variable &variable_id, const AttributeEnum &attribute_enum) final
 Gets a VariableAttribute from the storage if present. More...
 
std::vector< VariableAttributeget_variable_attributes (const Component &component_id, const Variable &variable_id, const std::optional< AttributeEnum > &attribute_enum) final
 Gets a std::vector<VariableAttribute> from the storage. More...
 
bool set_variable_attribute_value (const Component &component_id, const Variable &variable_id, const AttributeEnum &attribute_enum, const std::string &value, const std::string &source) final
 Sets the value of an VariableAttribute if present. More...
 
std::optional< VariableMonitoringMetaset_monitoring_data (const SetMonitoringData &data, const VariableMonitorType type) final
 Inserts or replaces a variable monitor in the database. More...
 
bool update_monitoring_reference (const int32_t monitor_id, const std::string &reference_value) final
 Updates the reference value for a monitor. The reference values is used for the delta monitors to detect a trigger, and must be updated when a trigger is detected. More...
 
std::vector< VariableMonitoringMetaget_monitoring_data (const std::vector< MonitoringCriterionEnum > &criteria, const Component &component_id, const Variable &variable_id) final
 Returns all the monitors currently in the database based on the provided filtering criteria. More...
 
ClearMonitoringStatusEnum clear_variable_monitor (int monitor_id, bool allow_protected) final
 Clears a single monitor based on the ID from the database. More...
 
int32_t clear_custom_variable_monitors () final
 Clears all custom monitors (that were added by the CSMS) from the database. More...
 
void check_integrity () final
 Check data integrity of the stored data: For "required" variables, assert values exist. Checks might be extended in the future. More...
 
virtual DeviceModelMap get_device_model ()=0
 Gets the device model from the device model interface. More...
 
virtual std::optional< VariableAttributeget_variable_attribute (const Component &component_id, const Variable &variable_id, const AttributeEnum &attribute_enum)=0
 Gets a VariableAttribute from the storage if present. More...
 
virtual std::vector< VariableAttributeget_variable_attributes (const Component &component_id, const Variable &variable_id, const std::optional< AttributeEnum > &attribute_enum=std::nullopt)=0
 Gets a std::vector<VariableAttribute> from the storage. More...
 
virtual bool set_variable_attribute_value (const Component &component_id, const Variable &variable_id, const AttributeEnum &attribute_enum, const std::string &value, const std::string &source)=0
 Sets the value of an VariableAttribute if present. More...
 
virtual std::optional< VariableMonitoringMetaset_monitoring_data (const SetMonitoringData &data, const VariableMonitorType type)=0
 Inserts or replaces a variable monitor in the database. More...
 
virtual bool update_monitoring_reference (const int32_t monitor_id, const std::string &reference_value)=0
 Updates the reference value for a monitor. The reference values is used for the delta monitors to detect a trigger, and must be updated when a trigger is detected. More...
 
virtual std::vector< VariableMonitoringMetaget_monitoring_data (const std::vector< MonitoringCriterionEnum > &criteria, const Component &component_id, const Variable &variable_id)=0
 Returns all the monitors currently in the database based on the provided filtering criteria. More...
 
virtual ClearMonitoringStatusEnum clear_variable_monitor (int monitor_id, bool allow_protected)=0
 Clears a single monitor based on the ID from the database. More...
 
virtual int32_t clear_custom_variable_monitors ()=0
 Clears all custom monitors (that were added by the CSMS) from the database. More...
 
virtual void check_integrity ()=0
 Check data integrity of the stored data: For "required" variables, assert values exist. Checks might be extended in the future. More...
 

Constructor & Destructor Documentation

◆ DeviceModelStorageSqlite()

ocpp::v2::DeviceModelStorageSqlite::DeviceModelStorageSqlite ( const fs::path &  db_path,
const std::filesystem::path &  migration_files_path = "",
const std::filesystem::path &  config_path = "",
const bool  init_db = false 
)
explicit

Opens SQLite connection at given db_path.

If init_db is true, all other paths must be given as well.

Parameters
db_pathPath to database
migration_files_pathPath to the migration files to initialize the database (only needs to be set if init_db is true)
config_pathPath to the device model config (only needs to be set if init_db is true)
init_dbTrue to initialize the database

Member Function Documentation

◆ check_integrity()

void ocpp::v2::DeviceModelStorageSqlite::check_integrity ( )
finalvirtual

Check data integrity of the stored data: For "required" variables, assert values exist. Checks might be extended in the future.

Implements ocpp::v2::DeviceModelStorageInterface.

◆ clear_custom_variable_monitors()

int32_t ocpp::v2::DeviceModelStorageSqlite::clear_custom_variable_monitors ( )
finalvirtual

Clears all custom monitors (that were added by the CSMS) from the database.

Returns
count of monitors deleted, or 0 if none were deleted

Implements ocpp::v2::DeviceModelStorageInterface.

◆ clear_variable_monitor()

ClearMonitoringStatusEnum ocpp::v2::DeviceModelStorageSqlite::clear_variable_monitor ( int  monitor_id,
bool  allow_protected 
)
finalvirtual

Clears a single monitor based on the ID from the database.

Parameters
monitor_idMonitor ID
allow_protectedIf we are allowed to delete non-custom monitors
Returns
if not Accepted, NotFound if the monitor could not be found, or Rejected if it is a protected monitor

Implements ocpp::v2::DeviceModelStorageInterface.

◆ get_device_model()

DeviceModelMap ocpp::v2::DeviceModelStorageSqlite::get_device_model ( )
finalvirtual

Gets the device model from the device model interface.

Returns
std::map<Component, std::map<Variable, VariableMetaData>> that will contain a full representation of the device model except for the VariableAttribute(s) of each Variable.

Implements ocpp::v2::DeviceModelStorageInterface.

◆ get_monitoring_data()

std::vector< VariableMonitoringMeta > ocpp::v2::DeviceModelStorageSqlite::get_monitoring_data ( const std::vector< MonitoringCriterionEnum > &  criteria,
const Component component_id,
const Variable variable_id 
)
finalvirtual

Returns all the monitors currently in the database based on the provided filtering criteria.

Parameters
criteria
component_id
variable_id
Returns
the monitoring data if it could be found or an empty vector

Implements ocpp::v2::DeviceModelStorageInterface.

◆ get_variable_attribute()

std::optional< VariableAttribute > ocpp::v2::DeviceModelStorageSqlite::get_variable_attribute ( const Component component_id,
const Variable variable_id,
const AttributeEnum &  attribute_enum 
)
finalvirtual

Gets a VariableAttribute from the storage if present.

Parameters
component_id
variable_id
attribute_enum
Returns
VariableAttribute or std::nullopt if not present in the storage

Implements ocpp::v2::DeviceModelStorageInterface.

◆ get_variable_attributes()

std::vector< VariableAttribute > ocpp::v2::DeviceModelStorageSqlite::get_variable_attributes ( const Component component_id,
const Variable variable_id,
const std::optional< AttributeEnum > &  attribute_enum 
)
finalvirtual

Gets a std::vector<VariableAttribute> from the storage.

Parameters
component_id
variable_id
attribute_enumoptionally specifies an AttributeEnum. In this case this std::vector will contain max. one element
Returns
std::vector<VariableAttribute> with maximum size of 4 elements (Actual, Target, MinSet, MaxSet) and minum size of 0 elements (if no VariableAttribute is present for the requested parameters)

Implements ocpp::v2::DeviceModelStorageInterface.

◆ set_monitoring_data()

std::optional< VariableMonitoringMeta > ocpp::v2::DeviceModelStorageSqlite::set_monitoring_data ( const SetMonitoringData data,
const VariableMonitorType  type 
)
finalvirtual

Inserts or replaces a variable monitor in the database.

Parameters
dataMonitor data to set
Returns
true if the value could be inserted, or valse otherwise

Implements ocpp::v2::DeviceModelStorageInterface.

◆ set_variable_attribute_value()

bool ocpp::v2::DeviceModelStorageSqlite::set_variable_attribute_value ( const Component component_id,
const Variable variable_id,
const AttributeEnum &  attribute_enum,
const std::string &  value,
const std::string &  source 
)
finalvirtual

Sets the value of an VariableAttribute if present.

Parameters
component_id
variable_id
attribute_enum
value
sourceThe source of the value.
Returns
true if the value could be set in the storage, else false

Implements ocpp::v2::DeviceModelStorageInterface.

◆ update_monitoring_reference()

bool ocpp::v2::DeviceModelStorageSqlite::update_monitoring_reference ( const int32_t  monitor_id,
const std::string &  reference_value 
)
finalvirtual

Updates the reference value for a monitor. The reference values is used for the delta monitors to detect a trigger, and must be updated when a trigger is detected.

Parameters
monitor_idId of the monitor that requires the reference changed
reference_valueValue to replace the reference with
Returns
true if the reference value could be updated, false otherwise

Implements ocpp::v2::DeviceModelStorageInterface.


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