MDF Lib 2.2
Interface against MDF 3/4 files
Loading...
Searching...
No Matches
mdf::IChannelConversion Class Referenceabstract

Defines a channel conversion (CC) block. More...

#include <ichannelconversion.h>

Inheritance diagram for mdf::IChannelConversion:
Collaboration diagram for mdf::IChannelConversion:

Public Member Functions

virtual void Name (const std::string &name)
 Sets the CC name.
 
virtual std::string Name () const
 Name.
 
virtual void Description (const std::string &desc)
 Sets the description.
 
virtual std::string Description () const
 Description.
 
virtual void Unit (const std::string &unit)=0
 Sets the unit.
 
virtual std::string Unit () const =0
 Unit of measure.
 
virtual bool IsUnitValid () const =0
 True if unit exist.
 
virtual void Type (ConversionType type)=0
 Sets the conversion type.
 
virtual ConversionType Type () const =0
 Conversion type.
 
virtual bool IsDecimalUsed () const =0
 True if decimal is used.
 
virtual void Decimals (uint8_t decimals)
 Sets number of decimals.
 
virtual uint8_t Decimals () const =0
 Number of decimals.
 
virtual IChannelConversionCreateInverse ()
 Creates an inverse conversion block.
 
virtual IChannelConversionInverse () const
 Returns the inverse conversion block. Seldom in use.
 
virtual void Range (double min, double max)
 Sets the range.
 
virtual std::optional< std::pair< double, double > > Range () const
 Returns the range if exist.
 
virtual void Flags (uint16_t flags)
 Sets the CcFlag.
 
virtual uint16_t Flags () const
 Returns CcFlag.
 
virtual IMetaDataCreateMetaData ()
 Creates a meta-data (MD) block.
 
virtual IMetaDataMetaData () const
 Returns the meta-data block.
 
virtual void Formula (const std::string &formula)
 Sets the formula string.
 
virtual const std::string & Formula () const
 Returns formula string.
 
uint16_t NofParameters () const
 Returns number of parameters in the block.
 
void Parameter (uint16_t index, double parameter)
 Sets a floating point parameter value.
 
double Parameter (uint16_t index) const
 Returns the parameter (double)
 
uint64_t ParameterUint (uint16_t index) const
 Returns the parameter as a bit field (uint64_t)
 
void ParameterUint (uint16_t index, uint64_t parameter)
 Sets an unsigned integer parameter value.
 
virtual uint16_t NofReferences () const
 Number of references in the block.
 
virtual void Reference (uint16_t index, const std::string &text)
 Sets text reference (TX) block.
 
virtual std::string Reference (uint16_t index) const
 Returns the reference string by its index.
 
void ChannelDataType (uint8_t channel_data_type)
 Sets the CN block data type.
 
template<typename T , typename V >
bool Convert (const T &channel_value, V &eng_value) const
 Converts a channel value to an engineering (scaled) value.
 
template<typename T , typename V = std::string>
bool Convert (const T &channel_value, std::string &eng_value) const
 Converts a channel value to an engineering string value.
 
template<typename T = std::string, typename V = double>
bool Convert (const std::string &channel_value, double &eng_value) const
 Convert from string to double with full precision.
 
template<typename T = std::string, typename V = std::string>
bool Convert (const std::string &channel_value, std::string &eng_value) const
 Converts from string to string.
 
- Public Member Functions inherited from mdf::IBlock
virtual ~IBlock ()=default
 Default destructor.
 
virtual int64_t Index () const =0
 File position within the file.
 
virtual std::string BlockType () const =0
 Returns the block type.
 

Protected Types

using ParameterList = std::vector<std::variant<uint64_t, double>>
 List of floating point constants.
 

Protected Member Functions

bool IsChannelInteger () const
 Returns true if channel is an integer.
 
bool IsChannelFloat () const
 Returns true if the channel is a float.
 
virtual bool ConvertLinear (double channel_value, double &eng_value) const
 Linear conversion.
 
virtual bool ConvertRational (double channel_value, double &eng_value) const
 Rational conversion.
 
virtual bool ConvertAlgebraic (double channel_value, double &eng_value) const
 Algebraic conversion.
 
