6
6
//
7
7
8
8
#pragma once
9
+ #include < cstdarg>
10
+ #include < fstream>
11
+ #include < iostream>
12
+ #include < set>
13
+ #include < string>
9
14
15
+ #include " OSMPConfig.h"
16
+ #include " fmi2Functions.h"
10
17
#include " osi_sensordata.pb.h"
11
18
19
+ using namespace std ;
20
+
12
21
class MySensorModel
13
22
{
14
23
public:
15
- void Init (double nominal_range_in);
24
+ void Init (double nominal_range_in, string theinstance_name, fmi2CallbackFunctions thefunctions, bool thelogging_on);
25
+
16
26
osi3::SensorData Step (osi3::SensorView current_in, double time);
17
27
18
28
static void RotatePointXYZ (double x, double y, double z, double yaw, double pitch, double roll, double & rx, double & ry, double & rz);
@@ -40,6 +50,11 @@ class MySensorModel
40
50
double mounting_position_roll);
41
51
42
52
private:
53
+ string instance_name_;
54
+ bool logging_on_;
55
+ set<string> logging_categories_;
56
+ fmi2CallbackFunctions functions_;
57
+
43
58
double nominal_range_;
44
59
45
60
/* Private File-based Logging just for Debugging */
@@ -55,7 +70,9 @@ class MySensorModel
55
70
va_start (ap, format);
56
71
char buffer[1024 ];
57
72
if (!private_log_file.is_open ())
73
+ {
58
74
private_log_file.open (PRIVATE_LOG_PATH, ios::out | ios::app);
75
+ }
59
76
if (private_log_file.is_open ())
60
77
{
61
78
#ifdef _WIN32
@@ -82,17 +99,23 @@ class MySensorModel
82
99
#endif
83
100
#ifdef PRIVATE_LOG_PATH
84
101
if (!private_log_file.is_open ())
102
+ {
85
103
private_log_file.open (PRIVATE_LOG_PATH, ios::out | ios::app);
104
+ }
86
105
if (private_log_file.is_open ())
87
106
{
88
- private_log_file << " OSMPDummySensor"
89
- << " ::" << instanceName << " <" << ((void *)this ) << " >:" << category << " : " << buffer << endl;
107
+ private_log_file << " MySensorModel"
108
+ << " ::"
109
+ << " template"
110
+ << " <" << ((void *)this ) << " >:" << category << " : " << buffer << endl;
90
111
private_log_file.flush ();
91
112
}
92
113
#endif
93
114
#ifdef PUBLIC_LOGGING
94
- if (loggingOn && loggingCategories.count (category))
95
- functions.logger (functions.componentEnvironment , instanceName.c_str (), fmi2OK, category, buffer);
115
+ if (logging_on_ && (logging_categories_.count (category) != 0U ))
116
+ {
117
+ functions_.logger (functions_.componentEnvironment , instance_name_.c_str (), fmi2OK, category, buffer);
118
+ }
96
119
#endif
97
120
#endif
98
121
}
@@ -113,7 +136,7 @@ class MySensorModel
113
136
#if defined(PRIVATE_LOG_PATH) || defined(PUBLIC_LOGGING)
114
137
va_list ap;
115
138
va_start (ap, format);
116
- internal_log (category, format, ap);
139
+ InternalLog (category, format, ap);
117
140
va_end (ap);
118
141
#endif
119
142
}
0 commit comments