Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:39

0001 #include <packet_cdevmadch.h>
0002 #include <time.h>
0003 #include <stdio.h>
0004 Packet_cdevmadch::Packet_cdevmadch(PACKET_ptr data)
0005   : Packet_w4 (data)
0006 {
0007   ps = 0;
0008 }
0009   
0010 int *Packet_cdevmadch::decode ( int *nwout)
0011 {
0012 
0013   if (ps != 0) return 0; 
0014  int il = getDataLength();
0015   no_structures = 4* il / sizeof ( struct cdevMadchData );
0016   std::cout << "no_structures = " << no_structures << std::endl;
0017 
0018   int *k = (int *) findPacketDataStart(packet);
0019   if (k == 0) 
0020     {
0021       ps = 0;
0022       *nwout = 0;
0023       return 0;
0024     }
0025   ps = ( struct cdevMadchData *) k;
0026 
0027 
0028   //fix_endianess ( &ps->current);
0029   //fix_endianess ( ps->avgOrbPosition);
0030   //fix_endianess ( ps->avgOrbVariance);
0031   //fix_endianess ( ps->avgOrbStat);
0032 
0033 
0034   *nwout = 0;
0035 
0036   return 0;
0037 }
0038 
0039 
0040 // ------------------------------------------------------
0041 
0042 
0043 void Packet_cdevmadch::dump ( OSTREAM &os) 
0044 {
0045 
0046   int i;
0047 
0048   decode (&i);
0049 
0050   this->identify(os);
0051   os << "Number of readings: " << iValue(0,"NOREADINGS") << std::endl;
0052 
0053   os << "current " << std::endl;
0054   for ( i = 0; i < iValue(0,"NOREADINGS") ; i++)
0055     {
0056       /*
0057       os << std::setw(4 ) << i ;
0058       os << std::setw(16) << ps[i].current;
0059       os << std::endl;
0060       */
0061       
0062       printf("%d  hex current %x  current %lf\n",i,(unsigned)ps[i].current,ps[i].current);
0063       //printf("%d    current %lf\n",i,ps[i].current);
0064       
0065       /*
0066       os << std::setw(16) << dValue(i,"current");
0067       os << std::setw(16) << " int value " << iValue(i,"current");
0068       os << std::setw(16) << " time  " << iValue(i,"timestamp");
0069       os << std::endl;
0070       */
0071 
0072     }
0073 
0074   dumpErrorBlock(os);
0075   dumpDebugBlock(os);
0076 }
0077 
0078 
0079 int   Packet_cdevmadch::iValue(const int ich, const char *what)
0080 {
0081 
0082   //  std::cout << "IN  Packet_cdevmadch::rValue " << std::endl;
0083   int i;
0084   decode (&i);
0085 // Unix time
0086   if ( strcmp(what, "NOREADINGS") == 0 ) return   no_structures ;     
0087   if ( strcmp(what, "timestamp") == 0 ) return ps[ich].cdevCaptureTimeStamp;
0088 
0089   std::cout << "packet_cdevmadc::iValue error unknown datum: " << what << std::endl;
0090   return 0;
0091 }
0092 
0093 
0094 double   Packet_cdevmadch::dValue(const int ich, const char *what)
0095 {
0096 
0097 
0098   //  std::cout << "IN  Packet_cdevmadch::rValue " << std::endl;
0099   int i;
0100   decode (&i);
0101 
0102   if ( ich < 0 || ich >= no_structures ) return 0;
0103 
0104   if ( strcmp(what, "current") == 0 ) return   ps[ich].current ;
0105 
0106 
0107   std::cout << "packet_cdevmadc::dValue error unknown datum: " << what << std::endl;
0108   return 0;
0109   
0110 
0111   
0112 }
0113 
0114