-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathCollectionSchemeIngestion.h
224 lines (172 loc) · 6.92 KB
/
CollectionSchemeIngestion.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "CollectionInspectionAPITypes.h"
#include "ICollectionScheme.h"
#include "SignalTypes.h"
#include "collection_schemes.pb.h"
#include "common_types.pb.h"
#include <cstddef>
#include <cstdint>
#include <memory>
#ifdef FWE_FEATURE_VISION_SYSTEM_DATA
#include <atomic>
#include <utility>
#endif
#ifdef FWE_FEATURE_STORE_AND_FORWARD
#include <string>
#endif
namespace Aws
{
namespace IoTFleetWise
{
/**
* @brief DecoderManifestIngestion (PI = Schema) is the implementation of ICollectionScheme used by
* Schema.
*/
class CollectionSchemeIngestion : public ICollectionScheme
{
public:
#ifdef FWE_FEATURE_VISION_SYSTEM_DATA
CollectionSchemeIngestion( std::shared_ptr<PartialSignalIDLookup> partialSignalIDLookup )
: mPartialSignalIDLookup( std::move( partialSignalIDLookup ) )
{
}
#else
CollectionSchemeIngestion() = default;
#endif
~CollectionSchemeIngestion() override;
CollectionSchemeIngestion( const CollectionSchemeIngestion & ) = delete;
CollectionSchemeIngestion &operator=( const CollectionSchemeIngestion & ) = delete;
CollectionSchemeIngestion( CollectionSchemeIngestion && ) = delete;
CollectionSchemeIngestion &operator=( CollectionSchemeIngestion && ) = delete;
bool operator==( const ICollectionScheme &other ) const override;
bool operator!=( const ICollectionScheme &other ) const override;
bool isReady() const override;
bool build() override;
bool copyData( std::shared_ptr<Schemas::CollectionSchemesMsg::CollectionScheme> protoCollectionSchemeMessagePtr );
const SyncID &getCollectionSchemeID() const override;
#ifdef FWE_FEATURE_STORE_AND_FORWARD
const std::string &getCampaignArn() const override;
#endif
const SyncID &getDecoderManifestID() const override;
uint64_t getStartTime() const override;
uint64_t getExpiryTime() const override;
uint32_t getAfterDurationMs() const override;
bool isActiveDTCsIncluded() const override;
bool isTriggerOnlyOnRisingEdge() const override;
const Signals_t &getCollectSignals() const override;
const RawCanFrames_t &getCollectRawCanFrames() const override;
bool isPersistNeeded() const override;
bool isCompressionNeeded() const override;
uint32_t getPriority() const override;
const ExpressionNode *getCondition() const override;
uint32_t getMinimumPublishIntervalMs() const override;
const ExpressionNode_t &getAllExpressionNodes() const override;
#ifdef FWE_FEATURE_VISION_SYSTEM_DATA
/**
* @brief The internal PartialSignalIDs are generated here. This ID must be unique across all campaigns.
* To avoid duplication this counter is used as the uppermost Bit INTERNAL_SIGNAL_ID_BITMASK must be set
* the MSB can never be used
*/
static std::atomic<uint32_t> mPartialSignalCounter; // NOLINT Global atomic partial signal counter
const PartialSignalIDLookup &getPartialSignalIdToSignalPathLookupTable() const override;
S3UploadMetadata getS3UploadMetadata() const override;
#endif
#ifdef FWE_FEATURE_STORE_AND_FORWARD
const StoreAndForwardConfig &getStoreAndForwardConfiguration() const override;
#endif
const ExpressionNode_t &getAllExpressionNodesForFetchCondition() const override;
const ExpressionNode_t &getAllExpressionNodesForFetchAction() const override;
const FetchInformation_t &getAllFetchInformations() const override;
private:
/**
* @brief The CollectionScheme message that will hold the deserialized proto.
*/
std::shared_ptr<Schemas::CollectionSchemesMsg::CollectionScheme> mProtoCollectionSchemeMessagePtr;
/**
* @brief Flag which is true if proto binary data is processed into readable data structures.
*/
bool mReady{ false };
/**
* @brief Vector of all the signals that need to be collected/monitored
*/
Signals_t mCollectedSignals;
/**
* @brief Vector of all the CAN Messages that need to be collected/monitored
*/
RawCanFrames_t mCollectedRawCAN;
/**
* @brief Expression Node Pointer to the Tree Root
*/
ExpressionNode *mExpressionNode{ nullptr };
/**
* @brief Vector representing all of the ExpressionNode(s)
*/
ExpressionNode_t mExpressionNodes;
#ifdef FWE_FEATURE_VISION_SYSTEM_DATA
/**
* @brief unordered_map from partial signal ID to pair of signal path and signal ID
*/
std::shared_ptr<PartialSignalIDLookup> mPartialSignalIDLookup;
/**
* @brief Required metadata for S3 upload
*/
S3UploadMetadata mS3UploadMetadata;
#endif
#ifdef FWE_FEATURE_STORE_AND_FORWARD
/**
* @brief Configuration of store and forward campaign
*/
StoreAndForwardConfig mStoreAndForwardConfig;
#endif
/**
* @brief Vector representing all expression nodes used for fetching conditions.
*/
ExpressionNode_t mExpressionNodesForFetchCondition;
/**
* @brief Vector representing all expression nodes used for fetching actions.
*/
ExpressionNode_t mExpressionNodesForFetchAction;
/**
* @brief Vector representing all fetch informations.
*/
FetchInformation_t mFetchInformations;
/**
* @brief Function used to Flatten the Abstract Syntax Tree (AST)
*/
ExpressionNode *serializeNode( const Schemas::CommonTypesMsg::ConditionNode &node,
ExpressionNode_t &expressionNodes,
std::size_t &nextIndex,
int remainingDepth );
/**
* @brief Helper function that returns all nodes in the AST by doing a recursive traversal
*
* @param node Root node of the AST
* @param depth Used recursively to find the depth. Start with maximum depth.
*
* @return Returns the number of nodes in the AST
*/
uint32_t getNumberOfNodes( const Schemas::CommonTypesMsg::ConditionNode &node, const int depth );
/**
* @brief Private Local Function used by the serializeNode Function to return the used Function Type
*/
static WindowFunction convertFunctionType(
Schemas::CommonTypesMsg::ConditionNode_NodeFunction_WindowFunction_WindowType function );
/**
* @brief Private Local Function used by the serializeNode Function to return the used Operator Type
*/
static ExpressionNodeType convertOperatorType( Schemas::CommonTypesMsg::ConditionNode_NodeOperator_Operator op );
#ifdef FWE_FEATURE_VISION_SYSTEM_DATA
/**
* @brief If for the Signal ID and path combination already an ID was generated return it. Otherwise generate a new.
*/
PartialSignalID getOrInsertPartialSignalId( SignalID signalId, const Schemas::CommonTypesMsg::SignalPath &path );
#endif
/**
* @brief Next custom function invocation ID to assign
*/
static CustomFunctionInvocationID mCustomFunctionNextInvocationId; // NOLINT
};
} // namespace IoTFleetWise
} // namespace Aws