Refactor DALI command handling: update DALI_DT1 and DALI_DT6 methods for improved command execution and status querying
This commit is contained in:
@@ -10,6 +10,7 @@ struct DT1TestStatusDetailed {
|
||||
std::optional<int> emergencyStatus;
|
||||
std::optional<int> emergencyMode;
|
||||
std::optional<int> feature;
|
||||
std::optional<int> deviceStatus;
|
||||
bool testInProgress = false;
|
||||
bool lampFailure = false;
|
||||
bool batteryFailure = false;
|
||||
@@ -18,6 +19,26 @@ struct DT1TestStatusDetailed {
|
||||
bool testDone = false;
|
||||
bool identifyActive = false;
|
||||
bool physicalSelectionActive = false;
|
||||
bool circuitFailure = false;
|
||||
bool batteryDurationFailure = false;
|
||||
bool emergencyLampFailure = false;
|
||||
bool functionTestMaxDelayExceeded = false;
|
||||
bool durationTestMaxDelayExceeded = false;
|
||||
bool functionTestFailed = false;
|
||||
bool durationTestFailed = false;
|
||||
bool functionTestResultValid = false;
|
||||
bool durationTestResultValid = false;
|
||||
bool batteryFullyCharged = false;
|
||||
bool functionTestPending = false;
|
||||
bool durationTestPending = false;
|
||||
bool restModeActive = false;
|
||||
bool normalModeActive = false;
|
||||
bool emergencyModeActive = false;
|
||||
bool extendedEmergencyModeActive = false;
|
||||
bool hardwiredInhibitActive = false;
|
||||
bool hardwiredSwitchOn = false;
|
||||
bool supportsAutoTest = false;
|
||||
bool supportsAdjustableEmergencyLevel = false;
|
||||
};
|
||||
|
||||
class DaliDT1DeviceStatus {
|
||||
@@ -60,6 +81,63 @@ class DaliDT1EmergencyStatus {
|
||||
bool bit(int mask) const { return (raw_ & mask) != 0; }
|
||||
};
|
||||
|
||||
class DaliDT1FailureStatus {
|
||||
public:
|
||||
explicit DaliDT1FailureStatus(int raw) : raw_(raw & 0xFF) {}
|
||||
|
||||
int raw() const { return raw_; }
|
||||
bool circuitFailure() const { return bit(0x01); }
|
||||
bool batteryDurationFailure() const { return bit(0x02); }
|
||||
bool batteryFailure() const { return bit(0x04); }
|
||||
bool emergencyLampFailure() const { return bit(0x08); }
|
||||
bool functionTestMaxDelayExceeded() const { return bit(0x10); }
|
||||
bool durationTestMaxDelayExceeded() const { return bit(0x20); }
|
||||
bool functionTestFailed() const { return bit(0x40); }
|
||||
bool durationTestFailed() const { return bit(0x80); }
|
||||
|
||||
private:
|
||||
int raw_ = 0;
|
||||
bool bit(int mask) const { return (raw_ & mask) != 0; }
|
||||
};
|
||||
|
||||
class DaliDT1EmergencyMode {
|
||||
public:
|
||||
explicit DaliDT1EmergencyMode(int raw) : raw_(raw & 0xFF) {}
|
||||
|
||||
int raw() const { return raw_; }
|
||||
bool restModeActive() const { return bit(0x01); }
|
||||
bool normalModeActive() const { return bit(0x02); }
|
||||
bool emergencyModeActive() const { return bit(0x04); }
|
||||
bool extendedEmergencyModeActive() const { return bit(0x08); }
|
||||
bool functionTestInProgress() const { return bit(0x10); }
|
||||
bool durationTestInProgress() const { return bit(0x20); }
|
||||
bool hardwiredInhibitActive() const { return bit(0x40); }
|
||||
bool hardwiredSwitchOn() const { return bit(0x80); }
|
||||
|
||||
private:
|
||||
int raw_ = 0;
|
||||
bool bit(int mask) const { return (raw_ & mask) != 0; }
|
||||
};
|
||||
|
||||
class DaliDT1Features {
|
||||
public:
|
||||
explicit DaliDT1Features(int raw) : raw_(raw & 0xFF) {}
|
||||
|
||||
int raw() const { return raw_; }
|
||||
bool integralEmergencyControlGear() const { return bit(0x01); }
|
||||
bool maintainedControlGear() const { return bit(0x02); }
|
||||
bool switchedMaintainedControlGear() const { return bit(0x04); }
|
||||
bool autoTestCapability() const { return bit(0x08); }
|
||||
bool adjustableEmergencyLevel() const { return bit(0x10); }
|
||||
bool hardwiredInhibitSupported() const { return bit(0x20); }
|
||||
bool physicalSelectionSupported() const { return bit(0x40); }
|
||||
bool relightInRestModeSupported() const { return bit(0x80); }
|
||||
|
||||
private:
|
||||
int raw_ = 0;
|
||||
bool bit(int mask) const { return (raw_ & mask) != 0; }
|
||||
};
|
||||
|
||||
class DaliDT1 {
|
||||
public:
|
||||
explicit DaliDT1(DaliBase& base);
|
||||
@@ -93,7 +171,9 @@ class DaliDT1 {
|
||||
bool storeTestDelayTimeLowByte(int a, int lowByte);
|
||||
bool storeFunctionTestIntervalDays(int a, int days);
|
||||
bool storeDurationTestIntervalWeeks(int a, int weeks);
|
||||
bool storeTestExecutionTimeoutDays(int a, int days);
|
||||
bool storeTestDelayTime16(int a, int quartersOfHour);
|
||||
bool storeProlongTimeHalfMinutes(int a, int halfMinutes);
|
||||
bool storeProlongTimeMinutes(int a, int minutes);
|
||||
bool storeRatedDurationMinutes(int a, int minutes);
|
||||
bool storeEmergencyMinLevel(int a, int level);
|
||||
@@ -105,18 +185,34 @@ class DaliDT1 {
|
||||
const std::optional<int>& dtr1 = std::nullopt);
|
||||
std::optional<int> getExtendedVersionDT1(int a);
|
||||
|
||||
std::optional<int> getBatteryChargeLevel(int a);
|
||||
std::optional<int> getTestTiming(int a, int selector);
|
||||
std::optional<int> getFunctionTestDelayHighByte(int a);
|
||||
std::optional<int> getFunctionTestDelayLowByte(int a);
|
||||
std::optional<int> getDurationTestDelayHighByte(int a);
|
||||
std::optional<int> getDurationTestDelayLowByte(int a);
|
||||
std::optional<int> getEmergencyLevel(int a);
|
||||
std::optional<int> getEmergencyMinLevel(int a);
|
||||
std::optional<int> getEmergencyMaxLevel(int a);
|
||||
std::optional<int> getProlongTimeHalfMinutes(int a);
|
||||
std::optional<int> getProlongTimeMinutes(int a);
|
||||
std::optional<int> getFunctionTestIntervalDays(int a);
|
||||
std::optional<int> getDurationTestIntervalWeeks(int a);
|
||||
std::optional<int> getTestExecutionTimeoutDays(int a);
|
||||
std::optional<int> getDurationTestResultRaw(int a);
|
||||
std::optional<int> getDurationTestResult(int a);
|
||||
std::optional<int> getLampEmergencyTimeHours(int a);
|
||||
std::optional<int> getLampEmergencyTimeMinutes(int a);
|
||||
std::optional<int> getLampTotalOperationTime4HourUnits(int a);
|
||||
std::optional<int> getLampTotalOperationTimeHours(int a);
|
||||
std::optional<int> getRatedDurationRaw(int a);
|
||||
std::optional<int> getRatedDurationMinutes(int a);
|
||||
|
||||
std::optional<DaliDT1DeviceStatus> getDeviceStatus(int a);
|
||||
std::optional<DaliDT1EmergencyStatus> getEmergencyStatusDecoded(int a);
|
||||
std::optional<DaliDT1FailureStatus> getFailureStatusDecoded(int a);
|
||||
std::optional<DaliDT1EmergencyMode> getEmergencyModeDecoded(int a);
|
||||
std::optional<DaliDT1Features> getFeatureDecoded(int a);
|
||||
|
||||
private:
|
||||
DaliBase& base_;
|
||||
@@ -124,6 +220,8 @@ class DaliDT1 {
|
||||
bool enable();
|
||||
static int addrOf(int a);
|
||||
bool send(int a, int code);
|
||||
bool sendWithDTR(int a, int code, int value);
|
||||
std::optional<int> query(int a, int code);
|
||||
std::optional<int> queryTiming(int a, int selector);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user