Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rsnodgrass committed Jan 22, 2024
1 parent 70f2f45 commit 39d4895
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
8 changes: 1 addition & 7 deletions pyavcontrol/client/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ class DeviceClientAsync(DeviceClient):
"""Asynchronous client for communicating with devices via the provided connection"""

def __init__(self, model: DeviceModel, connection: DeviceConnection, loop):
DeviceClient.__init__(self, model, connection)
self._connection = connection
super().__init__(model, connection)
self._loop = loop
self._callback = None

# FIXME: encoding should come from model
self._encoding = (
model.encoding
) # serial_config.get(CONFIG.encoding, DEFAULT_ENCODING)

@property
def is_async(self):
"""
Expand Down
11 changes: 4 additions & 7 deletions pyavcontrol/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,19 @@ class DeviceClient(ABC):
to control a device.
"""

def __new__(cls, *args, **kwargs):
return super().__new__(cls)
#def __new__(cls, *args, **kwargs):
# return super().__new__(cls)

def __init__(self, model: DeviceModel, connection: DeviceConnection):
super().__init__()
self._model = model
self._protocol_def = model.definition # FIXME
self._connection = connection
self._callback = None
self._encoding = DEFAULT_ENCODING

def encoding(self) -> str:
"""
:return: the bytes encoding format for requests/responses
"""
return self._encoding
return self._model.encoding

@property
def is_async(self):
Expand Down Expand Up @@ -200,7 +197,7 @@ def send_raw(self, data: bytes) -> None:

# @abstractmethod
def describe(self) -> dict:
return self._protocol_def
return self._model.definition

# FIXME: should take:
# 1. a model
Expand Down
11 changes: 1 addition & 10 deletions pyavcontrol/client/sync_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,8 @@ class DeviceClientSync(DeviceClient):
"""Synchronous client for communicating with devices via the provided connection"""

def __init__(self, model: DeviceModel, connection: DeviceConnection):
DeviceClient.__init__(self, model, connection)
self._protocol_defs = None

# FIXME:
# self._connection = serial.serial_for_url(url, **serial_config)
self._connection = connection

super().__init__(model, connection)
self._callback = None
self._encoding = (
model.encoding
) # serial_config.get('encoding', DEFAULT_ENCODING)

@synchronized
def send_raw(self, data: bytes) -> None:
Expand Down

0 comments on commit 39d4895

Please sign in to comment.