35 virtual bool GetSampleSigned(uint64_t sample, int64_t& value, uint64_t array_index)
37 virtual bool GetSampleFloat(uint64_t sample,
double& value, uint64_t array_index)
39 virtual bool GetSampleText(uint64_t sample, std::string& value, uint64_t array_index)
58 [[nodiscard]] std::string
Name()
const;
60 [[nodiscard]] std::string
Unit()
const;
82 [[nodiscard]] std::vector<uint64_t>
Shape()
const;
117 template <
typename V>
118 bool GetChannelValue(uint64_t sample, V& value, uint64_t array_index = 0 )
const;
148 std::vector<V>& values)
const;
159 template <
typename V>
160 bool GetEngValue(uint64_t sample, V& value, uint64_t array_index = 0)
const;
172 std::vector<bool>
GetEngSamples(std::vector<V>& values)
const;
187 std::vector<bool>
GetEngValues(uint64_t sample, std::vector<V>& values)
const;
228 value =
static_cast<V
>(v);
236 value =
static_cast<V
>(v);
244 value =
static_cast<V
>(v);
252 value =
static_cast<V
>(v);
262 std::istringstream s(v);
270 std::vector<uint8_t> v;
272 value =
static_cast<V
>(v.empty() ? V{} : v[0]);
285 std::string& value, uint64_t array_index)
const;
290 std::vector<uint8_t>& value, uint64_t array_index)
const;
294 std::vector<V>& values)
const {
296 std::vector<bool> valid_array(nof_samples,
false);
297 values.resize(nof_samples, {});
299 for (
auto& value : values) {
308 std::vector<V>& values)
const {
310 std::vector<bool> valid_array(array_size,
false);
311 values.resize(array_size, {});
313 for (
auto& value : values) {
323 if (conversion ==
nullptr) {
334 && conversion->Convert(v, value);
342 && conversion->Convert(v, value);
350 && conversion->Convert(v, value);
361 conversion->Convert(v, temp);
362 std::istringstream temp1(temp);
377 std::vector<uint8_t>& value,
378 uint64_t array_index)
const;
381 std::vector<V>& values)
const {
383 std::vector<bool> valid_array(nof_samples,
false);
384 values.resize(nof_samples, {});
386 for (
auto& value : values) {
387 valid_array[sample] =
GetEngValue(sample, value, 0);
395 std::vector<V>& values)
const {
397 std::vector<bool> valid_array(array_size,
false);
398 values.resize(array_size, {});
400 for (
auto& value : values) {
401 valid_array[index] =
GetEngValue(sample, value, index);
Defines a MDF channel (CN) block.
Definition ichannel.h:126
virtual IChannelConversion * ChannelConversion() const =0
Returns the conversion block, if any.
virtual void DataType(ChannelDataType type)=0
Sets the data type.
The channel observer object shall hold all samples for a channel.
Definition ichannelobserver.h:25
const std::vector< bool > & GetValidList() const
Returns the sample to valid list.
Definition ichannelobserver.h:212
std::vector< bool > valid_list_
List of valid samples.
Definition ichannelobserver.h:31
bool IsArray() const
True if this channel is an array channel.
const IChannel & channel_
Reference to the channel (CN) block.
Definition ichannelobserver.h:27
virtual bool GetSampleFloat(uint64_t sample, double &value, uint64_t array_index) const =0
Returns a float sample value.
virtual bool GetSampleUnsigned(uint64_t sample, uint64_t &value, uint64_t array_index) const =0
Returns a unsigned sample value.
const IChannel & Channel() const
Returns the channel object.
bool GetEngValue(uint64_t sample, V &value, uint64_t array_index=0) const
Returns the engineering value for a specific value.
Definition ichannelobserver.h:321
std::string Name() const
Channel name.
virtual bool GetSampleText(uint64_t sample, std::string &value, uint64_t array_index) const =0
Returns a string sample value.
bool GetChannelValue(uint64_t sample, V &value, uint64_t array_index=0) const
Returns the channel value for a sample.
Definition ichannelobserver.h:219
~IChannelObserver() override=default
Default destructor.
bool IsMaster() const
True if this is the master channel.
virtual bool GetSampleByteArray(uint64_t sample, std::vector< uint8_t > &value) const =0
Returns a byte array sample value.
virtual bool GetSampleSigned(uint64_t sample, int64_t &value, uint64_t array_index) const =0
Returns a signed sample value.
IChannelObserver(const IDataGroup &dataGroup, const IChannel &channel)
Constructor.
std::string EngValueToString(uint64_t sample) const
Support function that convert a sample value to a user friendly string.
std::string Unit() const
Channel unit.
void ReadVlsdData(bool read_vlsd_data)
Property interface that defines if the VLSD raw data should be read or not.
bool ReadVlsdData() const
Returns the read VLSD bytes property.
Definition ichannelobserver.h:98
std::vector< bool > GetEngSamples(std::vector< V > &values) const
Simple function that returns all scaled samples.
Definition ichannelobserver.h:380
const std::vector< uint64_t > & GetOffsetList() const
Returns the sample to VLSD offset list.
Definition ichannelobserver.h:207
bool read_vlsd_data_
Defines if the VLSD bytes should be read.
Definition ichannelobserver.h:28
std::vector< uint64_t > Shape() const
Returns a shape vector that describes an array dimension.
virtual uint64_t NofSamples() const =0
Returns number of samples.
std::vector< bool > GetChannelSamples(std::vector< V > &values) const
Simple function that returns all non-scaled samples.
Definition ichannelobserver.h:293
std::vector< bool > GetEngValues(uint64_t sample, std::vector< V > &values) const
Returns a vector of array values for a specific sample.
Definition ichannelobserver.h:394
std::vector< uint64_t > offset_list_
Only used for VLSD channels.
Definition ichannelobserver.h:30
uint64_t ArraySize() const
If this is an array channel, this function returns the array size.
std::vector< bool > GetChannelValues(uint64_t sample, std::vector< V > &values) const
Returns a vector of array channel values for a specific sample.
Definition ichannelobserver.h:307
Interface to a data group (DG) block.
Definition idatagroup.h:42
Interface to a sample observer that handle incoming samples events.
Definition isampleobserver.h:23
The define an interface against a channel block (CN).
Interface class to a sample observer. This class is used internally.
Support class for the MDF library.
Main namespace for the MDF library.
Definition canmessage.h:17
@ 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.
@ 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.
@ CanOpenTime
6-byte CANOpen time.
@ UnsignedIntegerBe
Unsigned integer, big endian.
@ MimeStream
MIME stream byte array.