-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adds slac simulator Signed-off-by: MarzellT <[email protected]> * updates codeowners file Signed-off-by: MarzellT <[email protected]> * changes loop_interval_ms variable to constexpr Signed-off-by: MarzellT <[email protected]> * removes doc files and changes namespace definitions Signed-off-by: MarzellT <[email protected]> * changes the config files to make use of the new SlacSimulator Signed-off-by: MarzellT <[email protected]> * Initialize car_simulation in init() instead of ready() to ensure it's initialized early enough Otherwise publishes from other modules can happen before its initialization triggering segfaults Signed-off-by: Kai-Uwe Hermann <[email protected]> * Removed config options that were not used Signed-off-by: Kai-Uwe Hermann <[email protected]> * Move SlacSimulator into simulation directory Signed-off-by: Kai-Uwe Hermann <[email protected]> --------- Signed-off-by: MarzellT <[email protected]> Signed-off-by: Kai-Uwe Hermann <[email protected]> Co-authored-by: Kai-Uwe Hermann <[email protected]>
- Loading branch information
1 parent
17555a7
commit 65aa57b
Showing
26 changed files
with
456 additions
and
15 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
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
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
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,26 @@ | ||
# | ||
# 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 | ||
"evse/slacImpl.cpp" | ||
"ev/ev_slacImpl.cpp" | ||
) | ||
|
||
# ev@c55432ab-152c-45a9-9d2e-7281d50c69c3:v1 | ||
# insert other things like install cmds etc here | ||
target_sources(${MODULE_NAME} | ||
PRIVATE | ||
"util/state.cpp" | ||
) | ||
# 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,36 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
#include "SlacSimulator.hpp" | ||
#include "ev/ev_slacImpl.hpp" | ||
#include "evse/slacImpl.hpp" | ||
|
||
namespace module { | ||
|
||
using util::State; | ||
|
||
void SlacSimulator::init() { | ||
invoke_init(*p_evse); | ||
invoke_init(*p_ev); | ||
} | ||
|
||
void SlacSimulator::ready() { | ||
invoke_ready(*p_evse); | ||
invoke_ready(*p_ev); | ||
|
||
std::thread(&SlacSimulator::run, this).detach(); | ||
} | ||
|
||
void SlacSimulator::run() { | ||
auto& evse = dynamic_cast<evse::slacImpl&>(*p_evse); | ||
auto& ev = dynamic_cast<ev::ev_slacImpl&>(*p_ev); | ||
while (true) { | ||
cntmatching++; | ||
if (ev.get_state() == State::MATCHING && evse.get_state() == State::MATCHING && cntmatching > 2 * 4) { | ||
ev.set_state_matched(); | ||
evse.set_state_matched(); | ||
} | ||
std::this_thread::sleep_for(std::chrono::milliseconds(loop_interval_ms)); | ||
} | ||
}; | ||
|
||
} // 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,67 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
#ifndef SLAC_SIMULATOR_HPP | ||
#define SLAC_SIMULATOR_HPP | ||
|
||
// | ||
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT | ||
// template version 2 | ||
// | ||
|
||
#include "ld-ev.hpp" | ||
|
||
// headers for provided interface implementations | ||
#include <generated/interfaces/ev_slac/Implementation.hpp> | ||
#include <generated/interfaces/slac/Implementation.hpp> | ||
|
||
// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1 | ||
// insert your custom include headers here | ||
#include "util/state.hpp" | ||
// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1 | ||
|
||
namespace module { | ||
|
||
struct Conf {}; | ||
|
||
class SlacSimulator : public Everest::ModuleBase { | ||
public: | ||
SlacSimulator() = delete; | ||
SlacSimulator(const ModuleInfo& info, Everest::MqttProvider& mqtt_provider, std::unique_ptr<slacImplBase> p_evse, | ||
std::unique_ptr<ev_slacImplBase> p_ev, Conf& config) : | ||
ModuleBase(info), mqtt(mqtt_provider), p_evse(std::move(p_evse)), p_ev(std::move(p_ev)), config(config){}; | ||
|
||
Everest::MqttProvider& mqtt; | ||
const std::unique_ptr<slacImplBase> p_evse; | ||
const std::unique_ptr<ev_slacImplBase> p_ev; | ||
const Conf& config; | ||
|
||
// ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1 | ||
// insert your public definitions here | ||
std::size_t cntmatching{0}; | ||
// 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 | ||
void run(); | ||
|
||
static constexpr size_t loop_interval_ms{250}; | ||
// 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 // SLAC_SIMULATOR_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,44 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
|
||
#include "ev_slacImpl.hpp" | ||
|
||
namespace module { | ||
namespace ev { | ||
|
||
using util::State; | ||
|
||
void ev_slacImpl::init() { | ||
} | ||
|
||
void ev_slacImpl::ready() { | ||
publish_state(state_to_string(state)); | ||
} | ||
|
||
void ev_slacImpl::handle_reset() { | ||
if (state != State::UNMATCHED) { | ||
state = State::UNMATCHED; | ||
publish_state(state_to_string(state)); | ||
publish_dlink_ready(false); | ||
} | ||
} | ||
|
||
bool ev_slacImpl::handle_trigger_matching() { | ||
state = State::MATCHING; | ||
mod->cntmatching = 0; | ||
publish_state(state_to_string(state)); | ||
return true; | ||
} | ||
|
||
State ev_slacImpl::get_state() const { | ||
return state; | ||
} | ||
|
||
void ev_slacImpl::set_state_matched() { | ||
state = State::MATCHED; | ||
publish_state(state_to_string(state)); | ||
publish_dlink_ready(true); | ||
} | ||
|
||
} // namespace ev | ||
} // 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,66 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
#ifndef EV_EV_SLAC_IMPL_HPP | ||
#define EV_EV_SLAC_IMPL_HPP | ||
|
||
// | ||
// AUTO GENERATED - MARKED REGIONS WILL BE KEPT | ||
// template version 3 | ||
// | ||
|
||
#include <generated/interfaces/ev_slac/Implementation.hpp> | ||
|
||
#include "../SlacSimulator.hpp" | ||
|
||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1 | ||
// insert your custom include headers here | ||
#include "../util/state.hpp" | ||
// ev@75ac1216-19eb-4182-a85c-820f1fc2c091:v1 | ||
|
||
namespace module { | ||
namespace ev { | ||
|
||
struct Conf {}; | ||
|
||
class ev_slacImpl : public ev_slacImplBase { | ||
public: | ||
ev_slacImpl() = delete; | ||
ev_slacImpl(Everest::ModuleAdapter* ev, const Everest::PtrContainer<SlacSimulator>& mod, Conf& config) : | ||
ev_slacImplBase(ev, "ev"), mod(mod), config(config){}; | ||
|
||
// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1 | ||
// insert your public definitions here | ||
util::State get_state() const; | ||
void set_state_matched(); | ||
// ev@8ea32d28-373f-4c90-ae5e-b4fcc74e2a61:v1 | ||
|
||
protected: | ||
// command handler functions (virtual) | ||
virtual void handle_reset() override; | ||
virtual bool handle_trigger_matching() override; | ||
|
||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1 | ||
// insert your protected definitions here | ||
// ev@d2d1847a-7b88-41dd-ad07-92785f06f5c4:v1 | ||
|
||
private: | ||
const Everest::PtrContainer<SlacSimulator>& mod; | ||
const Conf& config; | ||
|
||
virtual void init() override; | ||
virtual void ready() override; | ||
|
||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1 | ||
// insert your private definitions here | ||
util::State state; | ||
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1 | ||
}; | ||
|
||
// ev@3d7da0ad-02c2-493d-9920-0bbbd56b9876:v1 | ||
// insert other definitions here | ||
// ev@3d7da0ad-02c2-493d-9920-0bbbd56b9876:v1 | ||
|
||
} // namespace ev | ||
} // namespace module | ||
|
||
#endif // EV_EV_SLAC_IMPL_HPP |
Oops, something went wrong.