peary::device::PearyDevice

Peary Device class definition. More…

#include <peary/device/PearyDevice.hpp>

Inherits from peary::device::Device

Protected Types

Name
typedef utils::dictionary< utils::register_t< typename SCI::reg_t, typename SCI::data_t > > _registers

Public Functions

Name
template <typename… ArgsSCI> PearyDevice(std::string_view name, const config::Configuration & config, ArgsSCI &&… sciArgs)Default constructor for Peary Devices.
template <typename… ArgsSCI,typename… ArgsDRI> PearyDevice(std::string_view name, const config::Configuration config, std::tuple< ArgsSCI… > sciArgs, std::tuple< ArgsDRI… > driArgs)Default constructor for Peary Devices with the Data readout interface.
virtual std::string getFirmwareVersion() overrideReturn the firmware version string for reference.
virtual std::string getType() overrideReturn the human-readable device type.
uint8_t getBoardID()Return the identifier of the installed board.
uint16_t getChipID()Read the ID from the chip board if available.
std::string getDeviceName()Return the human-readable device name of the firmware currently loaded.
virtual void powerOn() overrideCall the device’s powerUp() function and toggle the powered state.
virtual void powerUp() =0Turn on the power supply for the attached device.
virtual void powerOff() overrideCall the device’s powerDown() function and toggle the powered state.
virtual void powerDown() =0Turn off power for the attached device.
virtual void daqStart() override =0Start the data acquisition.
virtual void daqStop() override =0Stop the data acquisition.
virtual void configure() overrideConfigure the device after power-up.
virtual void setRegister(const std::string & name, uintptr_t value) overrideSet a register on this device.
virtual void setSpecialRegister(const std::string & , uintptr_t )Set a special register on this device.
virtual uintptr_t getSpecialRegister(const std::string & )Get a special register on this device.
virtual uintptr_t getRegister(const std::string & name) overrideGet a register from this device.
virtual std::vector< std::pair< std::string, uintptr_t > > getRegisters() overrideGet all registers from this device.
virtual bool hasRegister(const std::string & name) const overrideCheck if a register with this name exists.
virtual void reset() overrideSending reset signal to the device.
virtual void setVoltage(const std::string & name, double voltage) overrideSet voltage and current limit on the board resource.
virtual void setCurrentLimit(const std::string & name, double current_limit) overrideSet current limit on the board resource.
virtual void setCurrent(const std::string & name, double current, utils::Polarity polarity) overrideConfigure board current source.
virtual void switchOn(const std::string & name) overrideSwitch on the given board resource.
virtual void switchOff(const std::string & name) overrideSwitch off the given board resource.
virtual double getVoltage(const std::string & name) overrideGet voltage of the given board resource.
virtual double getCurrent(const std::string & name) overrideGet current from the given board resource.
virtual double getPower(const std::string & name) overrideGet power consumption of the given board resource.
bool getAlertStatus(const std::string & name)Get alert status from the given board resource.
double getTemperature(const std::string & name)Get temperature from the given board resource.
virtual void configureClock(const std::string & name, const std::any & config) overrideConfigure a clock output on the board.
virtual void disableClock(const std::string & name) overrideDisable a clock output on the board.
virtual bool isClockLocked(const std::string & name) overrideCheck if a clock output is locked.
virtual void setClockFrequency(const std::string & name, uint64_t frequency) overrideSet frequency of a clock output on the board.
virtual std::vector< std::string > listMemories() overrideList all memory registers.
virtual std::vector< std::string > listRegisters() overrideList all registers known to this device.
virtual std::vector< std::pair< std::string, std::string > > listResources() overrideList all periphery components and their types registered by this device.
virtual std::optional< utils::pearyRawData > getRawData() overrideRaw and decoded data readback.
virtual std::optional< utils::pearyRawDataVector > getRawData(const unsigned int noFrames) overrideRaw and decoded data readback.
virtual std::optional< utils::pearydata > getData() overrideRaw and decoded data readback.
virtual std::optional< utils::pearydataVector > getData(const unsigned int noFrames) overrideRaw and decoded data readback.
virtual void setMemory(const std::string & name, size_t offset, uintptr_t value) overrideSet memory register on this device.
virtual void setMemory(const std::string & name, uintptr_t value) overrideSet memory register on this device.
template D getMemoryDefault(const std::string & name)Get default value of memory register.
template virtual D getMemory(const std::string & name, size_t offset)Get memory register from this device.
virtual uintptr_t getMemory(const std::string & name, size_t offset) overrideGet memory register from this device.
template virtual D getMemory(const std::string & name)Get memory register from this device.
virtual uintptr_t getMemory(const std::string & name) overrideGet memory register from this device.
virtual std::vector< std::pair< std::string, uintptr_t > > getMemories() overrideGet all memory registers from this device.
virtual bool hasMemory(const std::string & name) const overrideCheck if a memory register with this name exists.

