diff --git a/src/meter_amiplus.cc b/src/meter_amiplus.cc index 832ca63..d2ad651 100644 --- a/src/meter_amiplus.cc +++ b/src/meter_amiplus.cc @@ -55,9 +55,11 @@ private: }; MeterAmiplus::MeterAmiplus(WMBus *bus, string& name, string& id, string& key) : - MeterCommonImplementation(bus, name, id, key, AMIPLUS_METER, MANUFACTURER_APA, LinkMode::T1) + MeterCommonImplementation(bus, name, id, key, AMIPLUS_METER, 0, LinkMode::T1) { addMedia(0x02); + addManufacturer(MANUFACTURER_APA); + addManufacturer(MANUFACTURER_DEV); MeterCommonImplementation::bus()->onTelegram(calll(this,handleTelegram,Telegram*)); } diff --git a/src/meter_apator162.cc b/src/meter_apator162.cc index 6540e53..b228914 100644 --- a/src/meter_apator162.cc +++ b/src/meter_apator162.cc @@ -195,7 +195,7 @@ void MeterApator162::printMeter(Telegram *t, Q(total_m3,%f) QSE(timestamp,%s) "}", - mediaType(manufacturer(), t->a_field_device_type).c_str(), + mediaType(t->a_field_device_type).c_str(), name().c_str(), t->id.c_str(), totalWaterConsumption(), diff --git a/src/meter_iperl.cc b/src/meter_iperl.cc index 55117b3..d6d6c37 100644 --- a/src/meter_iperl.cc +++ b/src/meter_iperl.cc @@ -195,7 +195,7 @@ void MeterIperl::printMeter(Telegram *t, Q(max_flow_m3h,%f) QSE(timestamp,%s) "}", - mediaType(manufacturer(), t->a_field_device_type).c_str(), + mediaType(t->a_field_device_type).c_str(), name().c_str(), t->id.c_str(), totalWaterConsumption(), diff --git a/src/meter_multical21.cc b/src/meter_multical21.cc index a082ce3..fc2fc00 100644 --- a/src/meter_multical21.cc +++ b/src/meter_multical21.cc @@ -578,7 +578,7 @@ void MeterMultical21::printMeter(Telegram *t, QS(time_bursting,%s) QSE(timestamp,%s) "}", - mediaType(manufacturer(), t->a_field_device_type).c_str(), + mediaType(t->a_field_device_type).c_str(), meter_name_, name().c_str(), t->id.c_str(), diff --git a/src/meter_supercom587.cc b/src/meter_supercom587.cc index a80c5fd..a35f90d 100644 --- a/src/meter_supercom587.cc +++ b/src/meter_supercom587.cc @@ -180,7 +180,7 @@ void MeterSupercom587::printMeter(Telegram *t, Q(total_m3,%f) QSE(timestamp,%s) "}", - mediaType(manufacturer(), t->a_field_device_type).c_str(), + mediaType(t->a_field_device_type).c_str(), name().c_str(), t->id.c_str(), totalWaterConsumption(), diff --git a/src/meters.cc b/src/meters.cc index 9552825..462b5d4 100644 --- a/src/meters.cc +++ b/src/meters.cc @@ -23,7 +23,7 @@ MeterCommonImplementation::MeterCommonImplementation(WMBus *bus, string& name, string& id, string& key, MeterType type, int manufacturer, LinkMode required_link_mode) : - type_(type), manufacturer_(manufacturer), name_(name), bus_(bus), + type_(type), name_(name), bus_(bus), required_link_mode_(required_link_mode) { use_aes_ = true; @@ -33,6 +33,9 @@ MeterCommonImplementation::MeterCommonImplementation(WMBus *bus, string& name, s } else { hex2bin(key, &key_); } + if (manufacturer) { + manufacturers_.insert(manufacturer); + } } MeterType MeterCommonImplementation::type() @@ -40,11 +43,6 @@ MeterType MeterCommonImplementation::type() return type_; } -int MeterCommonImplementation::manufacturer() -{ - return manufacturer_; -} - vector MeterCommonImplementation::media() { return media_; @@ -55,6 +53,11 @@ void MeterCommonImplementation::addMedia(int m) media_.push_back(m); } +void MeterCommonImplementation::addManufacturer(int m) +{ + manufacturers_.insert(m); +} + vector MeterCommonImplementation::ids() { return ids_; @@ -155,7 +158,7 @@ bool MeterCommonImplementation::isTelegramForMe(Telegram *t) return false; } - if (manufacturer_ != 0 && t->m_field != manufacturer_) { + if (manufacturers_.count(t->m_field) == 0) { // We are not that strict for the manufacturer. // Simply warn. warning("(meter) %s: probably not for me since manufacturer differs\n", name_.c_str()); diff --git a/src/meters.h b/src/meters.h index b34096e..b861a75 100644 --- a/src/meters.h +++ b/src/meters.h @@ -40,7 +40,6 @@ struct Meter { virtual vector ids() = 0; virtual string name() = 0; virtual MeterType type() = 0; - virtual int manufacturer() = 0; virtual vector media() = 0; virtual WMBus *bus() = 0; virtual LinkMode requiredLinkMode() = 0; diff --git a/src/meters_common_implementation.h b/src/meters_common_implementation.h index 82895a8..58a6464 100644 --- a/src/meters_common_implementation.h +++ b/src/meters_common_implementation.h @@ -21,13 +21,13 @@ #include"meters.h" #include +#include struct MeterCommonImplementation : public virtual Meter { vector ids(); string name(); MeterType type(); - int manufacturer(); vector media(); WMBus *bus(); LinkMode requiredLinkMode(); @@ -56,12 +56,13 @@ protected: void triggerUpdate(Telegram *t); void addMedia(int media); + void addManufacturer(int m); private: MeterType type_ {}; - int manufacturer_ {}; - vector media_ {}; + vector media_; + set manufacturers_; string name_; vector ids_; vector key_; diff --git a/src/wmbus.cc b/src/wmbus.cc index c67dbcd..1cde5b7 100644 --- a/src/wmbus.cc +++ b/src/wmbus.cc @@ -166,7 +166,7 @@ string deviceType(int m_field, int a_field_device_type) { return "Unknown"; } -string mediaType(int m_field, int a_field_device_type) { +string mediaType(int a_field_device_type) { switch (a_field_device_type) { case 0: return "other"; case 1: return "oil"; diff --git a/src/wmbus.h b/src/wmbus.h index 34a4a5c..c85c342 100644 --- a/src/wmbus.h +++ b/src/wmbus.h @@ -151,7 +151,7 @@ unique_ptr openSimulator(string file, SerialCommunicationManager *manager string manufacturer(int m_field); string manufacturerFlag(int m_field); string deviceType(int m_field, int a_field_device_type); -string mediaType(int m_field, int a_field_device_type); +string mediaType(int a_field_device_type); string ciType(int ci_field); string cType(int c_field); string ccType(int cc_field);