Skip to content

Commit e317169

Browse files
authored
Merge pull request #14 from c-jimenez/develop
Version 1.1.0
2 parents a789d11 + 1b0f8b7 commit e317169

File tree

16 files changed

+202
-17
lines changed

16 files changed

+202
-17
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ cp_simu
186186
| |-status
187187
|--cps
188188
| |-simu_cp_XXX
189+
| | |-cmd
189190
| | |-status
190191
| | |-connectors
191192
| | | |-1
@@ -197,6 +198,7 @@ cp_simu
197198
| | | | |-id_tag
198199
| | | | |-status
199200
| |-simu_cp_YYY
201+
| | |-cmd
200202
| | |-status
201203
| | |-connectors
202204
| | | |-1
@@ -348,4 +350,17 @@ The expected command payload is :
348350
{
349351
"faulted": false
350352
}
351-
```
353+
```
354+
355+
356+
Each simulated Charge Point are listening to the following topic to execute a certain command: **cp_simu/cps/simu_cp_XXX/cmd**.
357+
358+
The expected command payload is :
359+
```
360+
{
361+
"type": "<cmd>"
362+
}
363+
```
364+
So far there are 2 commands:
365+
* close: ask to end the application
366+
* ocpp_config: ask to send on MQTT topic **cp_simu/cps/simu_cp_XXX/ocpp_config** all the OCPP config of the Charge Point

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ RUN apt-get update && apt-get install build-essential clang cmake python3 python
1616

1717
RUN git clone https://github.com/c-jimenez/open-ocpp.git
1818

19-
RUN cd open-ocpp && git fetch --tags && git checkout v1.1.0 && make gcc && make install-gcc
19+
RUN cd open-ocpp && git fetch --tags && git checkout v1.2.0 && make gcc && make install-gcc
2020

2121
RUN apt-get update && apt-get install pkg-config && apt-get -q autoremove && rm -rf "/var/lib/apt/lists/*"
2222

docker/Dockerfile_cp_simulator

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ COPY gcc_native/config.ini /var/chargepoint/config.ini
1414
RUN chown ${simu_uid}:${simu_gid} /var/chargepoint/config.ini
1515

1616
COPY gcc_native /cp_simulator
17+
COPY cp_simu_entrypoint.sh /cp_simu_entrypoint.sh
1718

1819
USER cp_simu
1920

2021
WORKDIR "/var/chargepoint"
2122

22-
ENTRYPOINT ["/cp_simulator/chargepoint"]
23+
ENTRYPOINT ["/cp_simu_entrypoint.sh"]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
cp_args=""
4+
diagnostic_file_size=0
5+
6+
for i in "$@"; do
7+
case $i in
8+
--diagnostic_file_size*)
9+
diagnostic_file_size="$2"
10+
shift
11+
;;
12+
-*)
13+
cp_args+=" $i $2"
14+
shift
15+
;;
16+
*)
17+
shift
18+
;;
19+
esac
20+
done
21+
22+
# create big file and add it in diagnostic zip of charge point
23+
if [ $diagnostic_file_size -gt 0 ]
24+
then
25+
echo "generate $diagnostic_file_size random strings in cp config file"
26+
echo "$(tr -dc A-Za-z0-9 < /dev/urandom | head -c $diagnostic_file_size)" >> /var/chargepoint/blob.txt
27+
cp_args+=" -f blob.txt"
28+
fi
29+
30+
# start simulator
31+
echo "start charpoint with arguments : $cp_args"
32+
/cp_simulator/chargepoint $cp_args

imgs/connect.png

48 Bytes
Loading

imgs/instances.png

10.8 KB
Loading

makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,12 @@ docker-build-simu-compile:
104104
@${DOCKER_BUILD} -f docker/Dockerfile -t $(DOCKER_COMPILE_IMAGE) $(ROOT_DIR)/docker
105105

106106
docker-build-cp-simulator:
107+
cp docker/Entrypoint/cp_simu_entrypoint.sh $(ROOT_DIR)/bin/
107108
@${DOCKER_BUILD} -f docker/Dockerfile_cp_simulator -t $(DOCKER_SIMULATOR_IMAGE) $(ROOT_DIR)/bin/
108109

109110

110111
run-simu:
111-
docker run $(DOCKER_INTERACTIVE) --rm --network=host --name ocpp-simu $(DOCKER_SIMULATOR_IMAGE) -c test_ocpp
112+
docker run $(DOCKER_INTERACTIVE) --rm --network=host --name ocpp-simu $(DOCKER_SIMULATOR_IMAGE)
112113

