Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Slac Simulator #859

Merged
merged 14 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
/modules/Setup @hikinggrass @corneliusclaussen @pietfried
/modules/YetiDriver @corneliusclaussen @hikinggrass
/modules/simulation/ @SebaLukas @pietfried @hikinggrass
/modules/SlacSimulator/ @SebaLukas @pietfried @corneliusclaussen @MarzellT
/modules/rust_examples/ @SirVer @golovasteek @dorezyuk
**/Cargo.toml @SirVer @golovasteek @dorezyuk
**/Cargo.lock @SirVer @golovasteek @dorezyuk
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-dc-sae-v2g.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ active_modules:
config_module:
connector_id: 1
slac:
module: JsSlacSimulator
module: SlacSimulator
imd:
module: IMDSimulator
config_implementation:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-dc-sae-v2h.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ active_modules:
config_module:
connector_id: 1
slac:
module: JsSlacSimulator
module: SlacSimulator
imd:
module: IMDSimulator
config_implementation:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-dc-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ active_modules:
config_module:
connector_id: 1
slac:
module: JsSlacSimulator
module: SlacSimulator
imd:
config_implementation:
main:
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 @@ -51,7 +51,7 @@ active_modules:
config_module:
connector_id: 1
slac:
module: JsSlacSimulator
module: SlacSimulator
imd:
config_implementation:
main:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-energy-management.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ active_modules:
config_module:
connector_id: 2
slac:
module: JsSlacSimulator
module: SlacSimulator
ev_manager_1:
module: EvManager
config_module:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-ocpp-custom-extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ active_modules:
config_module:
connector_id: 2
slac:
module: JsSlacSimulator
module: SlacSimulator
ev_manager_1:
module: EvManager
config_module:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-ocpp-pnc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ active_modules:
config_module:
connector_id: 2
slac:
module: JsSlacSimulator
module: SlacSimulator
ev_manager_1:
module: EvManager
config_module:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-ocpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ active_modules:
config_module:
connector_id: 2
slac:
module: JsSlacSimulator
module: SlacSimulator
ev_manager_1:
module: EvManager
config_module:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-ocpp201-pnc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ active_modules:
config_module:
connector_id: 2
slac:
module: JsSlacSimulator
module: SlacSimulator
ev_manager_1:
module: EvManager
config_module:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-ocpp201.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ active_modules:
config_module:
connector_id: 2
slac:
module: JsSlacSimulator
module: SlacSimulator
ev_manager_1:
module: EvManager
config_module:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-two-evse-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ active_modules:
config_module:
connector_id: 2
slac_1:
module: JsSlacSimulator
module: SlacSimulator
powersupply_dc:
module: DCSupplySimulator
imd:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-two-evse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ active_modules:
config_module:
connector_id: 2
slac:
module: JsSlacSimulator
module: SlacSimulator
ev_manager_1:
module: EvManager
config_module:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ active_modules:
nid: pionix!
number_of_sounds: 10
connections: {}
module: JsSlacSimulator
module: SlacSimulator
token_provider:
config_implementation:
main:
Expand Down
1 change: 1 addition & 0 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ev_add_module(DummyTokenValidator)
ev_add_module(DummyTokenProvider)
ev_add_module(DummyTokenProviderManual)
ev_add_module(PhyVersoBSP)
ev_add_module(SlacSimulator)

add_subdirectory(examples)
add_subdirectory(simulation)
Expand Down
4 changes: 2 additions & 2 deletions modules/EvManager/main/car_simulatorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ void car_simulatorImpl::init() {
register_all_commands();
subscribe_to_variables_on_init();

car_simulation = std::make_unique<CarSimulation>(mod->r_ev_board_support, mod->r_ev, mod->r_slac);

std::thread(&car_simulatorImpl::run, this).detach();
}

void car_simulatorImpl::ready() {
subscribe_to_external_mqtt();

car_simulation = std::make_unique<CarSimulation>(mod->r_ev_board_support, mod->r_ev, mod->r_slac);

setup_ev_parameters();

if (mod->config.auto_enable) {
Expand Down
27 changes: 27 additions & 0 deletions modules/SlacSimulator/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
"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
36 changes: 36 additions & 0 deletions modules/SlacSimulator/SlacSimulator.cpp
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
67 changes: 67 additions & 0 deletions modules/SlacSimulator/SlacSimulator.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 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};

Check notice on line 40 in modules/SlacSimulator/SlacSimulator.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/SlacSimulator/SlacSimulator.hpp#L40

class member 'SlacSimulator::cntmatching' is never used.
// 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};

Check notice on line 57 in modules/SlacSimulator/SlacSimulator.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/SlacSimulator/SlacSimulator.hpp#L57

class member 'SlacSimulator::loop_interval_ms' is never used.
// 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
44 changes: 44 additions & 0 deletions modules/SlacSimulator/ev/ev_slacImpl.cpp
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
68 changes: 68 additions & 0 deletions modules/SlacSimulator/ev/ev_slacImpl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// 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 {
std::string ev_id;

Check notice on line 24 in modules/SlacSimulator/ev/ev_slacImpl.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/SlacSimulator/ev/ev_slacImpl.hpp#L24

struct member 'Conf::ev_id' is never used.
};

class ev_slacImpl : public ev_slacImplBase {
public:
ev_slacImpl() = delete;
ev_slacImpl(Everest::ModuleAdapter* ev, const Everest::PtrContainer<SlacSimulator>& mod, Conf& config) :

Check warning on line 30 in modules/SlacSimulator/ev/ev_slacImpl.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/SlacSimulator/ev/ev_slacImpl.hpp#L30

Member variable 'ev_slacImpl::state' is not initialized in the constructor.
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;

Check notice on line 57 in modules/SlacSimulator/ev/ev_slacImpl.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/SlacSimulator/ev/ev_slacImpl.hpp#L57

class member 'ev_slacImpl::state' is never used.
// 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
Loading
Loading