Skip to content

Commit

Permalink
adjust device model database init
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Klemm <[email protected]>
  • Loading branch information
klemmpnx authored and Pietfried committed Nov 22, 2023
1 parent 63a9d67 commit 47e10e8
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import subprocess
import sys
from abc import ABC, abstractmethod
from copy import deepcopy
from pathlib import Path
Expand Down Expand Up @@ -85,7 +86,8 @@ def adjust_ocpp_configuration(self, config: dict):
for network_connection_profile in network_connection_profiles:
security_profile = network_connection_profile["connectionData"]["securityProfile"]
protocol = "ws" if security_profile == 1 else "wss"
network_connection_profile["connectionData"]["ocppCsmsUrl"] = f"{protocol}://{self._central_system_host}:{self._central_system_port}"
network_connection_profile["connectionData"][
"ocppCsmsUrl"] = f"{protocol}://{self._central_system_host}:{self._central_system_port}"
self._set_value_in_v201_config(config, "InternalCtrlr", "NetworkConnectionProfiles",
"Actual", json.dumps(network_connection_profiles))
return config
Expand Down Expand Up @@ -118,16 +120,14 @@ def create_temporary_ocpp_configuration_db(libocpp_path: Path,
device_model_schemas_path: Path,
ocpp_configuration_file: Path,
target_directory: Path):
wd = libocpp_path / "config/v201"
subprocess.run(
f"python3 {libocpp_path / 'config/v201/init_device_model_db.py'} --out {target_directory / 'device_model_storage.db'} --schemas {device_model_schemas_path}",
cwd=wd,
check=True,
shell=True
)
subprocess.run(
f"python3 {libocpp_path / 'config/v201/insert_device_model_config.py'} --config {ocpp_configuration_file} --db {target_directory / 'device_model_storage.db'}",
cwd=wd,
check=True,
shell=True
)
import_path = libocpp_path / "config/v201"
sys.path.append(str(import_path))
from init_device_model_db import DeviceModelDatabaseInitializer

database_file = target_directory / 'device_model_storage.db'
database_initializer = DeviceModelDatabaseInitializer(database_file)

database_initializer.initialize_database(schemas_path=device_model_schemas_path)
database_initializer.insert_config_and_default_values(
config_file=ocpp_configuration_file,
schemas_path=device_model_schemas_path)

0 comments on commit 47e10e8

Please sign in to comment.