Skip to content

Commit d469ba0

Browse files
committed
Put time util funtions into namespace + drop the Utils prefix
1 parent c55ca01 commit d469ba0

File tree

6 files changed

+35
-21
lines changed

6 files changed

+35
-21
lines changed

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

-7
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626

2727
using chip::Protocols::InteractionModel::Status;
2828

29-
/**
30-
* @brief Helper function to get current timestamp in Epoch format
31-
*
32-
* @param chipEpoch reference to hold return timestamp
33-
*/
34-
CHIP_ERROR GetEpochTS(uint32_t & chipEpoch);
35-
3629
namespace chip {
3730
namespace app {
3831
namespace Clusters {

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

+14-3
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@
2525

2626
using chip::Protocols::InteractionModel::Status;
2727

28+
namespace chip {
29+
namespace app {
30+
namespace Clusters {
31+
namespace DeviceEnergyManagement {
32+
2833
/**
2934
* @brief Helper function to get current timestamp in Epoch format
3035
*
3136
* @param chipEpoch reference to hold return timestamp
3237
*/
33-
CHIP_ERROR UtilsGetEpochTS(uint32_t & chipEpoch);
38+
CHIP_ERROR GetEpochTS(uint32_t & chipEpoch);
3439

3540
/**
3641
* @brief Helper function to get current timestamp and work out the day of week
@@ -44,7 +49,7 @@ CHIP_ERROR UtilsGetEpochTS(uint32_t & chipEpoch);
4449
* @return bitmap value for day of week
4550
* Sunday = 0x01, Monday = 0x01 ... Saturday = 0x40 (1<<6)
4651
*/
47-
uint8_t UtilsGetLocalDayOfWeekFromUnixEpoch(time_t unixEpoch);
52+
uint8_t GetLocalDayOfWeekFromUnixEpoch(time_t unixEpoch);
4853

4954
/**
5055
* @brief Helper function to get current timestamp and work out the day of week based on localtime
@@ -53,4 +58,10 @@ uint8_t UtilsGetLocalDayOfWeekFromUnixEpoch(time_t unixEpoch);
5358
*
5459
* Sunday = 0x01, Monday = 0x01 ... Saturday = 0x40 (1<<6)
5560
*/
56-
CHIP_ERROR UtilsGetLocalDayOfWeekNow(uint8_t & dayOfWeekMap);
61+
CHIP_ERROR GetLocalDayOfWeekNow(uint8_t & dayOfWeekMap);
62+
63+
} // namespace DeviceEnergyManagement
64+
} // namespace Clusters
65+
} // namespace app
66+
} // namespace chip
67+

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ CHIP_ERROR ConfigureForecast(uint16_t numSlots)
5555
{
5656
uint32_t chipEpoch = 0;
5757

58-
CHIP_ERROR err = UtilsGetEpochTS(chipEpoch);
58+
CHIP_ERROR err = GetEpochTS(chipEpoch);
5959
if (err != CHIP_NO_ERROR)
6060
{
6161
ChipLogError(Support, "ConfigureForecast could not get time");
@@ -198,7 +198,7 @@ void SetTestEventTrigger_StartTimeAdjustment()
198198

199199
uint32_t chipEpoch = 0;
200200

201-
CHIP_ERROR err = UtilsGetEpochTS(chipEpoch);
201+
CHIP_ERROR err = GetEpochTS(chipEpoch);
202202
if (err != CHIP_NO_ERROR)
203203
{
204204
ChipLogError(Support, "ConfigureForecast_EarliestStartLatestEndTimes could not get time");

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Status DeviceEnergyManagementDelegate::PowerAdjustRequest(const int64_t powerMw,
9292
sendEvent = true;
9393

9494
// Record when this PowerAdjustment starts. Note if we do not set this value if a PowerAdjustment is in progress
95-
CHIP_ERROR err = UtilsGetEpochTS(mPowerAdjustmentStartTimeUtc);
95+
CHIP_ERROR err = GetEpochTS(mPowerAdjustmentStartTimeUtc);
9696
if (err != CHIP_NO_ERROR)
9797
{
9898
ChipLogError(AppServer, "Unable to get time: %" CHIP_ERROR_FORMAT, err.Format());
@@ -286,7 +286,7 @@ CHIP_ERROR DeviceEnergyManagementDelegate::SendPowerAdjustEndEvent(CauseEnum cau
286286
event.cause = cause;
287287

288288
uint32_t timeNowUtc;
289-
CHIP_ERROR err = UtilsGetEpochTS(timeNowUtc);
289+
CHIP_ERROR err = GetEpochTS(timeNowUtc);
290290
if (err == CHIP_NO_ERROR)
291291
{
292292
event.duration = timeNowUtc - mPowerAdjustmentStartTimeUtc;

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

+14-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ using namespace chip::app::Clusters::EnergyEvse::Attributes;
3131
using chip::app::LogEvent;
3232
using chip::Protocols::InteractionModel::Status;
3333

34+
namespace chip {
35+
namespace app {
36+
namespace Clusters {
37+
namespace DeviceEnergyManagement {
38+
3439
/**
3540
* @brief Helper function to get current timestamp in Epoch format
3641
*
3742
* @param[out] chipEpoch reference to hold return timestamp. Set to 0 if an error occurs.
3843
*/
39-
CHIP_ERROR UtilsGetEpochTS(uint32_t & chipEpoch)
44+
CHIP_ERROR GetEpochTS(uint32_t & chipEpoch)
4045
{
4146
chipEpoch = 0;
4247

@@ -78,7 +83,7 @@ CHIP_ERROR UtilsGetEpochTS(uint32_t & chipEpoch)
7883
* @return bitmap value for day of week
7984
* Sunday = 0x01, Monday = 0x01 ... Saturday = 0x40 (1<<6)
8085
*/
81-
uint8_t UtilsGetLocalDayOfWeekFromUnixEpoch(time_t unixEpoch)
86+
uint8_t GetLocalDayOfWeekFromUnixEpoch(time_t unixEpoch)
8287
{
8388
// Define a timezone structure and initialize it to the local timezone
8489
// This will capture any daylight saving time changes
@@ -100,7 +105,7 @@ uint8_t UtilsGetLocalDayOfWeekFromUnixEpoch(time_t unixEpoch)
100105
*
101106
* Sunday = 0x01, Monday = 0x01 ... Saturday = 0x40 (1<<6)
102107
*/
103-
CHIP_ERROR UtilsGetLocalDayOfWeekNow(uint8_t & dayOfWeekMap)
108+
CHIP_ERROR GetLocalDayOfWeekNow(uint8_t & dayOfWeekMap)
104109
{
105110
chip::System::Clock::Milliseconds64 cTMs;
106111
CHIP_ERROR err = chip::System::SystemClock().GetClock_RealTimeMS(cTMs);
@@ -110,7 +115,12 @@ CHIP_ERROR UtilsGetLocalDayOfWeekNow(uint8_t & dayOfWeekMap)
110115
return err;
111116
}
112117
time_t unixEpoch = std::chrono::duration_cast<chip::System::Clock::Seconds32>(cTMs).count();
113-
dayOfWeekMap = UtilsGetLocalDayOfWeekFromUnixEpoch(unixEpoch);
118+
dayOfWeekMap = GetLocalDayOfWeekFromUnixEpoch(unixEpoch);
114119

115120
return CHIP_NO_ERROR;
116121
}
122+
123+
} // namespace DeviceEnergyManagement
124+
} // namespace Clusters
125+
} // namespace app
126+
} // namespace chip

src/python_testing/matter_testing_support.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ def wait_for_event_report(self, expected_event: ClusterObjects.ClusterEvent, tim
265265
asserts.assert_equal(res.Header.EventId, expected_event.event_id, "Expected event ID not found in event report")
266266
return res.Data
267267

268-
def wait_for_event_expect_no_report(self, timeout: int = 10):
269-
"""This function succceeds/returns if an event does not arrive within the timeout.
268+
def wait_for_event_expect_no_report(self, timeoutS: int = 10):
269+
"""This function succceeds/returns if an event does not arrive within the timeout specified in seconds.
270270
If an event does arrive, an assert is called."""
271271
try:
272-
res = self._q.get(block=True, timeout=timeout)
272+
res = self._q.get(block=True, timeout=timeoutS)
273273
except queue.Empty:
274274
return
275275

0 commit comments

Comments
 (0)