Skip to content

Commit ab1a2d5

Browse files
jamesharrowhastyrestyled-commits
authored
Add Electrical power measurement to energy management app (#31616)
* Hoist shared enums and bitmaps into detail namespace * Regenerate * Add electrical measurement clusters * Add NumberOfMeasurements attribute * Bump to latest spec * Bump ZAP version * Remove Electrical Measurement cluster * Add initial Electrical Power Measurement cluster implementation * Revert "Remove Electrical Measurement cluster" This reverts commit 47f5298. * Fix incorrect min/max values on energy attributes * Formatting electrical-power-measurement-server * Regen after restoring deprecated electrical measurement cluster * Re-add inexplicably important blank line to zap_execution.py * De-alphabetize list of files to avoid breaking GH action * Semi-realphabetize? * Added EPM cluster to Energy Management App * Restore strangely dropped events * Better BitMask handling * Change min/max on electrical measurements to be decimal instead of hex * Rename meas-and-sense to measurement-and-sensing.xml * Remove seemingly superfluous attribute requirements on Descriptor cluster on Electrical Measurement * Updates to electrical-power-measurement-server based on comments * Take all-clusters-zap from upstream-master. * Added side=server into electrical-power and electrical-energy clusters XML so events can be enabled in ZAP * Updated all-clusters.zap and reran autogen. Added EPM cluster to energy-management-app.zap * Added initial version of EPM delegate and instance to energy-management-app * Enabled Electrical Energy Measurement in example-energy-management-app ZAP and regen all. * Added ElectricalEnergyMeasurement to chip-repl __init__.py * Restyled by isort * Changed feature map to indicate CUME and IMP support only * Adding into __all__ some missing clusters which are causing flake8 issues. * Removed out of date comment * Added a test event trigger to fake energy reporting readings into the EEM cluster (hooks ready for EPM cluster) * Added new Energy Reporting TE Trigger delegate * Updated random calculation and scaled into mWh (divide by 3600) * Restyled by whitespace * Restyled by gn * Removed accidental launch.json inclusion * Fix for ARM linux etc builds due to gn dependency check error * Added code review suggestions. * More code review suggestions fixed. * Hoist shared enums and bitmaps into detail namespace * Regenerate * Add electrical measurement clusters * Add NumberOfMeasurements attribute * Bump to latest spec * Bump ZAP version * Remove Electrical Measurement cluster * Add initial Electrical Power Measurement cluster implementation * Revert "Remove Electrical Measurement cluster" This reverts commit 47f5298. * Fix incorrect min/max values on energy attributes * Formatting electrical-power-measurement-server * Regen after restoring deprecated electrical measurement cluster * Re-add inexplicably important blank line to zap_execution.py * De-alphabetize list of files to avoid breaking GH action * Semi-realphabetize? * Restore strangely dropped events * Better BitMask handling * Change min/max on electrical measurements to be decimal instead of hex * Rename meas-and-sense to measurement-and-sensing.xml * Remove seemingly superfluous attribute requirements on Descriptor cluster on Electrical Measurement * Updates to electrical-power-measurement-server based on comments * Remove defaults from MeasurementAccuracyRangeStruct to match spec update * Restore side="server" to events * Move common enums and bitmaps to detail:: instead of detail::Enums and detail::Bitmaps; remove superfluous using statement * Assign ID to Electrical Sensor device type * Removed EPM and EEM from Root Node Device * Restyled formatting is different than clang-format * Re-add FeatureMap to attributeAccessInterfaceAttributes for EEM and EPM * Regen after merge * Added electrical-energy-measurement-server to CMakelist to fix linker issue. * Lock client on Electrical Sensor device type * Remove unneeded using statement now that Enums are in detail:: * Check for null iterators and error * Switch to ResourceExhausted from CHIP_ERROR_INTERNAL * Re-enabled EEM in energy management app and regen all after previous merge * Some refactoring to add EPM Instance into the EVSEManufacturer class to clean up containment. Added ability to fake voltage, power and current to the TE triggers. * Missed one file. * Fixed crash due to unassigned dg pointer. Power/Voltage/Current faking working too. * Touch file since restyled crashed * Restyled by gn * Restyled by isort * Add stub for EPM cluster * Reverted whitespace change * Did regen_all after merge from master to resolve conflicts. * Put back line of clusters which somehow got deleted accidentally. * Remerged ZAP file and regen all after resolving conflicts. * Fixes for Python tests * Correct name for Ember init callback * Formatting * Sync optional attributes list with .zap file for EPM * Add missing features to EPM stub * Revert FeatureMap in attributeAccessInterfaceAttributes * Allow FeatureMap in EEM constructor; add all-clusters-app EEM stub * Forgot zcl-with-test-extensions * Unregister EEM attribute access in destructor * Remove redundant returns to keep clang-tidy happy * Fix for issue mentioned in code review on EEM cluster limiting the number of endpoints it allows. * Refactoring to have a common EvseMain across all platforms to avoid making changes in multiple places * Added electrical-power-measurement-server to ESP32 CMakeLists.txt * Updated Matter device types to add EVSE * Open and saved energy-management-app.zap and regen_all * Removed duplicate ElectricalEnergyMeasurment class which was accidentally merged in. Fixed issue raised about ElectricalEnergyMeasurement array size not working on bridges. * Added support for test event triggers and handling of reading events into matter_testing_support. * Made TC_EEVSE_Utils.py use the matter_testing_support instead of its own local copy. * Restyled by isort * Cherry pick from Tweaks to EVSE Test plans (Issue #31460) * Changed the random value generation to make the values +/- and handle sign conversion to avoid compile warnings * Enabled cumulativeEnergyExported in Energy-management-app. * Added initial electrical power measurement 2.2 test case * Changed copyright date * Code review comment fixes. * Changed to c++ style cast * Fixed trailing whitepace * Added support for testing read of EEM attributes and change of values * Corrected EPM references in TC_EEM_2_2. Added TC_EEM_2_3 * Added periodic energy reporting, and new cumulativeEnergyReset attribute into energy-management-app.zap * Added periodic energy reading support and TC_EEM_2_3 to 2_5. * Python removed unused logging and EventChangeCallback * Updates to align to test plan PR #3949 * Added initial EEM_2_1 test script. * Added example of setting EEM Accuracy and EEM CumulativeEnergyReset structure - TC_EEM_2_1 now passes * Restyled by whitespace * Restyled * Removed extra spaces in TC_EEM_2_1.py * Removed unused EnergyManagementManager.cpp/.h * Fixed PowerMode = kAc * Initial TC_EPM_2_1.py script * Restyled by isort * Merged TC_EEVSE tests back in * Initialized NumberOfMeasurementTypes * Added EEM 2.1,2.2,2.3,2.4,2.5 and EPM 2.1,2.2 into CI workflow tests.yaml * Interim state - partially refactored how Measurement Structs are encoded similar to how ModeBase clusters are implemented. Needs tidy up. Will break all-clusters for now * Removed SetNumberOfMeasurementTypes since this can be derived from the ArraySize(kMeasurementAccuracies). Added more stringent checking in test script of measurementTypes and ranges. * Completed TC_EPM_2_1.py script * Corrected test plan spec reference. * Test EPM_2_1 now runs and passes. Allows checking that attributes are supported, and skips test if not. Validation of values ignores Nulls (which are allowed). Turned on Ranges attribute. * Revert unintended change to tests.yaml * Python test case code-review updates * Removed old range iterator. * Fixed lint issues and adjusted timings to match the test plan pr. * Fixed all-clusters electrical-power-measurement cluster by using the energy-management-app/common Delegate * Implemented HarmonicCurrents and HarmonicStructs (to return empty list for now) * Changed the API to ensure that a delegate doesn't change the data mid-way through a read, so the cluster server signals with a StartxxxRead and EndxxxRead call * Applying suggested changes * Incorporated feedback from review to simplify the code * Removed comment per code review --------- Co-authored-by: Hasty Granbery <hasty@granbery.org> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 24f7fed commit ab1a2d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2501
-934
lines changed

.github/workflows/tests.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,16 @@ jobs:
483483
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lock-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-lock-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DRLK_2_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
484484
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DeviceBasicComposition.py" --script-args "--storage-path admin_storage.json --manual-code 10054912339 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
485485
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lock-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-lock-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DeviceConformance.py" --script-args "--storage-path admin_storage.json --manual-code 10054912339 --bool-arg ignore_in_progress:True allow_provisional:True --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto --tests test_TC_IDM_10_2"'
486+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-energy-management-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_EEM_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
487+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-energy-management-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_EEM_2_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
488+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-energy-management-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_EEM_2_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
489+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-energy-management-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_EEM_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
490+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-energy-management-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_EEM_2_5.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
486491
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-energy-management-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_EEVSE_2_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
487492
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-energy-management-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_EEVSE_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
488493
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-energy-management-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_EEVSE_2_5.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
494+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-energy-management-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_EPM_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
495+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-energy-management-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-energy-management-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_EPM_2_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
489496
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
490497
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
491498
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'

examples/all-clusters-app/all-clusters-common/src/electrical-power-measurement-stub.cpp

+9-223
Original file line numberDiff line numberDiff line change
@@ -16,239 +16,25 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include <app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.h>
19+
#include <ElectricalPowerMeasurementDelegate.h>
2020

2121
using namespace chip;
2222
using namespace chip::app::Clusters;
2323
using namespace chip::app::Clusters::ElectricalPowerMeasurement;
24-
using namespace chip::app::Clusters::ElectricalPowerMeasurement::Structs;
2524

26-
namespace chip {
27-
namespace app {
28-
namespace Clusters {
29-
namespace ElectricalPowerMeasurement {
30-
31-
static MeasurementAccuracyRangeStruct::Type activeCurrentAccuracyRanges[] = { { .rangeMin = 500, .rangeMax = 1000 } };
32-
33-
class StubAccuracyIterator : public Delegate::AccuracyIterator
34-
{
35-
public:
36-
size_t Count() override;
37-
bool Next(MeasurementAccuracyStruct::Type & output) override;
38-
void Release() override;
39-
40-
private:
41-
uint8_t mIndex;
42-
};
43-
44-
size_t StubAccuracyIterator::Count()
45-
{
46-
return 1;
47-
}
48-
49-
bool StubAccuracyIterator::Next(MeasurementAccuracyStruct::Type & output)
50-
{
51-
if (mIndex >= 1)
52-
{
53-
return false;
54-
}
55-
output.measurementType = MeasurementTypeEnum::kActiveCurrent;
56-
output.measured = true;
57-
output.minMeasuredValue = -10000000;
58-
output.maxMeasuredValue = 10000000;
59-
output.accuracyRanges = DataModel::List<const MeasurementAccuracyRangeStruct::Type>(activeCurrentAccuracyRanges);
60-
mIndex++;
61-
return true;
62-
}
63-
64-
void StubAccuracyIterator::Release()
65-
{
66-
mIndex = 0;
67-
}
68-
69-
class StubRangeIterator : public Delegate::RangeIterator
70-
{
71-
public:
72-
size_t Count() override;
73-
bool Next(MeasurementRangeStruct::Type & output) override;
74-
void Release() override;
75-
};
76-
77-
size_t StubRangeIterator::Count()
78-
{
79-
return 0;
80-
}
81-
82-
bool StubRangeIterator::Next(MeasurementRangeStruct::Type & output)
83-
{
84-
return false;
85-
}
86-
87-
void StubRangeIterator::Release() {}
88-
89-
class StubHarmonicMeasurementIterator : public Delegate::HarmonicMeasurementIterator
90-
{
91-
public:
92-
size_t Count() override;
93-
bool Next(HarmonicMeasurementStruct::Type & output) override;
94-
void Release() override;
95-
};
96-
97-
size_t StubHarmonicMeasurementIterator::Count()
98-
{
99-
return 0;
100-
}
101-
102-
bool StubHarmonicMeasurementIterator::Next(HarmonicMeasurementStruct::Type & output)
103-
{
104-
return false;
105-
}
106-
107-
void StubHarmonicMeasurementIterator::Release() {}
108-
109-
static StubAccuracyIterator accuracyIterator;
110-
static StubRangeIterator rangeIterator;
111-
static StubHarmonicMeasurementIterator harmonicMeasurementIterator;
112-
113-
class ElectricalPowerMeasurementDelegate : public Delegate
114-
{
115-
public:
116-
PowerModeEnum GetPowerMode() override;
117-
uint8_t GetNumberOfMeasurementTypes() override;
118-
AccuracyIterator * IterateAccuracy() override;
119-
RangeIterator * IterateRanges() override;
120-
DataModel::Nullable<int64_t> GetVoltage() override;
121-
DataModel::Nullable<int64_t> GetActiveCurrent() override;
122-
DataModel::Nullable<int64_t> GetReactiveCurrent() override;
123-
DataModel::Nullable<int64_t> GetApparentCurrent() override;
124-
DataModel::Nullable<int64_t> GetActivePower() override;
125-
DataModel::Nullable<int64_t> GetReactivePower() override;
126-
DataModel::Nullable<int64_t> GetApparentPower() override;
127-
DataModel::Nullable<int64_t> GetRMSVoltage() override;
128-
DataModel::Nullable<int64_t> GetRMSCurrent() override;
129-
DataModel::Nullable<int64_t> GetRMSPower() override;
130-
DataModel::Nullable<int64_t> GetFrequency() override;
131-
HarmonicMeasurementIterator * IterateHarmonicCurrents() override;
132-
HarmonicMeasurementIterator * IterateHarmonicPhases() override;
133-
DataModel::Nullable<int64_t> GetPowerFactor() override;
134-
DataModel::Nullable<int64_t> GetNeutralCurrent() override;
135-
136-
~ElectricalPowerMeasurementDelegate() = default;
137-
};
138-
139-
PowerModeEnum ElectricalPowerMeasurementDelegate::GetPowerMode()
140-
{
141-
return PowerModeEnum::kAc;
142-
}
143-
144-
uint8_t ElectricalPowerMeasurementDelegate::GetNumberOfMeasurementTypes()
145-
{
146-
return 1;
147-
}
148-
149-
Delegate::AccuracyIterator * ElectricalPowerMeasurementDelegate::IterateAccuracy()
150-
{
151-
return &accuracyIterator;
152-
}
153-
154-
Delegate::RangeIterator * ElectricalPowerMeasurementDelegate::IterateRanges()
155-
{
156-
return &rangeIterator;
157-
}
158-
159-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetVoltage()
160-
{
161-
return {};
162-
}
163-
164-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetActiveCurrent()
165-
{
166-
return {};
167-
}
168-
169-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetReactiveCurrent()
170-
{
171-
return {};
172-
}
173-
174-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetApparentCurrent()
175-
{
176-
return {};
177-
}
178-
179-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetActivePower()
180-
{
181-
return DataModel::Nullable<int64_t>(10000);
182-
}
183-
184-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetReactivePower()
185-
{
186-
return {};
187-
}
188-
189-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetApparentPower()
190-
{
191-
return {};
192-
}
193-
194-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetRMSVoltage()
195-
{
196-
return {};
197-
}
198-
199-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetRMSCurrent()
200-
{
201-
return {};
202-
}
203-
204-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetRMSPower()
205-
{
206-
return {};
207-
}
208-
209-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetFrequency()
210-
{
211-
return {};
212-
}
213-
214-
Delegate::HarmonicMeasurementIterator * ElectricalPowerMeasurementDelegate::IterateHarmonicCurrents()
215-
{
216-
return &harmonicMeasurementIterator;
217-
}
218-
219-
Delegate::HarmonicMeasurementIterator * ElectricalPowerMeasurementDelegate::IterateHarmonicPhases()
220-
{
221-
return &harmonicMeasurementIterator;
222-
}
223-
224-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetPowerFactor()
225-
{
226-
return {};
227-
}
228-
229-
DataModel::Nullable<int64_t> ElectricalPowerMeasurementDelegate::GetNeutralCurrent()
230-
{
231-
return {};
232-
}
233-
234-
} // namespace ElectricalPowerMeasurement
235-
} // namespace Clusters
236-
} // namespace app
237-
} // namespace chip
238-
239-
static std::unique_ptr<ElectricalPowerMeasurement::Delegate> gDelegate;
240-
static std::unique_ptr<ElectricalPowerMeasurement::Instance> gInstance;
25+
static std::unique_ptr<ElectricalPowerMeasurementDelegate> gEPMDelegate;
26+
static std::unique_ptr<ElectricalPowerMeasurementInstance> gEPMInstance;
24127

24228
void emberAfElectricalPowerMeasurementClusterInitCallback(chip::EndpointId endpointId)
24329
{
24430
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
245-
VerifyOrDie(!gInstance);
31+
VerifyOrDie(!gEPMInstance);
24632

247-
gDelegate = std::make_unique<ElectricalPowerMeasurementDelegate>();
248-
if (gDelegate)
33+
gEPMDelegate = std::make_unique<ElectricalPowerMeasurementDelegate>();
34+
if (gEPMDelegate)
24935
{
250-
gInstance = std::make_unique<Instance>(
251-
endpointId, *gDelegate,
36+
gEPMInstance = std::make_unique<ElectricalPowerMeasurementInstance>(
37+
endpointId, *gEPMDelegate,
25238
BitMask<Feature, uint32_t>(Feature::kDirectCurrent, Feature::kAlternatingCurrent, Feature::kPolyphasePower,
25339
Feature::kHarmonics, Feature::kPowerQuality),
25440
BitMask<OptionalAttributes, uint32_t>(
@@ -260,6 +46,6 @@ void emberAfElectricalPowerMeasurementClusterInitCallback(chip::EndpointId endpo
26046
OptionalAttributes::kOptionalAttributeFrequency, OptionalAttributes::kOptionalAttributePowerFactor,
26147
OptionalAttributes::kOptionalAttributeNeutralCurrent));
26248

263-
gInstance->Init();
49+
gEPMInstance->Init();
26450
}
26551
}

examples/all-clusters-app/ameba/chip_main.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ list(
179179

180180
${chip_dir}/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp
181181
${chip_dir}/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementManager.cpp
182+
${chip_dir}/examples/energy-management-app/energy-management-common/src/ElectricalPowerMeasurementDelegate.cpp
182183
${chip_dir}/examples/energy-management-app/energy-management-common/src/EnergyEvseDelegateImpl.cpp
183184
${chip_dir}/examples/energy-management-app/energy-management-common/src/EnergyEvseManager.cpp
184185

examples/all-clusters-app/asr/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ asr_executable("clusters_app") {
8484
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp",
8585
"${chip_root}/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp",
8686
"${chip_root}/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementManager.cpp",
87+
"${chip_root}/examples/energy-management-app/energy-management-common/src/ElectricalPowerMeasurementDelegate.cpp",
8788
"${chip_root}/examples/energy-management-app/energy-management-common/src/EnergyEvseDelegateImpl.cpp",
8889
"${chip_root}/examples/energy-management-app/energy-management-common/src/EnergyEvseManager.cpp",
8990
"${examples_plat_dir}/ButtonHandler.cpp",

0 commit comments

Comments
 (0)