Skip to content

Commit 3b1759e

Browse files
committed
fix TC_056_CS - Ensures that TxDefaultProfile appears in composite schedule even without active transaction
1 parent 0455ec0 commit 3b1759e

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/MicroOcpp/Model/SmartCharging/SmartChargingService.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void SmartChargingConnector::calculateLimit(const Timestamp &t, ChargeRate& limi
5353
}
5454

5555
//if no TxProfile limits charging, check the TxDefaultProfiles for this connector
56-
if (!txLimitDefined && trackTxStart < MAX_TIME) {
56+
if (!txLimitDefined) {
5757
for (int i = MO_ChargeProfileMaxStackLevel; i >= 0; i--) {
5858
if (TxDefaultProfile[i]) {
5959
ChargeRate crOut;
@@ -68,7 +68,7 @@ void SmartChargingConnector::calculateLimit(const Timestamp &t, ChargeRate& limi
6868
}
6969

7070
//if no appropriate TxDefaultProfile is set for this connector, search in the general TxDefaultProfiles
71-
if (!txLimitDefined && trackTxStart < MAX_TIME) {
71+
if (!txLimitDefined) {
7272
for (int i = MO_ChargeProfileMaxStackLevel; i >= 0; i--) {
7373
if (ChargePointTxDefaultProfile[i]) {
7474
ChargeRate crOut;

tests/SmartCharging.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
#define SCPROFILE_10_ABSOLUTE_LIMIT_5KW "[2,\"testmsg\",\"SetChargingProfile\",{\"connectorId\":0,\"csChargingProfiles\":{\"chargingProfileId\":10,\"stackLevel\":0,\"chargingProfilePurpose\":\"ChargePointMaxProfile\",\"chargingProfileKind\":\"Absolute\",\"chargingSchedule\":{\"startSchedule\":\"2023-01-01T00:00:00.000Z\",\"chargingRateUnit\":\"W\",\"chargingSchedulePeriod\":[{\"startPeriod\":0,\"limit\":5000,\"numberPhases\":3}]}}}]"
3939

40+
#define TC_056_CS_TXDEFPROFILE_ABSOLUTE_6A "[2,\"testmsg\",\"SetChargingProfile\",{\"connectorId\":1,\"csChargingProfiles\":{\"chargingProfileId\":41,\"stackLevel\":0,\"chargingProfilePurpose\":\"TxDefaultProfile\",\"chargingProfileKind\":\"Absolute\",\"validFrom\":\"2023-01-01T00:00:00Z\",\"validTo\":\"2023-01-01T00:06:00Z\",\"chargingSchedule\":{\"duration\":304,\"startSchedule\":\"2023-01-01T00:00:00Z\",\"chargingRateUnit\":\"A\",\"chargingSchedulePeriod\":[{\"startPeriod\":0,\"limit\":6.000000,\"numberPhases\":1}]}}}]"
41+
4042

4143
using namespace MicroOcpp;
4244

@@ -836,6 +838,26 @@ TEST_CASE( "SmartCharging" ) {
836838
REQUIRE( checkProcessed );
837839
}
838840

841+
SECTION("TC_056_CS - Ensures that TxDefaultProfile appears in composite schedule even without active transaction") {
842+
843+
loop();
844+
// Ensure no active transaction
845+
REQUIRE(getTransaction() == nullptr);
846+
847+
// Set the TxDefaultProfile as per OCTT TC_056_CS specification
848+
loopback.sendTXT(TC_056_CS_TXDEFPROFILE_ABSOLUTE_6A, strlen(TC_056_CS_TXDEFPROFILE_ABSOLUTE_6A));
849+
loop();
850+
851+
// Get composite schedule and verify the limit is 6A (not -1 indicating no limit)
852+
auto schedule = scService->getCompositeSchedule(1, 300, ChargingRateUnitType_Optional::Amp);
853+
REQUIRE(schedule);
854+
REQUIRE(schedule->chargingSchedulePeriod.size() > 0);
855+
856+
// "Limit 1 should be 6.000000" as per OCTT test case
857+
REQUIRE(schedule->chargingSchedulePeriod[0].limit == Approx(6.0f));
858+
REQUIRE(schedule->chargingSchedulePeriod[0].numberPhases == 1);
859+
}
860+
839861
scService->clearChargingProfile([] (int, int, ChargingProfilePurposeType, int) {
840862
return true;
841863
});

0 commit comments

Comments
 (0)