#pragma once #include #include #include #include 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 cmd_; std::map sCMD_; std::vector 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; };