Skip to content

Commit 083f324

Browse files
committed
Address review comments from Boris
1 parent 1db507a commit 083f324

File tree

4 files changed

+33
-46
lines changed

4 files changed

+33
-46
lines changed

examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementDelegateImpl.h

+20-19
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate
5454
* @param duration The duration that the ESA SHALL maintain the requested power for.
5555
* @return Success if the adjustment is accepted; otherwise the command SHALL be rejected with appropriate error.
5656
*/
57-
virtual chip::Protocols::InteractionModel::Status PowerAdjustRequest(const int64_t powerMw, const uint32_t durationS,
58-
AdjustmentCauseEnum cause) override;
57+
chip::Protocols::InteractionModel::Status PowerAdjustRequest(const int64_t powerMw, const uint32_t durationS,
58+
AdjustmentCauseEnum cause) override;
5959

6060
/**
6161
* @brief Make the ESA end the active power adjustment session & return to normal (or idle) power levels.
6262
* The ESA SHALL also generate an PowerAdjustEnd Event and the ESAState SHALL be restored to Online.
6363
*
6464
* @return It should report SUCCESS if successful and FAILURE otherwise.
6565
*/
66-
virtual chip::Protocols::InteractionModel::Status CancelPowerAdjustRequest() override;
66+
chip::Protocols::InteractionModel::Status CancelPowerAdjustRequest() override;
6767

6868
/**
6969
* @brief The ESA SHALL update its Forecast attribute with the RequestedStartTime including a new ForecastID.
@@ -81,8 +81,8 @@ class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate
8181
* @return Success if the StartTime in the Forecast is updated, otherwise the command SHALL be rejected with appropriate
8282
* IM_Status.
8383
*/
84-
virtual chip::Protocols::InteractionModel::Status StartTimeAdjustRequest(const uint32_t requestedStartTimeUtc,
85-
AdjustmentCauseEnum cause) override;
84+
chip::Protocols::InteractionModel::Status StartTimeAdjustRequest(const uint32_t requestedStartTimeUtc,
85+
AdjustmentCauseEnum cause) override;
8686

8787
/**
8888
* @brief Handler for PauseRequest command
@@ -97,7 +97,7 @@ class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate
9797
* @param duration Duration that the ESA SHALL be paused for.
9898
* @return Success if the ESA is paused, otherwise returns other IM_Status.
9999
*/
100-
virtual chip::Protocols::InteractionModel::Status PauseRequest(const uint32_t durationS, AdjustmentCauseEnum cause) override;
100+
chip::Protocols::InteractionModel::Status PauseRequest(const uint32_t durationS, AdjustmentCauseEnum cause) override;
101101

102102
/**
103103
* @brief Handler for ResumeRequest command
@@ -108,7 +108,7 @@ class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate
108108
*
109109
* @return Success if the ESA is resumed, otherwise returns other IM_Status.
110110
*/
111-
virtual chip::Protocols::InteractionModel::Status ResumeRequest() override;
111+
chip::Protocols::InteractionModel::Status ResumeRequest() override;
112112

113113
/**
114114
* @brief Handler for ModifyForecastRequest
@@ -126,7 +126,7 @@ class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate
126126
* @return Success if the entire list of SlotAdjustmentStruct are accepted, otherwise the command
127127
* SHALL be rejected returning other IM_Status.
128128
*/
129-
virtual chip::Protocols::InteractionModel::Status
129+
chip::Protocols::InteractionModel::Status
130130
ModifyForecastRequest(const uint32_t forecastID,
131131
const DataModel::DecodableList<Structs::SlotAdjustmentStruct::DecodableType> & slotAdjustments,
132132
AdjustmentCauseEnum cause) override;
@@ -142,7 +142,7 @@ class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate
142142
* @param constraints Sequence of turn up/down power requests that the ESA is being asked to constrain its operation within.
143143
* @return Success if successful, otherwise the command SHALL be rejected returning other IM_Status.
144144
*/
145-
virtual chip::Protocols::InteractionModel::Status
145+
chip::Protocols::InteractionModel::Status
146146
RequestConstraintBasedForecast(const DataModel::DecodableList<Structs::ConstraintsStruct::DecodableType> & constraints,
147147
AdjustmentCauseEnum cause) override;
148148

@@ -163,22 +163,23 @@ class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate
163163
*
164164
* @return Success if successful, otherwise the command SHALL be rejected returning other IM_Status.
165165
*/
166-
virtual chip::Protocols::InteractionModel::Status CancelRequest() override;
166+
chip::Protocols::InteractionModel::Status CancelRequest() override;
167167

