|
@@ -156,29 +156,25 @@ class Sink:
|
156
|
156
|
"""Blinks the LED quickly"""
|
157
|
157
|
self.send_command("identify")
|
158
|
158
|
|
159
|
|
- def output(self, state=None):
|
160
|
|
- """Gets or sets the state of a Sink's output
|
|
159
|
+ @property
|
|
160
|
+ def output(self):
|
|
161
|
+ """The state of the Sink's output
|
161
|
162
|
|
162
|
163
|
Raises KeyError if the ``output`` command is not available on the Sink.
|
163
|
164
|
Raises ValueError if an invalid output is read.
|
164
|
|
-
|
165
|
|
- :param state: optional value of the output to set
|
166
|
|
-
|
167
|
|
- :returns: the output state if state is None, None otherwise
|
168
|
165
|
"""
|
169
|
|
- # With no parameter, return the output state
|
170
|
|
- if state is None:
|
171
|
|
- value = self.send_command("output")
|
172
|
|
- if value[0] == b"enabled":
|
173
|
|
- return True
|
174
|
|
- elif value[0] == b"disabled":
|
175
|
|
- return False
|
176
|
|
- else:
|
177
|
|
- # If unexpected text is returned, raise an exception indicating a
|
178
|
|
- # firmware error
|
179
|
|
- raise ValueError("unknown output state")
|
|
166
|
+ value = self.send_command("output")
|
|
167
|
+ if value[0] == b"enabled":
|
|
168
|
+ return True
|
|
169
|
+ elif value[0] == b"disabled":
|
|
170
|
+ return False
|
|
171
|
+ else:
|
|
172
|
+ # If unexpected text is returned, raise an exception indicating a
|
|
173
|
+ # firmware error
|
|
174
|
+ raise ValueError("unknown output state")
|
180
|
175
|
|
181
|
|
- # With a parameter, set the output state
|
|
176
|
+ @output.setter
|
|
177
|
+ def output(self, state):
|
182
|
178
|
if state:
|
183
|
179
|
self.send_command("output enable")
|
184
|
180
|
else:
|
|
@@ -218,7 +214,8 @@ class SinkConfig(namedtuple("SinkConfig", "status flags v i")):
|
218
|
214
|
``status`` should be a `SinkStatus` object. ``flags`` should be zero or
|
219
|
215
|
more `SinkFlags` values. ``v`` is the voltage in millivolts, and ``i``
|
220
|
216
|
is the current in milliamperes. `None` is also an acceptible value for
|
221
|
|
- any of the fields."""
|
|
217
|
+ any of the fields.
|
|
218
|
+ """
|
222
|
219
|
__slots__ = ()
|
223
|
220
|
|
224
|
221
|
def __str__(self):
|