#pragma once #include "base.hpp" #include class DaliDT4DimmerStatus { public: explicit DaliDT4DimmerStatus(int raw) : raw_(raw & 0xFF) {} int raw() const { return raw_; } bool leadingEdgeModeRunning() const { return bit(0x01); } bool trailingEdgeModeRunning() const { return bit(0x02); } bool referenceMeasurementRunning() const { return bit(0x04); } bool nonLogarithmicDimmingCurveActive() const { return bit(0x10); } private: int raw_ = 0; bool bit(int mask) const { return (raw_ & mask) != 0; } }; class DaliDT4Features { public: DaliDT4Features(int raw1, int raw2, int raw3) : raw1_(raw1 & 0xFF), raw2_(raw2 & 0xFF), raw3_(raw3 & 0xFF) {} int raw1() const { return raw1_; } int raw2() const { return raw2_; } int raw3() const { return raw3_; } bool canQueryLoadOverCurrentShutdown() const { return bit(raw1_, 0x01); } bool canQueryOpenCircuitDetection() const { return bit(raw1_, 0x02); } bool canQueryLoadDecrease() const { return bit(raw1_, 0x04); } bool canQueryLoadIncrease() const { return bit(raw1_, 0x08); } bool canQueryThermalShutdown() const { return bit(raw1_, 0x20); } bool canQueryThermalOverloadReduction() const { return bit(raw1_, 0x40); } bool physicalSelectionSupported() const { return bit(raw1_, 0x80); } bool canQueryTemperature() const { return bit(raw2_, 0x01); } bool canQuerySupplyVoltage() const { return bit(raw2_, 0x02); } bool canQuerySupplyFrequency() const { return bit(raw2_, 0x04); } bool canQueryLoadVoltage() const { return bit(raw2_, 0x08); } bool canQueryLoadCurrent() const { return bit(raw2_, 0x10); } bool canQueryRealLoadPower() const { return bit(raw2_, 0x20); } bool canQueryLoadRating() const { return bit(raw2_, 0x40); } bool canQueryCurrentOverloadReduction() const { return bit(raw2_, 0x80); } bool canSelectNonLogarithmicDimmingCurve() const { return bit(raw3_, 0x08); } bool canQueryUnsuitableLoad() const { return bit(raw3_, 0x80); } int dimmingMethodCode() const { return raw3_ & 0x03; } private: int raw1_ = 0; int raw2_ = 0; int raw3_ = 0; static bool bit(int value, int mask) { return (value & mask) != 0; } }; class DaliDT4FailureStatus { public: DaliDT4FailureStatus(int raw1, int raw2) : raw1_(raw1 & 0xFF), raw2_(raw2 & 0xFF) {} int raw1() const { return raw1_; } int raw2() const { return raw2_; } bool loadOverCurrentShutdown() const { return bit(raw1_, 0x01); } bool openCircuitDetected() const { return bit(raw1_, 0x02); } bool loadDecreaseDetected() const { return bit(raw1_, 0x04); } bool loadIncreaseDetected() const { return bit(raw1_, 0x08); } bool thermalShutdown() const { return bit(raw1_, 0x20); } bool thermalOverloadReduction() const { return bit(raw1_, 0x40); } bool referenceMeasurementFailed() const { return bit(raw1_, 0x80); } bool loadUnsuitableForSelectedMethod() const { return bit(raw2_, 0x01); } bool supplyVoltageOutOfLimits() const { return bit(raw2_, 0x02); } bool supplyFrequencyOutOfLimits() const { return bit(raw2_, 0x04); } bool loadVoltageOutOfLimits() const { return bit(raw2_, 0x08); } bool loadCurrentOverloadReduction() const { return bit(raw2_, 0x10); } private: int raw1_ = 0; int raw2_ = 0; static bool bit(int value, int mask) { return (value & mask) != 0; } }; class DaliDT4 { public: explicit DaliDT4(DaliBase& base); bool enableDT4(); bool referenceSystemPower(int a); bool selectDimmingCurve(int a, int curve); std::optional getDimmingCurve(int a); std::optional getDimmerStatus(int a); std::optional getFeatures(int a); std::optional getFailureStatus(int a); std::optional getDimmerTemperatureRaw(int a); std::optional getDimmerTemperatureCelsius(int a); std::optional getRmsSupplyVoltageRaw(int a); std::optional getRmsSupplyVoltageVolts(int a); std::optional getSupplyFrequencyRaw(int a); std::optional getSupplyFrequencyHertz(int a); std::optional getRmsLoadVoltageRaw(int a); std::optional getRmsLoadVoltageVolts(int a); std::optional getRmsLoadCurrentRaw(int a); std::optional getRmsLoadCurrentPercent(int a); std::optional getRealLoadPowerRaw(int a); std::optional getRealLoadPowerWatts(int a); std::optional getLoadRatingRaw(int a); std::optional getLoadRatingAmps(int a); std::optional isReferenceRunning(int a); std::optional isReferenceMeasurementFailed(int a); std::optional getExtendedVersion(int a); private: DaliBase& base_; bool enable(); static int addrOf(int a); std::optional query(int a, int code); std::optional queryYesNo(int a, int code); };