Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement ykush auxiliary #225

Merged
merged 7 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/auxiliaries/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Included Auxiliaries
record_auxiliary
simulated_auxiliary
uds_auxiliary
ykush_auxiliary
16 changes: 16 additions & 0 deletions docs/auxiliaries/ykush_auxiliary.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ykush_auxiliary
===============

Example can be found here :ref:`ykush_aux`.

.. automodule:: pykiso.lib.auxiliaries.ykush_auxiliary
:members:

.. warning::
This auxiliary has only been tested on the Ykush Device.

Ykush 3 and Ykush XS have not been tested.


A command line to get information about the device or port can be found
on the following link : https://github.com/Yepkit/ykush
28 changes: 28 additions & 0 deletions docs/modules_usage/ykush_control.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. _ykush_aux:

Controlling an Yepkit USB hub
===============================
yannpoupon marked this conversation as resolved.
Show resolved Hide resolved

The ykush auxiliary offers commands to control an Yepkit USB hub,
allowing to switch the USB ports on and off individually.

yannpoupon marked this conversation as resolved.
Show resolved Hide resolved

Usage Examples
~~~~~~~~~~~~~~

To use the auxiliary in your test scripts the auxiliary must be properly defined
in the config yaml. Example:

.. code:: yaml

auxiliaries:
ykush_aux:
config:
# Serial number to connect to. Example: "YK00006"
serial_number : null # null = auto detection.
type: pykiso.lib.auxiliaries.ykush_auxiliary:YkushAuxiliary

Below find a example for the usage in a test script. All available methods are shown there.

.. literalinclude:: ../../examples/test_suite_ykush/test_ykush.py
:language: python
7 changes: 7 additions & 0 deletions docs/whats_new/version_ongoing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ specify their names for each defined auxiliary.

This is no longer the case and specifying them in only one auxiliary
will be enough for the loggers to stay enabled.


Ykush Auxiliary
^^^^^^^^^^^^^^^
Auxiliary that can be used to power on and off the ports of an Ykush USB Hub.

See :ref:`ykush_auxiliary`
72 changes: 72 additions & 0 deletions examples/test_suite_ykush/test_ykush.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
##########################################################################
# Copyright (c) 2010-2022 Robert Bosch GmbH
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0.
#
# SPDX-License-Identifier: EPL-2.0
##########################################################################

"""
Ykush auxiliary test
********************

:module: test_ykush

:synopsis: Example test that shows how to control the Ykush usb.

.. currentmodule:: test_ykush

"""

import logging

import pykiso
from pykiso.auxiliaries import ykush_aux


@pykiso.define_test_parameters(suite_id=1, case_id=1, aux_list=[ykush_aux])
class ExampleYkushTest(pykiso.BasicTest):
def setUp(self):
"""Hook method from unittest in order to execute code before test case run."""
logging.info(
f"--------------- SETUP: {self.test_suite_id}, {self.test_case_id} ---------------"
)

def test_run(self):
logging.info(
f"--------------- RUN: {self.test_suite_id}, {self.test_case_id} ---------------"
)
list_state = ykush_aux.get_all_ports_state()
logging.info(f"The state of the ports are :{list_state}")

logging.info("Power off all ports")
ykush_aux.set_all_ports_off()

logging.info("Check if all ports are off")
self.assertEqual(ykush_aux.get_all_ports_state(), [0, 0, 0])

logging.info("Power on the port 1")
ykush_aux.set_port_on(port_number=1)

logging.info("Get the state of the port 1")
state_port_1 = ykush_aux.get_port_state(port_number=1)
logging.info(f"Port 1 is {state_port_1}")

logging.info("Check if the port is on")
self.assertTrue(ykush_aux.is_port_on(port_number=1))

logging.info("Power off the port number 1")
ykush_aux.set_port_off(port_number=1)

logging.info("Check if the port is off")
self.assertTrue(ykush_aux.is_port_off(port_number=1))

list_state = ykush_aux.get_all_ports_state()
logging.info(f"The state of the ports are :{list_state}")
yannpoupon marked this conversation as resolved.
Show resolved Hide resolved

def tearDown(self):
"""Hook method from unittest in order to execute code after test case run."""
logging.info(
f"--------------- TEARDOWN: {self.test_suite_id}, {self.test_case_id} ---------------"
)
10 changes: 10 additions & 0 deletions examples/ykush.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
auxiliaries:
ykush_aux:
config:
# Serial number to connect to. Example: "YK00006"
serial_number : null # null = auto detection.
type: pykiso.lib.auxiliaries.ykush_auxiliary:YkushAuxiliary
test_suite_list:
- suite_dir: test_suite_ykush
test_filter_pattern: '*.py'
test_suite_id: 1
Loading