Protected Functions

Name
void register_resource(const std::string & name, B::R res)Register a resource with the device.
void register_memory(const std::string & name, utils::memory_map mem, utils::register_t< std::uintptr_t, std::uintptr_t > reg)Register a memory with the device.
void register_memory(const std::vector< std::pair< std::string, std::pair< utils::memory_map, utils::register_t< std::uintptr_t, std::uintptr_t »» elements)Register a memory with the device.
void process_register_write(utils::register_t< typename SCI::reg_t, typename SCI::data_t > reg, uintptr_t value)Process writing to registers, ignoring special flags.
uintptr_t process_register_read(utils::register_t< typename SCI::reg_t, typename SCI::data_t > reg)Process reading from registers, ignoring special flags.
SCI::data_t send(const typename SCI::data_t & data)Write data to a device which does not contain internal register.
SCI::vector_t send(const std::vector< typename SCI::data_t > & data)Write data to a device which does not contain internal register.
std::pair< typename SCI::reg_t, typename SCI::data_t > send(const std::pair< typename SCI::reg_t, typename SCI::data_t > & data)Send data to a device containing internal registers.
SCI::vector_t send(const typename SCI::reg_t & reg, const std::vector< typename SCI::data_t > & data)Send data to a device containing internal registers.
std::vector< std::pair< typename SCI::reg_t, typename SCI::data_t > > send(const std::vector< std::pair< typename SCI::reg_t, typename SCI::data_t » & data)Send data to a device containing internal registers.
SCI::vector_t receive(const typename SCI::reg_t reg, const unsigned int length =1)Receive data from a device which does not contain internal register.
DRI::vector_t receiveData(const unsigned int length =1)Receive data from a device which does not contain internal register.
DRI::vector_t receiveData(const typename DRI::reg_t reg, const unsigned int length =1)Receive data from a device containing internal registers.

Protected Attributes

Name
std::shared_ptr< B > _board
config::Configuration _config
std::map< std::string, typename SCI::data_t > _register_cache

Additional inherited members

Public Functions inherited from peary::device::Device

Name
Device(std::string_view name, const config::Configuration & )Default constructor for Peary Devices.
virtual ~Device()Default destructor for Peary Devices.
bool isManaged()Indicator flag for managed devices.
std::string getVersion()Return the software version string for reference.
std::string getName()Return the human-readable device name (full qualifier)
std::vector< std::pair< std::string, std::size_t > > listCommands()Retrieve list of all available device-specifiv commands.
std::string command(const std::string & name, const std::vector< std::string > & args =std::vector< std::string >())Call device-specific command with a list of arguments.
std::string command(const std::string & name, const std::string & arg)Call device-specific command with a single argument.

Protected Attributes inherited from peary::device::Device

Name
utils::Dispatcher _dispatcher Command dispatcher for this device.

Friends inherited from peary::device::Device

Name
class DeviceManager

Detailed Description

  template <typename B ,
typename SCI ,
typename DRI  =SCI>
class peary::device::PearyDevice;
  

