Skip to content

Commit bc445e6

Browse files
authored
Merge pull request #130 from c-jimenez/dev/rpc_pool
[rpc] RPC pool implementation + memory leaks fixes
2 parents d010af5 + a0e5313 commit bc445e6

37 files changed

+622
-227
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
cmake_minimum_required(VERSION 3.13)
66

7-
project(OpenOCPP DESCRIPTION "Open Source C++ implementation of the OCPP 2.6 protocol"
7+
project(OpenOCPP DESCRIPTION "Open Source C++ implementation of the OCPP 1.6 protocol"
88
VERSION 1.2.0
99
)
1010

@@ -101,7 +101,11 @@ target_link_libraries(open-ocpp-dynamic
101101
ws
102102
websockets
103103
)
104-
set_target_properties(open-ocpp-dynamic PROPERTIES OUTPUT_NAME "open-ocpp")
104+
set_target_properties(open-ocpp-dynamic PROPERTIES
105+
OUTPUT_NAME "open-ocpp"
106+
VERSION ${PROJECT_VERSION}
107+
SOVERSION ${PROJECT_VERSION_MAJOR}
108+
)
105109

106110
# Install commands
107111
include(GNUInstallDirs)

examples/common/config/CentralSystemConfig.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ class CentralSystemConfig : public ocpp::config::ICentralSystemConfig
8484
/** @brief Maximum number of entries in the log (0 = no logs in database) */
8585
unsigned int logMaxEntriesCount() const override { return get<unsigned int>("LogMaxEntriesCount"); }
8686

87+
// Behavior
88+
89+
/** @brief Size of the thread pool to handle incoming requests from the Charge Points */
90+
unsigned int incomingRequestsFromCpThreadPoolSize() const override
91+
{
92+
return get<unsigned int>("IncomingRequestsFromCpThreadPoolSize");
93+
};
94+
8795
// ISO 15118 PnC extensions
8896

8997
/** @brief If this variable set to true, then the Central System supports ISO 15118 plug and charge messages via the DataTransfer mechanism as

examples/common/config/LocalControllerConfig.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ class LocalControllerConfig : public ocpp::config::ILocalControllerConfig
8787

8888
// Behavior
8989

90+
/** @brief Size of the thread pool to handle incoming requests from the Charge Points */
91+
unsigned int incomingRequestsFromCpThreadPoolSize() const override
92+
{
93+
return get<unsigned int>("IncomingRequestsFromCpThreadPoolSize");
94+
};
95+
/** @brief Size of the thread pool to handle incoming requests from the Central System */
96+
unsigned int incomingRequestsFromCsThreadPoolSize() const override
97+
{
98+
return get<unsigned int>("IncomingRequestsFromCsThreadPoolSize");
99+
};
90100
/** @brief Disconnect from Charge Point on Central System disconnection */
91101
bool disconnectFromCpWhenCsDisconnected() const override { return getBool("DisconnectFromCpWhenCsDisconnected"); }
92102

examples/iso15118_centralsystem/config/iso15118_centralsystem.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ TlsServerCertificatePrivateKeyPassphrase=
1616
TlsServerCertificateCa=../../examples/certificates/open-ocpp_ca.crt
1717
TlsClientCertificateAuthent=true
1818
LogMaxEntriesCount=2000
19+
IncomingRequestsFromCpThreadPoolSize=10
1920
Iso15118PnCEnabled=true

examples/quick_start_centralsystem/config/quick_start_centralsystem.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ TlsServerCertificatePrivateKeyPassphrase=
1616
TlsServerCertificateCa=../../examples/certificates/open-ocpp_ca.crt
1717
TlsClientCertificateAuthent=true
1818
LogMaxEntriesCount=2000
19+
IncomingRequestsFromCpThreadPoolSize=10
1920
Iso15118PnCEnabled=false

examples/quick_start_cs_lc_hybrid/HybridCentralSystemEventsHandler.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@ HybridCentralSystemEventsHandler::HybridCentralSystemEventsHandler(LocalControll
3737
bool set_pending_status)
3838
: DefaultCentralSystemEventsHandler(iso_v2g_root_ca, iso_mo_root_ca, set_pending_status), m_config(config)
3939
{
40+
// Start RPC pool
41+
m_rpc_pool.start(config.incomingRequestsFromCsThreadPoolSize());
4042
}
4143

4244
/** @brief Destructor */
43-
HybridCentralSystemEventsHandler::~HybridCentralSystemEventsHandler() { }
45+
HybridCentralSystemEventsHandler::~HybridCentralSystemEventsHandler()
46+
{
47+
// Stop RPC pool
48+
m_rpc_pool.stop();
49+
}
4450

4551
// ICentralSystemEventsHandler interface
4652

@@ -58,7 +64,7 @@ void HybridCentralSystemEventsHandler::chargePointConnected(std::shared_ptr<ocpp
5864
if (ocpp::helpers::endsWith(chargepoint->identifier(), "lc"))
5965
{
6066
// Create Local Controller proxy
61-
auto proxy = ocpp::localcontroller::IChargePointProxy::createFrom(chargepoint, m_config);
67+
auto proxy = ocpp::localcontroller::IChargePointProxy::createFrom(chargepoint, m_config, m_rpc_pool);
6268

6369
// Open connection to the Central System
6470
ocpp::websockets::IWebsocketClient::Credentials credentials;

examples/quick_start_cs_lc_hybrid/HybridCentralSystemEventsHandler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ SOFTWARE.
2828
#include "DefaultCentralSystemEventsHandler.h"
2929
#include "IChargePointProxy.h"
3030
#include "LocalControllerConfig.h"
31+
#include "RpcPool.h"
3132

3233
/** @brief Hybrid central system event handlers implementation for the examples */
3334
class HybridCentralSystemEventsHandler : public DefaultCentralSystemEventsHandler
@@ -92,6 +93,8 @@ class HybridCentralSystemEventsHandler : public DefaultCentralSystemEventsHandle
9293
private:
9394
/** @brief Configuration */
9495
LocalControllerConfig& m_config;
96+
/** @brief RPC pool*/
97+
ocpp::rpc::RpcPool m_rpc_pool;
9598
/** @brief Forwared charge points */
9699
std::map<std::string, std::shared_ptr<LocalControllerProxyEventsHandler>> m_fowarded_chargepoints;
97100
};

examples/quick_start_cs_lc_hybrid/config/quick_start_cs_lc_hybrid.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ TlsClientCertificate=../../examples/certificates/open-ocpp_charge-point.crt
2020
TlsClientCertificatePrivateKey=../../examples/certificates/open-ocpp_charge-point.key
2121
TlsClientCertificatePrivateKeyPassphrase=
2222
LogMaxEntriesCount=2000
23+
IncomingRequestsFromCpThreadPoolSize=10
24+
IncomingRequestsFromCsThreadPoolSize=10
2325
DisconnectFromCpWhenCsDisconnected=true
2426
Iso15118PnCEnabled=false

examples/quick_start_localcontroller/config/quick_start_localcontroller.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ TlsClientCertificate=../../examples/certificates/open-ocpp_charge-point.crt
1818
TlsClientCertificatePrivateKey=../../examples/certificates/open-ocpp_charge-point.key
1919
TlsClientCertificatePrivateKeyPassphrase=
2020
LogMaxEntriesCount=2000
21+
IncomingRequestsFromCpThreadPoolSize=10
22+
IncomingRequestsFromCsThreadPoolSize=10
2123
DisconnectFromCpWhenCsDisconnected=true

examples/security_centralsystem/config/security_centralsystem_p0.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ TlsServerCertificatePrivateKeyPassphrase=
1616
TlsServerCertificateCa=
1717
TlsClientCertificateAuthent=false
1818
LogMaxEntriesCount=2000
19+
IncomingRequestsFromCpThreadPoolSize=5
1920
Iso15118PnCEnabled=false

0 commit comments

Comments
 (0)