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