File tree Expand file tree Collapse file tree 2 files changed +4
-17
lines changed Expand file tree Collapse file tree 2 files changed +4
-17
lines changed Original file line number Diff line number Diff line change @@ -29,21 +29,14 @@ CVolcraftCO20::CVolcraftCO20(const int ID)
29
29
{
30
30
m_HwdID=ID;
31
31
m_stoprequested=false ;
32
- Init ();
33
32
}
34
33
35
34
CVolcraftCO20::~CVolcraftCO20 (void )
36
35
{
37
36
}
38
37
39
- void CVolcraftCO20::Init ()
40
- {
41
- m_LastPollTime=mytime (NULL )-VolcraftCO20_POLL_INTERVAL+2 ;
42
- }
43
-
44
38
bool CVolcraftCO20::StartHardware ()
45
39
{
46
- Init ();
47
40
// Start worker thread
48
41
m_thread = boost::shared_ptr<boost::thread>(new boost::thread (boost::bind (&CVolcraftCO20::Do_Work, this )));
49
42
m_bIsStarted=true ;
@@ -73,20 +66,16 @@ bool CVolcraftCO20::StopHardware()
73
66
void CVolcraftCO20::Do_Work ()
74
67
{
75
68
time_t atime;
69
+ int sec_counter=VolcraftCO20_POLL_INTERVAL-5 ;
76
70
while (!m_stoprequested)
77
71
{
78
72
sleep_seconds (1 );
79
- atime=mytime (NULL );
80
-
81
- struct tm ltime;
82
- localtime_r (&atime, <ime);
83
-
84
-
85
- if (ltime.tm_sec % 12 == 0 ) {
73
+ sec_counter++;
74
+ if (sec_counter%12 ==0 )
86
75
mytime (&m_LastHeartbeat);
87
76
}
88
77
89
- if (atime-m_LastPollTime>= VolcraftCO20_POLL_INTERVAL)
78
+ if (sec_counter% VolcraftCO20_POLL_INTERVAL== 0 )
90
79
{
91
80
GetSensorDetails ();
92
81
m_LastPollTime=mytime (NULL );
Original file line number Diff line number Diff line change @@ -14,10 +14,8 @@ class CVolcraftCO20 : public CDomoticzHardwareBase
14
14
bool WriteToHardware (const char *pdata, const unsigned char length);
15
15
private:
16
16
volatile bool m_stoprequested;
17
- time_t m_LastPollTime;
18
17
boost::shared_ptr<boost::thread> m_thread;
19
18
20
- void Init ();
21
19
bool StartHardware ();
22
20
bool StopHardware ();
23
21
void Do_Work ();
You can’t perform that action at this time.
0 commit comments