kopia lustrzana https://github.com/weetmuts/wmbusmeters
Made amiplus have multiple manufacturers.
rodzic
bf5941ef42
commit
139178537d
|
@ -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*));
|
||||
}
|
||||
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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<int> 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<string> 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());
|
||||
|
|
|
@ -40,7 +40,6 @@ struct Meter {
|
|||
virtual vector<string> ids() = 0;
|
||||
virtual string name() = 0;
|
||||
virtual MeterType type() = 0;
|
||||
virtual int manufacturer() = 0;
|
||||
virtual vector<int> media() = 0;
|
||||
virtual WMBus *bus() = 0;
|
||||
virtual LinkMode requiredLinkMode() = 0;
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
#include"meters.h"
|
||||
|
||||
#include<map>
|
||||
#include<set>
|
||||
|
||||
struct MeterCommonImplementation : public virtual Meter
|
||||
{
|
||||
vector<string> ids();
|
||||
string name();
|
||||
MeterType type();
|
||||
int manufacturer();
|
||||
vector<int> 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<int> media_ {};
|
||||
vector<int> media_;
|
||||
set<int> manufacturers_;
|
||||
string name_;
|
||||
vector<string> ids_;
|
||||
vector<uchar> key_;
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -151,7 +151,7 @@ unique_ptr<WMBus> 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);
|
||||
|
|
Ładowanie…
Reference in New Issue