Skip to content

Commit

Permalink
refactor: migrate recorder to DT-aux interface (#80)
Browse files Browse the repository at this point in the history
* simply switch record aux to dt interface
* feat: adapt record aux to the double threaded auxiliay interface
  • Loading branch information
BKaDamien authored Jul 6, 2022
1 parent 3d7b683 commit 9a36fae
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/whats_new/version_ongoing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ DUT Auxiliary adaption
^^^^^^^^^^^^^^^^^^^^^^
refactor/redesign of the device under test auxiliary to fit with the brand new double
threaded auxiliary interface

Record Auxiliary adaption
^^^^^^^^^^^^^^^^^^^^^^^^^
adapt the record auxiliary to fit with the brand new double threaded auxiliary interface
2 changes: 1 addition & 1 deletion src/pykiso/interfaces/dt_auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AuxCommand(Enum):

class DTAuxiliaryInterface(abc.ABC):
"""Common interface for all double threaded auxiliary. A so called
<< double thread>> auxiliary, simply encapsulate two threads one
<< double threaded >> auxiliary, simply encapsulate two threads one
for the reception and one for the transmmission.
"""

Expand Down
28 changes: 23 additions & 5 deletions src/pykiso/lib/auxiliaries/record_auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@
import threading
import time
from pathlib import Path
from typing import Dict, List, Optional
from typing import Any, Dict, List, Optional

from pykiso import CChannel, SimpleAuxiliaryInterface
from pykiso import CChannel
from pykiso.interfaces.dt_auxiliary import (
DTAuxiliaryInterface,
close_connector,
open_connector,
)

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -62,7 +67,7 @@ def set_data(self, data: str) -> None:
self.write(data)


class RecordAuxiliary(SimpleAuxiliaryInterface):
class RecordAuxiliary(DTAuxiliaryInterface):
"""Auxiliary used to record a connectors receive channel."""

LOG_HEADER = "Received data :"
Expand Down Expand Up @@ -94,8 +99,9 @@ def __init__(
:param manual_start_record: flag to not start recording on
auxiliary creation
"""
self.is_proxy_capable = True
super().__init__(**kwargs)
super().__init__(
is_proxy_capable=True, tx_task_on=False, rx_task_on=False, **kwargs
)
self.channel = com
self.is_active = is_active
self.timeout = timeout
Expand Down Expand Up @@ -493,3 +499,15 @@ def wait_for_message_in_log(
time.sleep(interval)
logging.info(f"Received message after {(time.time() - start):.1f}s")
return True

def _run_command(self, cmd_message: Any, cmd_data: Optional[bytes]) -> None:
"""Not used.
Simply respect the interface.
"""

def _receive_message(self, timeout_in_s: float) -> None:
"""Not used.
Simply respect the interface.
"""
2 changes: 1 addition & 1 deletion tests/test_record_auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_constructor(
def test_instance_passive(mocker, mock_channel):
mocker.patch.object(threading.Thread, "start")
record_aux = RecordAuxiliary(mock_channel, is_active=False)
assert record_aux._create_auxiliary_instance()
assert record_aux.create_instance()
mock_channel.open.assert_called_once()
record_aux.stop()
mock_channel.close.assert_called_once()
Expand Down

0 comments on commit 9a36fae

Please sign in to comment.