-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathCustomFunctionMultiRisingEdgeTrigger.h
70 lines (61 loc) · 2.39 KB
/
CustomFunctionMultiRisingEdgeTrigger.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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "CollectionInspectionAPITypes.h"
#include "NamedSignalDataSource.h"
#include "RawDataManager.h"
#include "SignalTypes.h"
#include "TimeTypes.h"
#include <memory>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace Aws
{
namespace IoTFleetWise
{
/**
* MULTI_RISING_EDGE_TRIGGER custom function implementation
*
* Custom function signature:
*
* bool custom_function('MULTI_RISING_EDGE_TRIGGER',
* string conditionName1, bool condition1,
* string conditionName2, bool condition2,
* string conditionName3, bool condition3,
* ...
* );
*
* The function takes a variable number of pairs of arguments, with each pair being a string name
* of the condition and a Boolean value of the condition itself.
*
* The function will return true when one or more of the conditions has a rising edge (false ->
* true). Additionally it will produce a string signal called `Vehicle.MultiTriggerInfo` that
* contains a JSON serialized array of strings containing the names of the conditions that have a
* rising edge.
*/
class CustomFunctionMultiRisingEdgeTrigger
{
public:
CustomFunctionMultiRisingEdgeTrigger( std::shared_ptr<NamedSignalDataSource> namedSignalDataSource,
std::shared_ptr<RawData::BufferManager> rawBufferManager );
CustomFunctionInvokeResult invoke( CustomFunctionInvocationID invocationId,
const std::vector<InspectionValue> &args );
void conditionEnd( const std::unordered_set<SignalID> &collectedSignalIds,
Timestamp timestamp,
CollectionInspectionEngineOutput &output );
void cleanup( CustomFunctionInvocationID invocationId );
private:
struct InvocationState
{
// coverity[autosar_cpp14_a18_1_2_violation] std::vector<bool> specialization is acceptable in this usecase
std::vector<bool> lastConditionValues;
};
std::unordered_map<CustomFunctionInvocationID, InvocationState> mInvocationStates;
std::vector<std::string> mTriggeredConditions;
std::shared_ptr<NamedSignalDataSource> mNamedSignalDataSource;
std::shared_ptr<RawData::BufferManager> mRawBufferManager;
};
} // namespace IoTFleetWise
} // namespace Aws