-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstrumentCtrl.cpp
More file actions
73 lines (58 loc) · 1.73 KB
/
instrumentCtrl.cpp
File metadata and controls
73 lines (58 loc) · 1.73 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
63
64
65
66
67
68
69
#include <thread>
#include <iostream>
#include "instrumentCtrl.h"
// extern threadsafe_queue<ENGN_Info> rslt_q;
InstrumentCtrl::InstrumentCtrl(threadsafe_queue<Command>* p, threadsafe_queue<ENGN_Info>* i)
{
pCq = p;
pRq = i;
}
InstrumentCtrl::~InstrumentCtrl()
{
}
void InstrumentCtrl::control()
{
std::cout << "Ctrl thread is waiting for cmd ... \n";
Command cmd;
while(true){
pCq->wait_and_pop(cmd);
if(0 == cmd.cmd.compare("info"))
{
ENGN_Info info;
info.bCanAutoGain = true;
info.bHasDark = false;
info.bHasRef = true;
info.bHasVariableSpeed = false;
info.bMapOK = true;
//rslt_q.push(info);
pRq->push(info);
}
if(0 == cmd.cmd.compare("exit"))
{
std::cout << "Exit Intrument Control thread ..." << std::endl;
pCq->push(cmd);
break;
}
std::cout << "cmd.cmd :" << cmd.cmd << std::endl;
std::cout << "cmd.para1 :" << cmd.para1 << std::endl;
std::cout << "cmd.para2 :" << cmd.para2 << std::endl;
std::cout << "cmd.para3 :" << cmd.para3 << std::endl;
std::cout << "cmd.para4 :" << cmd.para4 << std::endl;
std::cout << "cmd.para5 :" << cmd.para5 << std::endl;
std::cout << "cmd.para6 :" << cmd.para6 << std::endl;
}
}
void InstrumentCtrl::run()
{
hw_thread = std::thread(&InstrumentCtrl::control, this);
}
void InstrumentCtrl::getInfo(std::promise<ENGN_Info>& prom)
{
ENGN_Info info;
info.bCanAutoGain = true;
info.bHasDark = false;
info.bHasRef = true;
info.bHasVariableSpeed = false;
info.bMapOK = true;
prom.set_value(info);
}