forked from M-Labs/thermostat
Update and add docstrings to aioclient
This commit is contained in:
parent
981c28ac27
commit
8520dae93b
@ -13,6 +13,15 @@ class Client:
|
||||
self._command_lock = asyncio.Lock()
|
||||
|
||||
async def connect(self, host='192.168.1.26', port=23, timeout=None):
|
||||
"""Connect to the TEC with host and port, throws TimeoutError if
|
||||
unable to connect. Returns True if not cancelled with disconnect.
|
||||
|
||||
Example::
|
||||
client = aioclient.Client()
|
||||
connected = await client.connect()
|
||||
if connected:
|
||||
return
|
||||
"""
|
||||
self._connecting_task = asyncio.create_task(asyncio.open_connection(host, port))
|
||||
try:
|
||||
self._reader, self._writer = await self._connecting_task
|
||||
@ -24,12 +33,15 @@ class Client:
|
||||
return True
|
||||
|
||||
def is_connecting(self):
|
||||
"""Returns True if client is connecting"""
|
||||
return self._connecting_task is not None
|
||||
|
||||
def is_connected(self):
|
||||
"""Returns True if client is connected"""
|
||||
return self._writer is not None
|
||||
|
||||
async def disconnect(self):
|
||||
"""Disconnect the client if connected, cancel connection if connecting"""
|
||||
if self._connecting_task is not None:
|
||||
self._connecting_task.cancel()
|
||||
self._connecting_task = None
|
||||
@ -170,11 +182,11 @@ class Client:
|
||||
"""Set configuration parameters
|
||||
|
||||
Examples::
|
||||
tec.set_param("pwm", 0, "max_v", 2.0)
|
||||
tec.set_param("pid", 1, "output_max", 2.5)
|
||||
tec.set_param("s-h", 0, "t0", 20.0)
|
||||
tec.set_param("center", 0, "vref")
|
||||
tec.set_param("postfilter", 1, 21)
|
||||
await tec.set_param("pwm", 0, "max_v", 2.0)
|
||||
await tec.set_param("pid", 1, "output_max", 2.5)
|
||||
await tec.set_param("s-h", 0, "t0", 20.0)
|
||||
await tec.set_param("center", 0, "vref")
|
||||
await tec.set_param("postfilter", 1, 21)
|
||||
|
||||
See the firmware's README.md for a full list.
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user