-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: MarzellT <tobias.marzell@pionix.de>
- Loading branch information
Showing
20 changed files
with
1,224 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
bool auto_exec; | ||
std::string auto_exec_commands; | ||
int dc_max_current_limit; | ||
int dc_max_power_limit; | ||
int dc_max_voltage_limit; | ||
int dc_energy_capacity; | ||
int dc_target_current; | ||
int dc_target_voltage; | ||
bool support_sae_j2847; | ||
int dc_discharge_max_current_limit; | ||
int dc_discharge_max_power_limit; | ||
int dc_discharge_target_current; | ||
int dc_discharge_v2g_minimal_soc; | ||
double max_curent; | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
const RegisteredCommandBase& registeredCommand; | ||
}; | ||
|
||
} // namespace module::main | ||
|
||
#endif // TMP_CLION_CLANG_TIDY_SIMCOMMAND_HPP |
Oops, something went wrong.