Files
dali_cpp/include/dt4.hpp
T
Tony bbcfcd11f6 Add support for DT4, DT5, and DT6 devices
- Updated CMakeLists.txt to include new source files for DT4, DT5, and DT6.
- Modified dali.hpp to include headers for DT4, DT5, and DT6.
- Added command definitions for DT4, DT5, and DT6 in dali_define.hpp.
- Enhanced DaliDeviceCapabilities to support DT4, DT5, and DT6 detection.
- Implemented DT4 and DT5 classes with methods for device control and status querying.
- Created DT6 class with methods for device control and status querying.
- Updated decode.cpp to include new device types in the deviceTypeName mapping.
- Enhanced device.cpp to handle new device capabilities.
2026-04-24 13:36:08 +08:00

126 lines
4.7 KiB
C++

#pragma once
#include "base.hpp"
#include <optional>
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<int> getDimmingCurve(int a);
std::optional<DaliDT4DimmerStatus> getDimmerStatus(int a);
std::optional<DaliDT4Features> getFeatures(int a);
std::optional<DaliDT4FailureStatus> getFailureStatus(int a);
std::optional<int> getDimmerTemperatureRaw(int a);
std::optional<int> getDimmerTemperatureCelsius(int a);
std::optional<int> getRmsSupplyVoltageRaw(int a);
std::optional<double> getRmsSupplyVoltageVolts(int a);
std::optional<int> getSupplyFrequencyRaw(int a);
std::optional<double> getSupplyFrequencyHertz(int a);
std::optional<int> getRmsLoadVoltageRaw(int a);
std::optional<double> getRmsLoadVoltageVolts(int a);
std::optional<int> getRmsLoadCurrentRaw(int a);
std::optional<double> getRmsLoadCurrentPercent(int a);
std::optional<int> getRealLoadPowerRaw(int a);
std::optional<double> getRealLoadPowerWatts(int a);
std::optional<int> getLoadRatingRaw(int a);
std::optional<double> getLoadRatingAmps(int a);
std::optional<bool> isReferenceRunning(int a);
std::optional<bool> isReferenceMeasurementFailed(int a);
std::optional<int> getExtendedVersion(int a);
private:
DaliBase& base_;
bool enable();
static int addrOf(int a);
std::optional<int> query(int a, int code);
std::optional<bool> queryYesNo(int a, int code);
};