forked from aymen-mouelhi/ocpp-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (27 loc) · 1019 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const CentralSystem = require('./entities/CentralSystem.js');
const ChargingPoint = require('./entities/ChargingPoint');
const ChargingPointServer = require('./entities/ChargingPointServer');
class OCPP {
constructor(options){
this.options = options || {};
}
createCentralSystem(port){
// CentralSystem Default URI is /Ocpp/CentralSystemService
var port = this.options.centralSystem.port || port || 9220;
return new CentralSystem(port);
}
createChargingPoint(uri, name){
var serverURI = this.options.chargingPoint.serverURI || uri;
var pointName = this.options.chargingPoint.name || name || 'Simulator';
if(!serverURI){
throw 'Charging Point Server URI is required';
}
return new ChargingPoint(serverURI, pointName);
}
createChargingPointServer(){
// ChargingPointServer Default URI is /Ocpp/ChargePointService
var port = this.options.chargingPointServer.port || port || 9221;
return new ChargingPointServer(port);
}
}
module.exports = OCPP;