Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/rename v201 to v2 #991

Merged
merged 2 commits into from
Feb 24, 2025
Merged

Refactor/rename v201 to v2 #991

merged 2 commits into from
Feb 24, 2025

Conversation

Pietfried
Copy link
Contributor

@Pietfried Pietfried commented Feb 20, 2025

Describe your changes

Since OCPP2.1 is backwards compatible with OCPP2.0.1 and we are reusing a lot of code and configuration that is now in v201 directories and namespaces for the implementation of OCPP2.1, the name v201 is missleading. We therefore decided to rename all directories and namespaces from v201 to v2. v2 can then cover the implementation of OCPP2.0.1 and OCPP2.1. All files that are only introduced for the implementation of OCPP2.1 will go into a v21 directory (e.g. generated messages).

This PR renames all directories with the name v201 to v2 and all occurances of v201 or V201 to v2 and V2.

I added a clarification for the directory structure and namespaces here

Issue ticket number and link

Checklist before requesting a review

Copy link
Contributor

@maaikez maaikez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried, it builds, the tests run and the integration tests seem to run as well.

I had some minor changes I would do as well and at least one important thing (OcppProtocolVersion)

CMakeLists.txt Outdated
@@ -19,10 +19,10 @@ option(OCPP_INSTALL "Install the library (shared data might be installed anyway)
option(LIBOCPP_ENABLE_DEPRECATED_WEBSOCKETPP "Websocket++ has been removed from the project" OFF)

option(LIBOCPP_ENABLE_V16 "Enable OCPP 1.6 in the ocpp library" ON)
option(LIBOCPP_ENABLE_V201 "Enable OCPP 2.0.1 in the ocpp library" ON)
option(LIBOCPP_ENABLE_V2 "Enable OCPP 2.0.1 in the ocpp library" ON)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Enable OCPP 2.0.1 / 2.1 in the ocpp library"

Because we will forget later on to add 2.1 there :)

set(MIGRATION_FILES_DEVICE_MODEL_SOURCE_DIR_V201 ${MIGRATION_FILES_DEVICE_MODEL_LOCATION} PARENT_SCOPE)
set(MIGRATION_DEVICE_MODEL_FILE_VERSION_V2 ${TARGET_MIGRATION_FILE_VERSION} PARENT_SCOPE)
set(MIGRATION_FILES_SOURCE_DIR_V2 ${MIGRATION_FILES_LOCATION} PARENT_SCOPE)
set(MIGRATION_FILES_DEVICE_MODEL_SOURCE_DIR_V2 ${MIGRATION_FILES_DEVICE_MODEL_LOCATION} PARENT_SCOPE)

option(LIBOCPP_INSTALL_DEVICE_MODEL_DATABASE "Install device model database for OCPP201" ON)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for OCPP2x ?

