lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Pds Namespace Reference

Outer namespace of the HSD digitizer helpers. More...

Namespaces

namespace  Bld
 Namespace of the BLD multicast packet classes (Header, Client, Server).
 
namespace  Cphw
 
namespace  Dti
 
namespace  Eb
 Namespace of the psdaq event-builder (eb) code.
 
namespace  Fabrics
 Thin C++ wrappers around the libfabric API.
 
namespace  HSD
 HSD digitizer classes: stream and event header views and stream validators.
 
namespace  Ipc
 POSIX shared-memory and message-queue helpers for the DRP.
 
namespace  Kcu
 
namespace  Mmhw
 
namespace  PvDaq
 
namespace  Tpr
 
namespace  Trg
 Namespace of the psdaq trigger code: TEB input data records, trigger primitives and trigger decisions.
 
namespace  Xpm
 Namespace of the XPM register access and control code.
 

Classes

class  AlignmentAllocator
 Stateless allocator for standard containers that allocates with posix_memalign() at N-byte alignment (default 16). More...
 
class  Dl
 Owns one dynamic library handle opened with dlopen(). More...
 
class  EbDgram
 Dgram prefixed by the pulse ID word, as built by the DRPs and exchanged with the event builders. More...
 
class  Entry
 Element of an intrusive doubly linked List; a new entry is linked to itself. More...
 
class  fast_monotonic_clock
 std::chrono-style steady clock with nanosecond duration read with clock_gettime(): CLOCK_MONOTONIC_COARSE if it works on this system, otherwise CLOCK_MONOTONIC (chosen once on first use). More...
 
class  Fifo
 Fixed-size ring buffer of T, not thread-safe. More...
 
class  GenericPool
 Pool whose buffers are carved from one new[] block and kept on a Queue of PoolEntry (spin-locked); allocation returns nullptr when the queue is empty. More...
 
class  GenericPoolW
 GenericPool whose allocation blocks on a condition variable until a buffer is freed (or stop() is called); frees wake one waiter. More...
 
class  Histogram
 Integer histogram with 2^size bins and an overflow count; unitsCvt converts a bin index to physical units when printing. More...
 
class  JsonIterator
 Walks a JSON value depth-first (object members in sorted order) and calls process() for each leaf, keeping the dotted name path; a parallel types value describes the leaves. More...
 
class  LinkedListSL
 Typed wrapper over Pds::ListBase (private base) in which every operation holds a per-object Pds::SpinLock. More...
 
class  List
 Head (label) of an intrusive doubly linked list of Entry objects; insert, jam and remove hold a spin lock, their NL variants do not. More...
 
class  ListBase
 Node of an intrusive doubly linked list; an object can be a list head (label) or an element. More...
 
class  Lock
 Abstract lock on a binary Semaphore (the VxWorks variant is not supported). More...
 
class  MetricExporter
 Prometheus collectable holding named metrics whose values come from callbacks evaluated at each scrape (Collect()). More...
 
class  Pool
 Abstract pool of numberofObjects equal buffers, each preceded by a PoolEntry, with allocation and free counters. More...
 
class  PoolEntry
 Header in front of each pool buffer: two words used as queue links while the buffer is free, the owning Pool and a tag. More...
 
struct  Previous
 Last sample of a Rate metric (value and time), used to compute the rate at the next scrape. More...
 
class  PromHistogram
 Fixed-bin histogram exported as a Prometheus histogram: numBins upper bounds binMin + i * binWidth plus an overflow bucket. More...
 
class  PulseId
 64-bit word whose low 56 bits are the pulse ID and whose upper 8 bits carry control bits from the timing system (per the code comment). More...
 
class  QueueSS
 Queue of T over List (private base) whose insert, remove, atHead and atTail hold a pthread mutex (per the header comment, re-entrant but slow). More...
 
class  Routine
 Job that can be queued to a Task with Task::call() (a queue Entry); the task thread calls routine(). More...
 
class  Semaphore
 Unnamed POSIX semaphore (sem_t) shared between threads of one process. More...
 
class  SemLock
 Lock built on a Semaphore. More...
 
class  SpinLock
 Busy-waiting lock on an atomic flag; satisfies the lock() and unlock() interface of std::lock_guard. More...
 
class  SysClk
 Static clock helpers. More...
 
class  Task
 Thread that runs Routine jobs from a queue in order (TaskMainLoop). More...
 
