Skip to content

Commit cf6ead4

Browse files
committed
[central system] Add skeleton of central system implementation and examples
1 parent 6b6dc93 commit cf6ead4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1133
-204
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
build
12
build_*
23
bin/*
34
.vscode/settings.json

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Extract of a quick start main() :
230230
int main()
231231
{
232232
// Configuration
233-
ChargePointConfig config("config.ini");
233+
ChargePointDemoConfig config("config.ini");
234234
235235
// Event handler
236236
DefaultChargePointEventsHandler event_handler(config);

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
# Subdirectories
33
add_subdirectory(common)
4+
add_subdirectory(quick_start_centralsystem)
45
add_subdirectory(quick_start_chargepoint)
56
add_subdirectory(remote_chargepoint)

examples/common/DefaultChargePointEventsHandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SOFTWARE.
2323
*/
2424

2525
#include "DefaultChargePointEventsHandler.h"
26-
#include "ChargePointConfig.h"
26+
#include "ChargePointDemoConfig.h"
2727
#include "String.h"
2828

2929
#include <iostream>
@@ -32,7 +32,7 @@ using namespace std;
3232
using namespace ocpp::types;
3333

3434
/** @brief Constructor */
35-
DefaultChargePointEventsHandler::DefaultChargePointEventsHandler(ChargePointConfig& config)
35+
DefaultChargePointEventsHandler::DefaultChargePointEventsHandler(ChargePointDemoConfig& config)
3636
: m_config(config),
3737
m_remote_start_pending(config.ocppConfig().numberOfConnectors()),
3838
m_remote_stop_pending(m_remote_start_pending.size()),

examples/common/DefaultChargePointEventsHandler.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ SOFTWARE.
2929

3030
#include <vector>
3131

32-
class ChargePointConfig;
32+
class ChargePointDemoConfig;
3333