@@ -60,4 +69,4 @@ Please see the [Getting Started documentation for OCPP2.0.1](../v201/getting_sta
You will find the generated doxygen documentation at:
`build/dist/docs/html/index.html`

The main reference for the integration of libocpp for OCPP1.6 is the ocpp::v16::ChargePoint class defined in `v16/charge_point.hpp` , for OCPP2.0.1 that is the ocpp::v201::ChargePoint class defined in `v201/charge_point.hpp` .
The main reference for the integration of libocpp for OCPP1.6 is the ocpp::v16::ChargePoint class defined in `v16/charge_point.hpp` , for OCPP2.0.1 that is the ocpp::v2::ChargePoint class defined in `v2/charge_point.hpp` .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.0.1/2.1 ?
Because otherwise we will forget it anyway.

@@ -610,7 +610,7 @@ std::ostream& operator<<(std::ostream& os, const CertificateHashDataChain& k);

enum class OcppProtocolVersion {
v16,
v201,
v2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this one should still be v201

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good one

@@ -126,7 +126,7 @@ class ChargePointInterface {
/// \param charging_state The new charging state
virtual void
on_transaction_started(const int32_t evse_id, const int32_t connector_id, const std::string& session_id,
const DateTime& timestamp, const ocpp::v201::TriggerReasonEnum trigger_reason,
const DateTime& timestamp, const ocpp::v2::TriggerReasonEnum trigger_reason,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove ocpp::v2:: here anyway if you want.

const std::optional<ocpp::v201::EVSE>& evse,
const std::optional<ocpp::v201::IdToken>& id_token,
const std::optional<std::vector<ocpp::v201::MeterValue>>& meter_value,
const std::optional<ocpp::v2::EVSE>& evse,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this file, if you want to, ocpp::v2:: can be removed (it is already in this namespace).

@@ -613,8 +613,8 @@ def parse_schemas(version: str, schema_dir: Path = Path('schemas/json/'),

if version == '1.6' or version == '16' or version == 'v16':
version_path = 'v16'
elif version == '2.0.1' or version == '201' or version == 'v201':
version_path = 'v201'
elif version == '2.0.1' or version == '201' or version == 'v2':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does not seem correct. I would revert (so change back to v201) and add the 2.1 cases here (or version == '2.1' or version == '21' or version == 'v21')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the version is used in the templates for namespaces etc. so setting the version_path to v2 here should be correct. In the condition I changed it back to version == 'v2' though

@maaikez
Copy link
Contributor

maaikez commented Feb 20, 2025

Maybe this has to be changed as well:

INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP201/core_migrations

INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP201/device_model_migrations

option(LIBOCPP_INSTALL_DEVICE_MODEL_DATABASE "Install device model database for OCPP201" ON)

DESTINATION ${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP201

install(DIRECTORY ${LIBOCPP_COMPONENT_CONFIG_PATH} DESTINATION ${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP201)

set(DEVICE_MODEL_DB_LOCATION_V2 "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP201/device_model_storage.db")

But I am not sure if everything will go well then?

/// \addtogroup ocpp201_handlers OCPP 2.0.1 handlers

/// @addtogroup ocpp201_callbacks OCPP 2.0.1 callbacks

/// @} // End ocpp 201 callbacks group / topic

!log_formats.empty(), message_log_path, "libocpp_201", log_to_console, detailed_log_to_console, log_to_file,

Not very interesting:

std::make_unique<common::DatabaseConnection>(fs::path("/tmp/ocpp201") / "cp.db");

static const std::string TEMP_OUTPUT_PATH = "/tmp/ocpp201";

auto database_connection = std::make_unique<common::DatabaseConnection>(fs::path("/tmp/ocpp201") / "cp.db");

std::make_unique<common::DatabaseConnection>(fs::path("/tmp/ocpp201") / "cp.db");

@maaikez
Copy link
Contributor

maaikez commented Feb 20, 2025

And some more things (to think about, not necessarily needed now):

help="Version of OCPP [1.6 or 2.0.1]", required=True)

option(LIBOCPP_ENABLE_V2 "Enable OCPP 2.0.1 in the ocpp library" ON)

Comment change? :

# If the test is not linked against the ocpp library, those default sources for ocpp v2.0.1 can be linked against, they

// In 2.0.1, the cost and transaction id are already part of the CostUpdatedRequest, so they need to be added to

// In OCPP 2.0.1, the chargepoint status trigger is not used.

// handles required behavior specified within OCPP2.0.1 (e.g. reconnect when BasicAuthPassword has changed)

EVLOG_error << "security_profile 0 not officially allowed in OCPP 2.0.1, skipping profile";

"All profiles configured have security_profile 0 which is not officially allowed in OCPP 2.0.1");
???
/// \brief Contains all supported OCPP 2.0.1 message types

/// \brief Interface for handling OCPP2.0.1 CALL messages from the CSMS. Classes implementing a functional block shall

/// should only be called for variables that have a role standardized in the OCPP2.0.1 specification.

// Provides access to standardized variables of OCPP2.0.1 spec

/// \brief Interface class for OCPP2.0.1 Charging Station

/// \brief Class implements OCPP2.0.1 Charging Station

/// @name Constructors for 2.0.1

/// @} // End chargepoint 2.0.1 member group

/// @} // End chargepoint 2.0.1 topic

/// \brief Common base class for OCPP1.6 and OCPP2.0.1 charging stations

Maybe add 2.1 to the dropdown? Although I think that's a bit early probably (but then we don't forget).


@Pietfried Pietfried marked this pull request as ready for review February 21, 2025 10:45
@Pietfried Pietfried force-pushed the refactor/rename-v201-to-v2 branch from 7cc099b to 245a75d Compare February 24, 2025 16:24
* Added clarifications of directory structure in getting started guide

Signed-off-by: Piet Gömpel <[email protected]>
@Pietfried Pietfried force-pushed the refactor/rename-v201-to-v2 branch from 245a75d to 7c69398 Compare February 24, 2025 16:47
@Pietfried Pietfried merged commit 04059e2 into main Feb 24, 2025
7 of 8 checks passed
@Pietfried Pietfried deleted the refactor/rename-v201-to-v2 branch February 24, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants