Refactor DALI command handling: update DALI_DT1 and DALI_DT6 methods for improved command execution and status querying
This commit is contained in:
+12
-12
@@ -194,19 +194,19 @@
|
||||
#define DALI_CMD_DT1_STORE_DTR_AS_EMERGENCY_LEVEL 0xE9
|
||||
#define DALI_CMD_DT1_STORE_DTR_AS_DELAY_TIME_HIGH 0xEA
|
||||
#define DALI_CMD_DT1_STORE_DTR_AS_DELAY_TIME_LOW 0xEB
|
||||
#define DALI_CMD_DT1_STORE_DTR_AS_PROLONG_TIME 0xEC
|
||||
#define DALI_CMD_DT1_STORE_DTR_AS_RATED_DURATION 0xED
|
||||
#define DALI_CMD_DT1_STORE_DTR_AS_EMERGENCY_MIN_LEVEL 0xEE
|
||||
#define DALI_CMD_DT1_STORE_DTR_AS_EMERGENCY_MAX_LEVEL 0xEF
|
||||
#define DALI_CMD_DT1_STORE_FUNCTION_TEST_INTERVAL 0xEC
|
||||
#define DALI_CMD_DT1_STORE_DURATION_TEST_INTERVAL 0xED
|
||||
#define DALI_CMD_DT1_STORE_TEST_EXECUTION_TIMEOUT 0xEE
|
||||
#define DALI_CMD_DT1_STORE_PROLONG_TIME 0xEF
|
||||
#define DALI_CMD_DT1_START_IDENTIFICATION 0xF0
|
||||
#define DALI_CMD_DT1_QUERY_EMERGENCY_LEVEL 0xF1
|
||||
#define DALI_CMD_DT1_QUERY_EMERGENCY_MIN_LEVEL 0xF2
|
||||
#define DALI_CMD_DT1_QUERY_EMERGENCY_MAX_LEVEL 0xF3
|
||||
#define DALI_CMD_DT1_QUERY_PROLONG_TIME 0xF4
|
||||
#define DALI_CMD_DT1_QUERY_FUNCTION_TEST_INTERVAL 0xF5
|
||||
#define DALI_CMD_DT1_QUERY_DURATION_TEST_INTERVAL 0xF6
|
||||
#define DALI_CMD_DT1_QUERY_DURATION_TEST_RESULT 0xF7
|
||||
#define DALI_CMD_DT1_QUERY_LAMP_EMERGENCY_TIME 0xF8
|
||||
#define DALI_CMD_DT1_QUERY_BATTERY_CHARGE 0xF1
|
||||
#define DALI_CMD_DT1_QUERY_TEST_TIMING 0xF2
|
||||
#define DALI_CMD_DT1_QUERY_DURATION_TEST_RESULT 0xF3
|
||||
#define DALI_CMD_DT1_QUERY_LAMP_EMERGENCY_TIME 0xF4
|
||||
#define DALI_CMD_DT1_QUERY_LAMP_TOTAL_OPERATION_TIME 0xF5
|
||||
#define DALI_CMD_DT1_QUERY_EMERGENCY_LEVEL 0xF6
|
||||
#define DALI_CMD_DT1_QUERY_EMERGENCY_MIN_LEVEL 0xF7
|
||||
#define DALI_CMD_DT1_QUERY_EMERGENCY_MAX_LEVEL 0xF8
|
||||
#define DALI_CMD_DT1_QUERY_RATED_DURATION 0xF9
|
||||
#define DALI_CMD_DT1_QUERY_EMERGENCY_MODE 0xFA
|
||||
#define DALI_CMD_DT1_QUERY_FEATURE 0xFB
|
||||
|
||||
@@ -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