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