commit | author | age
|
929277
|
1 |
#include <stdio.h> |
e9b870
|
2 |
#include <iostream> |
929277
|
3 |
#include "Quaternion.h" |
JS |
4 |
#include "struct.h" |
|
5 |
#include "G4Trk.h" |
|
6 |
#include "G4Hub.h" |
|
7 |
#include <string.h> |
|
8 |
#include <unistd.h> |
e9b870
|
9 |
#include "clipp.h" |
JS |
10 |
using namespace clipp; using std::cout; using std::string; |
929277
|
11 |
|
JS |
12 |
|
|
13 |
int RunCollect=0; |
|
14 |
|
|
15 |
|
|
16 |
void* Collect(REND_STRUCT* prs){ |
|
17 |
int i = 0; |
|
18 |
CG4Trk* pTrk = prs->pTrk; |
|
19 |
while (RunCollect){ |
|
20 |
// periodically check for new hubs coming on line |
|
21 |
if(i % 1000 == 0) { |
|
22 |
int numHubs; |
|
23 |
if (prs->tot_hubs_on_system!=prs->numHub){ |
|
24 |
prs->numHub=numHubs=prs->tot_hubs_on_system=pTrk->UpdateHubs(); |
|
25 |
int colorInd=0; |
|
26 |
if (prs->hubList) { |
|
27 |
delete[] prs->hubList; |
|
28 |
} |
|
29 |
prs->hubList=new CG4Hub[numHubs]; |
|
30 |
int* hubIds=new int[numHubs]; |
|
31 |
pTrk->GetHubList(hubIds,numHubs); |
|
32 |
for (int i=0;i<numHubs;i++){ |
|
33 |
prs->hubList[i].SetId(hubIds[i]); |
|
34 |
} |
|
35 |
delete[] hubIds; |
|
36 |
} |
|
37 |
|
|
38 |
} |
|
39 |
i++; |
|
40 |
prs->hubreadmap=0; |
|
41 |
prs->tot_hubs_on_system=prs->pTrk->GetHubsPno(prs); |
|
42 |
for (int i=0;i<prs->numHub;i++){ |
|
43 |
auto dat = prs->hubList[i].GetPnoData()[0]; |
|
44 |
printf("sns: %i: [%f;%f;%f],[%f,%f,%f]\n",i, dat[0],dat[1],dat[2], dat[3],dat[4],dat[5]); |
|
45 |
} |
|
46 |
|
|
47 |
usleep(15000); |
|
48 |
// usleep(8000); |
|
49 |
} |
|
50 |
|
|
51 |
return NULL; |
|
52 |
} |
|
53 |
|
|
54 |
int main(int argc,char* argv[]){ |
|
55 |
|
|
56 |
CG4Trk trk; |
|
57 |
REND_STRUCT rs; |
e9b870
|
58 |
string cfgFile; |
JS |
59 |
string oscSink; |
929277
|
60 |
|
e9b870
|
61 |
auto cli = ( |
JS |
62 |
value("c4g configuration file", cfgFile), |
|
63 |
value("osc sink", oscSink) |
|
64 |
); |
929277
|
65 |
|
e9b870
|
66 |
if(!parse(argc, argv, cli)) { |
JS |
67 |
cout << make_man_page(cli, argv[0]); |
|
68 |
return 1; |
|
69 |
} |
929277
|
70 |
memset(rs.viewTrans,0,sizeof(float)*3); |
JS |
71 |
rs.srcScale=rs.senScale=0.5; |
|
72 |
rs.counter=0; |
|
73 |
|
|
74 |
cfgFile="config.g4c"; |
e9b870
|
75 |
int resp=trk.Connect(const_cast<char*>(cfgFile.c_str())); // whaaaaa |
929277
|
76 |
if (!resp){ |
JS |
77 |
printf("Error Connecting to G4\n"); |
|
78 |
return -1; |
|
79 |
} |
|
80 |
|
|
81 |
usleep(500000); |
|
82 |
rs.numSrc=trk.GetNumSrc(); |
|
83 |
rs.srcList=new float[rs.numSrc][6]; |
|
84 |
trk.GetSrcLoc(rs.srcList); |
|
85 |
|
|
86 |
rs.numHub=trk.UpdateHubs(); |
|
87 |
rs.hubList=new CG4Hub[rs.numHub]; |
|
88 |
int* hubIds=new int[rs.numHub]; |
|
89 |
trk.GetHubList(hubIds,rs.numHub); |
|
90 |
for (int i=0;i<rs.numHub;i++){ |
|
91 |
rs.hubList[i].SetId(hubIds[i]); |
|
92 |
} |
|
93 |
delete[] hubIds; |
|
94 |
|
|
95 |
rs.pTrk=&trk; |
|
96 |
|
|
97 |
RunCollect=1; |
|
98 |
|
|
99 |
Collect(&rs); |
|
100 |
|
|
101 |
delete[] rs.srcList; |
|
102 |
delete[] rs.hubList; |
|
103 |
|
|
104 |
return 0; |
|
105 |
} |
|
106 |
|