-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.py
68 lines (50 loc) · 2.03 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import logging
from src import typhoon_automator
from demo_scenario import DemoScenario as DemoScenario
# Create logger
HIL_LOGGING_FORMAT = "%(asctime)s - %(levelname)s - %(message)s" # Log message format
HIL_LOGGER_NAME = "HIL_LOGGER" # Logger name
HIL_LOG_FILENAME = "./log.txt" # Logging filename
HIL_LOG_LEVEL = logging.DEBUG # Lowest severity level to log
logger = logging.getLogger(HIL_LOGGER_NAME)
logger_formatter = logging.Formatter(HIL_LOGGING_FORMAT)
# Add console handler
logger_console = logging.StreamHandler()
logger_console.setFormatter(logger_formatter)
logger.addHandler(logger_console)
# Set log level
logger.setLevel(HIL_LOG_LEVEL)
# Set example information
DEMO_SCHEMATIC = "./examples/rlc.tse"
DEMO_DATA_LOG_PATH = "./output/data/"
DEMO_CAPTURE_PATH = "./output/capture/"
# Set up and run automator
try:
automator = typhoon_automator.TyphoonAutomator()
automator.set_automation_logger(logger)
# Find available HIL devices
hil_devices = automator.get_available_devices()
use_vhil = False
# Connect to HIL devices, or specify use of Virtual HIL
if len(hil_devices) > 0:
devices = automator.connect_devices(hil_devices)
logger.info(f"Connected to {len(devices)} HIL devices:")
for serial_num in devices:
logger.info(f" {serial_num}")
else:
use_vhil = True
logger.info("Using Virtual HIL")
# Initialize the automator with the schematic
automator.initialize(DEMO_SCHEMATIC, conditional_compile = True)
# Add data logging and capture paths
automator.set_data_logger_path(DEMO_DATA_LOG_PATH)
automator.set_capture_path(DEMO_CAPTURE_PATH)
# Add some demo scenarios
automator.add_scenario(name = "Demo Scenario 1", scenario = DemoScenario(1.0))
automator.add_scenario(name = "Demo Scenario 2", scenario = DemoScenario(2.0))
automator.add_scenario(name = "Demo Scenario 3", scenario = DemoScenario(3.0))
# Run all the scenarios
automator.run(use_vhil = use_vhil)
except BaseException as ex:
logger.critical("Exiting due to exception")
logger.exception(ex)