test for smart charging transaction error
MODIFY
test/api/SmartChargingTest.ts
test/api/SmartChargingTest.ts
@@ -642,6 +642,54 @@ describe('Smart Charging Service', function() {
TestData.validateChargingProfile(chargingProfiles[2], transaction2);
expect(chargingProfiles[2].profile.chargingSchedule.chargingSchedulePeriod).containSubset(limitMinSinglePhased);
});
+
+ it('Test if Charging Station is excluded, when transaction is not existing anymore', async () => {
+ await testData.chargingStationContext1.stopTransaction(transaction2.id, transaction.tagID, 200, new Date);
+ const chargingProfiles = await smartChargingIntegration.buildChargingProfiles(testData.siteAreaContext.getSiteArea());
+ expect(chargingProfiles.length).to.be.eq(2);
+ // Charging Profiles should have limits according the sent meter values (+ buffer)
+ TestData.validateChargingProfile(chargingProfiles[0], transaction);
+ expect(chargingProfiles[0].profile.chargingSchedule.chargingSchedulePeriod).containSubset(limitMinThreePhased);
+ TestData.validateChargingProfile(chargingProfiles[1], transaction1);
+ expect(chargingProfiles[1].profile.chargingSchedule.chargingSchedulePeriod).containSubset([
+ {
+ 'startPeriod': 0,
+ 'limit': Utils.roundTo(24 * 3 * aCBufferFactor, 3)
+ },
+ {
+ 'startPeriod': 900,
+ 'limit': Utils.roundTo(24 * 3 * aCBufferFactor, 3)
+ },
+ {
+ 'startPeriod': 1800,
+ 'limit': Utils.roundTo(24 * 3 * aCBufferFactor, 3)
+ }
+ ]);
+ // Check adjustment of site area limit
+ const log = await LoggingStorage.getLogs(testData.tenantContext.getTenant().id, { actions: [ServerAction.SMART_CHARGING], search: 'currently being used' }, Constants.DB_PARAMS_SINGLE_RECORD, null);
+ const chargingStation = testData.chargingStationContext1.getChargingStation();
+ const siteArea = testData.siteAreaContext.getSiteArea();
+ const siteAreaLimitPerPhase = Utils.createDecimal(siteArea.maximumPower).div(siteArea.voltage).div(3).toNumber();
+ const connectorLimit = Utils.createDecimal(Utils.getChargingStationAmperage(chargingStation, null, transaction2.connectorId)).toNumber();
+ expect(log.result[0].detailedMessages).include('"fusePhase1": ' + (siteAreaLimitPerPhase - connectorLimit));
+ expect(log.result[0].detailedMessages).include('"fusePhase2": ' + siteAreaLimitPerPhase);
+ expect(log.result[0].detailedMessages).include('"fusePhase3": ' + siteAreaLimitPerPhase);
+ });
+
+ it('Test if Charging Stations are excluded, when transactions are not existing anymore', async () => {
+ await testData.chargingStationContext.stopTransaction(transaction.id, transaction.tagID, 200, new Date);
+ await smartChargingIntegration.buildChargingProfiles(testData.siteAreaContext.getSiteArea());
+ const log = await LoggingStorage.getLogs(testData.tenantContext.getTenant().id, { actions: [ServerAction.SMART_CHARGING], search: 'currently being used' }, Constants.DB_PARAMS_SINGLE_RECORD, null);
+ const siteArea = testData.siteAreaContext.getSiteArea();
+ const siteAreaLimitPerPhase = Utils.createDecimal(siteArea.maximumPower).div(siteArea.voltage).div(3).toNumber();
+ const connectorLimitSinglePhased = Utils.createDecimal(
+ Utils.getChargingStationAmperage(testData.chargingStationContext1.getChargingStation(), null, transaction2.connectorId)).toNumber();
+ const chargingStationLimitThreePhased = Utils.createDecimal(
+ Utils.getChargingStationAmperage(testData.chargingStationContext.getChargingStation())).div(3).toNumber();
+ expect(log.result[0].detailedMessages).include('"fusePhase1": ' + (siteAreaLimitPerPhase - connectorLimitSinglePhased - chargingStationLimitThreePhased));
+ expect(log.result[0].detailedMessages).include('"fusePhase2": ' + (siteAreaLimitPerPhase - chargingStationLimitThreePhased));
+ expect(log.result[0].detailedMessages).include('"fusePhase3": ' + (siteAreaLimitPerPhase - chargingStationLimitThreePhased));
+ });
});
describe('Test for single phased site area', () => {

test for smart charging transaction error