([]);
75 |
76 | const isSmUp = useMediaQuery(appTheme.breakpoints.up("md"));
77 |
78 | const handleMenuClick = (newMenuItem: MenuItem) => {
79 | setSelectedMenuItem(newMenuItem);
80 | };
81 | //Wait for db and userInfo to arrive (it does not load on component load right away)
82 |
83 | console.log(`App.tsx first render - elapsed: ${Date.now() - startTime} ms`);
84 |
85 | if (props.firebase.userInfo) {
86 | console.log(
87 | `App.tsx userInfo arrived - elapsed: ${Date.now() - startTime} ms`
88 | );
89 | }
90 | if (props.firebase.app) {
91 | console.log(
92 | `App.tsx firt app obj arrived - elapsed: ${Date.now() - startTime} ms`
93 | );
94 | }
95 |
96 | React.useEffect(() => {
97 | const timeOutID = setTimeout(() => {
98 | setUserInfo(props.firebase.userInfo);
99 | setDb(getFirestore(props.firebase.app));
100 | }, 1000);
101 | return () => clearTimeout(timeOutID);
102 | });
103 |
104 | React.useEffect(() => {
105 | if (!db || !userInfo || !userInfo.email) {
106 | console.log(
107 | "=> useffect STATIONS -------!db || !userInfo || !userInfo.email "
108 | );
109 | return;
110 | }
111 | let q = null;
112 | q = query(collection(db, "chargingstations"));
113 | return setUpSnapshotListener(
114 | (resultItems: ChargingStation[]) => {
115 | console.log("=> stationResults");
116 | console.log("=> ", [...resultItems]);
117 | setStations(resultItems);
118 | },
119 | "chargingstations",
120 | q,
121 | db,
122 | userInfo
123 | );
124 | }, [db, userInfo]);
125 |
126 | React.useEffect(() => {
127 | if (!db || !userInfo || !(stations.length > 0)) {
128 | console.log(
129 | "=> useffect TRANSACTIONS ------- !db !currentUserRecord ||!userInfo || !currentUserPermissions.transactions || !(stations.length > 0)"
130 | );
131 | return;
132 | }
133 | let q = null;
134 | q = query(collection(db, "transactions"), orderBy("energyTransferStarted", "desc"));
135 | return setUpSnapshotListener(
136 | (resultItems: Transaction[]) => {
137 | console.log("=> transactionResults");
138 | console.log("=> ", [...resultItems]);
139 | setTransactions(resultItems);
140 | },
141 | "transactions",
142 | q,
143 | db,
144 | userInfo
145 | );
146 | }, [db, userInfo, stations]);
147 |
148 |
149 | React.useEffect(() => {
150 | if (!db || !userInfo) {
151 | console.log(
152 | "=> useffect TOKENS ------- !db !currentUserRecord ||!userInfo || !currentUserPermissions.transactions || !(stations.length > 0)"
153 | );
154 | return;
155 | }
156 | let q = null;
157 | q = query(collection(db, "idTokens") /*orderBy("status"))*/);
158 | return setUpSnapshotListener(
159 | (resultItems: IdTokenType[]) => {
160 | console.log("=> tokenResults");
161 | console.log("=> ", [...resultItems]);
162 | setChargeTokens(resultItems);
163 | },
164 | "idTokens",
165 | q,
166 | db,
167 | userInfo
168 | );
169 | }, [db, userInfo, transactions]);
170 |
171 | const handleNewToken = async (newToken: IdTokenType, id: string) => {
172 | try {
173 | await createRecordInDB(
174 | {
175 | firebase: props.firebase,
176 | //db: db,
177 | record: newToken,
178 | collectionName: /*ExistingFirestoreCollection.idTokens*/ "idTokens",
179 | },
180 | id
181 | );
182 | } catch (err) {
183 | console.error(err);
184 | }
185 | };
186 |
187 | const handleModifiedToken = async (
188 | modifiedToken: IdTokenType,
189 | id: string
190 | ) => {
191 | try {
192 | await updateRecordInDB(
193 | {
194 | firebase: props.firebase,
195 | record: modifiedToken,
196 | collectionName: ExistingFirestoreCollection.idTokens,
197 | },
198 | id
199 | );
200 | } catch (err) {
201 | console.error(err);
202 | }
203 | };
204 |
205 | const handleDeletedToken = async (deletedToken: IdTokenType, id: string) => {
206 | try {
207 | await deleteRecordInDB(
208 | {
209 | firebase: props.firebase,
210 | record: deletedToken,
211 | collectionName: ExistingFirestoreCollection.idTokens,
212 | },
213 | id
214 | );
215 | } catch (err) {
216 | console.error(err);
217 | }
218 | };
219 |
220 | return (
221 | setAuthUser(newAuthUser),
233 | }}
234 | >
235 |
241 |
242 |
243 |
244 |
245 |
246 |
247 | );
248 | }
249 |
250 | export default App;
251 |
--------------------------------------------------------------------------------
/device-service/http/api/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | OCPP Device Service
5 |
179 |
180 |
181 | OCPP Device Service
182 | REST API to manage OCPP devices (e.g. Charging Stations)
183 |
184 |
185 | Version: v2.0.0
186 | BasePath:/gregszalay/ocpp_device_service/v2.0.0
187 | All rights reserved
188 | http://apache.org/licenses/LICENSE-2.0.html
189 | Access
190 |
191 |
192 | [ Jump to Models ]
193 |
194 | Table of Contents
195 |
196 |
197 |
200 |
201 |
204 |
205 |
208 |
209 |
212 |
213 |
216 |
217 |
218 |
219 |
220 |
Up
221 |
post /chargingstations/create
222 |
Adds a new charger in db (createChargingStation)
223 |
224 |
225 |
226 |
Consumes
227 | This API call consumes the following media types via the request header:
228 |
229 | application/json
230 |
231 |
232 |
Request body
233 |
234 |
235 |
236 |
Body Parameter — Creates a new charging station in the db
237 |
238 |
239 |
240 |
241 |
242 |
Return type
243 |
247 |
248 |
249 |
250 |
Example data
251 |
Content-Type: application/json
252 |
""
253 |
254 |
Produces
255 | This API call produces the following media types according to the request header;
256 | the media type will be conveyed by the response header.
257 |
258 | application/json
259 |
260 |
261 |
Responses
262 |
200
263 | Successful registration of new device
264 |
ChargingStationId
265 |
400
266 | Unsuccessful creation
267 |
268 |
269 |
270 |
271 |
272 |
273 |
Up
274 |
post /chargingstations/delete/{id}
275 |
Deletes a charger in db (deleteChargingStation)
276 |
277 |
278 |
Path parameters
279 |
280 |
id (required)
281 |
282 |
Path Parameter —
283 |
284 |
285 |
286 |
287 |
288 |
289 |
Return type
290 |
294 |
295 |
296 |
297 |
Example data
298 |
Content-Type: application/json
299 |
{
300 | "serialNumber" : "24",
301 | "lastBoot" : "2000-01-23T04:56:07.000+00:00",
302 | "modem" : {
303 | "iccid" : "24",
304 | "imsi" : "24"
305 | },
306 | "model" : "GT-5000",
307 | "location" : {
308 | "lng" : -71.1854651,
309 | "lat" : 42.366446
310 | },
311 | "id" : "id",
312 | "vendorName" : "ChargingStationMaker Inc.",
313 | "firmwareVersion" : "2.8"
314 | }
315 |
316 |
Produces
317 | This API call produces the following media types according to the request header;
318 | the media type will be conveyed by the response header.
319 |
320 | application/json
321 |
322 |
323 |
Responses
324 |
200
325 | Successful deletion of charging station
326 |
ChargingStation
327 |
400
328 | Unsuccessful deletion
329 |
330 |
331 |
332 |
333 |
334 |
335 |
Up
336 |
get /chargingstations/station/{id}
337 |
Gets charging station data based on id (getChargingStations)
338 |
Get charging station data
339 |
340 |
Path parameters
341 |
342 |
id (required)
343 |
344 |
Path Parameter —
345 |
346 |
347 |
348 |
349 |
350 |
351 |
Return type
352 |
356 |
357 |
358 |
359 |
Example data
360 |
Content-Type: application/json
361 |
{
362 | "serialNumber" : "24",
363 | "lastBoot" : "2000-01-23T04:56:07.000+00:00",
364 | "modem" : {
365 | "iccid" : "24",
366 | "imsi" : "24"
367 | },
368 | "model" : "GT-5000",
369 | "location" : {
370 | "lng" : -71.1854651,
371 | "lat" : 42.366446
372 | },
373 | "id" : "id",
374 | "vendorName" : "ChargingStationMaker Inc.",
375 | "firmwareVersion" : "2.8"
376 | }
377 |
378 |
Produces
379 | This API call produces the following media types according to the request header;
380 | the media type will be conveyed by the response header.
381 |
382 | application/json
383 |
384 |
385 |
Responses
386 |
200
387 | successful operation
388 |
ChargingStation
389 |
400
390 | Invalid status value
391 |
392 |
393 |
394 |
395 |
396 |
397 |
Up
398 |
get /chargingstations/list
399 |
Get array of all charging stations (getAllChargingStations)
400 |
Get charging station data
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
Return type
409 |
413 |
414 |
415 |
416 |
Example data
417 |
Content-Type: application/json
418 |
[ {
419 | "serialNumber" : "24",
420 | "lastBoot" : "2000-01-23T04:56:07.000+00:00",
421 | "modem" : {
422 | "iccid" : "24",
423 | "imsi" : "24"
424 | },
425 | "model" : "GT-5000",
426 | "location" : {
427 | "lng" : -71.1854651,
428 | "lat" : 42.366446
429 | },
430 | "id" : "id",
431 | "vendorName" : "ChargingStationMaker Inc.",
432 | "firmwareVersion" : "2.8"
433 | }, {
434 | "serialNumber" : "24",
435 | "lastBoot" : "2000-01-23T04:56:07.000+00:00",
436 | "modem" : {
437 | "iccid" : "24",
438 | "imsi" : "24"
439 | },
440 | "model" : "GT-5000",
441 | "location" : {
442 | "lng" : -71.1854651,
443 | "lat" : 42.366446
444 | },
445 | "id" : "id",
446 | "vendorName" : "ChargingStationMaker Inc.",
447 | "firmwareVersion" : "2.8"
448 | } ]
449 |
450 |
Produces
451 | This API call produces the following media types according to the request header;
452 | the media type will be conveyed by the response header.
453 |
454 | application/json
455 |
456 |
457 |
Responses
458 |
200
459 | successful operation
460 |
ChargingStationList
461 |
400
462 | Invalid status value
463 |
464 |
465 |
466 |
467 |
468 |
469 |
Up
470 |
post /chargingstations/update/{id}
471 |
Updates a charging station in the database (updateChargingStation)
472 |
473 |
474 |
Path parameters
475 |
476 |
id (required)
477 |
478 |
Path Parameter —
479 |
480 |
Consumes
481 | This API call consumes the following media types via the request header:
482 |
483 | application/json
484 |
485 |
486 |
Request body
487 |
488 |
489 |
490 |
Body Parameter — Updates charging station
491 |
492 |
493 |
494 |
495 |
496 |
Return type
497 |
501 |
502 |
503 |
504 |
Example data
505 |
Content-Type: application/json
506 |
""
507 |
508 |
Produces
509 | This API call produces the following media types according to the request header;
510 | the media type will be conveyed by the response header.
511 |
512 | application/json
513 |
514 |
515 |
Responses
516 |
200
517 | Successful registration of new charging station
518 |
ChargingStationId
519 |
400
520 | Unsuccessful registration of new charging station
521 |
522 |
523 |
524 |
525 |
526 | [ Jump to Methods ]
527 |
528 | Table of Contents
529 |
530 | ChargingStation
531 | ChargingStationId
532 | ChargingStationList
533 | ChargingStation_location
534 | ChargingStation_modem
535 |
536 |
537 |
538 |
539 |
540 |
541 |
id
542 |
serialNumber (optional)
String OCPP - Optional. Vendor-specific device identifier.
543 |
example: 24
544 |
model
String OCPP - Required. Defines the model of the device.
545 |
example: GT-5000
546 |
vendorName
String OCPP - Required. Identifies the vendor (not necessarily in a unique manner).
547 |
example: ChargingStationMaker Inc.
548 |
firmwareVersion (optional)
String OCPP - Optional. This contains the firmware version of the Charging Station.
549 |
example: 2.8
550 |
modem (optional)
551 |
location (optional)
552 |
lastBoot (optional)
Date Date and time of last BootNotification received. As defined by date-time - RFC3339 format: date-time
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
lat (optional)
572 |
example: 42.366446
573 |
lng (optional)
574 |
example: -71.1854651
575 |
576 |
577 |
578 |
579 |
580 |
581 |
iccid (optional)
String OCPP - Optional. This contains the ICCID of the modem’s SIMcard.
582 |
example: 24
583 |
imsi (optional)
String OCPP - Optional. This contains the IMSI of the modem’s SIM card.
584 |
example: 24
585 |
586 |
587 |
588 |
589 |
--------------------------------------------------------------------------------