57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct DecodedRecord {
|
|
std::string text;
|
|
std::string type;
|
|
int addr = -1;
|
|
int cmd = -1;
|
|
int proto = -1;
|
|
};
|
|
|
|
class DaliDecode {
|
|
public:
|
|
bool displayRaw = true;
|
|
int responseWindowMs = 100;
|
|
|
|
int dtr0 = 0;
|
|
int dtr1 = 0;
|
|
int dtr2 = 0;
|
|
|
|
DaliDecode();
|
|
|
|
int isQueryCmd(int cmd) const;
|
|
|
|
DecodedRecord decodeBright(int addr, int level);
|
|
DecodedRecord decodeScene(int addr, int sceneCmd);
|
|
DecodedRecord decodeCmd(int addr, int c);
|
|
DecodedRecord decodeSpCmd(int addr, int c);
|
|
DecodedRecord querySpCMD(int cmdByte, int dataByte);
|
|
DecodedRecord decodeQuery(int addr, int c);
|
|
DecodedRecord decodeCmdResponse(int value, int gwPrefix = 0xFF);
|
|
DecodedRecord decode(int addr, int c, int proto = 0x10);
|
|
|
|
private:
|
|
std::map<int, std::string> cmd_;
|
|
std::map<int, std::string> sCMD_;
|
|
std::vector<int> queryCmd_;
|
|
|
|
int lastQueryCmd_ = 0;
|
|
int64_t lastQueryAtMs_ = 0;
|
|
int pendingColourType_ = -1;
|
|
int64_t lastColourQueryAtMs_ = 0;
|
|
|
|
static int64_t nowMs();
|
|
static std::string hex(int v);
|
|
static std::string bin(int v);
|
|
static std::string yn(bool b);
|
|
static std::string whoLabel(int addr, bool even);
|
|
static std::string deviceTypeName(int v);
|
|
static std::string lightSourceName(int v);
|
|
DecodedRecord withRaw(const DecodedRecord& r) const;
|
|
};
|