Skip to content

Commit

Permalink
Ocpp 2.0.1 config is now in the same file as the component schema. Ch…
Browse files Browse the repository at this point in the history
…ange some paths etc.

Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
  • Loading branch information
maaikez committed Aug 8, 2024
1 parent b1d74b3 commit 8abca89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class EverestEnvironmentOCPPConfiguration:
ocpp_module_id: str = "ocpp"
template_ocpp_config: Optional[
Path] = None # Path for OCPP config to be used; if not provided, will be determined from everest config
device_model_schemas_path: Optional[
Path] = None # Path of the OCPP device model json schemas. If not set, {libocpp_path} / 'config/v201/component_schemas' will be used
device_model_component_config_path: Optional[
Path] = None # Path of the OCPP device model json schemas. If not set, {libocpp_path} / 'config/v201/component_config' will be used
configuration_strategies: list[OCPPModuleConfigurationStrategy] | None = None


Expand Down Expand Up @@ -195,8 +195,9 @@ def _setup_libocpp_configuration(self, temporary_paths: _EverestEnvironmentTempo
elif self._ocpp_config.ocpp_version == OCPPVersion.ocpp16:
source_ocpp_config = self._determine_configured_charge_point_config_path_from_everest_config()
elif self._ocpp_config.ocpp_version == OCPPVersion.ocpp201:
ocpp_dir = self._everest_core.prefix_path / "share/everest/modules/OCPP201"
source_ocpp_config = ocpp_dir / "config.json"
source_ocpp_config = self._ocpp_config.device_model_component_config_path \
if self._ocpp_config.device_model_component_config_path \
else self._ocpp_config.libocpp_path / 'config/v201/component_config'


liboccp_configuration_helper.generate_ocpp_config(
Expand All @@ -208,16 +209,6 @@ def _setup_libocpp_configuration(self, temporary_paths: _EverestEnvironmentTempo
configuration_strategies=self._ocpp_config.configuration_strategies
)

if self._ocpp_config.ocpp_version == OCPPVersion.ocpp201:
liboccp_configuration_helper.create_temporary_ocpp_configuration_db(
libocpp_path=self._ocpp_config.libocpp_path,
device_model_schemas_path=self._ocpp_config.device_model_schemas_path \
if self._ocpp_config.device_model_schemas_path \
else self._ocpp_config.libocpp_path / 'config/v201/component_schemas',
ocpp_configuration_file=temporary_paths.ocpp_config_file,
target_directory=temporary_paths.ocpp_database_dir
)

def _create_everest_configuration_strategies(self, temporary_paths: _EverestEnvironmentTemporaryPaths):
configuration_strategies = []
if self._ocpp_config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,3 @@ def _get_default_strategy(self, central_system_port: int | str,
central_system_host: str) -> OCPPConfigAdjustmentStrategy:
return _OCPP201NetworkConnectionProfileAdjustment(central_system_port, central_system_host)

@staticmethod
def create_temporary_ocpp_configuration_db(libocpp_path: Path,
device_model_schemas_path: Path,
ocpp_configuration_file: Path,
target_directory: Path):
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 8abca89

Please sign in to comment.