|
| 1 | +"""Commands and responses from IEC 62386 part 206. |
| 2 | +
|
| 3 | +This part covers conversion from digital signal into DC voltage. |
| 4 | +""" |
| 5 | + |
| 6 | +from dali import command |
| 7 | +from dali.gear.general import _StandardCommand, QueryExtendedVersionNumberMixin |
| 8 | + |
| 9 | + |
| 10 | +class _ConversionCommand(_StandardCommand): |
| 11 | + devicetype = 5 |
| 12 | + |
| 13 | + |
| 14 | +class _ConversionConfigCommand(_ConversionCommand): |
| 15 | + """An incandescent lighting configuration command as defined in |
| 16 | + section 11.3.4.1 of IEC 62386-206:2009. |
| 17 | + """ |
| 18 | + sendtwice = True |
| 19 | + |
| 20 | + |
| 21 | +############################################################################### |
| 22 | +# Commands from IEC 62386-206 section 11.3.4.1 |
| 23 | +############################################################################### |
| 24 | + |
| 25 | +class SetOutputRange1To10V(_ConversionConfigCommand): |
| 26 | + """Set the output range to 1V - 10V |
| 27 | +
|
| 28 | + Converters without this feature shall not react. |
| 29 | + """ |
| 30 | + _cmdval = 224 |
| 31 | + |
| 32 | + |
| 33 | +class SetOutputRange0To10V(_ConversionConfigCommand): |
| 34 | + """Set the output range to 0V - 10V |
| 35 | +
|
| 36 | + Converters without this feature shall not react. |
| 37 | + """ |
| 38 | + _cmdval = 225 |
| 39 | + |
| 40 | + |
| 41 | +class SwitchOnInternalPullUp(_ConversionConfigCommand): |
| 42 | + """Switch on the internal pull-up resistor at the control voltage output |
| 43 | +
|
| 44 | + Converters without this feature shall not react. |
| 45 | + """ |
| 46 | + _cmdval = 226 |
| 47 | + |
| 48 | + |
| 49 | +class SwitchOffInternalPullUp(_ConversionConfigCommand): |
| 50 | + """Switch off the internal pull-up resistor at the control voltage output |
| 51 | +
|
| 52 | + Converters without this feature shall not react. |
| 53 | + """ |
| 54 | + _cmdval = 227 |
| 55 | + |
| 56 | + |
| 57 | +class StoreDtrAsPhysicalMinimum(_ConversionConfigCommand): |
| 58 | + """The physical minimum level shall be changed to the value given in the DTR""" |
| 59 | + _cmdval = 228 |
| 60 | + |
| 61 | + |
| 62 | +class SelectDimmingCurve(_ConversionConfigCommand): |
| 63 | + """Select Dimming Curve |
| 64 | +
|
| 65 | + If DTR0 is 0 then selects the standard logarithmic curve |
| 66 | +
|
| 67 | + If DTR0 is 1 then selects a linear dimming curve |
| 68 | +
|
| 69 | + Other values of DTR0 are reserved and will not change the dimming |
| 70 | + curve. The setting is stored in non-volatile memory and is not |
| 71 | + cleared by the Reset command. |
| 72 | + """ |
| 73 | + _cmdval = 229 |
| 74 | + |
| 75 | + |
| 76 | +class ResetConverterSettings(_ConversionConfigCommand): |
| 77 | + """Reset parameters which are not affected by RESET |
| 78 | +
|
| 79 | + All converter settings not influenced by the RESET command shall be set to the |
| 80 | + default values given in clause 10 of IEC 62386-206:2009. |
| 81 | + """ |
| 82 | + _cmdval = 230 |
| 83 | + |
| 84 | + |
| 85 | +############################################################################### |
| 86 | +# Commands from IEC 62386-205 section 11.3.4.2 |
| 87 | +############################################################################### |
| 88 | + |
| 89 | +class QueryDimmingCurve(_ConversionCommand): |
| 90 | + """Query Dimming Curve |
| 91 | +
|
| 92 | + 0 = standard logarithmic |
| 93 | + 1 = linear |
| 94 | + 2-255 = reserved for future use |
| 95 | + """ |
| 96 | + _cmdval = 238 |
| 97 | + response = command.Response |
| 98 | + |
| 99 | + |
| 100 | +class OutputLevelResponse(command.NumericResponse): |
| 101 | + def __str__(self): |
| 102 | + if isinstance(self.value, int): |
| 103 | + if self.value == 254: |
| 104 | + return "10.16V or more" |
| 105 | + elif self.value == 255: |
| 106 | + return "unknown" |
| 107 | + else: |
| 108 | + return f"{self.value * 0.04} V" |
| 109 | + return self.value |
| 110 | + |
| 111 | + |
| 112 | +class QueryOutputLevel(_ConversionCommand): |
| 113 | + """Query the output level |
| 114 | +
|
| 115 | + The answer shall be the analog output level in units of 0.04V, fiving a range of 0V to 10.16V. |
| 116 | +
|
| 117 | + Raw value 254 maps to 10.16V or higher. |
| 118 | + Raw value of 255 means "the output level is not known". |
| 119 | +
|
| 120 | + Converters without this feature shall not react. |
| 121 | + """ |
| 122 | + _cmdval = 239 |
| 123 | + response = OutputLevelResponse |
| 124 | + |
| 125 | + |
| 126 | +class QueryConverterFeaturesResponse(command.BitmapResponse): |
| 127 | + bits = [ |
| 128 | + "0V - 10V output selectable", |
| 129 | + "internal pull-up selectable", |
| 130 | + "detection of output fault selectable", |
| 131 | + "mains relay", |
| 132 | + "output level can be queried", |
| 133 | + "non-logarithmic dimming curve supported", |
| 134 | + "physical selection / lamp fail detection by loss out output supported", |
| 135 | + "physical selection switch supported", |
| 136 | + ] |
| 137 | + |
| 138 | + |
| 139 | +class QueryConverterFeatures(_ConversionCommand): |
| 140 | + """Query hardware features of the converter""" |
| 141 | + _cmdval = 240 |
| 142 | + response = QueryConverterFeaturesResponse |
| 143 | + |
| 144 | + |
| 145 | +class QueryFailureStatusResponse(command.BitmapResponse): |
| 146 | + bits = [ |
| 147 | + "output fault detected", |
| 148 | + ] |
| 149 | + |
| 150 | + |
| 151 | +class QueryFailureStatus(_ConversionCommand): |
| 152 | + """Query failure status register""" |
| 153 | + _cmdval = 241 |
| 154 | + response = QueryFailureStatusResponse |
| 155 | + |
| 156 | + |
| 157 | +class QueryConverterStatusResponse(command.BitmapResponse): |
| 158 | + bits = [ |
| 159 | + "0-10V operation", |
| 160 | + "internal pull-up on", |
| 161 | + "non-logarithmic dimming curve active", |
| 162 | + ] |
| 163 | + |
| 164 | + |
| 165 | +class QueryConverterStatus(_ConversionCommand): |
| 166 | + """Query the current status of the converter""" |
| 167 | + _cmdval = 242 |
| 168 | + response = QueryConverterStatusResponse |
| 169 | + |
| 170 | + |
| 171 | +class QueryExtendedVersionNumber(QueryExtendedVersionNumberMixin, |
| 172 | + _ConversionCommand): |
| 173 | + pass |
0 commit comments