3434
/** @brief Default charge point event handlers implementation for the examples */
3535
class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEventsHandler
3636
{
3737
public:
3838
/** @brief Constructor */
39-
DefaultChargePointEventsHandler(ChargePointConfig& config);
39+
DefaultChargePointEventsHandler(ChargePointDemoConfig& config);
4040

4141
/** @brief Destructor */
4242
virtual ~DefaultChargePointEventsHandler();
@@ -133,11 +133,11 @@ class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEv
133133

134134
protected:
135135
/** @brief Get the configuration */
136-
ChargePointConfig& config() { return m_config; }
136+
ChargePointDemoConfig& config() { return m_config; }
137137

138138
private:
139139
/** @brief Configuration */
140-
ChargePointConfig& m_config;
140+
ChargePointDemoConfig& m_config;
141141
/** @brief Indicate a pending remote start transaction */
142142
std::vector<bool> m_remote_start_pending;
143143
/** @brief Indicate a pending remote stop transaction */
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2020 Cedric Jimenez
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
#ifndef CENTRALSYSTEMCONFIG_H
26+
#define CENTRALSYSTEMCONFIG_H
27+
28+
#include "ICentralSystemConfig.h"
29+
#include "IniFile.h"
30+
31+
/** @brief Section name for the parameters */
32+
static const std::string STACK_PARAMS = "CentralSystem";
33+
34+
/** @brief Charge Point stack internal configuration */
35+
class CentralSystemConfig : public ocpp::config::ICentralSystemConfig
36+
{
37+
public:
38+
/** @brief Constructor */
39+
CentralSystemConfig(ocpp::helpers::IniFile& config) : m_config(config) { }
40+
41+
// Paths
42+
43+
/** @brief Path to the database to store persistent data */
44+
std::string databasePath() const override { return getString("DatabasePath"); }
45+
/** @brief Path to the JSON schemas to validate the messages */
46+
std::string jsonSchemasPath() const override { return getString("JsonSchemasPath"); }
47+
48+
// Communication parameters
49+
50+
/** @brief Listen URL */
51+
std::string listenUrl() const override { return getString("ListenUrl"); };
52+
/** @brief Call request timeout */
53+
std::chrono::milliseconds callRequestTimeout() const override { return get<std::chrono::milliseconds>("CallRequestTimeout"); }
54+
/** @brief Cipher list to use for TLSv1.2 connections */
55+
std::string tlsv12CipherList() const override { return getString("Tlsv12CipherList"); }
56+
/** @brief Cipher list to use for TLSv1.3 connections */
57+
std::string tlsv13CipherList() const override { return getString("Tlsv13CipherList"); }
58+
/** @brief ECDH curve to use for TLS connections */
59+
std::string tlsvEcdhCurve() const override { return getString("TlsEcdhCurve"); }
60+
61+
// Logs
62+
63+
/** @brief Maximum number of entries in the log (0 = no logs in database) */
64+
unsigned int logMaxEntriesCount() const override { return get<unsigned int>("LogMaxEntriesCount"); }
65+
66+
private:
67+
/** @brief Configuration file */
68+
ocpp::helpers::IniFile& m_config;
69+
70+
/** @brief Get a boolean parameter */
71+
bool getBool(const std::string& param) const { return m_config.get(STACK_PARAMS, param).toBool(); }
72+
/** @brief Get a floating point parameter */
73+
double getFloat(const std::string& param) const { return m_config.get(STACK_PARAMS, param).toFloat(); }
74+
/** @brief Get a string parameter */
75+
std::string getString(const std::string& param) const { return m_config.get(STACK_PARAMS, param); }
76+
/** @brief Get a value which can be created from an unsigned integer */
77+
template <typename T>
78+
T get(const std::string& param) const
79+
{
80+
return T(m_config.get(STACK_PARAMS, param).toUInt());
81+
}
82+
};
83+
84+
#endif // CENTRALSYSTEMCONFIG_H
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2020 Cedric Jimenez
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
#ifndef CENTRALSYSTEMDEMOCONFIG_H
26+
#define CENTRALSYSTEMDEMOCONFIG_H
27+
28+
#include "CentralSystemConfig.h"
29+
#include "IniFile.h"
30+
31+
/** @brief Configuration of the Central System demo */
32+
class CentralSystemDemoConfig
33+
{
34+
public:
35+
/** @brief Constructor */
36+
CentralSystemDemoConfig(const std::string& config_file) : m_config(config_file), m_stack_config(m_config) { }
37+
38+
/** @brief Stack internal configuration */
39+
ocpp::config::ICentralSystemConfig& stackConfig() { return m_stack_config; }
40+
41+
private:
42+
/** @brief Configuration file */
43+
ocpp::helpers::IniFile m_config;
44+
45+
/** @brief Stack internal configuration */
46+
CentralSystemConfig m_stack_config;
47+
};
48+
49+
#endif // CENTRALSYSTEMDEMOCONFIG_H

examples/common/config/ChargePointConfig.h

Lines changed: 92 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,109 @@ SOFTWARE.
2525
#ifndef CHARGEPOINTCONFIG_H
2626
#define CHARGEPOINTCONFIG_H
2727

28+
#include "IChargePointConfig.h"
2829
#include "IniFile.h"
29-
#include "OcppConfig.h"
30-
#include "StackConfig.h"
3130

32-
/** @brief Configuration of the Charge Point demo */
33-
class ChargePointConfig
31+
/** @brief Section name for the parameters */
32+
static const std::string STACK_PARAMS = "ChargePoint";
33+
34+
/** @brief Charge Point stack internal configuration */
35+
class ChargePointConfig : public ocpp::config::IChargePointConfig
3436
{
3537
public:
3638
/** @brief Constructor */
37-
ChargePointConfig(const std::string& config_file) : m_config(config_file), m_stack_config(m_config), m_ocpp_config(m_config) { }
39+
ChargePointConfig(ocpp::helpers::IniFile& config) : m_config(config) { }
40+
41+
// Paths
42+
43+
/** @brief Path to the database to store persistent data */
44+
std::string databasePath() const override { return getString("DatabasePath"); }
45+
/** @brief Path to the JSON schemas to validate the messages */
46+
std::string jsonSchemasPath() const override { return getString("JsonSchemasPath"); }
47+
48+
// Communication parameters
49+
50+
/** @brief Connection URL */
51+
std::string connexionUrl() const override { return getString("ConnexionUrl"); };
52+
/** @brief Charge point identifier */
53+
std::string chargePointIdentifier() const override { return getString("ChargePointIdentifier"); }
54+
/** @brief Connection timeout */
55+
std::chrono::milliseconds connectionTimeout() const override { return get<std::chrono::milliseconds>("ConnectionTimeout"); }
56+
/** @brief Retry interval */
57+
std::chrono::milliseconds retryInterval() const override { return get<std::chrono::milliseconds>("RetryInterval"); }
58+
/** @brief Call request timeout */
59+
std::chrono::milliseconds callRequestTimeout() const override { return get<std::chrono::milliseconds>("CallRequestTimeout"); }
60+
/** @brief Cipher list to use for TLSv1.2 connections */
61+
std::string tlsv12CipherList() const override { return getString("Tlsv12CipherList"); }
62+
/** @brief Cipher list to use for TLSv1.3 connections */
63+
std::string tlsv13CipherList() const override { return getString("Tlsv13CipherList"); }
64+
/** @brief ECDH curve to use for TLS connections */
65+
std::string tlsvEcdhCurve() const override { return getString("TlsEcdhCurve"); }
66+
/** @brief Allow TLS connections using self-signed certificates
67+
* (Warning : enabling this feature is not recommended in production) */
68+
bool tlsAllowSelfSignedCertificates() const override { return getBool("TlsAllowSelfSignedCertificates"); }
69+
/** @brief Allow TLS connections using expired certificates
70+
* (Warning : enabling this feature is not recommended in production) */
71+
bool tlsAllowExpiredCertificates() const override { return getBool("TlsAllowExpiredCertificates"); }
72+
/** @brief Accept non trusted certificates for TLS connections
73+
* (Warning : enabling this feature is not recommended in production) */
74+
bool tlsAcceptNonTrustedCertificates() const override { return getBool("TlsAcceptNonTrustedCertificates"); }
75+
/** @brief Skip server name check in certificates for TLS connections
76+
* (Warning : enabling this feature is not recommended in production) */
77+
bool tlsSkipServerNameCheck() const override { return getBool("TlsSkipServerNameCheck"); }
78+
79+
// Charge point identification
80+
81+
/** @brief Charge box serial number */
82+
std::string chargeBoxSerialNumber() const override { return getString("ChargeBoxSerialNumber"); }
83+
/** @brief Charge point model */
84+
std::string chargePointModel() const override { return getString("ChargePointModel"); }
85+
/** @brief Charge point serial number */
86+
std::string chargePointSerialNumber() const override { return getString("ChargePointSerialNumber"); }
87+
/** @brief Charge point vendor */
88+
std::string chargePointVendor() const override { return getString("ChargePointVendor"); }
89+
/** @brief Firmware version */
90+
std::string firmwareVersion() const override { return getString("FirmwareVersion"); }
91+
/** @brief ICCID of the moden's SIM card */
92+
std::string iccid() const override { return getString("Iccid"); }
93+
/** @brief IMSI of the moden's SIM card */
94+
std::string imsi() const override { return getString("Imsi"); }
95+
/** @brief Main electrical meter serial number */
96+
std::string meterSerialNumber() const override { return getString("MeterSerialNumber"); }
97+
/** @brief Main electrical meter type */
98+
std::string meterType() const override { return getString("MeterType"); }
99+
100+
// Charging
101+
102+
/** @brief Nominal operating voltage (needed for Watt to Amp conversions in smart charging profiles) */
103+
float operatingVoltage() const override { return static_cast<float>(getFloat("OperatingVoltage")); }
104+
105+
// Authent
106+
107+
/** @brief Maximum number of entries in the authentication cache */
108+
unsigned int authentCacheMaxEntriesCount() const override { return get<unsigned int>("AuthentCacheMaxEntriesCount"); }
38109

39-
/** @brief Stack internal configuration */
40-
ocpp::config::IChargePointConfig& stackConfig() { return m_stack_config; }
110+
// Logs
41111

42-
/** @brief Standard OCPP configuration */
43-
ocpp::config::IOcppConfig& ocppConfig() { return m_ocpp_config; }
112+
/** @brief Maximum number of entries in the log (0 = no logs in database) */
113+
unsigned int logMaxEntriesCount() const override { return get<unsigned int>("LogMaxEntriesCount"); }
44114

45115
private:
46116
/** @brief Configuration file */
47-
ocpp::helpers::IniFile m_config;
117+
ocpp::helpers::IniFile& m_config;
48118

49-
/** @brief Stack internal configuration */
50-
StackConfig m_stack_config;
51-
/** @brief Standard OCPP configuration */
52-
OcppConfig m_ocpp_config;
119+
/** @brief Get a boolean parameter */
120+
bool getBool(const std::string& param) const { return m_config.get(STACK_PARAMS, param).toBool(); }
121+
/** @brief Get a floating point parameter */
122+
double getFloat(const std::string& param) const { return m_config.get(STACK_PARAMS, param).toFloat(); }
123+
/** @brief Get a string parameter */
124+
std::string getString(const std::string& param) const { return m_config.get(STACK_PARAMS, param); }
125+
/** @brief Get a value which can be created from an unsigned integer */
126+
template <typename T>
127+
T get(const std::string& param) const
128+
{
129+
return T(m_config.get(STACK_PARAMS, param).toUInt());
130+
}
53131
};
54132

55133
#endif // CHARGEPOINTCONFIG_H
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2020 Cedric Jimenez
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
#ifndef CHARGEPOINTDEMOCONFIG_H
26+
#define CHARGEPOINTDEMOCONFIG_H
27+
28+
#include "ChargePointConfig.h"
29+
#include "IniFile.h"
30+
#include "OcppConfig.h"
31+
32+
/** @brief Configuration of the Charge Point demo */
33+
class ChargePointDemoConfig
34+
{
35+
public:
36+
/** @brief Constructor */
37+
ChargePointDemoConfig(const std::string& config_file) : m_config(config_file), m_stack_config(m_config), m_ocpp_config(m_config) { }
38+
39+
/** @brief Stack internal configuration */
40+
ocpp::config::IChargePointConfig& stackConfig() { return m_stack_config; }
41+
42+
/** @brief Standard OCPP configuration */
43+
ocpp::config::IOcppConfig& ocppConfig() { return m_ocpp_config; }
44+
45+
private:
46+
/** @brief Configuration file */
47+
ocpp::helpers::IniFile m_config;
48+
49+
/** @brief Stack internal configuration */
50+
ChargePointConfig m_stack_config;
51+
/** @brief Standard OCPP configuration */
52+
OcppConfig m_ocpp_config;
53+
};
54+
55+
#endif // CHARGEPOINTDEMOCONFIG_H

examples/common/config/OcppConfig.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SOFTWARE.
2323
*/
2424

2525
#include "OcppConfig.h"
26-
#include "StackConfig.h"
26+
#include "ChargePointConfig.h"
2727

2828
#include <map>
2929
#include <string>

0 commit comments

Comments
 (0)