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