168168
// ------------------------------------------------------------------
169169
// Overridden DeviceEnergyManagement::Delegate Get attribute methods
170-
virtual ESATypeEnum GetESAType() override;
171-
virtual bool GetESACanGenerate() override;
172-
virtual ESAStateEnum GetESAState() override;
173-
virtual int64_t GetAbsMinPower() override;
174-
virtual int64_t GetAbsMaxPower() override;
175-
virtual const DataModel::Nullable<Structs::PowerAdjustCapabilityStruct::Type> & GetPowerAdjustmentCapability() override;
176-
virtual const DataModel::Nullable<Structs::ForecastStruct::Type> & GetForecast() override;
177-
virtual OptOutStateEnum GetOptOutState() override;
170+
171+
ESATypeEnum GetESAType() override;
172+
bool GetESACanGenerate() override;
173+
ESAStateEnum GetESAState() override;
174+
int64_t GetAbsMinPower() override;
175+
int64_t GetAbsMaxPower() override;
176+
const DataModel::Nullable<Structs::PowerAdjustCapabilityStruct::Type> & GetPowerAdjustmentCapability() override;
177+
const DataModel::Nullable<Structs::ForecastStruct::Type> & GetForecast() override;
178+
OptOutStateEnum GetOptOutState() override;
178179

179180
// ------------------------------------------------------------------
180181
// Overridden DeviceEnergyManagement::Delegate Set attribute methods
181-
virtual CHIP_ERROR SetESAState(ESAStateEnum) override;
182+
CHIP_ERROR SetESAState(ESAStateEnum) override;
182183

183184
// Local Set methods
184185
CHIP_ERROR SetESAType(ESATypeEnum);

examples/energy-management-app/energy-management-common/include/EnergyTimeUtils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ CHIP_ERROR GetEpochTS(uint32_t & chipEpoch);
4646
* @param unixEpoch (as time_t)
4747
*
4848
* @return bitmap value for day of week
49-
* Sunday = 0x01, Monday = 0x01 ... Saturday = 0x40 (1<<6)
49+
* Sunday = 0x00, Monday = 0x01 ... Saturday = 0x40 (1<<6)
5050
*/
5151
uint8_t GetLocalDayOfWeekFromUnixEpoch(time_t unixEpoch);
5252

@@ -55,7 +55,7 @@ uint8_t GetLocalDayOfWeekFromUnixEpoch(time_t unixEpoch);
5555
*
5656
* @param reference to hold the day of week as a bitmap
5757
*
58-
* Sunday = 0x01, Monday = 0x01 ... Saturday = 0x40 (1<<6)
58+
* Sunday = 0x00, Monday = 0x01 ... Saturday = 0x40 (1<<6)
5959
*/
6060
CHIP_ERROR GetLocalDayOfWeekNow(uint8_t & dayOfWeekMap);
6161

examples/energy-management-app/energy-management-common/include/FakeReadings.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class FakeReadings
4242
* @param[in] aCurrentRandomness_mA This is used to define the max randomness of the
4343
* random current values
4444
* @param[in] aInterval_s - the callback interval in seconds
45-
* @param[in] bReset - boolean: true will reset the energy values to 0
45+
* @param[in] aReset - boolean: true will reset the energy values to 0
4646
*/
4747
void StartFakeReadings(chip::EndpointId aEndpointId, int64_t aPower_mW, uint32_t aPowerRandomness_mW, int64_t aVoltage_mV,
4848
uint32_t aVoltageRandomness_mV, int64_t aCurrent_mA, uint32_t aCurrentRandomness_mA, uint8_t aInterval_s,
49-
bool bReset);
49+
bool aReset);
5050

