mirror of
https://github.com/saymrwulf/uhd.git
synced 2026-05-15 21:01:26 +00:00
mpm: PeriphManagerBase: List all sync-related methods
All PeriphManagerBase childs need to implement
- get_{clock,time,sync}_source()
- get_{clock,time,sync}_sources()
- set_{clock,time,sync}_source()
So we populate PeriphManagerBase with defaults for all of those.
This commit is contained in:
parent
c176425b85
commit
f73e32729d
1 changed files with 59 additions and 0 deletions
|
|
@ -1216,6 +1216,14 @@ class PeriphManagerBase(object):
|
|||
#######################################################################
|
||||
# Sync API
|
||||
#######################################################################
|
||||
def get_clock_source(self):
|
||||
" Returns the currently selected clock source "
|
||||
raise NotImplementedError("get_clock_source() not available on this device!")
|
||||
|
||||
def get_time_source(self):
|
||||
" Returns the currently selected time source "
|
||||
raise NotImplementedError("get_time_source() not available on this device!")
|
||||
|
||||
def get_sync_source(self):
|
||||
"""
|
||||
Gets the current time and clock source
|
||||
|
|
@ -1225,6 +1233,57 @@ class PeriphManagerBase(object):
|
|||
"clock_source": self.get_clock_source(),
|
||||
}
|
||||
|
||||
def get_clock_sources(self):
|
||||
"""
|
||||
Returns a list of valid clock sources. This is a list of strings.
|
||||
"""
|
||||
self.log.warning("get_clock_sources() was not specified for this device!")
|
||||
return []
|
||||
|
||||
def get_time_sources(self):
|
||||
"""
|
||||
Returns a list of valid time sources. This is a list of strings.
|
||||
"""
|
||||
self.log.warning("get_time_sources() was not specified for this device!")
|
||||
return []
|
||||
|
||||
def get_sync_sources(self):
|
||||
"""
|
||||
Returns a list of valid sync sources. This is a list of dictionaries.
|
||||
"""
|
||||
self.log.warning("get_sync_sources() was not specified for this device!")
|
||||
return []
|
||||
|
||||
def set_clock_source(self, *args):
|
||||
"""
|
||||
Set a clock source.
|
||||
|
||||
The choice to allow arbitrary arguments is based on historical decisions
|
||||
and backward compatibility. UHD/mpmd will call this with a single argument,
|
||||
so args[0] is the clock source (as a string).
|
||||
"""
|
||||
raise NotImplementedError("set_clock_source() not available on this device!")
|
||||
|
||||
def set_time_source(self, time_source):
|
||||
" Set a time source "
|
||||
raise NotImplementedError("set_time_source() not available on this device!")
|
||||
|
||||
def set_sync_source(self, sync_args):
|
||||
"""
|
||||
If a device has no special code for setting the sync-source atomically,
|
||||
we simply forward these settings to set_clock_source() and set_time_source()
|
||||
(in that order).
|
||||
"""
|
||||
if sync_args not in self.get_sync_sources():
|
||||
sync_args_str = \
|
||||
','.join([str(k) + '=' + str(v) for k, v in sync_args.items()])
|
||||
self.log.warn(
|
||||
f"Attempting to set unrecognized Sync source {sync_args_str}!")
|
||||
clock_source = sync_args.get('clock_source', self.get_clock_source())
|
||||
time_source = sync_args.get('time_source', self.get_time_source())
|
||||
self.set_clock_source(clock_source)
|
||||
self.set_time_source(time_source)
|
||||
|
||||
###########################################################################
|
||||
# Clock/Time API
|
||||
###########################################################################
|
||||
|
|
|
|||
Loading…
Reference in a new issue