Skip to navigation

hololink::module::OscillatorInterfaceV1

View as Markdown

Configure a clock source driving a sensor.

Sensors usually require an external reference clock before they can be configured. Call enable() with the rate the sensor requires, before configuring the sensor.

#include <hololink/module/oscillator.hpp>

Inherits from: hololink::module::ConfigurableService< OscillatorInterfaceV1 > (public)


Methods

enable

virtual bool hololink::module::OscillatorInterfaceV1::enable(
uint64_t clocks_per_second
)

Start the oscillator at the given output rate.

Calling this again with the rate the oscillator is already producing succeeds without disturbing the output, so it is safe to call from each sensor sharing a clock generator. Where the generator can supply only one rate at a time, asking for a different rate than the one already running returns false. After the device is reset the output must be started again by calling enable() again.

Returns: true if the oscillator is now producing the requested rate. false if the hardware cannot produce that rate, or cannot do so while another rate is in use.

Parameters

clocks_per_second
uint64_t

Requested output frequency, in Hz.

get_caps

virtual std::map<std::string, std::string> hololink::module::OscillatorInterfaceV1::get_caps()

Report the oscillator’s adjustable settings.

Settings are hardware specific; keys and their meaning are defined by the oscillator in use. Values are strings; how numeric values are encoded is also defined by the oscillator. An oscillator with no adjustable settings returns an empty map.

Returns: The current value of each setting, by name.

set_caps

virtual bool hololink::module::OscillatorInterfaceV1::set_caps(
const std::map<std::string, std::string> &caps
)

Change one or more of the oscillator’s adjustable settings.

The update is all-or-nothing: either every entry is applied, or none is.

Returns: true if every entry was applied. false if any name is not supported or any value is out of range for the hardware, in which case no setting is changed.

Parameters

caps
const std::map<std::string, std::string> &

New values, by setting name; use the names reported by get_caps().

configure

virtual void hololink::module::ConfigurableService<OscillatorInterfaceV1>::configure(
)

Use metadata contents to initialize this instance.

This routine is guaranteed to be called the first time a call to get_service(metadata) is called on a specific service instance.

module

std::shared_ptr<Module> hololink::module::ServiceBase::module() const

The Module that this service was published from.

The service holds no strong reference to its Module, so this does not extend the Module’s lifetime.

Returns: The owning Module, or an empty pointer if the service has not been published or its Module no longer exists.


Static methods

get_service

static std::shared_ptr<OscillatorInterfaceV1> hololink::module::ConfigurableService<OscillatorInterfaceV1>::get_service(
const EnumerationMetadata &metadata,
bool allow_null = false
)

Fetch a service, configured by EnumerationMetadata.

Module usually caches service objects; so when a specific service instance isn’t found, it will be constructed with the current values in EnumerationMetadata. Later calls to get_service are likely to return that cached instance, ignoring changes to any enumeration metadata that aren’t specifically related to service addressing.

Returns: A shared pointer to the requested service (<Derived>).

Throws: std::runtime_error when allow_null==false and the service lookup (or construction) fails.

Parameters

metadata
const EnumerationMetadata &

Addressing and configuration for the service.

allow_null
boolDefaults to false

Use true to return nullptr when the service cannot be resolved; the default false value raises a std::runtime_error.

for_each_type_id

static bool hololink::module::Service<OscillatorInterfaceV1>::for_each_type_id(
Callback &&cb
)

Iterate over every type_id supported by this instance.

The callback signature is bool(const char*) — returning false halts the walk; true continues. Iteration is depth-first, so you’ll see the most specific implementation types first.