-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimedOutput.cpp
More file actions
54 lines (42 loc) · 914 Bytes
/
Copy pathTimedOutput.cpp
File metadata and controls
54 lines (42 loc) · 914 Bytes
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
#include "TimedOutput.h"
#include "inifile.h"
#include "ProjectLogger.h"
#include <unistd.h>
CTimedOutput::CTimedOutput(int pin, bool bDefaultState)
: COutPin(pin, bDefaultState)
{
sem_init(&m_sem,0,0);
Start();
m_bDefault = bDefaultState;
m_pAppSettings = new INIReader(INIPATH);
m_dwTimePeriod = m_pAppSettings->GetInteger(TIMINGS_SEC,TIMINGS_STROBE,2500);
}
CTimedOutput::~CTimedOutput()
{
Stop(&m_sem);
delete m_pAppSettings;
}
void CTimedOutput::StopEvent()
{
sem_post(&m_sem);
}
void CTimedOutput::Fire()
{
sem_post(&m_sem);
}
int CTimedOutput::Run()
{
while(!ShouldExit())
{
sem_wait(&m_sem);
if(!ShouldExit())
{
//CProjectLogger::GetInstance()->Log("Timed output ON\n");
SetState(true);
sleep(m_dwTimePeriod);
//CProjectLogger::GetInstance()->Log("Timed output OFF\n");
SetState(false);
}
}
return 0;
}