129 virtual void Name(
const std::string &name) = 0;
130 [[nodiscard]]
virtual std::string
Name()
const = 0;
149 virtual void Unit(
const std::string &unit) = 0;
163 [[nodiscard]]
virtual std::string
Unit()
const = 0;
169 [[nodiscard]]
virtual uint32_t
Flags()
const;
188 [[nodiscard]]
virtual uint8_t
Decimals()
const = 0;
196 virtual void Range(
double min,
double max);
199 [[nodiscard]]
virtual std::optional<std::pair<double, double>>
Range()
const;
202 virtual void Limit(
double min,
double max);
205 [[nodiscard]]
virtual std::optional<std::pair<double, double>>
Limit()
const;
211 [[nodiscard]]
virtual std::optional<std::pair<double, double>>
ExtLimit()
271 const std::string_view& name);
323 vlsd_record_id_ = record_id;
335 return vlsd_record_id_;
349 template <
typename T>
351 T &dest, uint64_t array_index = 0)
const;
368 template <
typename T>
370 uint64_t array_index = 0);
392 uint64_t &dest, uint64_t array_index = 0)
const;
400 std::string &dest)
const;
410 void SetTimestamp(
double timestamp, std::vector<uint8_t> &record_buffer)
const;
423 [[nodiscard]]
virtual uint32_t
BitCount()
const = 0;
479 template <
typename V>
483 value =
static_cast<V
>(sample);
494 template <
typename V = std::
string>
496 value = std::to_string(sample);
512 calculate_master_time_ = calculate_master;
520 return calculate_master_time_;
529 void ArraySize(uint64_t array_size) { channel_array_size_ = array_size;}
534 [[nodiscard]] uint64_t
ArraySize()
const {
return channel_array_size_;}
541 uint64_t array_index)
const;
545 uint64_t array_index)
const;
549 std::vector<uint8_t> &dest)
const;
553 uint64_t &dest)
const;
557 uint64_t &dest)
const;
563 virtual void SetValid(
bool valid, uint64_t array_index);
566 virtual bool GetValid(
const std::vector<uint8_t> &record_buffer,
567 uint64_t array_index)
const;
584 virtual void SetByteArray(
const std::vector<uint8_t> &value,
bool valid);
589 mutable uint64_t vlsd_record_id_ = 0;
590 bool calculate_master_time_ =
true;
591 uint64_t channel_array_size_ = 1;
596 T &dest, uint64_t array_index)
const {
604 dest =
static_cast<T
>(value);
612 dest =
static_cast<T
>(value);
619 dest =
static_cast<T
>(value);
629 std::istringstream data(text);
637 std::vector<uint8_t> list;
639 dest = list.empty() ? T{} : list[0];
644 uint64_t ms_since_1970 = 0;
646 dest =
static_cast<T
>(ms_since_1970);
651 uint64_t ms_since_1970 = 0;
653 dest =
static_cast<T
>(ms_since_1970);
660 valid =
GetValid(record_buffer, array_index);
668 std::vector<uint8_t> &dest, uint64_t array_index)
const;
673 std::string &dest, uint64_t array_index)
const;
677 uint64_t array_index ) {
717 if (
typeid(T) ==
typeid(uint64_t) &&
DataBytes() == 7) {
718 const auto date_array =
727 if (
typeid(T) ==
typeid(uint64_t) &&
DataBytes() == 6) {
728 const auto time_array =
745 uint64_t array_index);
750 uint64_t array_index);
755 const auto array_size = array !=
nullptr ?
756 array->NofArrayValues() : 1;
758 for (
const T& value : values) {
759 if (index < array_size) {
Interface against an attached file.
Definition iattachment.h:21
Base class for all MDF blocks.
Definition iblock.h:19
Defines an interface against an array (CA) block.
Definition ichannelarray.h:74
Defines a channel conversion (CC) block.
Definition ichannelconversion.h:142
virtual void Type(ConversionType type)=0
Sets the conversion type.
Interface against a channel group (CG) block.
Definition ichannelgroup.h:66
Defines a MDF channel (CN) block.
Definition ichannel.h:126
virtual void Range(double min, double max)
Sets the ranges.
virtual std::optional< std::pair< double, double > > Limit() const
Returns the limits.
void SetChannelValue(const T &value, bool valid=true, uint64_t array_index=0)
Sets a channel value.
Definition ichannel.h:676
virtual const IChannelGroup * ChannelGroup() const =0
Support function that returns its channel group.
virtual IChannelArray * ChannelArray() const
Returns the channel array object if any exist in this channel.
void ArraySize(uint64_t array_size)
Sets the array size for the channel.
Definition ichannel.h:529
virtual std::string Description() const =0
Returns the description.
virtual double SamplingRate() const =0
Returns the sample rate (s). This is a MDF 3 feature.
void CalculateMasterTime(bool calculate_master)
Defines if the master channel time should be calculated or not.
Definition ichannel.h:511
virtual void SetByteArray(const std::vector< uint8_t > &value, bool valid)
Support function that sets array values.
virtual ISourceInformation * SourceInformation() const
Returns the source information, if any.
uint64_t RecordId() const
Returns th channel group (CG) record ID.
virtual ISourceInformation * CreateSourceInformation()
Creates a source information block.
virtual bool IsDecimalUsed() const =0
Returns true if decimals is used
virtual std::vector< const IAttachment * > AttachmentList() const
Returns a list of attachment pointers.
virtual bool GetTextValue(const std::vector< uint8_t > &record_buffer, std::string &dest) const
Internally used function mainly for fetching VLSD text values.
void SetUnsignedValueLe(uint64_t value, bool valid, uint64_t array_index)
Support function that sets unsigned little endian values.
void SetTimestamp(double timestamp, std::vector< uint8_t > &record_buffer) const
The function change the supplied records time channel value.
uint64_t VlsdRecordId() const
Returns the VLSD record id.
Definition ichannel.h:334
virtual void Unit(const std::string &unit)=0
Sets unit string or or the MIME text string.
bool GetUnsignedValue(const std::vector< uint8_t > &record_buffer, uint64_t &dest, uint64_t array_index=0) const
Internally used function mainly for fetching VLSD index values.
virtual uint32_t ByteOffset() const =0
Returns the byte offset to data in the record.
static bool GetVirtualSample(uint64_t sample, std::string &value)
Specialization that returns virtual sample values.
Definition ichannel.h:495
virtual void Type(ChannelType type)=0
Sets the type of channel.
virtual void SamplingRate(double sampling_rate)=0
Sets the sample rate (s). This is a MDF 3 feature.
virtual void Sync(ChannelSyncType type)
Sets the type of sync.
virtual uint32_t BitCount() const =0
Returns the data size in number of bits.
virtual uint64_t DataBytes() const =0
Data size (bytes);.
virtual ChannelType Type() const =0
Type of channel.
virtual void ByteOffset(uint32_t bytes)=0
Sets the byte offset in record to to data.
virtual void Flags(uint32_t flags)
Sets channel flags. Flags are defined in the CnFlag namespace
virtual IChannelConversion * CreateChannelConversion()=0
Creates a conversion block.
virtual IMetaData * MetaData() const
Returns the meta-data (MD) block if it exist.
virtual std::vector< uint8_t > & SampleBuffer() const =0
Support function that gets the channel group sample buffer.
virtual std::string Name() const =0
Returns channel name.
virtual IMetaData * CreateMetaData()
Creates a metadata (MD) block.
virtual std::vector< IChannel * > ChannelCompositions()=0
Creates a composition channel.
bool GetCanOpenDate(const std::vector< uint8_t > &record_buffer, uint64_t &dest) const
Support function that get CANOpen date values from a record.
void SetFloatValueBe(double value, bool valid, uint64_t array_index)
Support function that sets float big endian values.
void SetSignedValueBe(int64_t value, bool valid, uint64_t array_index)
Support function that sets signed big endian values.
virtual void DataBytes(uint64_t nof_bytes)=0
Sets the data size (bytes)
virtual void SetTextValue(const std::string &value, bool valid)
Support function that sets text values.
virtual IChannel * CreateChannelComposition(const std::string_view &name)
Creates a composition channel with a specific name or returns an existing channel.
virtual std::optional< std::pair< double, double > > Range() const
Returns the ranges.
virtual IChannelArray * CreateChannelArray()
Create or returns an existing channel array (CA) block.
virtual void Description(const std::string &description)=0
Sets the description.
virtual uint8_t Decimals() const =0
Number of decimals (floating points)
virtual void BitCount(uint32_t bits)=0
Sets the size of data in bits.
virtual ChannelDataType DataType() const =0
Data type.
virtual void SetValid(bool valid, uint64_t array_index)
Support function that sets the valid flag.
void SetFloatValueLe(double value, bool valid, uint64_t array_index)
Support function that sets float little endian values.
void SetUnsignedValueBe(uint64_t value, bool valid, uint64_t array_index)
Support function that sets unsigned big endian values.
bool GetFloatValue(const std::vector< uint8_t > &record_buffer, double &dest, uint64_t array_index) const
Support function that get float values from a record.
bool GetCanOpenTime(const std::vector< uint8_t > &record_buffer, uint64_t &dest) const
Support function that get CANOpen time values from a record.
bool GetSignedValue(const std::vector< uint8_t > &record_buffer, int64_t &dest, uint64_t array_index) const
Support function that get signed integer from a record.
virtual void BitOffset(uint16_t bits)=0
Sets the offset to data in bits.
virtual std::string DisplayName() const =0
Display name.
bool IsNumber() const
Returns true if the channel is a number.
Definition ichannel.h:281
virtual uint16_t BitOffset() const =0
Returns offset to data (0..7).
virtual bool GetValid(const std::vector< uint8_t > &record_buffer, uint64_t array_index) const
Support function that return true if the valid bit is set.
virtual void AddAttachmentReference(const IAttachment *attachment)
Adds an attachment reference to the channel.
virtual void Limit(double min, double max)
Sets the limits.
virtual std::string Unit() const =0
Returns the unit string or the MIME content type string.
uint64_t ArraySize() const
Returns 1 if no array and > 1 if it is an array.
Definition ichannel.h:534
virtual bool IsUnitValid() const =0
True if unit exists.
virtual bool GetByteArrayValue(const std::vector< uint8_t > &record_buffer, std::vector< uint8_t > &dest) const
Support function that get array values from a record.
void SetSignedValueLe(int64_t value, bool valid, uint64_t array_index)
Support function that sets signed little endian values.
virtual IChannelConversion * ChannelConversion() const =0
Returns the conversion block, if any.
virtual void DataType(ChannelDataType type)=0
Sets the data type.
virtual void Name(const std::string &name)=0
Sets channel name.
virtual IChannel * CreateChannelComposition()=0
Creates a composition channel.
void SetChannelValues(const std::vector< T > &values)
Sets channel array values.
Definition ichannel.h:753
static bool GetVirtualSample(uint64_t sample, V &value)
Returns the value for a virtual sample.
Definition ichannel.h:480
virtual void Decimals(uint8_t precision)
Sets number of decimals (floating points only)
virtual ChannelSyncType Sync() const
Type of sync.
void VlsdRecordId(uint64_t record_id) const
Sets the VLSD record id.
Definition ichannel.h:322
virtual void DisplayName(const std::string &name)=0
Sets display name.
bool GetChannelValue(const std::vector< uint8_t > &record_buffer, T &dest, uint64_t array_index=0) const
Parse out the channel value from a data record.
Definition ichannel.h:595
virtual std::optional< std::pair< double, double > > ExtLimit() const
Returns the extended limits.
virtual void ExtLimit(double min, double max)
Sets the extended limits.
bool CalculateMasterTime() const
Defines if the master channel time is calculated or user defined.
Definition ichannel.h:519
virtual uint32_t Flags() const
Channel flags are defined in the CnFlag namespace
static std::vector< uint8_t > NsToCanOpenTimeArray(uint64_t ns_since_1970)
Converts from nanoseconds to CANopen 6 byte Time array.
static std::vector< uint8_t > NsToCanOpenDateArray(uint64_t ns_since_1970)
Converts from nanoseconds to CANopen 7 byte Date array.
Interface against an attached file.
All MDF blocks inherits from the IBlock class. The interface class is used internally in lists....
Defines a channel array (CA) block.
Defines a channel conversion (CC) block.
Support class for the MDF library.
constexpr uint32_t LimitValid
Limit is used.
Definition ichannel.h:110
constexpr uint32_t Discrete
Discrete channel.
Definition ichannel.h:112
constexpr uint32_t BusEvent
Bus event channel.
Definition ichannel.h:116
constexpr uint32_t PrecisionValid
Precision is used.
Definition ichannel.h:108
constexpr uint32_t Calibration
Calibrated channel.
Definition ichannel.h:113
constexpr uint32_t StrictlyMonotonous
Strict monotonously.
Definition ichannel.h:117
constexpr uint32_t Virtual
Virtual channel.
Definition ichannel.h:115
constexpr uint32_t Calculated
Calculated channel.
Definition ichannel.h:114
constexpr uint32_t DefaultX
Default x-axis channel.
Definition ichannel.h:118
constexpr uint32_t VlsdDataStream
VLSD data stream channel.
Definition ichannel.h:120
constexpr uint32_t ExtendedLimitValid
Extended limit is used.
Definition ichannel.h:111
constexpr uint32_t RangeValid
Range is used.
Definition ichannel.h:109
constexpr uint32_t AllValuesInvalid
All values are invalid.
Definition ichannel.h:106
constexpr uint32_t InvalidValid
Invalid bit is used.
Definition ichannel.h:107
constexpr uint32_t EventSignal
Event signal.
Definition ichannel.h:119
Main namespace for the MDF library.
Definition canmessage.h:17
std::vector< uint8_t > ByteArray
Defines a dynamic byte array.
Definition zlibutil.h:17
ChannelSyncType
Synchronization type.
Definition ichannel.h:66
@ None
No synchronization (default value)
@ ValueRangeToValue
Value range to value conversion without interpolation. Defined by a list of Key min/max value triplet...
ChannelType
Channel functional type.
Definition ichannel.h:51
@ VirtualMaster
Virtual master channel.
@ FixedLength
Fixed length data (default type)
@ MaxLength
Max length channel.
@ VirtualData
Virtual data channel.
@ VariableLength
Variable length data.
@ Sync
Synchronize channel.
ChannelDataType
Channel data type.
Definition ichannel.h:82
@ StringUTF16Le
Text, UTF16 coded little endian.
@ StringUTF8
Text, UTF8 coded.
@ CanOpenDate
7-byte CANOpen date.
@ SignedIntegerBe
Signed integer, big endian.
@ UnsignedIntegerLe
Unsigned integer, little endian.
@ ComplexBe
Complex value, big endian.
@ StringUTF16Be
Text, UTF16 coded big endian.
@ FloatLe
Float, little endian.
@ MimeSample
MIME sample byte array.
@ StringAscii
Text, ISO-8859-1 coded.
@ FloatBe
Float, big endian.
@ SignedIntegerLe
Signed integer, little endian.
@ ComplexLe
Complex value, little endian.
@ CanOpenTime
6-byte CANOpen time.
@ UnsignedIntegerBe
Unsigned integer, big endian.
@ MimeStream
MIME stream byte array.