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.
This commit is contained in:
Tony
2026-04-24 13:36:08 +08:00
parent 21afc6b942
commit bbcfcd11f6
12 changed files with 798 additions and 1 deletions
+8 -1
View File
@@ -11,6 +11,9 @@
#include "decode.hpp"
#include "device.hpp"
#include "dt1.hpp"
#include "dt4.hpp"
#include "dt5.hpp"
#include "dt6.hpp"
#include "dt8.hpp"
#include "addr.hpp"
#include "gateway_cloud.hpp"
@@ -46,11 +49,15 @@ class Dali {
DaliBase base;
DaliDecode decode;
DaliDT1 dt1;
DaliDT4 dt4;
DaliDT5 dt5;
DaliDT6 dt6;
DaliDT8 dt8;
DaliAddr addr;
explicit Dali(DaliComm& comm, int g = 0, const std::string& n = "dali1")
: name(n), gw(g), base(comm), decode(), dt1(base), dt8(base), addr(base) {}
: name(n), gw(g), base(comm), decode(), dt1(base), dt4(base), dt5(base), dt6(base),
dt8(base), addr(base) {}
void open() {}
void close() {}
+59
View File
@@ -92,6 +92,65 @@
#define DALI_CMD_SPECIAL_SET_DTR_1 0xC3
#define DALI_CMD_SPECIAL_SET_DTR_2 0xC5
// DT4 commands and queries
#define DALI_CMD_DT4_REFERENCE_SYSTEM_POWER 0xE0
#define DALI_CMD_DT4_SELECT_DIMMING_CURVE 0xE1
#define DALI_CMD_DT4_QUERY_DIMMING_CURVE 0xEE
#define DALI_CMD_DT4_QUERY_DIMMER_STATUS 0xEF
#define DALI_CMD_DT4_QUERY_FEATURES 0xF0
#define DALI_CMD_DT4_QUERY_FAILURE_STATUS 0xF1
#define DALI_CMD_DT4_QUERY_DIMMER_TEMPERATURE 0xF2
#define DALI_CMD_DT4_QUERY_RMS_SUPPLY_VOLTAGE 0xF3
#define DALI_CMD_DT4_QUERY_SUPPLY_FREQUENCY 0xF4
#define DALI_CMD_DT4_QUERY_RMS_LOAD_VOLTAGE 0xF5
#define DALI_CMD_DT4_QUERY_RMS_LOAD_CURRENT 0xF6
#define DALI_CMD_DT4_QUERY_REAL_LOAD_POWER 0xF7
#define DALI_CMD_DT4_QUERY_LOAD_RATING 0xF8
#define DALI_CMD_DT4_QUERY_REFERENCE_RUNNING 0xF9
#define DALI_CMD_DT4_QUERY_REFERENCE_MEASUREMENT_FAILED 0xFA
#define DALI_CMD_DT4_QUERY_EXTENDED_VERSION 0xFF
// DT5 commands and queries
#define DALI_CMD_DT5_SET_OUTPUT_RANGE_1_TO_10V 0xE0
#define DALI_CMD_DT5_SET_OUTPUT_RANGE_0_TO_10V 0xE1
#define DALI_CMD_DT5_SWITCH_ON_INTERNAL_PULL_UP 0xE2
#define DALI_CMD_DT5_SWITCH_OFF_INTERNAL_PULL_UP 0xE3
#define DALI_CMD_DT5_STORE_DTR_AS_PHYSICAL_MINIMUM 0xE4
#define DALI_CMD_DT5_SELECT_DIMMING_CURVE 0xE5
#define DALI_CMD_DT5_RESET_CONVERTER_SETTINGS 0xE6
#define DALI_CMD_DT5_QUERY_DIMMING_CURVE 0xEE
#define DALI_CMD_DT5_QUERY_OUTPUT_LEVEL 0xEF
#define DALI_CMD_DT5_QUERY_CONVERTER_FEATURES 0xF0
#define DALI_CMD_DT5_QUERY_FAILURE_STATUS 0xF1
#define DALI_CMD_DT5_QUERY_CONVERTER_STATUS 0xF2
#define DALI_CMD_DT5_QUERY_EXTENDED_VERSION 0xFF
// DT6 commands and queries
#define DALI_CMD_DT6_REFERENCE_SYSTEM_POWER 0xE0
#define DALI_CMD_DT6_ENABLE_CURRENT_PROTECTOR 0xE1
#define DALI_CMD_DT6_DISABLE_CURRENT_PROTECTOR 0xE2
#define DALI_CMD_DT6_SELECT_DIMMING_CURVE 0xE3
#define DALI_CMD_DT6_STORE_DTR_AS_FAST_FADE_TIME 0xE4
#define DALI_CMD_DT6_QUERY_GEAR_TYPE 0xED
#define DALI_CMD_DT6_QUERY_DIMMING_CURVE 0xEE
#define DALI_CMD_DT6_QUERY_POSSIBLE_OPERATING_MODES 0xEF
#define DALI_CMD_DT6_QUERY_FEATURES 0xF0
#define DALI_CMD_DT6_QUERY_FAILURE_STATUS 0xF1
#define DALI_CMD_DT6_QUERY_SHORT_CIRCUIT 0xF2
#define DALI_CMD_DT6_QUERY_OPEN_CIRCUIT 0xF3
#define DALI_CMD_DT6_QUERY_LOAD_DECREASE 0xF4
#define DALI_CMD_DT6_QUERY_LOAD_INCREASE 0xF5
#define DALI_CMD_DT6_QUERY_CURRENT_PROTECTOR_ACTIVE 0xF6
#define DALI_CMD_DT6_QUERY_THERMAL_SHUTDOWN 0xF7
#define DALI_CMD_DT6_QUERY_THERMAL_OVERLOAD 0xF8
#define DALI_CMD_DT6_QUERY_REFERENCE_RUNNING 0xF9
#define DALI_CMD_DT6_QUERY_REFERENCE_MEASUREMENT_FAILED 0xFA
#define DALI_CMD_DT6_QUERY_CURRENT_PROTECTOR_ENABLED 0xFB
#define DALI_CMD_DT6_QUERY_OPERATING_MODE 0xFC
#define DALI_CMD_DT6_QUERY_FAST_FADE_TIME 0xFD
#define DALI_CMD_DT6_QUERY_MIN_FAST_FADE_TIME 0xFE
#define DALI_CMD_DT6_QUERY_EXTENDED_VERSION 0xFF
// DT8 commands and queries
#define DALI_CMD_DT8_STORE_DTR_AS_COLORX 0xE0
#define DALI_CMD_DT8_STORE_DTR_AS_COLORY 0xE1
+3
View File
@@ -17,6 +17,9 @@ struct DaliLongAddress {
struct DaliDeviceCapabilities {
std::optional<bool> supportsDt1;
std::optional<bool> supportsDt4;
std::optional<bool> supportsDt5;
std::optional<bool> supportsDt6;
std::optional<bool> supportsDt8;
static DaliDeviceCapabilities fromJson(const DaliValue::Object* json);
+126
View File
@@ -0,0 +1,126 @@
#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);
};
+78
View File
@@ -0,0 +1,78 @@
#pragma once
#include "base.hpp"
#include <optional>
class DaliDT5ConverterFeatures {
public:
explicit DaliDT5ConverterFeatures(int raw) : raw_(raw & 0xFF) {}
int raw() const { return raw_; }
bool outputRange0To10VSelectable() const { return bit(0x01); }
bool internalPullUpSelectable() const { return bit(0x02); }
bool outputFaultDetectionSelectable() const { return bit(0x04); }
bool mainsRelay() const { return bit(0x08); }
bool outputLevelQueryable() const { return bit(0x10); }
bool nonLogarithmicDimmingCurveSupported() const { return bit(0x20); }
bool physicalSelectionByOutputLossSupported() const { return bit(0x40); }
bool physicalSelectionSwitchSupported() const { return bit(0x80); }
private:
int raw_ = 0;
bool bit(int mask) const { return (raw_ & mask) != 0; }
};
class DaliDT5FailureStatus {
public:
explicit DaliDT5FailureStatus(int raw) : raw_(raw & 0xFF) {}
int raw() const { return raw_; }
bool outputFaultDetected() const { return (raw_ & 0x01) != 0; }
private:
int raw_ = 0;
};
class DaliDT5ConverterStatus {
public:
explicit DaliDT5ConverterStatus(int raw) : raw_(raw & 0xFF) {}
int raw() const { return raw_; }
bool zeroToTenVoltOperation() const { return (raw_ & 0x01) != 0; }
bool internalPullUpOn() const { return (raw_ & 0x02) != 0; }
bool nonLogarithmicDimmingCurveActive() const { return (raw_ & 0x04) != 0; }
private:
int raw_ = 0;
};
class DaliDT5 {
public:
explicit DaliDT5(DaliBase& base);
bool enableDT5();
bool setOutputRange1To10V(int a);
bool setOutputRange0To10V(int a);
bool switchOnInternalPullUp(int a);
bool switchOffInternalPullUp(int a);
bool storePhysicalMinimum(int a, int level);
bool selectDimmingCurve(int a, int curve);
bool resetConverterSettings(int a);
std::optional<int> getDimmingCurve(int a);
std::optional<int> getOutputLevelRaw(int a);
std::optional<double> getOutputLevelVolts(int a);
std::optional<DaliDT5ConverterFeatures> getConverterFeatures(int a);
std::optional<DaliDT5FailureStatus> getFailureStatus(int a);
std::optional<DaliDT5ConverterStatus> getConverterStatus(int a);
std::optional<int> getExtendedVersion(int a);
private:
DaliBase& base_;
bool enable();
static int addrOf(int a);
bool send(int a, int code, bool twice = false);
std::optional<int> query(int a, int code);
};
+130
View File
@@ -0,0 +1,130 @@
#pragma once
#include "base.hpp"
#include <optional>
class DaliDT6GearType {
public:
explicit DaliDT6GearType(int raw) : raw_(raw & 0xFF) {}
int raw() const { return raw_; }
bool ledPowerSupplyIntegrated() const { return bit(0x01); }
bool ledModuleIntegrated() const { return bit(0x02); }
bool acSupplyPossible() const { return bit(0x04); }
bool dcSupplyPossible() const { return bit(0x08); }
private:
int raw_ = 0;
bool bit(int mask) const { return (raw_ & mask) != 0; }
};
class DaliDT6OperatingModes {
public:
explicit DaliDT6OperatingModes(int raw) : raw_(raw & 0xFF) {}
int raw() const { return raw_; }
bool pwmModePossible() const { return bit(0x01); }
bool amModePossible() const { return bit(0x02); }
bool currentControlledOutput() const { return bit(0x04); }
bool highCurrentPulseMode() const { return bit(0x08); }
private:
int raw_ = 0;
bool bit(int mask) const { return (raw_ & mask) != 0; }
};
class DaliDT6Features {
public:
explicit DaliDT6Features(int raw) : raw_(raw & 0xFF) {}
int raw() const { return raw_; }
bool canQueryShortCircuit() const { return bit(0x01); }
bool canQueryOpenCircuit() const { return bit(0x02); }
bool canQueryLoadDecrease() const { return bit(0x04); }
bool canQueryLoadIncrease() const { return bit(0x08); }
bool canQueryCurrentProtector() const { return bit(0x10); }
bool canQueryThermalShutdown() const { return bit(0x20); }
bool canQueryThermalOverloadReduction() const { return bit(0x40); }
bool physicalSelectionSupported() const { return bit(0x80); }
private:
int raw_ = 0;
bool bit(int mask) const { return (raw_ & mask) != 0; }
};
class DaliDT6FailureStatus {
public:
explicit DaliDT6FailureStatus(int raw) : raw_(raw & 0xFF) {}
int raw() const { return raw_; }
bool shortCircuit() const { return bit(0x01); }
bool openCircuit() const { return bit(0x02); }
bool loadDecrease() const { return bit(0x04); }
bool loadIncrease() const { return bit(0x08); }
bool currentProtectorActive() const { return bit(0x10); }
bool thermalShutdown() const { return bit(0x20); }
bool thermalOverloadReduction() const { return bit(0x40); }
bool referenceMeasurementFailed() const { return bit(0x80); }
private:
int raw_ = 0;
bool bit(int mask) const { return (raw_ & mask) != 0; }
};
class DaliDT6OperatingMode {
public:
explicit DaliDT6OperatingMode(int raw) : raw_(raw & 0xFF) {}
int raw() const { return raw_; }
bool pwmModeActive() const { return bit(0x01); }
bool amModeActive() const { return bit(0x02); }
bool currentControlledOutput() const { return bit(0x04); }
bool highCurrentPulseModeActive() const { return bit(0x08); }
bool nonLogarithmicDimmingCurveActive() const { return bit(0x10); }
private:
int raw_ = 0;
bool bit(int mask) const { return (raw_ & mask) != 0; }
};
class DaliDT6 {
public:
explicit DaliDT6(DaliBase& base);
bool enableDT6();
bool referenceSystemPower(int a);
bool enableCurrentProtector(int a);
bool disableCurrentProtector(int a);
bool selectDimmingCurve(int a, int curve);
bool storeFastFadeTime(int a, int value);
std::optional<DaliDT6GearType> getGearType(int a);
std::optional<int> getDimmingCurve(int a);
std::optional<DaliDT6OperatingModes> getPossibleOperatingModes(int a);
std::optional<DaliDT6Features> getFeatures(int a);
std::optional<DaliDT6FailureStatus> getFailureStatus(int a);
std::optional<bool> hasShortCircuit(int a);
std::optional<bool> hasOpenCircuit(int a);
std::optional<bool> hasLoadDecrease(int a);
std::optional<bool> hasLoadIncrease(int a);
std::optional<bool> isCurrentProtectorActive(int a);
std::optional<bool> hasThermalShutDown(int a);
std::optional<bool> hasThermalOverload(int a);
std::optional<bool> isReferenceRunning(int a);
std::optional<bool> isReferenceMeasurementFailed(int a);
std::optional<bool> isCurrentProtectorEnabled(int a);
std::optional<DaliDT6OperatingMode> getOperatingMode(int a);
std::optional<int> getFastFadeTime(int a);
std::optional<int> getMinFastFadeTime(int a);
std::optional<int> getExtendedVersion(int a);
private:
DaliBase& base_;
bool enable();
static int addrOf(int a);
bool send(int a, int code, bool twice = false);
std::optional<int> query(int a, int code);
std::optional<bool> queryYesNo(int a, int code);
};