summaryrefslogtreecommitdiff
path: root/lcmodule/source/cnh1606344_ldr_communication_module/include/r_measurement_tool.h
blob: 25884b8f50c03d637f4f7a2604f94de095806e80 (plain)
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
/*******************************************************************************
 * Copyright (C) ST-Ericsson SA 2011
 * License terms: 3-clause BSD license
 ******************************************************************************/
#ifndef R_MEASUREMENT_TOOL_H_
#define R_MEASUREMENT_TOOL_H_
/**
 * @addtogroup ldr_communication_module
 * @{
 *    @addtogroup measurement_serv Measurement services
 *    Measurement functions is tool for performance measurement. Can be used
 *    for flashing performance, communication performance and i.t.c.
 *
 *    @{
 *
 */

/*******************************************************************************
 * Includes
 ******************************************************************************/

#include "t_basicdefinitions.h"
#include "t_measurement_tool.h"
#include "error_codes.h"

/*******************************************************************************
 * Declaration of functions
 ******************************************************************************/

#define MP(x, y, z) Do_Measurement_AddMeasurementData( x, Do_Timer_ReadTime(NULL,x->TimerId), y, z);
#define MFINISH(x) Do_Measurement_CompleteResults( x);
/**
 * Initialization of measurement module.
 *
 * @param [in] MeasurementData_p Pointer to curren measurement data block.
 *
 * @retval  E_SUCCESS If initialization is done.
 */
ErrorCode_e Do_Measurment_Init(Measurement_t *MeasurementData_p);

/**
 * This function create general measurement data block.
 *
 * @param [in]  Communication_p    Communication module context.
 * @param [in]  MeasurementData_pp Pointer to the created measurement data block.
 * @param [in]  Type               Type of measurement.
 *
 * @retval E_SUCCESS         After successful execution.
 * @retval E_ALLOCATE_FAILED If failed to allocate session measurement
 *                           data block.
 */
ErrorCode_e  Do_Measurement_CreateMeasurementData(Communication_t *Communication_p, Measurement_t    **MeasurementData_pp, uint32 Type);

/**
 * This function collect all data from measurement  buffer.
 *
 * @param [in]                      Communication_p    Communication module context.
 * @param [in, out]             Data_pp Point to pointer that should be initialized to point
 *                          on outgoing buffer.
 *
 * @return                 Number of characters successfully readied from measurement
 *                          buffer.
 */
uint32  Do_Measurement_GetMeasurementData(Communication_t *Communication_p, uint8 **Data_pp);

/**
 * This function create measurement data block for bulk session.
 *
 * @param [in]  Communication_p            Communication module context.
 * @param [in]  SessionMeasurement_pp      Pointer to the created session
 *                                         measurement data block.
 * @param [in]  PreviousSessionDataBlock_p Pointer to the previouse session
 *                                         measurement data block.
 * @param [in]  ChunkNr                    Number of chunks in this session.
 * @param [in]  Session                    Session number.
 *
 * @retval E_SUCCESS         After successful execution.
 * @retval E_ALLOCATE_FAILED If failed to allocate session measurement
 *                           data block.
 */
ErrorCode_e  Do_Measurement_CreateSessionMeasurementData(Communication_t *Communication_p,
        SessionMeasurement_t **SessionMeasurement_pp,
        SessionMeasurement_t *PreviousSessionDataBlock_p,
        uint32 ChunkNr, uint32 Session);

/**
 * This function create measurement data block for measure chunks transfer.
 *
 * @param [in]  Communication_p            Communication module context.
 * @param [in]  ChunkMeasurement_pp        Pointer to the created chunk
 *                                         measurement data block.
 * @param [in]  PreviousChunkDataBlock_p   Pointer to the previouse chunk
 *                                         measurement data block.
 * @param [in]  ChunkId                    Chunk ID.
 *
 * @retval E_SUCCESS         After successful execution.
 * @retval E_ALLOCATE_FAILED If failed to allocate session measurement
 *                           data block.
 */
ErrorCode_e  Do_Measurement_CreateChunkMeasurementData(Communication_t *Communication_p,
        ChunkMeasurement_t **ChunkMeasurement_pp,
        ChunkMeasurement_t *PreviousChunkDataBlock_p,
        uint32 ChunkId);
/**
 * This function destroy measurement data block for bulk session.
 *
 * @param [in]  MeasurementData_pp Pointer to the measurement data block.
 *
 * @retval E_SUCCESS         After successful execution.
 */
ErrorCode_e  Do_Measurement_DestroySessionMeasurementData(SessionMeasurement_t    **MeasurementData_pp);

/**
 * This function destroy measurement data block for bulk chunks.
 *
 * @param [in]  MeasurementData_pp Pointer to the main measurement data block.
 *
 * @retval E_SUCCESS         After successful execution.
 */
ErrorCode_e  Do_Measurement_DestroyChunkMeasurementData(ChunkMeasurement_t    **MeasurementData_pp);

/**
 * This function destroy general measurement data block.
 *
 * @param [in]  MeasurementData_pp Pointer to the main measurement data block.
 *
 * @retval E_SUCCESS         After successful execution.
 */
ErrorCode_e  Do_Measurement_DestroyMeasurementData(Measurement_t    **MeasurementData_pp);

/**
 * This function make zero reference for all measured data.
 *
 * @param [in]  MeasurementData_p Pointer to the main measurement data block.
 *
 * @retval E_SUCCESS         After successful execution.
 */
ErrorCode_e  Do_Measurement_ZeroReferenceMeasurementData(Measurement_t    *MeasurementData_p);

/**
 * This function add measured time in specified measurement data block.
 *
 * @param [in]  MeasurementData_p Pointer to the main measurement data block.
 * @param [in]  Time              Measured time.
 * @param [in]  ChunkID           Chunk ID
 * @param [in]  Parameter         Parameter in the measurement data block.
 *
 * @retval E_SUCCESS         After successful execution.
 */
ErrorCode_e  Do_Measurement_AddMeasurementData(Measurement_t *MeasurementData_p, uint32 Time, uint32 ChunkID, MeasurementParameter_t Parameter);

/**
 *
 */
ErrorCode_e  Do_Measurement_CompleteResults(Measurement_t *Measurement_p);

/** @} */
/** @} */
#endif /* R_MEASUREMENT_TOOL_H_ */