PulseView  unreleased development snapshot
A Qt-based sigrok GUI
pv::data::SignalBase Class Reference

#include <signalbase.hpp>

Inheritance diagram for pv::data::SignalBase:
Collaboration diagram for pv::data::SignalBase:

Public Types

enum  ChannelType { AnalogChannel = 1, LogicChannel, DecodeChannel, MathChannel }
 
enum  ConversionType { NoConversion = 0, A2LConversionByThreshold = 1, A2LConversionBySchmittTrigger = 2 }
 
enum  ConversionPreset { NoPreset = -1, DynamicPreset = 0 }
 

Signals

void enabled_changed (const bool &value)
 
void name_changed (const QString &name)
 
void color_changed (const QColor &color)
 
void error_message_changed (QString msg)
 
void conversion_type_changed (const ConversionType t)
 
void samples_cleared ()
 
void samples_added (uint64_t segment_id, uint64_t start_sample, uint64_t end_sample)
 
void min_max_changed (float min, float max)
 

Public Member Functions

 SignalBase (shared_ptr< sigrok::Channel > channel, ChannelType channel_type)
 
virtual ~SignalBase ()
 
shared_ptr< sigrok::Channel > channel () const
 
bool is_generated () const
 
bool enabled () const
 
void set_enabled (bool value)
 
ChannelType type () const
 
unsigned int index () const
 
void set_index (unsigned int index)
 
unsigned int logic_bit_index () const
 
void set_group (SignalGroup *group)
 
SignalGroupgroup () const
 
QString name () const
 
QString internal_name () const
 
void set_internal_name (QString internal_name)
 
QString display_name () const
 
virtual void set_name (QString name)
 
QColor color () const
 
virtual void set_color (QColor color)
 
QColor bgcolor () const
 
virtual QString get_error_message () const
 
void set_data (shared_ptr< pv::data::SignalData > data)
 
void clear_sample_data ()
 
shared_ptr< pv::data::Analoganalog_data () const
 
shared_ptr< pv::data::Logiclogic_data () const
 
shared_ptr< pv::data::SignalDatadata () const
 
bool segment_is_complete (uint32_t segment_id) const
 
bool has_samples () const
 
virtual double get_samplerate () const
 
ConversionType get_conversion_type () const
 
void set_conversion_type (ConversionType t)
 
map< QString, QVariant > get_conversion_options () const
 
bool set_conversion_option (QString key, QVariant value)
 
vector< double > get_conversion_thresholds (const ConversionType t=NoConversion, const bool always_custom=false) const
 
vector< pair< QString, int > > get_conversion_presets () const
 
ConversionPreset get_current_conversion_preset () const
 
void set_conversion_preset (ConversionPreset id)
 
virtual void save_settings (QSettings &settings) const
 
virtual void restore_settings (QSettings &settings)
 
void start_conversion (bool delayed_start=false)
 

Static Public Attributes

static const QColor AnalogSignalColors [8]
 
static const QColor LogicSignalColors [10]
 

Protected Member Functions

virtual void set_error_message (QString msg)
 

Protected Attributes

shared_ptr< sigrok::Channel > channel_
 
ChannelType channel_type_
 
SignalGroupgroup_
 
shared_ptr< pv::data::SignalDatadata_
 
shared_ptr< pv::data::SignalDataconverted_data_
 
ConversionType conversion_type_
 
map< QString, QVariant > conversion_options_
 
float min_value_
 
float max_value_
 
std::thread conversion_thread_
 
atomic< bool > conversion_interrupt_
 
mutex conversion_input_mutex_
 
condition_variable conversion_input_cond_
 
QTimer delayed_conversion_starter_
 
QString internal_name_
 
QString name_
 
QColor color_
 
QColor bgcolor_
 
unsigned int index_
 
QString error_message_
 

Properties

QString error_message
 

Private Slots

void on_samples_cleared ()
 
void on_samples_added (SharedPtrToSegment segment, uint64_t start_sample, uint64_t end_sample)
 
void on_input_segment_completed ()
 
void on_min_max_changed (float min, float max)
 
void on_capture_state_changed (int state)
 
void on_delayed_conversion_start ()
 

Private Member Functions

