McStas Readout Master 0.8.0
Loading...
Searching...
No Matches
Sender Class Reference

Buffers ESS readout records and transmits them as UDP packets to one EFU. More...

#include <Sender.h>

Public Member Functions

 Sender (std::string IpAddress, const int UDPPort, const int TCPPort, const DetectorType detector_type, const ReadoutType readout_type, const pulse_grid grid)
 
 Sender (std::string IpAddress, const int UDPPort, const int TCPPort, const DetectorType detector_type, const ReadoutType readout_type, const efu_time p=efu_time(1))
 
 Sender (const SenderConfig &config, const pulse_grid grid)
 
 Sender (const SenderConfig &config, const efu_time p=efu_time(1))
 
void addReadout (uint8_t Ring, uint8_t FEN, double tof, double weight, const void *data)
 Add one readout with its event time set to the current pulse time plus tof; the weight is ignored (statistical sampling happens upstream). A full buffer is transmitted and a new packet started automatically.
 
void addReadout (uint8_t Ring, uint8_t FEN, efu_time t, const void *data)
 Add a single readout with an explicit event time.
 
void addReadout (uint8_t Ring, uint8_t FEN, efu_time t, const CAEN_readout_t *data)
 
void addReadout (uint8_t Ring, uint8_t FEN, efu_time t, const CDT_readout_t *data)
 
void addReadout (uint8_t Ring, uint8_t FEN, efu_time t, const VMM3_readout_t *data)
 
void addReadout (uint8_t Ring, uint8_t FEN, efu_time t, const BM0_readout_t *data)
 
void addReadout (uint8_t Ring, uint8_t FEN, efu_time t, const BM2_readout_t *data)
 
void addReadout (uint8_t Ring, uint8_t FEN, efu_time t, const BMI_readout_t *data)
 
int send ()
 Transmit the current data buffer; the caller is responsible for starting a new packet (newPacket()) before adding further readouts.
 
void setPulseTime (uint32_t PHI, uint32_t PLO, uint32_t PPHI, uint32_t PPLO)
 Update the pulse and previous pulse times (high/low pairs).
 
void begin_pulse ()
 Start a new pulse: flush any buffered readouts, wait until the next pulse-grid tick has passed on the wall clock, and start a new packet with that tick as its pulse time. Everything sent afterwards carries reference times strictly later than any wall-clock instant preceding this call.
 
void begin_pulse_at (uint64_t at)
 begin_pulse(), at the grid tick at (rounded up onto the grid), so that several Senders can begin one and the same pulse.
 
uint64_t next_pulse () const
 The tick begin_pulse() would begin: the first after now and after the current pulse.
 
void announce_pulse ()
 Send the current pulse's header with no readouts, so the EFU sees the pulse even when nothing is detected in it. An EFU summing a number of pulses into one histogram counts the pulses it is shown, so a silent one would shift every later histogram's boundaries.
 
void flush ()
 Send whatever is buffered for the current pulse now.
 
void hold_pulse (const bool hold)
 Keep the pulse begun by begin_pulse()/begin_pulse_at() however long sending takes, rather than moving on with the wall clock when a full buffer is sent. For a caller that places every event in a pulse of its choosing.
 
void fold_tof (const bool fold)
 Choose whether add-by-time-of-flight readouts are stamped at pulse + (tof % period) — attributing each event to the frame it would be detected in, as the real readout system reports it — instead of pulse + tof. Either way, a time-of-flight of a period or more is counted and reported.
 
uint64_t long_tof_count () const
 How many readouts so far had a time-of-flight of at least one pulse period.
 
std::pair< uint32_t, uint32_t > lastPulseTime () const
 
uint64_t lastPulseNanoseconds () const
 The current pulse exactly, in nanoseconds since the UNIX epoch: a pulse_grid tick.
 
std::pair< uint32_t, uint32_t > prevPulseTime () const
 
std::pair< uint32_t, uint32_t > lastEventTime () const
 
void newPacket ()
 Initialize a new packet with no readouts.
 
int command_shutdown () const
 Tell the remote EFU to shut down via its TCP command port.
 
int verbose (const Verbosity v)
 Set verbosity via enum.
 
int verbose (const int v)
 

Detailed Description

Buffers ESS readout records and transmits them as UDP packets to one EFU.

Records are packed into ESS readout packets (packet-type byte from the DetectorType, record layout from the ReadoutType) and sent to the configured address when the buffer fills, at pulse boundaries (begin_pulse()), or on destruction.

The pulse (reference) times in the packet headers march forward on a fixed grid with the configured period, anchored on the UNIX epoch (pulse_grid), so every Sender – and mccode-plumber's mp-tdc – agrees on when a pulse was: whenever a full buffer forces a new packet, the pulse time advances to the latest grid tick at or before the wall clock, so consecutive packets may share a pulse time until the reference clock ticks. begin_pulse() waits for the next grid tick to pass, guaranteeing the new pulse time is a wall-clock instant later than everything that happened before the call. The previous pulse time is always exactly one period earlier, as for a continuously pulsed source.

Definition at line 44 of file Sender.h.

Constructor & Destructor Documentation

◆ Sender() [1/4]

Sender::Sender ( std::string  IpAddress,
const int  UDPPort,
const int  TCPPort,
const DetectorType  detector_type,
const ReadoutType  readout_type,
const pulse_grid  grid 
)
inline

Definition at line 46 of file Sender.h.

◆ Sender() [2/4]

Sender::Sender ( std::string  IpAddress,
const int  UDPPort,
const int  TCPPort,
const DetectorType  detector_type,
const ReadoutType  readout_type,
const efu_time  p = efu_time(1) 
)
inline

Definition at line 62 of file Sender.h.

◆ Sender() [3/4]

Sender::Sender ( const SenderConfig &  config,
const pulse_grid  grid 
)
inlineexplicit

Definition at line 66 of file Sender.h.

◆ Sender() [4/4]

Sender::Sender ( const SenderConfig &  config,
const efu_time  p = efu_time(1) 
)
inlineexplicit

Definition at line 69 of file Sender.h.

◆ ~Sender()

Sender::~Sender ( )
inline

Definition at line 72 of file Sender.h.

Member Function Documentation

◆ fold_tof()

void Sender::fold_tof ( const bool  fold)
inline

Choose whether add-by-time-of-flight readouts are stamped at pulse + (tof % period) — attributing each event to the frame it would be detected in, as the real readout system reports it — instead of pulse + tof. Either way, a time-of-flight of a period or more is counted and reported.

Definition at line 128 of file Sender.h.

◆ hold_pulse()

void Sender::hold_pulse ( const bool  hold)
inline

Keep the pulse begun by begin_pulse()/begin_pulse_at() however long sending takes, rather than moving on with the wall clock when a full buffer is sent. For a caller that places every event in a pulse of its choosing.

Definition at line 122 of file Sender.h.

◆ lastPulseNanoseconds()

uint64_t Sender::lastPulseNanoseconds ( ) const
inline

The current pulse exactly, in nanoseconds since the UNIX epoch: a pulse_grid tick.

Definition at line 135 of file Sender.h.

◆ long_tof_count()

uint64_t Sender::long_tof_count ( ) const
inline

How many readouts so far had a time-of-flight of at least one pulse period.

Definition at line 130 of file Sender.h.

◆ verbose() [1/2]

int Sender::verbose ( const int  v)
inline

Definition at line 157 of file Sender.h.

◆ verbose() [2/2]

int Sender::verbose ( const Verbosity  v)
inline

Set verbosity via enum.

Definition at line 146 of file Sender.h.


The documentation for this class was generated from the following file: