@zetra/citrineos-smartcharging 1.8.3-fork.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/module/1.6/MessageApi.d.ts +31 -0
- package/dist/module/1.6/MessageApi.js +69 -0
- package/dist/module/1.6/MessageApi.js.map +1 -0
- package/dist/module/2.0.1/MessageApi.d.ts +45 -0
- package/dist/module/2.0.1/MessageApi.js +443 -0
- package/dist/module/2.0.1/MessageApi.js.map +1 -0
- package/dist/module/interface.d.ts +5 -0
- package/dist/module/interface.js +5 -0
- package/dist/module/interface.js.map +1 -0
- package/dist/module/module.d.ts +98 -0
- package/dist/module/module.js +460 -0
- package/dist/module/module.js.map +1 -0
- package/dist/module/smartCharging/InternalSmartCharging.d.ts +29 -0
- package/dist/module/smartCharging/InternalSmartCharging.js +167 -0
- package/dist/module/smartCharging/InternalSmartCharging.js.map +1 -0
- package/dist/module/smartCharging/SmartCharging.d.ts +22 -0
- package/dist/module/smartCharging/SmartCharging.js +6 -0
- package/dist/module/smartCharging/SmartCharging.js.map +1 -0
- package/dist/module/smartCharging/index.d.ts +2 -0
- package/dist/module/smartCharging/index.js +5 -0
- package/dist/module/smartCharging/index.js.map +1 -0
- package/package.json +25 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { ChargingProfilePurposeEnum, OCPP2_0_1 } from '@citrineos/base';
|
|
2
|
+
import { ChargingProfile, ChargingSchedule, Transaction } from '@citrineos/data';
|
|
3
|
+
import { Logger } from 'tslog';
|
|
4
|
+
export class InternalSmartCharging {
|
|
5
|
+
_chargingProfileRepository;
|
|
6
|
+
_logger;
|
|
7
|
+
constructor(chargingProfileRepository, logger) {
|
|
8
|
+
this._chargingProfileRepository = chargingProfileRepository;
|
|
9
|
+
this._logger = logger
|
|
10
|
+
? logger.getSubLogger({ name: this.constructor.name })
|
|
11
|
+
: new Logger({ name: this.constructor.name });
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generates a `ChargingProfileType` from the given `NotifyEVChargingNeedsRequest`.
|
|
15
|
+
*
|
|
16
|
+
* This method creates a charging profile based on the EV's charging needs and the specified energy transfer mode.
|
|
17
|
+
* The profile includes the necessary parameters to set up a charging schedule for the EV.
|
|
18
|
+
*
|
|
19
|
+
* @param request - The `NotifyEVChargingNeedsRequest` containing details about the EV's charging requirements.
|
|
20
|
+
* @param transaction - The ID of the transaction associated with the charging profile.
|
|
21
|
+
* @param stationId - The ID of the station
|
|
22
|
+
* @returns A `ChargingProfileType`.
|
|
23
|
+
*
|
|
24
|
+
* @throws Error if the energy transfer mode is unsupported.
|
|
25
|
+
*/
|
|
26
|
+
async calculateChargingProfile(request, transaction, tenantId, stationId) {
|
|
27
|
+
const { chargingNeeds } = request;
|
|
28
|
+
const acParams = chargingNeeds.acChargingParameters;
|
|
29
|
+
const dcParams = chargingNeeds.dcChargingParameters;
|
|
30
|
+
const transferMode = chargingNeeds.requestedEnergyTransfer;
|
|
31
|
+
// Default values
|
|
32
|
+
const profileId = await this._chargingProfileRepository.getNextChargingProfileId(tenantId, stationId);
|
|
33
|
+
const nativePurpose = ChargingProfilePurposeEnum.TxProfile;
|
|
34
|
+
// Find existing charging profile and then add 1 as stack level
|
|
35
|
+
const stackLevel = await this._chargingProfileRepository.getNextStackLevel(tenantId, stationId, transaction.id, nativePurpose);
|
|
36
|
+
// Create charging schedule
|
|
37
|
+
const scheduleId = await this._chargingProfileRepository.getNextChargingScheduleId(tenantId, stationId);
|
|
38
|
+
let limit = 0;
|
|
39
|
+
let numberPhases;
|
|
40
|
+
let minChargingRate;
|
|
41
|
+
let chargingRateUnit = OCPP2_0_1.ChargingRateUnitEnumType.A;
|
|
42
|
+
// Determine charging parameters based on energy transfer mode
|
|
43
|
+
switch (transferMode) {
|
|
44
|
+
case OCPP2_0_1.EnergyTransferModeEnumType.AC_single_phase:
|
|
45
|
+
case OCPP2_0_1.EnergyTransferModeEnumType.AC_two_phase:
|
|
46
|
+
case OCPP2_0_1.EnergyTransferModeEnumType.AC_three_phase:
|
|
47
|
+
if (acParams) {
|
|
48
|
+
const { evMinCurrent, evMaxCurrent } = acParams;
|
|
49
|
+
numberPhases =
|
|
50
|
+
transferMode === OCPP2_0_1.EnergyTransferModeEnumType.AC_single_phase
|
|
51
|
+
? 1
|
|
52
|
+
: transferMode === OCPP2_0_1.EnergyTransferModeEnumType.AC_two_phase
|
|
53
|
+
? 2
|
|
54
|
+
: 3; // For AC_three_phase
|
|
55
|
+
chargingRateUnit = OCPP2_0_1.ChargingRateUnitEnumType.A; // always use amp for AC
|
|
56
|
+
limit = evMaxCurrent;
|
|
57
|
+
minChargingRate = evMinCurrent;
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
case OCPP2_0_1.EnergyTransferModeEnumType.DC:
|
|
61
|
+
if (dcParams) {
|
|
62
|
+
const { evMaxPower, evMaxCurrent, evMaxVoltage } = dcParams;
|
|
63
|
+
numberPhases = undefined; // For a DC EVSE this field should be omitted.
|
|
64
|
+
[chargingRateUnit, limit] = this._getChargingRateUnitAndLimit(evMaxCurrent, evMaxVoltage, evMaxPower);
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
throw new Error('Unsupported energy transfer mode');
|
|
69
|
+
}
|
|
70
|
+
await this._validateLimitAgainstExistingProfile(limit, tenantId, stationId, transaction.id);
|
|
71
|
+
const departureTime = chargingNeeds.departureTime
|
|
72
|
+
? new Date(chargingNeeds.departureTime)
|
|
73
|
+
: undefined;
|
|
74
|
+
const currentTime = new Date();
|
|
75
|
+
const duration = departureTime ? departureTime.getTime() - currentTime.getTime() : undefined;
|
|
76
|
+
// Create charging period
|
|
77
|
+
const chargingSchedulePeriod = [
|
|
78
|
+
{
|
|
79
|
+
startPeriod: 0,
|
|
80
|
+
limit,
|
|
81
|
+
numberPhases,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
const chargingSchedule = {
|
|
85
|
+
id: scheduleId,
|
|
86
|
+
duration,
|
|
87
|
+
chargingRateUnit,
|
|
88
|
+
chargingSchedulePeriod,
|
|
89
|
+
minChargingRate,
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
id: profileId,
|
|
93
|
+
stackLevel,
|
|
94
|
+
chargingProfilePurpose: OCPP2_0_1.ChargingProfilePurposeEnumType.TxProfile,
|
|
95
|
+
chargingProfileKind: OCPP2_0_1.ChargingProfileKindEnumType.Absolute,
|
|
96
|
+
validFrom: currentTime.toISOString(), // Now
|
|
97
|
+
validTo: chargingNeeds.departureTime, // Until departure
|
|
98
|
+
chargingSchedule: [chargingSchedule],
|
|
99
|
+
transactionId: transaction.transactionId,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
async checkLimitsOfChargingSchedule(request, tenantId, stationId, transaction) {
|
|
103
|
+
const givenChargingPeriods = request.chargingSchedule.chargingSchedulePeriod;
|
|
104
|
+
const existingChargingProfile = await this._findExistingChargingProfileWithHighestStackLevel(tenantId, stationId, transaction.id);
|
|
105
|
+
// Currently, we simply check the limit in each charging period
|
|
106
|
+
if (existingChargingProfile) {
|
|
107
|
+
if (existingChargingProfile.chargingSchedule.length === 1) {
|
|
108
|
+
const existingChargingPeriods = existingChargingProfile.chargingSchedule[0].chargingSchedulePeriod;
|
|
109
|
+
if (givenChargingPeriods.length === existingChargingPeriods.length) {
|
|
110
|
+
for (let i = 0; i < givenChargingPeriods.length; i++) {
|
|
111
|
+
if (givenChargingPeriods[i].limit > existingChargingPeriods[i].limit) {
|
|
112
|
+
throw new Error(`Given limits ${givenChargingPeriods[i].limit} exceeds existing limits ${existingChargingPeriods[i].limit} in charging profile ${existingChargingProfile.databaseId}.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
throw new Error(`Given charging periods and existing charging periods in charging profile ${existingChargingProfile.databaseId} are unmatched.`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
throw new Error(`Existing charging profile ${existingChargingProfile.databaseId} have more than one charging schedules.`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
_getChargingRateUnitAndLimit(evMaxCurrent, evMaxVoltage, evMaxPower) {
|
|
126
|
+
if (evMaxPower && evMaxPower < evMaxCurrent * evMaxVoltage) {
|
|
127
|
+
// when charging rate unit is W, multiply by 1000
|
|
128
|
+
// based on OCPP 2.0.1 V3 Part 6 TC_K_57_CS
|
|
129
|
+
return [OCPP2_0_1.ChargingRateUnitEnumType.W, evMaxPower * 1000];
|
|
130
|
+
}
|
|
131
|
+
return [OCPP2_0_1.ChargingRateUnitEnumType.A, evMaxCurrent * evMaxVoltage];
|
|
132
|
+
}
|
|
133
|
+
async _findExistingChargingProfileWithHighestStackLevel(tenantId, stationId, transactionDatabaseId) {
|
|
134
|
+
const existingChargingProfiles = await this._chargingProfileRepository.readAllByQuery(tenantId, {
|
|
135
|
+
where: {
|
|
136
|
+
tenantId,
|
|
137
|
+
stationId,
|
|
138
|
+
transactionDatabaseId,
|
|
139
|
+
chargingProfilePurpose: ChargingProfilePurposeEnum.TxProfile,
|
|
140
|
+
},
|
|
141
|
+
order: [['stackLevel', 'DESC']],
|
|
142
|
+
limit: 1,
|
|
143
|
+
include: [ChargingSchedule],
|
|
144
|
+
});
|
|
145
|
+
if (existingChargingProfiles.length > 0) {
|
|
146
|
+
return existingChargingProfiles[0];
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async _validateLimitAgainstExistingProfile(limit, tenantId, stationId, transactionDataBaseId) {
|
|
153
|
+
const existingChargingProfile = await this._findExistingChargingProfileWithHighestStackLevel(tenantId, stationId, transactionDataBaseId);
|
|
154
|
+
if (existingChargingProfile) {
|
|
155
|
+
this._logger.info(`Found existing charging profile ${existingChargingProfile.databaseId}`);
|
|
156
|
+
for (const schedule of existingChargingProfile.chargingSchedule) {
|
|
157
|
+
for (const period of schedule.chargingSchedulePeriod) {
|
|
158
|
+
if (period.limit < limit) {
|
|
159
|
+
this._logger.error(`Limit ${limit} is bigger than existing limit ${period.limit} in charging schedule ${schedule.id}`);
|
|
160
|
+
throw new Error(`Limit ${limit} is bigger than existing limit ${period.limit} in charging schedule ${schedule.id}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=InternalSmartCharging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InternalSmartCharging.js","sourceRoot":"","sources":["../../../src/module/smartCharging/InternalSmartCharging.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0BAA0B,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEjF,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,MAAM,OAAO,qBAAqB;IACtB,0BAA0B,CAA6B;IAC9C,OAAO,CAAkB;IAE5C,YAAY,yBAAqD,EAAE,MAAwB;QACzF,IAAI,CAAC,0BAA0B,GAAG,yBAAyB,CAAC;QAC5D,IAAI,CAAC,OAAO,GAAG,MAAM;YACnB,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YACtD,CAAC,CAAC,IAAI,MAAM,CAAU,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,wBAAwB,CAC5B,OAA+C,EAC/C,WAAwB,EACxB,QAAgB,EAChB,SAAiB;QAEjB,MAAM,EAAE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YACN,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,oCAAoC,CAChD,KAAa,EACb,QAAgB,EAChB,SAAiB,EACjB,qBAA6B;QAE7B,MAAM,uBAAuB,GAAG,MAAM,IAAI,CAAC,iDAAiD,CAC1F,QAAQ,EACR,SAAS,EACT,qBAAqB,CACtB,CAAC;QAEF,IAAI,uBAAuB,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mCAAmC,uBAAuB,CAAC,UAAU,EAAE,CAAC,CAAC;YAE3F,KAAK,MAAM,QAAQ,IAAI,uBAAuB,CAAC,gBAAgB,EAAE,CAAC;gBAChE,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,sBAAsB,EAAE,CAAC;oBACrD,IAAI,MAAM,CAAC,KAAK,GAAG,KAAK,EAAE,CAAC;wBACzB,IAAI,CAAC,OAAO,CAAC,KAAK,CAChB,SAAS,KAAK,kCAAkC,MAAM,CAAC,KAAK,yBAAyB,QAAQ,CAAC,EAAE,EAAE,CACnG,CAAC;wBACF,MAAM,IAAI,KAAK,CACb,SAAS,KAAK,kCAAkC,MAAM,CAAC,KAAK,yBAAyB,QAAQ,CAAC,EAAE,EAAE,CACnG,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OCPP2_0_1 } from '@citrineos/base';
|
|
2
|
+
import { Transaction } from '@citrineos/data';
|
|
3
|
+
export interface ISmartCharging {
|
|
4
|
+
/**
|
|
5
|
+
* Interface for calculating charging profile based on the charging needs
|
|
6
|
+
*
|
|
7
|
+
* @param {NotifyEVChargingNeedsRequest} request - charging need request
|
|
8
|
+
* @param {Transaction} transaction
|
|
9
|
+
* @param {string} stationId
|
|
10
|
+
*
|
|
11
|
+
* @returns {Promise<ChargingProfileType>} charging profile
|
|
12
|
+
**/
|
|
13
|
+
calculateChargingProfile(request: OCPP2_0_1.NotifyEVChargingNeedsRequest, transaction: Transaction, tenantId: number, stationId: string): Promise<OCPP2_0_1.ChargingProfileType>;
|
|
14
|
+
/**
|
|
15
|
+
* Inteface for checking EV charging schedule is within limits of CSMS ChargingSchedule
|
|
16
|
+
*
|
|
17
|
+
* @param {NotifyEVChargingScheduleRequest} request - EV charging schedule request
|
|
18
|
+
* @param {Transaction} transaction
|
|
19
|
+
* @param {string} stationId
|
|
20
|
+
**/
|
|
21
|
+
checkLimitsOfChargingSchedule(request: OCPP2_0_1.NotifyEVChargingScheduleRequest, tenantId: number, stationId: string, transaction: Transaction): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmartCharging.js","sourceRoot":"","sources":["../../../src/module/smartCharging/SmartCharging.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/module/smartCharging/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,sCAAsC;AAGtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zetra/citrineos-smartcharging",
|
|
3
|
+
"version": "1.8.3-fork.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "The smartcharging module for OCPP v2.0.1. This module is not intended to be used directly, but rather as a dependency for other modules.",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"prepublish": "npx eslint",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"ocpp",
|
|
17
|
+
"ocpp_v201"
|
|
18
|
+
],
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@zetra/citrineos-base": "1.8.3-fork.1",
|
|
22
|
+
"@zetra/citrineos-data": "1.8.3-fork.1",
|
|
23
|
+
"@zetra/citrineos-util": "1.8.3-fork.1"
|
|
24
|
+
}
|
|
25
|
+
}
|