-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarkSpaceOutput.cpp
More file actions
62 lines (53 loc) · 1.14 KB
/
Copy pathMarkSpaceOutput.cpp
File metadata and controls
62 lines (53 loc) · 1.14 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
#include "MarkSpaceOutput.h"
#include "inifile.h"
#include "ProjectLogger.h"
CMarkSpaceOutput::CMarkSpaceOutput(int pin, bool bDefault)
: COutPin(pin, bDefault)
{
m_pAppSettings = new INIReader(INIPATH);
Start() ;
}
CMarkSpaceOutput::~CMarkSpaceOutput()
{
if(ThreadIsRunning())
{
Stop();
}
SetState(false);
delete m_pAppSettings;
}
int CMarkSpaceOutput::Run()
{
unsigned int dwOnTime = 0;
unsigned int dwOffTime = 0;
while(!ShouldExit(10))
{
if(GetState())
{
dwOnTime++;
unsigned int dwTimeToBeOn;
dwTimeToBeOn = m_pAppSettings->GetInteger(MARKSPACE_SEC, MARKSPACE_ON,1);
dwTimeToBeOn *= 100;
if(dwOnTime >= dwTimeToBeOn)
{
//CProjectLogger::GetInstance()->Log("MarkSpace OFF\n");
SetState(false);
dwOffTime = 0;
}
}
else
{
dwOffTime++;
unsigned int dwTimeToBeOff;
dwTimeToBeOff = m_pAppSettings->GetInteger(MARKSPACE_SEC, MARKSPACE_OFF,1);
dwTimeToBeOff *= 100;
if(dwOffTime >= dwTimeToBeOff)
{
//CProjectLogger::GetInstance()->Log("MarkSpace ON\n");
SetState(true);
dwOnTime = 0;
}
}
}
return 0;
}