Skip to content

Commit

Permalink
temp commit
Browse files Browse the repository at this point in the history
Signed-off-by: MarzellT <tobias.marzell@pionix.de>
  • Loading branch information
MarzellT committed Apr 19, 2024
1 parent 38fccdc commit 5cf1891
Show file tree
Hide file tree
Showing 20 changed files with 1,224 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ cd everest-dev-environment/dependency_manager
edm init --workspace ~/checkout/everest-workspace
```

This sets up a workspace based on the most recent EVerest release. If you want to check out the most recent main you can use the following command:
This sets up a workspace based on the most recent EVerest release. If you want to check out the most recent main you can use the following commandName:

Check notice on line 77 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L77

Expected: 80; Actual: 151
```bash
cd everest-dev-environment/dependency_manager
edm init main --workspace ~/checkout/everest-workspace
Expand Down Expand Up @@ -106,7 +106,7 @@ cmake ..
make install
```

(Optional) In case you have more than one CPU core and more RAM availble you can use the following command to significantly speed up the build process:
(Optional) In case you have more than one CPU core and more RAM availble you can use the following commandName to significantly speed up the build process:

Check notice on line 109 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L109

Expected: 80; Actual: 155
```bash
make -j$(nproc) install
```
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ active_modules:
imd:
module: IMDSimulator
ev_manager:
module: JsEvManager
module: EvManager
config_module:
connector_id: 1
auto_enable: true
Expand Down
1 change: 1 addition & 0 deletions interfaces/car_simulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ description: >-
cmds:
enable:
description: >-
# TODO: change description
Sets the ID that uniquely identifies the EVSE. The EVSEID shall
match the following structure: <EVSEID> = <Country Code> <S> <EVSE Operator
ID> <S> <ID Type> <Power Outlet ID>
Expand Down
1 change: 1 addition & 0 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ev_add_module(API)
ev_add_module(Auth)
ev_add_module(EnergyManager)
ev_add_module(EnergyNode)
ev_add_module(EvManager)
ev_add_module(ErrorHistory)
ev_add_module(EvseManager)
ev_add_module(EvseSecurity)
Expand Down
27 changes: 27 additions & 0 deletions modules/EvManager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# AUTO GENERATED - MARKED REGIONS WILL BE KEPT
# template version 3
#

# module setup:
# - ${MODULE_NAME}: module name
ev_setup_cpp_module()

# ev@bcc62523-e22b-41d7-ba2f-825b493a3c97:v1
# insert your custom targets and additional config variables here
# ev@bcc62523-e22b-41d7-ba2f-825b493a3c97:v1

target_sources(${MODULE_NAME}
PRIVATE
"main/car_simulatorImpl.cpp"
"main/SimData.cpp"
"main/SimCommand.cpp"
"main/RegisteredCommand.cpp"
)

# ev@c55432ab-152c-45a9-9d2e-7281d50c69c3:v1
# insert other things like install cmds etc here
if(EVEREST_CORE_BUILD_TESTING)
add_subdirectory(tests)
endif()
# ev@c55432ab-152c-45a9-9d2e-7281d50c69c3:v1
16 changes: 16 additions & 0 deletions modules/EvManager/EvManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest
#include "EvManager.hpp"
#include "main/car_simulatorImpl.hpp"

namespace module {

void EvManager::init() {
invoke_init(*p_main);
}

void EvManager::ready() {
invoke_ready(*p_main);
}

} // namespace module
97 changes: 97 additions & 0 deletions modules/EvManager/EvManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest
#ifndef EV_MANAGER_HPP
#define EV_MANAGER_HPP

//
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT
// template version 2
//

#include "ld-ev.hpp"

// headers for provided interface implementations
#include <generated/interfaces/car_simulator/Implementation.hpp>

// headers for required interface implementations
#include <generated/interfaces/ISO15118_ev/Interface.hpp>
#include <generated/interfaces/ev_board_support/Interface.hpp>
#include <generated/interfaces/ev_slac/Interface.hpp>
#include <generated/interfaces/powermeter/Interface.hpp>

// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1
// insert your custom include headers here
// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1

namespace module {

struct Conf {
int connector_id;
bool auto_enable;

Check notice on line 30 in modules/EvManager/EvManager.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EvManager/EvManager.hpp#L30

struct member 'Conf::auto_enable' is never used.
bool auto_exec;
std::string auto_exec_commands;

Check notice on line 32 in modules/EvManager/EvManager.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EvManager/EvManager.hpp#L32

struct member 'Conf::auto_exec_commands' is never used.
int dc_max_current_limit;

Check notice on line 33 in modules/EvManager/EvManager.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EvManager/EvManager.hpp#L33

struct member 'Conf::dc_max_current_limit' is never used.
int dc_max_power_limit;

Check notice on line 34 in modules/EvManager/EvManager.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EvManager/EvManager.hpp#L34

struct member 'Conf::dc_max_power_limit' is never used.
int dc_max_voltage_limit;
int dc_energy_capacity;
int dc_target_current;

Check notice on line 37 in modules/EvManager/EvManager.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EvManager/EvManager.hpp#L37

struct member 'Conf::dc_target_current' is never used.
int dc_target_voltage;
bool support_sae_j2847;

Check notice on line 39 in modules/EvManager/EvManager.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EvManager/EvManager.hpp#L39

struct member 'Conf::support_sae_j2847' is never used.
int dc_discharge_max_current_limit;
int dc_discharge_max_power_limit;

Check notice on line 41 in modules/EvManager/EvManager.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EvManager/EvManager.hpp#L41

struct member 'Conf::dc_discharge_max_power_limit' is never used.
int dc_discharge_target_current;
int dc_discharge_v2g_minimal_soc;

Check notice on line 43 in modules/EvManager/EvManager.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EvManager/EvManager.hpp#L43

struct member 'Conf::dc_discharge_v2g_minimal_soc' is never used.
double max_curent;

Check notice on line 44 in modules/EvManager/EvManager.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EvManager/EvManager.hpp#L44

struct member 'Conf::max_curent' is never used.
bool three_phases;
};

class EvManager : public Everest::ModuleBase {
public:
EvManager() = delete;
EvManager(const ModuleInfo& info, Everest::MqttProvider& mqtt_provider,
std::unique_ptr<car_simulatorImplBase> p_main, std::unique_ptr<ev_board_supportIntf> r_ev_board_support,
std::vector<std::unique_ptr<ISO15118_evIntf>> r_ev, std::vector<std::unique_ptr<ev_slacIntf>> r_slac,
std::vector<std::unique_ptr<powermeterIntf>> r_powermeter, Conf& config) :
ModuleBase(info),
mqtt(mqtt_provider),
p_main(std::move(p_main)),
r_ev_board_support(std::move(r_ev_board_support)),
r_ev(std::move(r_ev)),
r_slac(std::move(r_slac)),
r_powermeter(std::move(r_powermeter)),
config(config){};

Everest::MqttProvider& mqtt;
const std::unique_ptr<car_simulatorImplBase> p_main;
const std::unique_ptr<ev_board_supportIntf> r_ev_board_support;
const std::vector<std::unique_ptr<ISO15118_evIntf>> r_ev;
const std::vector<std::unique_ptr<ev_slacIntf>> r_slac;
const std::vector<std::unique_ptr<powermeterIntf>> r_powermeter;
const Conf& config;

// ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1
// insert your public definitions here
// ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1

protected:
// ev@4714b2ab-a24f-4b95-ab81-36439e1478de:v1
// insert your protected definitions here
// ev@4714b2ab-a24f-4b95-ab81-36439e1478de:v1

private:
friend class LdEverest;
void init();
void ready();

// ev@211cfdbe-f69a-4cd6-a4ec-f8aaa3d1b6c8:v1
// insert your private definitions here
// ev@211cfdbe-f69a-4cd6-a4ec-f8aaa3d1b6c8:v1
};

// ev@087e516b-124c-48df-94fb-109508c7cda9:v1
// insert other definitions here
// ev@087e516b-124c-48df-94fb-109508c7cda9:v1

} // namespace module

#endif // EV_MANAGER_HPP
22 changes: 22 additions & 0 deletions modules/EvManager/doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. _everest_modules_handwritten_EvManager:

.. This file is a placeholder for an optional single file
handwritten documentation for the EvManager module.
Please decide whether you want to use this single file,
or a set of files in the doc/ directory.
In the latter case, you can delete this file.
In the former case, you can delete the doc/ directory.
.. This handwritten documentation is optional. In case
you do not want to write it, you can delete this file
and the doc/ directory.
.. The documentation can be written in reStructuredText,
and will be converted to HTML and PDF by Sphinx.
*******************************************
EvManager
*******************************************

:ref:`Link <everest_modules_EvManager>` to the module's reference.
This module implements a Car simulator that can execute charging sessions using the yeti-simulation-control interface
23 changes: 23 additions & 0 deletions modules/EvManager/docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. _everest_modules_handwritten_EvManager:

.. This file is a placeholder for optional multiple files
handwritten documentation for the EvManager module.
Please decide whether you want to use the doc.rst file
or a set of files in the doc/ directory.
In the latter case, you can delete the doc.rst file.
In the former case, you can delete the doc/ directory.
.. This handwritten documentation is optional. In case
you do not want to write it, you can delete this file
and the doc/ directory.
.. The documentation can be written in reStructuredText,
and will be converted to HTML and PDF by Sphinx.
This index.rst file is the entry point for the module documentation.
*******************************************
EvManager
*******************************************

:ref:`Link <everest_modules_EvManager>` to the module's reference.
This module implements a Car simulator that can execute charging sessions using the yeti-simulation-control interface
4 changes: 4 additions & 0 deletions modules/EvManager/main/RegisteredCommand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest

#include "RegisteredCommand.hpp"
67 changes: 67 additions & 0 deletions modules/EvManager/main/RegisteredCommand.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest

#ifndef TMP_CLION_CLANG_TIDY_SIMCOMMAND_HPP
#define TMP_CLION_CLANG_TIDY_SIMCOMMAND_HPP

#include <cstddef>
#include <memory>
#include <mutex>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
namespace module::main {

template <typename Func> class RegisteredCommand;

class RegisteredCommandBase {
public:
RegisteredCommandBase() = default;
virtual ~RegisteredCommandBase(){};
RegisteredCommandBase(const RegisteredCommandBase&) = default;
RegisteredCommandBase& operator=(const RegisteredCommandBase&) = default;
RegisteredCommandBase(RegisteredCommandBase&&) = default;
RegisteredCommandBase& operator=(RegisteredCommandBase&&) = default;

virtual bool operator()(const std::vector<std::string>& arguments) const = 0;

// TODO: maybe we could deduce the argument count from the function signature somehow
template <typename FunctionT>
static void registerCommand(std::string commandName, FunctionT&& function, size_t argumentCount) {
registeredCommands.try_emplace(commandName, std::make_unique<RegisteredCommand<FunctionT>>(
commandName, argumentCount, std::forward<FunctionT>(function)));
}

static const RegisteredCommandBase& getRegisteredCommand(const std::string& commandName) {
return *registeredCommands.at(commandName).get();
}

private:
inline static std::unordered_map<std::string, std::unique_ptr<RegisteredCommandBase>> registeredCommands;
};

template <typename FunctionT> class RegisteredCommand : public RegisteredCommandBase {
public:
RegisteredCommand(std::string commandName, std::size_t argumentCount, FunctionT function) :
commandName{std::move(commandName)}, argumentCount{argumentCount}, function{std::move(function)} {
}

~RegisteredCommand() override = default;

bool operator()(const std::vector<std::string>& arguments) const override {
if (!arguments.empty() && arguments.size() != argumentCount) {
throw std::invalid_argument{"Invalid number of arguments"};
}
return function(arguments);
}

private:
std::string commandName;
std::size_t argumentCount;
FunctionT function;
};
} // namespace module::main

#endif
18 changes: 18 additions & 0 deletions modules/EvManager/main/SimCommand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest

#include "SimCommand.hpp"
#include <string>
#include <utility>
#include <vector>
namespace module::main {

SimCommand::SimCommand(std::string commandName, std::vector<std::string> arguments) :
arguments{std::move(arguments)}, registeredCommand{RegisteredCommandBase::getRegisteredCommand(commandName)} {
}

bool SimCommand::execute() {
return registeredCommand(arguments);
}

} // namespace module::main
34 changes: 34 additions & 0 deletions modules/EvManager/main/SimCommand.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest

#ifndef TMP_CLION_CLANG_TIDY_SIMCOMMAND_HPP
#define TMP_CLION_CLANG_TIDY_SIMCOMMAND_HPP

#include <cstddef>
#include <memory>
#include <mutex>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

namespace module::main {

class RegisteredCommandBase;

class SimCommand {
public:
SimCommand(std::string commandName, std::vector<std::string> arguments);

bool execute();

private:
std::vector<std::string> arguments;

Check notice on line 27 in modules/EvManager/main/SimCommand.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EvManager/main/SimCommand.hpp#L27

class member 'SimCommand::arguments' is never used.

const RegisteredCommandBase& registeredCommand;
};

} // namespace module::main

#endif // TMP_CLION_CLANG_TIDY_SIMCOMMAND_HPP
Loading

0 comments on commit 5cf1891

Please sign in to comment.