class  TaskDelete
 Routine queued by Task::destroy() so that the task deletes itself from its own thread (per the code comment). More...
 
class  TaskObject
 Thread parameters of a Task: name, priority, stack size and base, queue size and pthread attributes, plus the thread ID once created. More...
 
class  TaskWait
 Routine that, once queued on a Task, lets the caller block until the task has run all jobs queued before it (per the file comment). More...
 
class  Timer
 Base of timers: after start(), expired() is run in the Task returned by task() every duration() milliseconds (or once if repetitive() is 0) until cancel(). More...
 
class  TimerServiceRoutine
 UNIX implementation of a Timer: a separate service Task waits on a condition variable with a deadline and, on timeout, queues the Timer on its user task. More...
 
class  TimingHeader
 Timing header at the start of the DMA data: the pulse ID word, the transition fields (time, env), an event counter and two opaque words. More...
 

Typedefs

typedef void *(* TaskFunction) (void *)
 C-linkage thread entry function type: takes and returns a void pointer.
 

Enumerations

enum class  MetricType {
  Gauge , Counter , Rate , Constant ,
  Histogram , Float
}
 Kind of a metric registered with MetricExporter. More...
 

Functions

int translateJson2Xtc (char *in, char *out, const void *bufEnd, XtcData::NamesId namesID, const char *detname=0, unsigned segment=0)
 Parse the JSON text in, create a Parent Xtc at out (bounded by bufEnd) and add the Names and data for it with namesID, detname (if non-null) and segment.
 
int translateJson2Xtc (PyObject *item, XtcData::Xtc &xtc, const void *bufEnd, XtcData::NamesId namesID)
 Translate the JSON string object item into Names and data appended to xtc, taking the detector name and segment from the detName:RO entry (name_N).
 
int translateJson2Xtc (PyObject *item, XtcData::Xtc &xtc, const void *bufEnd, XtcData::NamesId namesID, unsigned segment, std::string serNo=std::string(""))
 Like translateJson2Xtc(item, xtc, bufEnd, namesID), but uses serNo as detector ID when it is non-empty.
 
int translateJson2XtcNames (rapidjson::Document *d, XtcData::Xtc *xtc, const void *bufEnd, XtcData::NamesLookup &nl, XtcData::NamesId namesID, rapidjson::Value &json, const char *detname, unsigned segment, std::string const &serNo=std::string(""))
 Check that the document has alg:RO, detName:RO, detType:RO, detId:RO and doc:RO, add Names (detector name, algorithm, type, serNo or detId:RO, namesID, segment) with one entry per leaf typed from :types: (plus ENUMDICT entries for :enum:) to xtc, register them in nl, and move :types: into json.
 
int translateJson2XtcData (rapidjson::Document *d, XtcData::Xtc *xtc, const void *bufEnd, XtcData::NamesLookup &nl, XtcData::NamesId namesID, rapidjson::Value &json)
 Write the values of the remaining document members (and the :enum: dictionary values first) into xtc as data for namesID, typed from json; returns 0.
 
std::unique_ptr< prometheus::Exposer > createExposer (const std::string &prometheusDir, const std::string &hostname)
 Same as createExposer(prometheusDir, hostname, 0).
 
std::unique_ptr< prometheus::Exposer > createExposer (const std::string &prometheusDir, const std::string &hostname, unsigned portOffset)
 Start a Prometheus exposer on the first usable port from 9200 + portOffset (wrapping within 9200 to 9299) and write the scrape target file prometheusDir/drpmon_HOST_N.yaml for it.
 
template<typename T >
void setValue (prometheus::MetricFamily &family, const T &value)
 Set the counter or gauge value of the first metric of family to value; prints wrong type for other metric types.
 
void getRange (const std::string &input, std::vector< int > &data)
 Append to data every integer in input, where each item is a number or an inclusive range written N-M (items are found by regular expression search, so any separator works).
 
void * TaskMainLoop (void *)
 Thread body of a Task (task is the Task): run every queued Routine, then wait on the pending semaphore for more, forever.
 

Detailed Description

Outer namespace of the HSD digitizer helpers.

Top-level namespace of the psdaq C++ code.

Typedef Documentation

◆ TaskFunction

typedef void *(* Pds::TaskFunction) (void *)

C-linkage thread entry function type: takes and returns a void pointer.

Enumeration Type Documentation

◆ MetricType

enum class Pds::MetricType
strong

Kind of a metric registered with MetricExporter.