virtual bool ConvertValueToValueInterpolate (double channel_value, double &eng_value) const
 Value to value interpolation conversion.
 
virtual bool ConvertValueToValue (double channel_value, double &eng_value) const
 Value to value conversion.
 
virtual bool ConvertValueRangeToValue (double channel_value, double &eng_value) const
 Value range to value conversion.
 
virtual bool ConvertValueToText (double channel_value, std::string &eng_value) const
 Value to text conversion.
 
virtual bool ConvertValueRangeToText (double channel_value, std::string &eng_value) const
 Value range to text value.
 
virtual bool ConvertTextToValue (const std::string &channel_value, double &eng_value) const
 Text to value conversion.
 
virtual bool ConvertTextToTranslation (const std::string &channel_value, std::string &eng_value) const
 Text to text conversion.
 
virtual bool ConvertPolynomial (double channel_value, double &eng_value) const
 Polynomial conversion (MDF3).
 
virtual bool ConvertLogarithmic (double channel_value, double &eng_value) const
 Logarithmic conversion (MDF3).
 
virtual bool ConvertExponential (double channel_value, double &eng_value) const
 Exponential conversion (MDF3).
 

Protected Attributes

uint16_t nof_values_ = 0
 Number of parameter values (MDF3).
 
ParameterList value_list_
 List of parameters.
 
uint8_t channel_data_type_
 The channels data type. Needed by some conversions.
 
std::string formula_
 Formula string (MDF3).
 
std::vector< TextConversiontext_conversion_list_
 MDF3.
 
std::vector< TextRangeConversiontext_range_conversion_list_
 MDF3.
 

Detailed Description

The channel conversion (CC) block shall convert the channel value to an engineering value. If the CN block doesn't reference any CC block, the engineer and channel values are identical.

Depending on the type of conversion (ConversionType), none or more parameters (Parameter()) and none or more text string (Reference()) are used to define the conversion. Check description in ConversionType.

Member Function Documentation

◆ ChannelDataType()

void mdf::IChannelConversion::ChannelDataType ( uint8_t channel_data_type)

Some of the conversion methods need to know the CN channels data type.

Parameters
channel_data_typeChannel data type.

◆ Convert() [1/2]

template<typename T , typename V >
bool mdf::IChannelConversion::Convert ( const T & channel_value,
std::string & eng_value ) const
inline

Converts a channel value to an scaled value converted to a string. This function is typical used when presenting data in GUI.

Template Parameters
TChannel data type
VString type.
Parameters
channel_valueThe channel value.
eng_valueThe output string.
Returns
True if the conversion is valid.

◆ Convert() [2/2]

template<typename T , typename V >
bool mdf::IChannelConversion::Convert ( const T & channel_value,
V & eng_value ) const
inline

Converts the channel value to a scaled value.

Template Parameters
TChannel data type.
VEngineering value data type.
Parameters
channel_valueThe channel value.
eng_valueThe scaled engineering value.
Returns
True if the conversion is valid.

◆ Parameter() [1/2]

double mdf::IChannelConversion::Parameter ( uint16_t index) const
nodiscard
Parameters
index
Returns
Parameter floating point value

◆ Parameter() [2/2]

void mdf::IChannelConversion::Parameter ( uint16_t index,
double parameter )
Parameters
indexParameter index to set.
parameterValue to set.

◆ ParameterUint() [1/2]

uint64_t mdf::IChannelConversion::ParameterUint ( uint16_t index) const
nodiscard
Parameters
index
Returns
Parameter floating point value

◆ ParameterUint() [2/2]

void mdf::IChannelConversion::ParameterUint ( uint16_t index,
uint64_t parameter )
Parameters
indexParameter index to set.
parameterValue to set.

◆ Reference()

virtual void mdf::IChannelConversion::Reference ( uint16_t index,
const std::string & text )
virtual
Parameters
indexIndex of the text block (TX).
textText content of the TX block.

Member Data Documentation

◆ channel_data_type_

uint8_t mdf::IChannelConversion::channel_data_type_
protected
Initial value:
=
0

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