Skip to content

Commit

Permalink
OCPP201 device model setup in cmake (#190)
Browse files Browse the repository at this point in the history
* added execution of python scripts to setup the device model database to cmake script

Signed-off-by: pietfried <[email protected]>

* allowing to specify ocpp201 config as cmake parameter

Signed-off-by: pietfried <[email protected]>

---------

Signed-off-by: pietfried <[email protected]>
  • Loading branch information
Pietfried authored Sep 27, 2023
1 parent a53e4e0 commit e8e9b9e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
14 changes: 1 addition & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,7 @@ This library is automatically integrated as the OCPP and OCPP201 module within [
If you run libocpp with OCPP1.6 with EVerest, the build process of [everest-core](https://github.com/EVerest/everest-core) will take care of installing all necessary dependencies for you.

### Run OCPP2.0.1 with EVerest
the build process of [everest-core](https://github.com/EVerest/everest-core) will take care of installing all necessary dependencies for you. Additionally for OCPP2.0.1 you need to set up the SQLite device model storage database.

```bash
cd config/v201
python3 init_device_model_db.py
python3 insert_device_model_config.py --config config.json --db /tmp/ocpp201/device_model_storage.db
```

These two scripts do the following:

- create the database and tables and it will
- insert the variables with a role standardized within the OCPP2.0.1 specification
- insert the VariableAttributes specified within the config.json
If you run libocpp with OCPP1.6 with EVerest, the build process of [everest-core](https://github.com/EVerest/everest-core) will take care of installing all necessary dependencies for you. This includes the initialization of the device model database using the [config.json](config/v201/config.json) file.
## Integrate this library with your Charging Station Implementation for OCPP1.6

OCPP is a protocol that affects, controls and monitors many areas of a charging station's operation.
Expand Down
41 changes: 40 additions & 1 deletion config/v201/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
set(SQL_INIT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/init_core.sql")

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

list(APPEND CONFIGS
config.json
../logging.ini
Expand All @@ -10,4 +12,41 @@ install(
DESTINATION ${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP201
)

install(FILES ${SQL_INIT_FILE} DESTINATION ${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP201)
install(FILES ${SQL_INIT_FILE} DESTINATION ${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP201)

if (LIBOCPP_INSTALL_DEVICE_MODEL_DATABASE)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/config.json)

find_program(
PYTHON_EXECUTABLE
python3
REQUIRED
)

set(INIT_DEVICE_MODULE_DB_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/init_device_model_db.py")
set(INSERT_DEVICE_MODULE_CONFIG_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/insert_device_model_config.py")
set(DEVICE_MODEL_DATABASE_FILE "device_model_storage.db")

if(NOT LIBOCPP_V201_CONFIG_FILE)
set(LIBOCPP_V201_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/config.json")
endif()


message(STATUS "Using ocpp v201 config file path: ${LIBOCPP_V201_CONFIG_FILE}")

execute_process(
COMMAND
${PYTHON_EXECUTABLE} ${INIT_DEVICE_MODULE_DB_SCRIPT} --out ${CMAKE_CURRENT_BINARY_DIR}/${DEVICE_MODEL_DATABASE_FILE}
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
)

execute_process(
COMMAND
${PYTHON_EXECUTABLE} ${INSERT_DEVICE_MODULE_CONFIG_SCRIPT} --db ${CMAKE_CURRENT_BINARY_DIR}/${DEVICE_MODEL_DATABASE_FILE} --config ${LIBOCPP_V201_CONFIG_FILE}
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DEVICE_MODEL_DATABASE_FILE} DESTINATION ${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP201)
endif()

0 comments on commit e8e9b9e

Please sign in to comment.