void stop_conversion ()
 
bool conversion_is_a2l () const
 
uint8_t convert_a2l_threshold (float threshold, float value)
 
uint8_t convert_a2l_schmitt_trigger (float lo_thr, float hi_thr, float value, uint8_t &state)
 
void convert_single_segment_range (shared_ptr< AnalogSegment > asegment, shared_ptr< LogicSegment > lsegment, uint64_t start_sample, uint64_t end_sample)
 
void convert_single_segment (shared_ptr< AnalogSegment > asegment, shared_ptr< LogicSegment > lsegment)
 
void conversion_thread_proc ()
 

Static Private Attributes

static const int ColorBGAlpha = 8 * 256 / 100
 
static const uint64_t ConversionBlockSize = 4096
 
static const uint32_t ConversionDelay = 1000
 

Detailed Description

Definition at line 87 of file signalbase.hpp.

Member Enumeration Documentation

Enumerator
AnalogChannel 

Analog data.

LogicChannel 

Logic data.

DecodeChannel 

Protocol Decoder channel using libsigrokdecode.

MathChannel 

Virtual channel generated by math operations.

Definition at line 93 of file signalbase.hpp.

Conversion presets range from -1 to n, where 1..n are dependent on the conversion these presets apply to. -1 and 0 have fixed meanings, however.

Enumerator
NoPreset 

Conversion uses custom values.

DynamicPreset 

Conversion uses calculated values.

Definition at line 111 of file signalbase.hpp.

Enumerator
NoConversion 
A2LConversionByThreshold 
A2LConversionBySchmittTrigger 

Definition at line 100 of file signalbase.hpp.

Constructor & Destructor Documentation

pv::data::SignalBase::SignalBase ( shared_ptr< sigrok::Channel >  channel,
ChannelType  channel_type 
)

Definition at line 120 of file signalbase.cpp.

Here is the call graph for this function:

pv::data::SignalBase::~SignalBase ( )
virtual

Definition at line 148 of file signalbase.cpp.

Here is the call graph for this function:

Member Function Documentation

shared_ptr< data::Analog > pv::data::SignalBase::analog_data ( ) const

Get the internal data as analog data object in case of analog type.

Definition at line 309 of file signalbase.cpp.

Here is the caller graph for this function:

QColor pv::data::SignalBase::bgcolor ( ) const

Get the background color of the signal.

Definition at line 261 of file signalbase.cpp.

shared_ptr< sigrok::Channel > pv::data::SignalBase::channel ( ) const

Returns the underlying SR channel. Generated channels don't have a SR channel.

Definition at line 153 of file signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::clear_sample_data ( )

Clears all sample data and removes all associated segments.

Definition at line 300 of file signalbase.cpp.

Here is the call graph for this function:

QColor pv::data::SignalBase::color ( ) const

Get the color of the signal.

Definition at line 246 of file signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::color_changed ( const QColor &  color)
signal

Definition at line 378 of file moc_signalbase.cpp.

Here is the caller graph for this function:

bool pv::data::SignalBase::conversion_is_a2l ( ) const
private

Definition at line 626 of file signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::conversion_thread_proc ( )
private

Definition at line 771 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::conversion_type_changed ( const ConversionType  t)
signal

Definition at line 392 of file moc_signalbase.cpp.

Here is the caller graph for this function:

uint8_t pv::data::SignalBase::convert_a2l_schmitt_trigger ( float  lo_thr,
float  hi_thr,
float  value,
uint8_t &  state 
)
private
uint8_t pv::data::SignalBase::convert_a2l_threshold ( float  threshold,
float  value 
)
private
void pv::data::SignalBase::convert_single_segment ( shared_ptr< AnalogSegment asegment,
shared_ptr< LogicSegment lsegment 
)
private

Definition at line 735 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::convert_single_segment_range ( shared_ptr< AnalogSegment asegment,
shared_ptr< LogicSegment lsegment,
uint64_t  start_sample,
uint64_t  end_sample 
)
private

Definition at line 632 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

shared_ptr< pv::data::SignalData > pv::data::SignalBase::data ( ) const

Get the primary internal data object, i.e. the data that was acquired from the device.