Enumerator
Gauge 

Value read by the callback at each scrape, exported as a gauge.

Counter 

Value read by the callback at each scrape, exported as a counter.

Rate 

Rate per second of the callback value since the previous scrape (negative changes give 0), exported as a gauge.

Constant 

Fixed value set by constant(), exported as a counter (per the comment, only for constant()).

Histogram 

A PromHistogram created by histogram().

Float 

Double value from a callback that reports whether it is valid, exported as a gauge.

Function Documentation

◆ createExposer() [1/2]

std::unique_ptr< prometheus::Exposer > Pds::createExposer ( const std::string &  prometheusDir,
const std::string &  hostname 
)

Same as createExposer(prometheusDir, hostname, 0).

◆ createExposer() [2/2]

std::unique_ptr< prometheus::Exposer > Pds::createExposer ( const std::string &  prometheusDir,
const std::string &  hostname,
unsigned  portOffset 
)

Start a Prometheus exposer on the first usable port from 9200 + portOffset (wrapping within 9200 to 9299) and write the scrape target file prometheusDir/drpmon_HOST_N.yaml for it.

Returns an empty pointer if prometheusDir is empty or no port works.

◆ getRange()

void Pds::getRange ( const std::string &  input,
std::vector< int > &  data 
)

Append to data every integer in input, where each item is a number or an inclusive range written N-M (items are found by regular expression search, so any separator works).

◆ setValue()

template<typename T >
void Pds::setValue ( prometheus::MetricFamily &  family,
const T &  value 
)

Set the counter or gauge value of the first metric of family to value; prints wrong type for other metric types.

◆ TaskMainLoop()

void * Pds::TaskMainLoop ( void *  )

Thread body of a Task (task is the Task): run every queued Routine, then wait on the pending semaphore for more, forever.

Lets TaskMainLoop() reach the private job queue and semaphore.

Never returns.

◆ translateJson2Xtc() [1/3]

int Pds::translateJson2Xtc ( char *  in,
char *  out,
const void *  bufEnd,
XtcData::NamesId  namesID,
const char *  detname = 0,
unsigned  segment = 0 
)

Parse the JSON text in, create a Parent Xtc at out (bounded by bufEnd) and add the Names and data for it with namesID, detname (if non-null) and segment.

Returns the Xtc extent, or -1 if the Names translation fails.

◆ translateJson2Xtc() [2/3]

int Pds::translateJson2Xtc ( PyObject *  item,
XtcData::Xtc &  xtc,
const void *  bufEnd,
XtcData::NamesId  namesID 
)

Translate the JSON string object item into Names and data appended to xtc, taking the detector name and segment from the detName:RO entry (name_N).

Returns 0, or -1 if detName:RO is missing or has no _N suffix or a translation step fails.

◆ translateJson2Xtc() [3/3]

int Pds::translateJson2Xtc ( PyObject *  item,
XtcData::Xtc &  xtc,
const void *  bufEnd,
XtcData::NamesId  namesID,
unsigned  segment,
std::string  serNo = std::string("") 
)

Like translateJson2Xtc(item, xtc, bufEnd, namesID), but uses serNo as detector ID when it is non-empty.

The segment argument is overwritten by the number parsed from detName:RO.

◆ translateJson2XtcData()

int Pds::translateJson2XtcData ( rapidjson::Document *  d,
XtcData::Xtc *  xtc,
const void *  bufEnd,
XtcData::NamesLookup &  nl,
XtcData::NamesId  namesID,
rapidjson::Value &  json 
)

Write the values of the remaining document members (and the :enum: dictionary values first) into xtc as data for namesID, typed from json; returns 0.

◆ translateJson2XtcNames()

int Pds::translateJson2XtcNames ( rapidjson::Document *  d,
XtcData::Xtc *  xtc,
const void *  bufEnd,
XtcData::NamesLookup &  nl,
XtcData::NamesId  namesID,
rapidjson::Value &  json,
const char *  detname,
unsigned  segment,
std::string const &  serNo = std::string("") 
)

Check that the document has alg:RO, detName:RO, detType:RO, detId:RO and doc:RO, add Names (detector name, algorithm, type, serNo or detId:RO, namesID, segment) with one entry per leaf typed from :types: (plus ENUMDICT entries for :enum:) to xtc, register them in nl, and move :types: into json.

Those members are removed from the document. Returns 0, or -1 on a parse error or missing field.