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

This class manages access to the device model representation and to the device model interface and provides functionality to support the use cases defined in the functional block Provisioning. More...

#include <device_model.hpp>

Public Member Functions

 DeviceModel (std::unique_ptr< DeviceModelStorageInterface > device_model_storage_interface)
 Constructor for the device model. More...
 
template<typename T >
get_value (const RequiredComponentVariable &component_variable, const AttributeEnum &attribute_enum=AttributeEnum::Actual) const
 Direct access to value of a VariableAttribute for the given component, variable and attribute_enum. This should only be called for variables that have a role standardized in the OCPP2.0.1 specification. More...
 
template<typename T >
std::optional< T > get_optional_value (const ComponentVariable &component_variable, const AttributeEnum &attribute_enum=AttributeEnum::Actual) const
 Access to std::optional of a VariableAttribute for the given component, variable and attribute_enum. More...
 
template<typename T >
RequestDeviceModelResponse< T > request_value (const Component &component_id, const Variable &variable_id, const AttributeEnum &attribute_enum)
 Requests a value of a VariableAttribute specified by combination of component_id and variable_id from the device model. More...
 
std::optional< MutabilityEnum > get_mutability (const Component &component_id, const Variable &variable, const AttributeEnum &attribute_enum)
 Get the mutability for the given component, variable and attribute_enum. More...
 
SetVariableStatusEnum set_value (const Component &component_id, const Variable &variable_id, const AttributeEnum &attribute_enum, const std::string &value, const std::string &source, const bool allow_read_only=false)
 Sets the variable_id attribute value specified by component_id , variable_id and attribute_enum. More...
 
SetVariableStatusEnum set_read_only_value (const Component &component_id, const Variable &variable_id, const AttributeEnum &attribute_enum, const std::string &value, const std::string &source)
 Sets the variable_id attribute value specified by component_id , variable_id and attribute_enum for read only variables only. Only works on certain allowed components. More...
 
std::optional< VariableMetaDataget_variable_meta_data (const Component &component_id, const Variable &variable_id)
 Gets the VariableMetaData for the given component_id and variable_id. More...
 
std::vector< ReportDataget_base_report_data (const ReportBaseEnum &report_base)
 Gets the ReportData for the specifed filter report_base component_variables and component_criteria. More...
 
std::vector< ReportDataget_custom_report_data (const std::optional< std::vector< ComponentVariable > > &component_variables=std::nullopt, const std::optional< std::vector< ComponentCriterionEnum > > &component_criteria=std::nullopt)
 Gets the ReportData for the specifed filter component_variables and component_criteria. More...
 
void register_variable_listener (on_variable_changed &&listener)
 
void register_monitor_listener (on_monitor_updated &&listener)
 
std::vector< SetMonitoringResultset_monitors (const std::vector< SetMonitoringData > &requests, const VariableMonitorType type=VariableMonitorType::CustomMonitor)
 Sets the given monitor requests in the device model. More...
 
bool update_monitor_reference (int32_t monitor_id, const std::string &reference_value)
 
std::vector< VariableMonitoringPeriodicget_periodic_monitors ()
 
std::vector< MonitoringDataget_monitors (const std::vector< MonitoringCriterionEnum > &criteria, const std::vector< ComponentVariable > &component_variables)
 Gets the Monitoring data for the request criteria and component_variables. More...
 
std::vector< ClearMonitoringResultclear_monitors (const std::vector< int > &request_ids, bool allow_protected=false)
 Clears the given request_ids from the registered monitors if request_id is present. More...
 
int32_t clear_custom_monitors ()
 Clears all the custom monitors (set by the CSMS) present in the database. More...
 
void check_integrity (const std::map< int32_t, int32_t > &evse_connector_structure)
 Check data integrity of the device model provided by the device model data storage: For "required" variables, assert values exist. Checks might be extended in the future.
 

Detailed Description

This class manages access to the device model representation and to the device model interface and provides functionality to support the use cases defined in the functional block Provisioning.

Constructor & Destructor Documentation

◆ DeviceModel()

ocpp::v2::DeviceModel::DeviceModel ( std::unique_ptr< DeviceModelStorageInterface device_model_storage_interface)
explicit

Constructor for the device model.

Parameters
device_model_storage_interfacepointer to a device model interface class

Member Function Documentation

◆ clear_custom_monitors()

int32_t ocpp::v2::DeviceModel::clear_custom_monitors ( )

Clears all the custom monitors (set by the CSMS) present in the database.

Returns
count of monitors deleted, can be 0 if no custom monitors were present in the db

◆ clear_monitors()

std::vector< ClearMonitoringResult > ocpp::v2::DeviceModel::clear_monitors ( const std::vector< int > &  request_ids,
bool  allow_protected = false 
)

Clears the given request_ids from the registered monitors if request_id is present.

Parameters
request_ids
allow_protectedif we should delete the non-custom monitors, defaults to false when this operation is requested by the CSMS
Returns
List of results of the requested operation

◆ get_base_report_data()

std::vector< ReportData > ocpp::v2::DeviceModel::get_base_report_data ( const ReportBaseEnum &  report_base)

