Adu5Sat.cxx
1 
9 #include "Adu5Sat.h"
10 #include "AnitaPacketUtil.h"
11 #include <iostream>
12 #include <fstream>
13 #include <cstring>
14 #include "TPad.h"
15 #include "TEllipse.h"
16 #include "TLine.h"
17 #include "TLatex.h"
18 #include "TMath.h"
19 #include "TMarker.h"
20 
21 ClassImp(Adu5Sat);
22 
23 Adu5Sat::Adu5Sat()
24 {
25  //Default Constructor
26 }
27 
28 Adu5Sat::~Adu5Sat() {
29  //Default Destructor
30 }
31 
32 Adu5Sat::Adu5Sat(Int_t trun,
33  UInt_t trealTime,
34  GpsAdu5SatStruct_t *gpsStruct)
35 {
36  simplePacketCheck(&(gpsStruct->gHdr),PACKET_GPS_ADU5_SAT);
37  run=trun;
38  realTime=trealTime;
39  payloadTime=gpsStruct->unixTime;
40  for(int ant=0;ant<4;ant++) {
41  numSats[ant]=gpsStruct->numSats[ant];
42  for(int i=0;i<MAX_SATS;i++) {
43  prn[ant][i]=gpsStruct->sat[ant][i].prn;
44  elevation[ant][i]=gpsStruct->sat[ant][i].elevation;
45  snr[ant][i]=gpsStruct->sat[ant][i].snr;
46  flag[ant][i]=gpsStruct->sat[ant][i].flag;
47  azimuth[ant][i]=gpsStruct->sat[ant][i].azimuth;
48  }
49  }
50 
51 }
52 
53 
54 void Adu5Sat::getCirclePlot(TPad *padSat, const char *title)
55 {
56  padSat->cd();
57  TEllipse *lippy = new TEllipse();
58  lippy->SetFillColor(0);
59  lippy->SetFillStyle(0);
60  lippy->DrawEllipse(0.5,0.5,0.45*TMath::Cos(TMath::DegToRad()*10),0,0,360,0);
61  lippy->DrawEllipse(0.5,0.5,0.45*TMath::Cos(TMath::DegToRad()*20),0,0,360,0);
62  lippy->DrawEllipse(0.5,0.5,0.45*TMath::Cos(TMath::DegToRad()*30),0,0,360,0);
63  lippy->DrawEllipse(0.5,0.5,0.45*TMath::Cos(TMath::DegToRad()*40),0,0,360,0);
64  lippy->DrawEllipse(0.5,0.5,0.45*TMath::Cos(TMath::DegToRad()*50),0,0,360,0);
65  lippy->DrawEllipse(0.5,0.5,0.45*TMath::Cos(TMath::DegToRad()*60),0,0,360,0);
66  lippy->DrawEllipse(0.5,0.5,0.45*TMath::Cos(TMath::DegToRad()*70),0,0,360,0);
67  lippy->DrawEllipse(0.5,0.5,0.45*TMath::Cos(TMath::DegToRad()*80),0,0,360,0);
68  lippy->DrawEllipse(0.5,0.5,0.45*TMath::Cos(TMath::DegToRad()*90),0,0,360,0);
69 
70 
71  TLine *liney = new TLine();
72  liney->SetLineStyle(1);
73  liney->DrawLineNDC(0.03,0.5,0.97,0.5);
74  liney->DrawLineNDC(0.5,0.03,0.5,0.97);
75 
76  TLatex *texy = new TLatex();
77  texy->SetTextSize(0.08);
78  if(title)
79  texy->DrawTextNDC(0.02,0.93,title);
80  else
81  texy->DrawTextNDC(0.02,0.93,"ADU5");
82 
83  Int_t markers[4]={29,23,26,28};
84 
85  TMarker *satty = new TMarker();
86  for(int ant=0;ant<4;ant++) {
87  for(int i=0;i<(int)numSats[ant];i++) {
88  if(snr[ant][i]<30)
89  satty->SetMarkerColor(kRed);
90  else if(snr[ant][i]<40)
91  satty->SetMarkerColor(kOrange);
92  else
93  satty->SetMarkerColor(kGreen);
94  satty->SetMarkerStyle(markers[ant]);
95  satty->SetMarkerSize(2.5);
96  Double_t r=0.45*TMath::Cos(TMath::DegToRad()*elevation[ant][i]);
97  Double_t x=0.5+r*TMath::Cos(TMath::DegToRad()*azimuth[ant][i]);
98  Double_t y=0.5+r*TMath::Sin(TMath::DegToRad()*azimuth[ant][i]);
99  // std::cout << x << "\t" << y << std::endl;
100  satty->DrawMarker(x,y);
101  }
102  }
103 }
104 
105 
106 
107 int Adu5Sat::getNumSats(int whichAnt)
108 {
109  if(whichAnt>=0 && whichAnt<4)
110  return numSats[whichAnt];
111  return 0;
112 }
113 
114 int Adu5Sat::getPRN(int whichAnt,int whichSat)
115 {
116  if(whichAnt>=0 && whichAnt<4)
117  if(whichSat<numSats[whichAnt])
118  return prn[whichAnt][whichSat];
119  return 0;
120 
121 }
122 
123 int Adu5Sat::getSNR(int whichAnt,int whichSat)
124 {
125 
126  if(whichAnt>=0 && whichAnt<4)
127  if(whichSat<numSats[whichAnt])
128  return snr[whichAnt][whichSat];
129  return 0;
130 }
131 
132 int Adu5Sat::getElevation(int whichAnt,int whichSat)
133 {
134  if(whichAnt>=0 && whichAnt<4)
135  if(whichSat<numSats[whichAnt])
136  return elevation[whichAnt][whichSat];
137  return 0;
138 }
139 
140 int Adu5Sat::getAzimuth(int whichAnt,int whichSat)
141 {
142  if(whichAnt>=0 && whichAnt<4)
143  if(whichSat<numSats[whichAnt])
144  return azimuth[whichAnt][whichSat];
145  return 0;
146 }
147 
148 int Adu5Sat::getFlag(int whichAnt,int whichSat)
149 {
150  if(whichAnt>=0 && whichAnt<4)
151  if(whichSat<numSats[whichAnt])
152  return flag[whichAnt][whichSat];
153  return 0;
154 }
UShort_t azimuth[4][12]
The azimuth of each visible satellite.
Definition: Adu5Sat.h:41
Adu5Sat – The ADU5 Satellite Information.
Definition: Adu5Sat.h:23
ADU5 Satellite Info – Telemetered.
void getCirclePlot(TPad *padSat, const char *title=0)
Creates a 2D elevation-azimuth plot.
Definition: Adu5Sat.cxx:54
UChar_t flag[4][12]
The usability flag of each visible satellite.
Definition: Adu5Sat.h:40
UInt_t numSats[4]
The number of satellites each of the antennas can see.
Definition: Adu5Sat.h:36
UChar_t elevation[4][12]
The elevation of each visible satellite.
Definition: Adu5Sat.h:38
UChar_t snr[4][12]
The SNR of each visible satellite.
Definition: Adu5Sat.h:39
GpsAdu5SatStruct_t – Yes.
UChar_t prn[4][12]
The PRN of each visible satellite.
Definition: Adu5Sat.h:37
int simplePacketCheck(GenericHeader_t *gHdr, PacketCode_t code)
simplePacketCheck – utility function