ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
packet_cdevbpm.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file packet_cdevbpm.cc
1 #include <packet_cdevbpm.h>
2 #include <time.h>
3 
5  : Packet_w4 (data)
6 {
7  ps = 0;
8 }
9 
10 int *Packet_cdevbpm::decode ( int *nwout)
11 {
12 
13  if (ps != 0) return 0;
14 
15  int il = getDataLength();
16 
17  no_structures = 4* il / sizeof ( struct cdevBPMData );
18  std::cout << "no_structures = " << no_structures << std::endl;
19  int *k = (int *) findPacketDataStart(packet);
20  if (k == 0)
21  {
22  ps = 0;
23  *nwout = 0;
24  return 0;
25  }
26 
27  ps = ( struct cdevBPMData *) k;
28 
29 
30 
31  // no byte swat for floats
32  //fix_endianess ( ps->avgOrbTimeStamp);
33  //fix_endianess ( ps->avgOrbPosition);
34  //fix_endianess ( ps->avgOrbVariance);
35  //fix_endianess ( ps->avgOrbStat);
36 
37 
38  *nwout = 0;
39 
40  return 0;
41 }
42 
43 
44 // ------------------------------------------------------
45 
46 
48 {
49 
50  int i;
51 
52  decode (&i);
53 
54  this->identify(os);
55 
56  os << "Number of readings: " << iValue(0,"NOREADINGS") << std::endl;
57 
58  os << "index ";
59  os << "avgOrbTimeStamp " ;
60  os << "avgOrbPosition " ;
61  os << "argOrbVariance " ;
62  os << "argOrbStat " << std::endl;
63 
64  for ( i = 0; i < iValue(0,"NOREADINGS") ; i++)
65  {
66  os << std::setw(4 ) << i ;
67  os << std::setw(16) << iValue(i,"avgOrbTimeStamp") ;
68  os << std::setw(16) << rValue(i,"avgOrbPosition") ;
69  os << std::setw(16) << rValue(i,"avgOrbVariance") ;
70  os << std::setw(16) << rValue(i,"avgOrbStat");
71  os << std::endl;
72  }
73 
74 
75 
76  dumpErrorBlock(os);
77  dumpDebugBlock(os);
78 }
79 //-------------------------------------------------------------
80 
81 int Packet_cdevbpm::iValue(const int ich, const char *what)
82 {
83 
84  // std::cout << "IN Packet_cdevbpm::rValue " << std::endl;
85  int i;
86  decode (&i);
87 
88  if ( ich < 0 || ich >= no_structures ) return 0;
89 
90 // Unix time
91  if ( strcmp(what, "NOREADINGS") == 0 ) return no_structures ;
92  if ( strcmp(what, "avgOrbTimeStamp") == 0 ) return ps[ich].avgOrbTimeStamp ;
93  if ( strcmp(what, "datavalidMask") == 0 ) return ps[ich].datavalidMask ;
94 
95  std::cout << "packet_cdevbpm::iValue error unknown datum: " << what << std::endl;
96  return 0;
97 }
98 
99 
100 float Packet_cdevbpm::rValue(const int ich, const char *what)
101 {
102 
103 
104  // std::cout << "IN Packet_cdevbpm::rValue " << std::endl;
105  int i;
106  decode (&i);
107 
108  if ( ich < 0 || ich >= no_structures ) return 0;
109 
110 
111  if ( strcmp(what, "avgOrbPosition") == 0 ) return ps[ich].avgOrbPosition ;
112  if ( strcmp(what, "avgOrbVariance") == 0 ) return ps[ich].avgOrbVariance ;
113  if ( strcmp(what, "avgOrbStat") == 0 ) return ps[ich].avgOrbStat;
114 
115  std::cout << "packet_cdevbpm::rValue error unknown datum: " << what << std::endl;
116  return 0;
117 
118 
119 
120 }
121 
122