Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/custom-license
Browse files Browse the repository at this point in the history
# Conflicts:
#	ev-dev-tools/src/ev_cli/ev.py

Signed-off-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
hikinggrass committed Nov 21, 2024
2 parents 51cfe60 + 6960056 commit 5d87e20
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 28 deletions.
28 changes: 25 additions & 3 deletions ev-dev-tools/src/ev_cli/ev.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,9 @@ def main():
common_parser.add_argument('--licenses', '-lc', type=str,
help='license directory from which ev-cli will attempt to parse custom license texts (default ../licenses)',
default=str(Path.cwd() / '../licenses'))
common_parser.add_argument('--build-dir', '-bd', type=str,
help='everest build directory from which ev-cli will attempt to parse the everest framework schema definitions (default ./build)',
default=str(Path.cwd() / 'build'))
common_parser.add_argument('--clang-format-file', type=str, default=str(Path.cwd()),
help='Path to the directory, containing the .clang-format file (default: .)')
common_parser.add_argument('--disable-clang-format', action='store_true', default=False,
Expand Down Expand Up @@ -864,10 +867,29 @@ def main():

schemas_dir = Path(args.schemas_dir).resolve()
if not schemas_dir.exists():
print('The default ("../everest-framework/schemas") xor supplied (via --schemas-dir) schemas directory\n'
'doesn\'t exist.\n'
print('The default ("../everest-framework/schemas") xor supplied (via --schemas-dir) schemas directory'
' doesn\'t exist.\n'
f'dir: {schemas_dir}')
exit(1)
cmake_cache_path = Path(args.build_dir) / 'CMakeCache.txt'
print(f'Searching for everest-framework in: {cmake_cache_path}')
print('You can either provide the schemas directory with --schemas-dir or influence the'
' automatic search path by setting --build-dir (default: ./build)')
if not cmake_cache_path.exists():
print(f'CMakeCache.txt does not exist: {cmake_cache_path}')
exit(1)
with open(cmake_cache_path, 'r') as cmake_cache_file:
search = 'everest-framework_SOURCE_DIR:STATIC='
for line in cmake_cache_file:
if line.startswith(search):
found_schemas_dir = Path(line.replace(search, '', 1).strip(' \t\n\r')) / 'schemas'
if found_schemas_dir.exists():
print(f'Found everest-framework schemas directory: {found_schemas_dir}')
user_choice = input('Do you want to use this? [Y/n] ').lower()
if user_choice == 'y' or not user_choice:
schemas_dir = found_schemas_dir
break
if not schemas_dir.exists():
exit(1)

validators = helpers.load_validators(schemas_dir)

Expand Down
2 changes: 1 addition & 1 deletion everest-testing/src/everest/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__="0.4.2"
__version__="0.4.3"
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@

@dataclass
class EverestEnvironmentOCPPConfiguration:
libocpp_path: Path
ocpp_version: OCPPVersion
central_system_port: int
central_system_host: str = "127.0.0.1"
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_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
Path] = None # Path of the OCPP device model json schemas.
configuration_strategies: list[OCPPModuleConfigurationStrategy] | None = None


Expand Down Expand Up @@ -208,9 +207,7 @@ 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:
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'
source_ocpp_config = self._ocpp_config.device_model_component_config_path

return liboccp_configuration_helper.generate_ocpp_config(
central_system_port=self._ocpp_config.central_system_port,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ def plug_out(self, connector_id=1):
f"{self._mqtt_external_prefix}everest_external/nodered/{connector_id}/carsim/cmd/modify_charging_session",
"unplug")

def plug_out_iso(self, connector_id=1):
self._mqtt_client.publish(
f"{self._mqtt_external_prefix}everest_external/nodered/{connector_id}/carsim/cmd/modify_charging_session",
"iso_stop_charging;iso_wait_v2g_session_stopped;unplug")

def swipe(self, token, connectors=None):
connectors = connectors if connectors is not None else [1]
provided_token = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def plug_in_ac_iso(self, payment_type, connector_id):
"""
raise NotImplementedError()

def plug_out_iso(self, connector_id):
"""
Plug out of an electric vehicle properly ending the ISO15118 session.
"""
raise NotImplementedError()

def plug_out(self):
"""
Plug out of an electric vehicle from the chargepoint.
Expand Down
59 changes: 40 additions & 19 deletions everest-testing/src/everest/testing/ocpp_utils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def ocpp_config(request, central_system: CentralSystem, test_config: OcppTestCon
central_system_port=central_system.port,
central_system_host="127.0.0.1",
ocpp_version=ocpp_version,
libocpp_path=Path(request.config.getoption("--libocpp")),
template_ocpp_config=Path(ocpp_config_marker.args[0]) if ocpp_config_marker else None,
device_model_component_config_path=Path(f"{request.config.getoption('--everest-prefix')}/share/everest/modules/OCPP201/component_config"),
configuration_strategies=ocpp_configuration_strategies
)

Expand Down Expand Up @@ -103,9 +103,45 @@ def test_config():


class FtpThread(Thread):
def __init__(self, directory, port, test_config: OcppTestConfiguration, ftp_socket,
group = None, target = None, name = None, args = ..., kwargs = None, *, daemon = None):
super().__init__(group, target, name, args, kwargs, daemon=daemon)
self.directory = directory
self.port = port
self.test_config = test_config
self.ftp_socket = ftp_socket

def set_directory(self, directory):
self.directory = directory

def set_port(self, port):
self.port = port

def set_test_config(self, test_config: OcppTestConfiguration):
self.test_config = test_config

def set_socket(self, ftp_socket):
self.ftp_socket = ftp_socket

def stop(self):
self.server.close_all()

def run(self):
shutil.copyfile(self.test_config.firmware_info.update_file, os.path.join(
self.directory, "firmware_update.pnx"))
shutil.copyfile(self.test_config.firmware_info.update_file_signature,
os.path.join(self.directory, "firmware_update.pnx.base64"))

authorizer = DummyAuthorizer()
authorizer.add_user(getpass.getuser(), "12345", self.directory, perm="elradfmwMT")

handler = FTPHandler
handler.authorizer = authorizer

self.server = servers.FTPServer(self.ftp_socket, handler)

self.server.serve_forever()


@pytest.fixture
def ftp_server(test_config: OcppTestConfiguration):
Expand All @@ -120,29 +156,14 @@ def ftp_server(test_config: OcppTestConfiguration):
ftp_socket.bind(address)
port = ftp_socket.getsockname()[1]

def _ftp_server(test_config: OcppTestConfiguration, ftp_socket):
shutil.copyfile(test_config.firmware_info.update_file, os.path.join(
d, "firmware_update.pnx"))
shutil.copyfile(test_config.firmware_info.update_file_signature,
os.path.join(d, "firmware_update.pnx.base64"))

authorizer = DummyAuthorizer()
authorizer.add_user(getpass.getuser(), "12345", d, perm="elradfmwMT")

handler = FTPHandler
handler.authorizer = authorizer

server = servers.FTPServer(ftp_socket, handler)

server.serve_forever()

ftp_thread = FtpThread(target=_ftp_server, args=[test_config, ftp_socket])
ftp_thread = FtpThread(directory=d, port=port, test_config=test_config, ftp_socket=ftp_socket)
ftp_thread.daemon = True
ftp_thread.set_port(port)
ftp_thread.start()

yield ftp_thread

ftp_thread.stop()

shutil.rmtree(d)


Expand Down

0 comments on commit 5d87e20

Please sign in to comment.