Unify supervision urls setup and distribution to charging stations
[e-mobility-charging-stations-simulator.git] / README.md
... / ...
CommitLineData
1# [charging-stations-simulator](https://github.com/jerome-benoit/charging-stations-simulator)
2
3## Summary
4
5Simple [node.js](https://nodejs.org/) program to simulate a set of charging stations based on the OCPP-J 1.6 protocol.
6
7## Prerequisites
8
9### Windows
10
11* [Chocolatey](https://chocolatey.org/):
12
13```powershell
14choco install -y nodejs-lts
15```
16
17### MacOSX
18
19* [Homebrew](https://brew.sh/):
20
21```shell
22brew install node@14
23```
24
25### GNU/Linux:
26
27* [NodeSource](https://github.com/nodesource/distributions) Node.js Binary Distributions for version 14.X
28
29## Configuration syntax
30
31All configuration files are in the JSON standard format.
32
33The charging stations simulator's main configuration parameters must be within the `src/assets/config.json` file. A configuration template file is available at [src/assets/config-template.json](src/assets/config-template.json).
34
35All charging station templates are in the directory [src/assets/station-templates](src/assets/station-templates).
36
37A list of RFID tags must be defined for the automatic transaction generator with the default location and name `src/assets/authorization-tags.json`. A template file is available at [src/assets/authorization-tags-template.json](src/assets/authorization-tags-template.json).
38
39The charging stations simulator have an automatic configuration files reload feature at change for:
40* main configuration;
41* charging station templates;
42* authorization RFID tags.
43
44But the modifications to test have to be done to the files in the build result directory [dist/assets](dist/assets). Once the modifications are finished, they have to be reported or copied to the matching files in the build source directory [src/assets](src/assets) to ensure they will be taken into account at next build.
45
46### Main configuration
47
48**src/assets/config.json**:
49
50Key | Value(s) | Default Value | Value type | Description
51--- | -------| --------------| ---------- | ------------
52supervisionUrls | | [] | string \| string[] | string or array of global connection URIs to OCPP-J servers
53supervisionUrlDistribution | round-robin/random/sequential | round-robin | boolean | supervision urls distribution policy to simulated charging stations
54workerProcess | workerSet/staticPool/dynamicPool | workerSet | string | worker threads process type
55workerStartDelay | | 500 | integer | milliseconds to wait at charging station worker threads startup
56workerPoolMinSize | | 4 | integer | worker threads pool minimum number of threads
57workerPoolMaxSize | | 16 | integer | worker threads pool maximum number of threads
58workerPoolStrategy | ROUND_ROBIN/LESS_RECENTLY_USED/... | [poolifier](https://github.com/poolifier/poolifier) default: ROUND_ROBBIN | string | worker threads pool [poolifier](https://github.com/poolifier/poolifier) worker choice strategy
59chargingStationsPerWorker | | 1 | integer | number of charging stations per worker threads for the `workerSet` process type
60logStatisticsInterval | | 60 | integer | seconds between charging stations statistics output in the logs
61logConsole | true/false | false | boolean | output logs on the console
62logFormat | | simple | string | winston log format
63logRotate | true/false | true | boolean | enable daily log files rotation
64logMaxFiles | | 7 | integer | maximum number of log files to keep
65logLevel | emerg/alert/crit/error/warning/notice/info/debug | info | string | winston logging level
66logFile | | combined.log | string | log file relative path
67logErrorFile | | error.log | string | error log file relative path
68uiWebSocketServer | | { "enabled": true, "options": { "host: "localhost", "port": 8080 } } | { enabled: boolean; options: ServerOptions; } | UI WebSocket server configuration section
69performanceStorage | | { "enabled": false, "type": "jsonfile", "file:///performanceRecords.json" } | { enabled: boolean; type: string; URI: string; } where type can be 'jsonfile' or 'mongodb' | performance storage configuration section
70stationTemplateUrls | | {}[] | { file: string; numberOfStations: number; }[] | array of charging station templates URIs configuration section (template file name and number of stations)
71
72#### Worker process model:
73
74- **workerSet**:
75 Worker set executing each a static number (chargingStationsPerWorker) of simulated charging stations from the total
76
77- **staticPool**:
78 Statically sized worker pool executing a static total number of simulated charging stations
79
80- **dynamicPool**:
81 Dynamically sized worker pool executing a static total number of simulated charging stations
82
83### Charging station template
84
85Key | Value(s) | Default Value | Value type | Description
86--- | -------| --------------| ---------- | ------------
87supervisionUrls | | '' | string \| string[] | string or array of connection URIs to OCPP-J servers. It has priority over the global configuration parameter
88supervisionUser | | '' | string | basic HTTP authentication user to OCPP-J server
89supervisionPassword | | '' | string | basic HTTP authentication password to OCPP-J server
90supervisionUrlOcppConfiguration | true/false | false | boolean | Allow supervision URL configuration via a vendor OCPP parameter key
91supervisionUrlOcppKey | | 'ConnectionUrl' | string | The vendor string that will be used as a vendor OCPP parameter key to set the supervision URL
92ocppVersion | 1.6 | 1.6 | string | OCPP version
93ocppProtocol | json | json | string | OCPP protocol
94wsOptions | | {} | ClientOptions & ClientRequestArgs | [ws](https://github.com/websockets/ws) and node.js [http](https://nodejs.org/api/http.html) clients options intersection
95authorizationFile | | '' | string | RFID tags list file relative to src/assets path
96baseName | | '' | string | base name to build charging stations name
97nameSuffix | | '' | string | name suffix to build charging stations name
98fixedName | true/false | false | boolean | use the baseName as the charging stations unique name
99chargePointModel | | '' | string | charging stations model
100chargePointVendor | | '' | string | charging stations vendor
101chargeBoxSerialNumberPrefix | | '' | string | charging stations serial number prefix
102firmwareVersion | | '' | string | charging stations firmware version
103power | | | float\|float[] | charging stations maximum power value(s)
104powerSharedByConnectors | true/false | false | boolean | charging stations power shared by its connectors
105powerUnit | W/kW | W | string | charging stations power unit
106currentOutType | AC/DC | AC | string | charging stations current out type
107voltageOut | | AC:230/DC:400 | integer | charging stations voltage out
108numberOfPhases | 0/1/3 | AC:3/DC:0 | integer | charging stations number of phase(s)
109numberOfConnectors | | | integer\|integer[] | charging stations number of connector(s)
110useConnectorId0 | true/false | true | boolean | use connector id 0 definition from the template
111randomConnectors | true/false | false | boolean | randomize runtime connector id affectation from the connector id definition in template
112resetTime | | 60 | integer | seconds to wait before the charging stations come back at reset
113autoRegister | true/false | false | boolean | set the charging station as registered at boot notification for testing purpose
114autoReconnectMaxRetries | | -1 (unlimited) | integer | connection retries to the OCPP-J server
115reconnectExponentialDelay | true/false | false | boolean | connection delay retry to the OCPP-J server
116registrationMaxRetries | | -1 (unlimited) | integer | charging stations boot notification retries
117enableStatistics | true/false | true | boolean | enable charging stations statistics
118mayAuthorizeAtRemoteStart | true/false | true | boolean | always send authorize at remote start transaction when AuthorizeRemoteTxRequests is enabled
119beginEndMeterValues | true/false | false | boolean | enable Transaction.{Begin,End} MeterValues
120outOfOrderEndMeterValues | true/false | false | boolean | send Transaction.End MeterValues out of order
121meteringPerTransaction | true/false | true | boolean | enable metering history on a per transaction basis
122transactionDataMeterValues | true/false | false | boolean | enable transaction data MeterValues at stop transaction
123mainVoltageMeterValues | true/false | true | boolean | include charging station main voltage MeterValues on three phased charging stations
124phaseLineToLineVoltageMeterValues | true/false | true | boolean | include charging station line to line voltage MeterValues on three phased charging stations
125Configuration | | | ChargingStationConfiguration | charging stations OCPP parameters configuration section
126AutomaticTransactionGenerator | | | AutomaticTransactionGenerator | charging stations ATG configuration section
127Connectors | | | Connectors | charging stations connectors configuration section
128
129#### Configuration section
130
131```json
132 "Configuration": {
133 "configurationKey": [
134 ...
135 {
136 "key": "StandardKey",
137 "readonly": false,
138 "value": "StandardValue",
139 "visible": true,
140 "reboot": false
141 },
142 ...
143 {
144 "key": "VendorKey",
145 "readonly": false,
146 "value": "VendorValue",
147 "visible": false,
148 "reboot": true
149 },
150 ...
151 ]
152 }
153```
154
155#### AutomaticTransactionGenerator section
156
157```json
158 "AutomaticTransactionGenerator": {
159 "enable": false,
160 "minDuration": 60,
161 "maxDuration": 80,
162 "minDelayBetweenTwoTransactions": 15,
163 "maxDelayBetweenTwoTransactions": 30,
164 "probabilityOfStart": 1,
165 "stopAfterHours": 0.3,
166 "stopOnConnectionFailure": true,
167 "requireAuthorize": true
168 }
169```
170#### Connectors section
171
172```json
173 "Connectors": {
174 "0": {},
175 "1": {
176 "bootStatus": "Available",
177 "MeterValues": [
178 ...
179 {
180 "unit": "W",
181 "measurand": "Power.Active.Import",
182 "phase": "L1-N",
183 "value": "5000",
184 "fluctuationPercent": "10"
185 },
186 ...
187 {
188 "unit": "A",
189 "measurand": "Current.Import"
190 },
191 ...
192 {
193 "unit": "Wh"
194 },
195 ...
196 ]
197 }
198 },
199```
200
201## Start
202
203To start the program, run: `npm start`.
204
205## Docker
206
207In the [docker](./docker) folder:
208
209```bash
210make
211```
212
213Or with the optional git submodules:
214
215```bash
216make SUBMODULES_INIT=true
217```
218
219## OCPP-J commands supported
220
221### Version 1.6
222
223#### Core Profile
224
225- :white_check_mark: Authorize
226- :white_check_mark: BootNotification
227- :white_check_mark: ChangeAvailability
228- :white_check_mark: ChangeConfiguration
229- :white_check_mark: ClearCache
230- :x: DataTransfer
231- :white_check_mark: GetConfiguration
232- :white_check_mark: Heartbeat
233- :white_check_mark: MeterValues
234- :white_check_mark: RemoteStartTransaction
235- :white_check_mark: RemoteStopTransaction
236- :white_check_mark: Reset
237- :white_check_mark: StartTransaction
238- :white_check_mark: StatusNotification
239- :white_check_mark: StopTransaction
240- :white_check_mark: UnlockConnector
241
242#### Firmware Management Profile
243
244- :white_check_mark: GetDiagnostics
245- :white_check_mark: DiagnosticsStatusNotification
246- :x: FirmwareStatusNotification
247- :x: UpdateFirmware
248
249#### Local Auth List Management Profile
250
251- :x: GetLocalListVersion
252- :x: SendLocalList
253
254#### Reservation Profile
255
256- :x: CancelReservation
257- :x: ReserveNow
258
259#### Smart Charging Profile
260
261- :white_check_mark: ClearChargingProfile
262- :white_check_mark: GetCompositeSchedule
263- :white_check_mark: SetChargingProfile
264
265#### Remote Trigger Profile
266
267- :white_check_mark: TriggerMessage
268
269## OCPP-J standard parameters supported
270
271All kind of OCPP parameters are supported in a charging station template. The list here mention the standard ones also handled automatically in the simulator.
272
273### Version 1.6
274
275#### Core Profile
276
277- :white_check_mark: AuthorizeRemoteTxRequests (type: boolean) (units: -)
278- :x: ClockAlignedDataInterval (type: integer) (units: seconds)
279- :white_check_mark: ConnectionTimeOut (type: integer) (units: seconds)
280- :x: GetConfigurationMaxKeys (type: integer) (units: -)
281- :white_check_mark: HeartbeatInterval (type: integer) (units: seconds)
282- :x: LocalAuthorizeOffline (type: boolean) (units: -)
283- :x: LocalPreAuthorize (type: boolean) (units: -)
284- :x: MeterValuesAlignedData (type: CSL) (units: -)
285- :white_check_mark: MeterValuesSampledData (type: CSL) (units: -)
286- :white_check_mark: MeterValueSampleInterval (type: integer) (units: seconds)
287- :white_check_mark: NumberOfConnectors (type: integer) (units: -)
288- :x: ResetRetries (type: integer) (units: times)
289- :white_check_mark: ConnectorPhaseRotation (type: CSL) (units: -)
290- :x: StopTransactionOnEVSideDisconnect (type: boolean) (units: -)
291- :x: StopTransactionOnInvalidId (type: boolean) (units: -)
292- :x: StopTxnAlignedData (type: CSL) (units: -)
293- :x: StopTxnSampledData (type: CSL) (units: -)
294- :white_check_mark: SupportedFeatureProfiles (type: CSL) (units: -)
295- :x: TransactionMessageAttempts (type: integer) (units: times)
296- :x: TransactionMessageRetryInterval (type: integer) (units: seconds)
297- :x: UnlockConnectorOnEVSideDisconnect (type: boolean) (units: -)
298- :white_check_mark: WebSocketPingInterval (type: integer) (units: seconds)
299
300#### Firmware Management Profile
301
302- *none*
303
304#### Local Auth List Management Profile
305
306- :white_check_mark: LocalAuthListEnabled (type: boolean) (units: -)
307- :x: LocalAuthListMaxLength (type: integer) (units: -)
308- :x: SendLocalListMaxLength (type: integer) (units: -)
309
310#### Reservation Profile
311
312- *none*
313
314#### Smart Charging Profile
315
316- :x: ChargeProfileMaxStackLevel (type: integer) (units: -)
317- :x: ChargingScheduleAllowedChargingRateUnit (type: CSL) (units: -)
318- :x: ChargingScheduleMaxPeriods (type: integer) (units: -)
319- :x: MaxChargingProfilesInstalled (type: integer) (units: -)
320
321#### Remote Trigger Profile
322
323- *none*
324
325## License
326
327This file and all other files in this repository are licensed under the Apache Software License, v.2 and copyrighted under the copyright in [NOTICE](NOTICE) file, except as noted otherwise in the [LICENSE](LICENSE) file or the code source file header.
328
329Please note that Docker images can contain other software which may be licensed under different licenses. This LICENSE and NOTICE files are also included in the Docker image. For any usage of built Docker images please make sure to check the licenses of the artifacts contained in the images.