Definition at line 333 of file signalbase.cpp.

Here is the caller graph for this function:

QString pv::data::SignalBase::display_name ( ) const

Produces a string for this signal that can be used for display, i.e. it contains one or both of the signal/internal names.

Definition at line 228 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool pv::data::SignalBase::enabled ( ) const

Returns enabled status of this channel.

Definition at line 164 of file signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::enabled_changed ( const bool &  value)
signal

Definition at line 364 of file moc_signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::error_message_changed ( QString  msg)
signal

Definition at line 385 of file moc_signalbase.cpp.

Here is the caller graph for this function:

map< QString, QVariant > pv::data::SignalBase::get_conversion_options ( ) const

Returns all currently known conversion options

Definition at line 433 of file signalbase.cpp.

vector< pair< QString, int > > pv::data::SignalBase::get_conversion_presets ( ) const

Provides all conversion presets available for the currently active conversion.

Returns
a list of description/ID pairs for each preset

Definition at line 519 of file signalbase.cpp.

vector< double > pv::data::SignalBase::get_conversion_thresholds ( const ConversionType  t = NoConversion,
const bool  always_custom = false 
) const

Returns the threshold(s) used for conversions, if applicable. The resulting thresholds are given for the chosen conversion, so you can query thresholds also for conversions which aren't currently active.

If you want the thresholds for the currently active conversion, call it either with NoConversion or no parameter.

Parameters
tthe type of conversion to obtain the thresholds for, leave empty or use NoConversion if you want to query the currently used conversion
always_customignore the currently selected preset and always return the custom values for this conversion, using 0 if those aren't set
Returns
a list of threshold(s) used by the chosen conversion

Definition at line 451 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

SignalBase::ConversionType pv::data::SignalBase::get_conversion_type ( ) const

Queries the kind of conversion performed on this channel.

Definition at line 404 of file signalbase.cpp.

SignalBase::ConversionPreset pv::data::SignalBase::get_current_conversion_preset ( ) const

Determines the ID of the currently used conversion preset, which is only valid for the currently available conversion presets. It is therefore suggested to call get_conversion_presets right before calling this.

Returns
the ID of the currently used conversion preset. -1 if no preset is used. In that case, a user setting is used instead.

Definition at line 544 of file signalbase.cpp.

Here is the caller graph for this function:

QString pv::data::SignalBase::get_error_message ( ) const
virtual

Returns the current error message text.

Definition at line 266 of file signalbase.cpp.

double pv::data::SignalBase::get_samplerate ( ) const
virtual

Returns the sample rate for this signal.

Reimplemented in pv::data::DecodeSignal.

Definition at line 389 of file signalbase.cpp.

Here is the call graph for this function:

SignalGroup * pv::data::SignalBase::group ( ) const

Returns the signal group this signal belongs to or nullptr if none

Definition at line 205 of file signalbase.cpp.

Here is the caller graph for this function:

bool pv::data::SignalBase::has_samples ( ) const

Determines whether this signal has any sample data at all.

Definition at line 367 of file signalbase.cpp.

Here is the call graph for this function:

unsigned int pv::data::SignalBase::index ( ) const

Gets the index number of this channel, i.e. a unique ID assigned by the device driver.

Definition at line 182 of file signalbase.cpp.

Here is the caller graph for this function:

QString pv::data::SignalBase::internal_name ( ) const

Gets the internal name of this signal, i.e. how the device/generator calls it.

Definition at line 215 of file signalbase.cpp.

Here is the caller graph for this function:

bool pv::data::SignalBase::is_generated ( ) const

Returns whether this channel is generated or a channel associated with the device.

Definition at line 158 of file signalbase.cpp.

unsigned int pv::data::SignalBase::logic_bit_index ( ) const

Returns which bit of a given sample for this signal represents the signal itself. This is relevant for compound signals like logic, rather meaningless for everything else but provided in case there is a conversion active that provides a digital signal using bit #0.

Definition at line 192 of file signalbase.cpp.

shared_ptr< data::Logic > pv::data::SignalBase::logic_data ( ) const

Get the internal data as logic data object in case of logic type.

Definition at line 317 of file signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::min_max_changed ( float  min,
float  max 
)
signal