Peary Device class definition.

Template Parameters:

  • B Type of the hardware board class
  • SCI Type of the slow control interface
  • DRI Type of the data readout interface

this is the central device class from which all device implementations inherit. Some basic functionality is defined via purely virtual member functions which have to be implemented by every device instance. This enables the possibility of interfacing the devices independently via the common set of function calls, e.g., from a GUI or a commandline interface.

Protected Types Documentation

typedef _registers

  utils::dictionary<utils::register_t<typename SCI::reg_t, typename SCI::data_t> > peary::device::PearyDevice< B, SCI, DRI >::_registers;
  

Register dictionary for the devices:

Public Functions Documentation

function PearyDevice

  template <typename... ArgsSCI>
PearyDevice(
    std::string_view name,
    const config::Configuration & config,
    ArgsSCI &&... sciArgs
)
  

Default constructor for Peary Devices.

Parameters:

  • name Device name
  • config Configuration object
  • sciArgs Arguments to instantiate the slow-control interface

function PearyDevice

  template <typename... ArgsSCI,
typename... ArgsDRI>
PearyDevice(
    std::string_view name,
    const config::Configuration config,
    std::tuple< ArgsSCI... > sciArgs,
    std::tuple< ArgsDRI... > driArgs
)
  

Default constructor for Peary Devices with the Data readout interface.

Parameters:

  • name Device name
  • config Configuration object
  • sciArgs Arguments to instantiate the slow control interface
  • driArgs Arguments to instantiate the data readout interface

function getFirmwareVersion

  virtual std::string getFirmwareVersion() override
  

Return the firmware version string for reference.

Return: Peary software version string

Reimplements: peary::device::Device::getFirmwareVersion

function getType

  virtual std::string getType() override
  

Return the human-readable device type.

Return: Device type

Reimplements: peary::device::Device::getType

function getBoardID

  uint8_t getBoardID()
  

Return the identifier of the installed board.

Return: Board ID

function getChipID

  inline uint16_t getChipID()
  

Read the ID from the chip board if available.

Return: Chip ID, 0 if not available

Some chip boards feature an EPROM which stores a board ID and thus allows identification of the attached chip board.

function getDeviceName

  std::string getDeviceName()
  

Return the human-readable device name of the firmware currently loaded.

Return: Device name

function powerOn

  virtual void powerOn() override
  

Call the device’s powerUp() function and toggle the powered state.

Reimplements: peary::device::Device::powerOn

function powerUp

  virtual void powerUp() =0
  

Turn on the power supply for the attached device.

function powerOff

  virtual void powerOff() override
  

Call the device’s powerDown() function and toggle the powered state.

Reimplements: peary::device::Device::powerOff

function powerDown

  virtual void powerDown() =0
  

Turn off power for the attached device.

function daqStart

  virtual void daqStart() override =0
  

Start the data acquisition.

Reimplements: peary::device::Device::daqStart

function daqStop

  virtual void daqStop() override =0
  

Stop the data acquisition.

Reimplements: peary::device::Device::daqStop

function configure

  virtual void configure() override
  

Configure the device after power-up.

Reimplements: peary::device::Device::configure

function setRegister

  virtual void setRegister(
    const std::string & name,
    uintptr_t value
) override
  

Set a register on this device.

Parameters:

  • name Name of the register
  • value Value to be set

Reimplements: peary::device::Device::setRegister

function setSpecialRegister

  inline virtual void setSpecialRegister(
    const std::string & ,
    uintptr_t 
)
  

Set a special register on this device.

function getSpecialRegister

  inline virtual uintptr_t getSpecialRegister(
    const std::string & 
)
  

Get a special register on this device.

function getRegister

  virtual uintptr_t getRegister(
    const std::string & name
) override
  

Get a register from this device.

Parameters:

  • name Name of the register

Return: Value of the register

Reimplements: peary::device::Device::getRegister

function getRegisters

  virtual std::vector< std::pair< std::string, uintptr_t > > getRegisters() override
  

