Skip to content

Commit

Permalink
Log telemetry (#186)
Browse files Browse the repository at this point in the history
Signed-off-by: Cornelius Claussen <cc@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: pietfried <piet.goempel@pionix.de>
Co-authored-by: Cornelius Claussen <cc@pionix.de>
  • Loading branch information
hikinggrass and corneliusclaussen authored Feb 23, 2023
1 parent 690012a commit 25f6d43
Show file tree
Hide file tree
Showing 32 changed files with 501 additions and 431 deletions.
2 changes: 1 addition & 1 deletion cmake/ev-project-bootstrap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/config-run-script.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/config-run-nodered-script.cmake)

# dependencies
require_ev_cli_version("0.0.17")
require_ev_cli_version("0.0.18")

# source generate scripts / setup
include(${CMAKE_CURRENT_LIST_DIR}/everest-generate.cmake)
2 changes: 1 addition & 1 deletion config/config-sil-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ active_modules:
evse_id_din: 49A80737A45678
session_logging: true
session_logging_xml: false
session_logging_path: /tmp
session_logging_path: /tmp/everest-logs
charge_mode: DC
connections:
bsp:
Expand Down
2 changes: 1 addition & 1 deletion config/config-sil-four-evse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ active_modules:
evse_id: DE*PNX*E12345*1
session_logging: true
session_logging_xml: false
session_logging_path: /tmp
session_logging_path: /tmp/everest-logs
ac_hlc_enabled: false
ac_hlc_use_5percent: false
ac_enforce_hlc: false
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 @@ -23,7 +23,7 @@ active_modules:
evse_id: "1"
session_logging: true
session_logging_xml: false
session_logging_path: /tmp
session_logging_path: /tmp/everest-logs
ac_hlc_enabled: false
ac_hlc_use_5percent: false
ac_enforce_hlc: false
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 @@ -23,7 +23,7 @@ active_modules:
evse_id_din: 49A80737A45678
session_logging: true
session_logging_xml: false
session_logging_path: /tmp
session_logging_path: /tmp/everest-logs
charge_mode: DC
connections:
bsp:
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 @@ -21,7 +21,7 @@ active_modules:
evse_id: DE*PNX*E12345*1
session_logging: true
session_logging_xml: false
session_logging_path: /tmp
session_logging_path: /tmp/everest-logs
ac_hlc_enabled: true
ac_hlc_use_5percent: false
ac_enforce_hlc: false
Expand Down
34 changes: 20 additions & 14 deletions config/config-sil.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
settings:
telemetry_enabled: true
active_modules:
api:
connections:
evse_manager:
- implementation_id: evse
module_id: evse_manager
module_id: connector_1
module: API
auth:
config_module:
Expand All @@ -13,7 +15,7 @@ active_modules:
connections:
evse_manager:
- implementation_id: evse
module_id: evse_manager
module_id: connector_1
token_provider:
- implementation_id: main
module_id: token_provider
Expand All @@ -33,7 +35,7 @@ active_modules:
module_id: iso15118_car
simulation_control:
- implementation_id: yeti_simulation_control
module_id: yeti_driver
module_id: connector_1_powerpath
slac:
- implementation_id: ev
module_id: slac
Expand All @@ -44,7 +46,7 @@ active_modules:
- implementation_id: energy_grid
module_id: grid_connection_point
module: EnergyManager
evse_manager:
connector_1:
config_module:
ac_enforce_hlc: false
ac_hlc_enabled: true
Expand All @@ -61,31 +63,33 @@ active_modules:
payment_enable_eim: true
rcd_enabled: true
session_logging: true
session_logging_path: /tmp
session_logging_path: /tmp/everest-logs
session_logging_xml: false
three_phases: true
connections:
bsp:
- implementation_id: board_support
module_id: yeti_driver
module_id: connector_1_powerpath
hlc:
- implementation_id: charger
module_id: iso15118_charger
powermeter_grid_side:
- implementation_id: powermeter
module_id: yeti_driver
module_id: connector_1_powerpath
slac:
- implementation_id: evse
module_id: slac
module: EvseManager
telemetry:
id: 1
grid_connection_point:
config_module:
fuse_limit_A: 40
phase_count: 3
connections:
energy_consumer:
- implementation_id: energy_grid
module_id: evse_manager
module_id: connector_1
module: EnergyNode
iso15118_car:
config_implementation:
Expand Down Expand Up @@ -135,7 +139,7 @@ active_modules:
connections:
evse:
- implementation_id: evse
module_id: evse_manager
module_id: connector_1
module: JsDummyTokenProvider
token_validator:
config_implementation:
Expand All @@ -145,9 +149,11 @@ active_modules:
validation_result: Accepted
connections: {}
module: JsDummyTokenValidator
yeti_driver:
connector_1_powerpath:
connections: {}
module: JsYetiSimulator
telemetry:
id: 1
x-module-layout:
api:
position:
Expand All @@ -160,7 +166,7 @@ x-module-layout:
- id: main
interface: empty
type: provide
- id: evse_manager
- id: connector_1
interface: evse_manager
type: requirement
top: []
Expand All @@ -170,7 +176,7 @@ x-module-layout:
y: -6
terminals:
bottom:
- id: evse_manager
- id: connector_1
interface: evse_manager
type: requirement
left: []
Expand Down Expand Up @@ -224,7 +230,7 @@ x-module-layout:
interface: energy
type: requirement
top: []
evse_manager:
connector_1:
position:
x: 17
y: 13
Expand Down Expand Up @@ -377,7 +383,7 @@ x-module-layout:
type: provide
right: []
top: []
yeti_driver:
connector_1_powerpath:
position:
x: 15
y: 26
Expand Down
4 changes: 2 additions & 2 deletions dependencies.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
everest-framework:
git: https://github.com/EVerest/everest-framework.git
git_tag: v0.3.0
git_tag: v0.4.0
sigslot:
git: https://github.com/palacaze/sigslot
git_tag: v1.2.0
Expand Down Expand Up @@ -38,7 +38,7 @@ RISE-V2G:
# OCPP
libocpp:
git: https://github.com/EVerest/libocpp.git
git_tag: v0.5.0
git_tag: 904343c96f945710586b45975beb5b6dfed811d6
# Josev
Josev:
git: https://github.com/EVerest/ext-switchev-iso15118.git
Expand Down
108 changes: 106 additions & 2 deletions modules/EvseManager/EvseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void EvseManager::ready() {
hlc_waiting_for_auth_pnc = false;
}
r_hlc[0]->call_set_Auth_Okay_PnC(types::authorization::AuthorizationStatus::Accepted,
types::authorization::CertificateStatus::Accepted);
types::authorization::CertificateStatus::Accepted);
} else {
std::scoped_lock lock(hlc_mutex);
hlc_waiting_for_auth_eim = false;
Expand Down Expand Up @@ -614,6 +614,110 @@ void EvseManager::ready() {
charger->setMaxCurrent(0.0F, date::utc_clock::now());
charger->run();
charger->enable();

telemetryThreadHandle = std::thread([this]() {
while (!telemetryThreadHandle.shouldExit()) {
sleep(10);
auto p = get_latest_powermeter_data_billing();
Everest::TelemetryMap telemetry_data{{"timestamp", p.timestamp},
{"type", "power_meter"},
{"meter_id", p.meter_id.get_value_or("N/A")},
{"energy_import_total_Wh", p.energy_Wh_import.total}};

if (p.energy_Wh_import.L1.is_initialized()) {
telemetry_data["energy_import_L1_Wh"] = p.energy_Wh_import.L1.get();
}
if (p.energy_Wh_import.L2.is_initialized()) {
telemetry_data["energy_import_L2_Wh"] = p.energy_Wh_import.L2.get();
}
if (p.energy_Wh_import.L3.is_initialized()) {
telemetry_data["energy_import_L3_Wh"] = p.energy_Wh_import.L3.get();
}

if (p.energy_Wh_export.is_initialized()) {
telemetry_data["energy_export_total_Wh"] = p.energy_Wh_export.get().total;
}
if (p.energy_Wh_export.is_initialized() && p.energy_Wh_export.get().L1.is_initialized()) {
telemetry_data["energy_export_L1_Wh"] = p.energy_Wh_export.get().L1.get();
}
if (p.energy_Wh_export.is_initialized() && p.energy_Wh_export.get().L2.is_initialized()) {
telemetry_data["energy_export_L2_Wh"] = p.energy_Wh_export.get().L2.get();
}
if (p.energy_Wh_export.is_initialized() && p.energy_Wh_export.get().L3.is_initialized()) {
telemetry_data["energy_export_L3_Wh"] = p.energy_Wh_export.get().L3.get();
}

if (p.power_W.is_initialized()) {
telemetry_data["power_total_W"] = p.power_W.get().total;
}
if (p.power_W.is_initialized() && p.power_W.get().L1.is_initialized()) {
telemetry_data["power_L1_W"] = p.power_W.get().L1.get();
}
if (p.power_W.is_initialized() && p.power_W.get().L2.is_initialized()) {
telemetry_data["power_L3_W"] = p.power_W.get().L2.get();
}
if (p.power_W.is_initialized() && p.power_W.get().L3.is_initialized()) {
telemetry_data["power_L3_W"] = p.power_W.get().L3.get();
}

if (p.VAR.is_initialized()) {
telemetry_data["var_total"] = p.VAR.get().total;
}
if (p.VAR.is_initialized() && p.VAR.get().L1.is_initialized()) {
telemetry_data["var_L1"] = p.VAR.get().L1.get();
}
if (p.VAR.is_initialized() && p.VAR.get().L2.is_initialized()) {
telemetry_data["var_L1"] = p.VAR.get().L2.get();
}
if (p.VAR.is_initialized() && p.VAR.get().L3.is_initialized()) {
telemetry_data["var_L1"] = p.VAR.get().L3.get();
}

if (p.voltage_V.is_initialized() && p.voltage_V.get().L1.is_initialized()) {
telemetry_data["voltage_L1_V"] = p.voltage_V.get().L1.get();
}
if (p.voltage_V.is_initialized() && p.voltage_V.get().L2.is_initialized()) {
telemetry_data["voltage_L2_V"] = p.voltage_V.get().L2.get();
}
if (p.voltage_V.is_initialized() && p.voltage_V.get().L3.is_initialized()) {
telemetry_data["voltage_L3_V"] = p.voltage_V.get().L3.get();
}
if (p.voltage_V.is_initialized() && p.voltage_V.get().DC.is_initialized()) {
telemetry_data["voltage_DC_V"] = p.voltage_V.get().DC.get();
}

if (p.current_A.is_initialized() && p.current_A.get().L1.is_initialized()) {
telemetry_data["current_L1_A"] = p.current_A.get().L1.get();
}
if (p.current_A.is_initialized() && p.current_A.get().L2.is_initialized()) {
telemetry_data["current_L2_A"] = p.current_A.get().L2.get();
}
if (p.current_A.is_initialized() && p.current_A.get().L3.is_initialized()) {
telemetry_data["current_L3_A"] = p.current_A.get().L3.get();
}
if (p.current_A.is_initialized() && p.current_A.get().DC.is_initialized()) {
telemetry_data["current_DC_A"] = p.current_A.get().DC.get();
}

if (p.frequency_Hz.is_initialized()) {
telemetry_data["frequency_L1_Hz"] = p.frequency_Hz.get().L1;
}
if (p.frequency_Hz.is_initialized() && p.frequency_Hz.get().L2.is_initialized()) {
telemetry_data["frequency_L2_Hz"] = p.frequency_Hz.get().L2.get();
}
if (p.frequency_Hz.is_initialized() && p.frequency_Hz.get().L3.is_initialized()) {
telemetry_data["frequency_L3_Hz"] = p.frequency_Hz.get().L3.get();
}

if (p.phase_seq_error.is_initialized()) {
telemetry_data["phase_seq_error"] = p.phase_seq_error.get();
}

// Publish as external telemetry data
telemetry.publish("livedata", "power_meter", telemetry_data);
}
});

EVLOG_info << fmt::format(fmt::emphasis::bold | fg(fmt::terminal_color::green), "🌀🌀🌀 Ready to start charging 🌀🌀🌀");
}

Expand Down Expand Up @@ -791,7 +895,7 @@ void EvseManager::charger_was_authorized() {
std::scoped_lock lock(hlc_mutex);
if (hlc_waiting_for_auth_pnc && charger->Authorized_PnC()) {
r_hlc[0]->call_set_Auth_Okay_PnC(types::authorization::AuthorizationStatus::Accepted,
types::authorization::CertificateStatus::Accepted);
types::authorization::CertificateStatus::Accepted);
hlc_waiting_for_auth_eim = false;
hlc_waiting_for_auth_pnc = false;
}
Expand Down
7 changes: 5 additions & 2 deletions modules/EvseManager/EvseManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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

#include "ld-ev.hpp"
Expand Down Expand Up @@ -75,7 +75,7 @@ struct Conf {
class EvseManager : public Everest::ModuleBase {
public:
EvseManager() = delete;
EvseManager(const ModuleInfo& info, Everest::MqttProvider& mqtt_provider,
EvseManager(const ModuleInfo& info, Everest::MqttProvider& mqtt_provider, Everest::TelemetryProvider& telemetry,
std::unique_ptr<evse_managerImplBase> p_evse, std::unique_ptr<energyImplBase> p_energy_grid,
std::unique_ptr<auth_token_providerImplBase> p_token_provider,
std::unique_ptr<board_support_ACIntf> r_bsp,
Expand All @@ -86,6 +86,7 @@ class EvseManager : public Everest::ModuleBase {
std::vector<std::unique_ptr<power_supply_DCIntf>> r_powersupply_DC, Conf& config) :
ModuleBase(info),
mqtt(mqtt_provider),
telemetry(telemetry),
p_evse(std::move(p_evse)),
p_energy_grid(std::move(p_energy_grid)),
p_token_provider(std::move(p_token_provider)),
Expand All @@ -100,6 +101,7 @@ class EvseManager : public Everest::ModuleBase {

const Conf& config;
Everest::MqttProvider& mqtt;
Everest::TelemetryProvider& telemetry;
const std::unique_ptr<evse_managerImplBase> p_evse;
const std::unique_ptr<energyImplBase> p_energy_grid;
const std::unique_ptr<auth_token_providerImplBase> p_token_provider;
Expand Down Expand Up @@ -201,6 +203,7 @@ class EvseManager : public Everest::ModuleBase {

void imd_stop();
void imd_start();
Everest::Thread telemetryThreadHandle;
// ev@211cfdbe-f69a-4cd6-a4ec-f8aaa3d1b6c8:v1
};

Expand Down
Loading

0 comments on commit 25f6d43

Please sign in to comment.