DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
irig.py
Go to the documentation of this file.
1import click
2import sys
3
4import collections
5
6from . import toolbox
7import timing.common.definitions as defs
8from timing.common.definitions import kLibrarySupportedBoards, kLibrarySupportedDesigns, IRIGEpoch
9
10from click import echo, style, secho
11import time
12
13# ------------------------------------------------------------------------------
14# ____ __ _ __
15# / __/__ ___/ /__ ___ (_)__ / /_
16# / _// _ \/ _ / _ \/ _ \/ / _ \/ __/
17# /___/_//_/\_,_/ .__/\___/_/_//_/\__/
18# /_/
19@click.group('irig', invoke_without_command=True)
20@click.pass_obj
21@click.argument('device', callback=toolbox.validate_device, shell_complete=toolbox.completeDevices)
22def irig(obj, device):
23 '''
24 IRIG commands.
25
26 \b
27 DEVICE: uhal device identifier
28 IDS: id(s) of the target endpoint(s).
29 '''
30
31 lDevice = obj.mConnectionManager.getDevice(str(device))
32 if obj.mTimeout:
33 lDevice.setTimeoutPeriod(obj.mTimeout)
34
35
36 echo('Created IRIG device')
37 lTopDesign = lDevice.getNode('')
38 lBoardInfo = toolbox.readSubNodes(lDevice.getNode('io.config'), False)
39 lDevice.dispatch()
40
41 if lBoardInfo['board_type'].value() in kLibrarySupportedBoards and lBoardInfo['design_type'].value() in kLibrarySupportedDesigns:
42 lTopDesign.validate_firmware_version()
43 try:
44 echo(lDevice.getNode('io').get_hardware_info())
45 except:
46 secho("Failed to retrieve hardware information! I2C issue? Initial board reset needed?", fg='yellow')
47 e = sys.exc_info()[0]
48 secho("Error: {}".format(e), fg='red')
49
50 obj.mDevice = lDevice
51 obj.mTopDesign = lDevice.getNode('')
52 obj.mIRIG = lDevice.getNode('irig_time_source')
53# ------------------------------------------------------------------------------
54
55
56# ------------------------------------------------------------------------------
57@irig.command('status')
58@click.pass_obj
59@click.pass_context
60def status(ctx, obj):
61 '''
62 Print the status of IRIG block.
63 '''
64
65 lDevice = obj.mDevice
66 lIRIG = obj.mIRIG
67
68 echo(lIRIG.get_status())
69# ------------------------------------------------------------------------------
70
71# ------------------------------------------------------------------------------
72@irig.command('set-epoch', short_help="Set IRIG epoch: TAI or UNIX")
73@click.pass_obj
74@click.argument('epoch', type=click.Choice(IRIGEpoch.__members__.keys()))
75def synctime(obj, epoch):
76
77 lDevice = obj.mDevice
78 lIRIG = obj.mIRIG
79
80 lEpoch=IRIGEpoch.__members__[epoch]
81 lIRIG.set_irig_epoch(lEpoch)
82# ------------------------------------------------------------------------------
status(ctx, obj)
Definition irig.py:60
synctime(obj, epoch)
Definition irig.py:75