|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
One T7's stream: open, configure, start, then read blocks until something throws. More...
#include <T7Stream.hpp>
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_ |
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.
| using fsw::t7::T7Session::Clock = std::function<uint64_t()> |
epoch ns
Definition at line 146 of file T7Stream.hpp.
| fsw::t7::T7Session::T7Session | ( | config::T7Board | board, |
| std::unique_ptr< T7Device > | device, | ||
| const time::TimeSyncConfig & | time_sync, | ||
| Clock | clock ) |
Definition at line 82 of file T7Stream.cpp.
References board(), board_, cjc_device_offset_k_, clock_, clock_sync_, device_, plan_, and fsw::t7::plan_stream().
|
inline |
Definition at line 168 of file T7Stream.hpp.
References actual_rate_hz_.
|
inline |
Definition at line 162 of file T7Stream.hpp.
References board(), and board_.
Referenced by board(), and T7Session().
|
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_.
|
inline |
Definition at line 165 of file T7Stream.hpp.
References plan_.
Referenced by anonymous_namespace{t7_bridge_main.cpp}::run_board().
| Block fsw::t7::T7Session::read | ( | ) |
Reads and decodes one block.
Definition at line 158 of file T7Stream.cpp.
References actual_rate_hz_, b, back(), board_, buffer_, cjc_device_offset_k_, fsw::t7::cjc_temp_c(), clock_, clock_sync_, device_, fsw::t7::kDummyValue, next_scan_, and plan_.
Referenced by main(), and anonymous_namespace{t7_bridge_main.cpp}::run_board().
|
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().
| 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().
|
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().
|
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().
|
private |
Definition at line 191 of file T7Stream.hpp.
Referenced by actual_rate_hz(), read(), and start().
|
private |
Definition at line 186 of file T7Stream.hpp.
Referenced by board(), read(), start(), and T7Session().
|
private |
Definition at line 195 of file T7Stream.hpp.
|
private |
Definition at line 197 of file T7Stream.hpp.
Referenced by cjc_device_offset_k(), read(), start(), and T7Session().
|
private |
Definition at line 189 of file T7Stream.hpp.
Referenced by read(), and T7Session().
|
private |
Definition at line 188 of file T7Stream.hpp.
Referenced by read(), and T7Session().
|
private |
Definition at line 187 of file T7Stream.hpp.
Referenced by read(), start(), stop(), and T7Session().
|
private |
Definition at line 194 of file T7Stream.hpp.
|
private |
Definition at line 196 of file T7Stream.hpp.
|
private |
Definition at line 190 of file T7Stream.hpp.
Referenced by plan(), read(), start(), and T7Session().
|
private |
Definition at line 192 of file T7Stream.hpp.
|
private |
Definition at line 193 of file T7Stream.hpp.
Referenced by start(), and stopped_leftover_stream().