113114
run-launcher:
114115
docker run $(DOCKER_INTERACTIVE) --rm --network=host --name ocpp-launcher --entrypoint /cp_simulator/launcher $(DOCKER_SIMULATOR_IMAGE)

src/chargepoint/Version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ SOFTWARE.
2626
#define VERSION_H
2727

2828
/** @brief Firmware version of the simulated charge point */
29-
#define CHARGEPOINT_FW_VERSION "1.0.0"
29+
#define CHARGEPOINT_FW_VERSION "1.1.0"
3030

3131
#endif // VERSION_H

src/chargepoint/config/SimulatedChargePointConfig.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,29 @@ SOFTWARE.
3030
#include "OcppConfig.h"
3131

3232
#include <openocpp/IniFile.h>
33+
#include <set>
3334

3435
/** @brief Configuration of the simulated charge point */
3536
class SimulatedChargePointConfig
3637
{
3738
public:
3839
/** @brief Constructor */
39-
SimulatedChargePointConfig(const std::string& working_dir, const std::string& config_file)
40-
: m_working_dir(working_dir), m_config(config_file), m_stack_config(m_config), m_ocpp_config(m_config), m_mqtt_config(m_config)
40+
SimulatedChargePointConfig(const std::string& working_dir, const std::string& config_file, std::set<std::string>& diag_files)
41+
: m_working_dir(working_dir),
42+
m_config(config_file),
43+
m_diag_files(diag_files),
44+
m_stack_config(m_config),
45+
m_ocpp_config(m_config),
46+
m_mqtt_config(m_config)
4147
{
4248
}
4349

4450
/** @brief Working directory */
4551
const std::string& workingDir() const { return m_working_dir; }
4652

53+
/** @brief files to put diagnostic zip */
54+
const std::set<std::string>& diagFiles() const { return m_diag_files; }
55+
4756
/** @brief Stack internal configuration */
4857
ocpp::config::IChargePointConfig& stackConfig() { return m_stack_config; }
4958

@@ -67,6 +76,8 @@ class SimulatedChargePointConfig
6776
std::string m_working_dir;
6877
/** @brief Configuration file */
6978
ocpp::helpers::IniFile m_config;
79+
/** @brief files to put diagnostic zip */
80+
std::set<std::string> m_diag_files;
7081

7182
/** @brief Stack internal configuration */
7283
ChargePointConfig m_stack_config;

src/chargepoint/main.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SOFTWARE.
3333
#include <iostream>
3434
#include <string.h>
3535
#include <thread>
36+
#include <set>
3637

3738
using namespace std;
3839

@@ -73,6 +74,7 @@ int main(int argc, char* argv[])
7374
std::string mqtt_broker_url = "tcp://localhost:1883";
7475
unsigned int max_charge_point_current = 32u;
7576
unsigned int max_connector_current = 32u;
77+
std::set<std::string> diag_files = {"ocpp.db"};
7678

7779
// Check parameters
7880
if (argc > 1)
@@ -140,6 +142,19 @@ int main(int argc, char* argv[])
140142
argc--;
141143
max_connector_current = static_cast<unsigned int>(std::atoi(*argv));
142144
}
145+
else if ((strcmp(*argv, "-f") == 0) && (argc > 1))
146+
{
147+
argv++;
148+
argc--;
149+
// add all files in diag file list:
150+
diag_files.insert(*argv);
151+
while((argc > 2) && (*argv[1] != '-'))
152+
{
153+
argv++;
154+
argc--;
155+
diag_files.insert(*argv);
156+
}
157+
}
143158
else
144159
{
145160
param = *argv;
@@ -168,14 +183,16 @@ int main(int argc, char* argv[])
168183
std::cout << " -b : URL of the MQTT broker (Default = tcp://localhost:1883)" << std::endl;
169184
std::cout << " -m : Max current in A for the whole Charge Point (Default = 32A)" << std::endl;
170185
std::cout << " -i : Max current in A for a connector of the Charge Point (Default = 32A)" << std::endl;
186+
std::cout << " -f : Files to put in diagnostic zip. Absolute path or relative path from working directory. " << std::endl;
187+
std::cout << "Default = [ocpp.db]" << std::endl;
171188
return 1;
172189
}
173190
}
174191

175192
// Open configuration file
176193
std::filesystem::path path(working_dir);
177194
path /= "config.ini";
178-
SimulatedChargePointConfig config(working_dir, path.string());
195+
SimulatedChargePointConfig config(working_dir, path.string(), diag_files);
179196

180197
// Update configuration file
181198
std::filesystem::path db_path(working_dir);

0 commit comments

Comments
 (0)