Get all registers from this device.

Return: Vector with pairs of register name and value

Reimplements: peary::device::Device::getRegisters

function hasRegister

  virtual bool hasRegister(
    const std::string & name
) const override
  

Check if a register with this name exists.

Parameters:

  • name Name of the register

Return: True if the register exists, false otherwise

Reimplements: peary::device::Device::hasRegister

function reset

  virtual void reset() override
  

Sending reset signal to the device.

Reimplements: peary::device::Device::reset

function setVoltage

  virtual void setVoltage(
    const std::string & name,
    double voltage
) override
  

Set voltage and current limit on the board resource.

Parameters:

  • name Name of the resource
  • voltage Voltage to be set in V

Reimplements: peary::device::Device::setVoltage

function setCurrentLimit

  virtual void setCurrentLimit(
    const std::string & name,
    double current_limit
) override
  

Set current limit on the board resource.

Parameters:

  • name Name of the resource
  • current_limit current limit to be set in A

Reimplements: peary::device::Device::setCurrentLimit

function setCurrent

  virtual void setCurrent(
    const std::string & name,
    double current,
    utils::Polarity polarity
) override
  

Configure board current source.

Parameters:

  • name Name of the current source
  • current Current to be set in A
  • polarity Polarity of the source, HIGH or LOW

Reimplements: peary::device::Device::setCurrent

function switchOn

  inline virtual void switchOn(
    const std::string & name
) override
  

Switch on the given board resource.

Parameters:

  • name Name of the resource

Reimplements: peary::device::Device::switchOn

function switchOff

  inline virtual void switchOff(
    const std::string & name
) override
  

Switch off the given board resource.

Parameters:

  • name Name of the resource

Reimplements: peary::device::Device::switchOff

function getVoltage

  virtual double getVoltage(
    const std::string & name
) override
  

Get voltage of the given board resource.

Parameters:

  • name Name of the resource

Return: Voltage in V

Reimplements: peary::device::Device::getVoltage

function getCurrent

  virtual double getCurrent(
    const std::string & name
) override
  

Get current from the given board resource.

Parameters:

  • name Name of the resource

Return: Current in A

Reimplements: peary::device::Device::getCurrent

function getPower

  virtual double getPower(
    const std::string & name
) override
  

Get power consumption of the given board resource.

Parameters:

  • name Name of the resource

Return: Power in W

Reimplements: peary::device::Device::getPower

function getAlertStatus

  bool getAlertStatus(
    const std::string & name
)
  

Get alert status from the given board resource.

Parameters:

  • name Name of the resource

Return: Alert status, true if alert is active

function getTemperature

  double getTemperature(
    const std::string & name
)
  

Get temperature from the given board resource.

Parameters:

  • name Name of the resource

Return: Temperature in degree Celsius

function configureClock

  virtual void configureClock(
    const std::string & name,
    const std::any & config
) override
  

Configure a clock output on the board.

Parameters:

  • name Name of the resource
  • config Configuration object for the clock

Reimplements: peary::device::Device::configureClock

function disableClock

  virtual void disableClock(
    const std::string & name
) override
  

Disable a clock output on the board.

Parameters:

  • name Name of the resource

Reimplements: peary::device::Device::disableClock

function isClockLocked

  virtual bool isClockLocked(
    const std::string & name
) override
  

Check if a clock output is locked.

Parameters:

  • name Name of the resource

Return: True if the clock is locked, false otherwise

Reimplements: peary::device::Device::isClockLocked

function setClockFrequency

  virtual void setClockFrequency(
    const std::string & name,
    uint64_t frequency
) override
  

Set frequency of a clock output on the board.

Parameters:

  • name Name of the resource
  • frequency Frequency in Hz

Reimplements: peary::device::Device::setClockFrequency

function listMemories

  virtual std::vector< std::string > listMemories() override
  

List all memory registers.

Return: Vector with names of all available memory pages

Reimplements: peary::device::Device::listMemories

