forked from M-Labs/thermostat
AsyncIO version Client -> AsyncioClient
This commit is contained in:
parent
b76f5a01fa
commit
6b08720f4f
@ -1,9 +1,9 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from pytec.aioclient import Client
|
from pytec.aioclient import AsyncioClient
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
tec = Client()
|
tec = AsyncioClient()
|
||||||
await tec.start_session() # (host="192.168.1.26", port=23)
|
await tec.start_session() # (host="192.168.1.26", port=23)
|
||||||
await tec.set_param("s-h", 1, "t0", 20)
|
await tec.set_param("s-h", 1, "t0", 20)
|
||||||
print(await tec.get_pwm())
|
print(await tec.get_pwm())
|
||||||
|
@ -11,7 +11,7 @@ class StoppedConnecting(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Client:
|
class AsyncioClient:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._reader = None
|
self._reader = None
|
||||||
self._writer = None
|
self._writer = None
|
||||||
@ -26,7 +26,7 @@ class Client:
|
|||||||
Throws asyncio.TimeoutError if timeout was exceeded.
|
Throws asyncio.TimeoutError if timeout was exceeded.
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
client = Client()
|
client = AsyncioClient()
|
||||||
try:
|
try:
|
||||||
await client.start_session()
|
await client.start_session()
|
||||||
except StoppedConnecting:
|
except StoppedConnecting:
|
||||||
|
@ -3,7 +3,7 @@ from qasync import asyncSlot
|
|||||||
from pytec.gui.model.property import Property, PropertyMeta
|
from pytec.gui.model.property import Property, PropertyMeta
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from pytec.aioclient import Client
|
from pytec.aioclient import AsyncioClient
|
||||||
|
|
||||||
|
|
||||||
class Thermostat(QObject, metaclass=PropertyMeta):
|
class Thermostat(QObject, metaclass=PropertyMeta):
|
||||||
@ -20,7 +20,7 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||||||
|
|
||||||
def __init__(self, parent, update_s):
|
def __init__(self, parent, update_s):
|
||||||
self._update_s = update_s
|
self._update_s = update_s
|
||||||
self._client = Client()
|
self._client = AsyncioClient()
|
||||||
self._watch_task = None
|
self._watch_task = None
|
||||||
self._report_mode_task = None
|
self._report_mode_task = None
|
||||||
self._poll_for_report = True
|
self._poll_for_report = True
|
||||||
|
Loading…
Reference in New Issue
Block a user