Definition at line 412 of file moc_signalbase.cpp.

Here is the caller graph for this function:

QString pv::data::SignalBase::name ( ) const

Gets the name of this signal.

Definition at line 210 of file signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::name_changed ( const QString &  name)
signal

Definition at line 371 of file moc_signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::on_capture_state_changed ( int  state)
privateslot

Definition at line 929 of file signalbase.cpp.

Here is the call graph for this function:

void pv::data::SignalBase::on_delayed_conversion_start ( )
privateslot

Definition at line 938 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::on_input_segment_completed ( )
privateslot

Definition at line 910 of file signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::on_min_max_changed ( float  min,
float  max 
)
privateslot

Definition at line 919 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::on_samples_added ( SharedPtrToSegment  segment,
uint64_t  start_sample,
uint64_t  end_sample 
)
privateslot

Definition at line 893 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::on_samples_cleared ( )
privateslot

Definition at line 885 of file signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::restore_settings ( QSettings settings)
virtual

Reimplemented in pv::data::DecodeSignal, and pv::data::MathSignal.

Definition at line 581 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::samples_added ( uint64_t  segment_id,
uint64_t  start_sample,
uint64_t  end_sample 
)
signal

Definition at line 405 of file moc_signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::samples_cleared ( )
signal

Definition at line 399 of file moc_signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::save_settings ( QSettings settings) const
virtual

Reimplemented in pv::data::DecodeSignal, and pv::data::MathSignal.

Definition at line 565 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool pv::data::SignalBase::segment_is_complete ( uint32_t  segment_id) const

Determines whether a given segment is complete (i.e. end-of-frame has been seen). It only considers the original data, not the converted data.

Definition at line 338 of file signalbase.cpp.

Here is the call graph for this function:

void pv::data::SignalBase::set_color ( QColor  color)
virtual

Set the color of the signal.

Reimplemented in pv::data::DecodeSignal.

Definition at line 251 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool pv::data::SignalBase::set_conversion_option ( QString  key,
QVariant  value 
)

Sets the value of a particular conversion option Note: it is not checked whether the option is valid for the currently conversion. If it's not, it will be silently ignored.

Does not restart the conversion.

Returns
true if the value is different from before, false otherwise

Definition at line 438 of file signalbase.cpp.

void pv::data::SignalBase::set_conversion_preset ( ConversionPreset  id)

Sets the conversion preset to be used.

Does not restart the conversion.

Parameters
idthe id of the preset to use

Definition at line 553 of file signalbase.cpp.

void pv::data::SignalBase::set_conversion_type ( ConversionType  t)

Changes the kind of conversion performed on this channel.

Restarts the conversion.

Definition at line 409 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::set_data ( shared_ptr< pv::data::SignalData data)

Sets the internal data object.

Definition at line 271 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::set_enabled ( bool  value)

Sets the enabled status of this channel.

Parameters
valueBoolean value to set.

Definition at line 169 of file signalbase.cpp.

Here is the caller graph for this function:

void pv::data::SignalBase::set_error_message ( QString  msg)
protectedvirtual

Definition at line 867 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::set_group ( SignalGroup group)

Sets the signal group this signal belongs to

Definition at line 200 of file signalbase.cpp.

Here is the call graph for this function:

void pv::data::SignalBase::set_index ( unsigned int  index)

Sets the index number of this channel, i.e. a unique ID assigned by the device driver or the logic bit index (see below). Only use immediately after creating the signal and leave it untouched after.

Definition at line 187 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::set_internal_name ( QString  internal_name)

Sets the internal name of this signal, i.e. how the device/generator calls it. Only use immediately after creating the signal and leave it untouched after.

Definition at line 220 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::set_name ( QString  name)
virtual

Sets the name of the signal.

Reimplemented in pv::data::DecodeSignal.

Definition at line 236 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::start_conversion ( bool  delayed_start = false)

Definition at line 849 of file signalbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::data::SignalBase::stop_conversion ( )
private

Definition at line 876 of file signalbase.cpp.

Here is the caller graph for this function:

SignalBase::ChannelType pv::data::SignalBase::type ( ) const

Gets the type of this channel.

