Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fc56abc07021d3108044ce2153a8c24f317f08d0 (plain) (blame)
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
/*******************************************************************************
 * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 * 
 * CONTRIBUTORS:
 * 		Henrik Rentz-Reichert (initial contribution)
 * 
 *******************************************************************************/

/**
 * \file etDataLogger.h
 *
 * The data logger is a means that lets data driven send ports write their data to file
 * in every cycle. Only one log file can be open at a time. The data are written
 * in comma separated value (csv) format.
 *
 * \author Henrik Rentz-Reichert
 */

#ifndef ETDATALOGGER_H_
#define ETDATALOGGER_H_

#include "etRuntimeConfig.h"

/**
 * opens a file for data logging
 *
 * \param logPath the path to the file
 * \param logName the name of the log file
 */
void etDataLogger_open(const char* logPath, const char* logName);
/**
 * closes a previously opened data log file
 */
void etDataLogger_close(void);

/**
 * writes a string to the log
 *
 * \param text the string to be written
 */
void etDataLogger_logString(const char* text);
/**
 * writes a boolean value to the log (as integer)
 *
 * \param val the value to be written
 */
void etDataLogger_logBool(int val);
/**
 * writes an integer value to the log
 * \param val the value to be written
 */
void etDataLogger_logInt(int val);
/**
 * writes a double value to the log
 * \param val the value to be written
 */
void etDataLogger_logDouble(double val);
/**
 * starts a new row of the log
 */
void etDataLogger_newRow();

#ifdef ET_DATA_LOGGER_ACTIVATE
	#define ET_DATA_LOGGER_OPEN(name) \
			etDataLogger_open("log", name);
	#define ET_DATA_LOGGER_CLOSE \
			etDataLogger_close();
	#define ET_DATA_LOGGER_LOG_STRING(text) \
			etDataLogger_logString(text);
	#define ET_DATA_LOGGER_LOG_BOOL(val) \
			etDataLogger_logBool(val);
	#define ET_DATA_LOGGER_LOG_INT(val) \
			etDataLogger_logInt(val);
	#define ET_DATA_LOGGER_LOG_DOUBLE(val) \
			etDataLogger_logDouble(val);
	#define ET_DATA_LOGGER_NEW_ROW \
			etDataLogger_newRow();
#else
	/**
	 * calls \ref etDataLogger_open(const char*, const char*) with path <code>tmp/log</code>
	 * or <code>void</code> if <code>ET_DATA_LOGGER_ACTIVATE</code> is not defined
	 */
	#define ET_DATA_LOGGER_OPEN(name)
	/**
	 * calls \ref etDataLogger_close()
	 * or <code>void</code> if <code>ET_DATA_LOGGER_ACTIVATE</code> is not defined
	 */
	#define ET_DATA_LOGGER_CLOSE
	/**
	 * calls etDataLogger_logString(const char*)
	 * or <code>void</code> if <code>ET_DATA_LOGGER_ACTIVATE</code> is not defined
	 *
	 * \param text the text to be written
	 */
	#define ET_DATA_LOGGER_LOG_STRING(text)
	/**
	 * calls \ref etDataLogger_logBool(int val)
	 * or <code>void</code> if <code>ET_DATA_LOGGER_ACTIVATE</code> is not defined
	 *
	 * \param val the value to be written
	 */
	#define ET_DATA_LOGGER_LOG_BOOL(val)
	/**
	 * calls \ref etDataLogger_logInt(int val)
	 * or <code>void</code> if <code>ET_DATA_LOGGER_ACTIVATE</code> is not defined
	 *
	 * \param val the value to be written
	 */
	#define ET_DATA_LOGGER_LOG_INT(val)
	/**
	 * calls \ref etDataLogger_logDouble(double val)
	 * or <code>void</code> if <code>ET_DATA_LOGGER_ACTIVATE</code> is not defined
	 *
	 * \param val the value to be written
	 */
	#define ET_DATA_LOGGER_LOG_DOUBLE(val)
	/**
	 * calls \ref etDataLogger_newRow()
	 * or <code>void</code> if <code>ET_DATA_LOGGER_ACTIVATE</code> is not defined
	 */
	#define ET_DATA_LOGGER_NEW_ROW
#endif

#endif /* ETDATALOGGER_H_ */

Back to the top