forked from northern-bites/nao-man
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTTMan.cpp
54 lines (42 loc) · 1.47 KB
/
TTMan.cpp
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
#include "TTMan.h"
using boost::shared_ptr;
using namespace std;
TTMan::TTMan(shared_ptr<Sensors> _sensors,
shared_ptr<Transcriber> _transcriber,
shared_ptr<ThreadedImageTranscriber> _imageTranscriber,
shared_ptr<ThreadedMotionEnactor> _enactor,
shared_ptr<Synchro> synchro,
shared_ptr<Lights> _lights)
:Man(_sensors,_transcriber,_imageTranscriber,_enactor,synchro,_lights),
threadedImageTranscriber(_imageTranscriber),
threadedEnactor(_enactor){}
TTMan::~TTMan(){}
void TTMan::startSubThreads(){
if(threadedEnactor->start()!=0)
cout << "Failed to start enactor" <<endl;
else
threadedEnactor->getTrigger()->await_on();
Man::startSubThreads();
// Start Image transcriber thread (it handles its own threading
if (threadedImageTranscriber->start() != 0) {
cerr << "Image transcriber failed to start" << endl;
}
else
threadedImageTranscriber->getTrigger()->await_on();
}
void TTMan::stopSubThreads(){
#ifdef DEBUG_MAN_THREADING
cout << " TTMan stoping:" << endl;
#endif
threadedImageTranscriber->stop();
threadedImageTranscriber->getTrigger()->await_off();
#ifdef DEBUG_MAN_THREADING
cout << " Image Transcriber thread is stopped" << endl;
#endif
Man::stopSubThreads();
threadedEnactor->stop();
threadedEnactor->getTrigger()->await_off();
#ifdef DEBUG_MAN_THREADING
cout << " Enactor thread is stopped" << endl;
#endif
}