DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
timing
python
timing
cli
irig.py
Go to the documentation of this file.
1
import
click
2
import
sys
3
4
import
collections
5
6
from
.
import
toolbox
7
import
timing.common.definitions
as
defs
8
from
timing.common.definitions
import
kLibrarySupportedBoards, kLibrarySupportedDesigns, TimestampEpoch, TimestampTimebase
9
10
from
click
import
echo, style, secho
11
import
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)
22
def
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
60
def
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 ts epoch: UNIX or custom")
73
@click.pass_obj
74
@click.argument('epoch', type=click.Choice(TimestampEpoch.__members__.keys()
))
75
def
set_epoch
(obj, epoch):
76
77
lDevice = obj.mDevice
78
lIRIG = obj.mIRIG
79
80
lEpoch=TimestampEpoch.__members__[epoch]
81
lIRIG.set_ts_epoch(lEpoch)
82
# ------------------------------------------------------------------------------
83
84
# ------------------------------------------------------------------------------
85
@irig.command('set-epoch-value', short_help="Set ts epoch (custom mode)
")
86
@click.pass_obj
87
@click.argument('epoch_to_2000_seconds_tai', type=int)
88
@click.argument('epoch_to_2000_leap_seconds', type=int)
89
def
set_epoch_value
(obj, epoch_to_2000_seconds_tai, epoch_to_2000_leap_seconds):
90
91
lDevice = obj.mDevice
92
lIRIG = obj.mIRIG
93
94
lIRIG.set_ts_epoch_value(epoch_to_2000_seconds_tai, epoch_to_2000_leap_seconds)
95
# ------------------------------------------------------------------------------
96
97
# ------------------------------------------------------------------------------
98
@irig.command('set-timebase', short_help="Set ts timebase: TAI or UTC")
99
@click.pass_obj
100
@click.argument('timebase', type=click.Choice(TimestampTimebase.__members__.keys()
))
101
def
set_timebase
(obj, timebase):
102
103
lDevice = obj.mDevice
104
lIRIG = obj.mIRIG
105
106
lTimebase=TimestampTimebase.__members__[timebase]
107
lIRIG.set_ts_timebase(lTimebase)
108
# ------------------------------------------------------------------------------
109
110
# ------------------------------------------------------------------------------
111
@irig.command('set-seconds-offset', short_help="Set ts seconds offset")
112
@click.pass_obj
113
@click.argument('offset', type=click.IntRange(-128, 127)
)
114
def
set_seconds_offset
(obj, offset):
115
116
lDevice = obj.mDevice
117
lIRIG = obj.mIRIG
118
119
lIRIG.set_ts_seconds_offset(offset)
120
# ------------------------------------------------------------------------------
121
122
# ------------------------------------------------------------------------------
123
@irig.command('set-ticks-offset', short_help="Set ts ticks offset")
124
@click.pass_obj
125
@click.argument('offset', type=click.IntRange(-32768, 32767)
)
126
def
set_ticks_offset
(obj, offset):
127
128
lDevice = obj.mDevice
129
lIRIG = obj.mIRIG
130
131
lIRIG.set_ts_ticks_offset(offset)
132
# ------------------------------------------------------------------------------
timing.cli.irig.status
status(ctx, obj)
Definition
irig.py:60
timing.cli.irig.set_epoch_value
set_epoch_value(obj, epoch_to_2000_seconds_tai, epoch_to_2000_leap_seconds)
Definition
irig.py:89
timing.cli.irig.set_timebase
set_timebase(obj, timebase)
Definition
irig.py:101
timing.cli.irig.set_seconds_offset
set_seconds_offset(obj, offset)
Definition
irig.py:114
timing.cli.irig.set_epoch
set_epoch(obj, epoch)
Definition
irig.py:75
timing.cli.irig.set_ticks_offset
set_ticks_offset(obj, offset)
Definition
irig.py:126
timing.common.definitions
Definition
__init__.py:1
Generated on
for DUNE-DAQ by
1.17.0