Skip to content

Commit

Permalink
move find_if filter to a custom function
Browse files Browse the repository at this point in the history
Signed-off-by: Soumya Subramanya <[email protected]>

fix bug in matching

Signed-off-by: Soumya Subramanya <[email protected]>

fix formatting

Signed-off-by: Soumya Subramanya <[email protected]>

fix more formatting

Signed-off-by: Soumya Subramanya <[email protected]>

some more strange formatting

Signed-off-by: Soumya Subramanya <[email protected]>

PR changes

Signed-off-by: Soumya Subramanya <[email protected]>

fix formatting

Signed-off-by: Soumya Subramanya <[email protected]>
  • Loading branch information
SNSubramanya committed Jan 8, 2024
1 parent 51aca06 commit 0a5a692
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 182 deletions.
261 changes: 131 additions & 130 deletions config/v201/component_schemas/standardized/ChargingStation.json
Original file line number Diff line number Diff line change
@@ -1,132 +1,133 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Schema for ChargingStation",
"type": "object",
"name": "ChargingStation",
"properties": {
"AllowNewSessionsPendingFirmwareUpdate": {
"variable_name": "AllowNewSessionsPendingFirmwareUpdate",
"characteristics": {
"supportsMonitoring": true,
"dataType": "boolean"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadWrite"
}
],
"instance": "BytesPerMessage",
"description": "Indicates whether new sessions can be started on EVSEs, while Charging Station is waiting for all EVSEs to become Available in order to start a pending firmware update",
"type": "boolean"
},
"ChargingStationAvailabilityState": {
"variable_name": "AvailabilityState",
"characteristics": {
"supportsMonitoring": true,
"dataType": "OptionList"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadOnly"
}
],
"description": "This variable reports current availability state for the ChargingStation",
"type": "string"
},
"ChargingStationPhaseRotation": {
"variable_name": "PhaseRotation",
"characteristics": {
"supportsMonitoring": true,
"dataType": "string"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadWrite"
}
],
"description": "This variable describes the phase rotation of a Component relative to its parent Component, using a three letter string consisting of the letters: R, S, T and x.",
"type": "string"
},
"ChargingStationAvailable": {
"variable_name": "Available",
"characteristics": {
"supportsMonitoring": true,
"dataType": "boolean"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadOnly"
}
],
"description": "Component exists",
"type": "boolean"
},
"ChargingStationModel": {
"variable_name": "Model",
"characteristics": {
"supportsMonitoring": true,
"dataType": "string"
},
"attributes": [
{
"type": "Actual"
}
],
"description": "Charging station model as reported in BootNotification.",
"type": "string"
},
"ChargingStationSupplyPhases": {
"variable_name": "SupplyPhases",
"characteristics": {
"supportsMonitoring": true,
"dataType": "integer"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadOnly"
}
],
"description": "Number of alternating current phases connected/available.",
"type": "integer"
},
"ChargingStationVendorName": {
"variable_name": "VendorName",
"characteristics": {
"supportsMonitoring": true,
"dataType": "string"
},
"attributes": [
{
"type": "Actual"
}
],
"description": "Charging station vendor name as reported in BootNotification.",
"type": "string"
},
"ChargingStationProblem": {
"variable_name": "Problem",
"characteristics": {
"supportsMonitoring": true,
"dataType": "boolean"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadWrite"
}
],
"description": "Some problem/fault exists",
"type": "boolean"
}
},
"required": [
"ChargingStationAvailabilityState",
"ChargingStationAvailable",
"ChargingStationSupplyPhases"
]
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Schema for ChargingStation",
"type": "object",
"name": "ChargingStation",
"properties": {
"AllowNewSessionsPendingFirmwareUpdate": {
"variable_name": "AllowNewSessionsPendingFirmwareUpdate",
"characteristics": {
"supportsMonitoring": true,
"dataType": "boolean"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadWrite"
}
],
"instance": "BytesPerMessage",
"description": "Indicates whether new sessions can be started on EVSEs, while Charging Station is waiting for all EVSEs to become Available in order to start a pending firmware update",
"type": "boolean"
},
"ChargingStationAvailabilityState": {
"variable_name": "AvailabilityState",
"characteristics": {
"supportsMonitoring": true,
"dataType": "OptionList",
"valuesList": "Available,Occupied,Reserved,Unavailable,Faulted"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadOnly"
}
],
"description": "This variable reports current availability state for the ChargingStation",
"type": "string"
},
"ChargingStationPhaseRotation": {
"variable_name": "PhaseRotation",
"characteristics": {
"supportsMonitoring": true,
"dataType": "string"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadWrite"
}
],
"description": "This variable describes the phase rotation of a Component relative to its parent Component, using a three letter string consisting of the letters: R, S, T and x.",
"type": "string"
},
"ChargingStationAvailable": {
"variable_name": "Available",
"characteristics": {
"supportsMonitoring": true,
"dataType": "boolean"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadOnly"
}
],
"description": "Component exists",
"type": "boolean"
},
"ChargingStationModel": {
"variable_name": "Model",
"characteristics": {
"supportsMonitoring": true,
"dataType": "string"
},
"attributes": [
{
"type": "Actual"
}
],
"description": "Charging station model as reported in BootNotification.",
"type": "string"
},
"ChargingStationSupplyPhases": {
"variable_name": "SupplyPhases",
"characteristics": {
"supportsMonitoring": true,
"dataType": "integer"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadOnly"
}
],
"description": "Number of alternating current phases connected/available.",
"type": "integer"
},
"ChargingStationVendorName": {
"variable_name": "VendorName",
"characteristics": {
"supportsMonitoring": true,
"dataType": "string"
},
"attributes": [
{
"type": "Actual"
}
],
"description": "Charging station vendor name as reported in BootNotification.",
"type": "string"
},
"ChargingStationProblem": {
"variable_name": "Problem",
"characteristics": {
"supportsMonitoring": true,
"dataType": "boolean"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadWrite"
}
],
"description": "Some problem/fault exists",
"type": "boolean"
}
},
"required": [
"ChargingStationAvailabilityState",
"ChargingStationAvailable",
"ChargingStationSupplyPhases"
]
}
6 changes: 3 additions & 3 deletions config/v201/component_schemas/standardized/InternalCtrlr.json
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@
"default": "32000",
"type": "integer"
},
"NotSupportedCriteria": {
"variable_name": "NotSupportedCriteria",
"SupportedCriteria": {
"variable_name": "SupportedCriteria",
"characteristics": {
"supportsMonitoring": true,
"dataType": "string"
Expand All @@ -518,7 +518,7 @@
"mutability": "ReadWrite"
}
],
"description": "List of criteria not supported for a get custom report. Enabled,Active,Problem,Available",
"description": "List of criteria supported for a get custom report. Enabled,Active,Problem,Available",
"default": "",
"type": "string"
}
Expand Down
8 changes: 4 additions & 4 deletions config/v201/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@
"Actual": "log,html"
}
},
"NotSupportedCriteria": {
"variable_name": "NotSupportedCriteria",
"SupportedCriteria": {
"variable_name": "SupportedCriteria",
"attributes": {
"Actual": ""
"Actual": "Enabled,Active,Available,Problem"
}
}
}
Expand Down Expand Up @@ -674,7 +674,7 @@
"DeviceDataCtrlrEnabled": {
"variable_name": "Enabled",
"attributes": {
"Actual": false
"Actual": true
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/ocpp/v201/ctrlr_component_variables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern const ComponentVariable& AuthorizeConnectorZeroOnConnectorOne;
extern const ComponentVariable& LogMessages;
extern const RequiredComponentVariable& LogMessagesFormat;
extern const ComponentVariable& SupportedChargingProfilePurposeTypes;
extern const ComponentVariable& NotSupportedCriteria;
extern const ComponentVariable& SupportedCriteria;
extern const ComponentVariable& MaxCompositeScheduleDuration;
extern const RequiredComponentVariable& NumberOfConnectors;
extern const ComponentVariable& UseSslDefaultVerifyPaths;
Expand Down
13 changes: 11 additions & 2 deletions include/ocpp/v201/device_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,23 @@ class DeviceModel {

/// \brief Iterates over the given \p component_criteria and converts this to the variable names
/// (Active,Available,Enabled,Problem). If any of the variables can not be found as part of a component this
/// function returns false. If any of those variable's value is true, this function returns true (except for criteria problem). If all variable's
/// value are false, this function returns false
/// function returns false. If any of those variable's value is true, this function returns true (except for
/// criteria problem). If all variable's value are false, this function returns false
/// \param component_id
/// \param /// component_criteria
/// \return
bool component_criteria_match_custom(const Component& component_id,
const std::vector<ComponentCriterionEnum>& component_criteria);

/// @brief Iterates over the given \p component_variables and filters them according to the requirement conditions.
/// @param component_variables
/// @param component_ current component
/// @param variable_ current variable
/// @return true if the component is found according to any of the requirement conditions.
bool component_variables_match(const std::vector<ComponentVariable>& component_variables,
const ocpp::v201::Component& component_,
const struct ocpp::v201::Variable& variable_);

/// \brief Sets the variable_id attribute \p value specified by \p component_id , \p variable_id and \p
/// attribute_enum \param component_id \param variable_id \param attribute_enum \param value
/// \param force_read_only If this is true, only read-only variables can be changed,
Expand Down
12 changes: 5 additions & 7 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2075,15 +2075,13 @@ void ChargePoint::handle_get_report_req(const EnhancedMessage<v201::MessageType>
}

// if a criteria is not supported then send a not supported response.
auto non_sup_criteria =
this->device_model->get_optional_value<std::string>(ControllerComponentVariables::NotSupportedCriteria);

if (non_sup_criteria.has_value() and msg.componentCriteria.has_value() and !non_sup_criteria.value().empty()) {
auto sup_criteria =
this->device_model->get_optional_value<std::string>(ControllerComponentVariables::SupportedCriteria);
if (sup_criteria.has_value() and msg.componentCriteria.has_value()) {
for (const auto& criteria : msg.componentCriteria.value()) {
const auto variable_ = conversions::component_criterion_enum_to_string(criteria);

if (non_sup_criteria.value().find(variable_) != std::string::npos) {
EVLOG_info << " This crieteria is not supported: " << variable_;
if (sup_criteria.value().find(variable_) == std::string::npos) {
EVLOG_info << "This criteria is not supported: " << variable_;
response.status = GenericDeviceModelStatusEnum::NotSupported;
break;
// TODO: maybe consider adding the reason why in statusInfo
Expand Down
4 changes: 2 additions & 2 deletions lib/ocpp/v201/ctrlr_component_variables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ const RequiredComponentVariable& LogMessagesFormat = {
"LogMessagesFormat",
}),
};
const ComponentVariable& NotSupportedCriteria = {
const ComponentVariable& SupportedCriteria = {
ControllerComponents::InternalCtrlr,
std::nullopt,
std::optional<Variable>({
"NotSupportedCriteria",
"SupportedCriteria",
}),
};
const ComponentVariable& SupportedChargingProfilePurposeTypes = {
Expand Down
Loading

0 comments on commit 0a5a692

Please sign in to comment.