Skip to content

Commit

Permalink
meters-meta: Remove custom register events logic
Browse files Browse the repository at this point in the history
This is centralized now as part of IMeter.
  • Loading branch information
photron committed Oct 24, 2024
1 parent 610496d commit 2b92155
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
3 changes: 1 addition & 2 deletions software/src/modules/meters_meta/meter_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,14 @@ class MeterMeta final : public IMeter

[[gnu::const]] MeterClassID get_class() const override;
void setup(const Config &ephemeral_config) override;
void register_events() override;

bool supports_power() override {return true;}
bool supports_energy_import() override {return true;}
bool supports_energy_imexsum()override {return true;}
bool supports_energy_export() override {return true;}
bool supports_currents() override {return true;}

void register_events();

EventResult on_value_ids_change(const Config *value_ids);
void on_values_change_single(const Config *source_values);
void on_values_change_double();
Expand Down
16 changes: 1 addition & 15 deletions software/src/modules/meters_meta/meters_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,17 @@ void MetersMeta::pre_setup()
{"constant", Config::Int32(0)},
});

child_meters = new std::vector<MeterMeta *>;

meters.register_meter_generator(get_class(), this);
}

void MetersMeta::register_events()
{
for (MeterMeta *meter : *child_meters) {
meter->register_events();
}

delete child_meters;
child_meters = nullptr;
}

MeterClassID MetersMeta::get_class() const
{
return MeterClassID::Meta;
}

IMeter *MetersMeta::new_meter(uint32_t slot, Config *state, Config *errors)
{
MeterMeta *new_meter = new MeterMeta(slot);
child_meters->push_back(new_meter);
return new_meter;
return new MeterMeta(slot);
}

const Config *MetersMeta::get_config_prototype()
Expand Down
5 changes: 1 addition & 4 deletions software/src/modules/meters_meta/meters_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class MetersMeta final : public IModule, public MeterGenerator
{
public:
// for IModule
void pre_setup() override;
void register_events() override;
void pre_setup() override;

// for MeterGenerator
[[gnu::const]] MeterClassID get_class() const override;
Expand All @@ -49,8 +48,6 @@ class MetersMeta final : public IModule, public MeterGenerator

private:
Config config_prototype;

std::vector<MeterMeta *> *child_meters = nullptr;
};

#if defined(__GNUC__)
Expand Down

0 comments on commit 2b92155

Please sign in to comment.