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

A connection to a stand-in T7, for tests and for running the bridge with no hardware (t7_bridge --fake). More...

#include <T7Stream.hpp>

Inheritance diagram for fsw::t7::FakeT7Device:
[legend]
Collaboration diagram for fsw::t7::FakeT7Device:
[legend]

Classes

struct  Options

Public Member Functions

 FakeT7Device ()
 FakeT7Device (Options o)
void open (const std::string &ip) override
int64_t serial_number () override
void write_names (const std::vector< std::string > &names, const std::vector< double > &values) override
std::vector< double > read_names (const std::vector< std::string > &names) override
 Command-response reads; only valid while no stream is running.
double stream_start (const std::vector< std::string > &scan_names, int scans_per_read, double scan_rate_hz) override
 Starts the stream; returns the scan rate the device will actually run at.
Backlog stream_read (std::vector< double > &data) override
 Fills data with scans_per_read scans, channels interleaved.
void stream_stop () override
void close () override
FakeT7Unit & unit ()
double volts (int ain, double t) const
 Volts on ain at t: Options::signal, else the default described above.
Public Member Functions inherited from fsw::t7::T7Device
virtual ~T7Device ()=default

Public Attributes

std::string opened_ip
std::vector< std::pair< std::string, double > > writes
std::vector< std::string > scan_names
std::vector< std::string > reads
 every name read_names() was asked for
bool streaming = false
 this handle's own stream is running
bool closed = false
int stop_calls = 0

Private Member Functions

bool owns_stream () const

Private Attributes

Options opt_
int scans_per_read_ = 0
double rate_ = 0.0
uint64_t scan_ = 0
int reads_ = 0
uint64_t my_stream_ = 0
 unit stream_id this handle started; 0 = none

Detailed Description

A connection to a stand-in T7, for tests and for running the bridge with no hardware (t7_bridge --fake).

By default each AIN reads a slow sine offset by its AIN number, so the GUI shows distinct lines; Options::signal replaces that. AIN14 (the internal temperature sensor) reads 25 C and TEMPERATURE_DEVICE_K agrees with it. Every call is recorded so a test can check what the session asked of the device. Device state (stream, registers) is the shared FakeT7Unit's.

Modelled on LJM and the T7 firmware: a stream start, a configuration write or a command-response read while the unit streams fails with STREAM_IS_ACTIVE (2605); a stop with no stream answers STREAM_NOT_RUNNING (1303); writing STREAM_ENABLE = 0 stops the stream from any handle; reading a stream another handle stopped times out (1306).

Definition at line 249 of file T7Stream.hpp.

Constructor & Destructor Documentation

◆ FakeT7Device() [1/2]

fsw::t7::FakeT7Device::FakeT7Device ( )
inline

Definition at line 270 of file T7Stream.hpp.

References FakeT7Device().

Referenced by FakeT7Device().

◆ FakeT7Device() [2/2]

fsw::t7::FakeT7Device::FakeT7Device ( Options o)
explicit

Definition at line 318 of file T7Stream.cpp.

References o, and opt_.

Member Function Documentation

◆ close()

void fsw::t7::FakeT7Device::close ( )
overridevirtual

Implements fsw::t7::T7Device.

Definition at line 455 of file T7Stream.cpp.

References closed, my_stream_, and streaming.

Referenced by engine.layerx.pool.WorkerPool::__exit__().

◆ open()

void fsw::t7::FakeT7Device::open ( const std::string & ip)
overridevirtual

Implements fsw::t7::T7Device.

Definition at line 323 of file T7Stream.cpp.

References closed, opened_ip, and opt_.

◆ owns_stream()

bool fsw::t7::FakeT7Device::owns_stream ( ) const
inlineprivate

Definition at line 308 of file T7Stream.hpp.

References my_stream_, and opt_.

Referenced by stream_read(), stream_stop(), and write_names().

◆ read_names()

std::vector< double > fsw::t7::FakeT7Device::read_names ( const std::vector< std::string > & names)
overridevirtual

Command-response reads; only valid while no stream is running.

Implements fsw::t7::T7Device.

Definition at line 360 of file T7Stream.cpp.

References fsw::t7::ljm_code::kStreamIsActive, opt_, reads, and volts().

◆ serial_number()

int64_t fsw::t7::FakeT7Device::serial_number ( )
overridevirtual

Implements fsw::t7::T7Device.

Definition at line 329 of file T7Stream.cpp.

References opt_.

◆ stream_read()

