forked from wirenboard/wb-mqtt-serial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmilur_device.h
38 lines (30 loc) · 933 Bytes
/
milur_device.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <string>
#include <memory>
#include <exception>
#include <cstdint>
#include "em_device.h"
class TMilurDevice;
typedef TBasicProtocol<TMilurDevice> TMilurProtocol;
class TMilurDevice: public TEMDevice<TMilurProtocol> {
public:
static const int DefaultTimeoutMs = 1000;
static const int FrameTimeoutMs = 50;
enum RegisterType {
REG_PARAM = 0,
REG_POWER,
REG_ENERGY,
REG_FREQ,
REG_POWERFACTOR
};
TMilurDevice(PDeviceConfig device_config, PPort port, PProtocol protocol);
uint64_t ReadRegister(PRegister reg);
void Prepare();
protected:
bool ConnectionSetup();
ErrorType CheckForException(uint8_t* frame, int len, const char** message);
uint64_t BuildIntVal(uint8_t *p, int sz) const;
uint64_t BuildBCB32(uint8_t* psrc) const;
int GetExpectedSize(int type) const;
};
typedef std::shared_ptr<TMilurDevice> PMilurDevice;