List all memory registers (accessed through memory pages mapping) known to this device

function listRegisters

  virtual std::vector< std::string > listRegisters() override
  

List all registers known to this device.

Return: Vector with names of all available registers

Reimplements: peary::device::Device::listRegisters

function listResources

  virtual std::vector< std::pair< std::string, std::string > > listResources() override
  

List all periphery components and their types registered by this device.

Return: Vector with pairs of component name and component type

Reimplements: peary::device::Device::listResources

function getRawData

  virtual std::optional< utils::pearyRawData > getRawData() override
  

Raw and decoded data readback.

Return: Raw data structure

Reimplements: peary::device::Device::getRawData

function getRawData

  virtual std::optional< utils::pearyRawDataVector > getRawData(
    const unsigned int noFrames
) override
  

Raw and decoded data readback.

Parameters:

  • noFrames Number of frames to be read

Return: Vector of raw data frames

Reimplements: peary::device::Device::getRawData

function getData

  virtual std::optional< utils::pearydata > getData() override
  

Raw and decoded data readback.

Return: Decoded data structure

Reimplements: peary::device::Device::getData

function getData

  virtual std::optional< utils::pearydataVector > getData(
    const unsigned int noFrames
) override
  

Raw and decoded data readback.

Parameters:

  • noFrames Number of frames to be read

Return: Vector of decoded data frames

Reimplements: peary::device::Device::getData

function setMemory

  virtual void setMemory(
    const std::string & name,
    size_t offset,
    uintptr_t value
) override
  

Set memory register on this device.

Parameters:

  • name Name of the memory register
  • offset Offset to be applied to the base address of the memory register
  • value Value to be set

Reimplements: peary::device::Device::setMemory

function setMemory

  virtual void setMemory(
    const std::string & name,
    uintptr_t value
) override
  

Set memory register on this device.

Parameters:

  • name Name of the memory register
  • value Value to be set

Reimplements: peary::device::Device::setMemory

function getMemoryDefault

  template <typename D  =uintptr_t>
D getMemoryDefault(
    const std::string & name
)
  

Get default value of memory register.

Parameters:

  • name Name of the memory register

Return: Default value of the register

function getMemory

  template <typename D  =uintptr_t>
virtual D getMemory(
    const std::string & name,
    size_t offset
)
  

Get memory register from this device.

Parameters:

  • name Name of the memory register
  • offset Offset to be applied to the base address of the memory register

Return: Value of the register

Reimplements: peary::device::Device::getMemory

function getMemory

  inline virtual uintptr_t getMemory(
    const std::string & name,
    size_t offset
) override
  

Get memory register from this device.

Parameters:

  • name Name of the memory register
  • offset Offset to be applied to the base address of the memory register

Return: Value of the register

Reimplements: peary::device::Device::getMemory

function getMemory

  template <typename D  =uintptr_t>
virtual D getMemory(
    const std::string & name
)
  

Get memory register from this device.

Parameters:

  • name Name of the memory register

Return: Value of the register

Reimplements: peary::device::Device::getMemory

function getMemory

  inline virtual uintptr_t getMemory(
    const std::string & name
) override
  

Get memory register from this device.

Parameters:

  • name Name of the memory register

Return: Value of the register

Reimplements: peary::device::Device::getMemory

function getMemories

  virtual std::vector< std::pair< std::string, uintptr_t > > getMemories() override
  

Get all memory registers from this device.

Return: Vector with pairs of memory name and value

Reimplements: peary::device::Device::getMemories

function hasMemory

  virtual bool hasMemory(
    const std::string & name
) const override
  

Check if a memory register with this name exists.

Parameters:

  • name Name of the memory register

Return: True if the memory register exists, false otherwise

Reimplements: peary::device::Device::hasMemory

Protected Functions Documentation

function register_resource

  void register_resource(
    const std::string & name,
    B::R res
)
  

Register a resource with the device.

Parameters:

  • name Name of the resource
  • res Resource to be associated

