Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ add_compile_options(-Wall -Wextra -Werror=switch)
add_compile_options(-Wno-unused-function)

ev_add_cpp_module(CbChargeSOMDriver)
ev_add_cpp_module(CbCPXDriver)
ev_add_cpp_module(CbTarragonDIs)
ev_add_cpp_module(CbTarragonDriver)
ev_add_cpp_module(CbTarragonPlugLock)
Expand Down
53 changes: 53 additions & 0 deletions modules/CbCPXDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# 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

find_package(PalSigslot REQUIRED)

add_subdirectory("cpx")

set(MODULE_DESCRIPTION "chargebyte's CPX EVerest module")
set(MODULE_VERSION ${PROJECT_VERSION})

# make CMake project variables usable in source code
configure_file(configuration.h.in configuration.h @ONLY)

# create a VERSION file
configure_file(VERSION.in VERSION @ONLY)

target_link_libraries(${MODULE_NAME}
PRIVATE
Pal::Sigslot
nlohmann_json::nlohmann_json
cpx
utils::cp
)
target_include_directories(${MODULE_NAME}
PRIVATE
${CPX_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/cpx
)
# ev@bcc62523-e22b-41d7-ba2f-825b493a3c97:v1

target_sources(${MODULE_NAME}
PRIVATE
"evse_board_support/evse_board_supportImpl.cpp"
"temperatures/cb_temperaturesImpl.cpp"
)

# ev@c55432ab-152c-45a9-9d2e-7281d50c69c3:v1
# insert other things like install cmds etc here

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/VERSION"
DESTINATION "${EVEREST_MODULE_INSTALL_PREFIX}/${MODULE_NAME}"
)
# ev@c55432ab-152c-45a9-9d2e-7281d50c69c3:v1
32 changes: 32 additions & 0 deletions modules/CbCPXDriver/CbCPXDriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest
#include "CbCPXDriver.hpp"
#include "configuration.h"

using namespace std::chrono_literals;

namespace module {

void CbCPXDriver::init() {
types::evse_board_support::Connector_type connector_type =
types::evse_board_support::string_to_connector_type(this->config.connector_type);
const bool is_pluggable = connector_type == types::evse_board_support::Connector_type::IEC62196Type2Socket;

// instantiate CPX controller
this->controller =
std::make_unique<CbCPX>(this->config.device_id, this->config.can_interface, this->config.can_bitrate);
this->controller->init(is_pluggable);

// initialize the interfaces now
invoke_init(*this->p_evse_board_support);
invoke_init(*this->p_temperatures);

EVLOG_info << MODULE_DESCRIPTION << " (version: " << MODULE_VERSION << ")";
}

void CbCPXDriver::ready() {
invoke_ready(*this->p_evse_board_support);
invoke_ready(*this->p_temperatures);
}

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

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

#include "ld-ev.hpp"

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

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

#include "cpx/CbCPX.hpp"
// ev@4bf81b14-a215-475c-a1d3-0a484ae48918:v1

namespace module {

struct Conf {
std::string connector_type;
double min_current_A;
double max_current_A;
std::string can_interface;
int can_bitrate;
std::string pt1000_1_identification;
std::string pt1000_2_identification;
std::string pt1000_3_identification;
std::string pt1000_4_identification;
int device_id;
};

class CbCPXDriver : public Everest::ModuleBase {
public:
CbCPXDriver() = delete;
CbCPXDriver(const ModuleInfo& info, std::unique_ptr<evse_board_supportImplBase> p_evse_board_support,
std::unique_ptr<cb_temperaturesImplBase> p_temperatures, Conf& config) :
ModuleBase(info),
p_evse_board_support(std::move(p_evse_board_support)),
p_temperatures(std::move(p_temperatures)),
config(config) {};

const std::unique_ptr<evse_board_supportImplBase> p_evse_board_support;
const std::unique_ptr<cb_temperaturesImplBase> p_temperatures;
const Conf& config;

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

/// @brief Helper to signal thread termination wish
std::atomic_bool termination_requested {false};

/// @brief CPX CAN Interface
std::unique_ptr<CbCPX> controller;
// 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 // CB_CPXDRIVER_HPP
2 changes: 2 additions & 0 deletions modules/CbCPXDriver/VERSION.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@MODULE_DESCRIPTION@
Version: @MODULE_VERSION@
5 changes: 5 additions & 0 deletions modules/CbCPXDriver/configuration.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#define MODULE_NAME "@MODULE_NAME@"
#define MODULE_DESCRIPTION "@MODULE_DESCRIPTION@"
#define MODULE_VERSION "@MODULE_VERSION@"
34 changes: 34 additions & 0 deletions modules/CbCPXDriver/cpx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
set(CPX_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE)

add_library(cpx STATIC)

find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBSOCKETCAN REQUIRED libsocketcan)

target_sources(cpx
PRIVATE
"CbCPX.cpp"
"can_interface/can.c"
)

get_target_property(GENERATED_INCLUDE_DIR generate_cpp_files EVEREST_GENERATED_INCLUDE_DIR)

target_include_directories(cpx
PRIVATE
${GENERATED_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/../everest-framework/include
${CMAKE_SOURCE_DIR}/build/_deps/nlohmann_json_schema_validator-src/src
${LIBSOCKETCAN_INCLUDE_DIRS}
)

target_include_directories(cpx PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

add_dependencies(cpx generate_cpp_files)

target_link_libraries(cpx
PRIVATE
Pal::Sigslot
nlohmann_json::nlohmann_json
everest::log
${LIBSOCKETCAN_LIBRARIES}
)
Comment on lines 28 to 34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see you using Boost headers anywhere in this lib or this module? Neither sqlite. Same assumption as above regarding CbCpx. Drop these. See there (CbCpx).

Suggested change
target_link_libraries(cpx
PRIVATE
Pal::Sigslot
nlohmann_json::nlohmann_json
everest::log
everest::sqlite
Boost::log
Boost::log_setup
Boost::system
Boost::thread
Boost::filesystem
Boost::date_time
Boost::regex
)
target_link_libraries(cpx
PRIVATE
Pal::Sigslot
nlohmann_json::nlohmann_json
everest::log
)

Loading