2018-04-01 06:53:37 +00:00
|
|
|
/*
|
2019-02-24 13:08:51 +00:00
|
|
|
Copyright (C) 2017-2019 Fredrik Öhrström
|
2018-04-01 06:53:37 +00:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2017-08-09 10:00:11 +00:00
|
|
|
|
|
|
|
#ifndef METER_H_
|
|
|
|
#define METER_H_
|
|
|
|
|
|
|
|
#include"util.h"
|
2019-05-04 11:07:37 +00:00
|
|
|
#include"units.h"
|
2017-08-09 10:00:11 +00:00
|
|
|
#include"wmbus.h"
|
|
|
|
|
|
|
|
#include<string>
|
|
|
|
#include<vector>
|
|
|
|
|
2019-05-04 08:52:18 +00:00
|
|
|
#define LIST_OF_METERS \
|
2019-06-06 15:28:20 +00:00
|
|
|
X(amiplus, T1_bit, Electricity, AMIPLUS, Amiplus) \
|
|
|
|
X(apator162, C1_bit|T1_bit, Water, APATOR162, Apator162) \
|
|
|
|
X(eurisii, T1_bit, HeatCostAllocation, EURISII, EurisII) \
|
|
|
|
X(flowiq3100, C1_bit, Water, FLOWIQ3100, Multical21) \
|
|
|
|
X(iperl, T1_bit, Water, IPERL, Iperl) \
|
|
|
|
X(mkradio3, T1_bit, Water, MKRADIO3, MKRadio3) \
|
|
|
|
X(multical21, C1_bit, Water, MULTICAL21, Multical21) \
|
|
|
|
X(multical302,C1_bit, Heat, MULTICAL302, Multical302) \
|
|
|
|
X(omnipower, C1_bit, Electricity, OMNIPOWER, Omnipower) \
|
|
|
|
X(qcaloric, C1_bit, HeatCostAllocation, QCALORIC, QCaloric) \
|
|
|
|
X(supercom587,T1_bit, Water, SUPERCOM587, Supercom587) \
|
|
|
|
X(vario451, T1_bit, Heat, VARIO451, Vario451) \
|
2019-05-04 08:52:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
enum class MeterType {
|
|
|
|
#define X(mname,linkmode,info,type,cname) type,
|
2018-03-05 10:29:25 +00:00
|
|
|
LIST_OF_METERS
|
|
|
|
#undef X
|
2019-05-04 08:52:18 +00:00
|
|
|
UNKNOWN
|
2018-03-05 10:29:25 +00:00
|
|
|
};
|
|
|
|
|
2017-08-09 10:00:11 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
typedef unsigned char uchar;
|
|
|
|
|
2019-05-21 12:19:54 +00:00
|
|
|
struct MeterInfo
|
|
|
|
{
|
|
|
|
string name;
|
|
|
|
string type;
|
|
|
|
string id;
|
|
|
|
string key;
|
2019-06-06 15:28:20 +00:00
|
|
|
LinkModeSet link_modes;
|
2019-05-21 12:19:54 +00:00
|
|
|
vector<string> shells;
|
|
|
|
|
2019-06-06 15:28:20 +00:00
|
|
|
MeterInfo(string n, string t, string i, string k, LinkModeSet lms, vector<string> &s)
|
|
|
|
{
|
2019-05-21 12:19:54 +00:00
|
|
|
name = n;
|
|
|
|
type = t;
|
|
|
|
id = i;
|
|
|
|
key = k;
|
|
|
|
shells = s;
|
2019-06-06 15:28:20 +00:00
|
|
|
link_modes = lms;
|
2019-05-21 12:19:54 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-05-04 17:56:17 +00:00
|
|
|
struct Meter
|
|
|
|
{
|
2019-03-05 20:19:05 +00:00
|
|
|
virtual vector<string> ids() = 0;
|
2019-05-04 08:52:18 +00:00
|
|
|
virtual string meterName() = 0;
|
2017-08-09 10:00:11 +00:00
|
|
|
virtual string name() = 0;
|
2018-03-05 10:29:25 +00:00
|
|
|
virtual MeterType type() = 0;
|
2019-03-05 20:19:05 +00:00
|
|
|
virtual vector<int> media() = 0;
|
2018-03-05 10:29:25 +00:00
|
|
|
virtual WMBus *bus() = 0;
|
|
|
|
|
|
|
|
virtual string datetimeOfUpdateHumanReadable() = 0;
|
|
|
|
virtual string datetimeOfUpdateRobot() = 0;
|
|
|
|
|
2019-03-05 20:19:05 +00:00
|
|
|
virtual void onUpdate(function<void(Telegram*t,Meter*)> cb) = 0;
|
2018-03-05 10:29:25 +00:00
|
|
|
virtual int numUpdates() = 0;
|
2017-09-02 21:26:57 +00:00
|
|
|
|
2019-03-05 20:19:05 +00:00
|
|
|
virtual void printMeter(Telegram *t,
|
2019-03-05 17:38:54 +00:00
|
|
|
string *human_readable,
|
2018-11-02 12:50:12 +00:00
|
|
|
string *fields, char separator,
|
|
|
|
string *json,
|
|
|
|
vector<string> *envs) = 0;
|
2018-03-05 10:29:25 +00:00
|
|
|
|
2019-05-04 15:38:10 +00:00
|
|
|
void handleTelegram(Telegram *t);
|
2018-03-05 10:29:25 +00:00
|
|
|
virtual bool isTelegramForMe(Telegram *t) = 0;
|
|
|
|
virtual bool useAes() = 0;
|
|
|
|
virtual vector<uchar> key() = 0;
|
2019-05-04 17:56:17 +00:00
|
|
|
virtual EncryptionMode encryptionMode() = 0;
|
|
|
|
virtual int expectedVersion() = 0;
|
2018-04-20 09:42:46 +00:00
|
|
|
|
|
|
|
// Dynamically access all data received for the meter.
|
|
|
|
virtual std::vector<std::string> getRecords() = 0;
|
|
|
|
virtual double getRecordAsDouble(std::string record) = 0;
|
|
|
|
virtual uint16_t getRecordAsUInt16(std::string record) = 0;
|
2018-12-28 17:35:32 +00:00
|
|
|
|
2019-05-04 11:55:52 +00:00
|
|
|
virtual void addConversions(std::vector<Unit> cs) = 0;
|
2019-05-21 12:19:54 +00:00
|
|
|
virtual void addShell(std::string cmdline) = 0;
|
|
|
|
virtual vector<string> &shellCmdlines() = 0;
|
2019-05-04 11:55:52 +00:00
|
|
|
|
2018-12-28 17:35:32 +00:00
|
|
|
virtual ~Meter() = default;
|
2018-03-05 10:29:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct WaterMeter : public virtual Meter {
|
2019-05-04 15:38:10 +00:00
|
|
|
virtual double totalWaterConsumption(Unit u); // m3
|
|
|
|
virtual bool hasTotalWaterConsumption();
|
|
|
|
virtual double targetWaterConsumption(Unit u); // m3
|
|
|
|
virtual bool hasTargetWaterConsumption();
|
|
|
|
virtual double maxFlow(Unit u); // m3/s
|
|
|
|
virtual bool hasMaxFlow();
|
|
|
|
virtual double flowTemperature(Unit u); // °C
|
|
|
|
virtual bool hasFlowTemperature();
|
|
|
|
virtual double externalTemperature(Unit u); // °C
|
|
|
|
virtual bool hasExternalTemperature();
|
|
|
|
|
|
|
|
virtual string statusHumanReadable();
|
|
|
|
virtual string status();
|
|
|
|
virtual string timeDry();
|
|
|
|
virtual string timeReversed();
|
|
|
|
virtual string timeLeaking();
|
|
|
|
virtual string timeBursting();
|
2018-03-05 10:29:25 +00:00
|
|
|
};
|
2017-08-09 10:00:11 +00:00
|
|
|
|
2018-03-05 10:29:25 +00:00
|
|
|
struct HeatMeter : public virtual Meter {
|
2019-05-04 15:38:10 +00:00
|
|
|
virtual double totalEnergyConsumption(Unit u); // kwh
|
|
|
|
virtual double currentPeriodEnergyConsumption(Unit u); // kwh
|
|
|
|
virtual double previousPeriodEnergyConsumption(Unit u); // kwh
|
|
|
|
virtual double currentPowerConsumption(Unit u); // kw
|
|
|
|
virtual double totalVolume(Unit u); // m3
|
2017-08-09 10:00:11 +00:00
|
|
|
};
|
|
|
|
|
2018-03-16 10:48:04 +00:00
|
|
|
struct ElectricityMeter : public virtual Meter {
|
2019-05-04 18:52:05 +00:00
|
|
|
virtual double totalEnergyConsumption(Unit u); // kwh
|
|
|
|
virtual double currentPowerConsumption(Unit u); // kw
|
|
|
|
virtual double totalEnergyProduction(Unit u); // kwh
|
|
|
|
virtual double currentPowerProduction(Unit u); // kw
|
2018-03-16 10:48:04 +00:00
|
|
|
};
|
|
|
|
|
2019-02-17 20:47:23 +00:00
|
|
|
struct HeatCostMeter : public virtual Meter {
|
2019-05-04 18:52:05 +00:00
|
|
|
virtual double currentConsumption(Unit u);
|
2019-05-04 15:38:10 +00:00
|
|
|
virtual string setDate();
|
2019-05-04 18:52:05 +00:00
|
|
|
virtual double consumptionAtSetDate(Unit u);
|
2019-02-17 20:47:23 +00:00
|
|
|
};
|
|
|
|
|
2018-04-20 09:42:46 +00:00
|
|
|
struct GenericMeter : public virtual Meter {
|
|
|
|
};
|
2018-03-05 10:29:25 +00:00
|
|
|
|
2019-05-04 08:52:18 +00:00
|
|
|
string toMeterName(MeterType mt);
|
2019-02-23 12:41:17 +00:00
|
|
|
MeterType toMeterType(string& type);
|
2019-06-06 15:28:20 +00:00
|
|
|
LinkModeSet toMeterLinkModeSet(string& type);
|
2019-05-21 12:19:54 +00:00
|
|
|
unique_ptr<WaterMeter> createMultical21(WMBus *bus, MeterInfo &m);
|
|
|
|
unique_ptr<WaterMeter> createFlowIQ3100(WMBus *bus, MeterInfo &m);
|
|
|
|
unique_ptr<HeatMeter> createMultical302(WMBus *bus, MeterInfo &m);
|
|
|
|
unique_ptr<HeatMeter> createVario451(WMBus *bus, MeterInfo &m);
|
|
|
|
unique_ptr<ElectricityMeter> createOmnipower(WMBus *bus, MeterInfo &m);
|
|
|
|
unique_ptr<ElectricityMeter> createAmiplus(WMBus *bus, MeterInfo &m);
|
|
|
|
unique_ptr<WaterMeter> createSupercom587(WMBus *bus, MeterInfo &m);
|
|
|
|
unique_ptr<WaterMeter> createMKRadio3(WMBus *bus, MeterInfo &m);
|
|
|
|
unique_ptr<WaterMeter> createApator162(WMBus *bus, MeterInfo &m);
|
|
|
|
unique_ptr<WaterMeter> createIperl(WMBus *bus, MeterInfo &m);
|
|
|
|
unique_ptr<HeatCostMeter> createQCaloric(WMBus *bus, MeterInfo &m);
|
2019-05-21 13:18:06 +00:00
|
|
|
unique_ptr<HeatCostMeter> createEurisII(WMBus *bus, MeterInfo &m);
|
2019-05-21 12:19:54 +00:00
|
|
|
GenericMeter *createGeneric(WMBus *bus, MeterInfo &m);
|
2017-08-09 10:00:11 +00:00
|
|
|
|
|
|
|
#endif
|