This function registers a resource with the device, which can be used to control the device’s periphery components, such as voltage regulators, ADCs, etc.

function register_memory

  void register_memory(
    const std::string & name,
    utils::memory_map mem,
    utils::register_t< std::uintptr_t, std::uintptr_t > reg
)
  

Register a memory with the device.

Parameters:

  • name Name of the register
  • mem Memory map to use
  • reg Register to associate

This function registers a memory map with the device, which can be used to read and write registers in the FPGA firmware through the AXI bus

function register_memory

  void register_memory(
    const std::vector< std::pair< std::string, std::pair< utils::memory_map, utils::register_t< std::uintptr_t, std::uintptr_t >>>> elements
)
  

Register a memory with the device.

Parameters:

  • elements Elements to register

This function registers a memory map with the device, which can be used to read and write registers in the FPGA firmware through the AXI bus

function process_register_write

  void process_register_write(
    utils::register_t< typename SCI::reg_t, typename SCI::data_t > reg,
    uintptr_t value
)
  

Process writing to registers, ignoring special flags.

Parameters:

  • reg Register to be written
  • value Value of the register to be set

function process_register_read

  uintptr_t process_register_read(
    utils::register_t< typename SCI::reg_t, typename SCI::data_t > reg
)
  

Process reading from registers, ignoring special flags.

Parameters:

  • reg Register to be read

Return: Value of the register

function send

  SCI::data_t send(
    const typename SCI::data_t & data
)
  

Write data to a device which does not contain internal register.

Parameters:

  • data Data to be sent

Return: Data read back if readout is integral part of write operations

function send

  SCI::vector_t send(
    const std::vector< typename SCI::data_t > & data
)
  

Write data to a device which does not contain internal register.

Parameters:

  • data Data to be sent

Return: Data read back if readout is integral part of write operations

function send

  std::pair< typename SCI::reg_t, typename SCI::data_t > send(
    const std::pair< typename SCI::reg_t, typename SCI::data_t > & data
)
  

Send data to a device containing internal registers.

Parameters:

  • data Pair of register address and data to be sent

Return: Pair of register address and data read back if readout is integral part of write operations

function send

  SCI::vector_t send(
    const typename SCI::reg_t & reg,
    const std::vector< typename SCI::data_t > & data
)
  

Send data to a device containing internal registers.

Parameters:

  • reg Register address to which data is to be sent
  • data Data to be sent

Return: Data read back if readout is integral part of write operations

function send

  std::vector< std::pair< typename SCI::reg_t, typename SCI::data_t > > send(
    const std::vector< std::pair< typename SCI::reg_t, typename SCI::data_t >> & data
)
  

Send data to a device containing internal registers.

Parameters:

  • data Vector of pairs of register address and data to be sent

Return: Vector of pairs of register address and data read back if readout is integral part of write operations

function receive

  SCI::vector_t receive(
    const typename SCI::reg_t reg,
    const unsigned int length =1
)
  

Receive data from a device which does not contain internal register.

Parameters:

  • reg Register address from which data is to be read
  • length Number of data words to be read

Return: Data read back

function receiveData

  DRI::vector_t receiveData(
    const unsigned int length =1
)
  

Receive data from a device which does not contain internal register.

Parameters:

  • length Number of data words to be read

Return: Data read back

function receiveData

  DRI::vector_t receiveData(
    const typename DRI::reg_t reg,
    const unsigned int length =1
)
  

Receive data from a device containing internal registers.

Parameters:

  • reg Register address from which data is to be read
  • length Number of data words to be read

Return: Data read back

Protected Attributes Documentation

variable _board

  std::shared_ptr< B > _board;
  

Instance of the Caribou Board abstraction layer library All register and hardware access should go through this interface.

variable _config

  config::Configuration _config;
  

Device configuration object

variable _register_cache

  std::map< std::string, typename SCI::data_t > _register_cache;
  

Register cache


Updated on 2026-01-30 at 22:01:05 +0100