Gets the ReportData for the specifed filter report_base component_variables and component_criteria.

Parameters
report_base
component_variables
component_criteria
Returns

◆ get_custom_report_data()

std::vector< ReportData > ocpp::v2::DeviceModel::get_custom_report_data ( const std::optional< std::vector< ComponentVariable > > &  component_variables = std::nullopt,
const std::optional< std::vector< ComponentCriterionEnum > > &  component_criteria = std::nullopt 
)

Gets the ReportData for the specifed filter component_variables and component_criteria.

Parameters
report_base
component_variables
component_criteria
Returns

◆ get_monitors()

std::vector< MonitoringData > ocpp::v2::DeviceModel::get_monitors ( const std::vector< MonitoringCriterionEnum > &  criteria,
const std::vector< ComponentVariable > &  component_variables 
)

Gets the Monitoring data for the request criteria and component_variables.

Parameters
criteria
component_variables
Returns
List of results of the requested monitors

◆ get_mutability()

std::optional< MutabilityEnum > ocpp::v2::DeviceModel::get_mutability ( const Component component_id,
const Variable variable,
const AttributeEnum &  attribute_enum 
)

Get the mutability for the given component, variable and attribute_enum.

Parameters
component_id
variable_id
attribute_enum
Returns
The mutability of the given component variable, else std::nullopt

◆ get_optional_value()

template<typename T >
std::optional< T > ocpp::v2::DeviceModel::get_optional_value ( const ComponentVariable component_variable,
const AttributeEnum &  attribute_enum = AttributeEnum::Actual 
) const
inline

Access to std::optional of a VariableAttribute for the given component, variable and attribute_enum.

Template Parameters
TType of the value that is requested
Parameters
component_variableCombination of Component and Variable that identifies the Variable
attribute_enum
Returns
std::optional<T> if the combination of component_variable and attribute_enum could successfully requested from the storage and a value is present for this combination, else std::nullopt .

◆ get_value()

template<typename T >
T ocpp::v2::DeviceModel::get_value ( const RequiredComponentVariable component_variable,
const AttributeEnum &  attribute_enum = AttributeEnum::Actual 
) const
inline

Direct access to value of a VariableAttribute for the given component, variable and attribute_enum. This should only be called for variables that have a role standardized in the OCPP2.0.1 specification.

Template Parameters
Tdatatype of the value that is requested
Parameters
component_variableCombination of Component and Variable that identifies the Variable
attribute_enumdefaults to AttributeEnum::Actual
Returns
the requested value from the device model interface

◆ get_variable_meta_data()

std::optional< VariableMetaData > ocpp::v2::DeviceModel::get_variable_meta_data ( const Component component_id,
const Variable variable_id 
)

Gets the VariableMetaData for the given component_id and variable_id.

Parameters
component_id
variable_id
Returns
VariableMetaData or std::nullopt if component_id or variable_id not present

◆ request_value()

template<typename T >
RequestDeviceModelResponse< T > ocpp::v2::DeviceModel::request_value ( const Component component_id,
const Variable variable_id,
const AttributeEnum &  attribute_enum 
)
inline

Requests a value of a VariableAttribute specified by combination of component_id and variable_id from the device model.

Template Parameters
Tdatatype of the value that is requested
Parameters
component_id
variable_id
attribute_enum
Returns
Response to request that contains status of the request and the requested value as std::optional<T> . The value is present if the status is GetVariableStatusEnum::Accepted

◆ set_monitors()

std::vector< SetMonitoringResult > ocpp::v2::DeviceModel::set_monitors ( const std::vector< SetMonitoringData > &  requests,
const VariableMonitorType  type = VariableMonitorType::CustomMonitor 
)

Sets the given monitor requests in the device model.

Parameters
request
typeThe type of the set monitors. HardWiredMonitor - used for OEM specific monitors, PreconfiguredMonitor - monitors that were manually defined in the component config, CustomMonitor - used for monitors that are set by the CSMS,
Returns
List of results of the requested operation

◆ set_read_only_value()

SetVariableStatusEnum ocpp::v2::DeviceModel::set_read_only_value ( const Component component_id,
const Variable variable_id,
const AttributeEnum &  attribute_enum,
const std::string &  value,
const std::string &  source 
)

Sets the variable_id attribute value specified by component_id , variable_id and attribute_enum for read only variables only. Only works on certain allowed components.

Parameters
component_id
variable_id
attribute_enum
value
sourceThe source of the value (for example 'csms' or 'default').
Returns
Result of the requested operation

◆ set_value()

SetVariableStatusEnum ocpp::v2::DeviceModel::set_value ( const Component component_id,
const Variable variable_id,
const AttributeEnum &  attribute_enum,
const std::string &  value,
const std::string &  source,
const bool  allow_read_only = false 
)

Sets the variable_id attribute value specified by component_id , variable_id and attribute_enum.

Parameters
component_id
variable_id
attribute_enum
value
sourceThe source of the value (for example 'csms' or 'default').
allow_read_onlyIf this is true, read-only variables can be changed, otherwise only non read-only variables can be changed. Defaults to false
Returns
Result of the requested operation

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