-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathext_clock_test.py
executable file
·61 lines (48 loc) · 1.58 KB
/
ext_clock_test.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020-2021 by Murray Altheim. All rights reserved. This file is part
# of the Robot Operating System project, released under the MIT License. Please
# see the LICENSE file included as part of this package.
#
# author: Murray Altheim
# created: 2021-02-19
# modified: 2021-02-19
#
# Uses an interrupt (event detect) set on a GPIO pin as an external Clock trigger.
#
import pytest
import sys, time
from colorama import init, Fore, Style
init()
from lib.config_loader import ConfigLoader
from lib.logger import Logger, Level
from lib.message_bus import MessageBus
from lib.ext_clock import ExternalClock
# ..............................................................................
@pytest.mark.unit
def test_external_clock():
_log = Logger("xclock", Level.INFO)
_log.info('starting test...')
# read YAML configuration
_loader = ConfigLoader(Level.INFO)
filename = 'config.yaml'
_config = _loader.configure(filename)
_message_bus = MessageBus(Level.INFO)
_clock = ExternalClock(_config, _message_bus, Level.INFO)
try:
_log.info('starting clock...')
_clock.enable()
while _clock.enabled:
time.sleep(1.0)
except KeyboardInterrupt:
_log.info("caught Ctrl-C.")
finally:
_log.info("closed.")
# main .........................................................................
def main(argv):
test_external_clock()
# call main ....................................................................
if __name__== "__main__":
main(sys.argv[1:])
#EOF