-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTracer.cpp
More file actions
90 lines (80 loc) · 4.18 KB
/
Copy pathTracer.cpp
File metadata and controls
90 lines (80 loc) · 4.18 KB
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
#include "include.h"
/** \brief Constructor takes in the run name, simulation context, and desired tracing level
*
* \param runName a string identify the run corresponding to this Tracer: this->traceFileName will be the runName appended to CepacUtil::FILE_EXTENSION_FOR_TRACE
* \param *simContext this->simContext
* \param traceLevel this->traceLevel
**/
Tracer::Tracer(string runName, SimContext *simContext, int traceLevel) {
traceFileName = runName;
traceFileName.append(CepacUtil::FILE_EXTENSION_FOR_TRACE);
this->traceLevel = traceLevel;
this->simContext = simContext;
} /* end Constructor */
/** \brief Destructor is empty, no cleanup required */
Tracer::~Tracer(void) {
} /* end Destructor */
/** \brief openTraceFile opens the trace file for writing */
void Tracer::openTraceFile() {
CepacUtil::changeDirectoryToResults();
traceFile = CepacUtil::openFile(traceFileName.c_str(), "w");
} /* end openTraceFile */
/** \brief closeTraceFile closes the trace file */
void Tracer::closeTraceFile() {
// return if trace file is not valid
if (traceFile == NULL)
return;
CepacUtil::closeFile(traceFile);
} /* end closeTraceFile */
/** \brief printTraceOutputHeader prints out the HVL/CD4 strata information to trace file */
void Tracer::printTraceHeader() {
// return if trace file is not valid
if (traceFile == NULL)
return;
const SimContext::RunSpecsInputs *runSpecsInputs = simContext->getRunSpecsInputs();
printTrace(1, "=============================\n");
printTrace(1, "HVL: %s = 0 - 20\n", SimContext::HVL_STRATA_STRS[SimContext::HVL_VLO]);
printTrace(1, " %s = 20 - 500\n", SimContext::HVL_STRATA_STRS[SimContext::HVL__LO]);
printTrace(1, " %s = 500 - 3k\n", SimContext::HVL_STRATA_STRS[SimContext::HVL_MLO]);
printTrace(1, " %s = 3k - 10k\n", SimContext::HVL_STRATA_STRS[SimContext::HVL_MED]);
printTrace(1, " %s = 10k - 30k\n", SimContext::HVL_STRATA_STRS[SimContext::HVL_MHI]);
printTrace(1, " %s = 30k - 100k\n", SimContext::HVL_STRATA_STRS[SimContext::HVL__HI]);
printTrace(1, " %s = > 100k\n", SimContext::HVL_STRATA_STRS[SimContext::HVL_VHI]);
printTrace(1, "=============================\n");
printTrace(1, "CD4: %s = 0 - %1.0f\n", SimContext::CD4_STRATA_STRS[SimContext::CD4_VLO],
runSpecsInputs->CD4StrataUpperBounds[SimContext::CD4_VLO]);
printTrace(1, " %s = %1.0f - %1.0f\n", SimContext::CD4_STRATA_STRS[SimContext::CD4__LO],
runSpecsInputs->CD4StrataUpperBounds[SimContext::CD4_VLO],
runSpecsInputs->CD4StrataUpperBounds[SimContext::CD4__LO]);
printTrace(1, " %s = %1.0f - %1.0f\n", SimContext::CD4_STRATA_STRS[SimContext::CD4_MLO],
runSpecsInputs->CD4StrataUpperBounds[SimContext::CD4__LO],
runSpecsInputs->CD4StrataUpperBounds[SimContext::CD4_MLO]);
printTrace(1, " %s = %1.0f - %1.0f\n", SimContext::CD4_STRATA_STRS[SimContext::CD4_MHI],
runSpecsInputs->CD4StrataUpperBounds[SimContext::CD4_MLO],
runSpecsInputs->CD4StrataUpperBounds[SimContext::CD4_MHI]);
printTrace(1, " %s = %1.0f - %1.0f\n", SimContext::CD4_STRATA_STRS[SimContext::CD4__HI],
runSpecsInputs->CD4StrataUpperBounds[SimContext::CD4_MHI],
runSpecsInputs->CD4StrataUpperBounds[SimContext::CD4__HI]);
printTrace(1, " %s = > %1.0f\n", SimContext::CD4_STRATA_STRS[SimContext::CD4_VHI],
runSpecsInputs->CD4StrataUpperBounds[SimContext::CD4__HI]);
printTrace(1, "=============================\n");
printTrace(1, "\n\n-----------------------------\n");
printTrace(1, "BEGIN SCENARIO %s [%d]\n", runSpecsInputs->runName.c_str(), traceLevel);
printTrace(1, "-----------------------------\n");
} /* end printTraceHeader */
/** \brief printTrace prints out the specified text to the trace file if at the specified tracing level
*
* \param level an integer representing the trace level of the information to be printed: only prints if level <= this->traceLevel
* \param format the information to be printed
**/
void Tracer::printTrace(int level, const char *format, ...) {
// return if trace file is not valid
if (traceFile == NULL)
return;
if (level > traceLevel)
return;
va_list args;
va_start (args, format);
vfprintf(traceFile, format, args);
va_end(args);
} /* end printTrace */