T7Device::Backlog fsw::t7::FakeT7Device::stream_read ( std::vector< double > & data)
overridevirtual

Fills data with scans_per_read scans, channels interleaved.

Blocks until they arrive.

Implements fsw::t7::T7Device.

Definition at line 407 of file T7Stream.cpp.

References fsw::t7::kDummyValue, fsw::t7::ljm_code::kStreamNotInitialized, fsw::t7::ljm_code::kSynchronizationTimeout, my_stream_, opt_, owns_stream(), rate_, reads_, scan_, scan_names, scans_per_read_, streaming, and volts().

◆ stream_start()

double fsw::t7::FakeT7Device::stream_start ( const std::vector< std::string > & scan_names,
int scans_per_read,
double scan_rate_hz )
overridevirtual

Starts the stream; returns the scan rate the device will actually run at.

Implements fsw::t7::T7Device.

Definition at line 386 of file T7Stream.cpp.

References fsw::t7::ljm_code::kStreamIsActive, my_stream_, opt_, rate_, scan_, scan_names, scans_per_read_, and streaming.

◆ stream_stop()

void fsw::t7::FakeT7Device::stream_stop ( )
overridevirtual

◆ unit()

FakeT7Unit & fsw::t7::FakeT7Device::unit ( )
inline

Definition at line 294 of file T7Stream.hpp.

References opt_.

◆ volts()

double fsw::t7::FakeT7Device::volts ( int ain,
double t ) const

Volts on ain at t: Options::signal, else the default described above.

Definition at line 378 of file T7Stream.cpp.

References fsw::t7::kAin14NominalOffsetK, fsw::t7::kAin14SlopeKPerV, fsw::t7::kCjcAin, and opt_.

Referenced by read_names(), and stream_read().

◆ write_names()

void fsw::t7::FakeT7Device::write_names ( const std::vector< std::string > & names,
const std::vector< double > & values )
overridevirtual

Implements fsw::t7::T7Device.

Definition at line 333 of file T7Stream.cpp.

References fsw::t7::ljm_code::kStreamIsActive, opt_, owns_stream(), streaming, and writes.

Member Data Documentation

◆ closed

bool fsw::t7::FakeT7Device::closed = false

Definition at line 291 of file T7Stream.hpp.

Referenced by close(), main(), and open().

◆ my_stream_

uint64_t fsw::t7::FakeT7Device::my_stream_ = 0
private

unit stream_id this handle started; 0 = none

Definition at line 307 of file T7Stream.hpp.

Referenced by close(), owns_stream(), stream_read(), stream_start(), and stream_stop().

◆ opened_ip

std::string fsw::t7::FakeT7Device::opened_ip

Definition at line 286 of file T7Stream.hpp.

Referenced by main(), and open().

◆ opt_

Options fsw::t7::FakeT7Device::opt_
private

◆ rate_

double fsw::t7::FakeT7Device::rate_ = 0.0
private

Definition at line 304 of file T7Stream.hpp.

Referenced by stream_read(), and stream_start().

◆ reads

std::vector<std::string> fsw::t7::FakeT7Device::reads

every name read_names() was asked for

Definition at line 289 of file T7Stream.hpp.

Referenced by main(), and read_names().

◆ reads_

int fsw::t7::FakeT7Device::reads_ = 0
private

Definition at line 306 of file T7Stream.hpp.

Referenced by stream_read().

◆ scan_

uint64_t fsw::t7::FakeT7Device::scan_ = 0
private

Definition at line 305 of file T7Stream.hpp.

Referenced by stream_read(), and stream_start().

◆ scan_names

std::vector<std::string> fsw::t7::FakeT7Device::scan_names

Definition at line 288 of file T7Stream.hpp.

Referenced by stream_read(), and stream_start().

◆ scans_per_read_

int fsw::t7::FakeT7Device::scans_per_read_ = 0
private

Definition at line 303 of file T7Stream.hpp.

Referenced by stream_read(), and stream_start().

◆ stop_calls

int fsw::t7::FakeT7Device::stop_calls = 0

Definition at line 292 of file T7Stream.hpp.

Referenced by main(), and stream_stop().

◆ streaming

bool fsw::t7::FakeT7Device::streaming = false

this handle's own stream is running

Definition at line 290 of file T7Stream.hpp.

Referenced by close(), main(), stream_read(), stream_start(), stream_stop(), and write_names().

◆ writes

std::vector<std::pair<std::string, double> > fsw::t7::FakeT7Device::writes

Definition at line 287 of file T7Stream.hpp.

Referenced by main(), and write_names().


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