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