6
6
#include " ../hardware/hardwaretypes.h"
7
7
#include " ../main/RFXtrx.h"
8
8
#include " ../main/SQLHelper.h"
9
- #include < boost/date_time/c_local_time_adjustor.hpp>
10
9
#include " ../webserver/Base64.h"
11
10
#include " ../main/localtime_r.h"
12
11
#include " ../main/WebServer.h"
18
17
#include < unistd.h> // gethostbyname
19
18
#endif
20
19
21
- typedef struct _STR_TABLE_ID1_ID2 {
22
- unsigned long id1;
23
- unsigned long id2;
24
- const char *str1;
25
- } STR_TABLE_ID1_ID2;
26
-
27
- static boost::posix_time::time_duration get_utc_offset () {
28
- using namespace boost ::posix_time;
29
-
30
- // boost::date_time::c_local_adjustor uses the C-API to adjust a
31
- // moment given in utc to the same moment in the local time zone.
32
- typedef boost::date_time::c_local_adjustor<ptime> local_adj;
33
-
34
- const ptime utc_now = second_clock::universal_time ();
35
- const ptime now = local_adj::utc_to_local (utc_now);
36
-
37
- return now - utc_now;
38
- }
39
-
40
20
CHttpPush::CHttpPush ()
41
21
{
42
22
m_bLinkActive = false ;
@@ -113,8 +93,6 @@ void CHttpPush::DoHttpPush()
113
93
int delpos = atoi (sd[1 ].c_str ());
114
94
int dType = atoi (sd[3 ].c_str ());
115
95
int dSubType = atoi (sd[4 ].c_str ());
116
- std::string lType = sd[3 ].c_str ();
117
- std::string lSubType = sd[4 ].c_str ();
118
96
int nValue = atoi (sd[5 ].c_str ());
119
97
std::string sValue = sd[6 ].c_str ();
120
98
int targetType = atoi (sd[7 ].c_str ());
@@ -124,16 +102,12 @@ void CHttpPush::DoHttpPush()
124
102
int includeUnit = atoi (sd[11 ].c_str ());
125
103
int metertype = atoi (sd[12 ].c_str ());
126
104
int lastUpdate = atoi (sd[13 ].c_str ());
127
- std::string lstatus=" " ;
128
- std::string lunit = " " ;
129
105
std::string ltargetVariable = sd[8 ].c_str ();
130
106
std::string ltargetDeviceId = sd[9 ].c_str ();
131
107
std::string lname = sd[14 ].c_str ();
132
108
sendValue = sValue ;
133
109
134
- // Compute tz
135
- boost::posix_time::time_duration uoffset = get_utc_offset ();
136
- unsigned long tzoffset = (int )((double )(uoffset.ticks () / 3600000000LL ) * 3600 );
110
+ unsigned long tzoffset = get_tzoffset ();
137
111
138
112
#ifdef WIN32
139
113
unsigned __int64 localTime = lastUpdate;
@@ -152,18 +126,7 @@ void CHttpPush::DoHttpPush()
152
126
char szLocalTimeUtcMs[16 ];
153
127
sprintf (szLocalTimeUtcMs, " %llu" , localTimeUtc * 1000 );
154
128
155
- // RFC3339 time format
156
- time_t tmpT = localTimeUtc;
157
- struct tm * timeinfo = gmtime (&tmpT);
158
-
159
- char llastUpdate[255 ];
160
- #if !defined WIN32
161
- snprintf (llastUpdate, sizeof (llastUpdate), " %04d-%02d-%02dT%02d:%02d:%02dZ" ,
162
- timeinfo->tm_year + 1900 , timeinfo->tm_mon + 1 , timeinfo->tm_mday , timeinfo->tm_hour , timeinfo->tm_min , timeinfo->tm_sec );
163
- #else
164
- sprintf_s (llastUpdate, sizeof (llastUpdate), " %04d-%02d-%02dT%02d:%02d:%02dZ" ,
165
- timeinfo->tm_year + 1900 , timeinfo->tm_mon + 1 , timeinfo->tm_mday , timeinfo->tm_hour , timeinfo->tm_min , timeinfo->tm_sec );
166
- #endif
129
+ std::string llastUpdate = get_lastUpdate (localTimeUtc);
167
130
168
131
// Replace keywords
169
132
/*
@@ -182,9 +145,9 @@ void CHttpPush::DoHttpPush()
182
145
%h : hostname
183
146
*/
184
147
185
- lunit = getUnit (delpos, metertype);
186
- lType = RFX_Type_Desc (dType,1 );
187
- lSubType = RFX_Type_SubType_Desc (dType,dSubType);
148
+ std::string lunit = getUnit (delpos, metertype);
149
+ std::string lType = RFX_Type_Desc (dType,1 );
150
+ std::string lSubType = RFX_Type_SubType_Desc (dType,dSubType);
188
151
189
152
char hostname[256 ];
190
153
gethostname (hostname, sizeof (hostname));
@@ -214,8 +177,8 @@ void CHttpPush::DoHttpPush()
214
177
replaceAll (httpUrl, " %t1" , std::string (szLocalTimeMs));
215
178
replaceAll (httpUrl, " %t2" , std::string (szLocalTimeUtc));
216
179
replaceAll (httpUrl, " %t3" , std::string (szLocalTimeUtcMs));
217
- replaceAll (httpUrl, " %t4" , std::string ( llastUpdate) );
218
- replaceAll (httpUrl, " %n" , std::string ( lname) );
180
+ replaceAll (httpUrl, " %t4" , llastUpdate);
181
+ replaceAll (httpUrl, " %n" , lname);
219
182
replaceAll (httpUrl, " %T0" , lType);
220
183
replaceAll (httpUrl, " %T1" , lSubType);
221
184
replaceAll (httpUrl, " %h" , std::string (hostname));
@@ -228,8 +191,8 @@ void CHttpPush::DoHttpPush()
228
191
replaceAll (httpData, " %t1" , std::string (szLocalTimeMs));
229
192
replaceAll (httpData, " %t2" , std::string (szLocalTimeUtc));
230
193
replaceAll (httpData, " %t3" , std::string (szLocalTimeUtcMs));
231
- replaceAll (httpData, " %t4" , std::string ( llastUpdate) );
232
- replaceAll (httpData, " %n" , std::string ( lname) );
194
+ replaceAll (httpData, " %t4" , llastUpdate);
195
+ replaceAll (httpData, " %n" , lname);
233
196
replaceAll (httpData, " %T0" , lType);
234
197
replaceAll (httpData, " %T1" , lSubType);
235
198
replaceAll (httpData, " %h" , std::string (hostname));
0 commit comments