STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
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 FakeT7Device:
[legend]
Collaboration diagram for 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]

Definition at line 270 of file T7Stream.hpp.

◆ FakeT7Device() [2/2]

Definition at line 318 of file T7Stream.cpp.

Member Function Documentation

◆ close()

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

Implements fsw::t7::T7Device.

Definition at line 455 of file T7Stream.cpp.

◆ open()

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

Implements fsw::t7::T7Device.

Definition at line 323 of file T7Stream.cpp.

◆ owns_stream()

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

Definition at line 308 of file T7Stream.hpp.

◆ 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.

◆ serial_number()

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

Implements fsw::t7::T7Device.

Definition at line 329 of file T7Stream.cpp.

◆ 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.

◆ 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.

◆ stream_stop()

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

Implements fsw::t7::T7Device.

Definition at line 436 of file T7Stream.cpp.

◆ unit()

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

Definition at line 294 of file T7Stream.hpp.

◆ 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.

◆ 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.

Member Data Documentation

◆ closed

Definition at line 291 of file T7Stream.hpp.

◆ 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.

◆ opened_ip

Definition at line 286 of file T7Stream.hpp.

◆ opt_

Definition at line 302 of file T7Stream.hpp.

◆ rate_

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

Definition at line 304 of file T7Stream.hpp.

◆ reads

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

every name read_names() was asked for

Definition at line 289 of file T7Stream.hpp.

◆ reads_

Definition at line 306 of file T7Stream.hpp.

◆ scan_

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

Definition at line 305 of file T7Stream.hpp.

◆ scan_names

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

Definition at line 288 of file T7Stream.hpp.

◆ scans_per_read_

Definition at line 303 of file T7Stream.hpp.

◆ stop_calls

Definition at line 292 of file T7Stream.hpp.

◆ streaming

this handle's own stream is running

Definition at line 290 of file T7Stream.hpp.

◆ writes

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

Definition at line 287 of file T7Stream.hpp.


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