STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
fsw::t7::T7Session Class Reference

One T7's stream: open, configure, start, then read blocks until something throws. More...

#include <T7Stream.hpp>

Collaboration diagram for fsw::t7::T7Session:
[legend]

Public Types

using Clock = std::function<uint64_t()>
 epoch ns

Public Member Functions

 T7Session (config::T7Board board, std::unique_ptr< T7Device > device, const time::TimeSyncConfig &time_sync, Clock clock)
double start ()
 Opens the device, checks its serial number if the config gives one, writes the setup, takes the cold-junction reference (TC boards) and starts the stream.
Block read ()
 Reads and decodes one block.
void stop () noexcept
 Stops the stream and closes the device; never throws.
const config::T7Board & board () const
const StreamPlan & plan () const
double actual_rate_hz () const
bool stopped_leftover_stream () const
 start() found a stream already running on the device (left by a bridge that was killed, a server torn down mid-run, or Kipling) and stopped it before configuring.
int64_t serial () const
 The device's serial number, read by start(); 0 before then.
double cjc_device_offset_k () const
 AIN14 offset taken at start (K); see t7::cjc_device_offset_k.

Private Attributes

config::T7Board board_
std::unique_ptr< T7Device > device_
time::BoardClockSync clock_sync_
Clock clock_
StreamPlan plan_
double actual_rate_hz_ = 0.0
int64_t serial_ = 0
bool stopped_leftover_ = false
uint64_t next_scan_ = 0
std::vector< double > buffer_
bool open_ = false
double cjc_device_offset_k_

Detailed Description

One T7's stream: open, configure, start, then read blocks until something throws.

Timestamps. The T7 scans on its own crystal at a fixed rate, so scan k happened at k / actual_rate seconds after the stream started. That device time goes through the same BoardClockSync the ESP32 boards use, keyed by the board's config section, which estimates the device-to-host offset from when blocks arrive (arrival can only be late, never early). The newest scan of each block is anchored that way and the others are placed back from it at the exact scan period. In [time_sync] mode = "arrival" the anchor is simply the arrival time.

Definition at line 144 of file T7Stream.hpp.

Member Typedef Documentation

◆ Clock

using fsw::t7::T7Session::Clock = std::function<uint64_t()>

epoch ns

Definition at line 146 of file T7Stream.hpp.

Constructor & Destructor Documentation

◆ T7Session()

fsw::t7::T7Session::T7Session ( config::T7Board board,
std::unique_ptr< T7Device > device,
const time::TimeSyncConfig & time_sync,
Clock clock )

Member Function Documentation

◆ actual_rate_hz()

double fsw::t7::T7Session::actual_rate_hz ( ) const
inline

Definition at line 168 of file T7Stream.hpp.

References actual_rate_hz_.

◆ board()

const config::T7Board & fsw::t7::T7Session::board ( ) const
inline

Definition at line 162 of file T7Stream.hpp.

References board(), and board_.

Referenced by board(), and T7Session().

◆ cjc_device_offset_k()

double fsw::t7::T7Session::cjc_device_offset_k ( ) const
inline

AIN14 offset taken at start (K); see t7::cjc_device_offset_k.

NaN without a TC.

Definition at line 181 of file T7Stream.hpp.

References cjc_device_offset_k_.

◆ plan()

const StreamPlan & fsw::t7::T7Session::plan ( ) const
inline

Definition at line 165 of file T7Stream.hpp.

References plan_.

Referenced by anonymous_namespace{t7_bridge_main.cpp}::run_board().

◆ read()

Block fsw::t7::T7Session::read ( )

◆ serial()

int64_t fsw::t7::T7Session::serial ( ) const
inline

The device's serial number, read by start(); 0 before then.

Definition at line 177 of file T7Stream.hpp.

References serial_.

Referenced by anonymous_namespace{t7_bridge_main.cpp}::run_board().

◆ start()

double fsw::t7::T7Session::start ( )

Opens the device, checks its serial number if the config gives one, writes the setup, takes the cold-junction reference (TC boards) and starts the stream.

Returns the actual scan rate.

Definition at line 92 of file T7Stream.cpp.

References actual_rate_hz_, board_, buffer_, fsw::t7::cjc_device_offset_k(), cjc_device_offset_k_, fsw::t7::T7Error::code(), device_, fsw::t7::is_stream_not_running(), fsw::t7::ljm_code::kStreamIsActive, next_scan_, open_, plan_, serial_, and stopped_leftover_.

Referenced by main(), and anonymous_namespace{t7_bridge_main.cpp}::run_board().

◆ stop()

void fsw::t7::T7Session::stop ( )
noexcept

Stops the stream and closes the device; never throws.

Definition at line 215 of file T7Stream.cpp.

References device_, and open_.

Referenced by main(), and anonymous_namespace{t7_bridge_main.cpp}::run_board().

◆ stopped_leftover_stream()

bool fsw::t7::T7Session::stopped_leftover_stream ( ) const
inline

start() found a stream already running on the device (left by a bridge that was killed, a server torn down mid-run, or Kipling) and stopped it before configuring.

Definition at line 173 of file T7Stream.hpp.

References stopped_leftover_.

Referenced by main(), and anonymous_namespace{t7_bridge_main.cpp}::run_board().

Member Data Documentation

◆ actual_rate_hz_

double fsw::t7::T7Session::actual_rate_hz_ = 0.0
private

Definition at line 191 of file T7Stream.hpp.

Referenced by actual_rate_hz(), read(), and start().

◆ board_

config::T7Board fsw::t7::T7Session::board_
private

Definition at line 186 of file T7Stream.hpp.

Referenced by board(), read(), start(), and T7Session().

◆ buffer_

std::vector<double> fsw::t7::T7Session::buffer_
private

Definition at line 195 of file T7Stream.hpp.

Referenced by read(), and start().

◆ cjc_device_offset_k_

double fsw::t7::T7Session::cjc_device_offset_k_
private

Definition at line 197 of file T7Stream.hpp.

Referenced by cjc_device_offset_k(), read(), start(), and T7Session().

◆ clock_

Clock fsw::t7::T7Session::clock_
private

Definition at line 189 of file T7Stream.hpp.

Referenced by read(), and T7Session().

◆ clock_sync_

time::BoardClockSync fsw::t7::T7Session::clock_sync_
private

Definition at line 188 of file T7Stream.hpp.

Referenced by read(), and T7Session().

◆ device_

std::unique_ptr<T7Device> fsw::t7::T7Session::device_
private

Definition at line 187 of file T7Stream.hpp.

Referenced by read(), start(), stop(), and T7Session().

◆ next_scan_

uint64_t fsw::t7::T7Session::next_scan_ = 0
private

Definition at line 194 of file T7Stream.hpp.

Referenced by read(), and start().

◆ open_

bool fsw::t7::T7Session::open_ = false
private

Definition at line 196 of file T7Stream.hpp.

Referenced by start(), and stop().

◆ plan_

StreamPlan fsw::t7::T7Session::plan_
private

Definition at line 190 of file T7Stream.hpp.

Referenced by plan(), read(), start(), and T7Session().

◆ serial_

int64_t fsw::t7::T7Session::serial_ = 0
private

Definition at line 192 of file T7Stream.hpp.

Referenced by serial(), and start().

◆ stopped_leftover_

bool fsw::t7::T7Session::stopped_leftover_ = false
private

Definition at line 193 of file T7Stream.hpp.

Referenced by start(), and stopped_leftover_stream().


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