MDF Lib 2.2
Interface against MDF 3/4 files
Loading...
Searching...
No Matches
ichannelarray.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Ingemar Hedvall
3 * SPDX-License-Identifier: MIT
4 */
5
15#pragma once
16#include <cstdint>
17#include <vector>
18#include <optional>
19#include "mdf/iblock.h"
20
21namespace mdf {
22
23class IChannel;
24class IChannelConversion;
25class IChannelGroup;
26class IDataGroup;
27
31enum class ArrayType : uint8_t {
32 Array = 0,
33 ScalingAxis = 1,
34 LookUp = 2,
35 IntervalAxis = 3,
37};
38
40enum class ArrayStorage : uint8_t {
41 CnTemplate = 0,
42 CgTemplate = 1,
43 DgTemplate = 2
44};
45
47namespace CaFlag {
48constexpr uint32_t DynamicSize = 0x0001;
49constexpr uint32_t InputQuantity = 0x0002;
50constexpr uint32_t OutputQuantity = 0x0004;
51constexpr uint32_t ComparisonQuantity = 0x0008;
52constexpr uint32_t Axis = 0x0010;
53constexpr uint32_t FixedAxis = 0x0020;
54constexpr uint32_t InverseLayout = 0x0040;
55constexpr uint32_t LeftOpenInterval = 0x0080;
56constexpr uint32_t StandardAxis = 0x0100;
57} // namespace CaFlag
58
61 const mdf::IDataGroup* DataGroup = nullptr;
63 const mdf::IChannel* Channel = nullptr;
64};
65
66
74class IChannelArray : public IBlock {
75 public:
76
77 virtual void Type(ArrayType type) = 0;
78 [[nodiscard]] virtual ArrayType Type() const = 0;
79
80 virtual void Storage(ArrayStorage storage) = 0;
81 [[nodiscard]] virtual ArrayStorage Storage() const = 0;
82
83 virtual void Flags(uint32_t flags) = 0;
84 [[nodiscard]] virtual uint32_t Flags() const = 0;
85
86 [[nodiscard]] virtual size_t Dimensions() const = 0;
87
93 virtual void Shape(const std::vector<uint64_t>& dim_sizes) = 0;
94
99 [[nodiscard]] virtual const std::vector<uint64_t>& Shape() const = 0;
100
102 [[nodiscard]] virtual uint64_t DimensionSize(size_t dimension) const = 0;
103
105 [[nodiscard]] virtual const std::vector<double>& AxisValues() const = 0;
106
108 [[nodiscard]] virtual std::vector<double>& AxisValues() = 0;
109
111 [[nodiscard]] virtual const std::vector<uint64_t>& CycleCounts() const = 0;
112
114 [[nodiscard]] virtual std::vector<uint64_t>& CycleCounts() = 0;
115
120 [[nodiscard]] uint64_t NofArrayValues() const;
121
126 [[nodiscard]] std::string DimensionAsString() const;
127
137 virtual void ResizeArrays();
138
140 [[nodiscard]] const std::vector<int64_t>& DataLinks() const {
141 return data_links_;
142 }
144 [[nodiscard]] std::vector<int64_t>& DataLinks();
145
147 [[nodiscard]] const std::vector<CaTripleReference>& DynamicSizeList() const {
148 return dynamic_size_list_;
149 }
151 [[nodiscard]] std::vector<CaTripleReference>& DynamicSizeList();
152
154 [[nodiscard]] const std::vector<CaTripleReference>& InputQuantityList() const {
156 }
158 [[nodiscard]] std::vector<CaTripleReference>& InputQuantityList();
159
161 [[nodiscard]] const CaTripleReference& OutputQuantity() const {
162 return output_quantity_;
163 }
166 return output_quantity_;
167 }
168
170 [[nodiscard]] const CaTripleReference& ComparisonQuantity() const {
172 }
176 }
177
179 [[nodiscard]] const std::vector<const IChannelConversion*>& AxisConversionList() const {
181 }
183 [[nodiscard]] std::vector<const IChannelConversion*>& AxisConversionList();
184
186 [[nodiscard]] const std::vector<CaTripleReference>& AxisList() const {
187 return axis_list_;
188 }
190 [[nodiscard]] std::vector<CaTripleReference>& AxisList();
191
198 [[nodiscard]] virtual uint64_t SumOfArray() const = 0;
199
206 [[nodiscard]] virtual uint64_t ProductOfArray() const = 0;
207 protected:
208 std::vector<int64_t> data_links_;
209 std::vector<CaTripleReference> dynamic_size_list_;
210 std::vector<CaTripleReference> input_quantity_list_;
213 std::vector<const IChannelConversion*> axis_conversion_list_;
214 std::vector<CaTripleReference> axis_list_;
215
216
217};
218
219} // namespace mdf
Base class for all MDF blocks.
Definition iblock.h:19
Defines an interface against an array (CA) block.
Definition ichannelarray.h:74
const CaTripleReference & OutputQuantity() const
Returns the output quantity reference if it exist.
Definition ichannelarray.h:161
virtual void Flags(uint32_t flags)=0
Flags.
std::string DimensionAsString() const
Returns the array dimensions as string ("N[2][3]")
virtual std::vector< uint64_t > & CycleCounts()=0
Returns a list of cycle counts.
CaTripleReference & OutputQuantity()
Returns the output quantity reference if it exist.
Definition ichannelarray.h:165
virtual void Shape(const std::vector< uint64_t > &dim_sizes)=0
Sets the dimension and each dimension size.
uint64_t NofArrayValues() const
Returns the number of values in the array.
virtual uint64_t ProductOfArray() const =0
Calculates the product of array dimension sizes.
std::vector< CaTripleReference > dynamic_size_list_
Dynamic size list.
Definition ichannelarray.h:209
std::vector< CaTripleReference > axis_list_
Axis list.
Definition ichannelarray.h:214
virtual const std::vector< uint64_t > & CycleCounts() const =0
Returns a list of cycle counts.
virtual void ResizeArrays()
Converts the array link indexes into pointers.
CaTripleReference comparison_quantity_
Comparison quantity list.
Definition ichannelarray.h:212
std::vector< int64_t > data_links_
List of index to data blocks.
Definition ichannelarray.h:208
virtual void Type(ArrayType type)=0
Sets the type of array..
CaTripleReference output_quantity_
Output quantity list.
Definition ichannelarray.h:211
const std::vector< const IChannelConversion * > & AxisConversionList() const
Returns the axis conversion list.
Definition ichannelarray.h:179
virtual size_t Dimensions() const =0
Number of dimensions.
std::vector< CaTripleReference > & InputQuantityList()
Returns the input quantity list.
std::vector< CaTripleReference > & AxisList()
Returns the axis list.
virtual ArrayStorage Storage() const =0
Storage type.
virtual void Storage(ArrayStorage storage)=0
Storage type.
const std::vector< CaTripleReference > & AxisList() const
Returns the axis list.
Definition ichannelarray.h:186
CaTripleReference & ComparisonQuantity()
Returns the comparison quantity list.
Definition ichannelarray.h:174
const std::vector< CaTripleReference > & InputQuantityList() const
Returns the input quantity list.
Definition ichannelarray.h:154
virtual const std::vector< double > & AxisValues() const =0
Returns the fixed axis value list for reading only.
std::vector< const IChannelConversion * > & AxisConversionList()
Returns the axis conversion list.
std::vector< int64_t > & DataLinks()
Returns a list of data kink indexes.
const std::vector< CaTripleReference > & DynamicSizeList() const
Returns the dynamic size list.
Definition ichannelarray.h:147
virtual uint64_t DimensionSize(size_t dimension) const =0
Returns a dimension size.
std::vector< CaTripleReference > input_quantity_list_
Input quantity list.
Definition ichannelarray.h:210
virtual uint32_t Flags() const =0
Flags.
virtual const std::vector< uint64_t > & Shape() const =0
Returns the dimension and each dimension size.
virtual std::vector< double > & AxisValues()=0
Returns the fixed axis value list for write.
const CaTripleReference & ComparisonQuantity() const
Returns the comparison quantity list.
Definition ichannelarray.h:170
const std::vector< int64_t > & DataLinks() const
Returns a list of data kink indexes.
Definition ichannelarray.h:140
virtual ArrayType Type() const =0
Type of array.
std::vector< const IChannelConversion * > axis_conversion_list_
Axis_conversion list.
Definition ichannelarray.h:213
std::vector< CaTripleReference > & DynamicSizeList()
Returns the dynamic size list.
virtual uint64_t SumOfArray() const =0
Summation of all array dimensions.
Interface against a channel group (CG) block.
Definition ichannelgroup.h:66
Defines a MDF channel (CN) block.
Definition ichannel.h:126
Interface to a data group (DG) block.
Definition idatagroup.h:42
All MDF blocks inherits from the IBlock class. The interface class is used internally in lists....
constexpr uint32_t InputQuantity
Input quantity.
Definition ichannelarray.h:49
constexpr uint32_t ComparisonQuantity
Comparison quantity.
Definition ichannelarray.h:51
constexpr uint32_t LeftOpenInterval
Left-over interval.
Definition ichannelarray.h:55
constexpr uint32_t StandardAxis
Standard axis.
Definition ichannelarray.h:56
constexpr uint32_t DynamicSize
Dynamic size.
Definition ichannelarray.h:48
constexpr uint32_t FixedAxis
Fixed axis.
Definition ichannelarray.h:53
constexpr uint32_t OutputQuantity
Output quantity.
Definition ichannelarray.h:50
constexpr uint32_t InverseLayout
Inverse layout.
Definition ichannelarray.h:54
constexpr uint32_t Axis
Axis.
Definition ichannelarray.h:52
Main namespace for the MDF library.
Definition canmessage.h:17
ArrayType
Type of array.
Definition ichannelarray.h:31
@ Array
Simple array without attributes.
@ IntervalAxis
Interval axis.
@ LookUp
Lookup array.
@ ClassificationResult
Classification result.
@ ScalingAxis
Scaling axis.
ArrayStorage
Type of storage.
Definition ichannelarray.h:40
@ DgTemplate
Data group template.
@ CnTemplate
Channel template.
@ CgTemplate
Channel group template.
Structure that defines the channel array (CA) blocks references.
Definition ichannelarray.h:60
const mdf::IChannelGroup * ChannelGroup
Pointer to the channel group (CG) block.
Definition ichannelarray.h:62
const mdf::IChannel * Channel
Pointer to the channel (CN) block.
Definition ichannelarray.h:63
const mdf::IDataGroup * DataGroup
Pointer to the data group (DG) block.
Definition ichannelarray.h:61