Definition at line 177 of file signalbase.cpp.

Here is the caller graph for this function:

Member Data Documentation

const QColor pv::data::SignalBase::AnalogSignalColors
static
Initial value:
=
{
QColor(0xC4, 0xA0, 0x00),
QColor(0x87, 0x20, 0x7A),
QColor(0x20, 0x4A, 0x87),
QColor(0x4E, 0x9A, 0x06),
QColor(0xBF, 0x6E, 0x00),
QColor(0x5E, 0x20, 0x80),
QColor(0x20, 0x80, 0x7A),
QColor(0x80, 0x20, 0x24)
}

Definition at line 116 of file signalbase.hpp.

QColor pv::data::SignalBase::bgcolor_
protected

Definition at line 423 of file signalbase.hpp.

shared_ptr<sigrok::Channel> pv::data::SignalBase::channel_
protected

Definition at line 406 of file signalbase.hpp.

ChannelType pv::data::SignalBase::channel_type_
protected

Definition at line 407 of file signalbase.hpp.

QColor pv::data::SignalBase::color_
protected

Definition at line 423 of file signalbase.hpp.

const int pv::data::SignalBase::ColorBGAlpha = 8 * 256 / 100
staticprivate

Definition at line 120 of file signalbase.hpp.

condition_variable pv::data::SignalBase::conversion_input_cond_
protected

Definition at line 419 of file signalbase.hpp.

mutex pv::data::SignalBase::conversion_input_mutex_
protected

Definition at line 418 of file signalbase.hpp.

atomic<bool> pv::data::SignalBase::conversion_interrupt_
protected

Definition at line 417 of file signalbase.hpp.

map<QString, QVariant> pv::data::SignalBase::conversion_options_
protected

Definition at line 412 of file signalbase.hpp.

std::thread pv::data::SignalBase::conversion_thread_
protected

Definition at line 416 of file signalbase.hpp.

ConversionType pv::data::SignalBase::conversion_type_
protected

Definition at line 411 of file signalbase.hpp.

const uint64_t pv::data::SignalBase::ConversionBlockSize = 4096
staticprivate

Definition at line 121 of file signalbase.hpp.

const uint32_t pv::data::SignalBase::ConversionDelay = 1000
staticprivate

Definition at line 122 of file signalbase.hpp.

shared_ptr<pv::data::SignalData> pv::data::SignalBase::converted_data_
protected

Definition at line 410 of file signalbase.hpp.

shared_ptr<pv::data::SignalData> pv::data::SignalBase::data_
protected

Definition at line 409 of file signalbase.hpp.

QTimer pv::data::SignalBase::delayed_conversion_starter_
protected

Definition at line 420 of file signalbase.hpp.

QString pv::data::SignalBase::error_message_
protected

Definition at line 426 of file signalbase.hpp.

SignalGroup* pv::data::SignalBase::group_
protected

Definition at line 408 of file signalbase.hpp.

unsigned int pv::data::SignalBase::index_
protected

Definition at line 424 of file signalbase.hpp.

QString pv::data::SignalBase::internal_name_
protected

Definition at line 422 of file signalbase.hpp.

const QColor pv::data::SignalBase::LogicSignalColors
static
Initial value:
=
{
QColor(0x16, 0x19, 0x1A),
QColor(0x8F, 0x52, 0x02),
QColor(0xCC, 0x00, 0x00),
QColor(0xF5, 0x79, 0x00),
QColor(0xED, 0xD4, 0x00),
QColor(0x73, 0xD2, 0x16),
QColor(0x34, 0x65, 0xA4),
QColor(0x75, 0x50, 0x7B),
QColor(0x88, 0x8A, 0x85),
QColor(0xEE, 0xEE, 0xEC),
}

Definition at line 117 of file signalbase.hpp.

float pv::data::SignalBase::max_value_
protected

Definition at line 414 of file signalbase.hpp.

float pv::data::SignalBase::min_value_
protected

Definition at line 414 of file signalbase.hpp.

QString pv::data::SignalBase::name_
protected

Definition at line 422 of file signalbase.hpp.

Property Documentation

QString pv::data::SignalBase::error_message
read

Definition at line 90 of file signalbase.hpp.


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