direcs
2012-09-30
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
timerThread.cpp
Go to the documentation of this file.
1
/*************************************************************************
2
* Copyright (C) Markus Knapp *
3
* www.direcs.de *
4
* *
5
* This file is part of direcs. *
6
* *
7
* direcs is free software: you can redistribute it and/or modify it *
8
* under the terms of the GNU General Public License as published *
9
* by the Free Software Foundation, version 3 of the License. *
10
* *
11
* direcs is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
15
* *
16
* You should have received a copy of the GNU General Public License *
17
* along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18
* *
19
*************************************************************************/
20
21
#include "
timerThread.h
"
22
23
TimerThread::TimerThread
()
24
{
25
stopped
=
false
;
26
networkStateSet
=
false
;
27
}
28
29
30
TimerThread::~TimerThread
()
31
{
32
}
33
34
35
void
TimerThread::stop
()
36
{
37
stopped
=
true
;
38
}
39
40
41
void
TimerThread::run
()
42
{
43
// get the current date and time
44
startTime
= QTime::currentTime();
45
// emit message(QString("Timer thread start at %1-%2-%3 %4:%5:%6.%7.").arg(startTime.toString("yyyy")).arg(startTime.toString("MM")).arg(startTime.toString("dd")).arg(startTime.toString("hh")).arg(startTime.toString("mm")).arg(startTime.toString("ss")).arg(startTime.toString("zzz")));
46
emit
message
(
"Timer thread started now (run)."
);
47
48
//
49
// start "threading"...
50
//
51
while
(!
stopped
)
52
{
53
// let the thread sleep some time
54
// for having more time for the other threads
55
msleep(
THREADSLEEPTIME
);
56
57
// get current time
58
now
= QTime::currentTime();
59
// qDebug("%d seconds from pgm start.", startTime.secsTo( QDateTime::currentDateTime() ));
60
61
//------------------
62
// master or slave?
63
//------------------
64
if
(
networkStateSet
==
false
)
65
{
66
// time elapsed for receiving a master signal.
67
if
(
startTime
.secsTo(
now
) >=
timeToNetworkCheck
)
68
{
69
networkStateSet
=
true
;
70
emit
checkNetworkState
();
71
}
72
}
73
74
75
//----------------------
76
// send 'master' signal
77
// every second
78
//----------------------
79
emit
networkMessage
();
80
}
81
stopped
=
false
;
82
}
83
84
85
bool
TimerThread::init
()
86
{
87
return
true
;
88
}
direcs
src
timerThread.cpp
Generated on Sat Feb 2 2013 21:41:02 for direcs by
1.8.1.1