10. Device Manager API¶
Module: typhoon.api.device_manager
Device Manager API set of functions/methods to manipulate current HIL setup (add or remove devices), create new ones from scratch programmaticaly and connect/disconnect current setup. This is most commonly used for creating scripts for testing and automating repetitive tasks, but its use is not restricted for these use cases only.
10.1. Examples¶
Following two examples illustrates how you can use Device Manager API.
10.1.1. Example 1¶
This example illustrates adding/removing device to setup and how to connect/disconnect current setup.
# specify HIL devices serial numbers
hil_device_1 = "604-1010101"
hil_device_2 = "604-2020202"
devices_to_add = [hil_device_1, hil_device_2]
# add devices to setup
device_manager.add_devices_to_setup(devices_to_add)
# connect HIL setup
device_manager.connect_setup()
#
# do something here with 2 connected devices
#
device_manager.disconnect_setup()
# remove device with "604-2020202" serial number
device_manager.remove_devices(hil_device_2)
# connect setup again this time only with device with serial "604-1010101"
device_manager.connect_setup()
Script output:
10.1.2. Example 2¶
This example illustrates loading an existing setup and connecting it.
# print all detected devices on network
print(device_manager.get_detected_devices())
device_manager.load_setup(file="C:/Users/User/Desktop/test_setup.setup")
# connect HIL setup
device_manager.connect_setup()
# print all devices from setup
print(device_manager.get_setup_devices)
# Check connection status
device_manager.is_setup_connected()
# and disconnect setup
device_manager.disconnect_setup()
Script output:
- class DeviceManagerAPI¶
- add_devices_to_setup(devices=[])¶
Add devices to active setup.
- Parameters
devices (list) – devices to add.
- Returns
True
if everything ok, otherwise returnsFalse
.- Return type
status (bool)
- add_discovery_ip_addresses(addresses=[])¶
Specify addresses where HIL devices are located if auto discovery fails for some reason.
- Parameters
addresses (list) – IP addresses where HIL devices are located.
- Returns
True
if everything ok, otherwise returnsFalse
.- Return type
status (bool)
- connect_setup()¶
Activate current selected HIL setup. Make all devices in the selected setup inaccessible to others.
- Returns
True
if everything ok, otherwise returnsFalse
.- Return type
status (bool)
- disconnect_setup()¶
Deactivate current selected HIL setup. Make all devices in the selected setup accessible to others.
- Returns
True
if everything ok, otherwise returnsFalse
.- Return type
status (bool)
- get_available_devices()¶
Get all discovered available devices.
- Returns
available devices in JSON representation.
- Return type
devices (list)
- get_detected_devices()¶
Get all discovered devices.
- Returns
discovered devices in JSON representation.
- Return type
devices (list)
- get_setup_devices()¶
Get all devices from current HIL setup.
- Returns
- dicts with information for each devices
- {“serial_number”: “some_serial”, “device_name”: “some_device_name”,
”status”: “device_stauts”}.
- Return type
devices (list)
- get_setup_devices_serials()¶
Get all devices from current HIL setup.
- Returns
serial number of each device from setup.
- Return type
devices (list)
- is_setup_connected()¶
Returns current status of active HIL setup.
- Returns
True
if everything ok, otherwise returnsFalse
.- Return type
status (bool)
- load_setup(file='')¶
Loads HIL setup from file to Control Center.
- Parameters
file (str) – Setup description.
- Returns
True
if everything ok, otherwise returnsFalse
.- Return type
status (bool)
- remove_devices_from_setup(devices=[])¶
Remove devices from active setup.
- Parameters
devices (list) – devices to remove.
- Returns
True
if everything ok, otherwise returnsFalse
.- Return type
status (bool)
- remove_discovery_ip_addresses(addresses=[])¶
Remove previously added addresses where HIL devices are located if auto discovery fails for some reason.
- Parameters
addresses (list) – IP addresses which you want to remove.
- Returns
True
if everything ok, otherwise returnsFalse
.- Return type
status (bool)