5151
/**
5252
* @brief Stops any active updates to the fake load data callbacks

examples/energy-management-app/energy-management-common/src/DEMTestEventTriggers.cpp

+9-23
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ CHIP_ERROR ConfigureForecast(uint16_t numSlots)
6363
}
6464

6565
// planned start time, in UTC, for the entire Forecast.
66-
sForecastStruct.startTime = static_cast<uint32_t>(chipEpoch);
66+
sForecastStruct.startTime = chipEpoch;
6767

6868
// earliest start time, in UTC, that the entire Forecast can be shifted to. null value indicates that it can be started
6969
// immediately.
7070
sForecastStruct.earliestStartTime = MakeOptional(DataModel::MakeNullable(chipEpoch));
7171

7272
// planned end time, in UTC, for the entire Forecast.
73-
sForecastStruct.endTime = static_cast<uint32_t>(chipEpoch * 3);
73+
sForecastStruct.endTime = chipEpoch * 3;
7474

7575
// latest end time, in UTC, for the entire Forecast
7676
sForecastStruct.latestEndTime = MakeOptional(chipEpoch * 3);
@@ -133,11 +133,8 @@ CHIP_ERROR ConfigureForecast(uint16_t numSlots)
133133

134134
sForecastStruct.slots = DataModel::List<const DeviceEnergyManagement::Structs::SlotStruct::Type>(sSlots, numSlots);
135135

136-
DataModel::Nullable<DeviceEnergyManagement::Structs::ForecastStruct::Type> forecast(sForecastStruct);
137-
138136
EVSEManufacturer * mn = GetEvseManufacturer();
139-
mn->GetDEMDelegate()->SetForecast(forecast);
140-
137+
mn->GetDEMDelegate()->SetForecast(DataModel::MakeNullable(sForecastStruct));
141138
mn->GetDEMDelegate()->SetAbsMinPower(1000);
142139
mn->GetDEMDelegate()->SetAbsMaxPower(256 * 2000 * 1000);
143140

@@ -216,9 +213,7 @@ void SetTestEventTrigger_StartTimeAdjustment()
216213
// Latest end time, in UTC, for the entire Forecast which is > sForecastStruct.endTime
217214
sForecastStruct.latestEndTime = Optional<uint32_t>(static_cast<uint32_t>(chipEpoch * 3 + 60));
218215

219-
DataModel::Nullable<DeviceEnergyManagement::Structs::ForecastStruct::Type> forecast(sForecastStruct);
220-
221-
GetDEMDelegate()->SetForecast(forecast);
216+
GetDEMDelegate()->SetForecast(DataModel::MakeNullable(sForecastStruct));
222217
}
223218

224219
void SetTestEventTrigger_StartTimeAdjustmentClear()
@@ -232,9 +227,7 @@ void SetTestEventTrigger_StartTimeAdjustmentClear()
232227
sForecastStruct.earliestStartTime = Optional<DataModel::Nullable<uint32_t>>();
233228
sForecastStruct.latestEndTime = Optional<uint32_t>();
234229

235-
DataModel::Nullable<DeviceEnergyManagement::Structs::ForecastStruct::Type> forecast(sForecastStruct);
236-
237-
GetDEMDelegate()->SetForecast(forecast);
230+
GetDEMDelegate()->SetForecast(DataModel::MakeNullable(sForecastStruct));
238231
}
239232

240233
void SetTestEventTrigger_UserOptOutOptimization(OptOutStateEnum optOutState)
@@ -253,9 +246,7 @@ void SetTestEventTrigger_PausableNextSlot()
253246
sForecastStruct = GetDEMDelegate()->GetForecast().Value();
254247
sForecastStruct.activeSlotNumber.SetNonNull(1);
255248

256-
DataModel::Nullable<DeviceEnergyManagement::Structs::ForecastStruct::Type> forecast(sForecastStruct);
257-
258-
GetDEMDelegate()->SetForecast(forecast);
249+
GetDEMDelegate()->SetForecast(DataModel::MakeNullable(sForecastStruct));
259250
}
260251

261252
void SetTestEventTrigger_Forecast()
@@ -273,9 +264,7 @@ void SetTestEventTrigger_ForecastClear()
273264
sForecastStruct.activeSlotNumber.SetNull();
274265
sForecastStruct.slots = DataModel::List<const DeviceEnergyManagement::Structs::SlotStruct::Type>();
275266

276-
DataModel::Nullable<DeviceEnergyManagement::Structs::ForecastStruct::Type> forecast(sForecastStruct);
277-
278-
GetDEMDelegate()->SetForecast(forecast);
267+
GetDEMDelegate()->SetForecast(DataModel::MakeNullable(sForecastStruct));
279268
}
280269

281270
void SetTestEventTrigger_ForecastAdjustment()
@@ -291,18 +280,15 @@ void SetTestEventTrigger_ForecastAdjustment()
291280

292281
sForecastStruct.slots = DataModel::List<const DeviceEnergyManagement::Structs::SlotStruct::Type>(sSlots, 2);
293282

294-
DataModel::Nullable<DeviceEnergyManagement::Structs::ForecastStruct::Type> forecast(sForecastStruct);
295-
296-
GetDEMDelegate()->SetForecast(forecast);
283+
GetDEMDelegate()->SetForecast(DataModel::MakeNullable(sForecastStruct));
297284
}
298285

299286
void SetTestEventTrigger_ForecastAdjustmentNextSlot()
300287
{
301288
sForecastStruct = GetDEMDelegate()->GetForecast().Value();
302289
sForecastStruct.activeSlotNumber.SetNonNull(sForecastStruct.activeSlotNumber.Value() + 1);
303-
DataModel::Nullable<DeviceEnergyManagement::Structs::ForecastStruct::Type> forecast(sForecastStruct);
304290

305-
GetDEMDelegate()->SetForecast(forecast);
291+
GetDEMDelegate()->SetForecast(DataModel::MakeNullable(sForecastStruct));
306292
}
307293

308294
void SetTestEventTrigger_ConstraintBasedAdjustment()

0 commit comments

Comments
 (0)