kopia lustrzana https://github.com/weetmuts/wmbusmeters
67 wiersze
2.1 KiB
C++
67 wiersze
2.1 KiB
C++
// Copyright (c) 2017 Fredrik Öhrström
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
// copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
// SOFTWARE.
|
|
|
|
#ifndef METERS_COMMON_IMPLEMENTATION_H_
|
|
#define METERS_COMMON_IMPLEMENTATION_H_
|
|
|
|
#include"meters.h"
|
|
|
|
struct MeterCommonImplementation : public virtual Meter {
|
|
string id();
|
|
string name();
|
|
MeterType type();
|
|
int manufacturer();
|
|
int media();
|
|
WMBus *bus();
|
|
|
|
string datetimeOfUpdateHumanReadable();
|
|
string datetimeOfUpdateRobot();
|
|
|
|
void onUpdate(function<void(Meter*)> cb);
|
|
int numUpdates();
|
|
|
|
bool isTelegramForMe(Telegram *t);
|
|
bool useAes();
|
|
vector<uchar> key();
|
|
|
|
MeterCommonImplementation(WMBus *bus, const char *name, const char *id, const char *key,
|
|
MeterType type, int manufacturer, int media);
|
|
|
|
protected:
|
|
|
|
void triggerUpdate(Telegram *t);
|
|
|
|
private:
|
|
|
|
MeterType type_ {};
|
|
int manufacturer_ {};
|
|
int media_ {};
|
|
string name_;
|
|
vector<uchar> id_;
|
|
vector<uchar> key_;
|
|
WMBus *bus_ {};
|
|
vector<function<void(Meter*)>> on_update_;
|
|
int num_updates_ {};
|
|
bool use_aes_ {};
|
|
time_t datetime_of_update_ {};
|
|
};
|
|
|
|
#endif
|