-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.cpp
104 lines (84 loc) · 3.88 KB
/
app.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "app.h"
App::App(int channels, int packetSize, int packetDelay)
: channels(channels), packetSize(packetSize), packetDelay(packetDelay)
{
app = new GVApplication();
connect(this, SIGNAL(initialization()),this,SLOT(setupTimer()));
simpleViewer = new SimpleViewer(channels);
}
void App::checkSlot()
{
if(initPartnerDevice) {
if(app->discoverDevices()>0) {
foreach (PartnerDevice* aDevice, app->getDiscoveredDevices()) {
std::cout<<aDevice->manufactureName.toStdString()<<std::endl;
std::cout<<aDevice->modelName.toStdString()<<std::endl;
std::cout<<aDevice->deviceVersion.toStdString()<<std::endl;
std::cout<<aDevice->macAddress.toStdString()<<std::endl;
std::cout<<aDevice->ipAddress.toString().toStdString()<<std::endl;
std::cout<<aDevice->subnetMask.toString().toStdString()<<std::endl;
std::cout<<aDevice->defaultGateway.toString().toStdString()<<std::endl;
}
pdevice = *(app->getDiscoveredDevices().at(0));
initPartnerDevice = false;
}
} else {
if(initControlChannel) {
if(pdevice.openControlChannel(5001))
initControlChannel = false;
} else {
if(initStreamChannel) {
if(pdevice.getStreamingChannelNumber()>=0) {
hfov = pdevice.getHorizontalFieldOfView();
vfov = pdevice.getVerticalFieldOfView();
std::cout<<"HFOV: "<<hfov<<"; VFOV: "<<vfov<<std::endl;
if((channels & 0xF00)==0x100) {
if(pdevice.openStreamChannel(0)==GEV_STATUS_SUCCESS) {
pdevice.setStreamChannelDelay(0,packetDelay);
pdevice.setStreamChannelPacketLength(0,packetSize);
obs1 = new DepthStreamDataObserver(*pdevice.getStreamChannel(0),hfov,vfov);
connect(obs1, SIGNAL(pointCloudUpdate()),
simpleViewer, SLOT(updateViewer1()));
simpleViewer->obs1 = obs1;
}
}
if((channels & 0x0F0)==0x010) {
if(pdevice.openStreamChannel(1)==GEV_STATUS_SUCCESS) {
pdevice.setStreamChannelDelay(1,packetDelay);
pdevice.setStreamChannelPacketLength(1,packetSize);
obs2 = new ColorStreamDataObserver(*pdevice.getStreamChannel(1),hfov,vfov);
connect(obs2, SIGNAL(pointCloudUpdate()),
simpleViewer, SLOT(updateViewer2()));
simpleViewer->obs2 = obs2;
}
}
if((channels & 0x00F)==0x001) {
if(pdevice.openStreamChannel(2)==GEV_STATUS_SUCCESS) {
pdevice.setStreamChannelDelay(2,packetDelay);
pdevice.setStreamChannelPacketLength(2,packetSize);
obs3 = new DepthColorStreamDataObserver(*pdevice.getStreamChannel(2),hfov,vfov);
connect(obs3, SIGNAL(pointCloudUpdate()),
simpleViewer, SLOT(updateViewer3()));
simpleViewer->obs3 = obs3;
}
}
initStreamChannel = false;
disconnect(this, SIGNAL(initialization()),this,SLOT(setupTimer()));
timer->stop();
}
}
}
}
}
void App::setupTimer()
{
timer = new QTimer(this);
timer->setInterval(30);
connect(timer,SIGNAL(timeout()),this,SLOT(checkSlot()));
timer->start();
}
void App::run()
{
emit initialization();
exec();
}